import{cg as st,q as ot,aK as ee,u as oe,F as Xe,at as Ve,b9 as we,t as ce,cd as it,I as H,bH as Y,c5 as de,s as Pe,v as me,cj as fe,aX as Ye,bJ as Oe,bz as Ae,ch as pe,ci as ze,H as Qe,cH as at,cl as lt,dh as ht}from"./index-UvaAT40e.js";import{c as ut,a as ct}from"./_commonjsHelpers-C4iS2aBk.js";import{V as dt}from"./ChildTreeSearchButton-C65ZPLlZ.js";import{L as ft}from"./LoadingSpinner-CRcacgcO.js";import{V as gt}from"./VSlider-tpXMn7rf.js";let We,nt;function pt({from_date:P,to_date:x},e){return P=Ke(P,e),x=Ke(x,e),P===null&&x!==null?P=x:P!==null&&x===null&&(x=P),{from:P,to:x}}function Ke(P,x=609){if(P)if(P.charAt(0)=="-"){let e;return P.match(/-00\d{4}-\d{2}-\d{2}T./)?(e=Ue(mt(P)),e.setFullYear(e.getFullYear()-1)):(e=Ue(P.substring(1)),e.setFullYear(e.getFullYear()+1)),{date:e,bc_ad:"before"}}else{let e=Ue(P);return e.getFullYear()==0?(e.setFullYear(e.getFullYear()-1),{date:e,bc_ad:"before"}):e.getFullYear()>x?{date:e,bc_ad:"none"}:{date:e,bc_ad:"after"}}return null}function Ue(P){return new Date(P)}function mt(P){if(console.log(P),P.length<=5&&P.charAt(0)=="-"){let x=parseInt(P.substring(1));return x+=1,String(x).padStart(4,"0")}else return P}function vt({from:P,to:x,txt:e},t){if(/^-?\d{4}$/.test(e)||t||wt(P,x)){let i=!yt(P.date,x.date);return Je(i,_t,P,x)}else{let i=!Tt(P.date,x.date);return Je(i,xt,P,x)}}function wt(P,x){return P.date.getMonth()==0&&P.date.getDate()==1&&x.date.getMonth()==11&&x.date.getDate()==31}function Je(P,x,e,t){return P?x(e)+" - "+x(t):x(e)}function yt(P,x){return P&&x&&P.getFullYear()==x.getFullYear()}function Tt(P,x){return P&&x&&P.getFullYear()==x.getFullYear()&&P.getMonth()==x.getMonth()&&P.getDate()==x.getDate()}function _t(P){return(Math.abs(P.date.getFullYear())+We("dating."+P.bc_ad)).trim()}function xt(P){return P.date.toLocaleDateString(nt)+We("dating."+P.bc_ad)}const Et=609;function St(P,x,e,t){We=e,nt=t;const{from:n,to:i}=pt(P,Et);return n===null&&i===null?"":vt({from:n,to:i,txt:P.from_txt},x)}const Pt={key:0},Rt={key:1},bt={key:0},Ct={key:1},Jt={__name:"Dating",props:{data:{type:Object,default:()=>{}},yearOnly:{type:Boolean,default:!1},asHeading:{type:Boolean,default:!1},inline:{type:Boolean,default:!1}},setup(P){const{t:x,locale:e}=st(),t=P,n=ot(()=>St(t.data,t.yearOnly,x,e));return(i,r)=>P.data?(ee(),oe("span",Pt,[P.asHeading?(ee(),oe(Xe,{key:0},[P.data.text?(ee(),oe("h5",{key:0,class:Ve(P.inline?"d-inline":"")},we(P.data.text),3)):(ee(),oe("h5",Rt,we(n.value),1))],64)):(ee(),oe(Xe,{key:1},[P.data.text?(ee(),oe("span",bt,we(P.data.text),1)):(ee(),oe("span",Ct,we(n.value),1))],64))])):ce("",!0)}};var rt={exports:{}};(function(P){//! openseadragon 5.0.0 //! Built on 2024-08-14 //! Git commit: v5.0.0-0-f28b7fc1 //! http://openseadragon.github.io //! License: http://openseadragon.github.io/license/ function x(e){return new x.Viewer(e)}(function(e){e.version={versionStr:"5.0.0",major:parseInt("5",10),minor:parseInt("0",10),revision:parseInt("0",10)};var 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"},n=Object.prototype.toString,i=Object.prototype.hasOwnProperty;e.isFunction=function(r){return e.type(r)==="function"},e.isArray=Array.isArray||function(r){return e.type(r)==="array"},e.isWindow=function(r){return r&&typeof r=="object"&&"setInterval"in r},e.type=function(r){return r==null?String(r):t[n.call(r)]||"object"},e.isPlainObject=function(r){if(!r||x.type(r)!=="object"||r.nodeType||e.isWindow(r)||r.constructor&&!i.call(r,"constructor")&&!i.call(r.constructor.prototype,"isPrototypeOf"))return!1;var a;for(var s in r)a=s;return a===void 0||i.call(r,a)},e.isEmptyObject=function(r){for(var a in r)return!1;return!0},e.freezeObject=function(r){return Object.freeze?e.freezeObject=Object.freeze:e.freezeObject=function(a){return a},e.freezeObject(r)},e.supportsCanvas=function(){var r=document.createElement("canvas");return!!(e.isFunction(r.getContext)&&r.getContext("2d"))}(),e.isCanvasTainted=function(r){var a=!1;try{r.getContext("2d").getImageData(0,0,1,1)}catch{a=!0}return a},e.supportsAddEventListener=function(){return!!(document.documentElement.addEventListener&&document.addEventListener)}(),e.supportsRemoveEventListener=function(){return!!(document.documentElement.removeEventListener&&document.removeEventListener)}(),e.supportsEventListenerOptions=function(){var r=0;if(e.supportsAddEventListener)try{var a={get capture(){return r++,!1},get once(){return r++,!1},get passive(){return r++,!1}};window.addEventListener("test",null,a),window.removeEventListener("test",null,a)}catch{r=0}return r>=3}(),e.getCurrentPixelDensityRatio=function(){if(e.supportsCanvas){var r=document.createElement("canvas").getContext("2d"),a=window.devicePixelRatio||1,s=r.webkitBackingStorePixelRatio||r.mozBackingStorePixelRatio||r.msBackingStorePixelRatio||r.oBackingStorePixelRatio||r.backingStorePixelRatio||1;return Math.max(a,1)/s}else return 1},e.pixelDensityRatio=e.getCurrentPixelDensityRatio()})(x),function(e){e.extend=function(){var s,o,l,u,d,m,v=arguments[0]||{},y=arguments.length,T=!1,_=1;for(typeof v=="boolean"&&(T=v,v=arguments[1]||{},_=2),typeof v!="object"&&!x.isFunction(v)&&(v={}),y===_&&(v=this,--_);_<y;_++)if(s=arguments[_],s!==null||s!==void 0)for(o in s){var S=Object.getOwnPropertyDescriptor(s,o);if(S!==void 0){if(S.get||S.set){Object.defineProperty(v,o,S);continue}u=S.value}else{e.console.warn('Could not copy inherited property "'+o+'".');continue}v!==u&&(T&&u&&(x.isPlainObject(u)||(d=x.isArray(u)))?(l=v[o],d?(d=!1,m=l&&x.isArray(l)?l:[]):m=l&&x.isPlainObject(l)?l:{},v[o]=x.extend(T,m,u)):u!==void 0&&(v[o]=u))}return v};var t=function(){if(typeof navigator!="object")return!1;var s=navigator.userAgent;return typeof s!="string"?!1:s.indexOf("iPhone")!==-1||s.indexOf("iPad")!==-1||s.indexOf("iPod")!==-1};e.extend(e,{DEFAULT_SETTINGS:{xmlPath:null,tileSources:null,tileHost:null,initialPage:0,crossOriginPolicy:!1,ajaxWithCredentials:!1,loadTilesWithAjax:!1,ajaxHeaders:{},splitHashDataForPost:!1,panHorizontal:!0,panVertical:!0,constrainDuringPan:!1,wrapHorizontal:!1,wrapVertical:!1,visibilityRatio:.5,minPixelRatio:.5,defaultZoomLevel:0,minZoomLevel:null,maxZoomLevel:null,homeFillsViewer:!1,clickTimeThreshold:300,clickDistThreshold:5,dblClickTimeThreshold:300,dblClickDistThreshold:20,springStiffness:6.5,animationTime:1.2,gestureSettingsMouse:{dragToPan:!0,scrollToZoom:!0,clickToZoom:!0,dblClickToZoom:!1,dblClickDragToZoom:!1,pinchToZoom:!1,zoomToRefPoint:!0,flickEnabled:!1,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsTouch:{dragToPan:!0,scrollToZoom:!1,clickToZoom:!1,dblClickToZoom:!0,dblClickDragToZoom:!0,pinchToZoom:!0,zoomToRefPoint:!0,flickEnabled:!0,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsPen:{dragToPan:!0,scrollToZoom:!1,clickToZoom:!0,dblClickToZoom:!1,dblClickDragToZoom:!1,pinchToZoom:!1,zoomToRefPoint:!0,flickEnabled:!1,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsUnknown:{dragToPan:!0,scrollToZoom:!1,clickToZoom:!1,dblClickToZoom:!0,dblClickDragToZoom:!1,pinchToZoom:!0,zoomToRefPoint:!0,flickEnabled:!0,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},zoomPerClick:2,zoomPerScroll:1.2,zoomPerDblClickDrag:1.2,zoomPerSecond:1,blendTime:0,alwaysBlend:!1,autoHideControls:!0,immediateRender:!1,minZoomImageRatio:.9,maxZoomPixelRatio:1.1,smoothTileEdgesMinZoom:1.1,iOSDevice:t(),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,showNavigator:!1,navigatorElement:null,navigatorId:null,navigatorPosition:null,navigatorSizeRatio:.2,navigatorMaintainSizeRatio:!1,navigatorTop:null,navigatorLeft:null,navigatorHeight:null,navigatorWidth:null,navigatorAutoResize:!0,navigatorAutoFade:!0,navigatorRotate:!0,navigatorBackground:"#000",navigatorOpacity:.8,navigatorBorderColor:"#555",navigatorDisplayRegionColor:"#900",degrees:0,flipped:!1,overlayPreserveContentDirection:!0,opacity:1,compositeOperation:null,drawer:["webgl","canvas","html"],drawerOptions:{webgl:{},canvas:{},html:{},custom:{}},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(s,o){return function(){var l=arguments;return l===void 0&&(l=[]),o.apply(s,l)}},BROWSERS:{UNKNOWN:0,IE:1,FIREFOX:2,SAFARI:3,CHROME:4,OPERA:5,EDGE:6,CHROMEEDGE:7},SUBPIXEL_ROUNDING_OCCURRENCES:{NEVER:0,ONLY_AT_REST:1,ALWAYS:2},_viewers:new Map,getViewer:function(s){return e._viewers.get(this.getElement(s))},getElement:function(s){return typeof s=="string"&&(s=document.getElementById(s)),s},getElementPosition:function(s){var o=new e.Point,l,u;for(s=e.getElement(s),l=e.getElementStyle(s).position==="fixed",u=a(s,l);u;)o.x+=s.offsetLeft,o.y+=s.offsetTop,l&&(o=o.plus(e.getPageScroll())),s=u,l=e.getElementStyle(s).position==="fixed",u=a(s,l);return o},getElementOffset:function(s){s=e.getElement(s);var o=s&&s.ownerDocument,l,u,d={top:0,left:0};return o?(l=o.documentElement,typeof s.getBoundingClientRect<"u"&&(d=s.getBoundingClientRect()),u=o===o.window?o:o.nodeType===9?o.defaultView||o.parentWindow:!1,new e.Point(d.left+(u.pageXOffset||l.scrollLeft)-(l.clientLeft||0),d.top+(u.pageYOffset||l.scrollTop)-(l.clientTop||0))):new e.Point},getElementSize:function(s){return s=e.getElement(s),new e.Point(s.clientWidth,s.clientHeight)},getElementStyle:document.documentElement.currentStyle?function(s){return s=e.getElement(s),s.currentStyle}:function(s){return s=e.getElement(s),window.getComputedStyle(s,"")},getCssPropertyWithVendorPrefix:function(s){var o={};return e.getCssPropertyWithVendorPrefix=function(l){if(o[l]!==void 0)return o[l];var u=document.createElement("div").style,d=null;if(u[l]!==void 0)d=l;else for(var m=["Webkit","Moz","MS","O","webkit","moz","ms","o"],v=e.capitalizeFirstLetter(l),y=0;y<m.length;y++){var T=m[y]+v;if(u[T]!==void 0){d=T;break}}return o[l]=d,d},e.getCssPropertyWithVendorPrefix(s)},capitalizeFirstLetter:function(s){return s.charAt(0).toUpperCase()+s.slice(1)},positiveModulo:function(s,o){var l=s%o;return l<0&&(l+=o),l},pointInElement:function(s,o){s=e.getElement(s);var l=e.getElementOffset(s),u=e.getElementSize(s);return o.x>=l.x&&o.x<l.x+u.x&&o.y<l.y+u.y&&o.y>=l.y},getMousePosition:function(s){if(typeof s.pageX=="number")e.getMousePosition=function(o){var l=new e.Point;return l.x=o.pageX,l.y=o.pageY,l};else if(typeof s.clientX=="number")e.getMousePosition=function(o){var l=new e.Point;return l.x=o.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,l.y=o.clientY+document.body.scrollTop+document.documentElement.scrollTop,l};else throw new Error("Unknown event mouse position, no known technique.");return e.getMousePosition(s)},getPageScroll:function(){var s=document.documentElement||{},o=document.body||{};if(typeof window.pageXOffset=="number")e.getPageScroll=function(){return new e.Point(window.pageXOffset,window.pageYOffset)};else if(o.scrollLeft||o.scrollTop)e.getPageScroll=function(){return new e.Point(document.body.scrollLeft,document.body.scrollTop)};else if(s.scrollLeft||s.scrollTop)e.getPageScroll=function(){return new e.Point(document.documentElement.scrollLeft,document.documentElement.scrollTop)};else return new e.Point(0,0);return e.getPageScroll()},setPageScroll:function(s){if(typeof window.scrollTo<"u")e.setPageScroll=function(u){window.scrollTo(u.x,u.y)};else{var o=e.getPageScroll();if(o.x===s.x&&o.y===s.y)return;document.body.scrollLeft=s.x,document.body.scrollTop=s.y;var l=e.getPageScroll();if(l.x!==o.x&&l.y!==o.y){e.setPageScroll=function(u){document.body.scrollLeft=u.x,document.body.scrollTop=u.y};return}if(document.documentElement.scrollLeft=s.x,document.documentElement.scrollTop=s.y,l=e.getPageScroll(),l.x!==o.x&&l.y!==o.y){e.setPageScroll=function(u){document.documentElement.scrollLeft=u.x,document.documentElement.scrollTop=u.y};return}e.setPageScroll=function(u){}}e.setPageScroll(s)},getWindowSize:function(){var s=document.documentElement||{},o=document.body||{};if(typeof window.innerWidth=="number")e.getWindowSize=function(){return new e.Point(window.innerWidth,window.innerHeight)};else if(s.clientWidth||s.clientHeight)e.getWindowSize=function(){return new e.Point(document.documentElement.clientWidth,document.documentElement.clientHeight)};else if(o.clientWidth||o.clientHeight)e.getWindowSize=function(){return new e.Point(document.body.clientWidth,document.body.clientHeight)};else throw new Error("Unknown window size, no known technique.");return e.getWindowSize()},makeCenteredNode:function(s){s=e.getElement(s);var o=[e.makeNeutralElement("div"),e.makeNeutralElement("div"),e.makeNeutralElement("div")];return e.extend(o[0].style,{display:"table",height:"100%",width:"100%"}),e.extend(o[1].style,{display:"table-row"}),e.extend(o[2].style,{display:"table-cell",verticalAlign:"middle",textAlign:"center"}),o[0].appendChild(o[1]),o[1].appendChild(o[2]),o[2].appendChild(s),o[0]},makeNeutralElement:function(s){var o=document.createElement(s),l=o.style;return l.background="transparent none",l.border="none",l.margin="0px",l.padding="0px",l.position="static",o},now:function(){return Date.now?e.now=Date.now:e.now=function(){return new Date().getTime()},e.now()},makeTransparentImage:function(s){var o=e.makeNeutralElement("img");return o.src=s,o},setElementOpacity:function(s,o,l){var u,d;s=e.getElement(s),l&&!e.Browser.alpha&&(o=Math.round(o)),e.Browser.opacity?s.style.opacity=o<1?o:"":o<1?(u=Math.round(100*o),d="alpha(opacity="+u+")",s.style.filter=d):s.style.filter=""},setElementTouchActionNone:function(s){s=e.getElement(s),typeof s.style.touchAction<"u"?s.style.touchAction="none":typeof s.style.msTouchAction<"u"&&(s.style.msTouchAction="none")},setElementPointerEvents:function(s,o){s=e.getElement(s),typeof s.style<"u"&&typeof s.style.pointerEvents<"u"&&(s.style.pointerEvents=o)},setElementPointerEventsNone:function(s){e.setElementPointerEvents(s,"none")},addClass:function(s,o){s=e.getElement(s),s.className?(" "+s.className+" ").indexOf(" "+o+" ")===-1&&(s.className+=" "+o):s.className=o},indexOf:function(s,o,l){return Array.prototype.indexOf?this.indexOf=function(u,d,m){return u.indexOf(d,m)}:this.indexOf=function(u,d,m){var v,y=m||0,T;if(!u)throw new TypeError;if(T=u.length,T===0||y>=T)return-1;for(y<0&&(y=T-Math.abs(y)),v=y;v<T;v++)if(u[v]===d)return v;return-1},this.indexOf(s,o,l)},removeClass:function(s,o){var l,u=[],d;for(s=e.getElement(s),l=s.className.split(/\s+/),d=0;d<l.length;d++)l[d]&&l[d]!==o&&u.push(l[d]);s.className=u.join(" ")},normalizeEventListenerOptions:function(s){var o;return typeof s<"u"?typeof s=="boolean"?o=e.supportsEventListenerOptions?{capture:s}:s:o=e.supportsEventListenerOptions?s:typeof s.capture<"u"?s.capture:!1:o=e.supportsEventListenerOptions?{capture:!1}:!1,o},addEvent:function(){if(e.supportsAddEventListener)return function(s,o,l,u){u=e.normalizeEventListenerOptions(u),s=e.getElement(s),s.addEventListener(o,l,u)};if(document.documentElement.attachEvent&&document.attachEvent)return function(s,o,l){s=e.getElement(s),s.attachEvent("on"+o,l)};throw new Error("No known event model.")}(),removeEvent:function(){if(e.supportsRemoveEventListener)return function(s,o,l,u){u=e.normalizeEventListenerOptions(u),s=e.getElement(s),s.removeEventListener(o,l,u)};if(document.documentElement.detachEvent&&document.detachEvent)return function(s,o,l){s=e.getElement(s),s.detachEvent("on"+o,l)};throw new Error("No known event model.")}(),cancelEvent:function(s){s.preventDefault()},eventIsCanceled:function(s){return s.defaultPrevented},stopEvent:function(s){s.stopPropagation()},createCallback:function(s,o){console.error("The createCallback function is deprecated and will be removed in future versions. Please use alternativeFunction instead.");var l=[],u;for(u=2;u<arguments.length;u++)l.push(arguments[u]);return function(){var d=l.concat([]),m;for(m=0;m<arguments.length;m++)d.push(arguments[m]);return o.apply(s,d)}},getUrlParameter:function(s){var o=r[s];return o||null},getUrlProtocol:function(s){var o=s.match(/^([a-z]+:)\/\//i);return o===null?window.location.protocol:o[1].toLowerCase()},createAjaxRequest:function(){if(window.XMLHttpRequest)return e.createAjaxRequest=function(){return new XMLHttpRequest},new XMLHttpRequest;throw new Error("Browser doesn't support XMLHttpRequest.")},makeAjaxRequest:function(s,o,l){var u,d,m,v;e.isPlainObject(s)&&(o=s.success,l=s.error,u=s.withCredentials,d=s.headers,m=s.responseType||null,v=s.postData||null,s=s.url);var y=e.getUrlProtocol(s),T=e.createAjaxRequest();if(!e.isFunction(o))throw new Error("makeAjaxRequest requires a success callback");T.onreadystatechange=function(){T.readyState===4&&(T.onreadystatechange=function(){},T.status>=200&&T.status<300||T.status===0&&y!=="http:"&&y!=="https:"?o(T):e.isFunction(l)?l(T):e.console.error("AJAX request returned %d: %s",T.status,s))};var _=v?"POST":"GET";try{if(T.open(_,s,!0),m&&(T.responseType=m),d)for(var S in d)Object.prototype.hasOwnProperty.call(d,S)&&d[S]&&T.setRequestHeader(S,d[S]);u&&(T.withCredentials=!0),T.send(v)}catch(b){e.console.error("%s while making AJAX request: %s",b.name,b.message),T.onreadystatechange=function(){},e.isFunction(l)&&l(T,b)}return T},jsonp:function(s){var o,l=s.url,u=document.head||document.getElementsByTagName("head")[0]||document.documentElement,d=s.callbackName||"openseadragon"+e.now(),m=window[d],v="$1"+d+"$2",y=s.param||"callback",T=s.callback;l=l.replace(/(=)\?(&|$)|\?\?/i,v),l+=(/\?/.test(l)?"&":"?")+y+"="+d,window[d]=function(_){if(m)window[d]=m;else try{delete window[d]}catch{}T&&e.isFunction(T)&&T(_)},o=document.createElement("script"),(s.async!==void 0||s.async!==!1)&&(o.async="async"),s.scriptCharset&&(o.charset=s.scriptCharset),o.src=l,o.onload=o.onreadystatechange=function(_,S){(S||!o.readyState||/loaded|complete/.test(o.readyState))&&(o.onload=o.onreadystatechange=null,u&&o.parentNode&&u.removeChild(o),o=void 0)},u.insertBefore(o,u.firstChild)},createFromDZI:function(){throw"OpenSeadragon.createFromDZI is deprecated, use Viewer.open."},parseXml:function(s){if(window.DOMParser)e.parseXml=function(o){var l=null,u;return u=new DOMParser,l=u.parseFromString(o,"text/xml"),l};else throw new Error("Browser doesn't support XML DOM.");return e.parseXml(s)},parseJSON:function(s){return e.parseJSON=window.JSON.parse,e.parseJSON(s)},imageFormatSupported:function(s){return s=s||"",!!i[s.toLowerCase()]},setImageFormatsSupported:function(s){e.extend(i,s)}});var n=function(s){};e.console=window.console||{log:n,debug:n,info:n,warn:n,error:n,assert:n},e.Browser={vendor:e.BROWSERS.UNKNOWN,version:0,alpha:!0};var i={avif:!0,bmp:!1,jpeg:!0,jpg:!0,png:!0,tif:!1,wdp:!1,webp:!0},r={};(function(){var s=navigator.appVersion,o=navigator.userAgent,l;switch(navigator.appName){case"Microsoft Internet Explorer":window.attachEvent&&window.ActiveXObject&&(e.Browser.vendor=e.BROWSERS.IE,e.Browser.version=parseFloat(o.substring(o.indexOf("MSIE")+5,o.indexOf(";",o.indexOf("MSIE")))));break;case"Netscape":window.addEventListener&&(o.indexOf("Edge")>=0?(e.Browser.vendor=e.BROWSERS.EDGE,e.Browser.version=parseFloat(o.substring(o.indexOf("Edge")+5))):o.indexOf("Edg")>=0?(e.Browser.vendor=e.BROWSERS.CHROMEEDGE,e.Browser.version=parseFloat(o.substring(o.indexOf("Edg")+4))):o.indexOf("Firefox")>=0?(e.Browser.vendor=e.BROWSERS.FIREFOX,e.Browser.version=parseFloat(o.substring(o.indexOf("Firefox")+8))):o.indexOf("Safari")>=0?(e.Browser.vendor=o.indexOf("Chrome")>=0?e.BROWSERS.CHROME:e.BROWSERS.SAFARI,e.Browser.version=parseFloat(o.substring(o.substring(0,o.indexOf("Safari")).lastIndexOf("/")+1,o.indexOf("Safari")))):(l=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})"),l.exec(o)!==null&&(e.Browser.vendor=e.BROWSERS.IE,e.Browser.version=parseFloat(RegExp.$1))));break;case"Opera":e.Browser.vendor=e.BROWSERS.OPERA,e.Browser.version=parseFloat(s);break}var u=window.location.search.substring(1),d=u.split("&"),m,v,y;for(y=0;y<d.length;y++)if(m=d[y],v=m.indexOf("="),v>0){var T=m.substring(0,v),_=m.substring(v+1);try{r[T]=decodeURIComponent(_)}catch{e.console.error("Ignoring malformed URL parameter: %s=%s",T,_)}}e.Browser.alpha=!(e.Browser.vendor===e.BROWSERS.CHROME&&e.Browser.version<2),e.Browser.opacity=!0,e.Browser.vendor===e.BROWSERS.IE&&e.console.error("Internet Explorer is not supported by OpenSeadragon")})(),function(s){var o=s.requestAnimationFrame||s.mozRequestAnimationFrame||s.webkitRequestAnimationFrame||s.msRequestAnimationFrame,l=s.cancelAnimationFrame||s.mozCancelAnimationFrame||s.webkitCancelAnimationFrame||s.msCancelAnimationFrame;if(o&&l)e.requestAnimationFrame=function(){return o.apply(s,arguments)},e.cancelAnimationFrame=function(){return l.apply(s,arguments)};else{var u=[],d=[],m=0,v;e.requestAnimationFrame=function(y){return u.push([++m,y]),v||(v=setInterval(function(){if(u.length){var T=e.now(),_=d;for(d=u,u=_;d.length;)d.shift()[1](T)}else clearInterval(v),v=void 0},1e3/50)),m},e.cancelAnimationFrame=function(y){var T,_;for(T=0,_=u.length;T<_;T+=1)if(u[T][0]===y){u.splice(T,1);return}for(T=0,_=d.length;T<_;T+=1)if(d[T][0]===y){d.splice(T,1);return}}}}(window);function a(s,o){return o&&s!==document.body?document.body:s.offsetParent}}(x),function(e,t){P.exports?P.exports=t():e.OpenSeadragon=t()}(ut,function(){return x}),function(e){class t{constructor(i){i||(i=[0,0,0,0,0,0,0,0,0]),this.values=i}static makeIdentity(){return new t([1,0,0,0,1,0,0,0,1])}static makeTranslation(i,r){return new t([1,0,0,0,1,0,i,r,1])}static makeRotation(i){var r=Math.cos(i),a=Math.sin(i);return new t([r,-a,0,a,r,0,0,0,1])}static makeScaling(i,r){return new t([i,0,0,0,r,0,0,0,1])}multiply(i){let r=this.values,a=i.values;var s=r[0*3+0],o=r[0*3+1],l=r[0*3+2],u=r[1*3+0],d=r[1*3+1],m=r[1*3+2],v=r[2*3+0],y=r[2*3+1],T=r[2*3+2],_=a[0*3+0],S=a[0*3+1],b=a[0*3+2],L=a[1*3+0],I=a[1*3+1],M=a[1*3+2],Z=a[2*3+0],V=a[2*3+1],j=a[2*3+2];return new t([_*s+S*u+b*v,_*o+S*d+b*y,_*l+S*m+b*T,L*s+I*u+M*v,L*o+I*d+M*y,L*l+I*m+M*T,Z*s+V*u+j*v,Z*o+V*d+j*y,Z*l+V*m+j*T])}}e.Mat3=t}(x),function(e){var t={supportsFullScreen:!1,isFullScreen:function(){return!1},getFullScreenElement:function(){return null},requestFullScreen:function(){},exitFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",fullScreenErrorEventName:""};document.exitFullscreen?(t.supportsFullScreen=!0,t.getFullScreenElement=function(){return document.fullscreenElement},t.requestFullScreen=function(n){return n.requestFullscreen().catch(function(i){e.console.error("Fullscreen request failed: ",i)})},t.exitFullScreen=function(){document.exitFullscreen().catch(function(n){e.console.error("Error while exiting fullscreen: ",n)})},t.fullScreenEventName="fullscreenchange",t.fullScreenErrorEventName="fullscreenerror"):document.msExitFullscreen?(t.supportsFullScreen=!0,t.getFullScreenElement=function(){return document.msFullscreenElement},t.requestFullScreen=function(n){return n.msRequestFullscreen()},t.exitFullScreen=function(){document.msExitFullscreen()},t.fullScreenEventName="MSFullscreenChange",t.fullScreenErrorEventName="MSFullscreenError"):document.webkitExitFullscreen?(t.supportsFullScreen=!0,t.getFullScreenElement=function(){return document.webkitFullscreenElement},t.requestFullScreen=function(n){return n.webkitRequestFullscreen()},t.exitFullScreen=function(){document.webkitExitFullscreen()},t.fullScreenEventName="webkitfullscreenchange",t.fullScreenErrorEventName="webkitfullscreenerror"):document.webkitCancelFullScreen?(t.supportsFullScreen=!0,t.getFullScreenElement=function(){return document.webkitCurrentFullScreenElement},t.requestFullScreen=function(n){return n.webkitRequestFullScreen()},t.exitFullScreen=function(){document.webkitCancelFullScreen()},t.fullScreenEventName="webkitfullscreenchange",t.fullScreenErrorEventName="webkitfullscreenerror"):document.mozCancelFullScreen&&(t.supportsFullScreen=!0,t.getFullScreenElement=function(){return document.mozFullScreenElement},t.requestFullScreen=function(n){return n.mozRequestFullScreen()},t.exitFullScreen=function(){document.mozCancelFullScreen()},t.fullScreenEventName="mozfullscreenchange",t.fullScreenErrorEventName="mozfullscreenerror"),t.isFullScreen=function(){return t.getFullScreenElement()!==null},t.cancelFullScreen=function(){e.console.error("cancelFullScreen is deprecated. Use exitFullScreen instead."),t.exitFullScreen()},e.extend(e,t)}(x),function(e){e.EventSource=function(){this.events={},this._rejectedEventList={}},e.EventSource.prototype={addOnceHandler:function(t,n,i,r,a){var s=this;r=r||1;var o=0,l=function(u){return o++,o===r&&s.removeHandler(t,l),n(u)};return this.addHandler(t,l,i,a)},addHandler:function(t,n,i,r){if(Object.prototype.hasOwnProperty.call(this._rejectedEventList,t))return e.console.error(`Error adding handler for ${t}. ${this._rejectedEventList[t]}`),!1;var a=this.events[t];if(a||(this.events[t]=a=[]),n&&e.isFunction(n)){var s=a.length,o={handler:n,userData:i||null,priority:r||0};for(a[s]=o;s>0&&a[s-1].priority<a[s].priority;)a[s]=a[s-1],a[s-1]=o,s--}return!0},removeHandler:function(t,n){var i=this.events[t],r=[],a;if(i&&e.isArray(i)){for(a=0;a<i.length;a++)i[a].handler!==n&&r.push(i[a]);this.events[t]=r}},numberOfHandlers:function(t){var n=this.events[t];return n?n.length:0},removeAllHandlers:function(t){if(t)this.events[t]=[];else for(var n in this.events)this.events[n]=[]},getHandler:function(t){var n=this.events[t];return!n||!n.length?null:(n=n.length===1?[n[0]]:Array.apply(null,n),function(i,r){var a,s=n.length;for(a=0;a<s;a++)n[a]&&(r.eventSource=i,r.userData=n[a].userData,n[a].handler(r))})},raiseEvent:function(t,n){if(Object.prototype.hasOwnProperty.call(this._rejectedEventList,t))return e.console.error(`Error adding handler for ${t}. ${this._rejectedEventList[t]}`),!1;var i=this.getHandler(t);return i&&i(this,n||{}),!0},rejectEventHandler(t,n=""){this._rejectedEventList[t]=n},allowEventHandler(t){delete this._rejectedEventList[t]}}}(x),function(e){var t={};e.MouseTracker=function(f){var c=arguments;e.isPlainObject(f)||(f={element:c[0],clickTimeThreshold:c[1],clickDistThreshold:c[2]}),this.hash=Math.random(),this.element=e.getElement(f.element),this.clickTimeThreshold=f.clickTimeThreshold||e.DEFAULT_SETTINGS.clickTimeThreshold,this.clickDistThreshold=f.clickDistThreshold||e.DEFAULT_SETTINGS.clickDistThreshold,this.dblClickTimeThreshold=f.dblClickTimeThreshold||e.DEFAULT_SETTINGS.dblClickTimeThreshold,this.dblClickDistThreshold=f.dblClickDistThreshold||e.DEFAULT_SETTINGS.dblClickDistThreshold,this.userData=f.userData||null,this.stopDelay=f.stopDelay||50,this.preProcessEventHandler=f.preProcessEventHandler||null,this.contextMenuHandler=f.contextMenuHandler||null,this.enterHandler=f.enterHandler||null,this.leaveHandler=f.leaveHandler||null,this.exitHandler=f.exitHandler||null,this.overHandler=f.overHandler||null,this.outHandler=f.outHandler||null,this.pressHandler=f.pressHandler||null,this.nonPrimaryPressHandler=f.nonPrimaryPressHandler||null,this.releaseHandler=f.releaseHandler||null,this.nonPrimaryReleaseHandler=f.nonPrimaryReleaseHandler||null,this.moveHandler=f.moveHandler||null,this.scrollHandler=f.scrollHandler||null,this.clickHandler=f.clickHandler||null,this.dblClickHandler=f.dblClickHandler||null,this.dragHandler=f.dragHandler||null,this.dragEndHandler=f.dragEndHandler||null,this.pinchHandler=f.pinchHandler||null,this.stopHandler=f.stopHandler||null,this.keyDownHandler=f.keyDownHandler||null,this.keyUpHandler=f.keyUpHandler||null,this.keyHandler=f.keyHandler||null,this.focusHandler=f.focusHandler||null,this.blurHandler=f.blurHandler||null;var g=this;t[this.hash]={click:function(w){b(g,w)},dblclick:function(w){L(g,w)},keydown:function(w){I(g,w)},keyup:function(w){M(g,w)},keypress:function(w){Z(g,w)},focus:function(w){V(g,w)},blur:function(w){j(g,w)},contextmenu:function(w){J(g,w)},wheel:function(w){W(g,w)},mousewheel:function(w){U(g,w)},DOMMouseScroll:function(w){U(g,w)},MozMousePixelScroll:function(w){U(g,w)},losecapture:function(w){ne(g,w)},mouseenter:function(w){G(g,w)},mouseleave:function(w){Re(g,w)},mouseover:function(w){be(g,w)},mouseout:function(w){Ce(g,w)},mousedown:function(w){_e(g,w)},mouseup:function(w){De(g,w)},mousemove:function(w){Be(g,w)},touchstart:function(w){te(g,w)},touchend:function(w){se(g,w)},touchmove:function(w){re(g,w)},touchcancel:function(w){ge(g,w)},gesturestart:function(w){ye(g,w)},gesturechange:function(w){ve(g,w)},gotpointercapture:function(w){Me(g,w)},lostpointercapture:function(w){Le(g,w)},pointerenter:function(w){G(g,w)},pointerleave:function(w){Re(g,w)},pointerover:function(w){be(g,w)},pointerout:function(w){Ce(g,w)},pointerdown:function(w){_e(g,w)},pointerup:function(w){De(g,w)},pointermove:function(w){Be(g,w)},pointercancel:function(w){Ne(g,w)},pointerupcaptured:function(w){He(g,w)},pointermovecaptured:function(w){ke(g,w)},tracking:!1,activePointersLists:[],lastClickPos:null,dblClickTimeOut:null,pinchGPoints:[],lastPinchDist:0,currentPinchDist:0,lastPinchCenter:null,currentPinchCenter:null,sentDragEvent:!1},this.hasGestureHandlers=!!(this.pressHandler||this.nonPrimaryPressHandler||this.releaseHandler||this.nonPrimaryReleaseHandler||this.clickHandler||this.dblClickHandler||this.dragHandler||this.dragEndHandler||this.pinchHandler),this.hasScrollHandler=!!this.scrollHandler,e.MouseTracker.havePointerEvents&&e.setElementPointerEvents(this.element,"auto"),this.exitHandler&&e.console.error("MouseTracker.exitHandler is deprecated. Use MouseTracker.leaveHandler instead."),f.startDisabled||this.setTracking(!0)},e.MouseTracker.prototype={destroy:function(){s(this),this.element=null,t[this.hash]=null,delete t[this.hash]},isTracking:function(){return t[this.hash].tracking},setTracking:function(f){return f?a(this):s(this),this},getActivePointersListByType:function(f){var c=t[this.hash],g,w=c?c.activePointersLists.length:0,R;for(g=0;g<w;g++)if(c.activePointersLists[g].type===f)return c.activePointersLists[g];return R=new e.MouseTracker.GesturePointList(f),c&&c.activePointersLists.push(R),R},getActivePointerCount:function(){var f=t[this.hash],c,g=f.activePointersLists.length,w=0;for(c=0;c<g;c++)w+=f.activePointersLists[c].getLength();return w},preProcessEventHandler:function(){},contextMenuHandler:function(){},enterHandler:function(){},leaveHandler:function(){},exitHandler:function(){},overHandler:function(){},outHandler:function(){},pressHandler:function(){},nonPrimaryPressHandler:function(){},releaseHandler:function(){},nonPrimaryReleaseHandler:function(){},moveHandler:function(){},scrollHandler:function(){},clickHandler:function(){},dblClickHandler:function(){},dragHandler:function(){},dragEndHandler:function(){},pinchHandler:function(){},stopHandler:function(){},keyDownHandler:function(){},keyUpHandler:function(){},keyHandler:function(){},focusHandler:function(){},blurHandler:function(){}};var n=function(){try{return window.self!==window.top}catch{return!0}}();function i(f){try{return f.addEventListener&&f.removeEventListener}catch{return!1}}e.MouseTracker.gesturePointVelocityTracker=function(){var f=[],c=0,g=0,w=function(X,z){return X.hash.toString()+z.type+z.id.toString()},R=function(){var X,z=f.length,le,ie,Ee=e.now(),je,qe,Ze;for(je=Ee-g,g=Ee,X=0;X<z;X++)le=f[X],ie=le.gPoint,ie.direction=Math.atan2(ie.currentPos.y-le.lastPos.y,ie.currentPos.x-le.lastPos.x),qe=le.lastPos.distanceTo(ie.currentPos),le.lastPos=ie.currentPos,Ze=1e3*qe/(je+1),ie.speed=.75*Ze+.25*ie.speed},F=function(X,z){var le=w(X,z);f.push({guid:le,gPoint:z,lastPos:z.currentPos}),f.length===1&&(g=e.now(),c=window.setInterval(R,50))},A=function(X,z){var le=w(X,z),ie,Ee=f.length;for(ie=0;ie<Ee;ie++)if(f[ie].guid===le){f.splice(ie,1),Ee--,Ee===0&&window.clearInterval(c);break}};return{addPoint:F,removePoint:A}}(),e.MouseTracker.captureElement=document,e.MouseTracker.wheelEventName="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll",e.MouseTracker.subscribeEvents=["click","dblclick","keydown","keyup","keypress","focus","blur","contextmenu",e.MouseTracker.wheelEventName],e.MouseTracker.wheelEventName==="DOMMouseScroll"&&e.MouseTracker.subscribeEvents.push("MozMousePixelScroll"),window.PointerEvent?(e.MouseTracker.havePointerEvents=!0,e.MouseTracker.subscribeEvents.push("pointerenter","pointerleave","pointerover","pointerout","pointerdown","pointerup","pointermove","pointercancel"),e.MouseTracker.havePointerCapture=function(){var f=document.createElement("div");return e.isFunction(f.setPointerCapture)&&e.isFunction(f.releasePointerCapture)}(),e.MouseTracker.havePointerCapture&&e.MouseTracker.subscribeEvents.push("gotpointercapture","lostpointercapture")):(e.MouseTracker.havePointerEvents=!1,e.MouseTracker.subscribeEvents.push("mouseenter","mouseleave","mouseover","mouseout","mousedown","mouseup","mousemove"),e.MouseTracker.mousePointerId="legacy-mouse",e.MouseTracker.havePointerCapture=function(){var f=document.createElement("div");return e.isFunction(f.setCapture)&&e.isFunction(f.releaseCapture)}(),e.MouseTracker.havePointerCapture&&e.MouseTracker.subscribeEvents.push("losecapture"),"ontouchstart"in window&&e.MouseTracker.subscribeEvents.push("touchstart","touchend","touchmove","touchcancel"),"ongesturestart"in window&&e.MouseTracker.subscribeEvents.push("gesturestart","gesturechange")),e.MouseTracker.GesturePointList=function(f){this._gPoints=[],this.type=f,this.buttons=0,this.contacts=0,this.clicks=0,this.captureCount=0},e.MouseTracker.GesturePointList.prototype={getLength:function(){return this._gPoints.length},asArray:function(){return this._gPoints},add:function(f){return this._gPoints.push(f)},removeById:function(f){var c,g=this._gPoints.length;for(c=0;c<g;c++)if(this._gPoints[c].id===f){this._gPoints.splice(c,1);break}return this._gPoints.length},getByIndex:function(f){return f<this._gPoints.length?this._gPoints[f]:null},getById:function(f){var c,g=this._gPoints.length;for(c=0;c<g;c++)if(this._gPoints[c].id===f)return this._gPoints[c];return null},getPrimary:function(f){var c,g=this._gPoints.length;for(c=0;c<g;c++)if(this._gPoints[c].isPrimary)return this._gPoints[c];return null},addContact:function(){++this.contacts,this.contacts>1&&(this.type==="mouse"||this.type==="pen")&&(e.console.warn("GesturePointList.addContact() Implausible contacts value"),this.contacts=1)},removeContact:function(){--this.contacts,this.contacts<0&&(this.contacts=0)}};function r(f){var c=t[f.hash],g,w,R,F,A,X=c.activePointersLists.length;for(g=0;g<X;g++)if(R=c.activePointersLists[g],R.getLength()>0){for(A=[],F=R.asArray(),w=0;w<F.length;w++)A.push(F[w]);for(w=0;w<A.length;w++)xe(f,R,A[w])}for(g=0;g<X;g++)c.activePointersLists.pop();c.sentDragEvent=!1}function a(f){var c=t[f.hash],g,w;if(!c.tracking){for(w=0;w<e.MouseTracker.subscribeEvents.length;w++)g=e.MouseTracker.subscribeEvents[w],e.addEvent(f.element,g,c[g],g===e.MouseTracker.wheelEventName?{passive:!1,capture:!1}:!1);r(f),c.tracking=!0}}function s(f){var c=t[f.hash],g,w;if(c.tracking){for(w=0;w<e.MouseTracker.subscribeEvents.length;w++)g=e.MouseTracker.subscribeEvents[w],e.removeEvent(f.element,g,c[g],!1);r(f),c.tracking=!1}}function o(f,c){var g=t[f.hash];if(c==="pointerevent")return{upName:"pointerup",upHandler:g.pointerupcaptured,moveName:"pointermove",moveHandler:g.pointermovecaptured};if(c==="mouse")return{upName:"pointerup",upHandler:g.pointerupcaptured,moveName:"pointermove",moveHandler:g.pointermovecaptured};if(c==="touch")return{upName:"touchend",upHandler:g.touchendcaptured,moveName:"touchmove",moveHandler:g.touchmovecaptured};throw new Error("MouseTracker.getCaptureEventParams: Unknown pointer type.")}function l(f,c){var g;if(e.MouseTracker.havePointerCapture)if(e.MouseTracker.havePointerEvents)try{f.element.setPointerCapture(c.id)}catch{e.console.warn("setPointerCapture() called on invalid pointer ID");return}else f.element.setCapture(!0);else g=o(f,e.MouseTracker.havePointerEvents?"pointerevent":c.type),n&&i(window.top)&&e.addEvent(window.top,g.upName,g.upHandler,!0),e.addEvent(e.MouseTracker.captureElement,g.upName,g.upHandler,!0),e.addEvent(e.MouseTracker.captureElement,g.moveName,g.moveHandler,!0);E(f,c,!0)}function u(f,c){var g,w,R;if(e.MouseTracker.havePointerCapture)if(e.MouseTracker.havePointerEvents){if(w=f.getActivePointersListByType(c.type),R=w.getById(c.id),!R||!R.captured)return;try{f.element.releasePointerCapture(c.id)}catch{}}else f.element.releaseCapture();else g=o(f,e.MouseTracker.havePointerEvents?"pointerevent":c.type),n&&i(window.top)&&e.removeEvent(window.top,g.upName,g.upHandler,!0),e.removeEvent(e.MouseTracker.captureElement,g.moveName,g.moveHandler,!0),e.removeEvent(e.MouseTracker.captureElement,g.upName,g.upHandler,!0);E(f,c,!1)}function d(f){return e.MouseTracker.havePointerEvents?f.pointerId:e.MouseTracker.mousePointerId}function m(f){return e.MouseTracker.havePointerEvents&&f.pointerType?f.pointerType:"mouse"}function v(f){return e.MouseTracker.havePointerEvents?f.isPrimary:!0}function y(f){return e.getMousePosition(f)}function T(f,c){return _(y(f),c)}function _(f,c){var g=e.getElementOffset(c);return f.minus(g)}function S(f,c){return new e.Point((f.x+c.x)/2,(f.y+c.y)/2)}function b(f,c){var g={originalEvent:c,eventType:"click",pointerType:"mouse",isEmulated:!1};p(f,g),g.preventDefault&&!g.defaultPrevented&&e.cancelEvent(c),g.stopPropagation&&e.stopEvent(c)}function L(f,c){var g={originalEvent:c,eventType:"dblclick",pointerType:"mouse",isEmulated:!1};p(f,g),g.preventDefault&&!g.defaultPrevented&&e.cancelEvent(c),g.stopPropagation&&e.stopEvent(c)}function I(f,c){var g=null,w={originalEvent:c,eventType:"keydown",pointerType:"",isEmulated:!1};p(f,w),f.keyDownHandler&&!w.preventGesture&&!w.defaultPrevented&&(g={eventSource:f,keyCode:c.keyCode?c.keyCode:c.charCode,ctrl:c.ctrlKey,shift:c.shiftKey,alt:c.altKey,meta:c.metaKey,originalEvent:c,preventDefault:w.preventDefault||w.defaultPrevented,userData:f.userData},f.keyDownHandler(g)),(g&&g.preventDefault||w.preventDefault&&!w.defaultPrevented)&&e.cancelEvent(c),w.stopPropagation&&e.stopEvent(c)}function M(f,c){var g=null,w={originalEvent:c,eventType:"keyup",pointerType:"",isEmulated:!1};p(f,w),f.keyUpHandler&&!w.preventGesture&&!w.defaultPrevented&&(g={eventSource:f,keyCode:c.keyCode?c.keyCode:c.charCode,ctrl:c.ctrlKey,shift:c.shiftKey,alt:c.altKey,meta:c.metaKey,originalEvent:c,preventDefault:w.preventDefault||w.defaultPrevented,userData:f.userData},f.keyUpHandler(g)),(g&&g.preventDefault||w.preventDefault&&!w.defaultPrevented)&&e.cancelEvent(c),w.stopPropagation&&e.stopEvent(c)}function Z(f,c){var g=null,w={originalEvent:c,eventType:"keypress",pointerType:"",isEmulated:!1};p(f,w),f.keyHandler&&!w.preventGesture&&!w.defaultPrevented&&(g={eventSource:f,keyCode:c.keyCode?c.keyCode:c.charCode,ctrl:c.ctrlKey,shift:c.shiftKey,alt:c.altKey,meta:c.metaKey,originalEvent:c,preventDefault:w.preventDefault||w.defaultPrevented,userData:f.userData},f.keyHandler(g)),(g&&g.preventDefault||w.preventDefault&&!w.defaultPrevented)&&e.cancelEvent(c),w.stopPropagation&&e.stopEvent(c)}function V(f,c){var g={originalEvent:c,eventType:"focus",pointerType:"",isEmulated:!1};p(f,g),f.focusHandler&&!g.preventGesture&&f.focusHandler({eventSource:f,originalEvent:c,userData:f.userData})}function j(f,c){var g={originalEvent:c,eventType:"blur",pointerType:"",isEmulated:!1};p(f,g),f.blurHandler&&!g.preventGesture&&f.blurHandler({eventSource:f,originalEvent:c,userData:f.userData})}function J(f,c){var g=null,w={originalEvent:c,eventType:"contextmenu",pointerType:"mouse",isEmulated:!1};p(f,w),f.contextMenuHandler&&!w.preventGesture&&!w.defaultPrevented&&(g={eventSource:f,position:_(y(c),f.element),originalEvent:w.originalEvent,preventDefault:w.preventDefault||w.defaultPrevented,userData:f.userData},f.contextMenuHandler(g)),(g&&g.preventDefault||w.preventDefault&&!w.defaultPrevented)&&e.cancelEvent(c),w.stopPropagation&&e.stopEvent(c)}function W(f,c){$(f,c,c)}function U(f,c){var g={target:c.target||c.srcElement,type:"wheel",shiftKey:c.shiftKey||!1,clientX:c.clientX,clientY:c.clientY,pageX:c.pageX?c.pageX:c.clientX,pageY:c.pageY?c.pageY:c.clientY,deltaMode:c.type==="MozMousePixelScroll"?0:1,deltaX:0,deltaZ:0};e.MouseTracker.wheelEventName==="mousewheel"?g.deltaY=-c.wheelDelta/e.DEFAULT_SETTINGS.pixelsPerWheelLine:g.deltaY=c.detail,$(f,g,c)}function $(f,c,g){var w=0,R,F=null;w=c.deltaY?c.deltaY<0?1:-1:0,R={originalEvent:c,eventType:"wheel",pointerType:"mouse",isEmulated:c!==g},p(f,R),f.scrollHandler&&!R.preventGesture&&!R.defaultPrevented&&(F={eventSource:f,pointerType:"mouse",position:T(c,f.element),scroll:w,shift:c.shiftKey,isTouchEvent:!1,originalEvent:g,preventDefault:R.preventDefault||R.defaultPrevented,userData:f.userData},f.scrollHandler(F)),R.stopPropagation&&e.stopEvent(g),(F&&F.preventDefault||R.preventDefault&&!R.defaultPrevented)&&e.cancelEvent(g)}function ne(f,c){var g={id:e.MouseTracker.mousePointerId,type:"mouse"},w={originalEvent:c,eventType:"lostpointercapture",pointerType:"mouse",isEmulated:!1};p(f,w),c.target===f.element&&E(f,g,!1),w.stopPropagation&&e.stopEvent(c)}function te(f,c){var g,w,R=c.changedTouches.length,F,A=f.getActivePointersListByType("touch");g=e.now(),A.getLength()>c.touches.length-R&&e.console.warn("Tracked touch contact count doesn't match event.touches.length");var X={originalEvent:c,eventType:"pointerdown",pointerType:"touch",isEmulated:!1};for(p(f,X),w=0;w<R;w++)F={id:c.changedTouches[w].identifier,type:"touch",isPrimary:A.getLength()===0,currentPos:y(c.changedTouches[w]),currentTime:g},D(f,X,F),k(f,X,F,0),E(f,F,!0);X.preventDefault&&!X.defaultPrevented&&e.cancelEvent(c),X.stopPropagation&&e.stopEvent(c)}function se(f,c){var g,w,R=c.changedTouches.length,F;g=e.now();var A={originalEvent:c,eventType:"pointerup",pointerType:"touch",isEmulated:!1};for(p(f,A),w=0;w<R;w++)F={id:c.changedTouches[w].identifier,type:"touch",currentPos:y(c.changedTouches[w]),currentTime:g},q(f,A,F,0),E(f,F,!1),B(f,A,F);A.preventDefault&&!A.defaultPrevented&&e.cancelEvent(c),A.stopPropagation&&e.stopEvent(c)}function re(f,c){var g,w,R=c.changedTouches.length,F;g=e.now();var A={originalEvent:c,eventType:"pointermove",pointerType:"touch",isEmulated:!1};for(p(f,A),w=0;w<R;w++)F={id:c.changedTouches[w].identifier,type:"touch",currentPos:y(c.changedTouches[w]),currentTime:g},Q(f,A,F);A.preventDefault&&!A.defaultPrevented&&e.cancelEvent(c),A.stopPropagation&&e.stopEvent(c)}function ge(f,c){var g=c.changedTouches.length,w,R,F={originalEvent:c,eventType:"pointercancel",pointerType:"touch",isEmulated:!1};for(p(f,F),w=0;w<g;w++)R={id:c.changedTouches[w].identifier,type:"touch"},N(f,F,R);F.stopPropagation&&e.stopEvent(c)}function ye(f,c){return e.eventIsCanceled(c)||c.preventDefault(),!1}function ve(f,c){return e.eventIsCanceled(c)||c.preventDefault(),!1}function Me(f,c){var g={originalEvent:c,eventType:"gotpointercapture",pointerType:m(c),isEmulated:!1};p(f,g),c.target===f.element&&E(f,{id:c.pointerId,type:m(c)},!0),g.stopPropagation&&e.stopEvent(c)}function Le(f,c){var g={originalEvent:c,eventType:"lostpointercapture",pointerType:m(c),isEmulated:!1};p(f,g),c.target===f.element&&E(f,{id:c.pointerId,type:m(c)},!1),g.stopPropagation&&e.stopEvent(c)}function G(f,c){var g={id:d(c),type:m(c),isPrimary:v(c),currentPos:y(c),currentTime:e.now()},w={originalEvent:c,eventType:"pointerenter",pointerType:g.type,isEmulated:!1};p(f,w),D(f,w,g)}function Re(f,c){var g={id:d(c),type:m(c),isPrimary:v(c),currentPos:y(c),currentTime:e.now()},w={originalEvent:c,eventType:"pointerleave",pointerType:g.type,isEmulated:!1};p(f,w),B(f,w,g)}function be(f,c){var g={id:d(c),type:m(c),isPrimary:v(c),currentPos:y(c),currentTime:e.now()},w={originalEvent:c,eventType:"pointerover",pointerType:g.type,isEmulated:!1};p(f,w),O(f,w,g),w.preventDefault&&!w.defaultPrevented&&e.cancelEvent(c),w.stopPropagation&&e.stopEvent(c)}function Ce(f,c){var g={id:d(c),type:m(c),isPrimary:v(c),currentPos:y(c),currentTime:e.now()},w={originalEvent:c,eventType:"pointerout",pointerType:g.type,isEmulated:!1};p(f,w),C(f,w,g),w.preventDefault&&!w.defaultPrevented&&e.cancelEvent(c),w.stopPropagation&&e.stopEvent(c)}function _e(f,c){var g={id:d(c),type:m(c),isPrimary:v(c),currentPos:y(c),currentTime:e.now()},w=e.MouseTracker.havePointerEvents&&g.type==="touch",R={originalEvent:c,eventType:"pointerdown",pointerType:g.type,isEmulated:!1};p(f,R),k(f,R,g,c.button),R.preventDefault&&!R.defaultPrevented&&e.cancelEvent(c),R.stopPropagation&&e.stopEvent(c),R.shouldCapture&&(w?E(f,g,!0):l(f,g))}function De(f,c){Fe(f,c)}function He(f,c){var g=f.getActivePointersListByType(m(c));g.getById(c.pointerId)&&Fe(f,c),e.stopEvent(c)}function Fe(f,c){var g;g={id:d(c),type:m(c),isPrimary:v(c),currentPos:y(c),currentTime:e.now()};var w={originalEvent:c,eventType:"pointerup",pointerType:g.type,isEmulated:!1};p(f,w),q(f,w,g,c.button),w.preventDefault&&!w.defaultPrevented&&e.cancelEvent(c),w.stopPropagation&&e.stopEvent(c),w.shouldReleaseCapture&&(c.target===f.element?u(f,g):E(f,g,!1))}function Be(f,c){Ie(f,c)}function ke(f,c){var g=f.getActivePointersListByType(m(c));g.getById(c.pointerId)&&Ie(f,c),e.stopEvent(c)}function Ie(f,c){var g={id:d(c),type:m(c),isPrimary:v(c),currentPos:y(c),currentTime:e.now()},w={originalEvent:c,eventType:"pointermove",pointerType:g.type,isEmulated:!1};p(f,w),Q(f,w,g),w.preventDefault&&!w.defaultPrevented&&e.cancelEvent(c),w.stopPropagation&&e.stopEvent(c)}function Ne(f,c){var g={id:c.pointerId,type:m(c)},w={originalEvent:c,eventType:"pointercancel",pointerType:g.type,isEmulated:!1};p(f,w),N(f,w,g),w.stopPropagation&&e.stopEvent(c)}function Se(f,c){return c.speed=0,c.direction=0,c.contactPos=c.currentPos,c.contactTime=c.currentTime,c.lastPos=c.currentPos,c.lastTime=c.currentTime,f.add(c)}function xe(f,c,g){var w,R=c.getById(g.id);return R?(R.captured&&(e.console.warn("stopTrackingPointer() called on captured pointer"),u(f,R)),c.removeContact(),w=c.removeById(g.id)):w=c.getLength(),w}function h(f,c){switch(c.eventType){case"pointermove":c.isStoppable=!0,c.isCancelable=!0,c.preventDefault=!1,c.preventGesture=!f.hasGestureHandlers,c.stopPropagation=!1;break;case"pointerover":case"pointerout":case"contextmenu":case"keydown":case"keyup":case"keypress":c.isStoppable=!0,c.isCancelable=!0,c.preventDefault=!1,c.preventGesture=!1,c.stopPropagation=!1;break;case"pointerdown":c.isStoppable=!0,c.isCancelable=!0,c.preventDefault=!1,c.preventGesture=!f.hasGestureHandlers,c.stopPropagation=!1;break;case"pointerup":c.isStoppable=!0,c.isCancelable=!0,c.preventDefault=!1,c.preventGesture=!f.hasGestureHandlers,c.stopPropagation=!1;break;case"wheel":c.isStoppable=!0,c.isCancelable=!0,c.preventDefault=!1,c.preventGesture=!f.hasScrollHandler,c.stopPropagation=!1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":c.isStoppable=!0,c.isCancelable=!1,c.preventDefault=!1,c.preventGesture=!1,c.stopPropagation=!1;break;case"click":c.isStoppable=!0,c.isCancelable=!0,c.preventDefault=!!f.clickHandler,c.preventGesture=!1,c.stopPropagation=!1;break;case"dblclick":c.isStoppable=!0,c.isCancelable=!0,c.preventDefault=!!f.dblClickHandler,c.preventGesture=!1,c.stopPropagation=!1;break;case"focus":case"blur":case"pointerenter":case"pointerleave":default:c.isStoppable=!1,c.isCancelable=!1,c.preventDefault=!1,c.preventGesture=!1,c.stopPropagation=!1;break}}function p(f,c){c.eventSource=f,c.eventPhase=c.originalEvent&&typeof c.originalEvent.eventPhase<"u"?c.originalEvent.eventPhase:0,c.defaultPrevented=e.eventIsCanceled(c.originalEvent),c.shouldCapture=!1,c.shouldReleaseCapture=!1,c.userData=f.userData,h(f,c),f.preProcessEventHandler&&f.preProcessEventHandler(c)}function E(f,c,g){var w=f.getActivePointersListByType(c.type),R=w.getById(c.id);R?g&&!R.captured?(R.captured=!0,w.captureCount++):!g&&R.captured&&(R.captured=!1,w.captureCount--,w.captureCount<0&&(w.captureCount=0,e.console.warn("updatePointerCaptured() - pointsList.captureCount went negative"))):e.console.warn("updatePointerCaptured() called on untracked pointer")}function D(f,c,g){var w=f.getActivePointersListByType(g.type),R;R=w.getById(g.id),R?(R.insideElement=!0,R.lastPos=R.currentPos,R.lastTime=R.currentTime,R.currentPos=g.currentPos,R.currentTime=g.currentTime,g=R):(g.captured=!1,g.insideElementPressed=!1,g.insideElement=!0,Se(w,g)),f.enterHandler&&f.enterHandler({eventSource:f,pointerType:g.type,position:_(g.currentPos,f.element),buttons:w.buttons,pointers:f.getActivePointerCount(),insideElementPressed:g.insideElementPressed,buttonDownAny:w.buttons!==0,isTouchEvent:g.type==="touch",originalEvent:c.originalEvent,userData:f.userData})}function B(f,c,g){var w=f.getActivePointersListByType(g.type),R,F;R=w.getById(g.id),R?(R.captured?(R.insideElement=!1,R.lastPos=R.currentPos,R.lastTime=R.currentTime,R.currentPos=g.currentPos,R.currentTime=g.currentTime):xe(f,w,R),g=R):(g.captured=!1,g.insideElementPressed=!1),(f.leaveHandler||f.exitHandler)&&(F={eventSource:f,pointerType:g.type,position:g.currentPos&&_(g.currentPos,f.element),buttons:w.buttons,pointers:f.getActivePointerCount(),insideElementPressed:g.insideElementPressed,buttonDownAny:w.buttons!==0,isTouchEvent:g.type==="touch",originalEvent:c.originalEvent,userData:f.userData},f.leaveHandler&&f.leaveHandler(F),f.exitHandler&&f.exitHandler(F))}function O(f,c,g){var w,R;w=f.getActivePointersListByType(g.type),R=w.getById(g.id),R?g=R:(g.captured=!1,g.insideElementPressed=!1),f.overHandler&&f.overHandler({eventSource:f,pointerType:g.type,position:_(g.currentPos,f.element),buttons:w.buttons,pointers:f.getActivePointerCount(),insideElementPressed:g.insideElementPressed,buttonDownAny:w.buttons!==0,isTouchEvent:g.type==="touch",originalEvent:c.originalEvent,userData:f.userData})}function C(f,c,g){var w,R;w=f.getActivePointersListByType(g.type),R=w.getById(g.id),R?g=R:(g.captured=!1,g.insideElementPressed=!1),f.outHandler&&f.outHandler({eventSource:f,pointerType:g.type,position:g.currentPos&&_(g.currentPos,f.element),buttons:w.buttons,pointers:f.getActivePointerCount(),insideElementPressed:g.insideElementPressed,buttonDownAny:w.buttons!==0,isTouchEvent:g.type==="touch",originalEvent:c.originalEvent,userData:f.userData})}function k(f,c,g,w){var R=t[f.hash],F=f.getActivePointersListByType(g.type),A;if(typeof c.originalEvent.buttons<"u"?F.buttons=c.originalEvent.buttons:w===0?F.buttons|=1:w===1?F.buttons|=4:w===2?F.buttons|=2:w===3?F.buttons|=8:w===4?F.buttons|=16:w===5&&(F.buttons|=32),w!==0){c.shouldCapture=!1,c.shouldReleaseCapture=!1,f.nonPrimaryPressHandler&&!c.preventGesture&&!c.defaultPrevented&&(c.preventDefault=!0,f.nonPrimaryPressHandler({eventSource:f,pointerType:g.type,position:_(g.currentPos,f.element),button:w,buttons:F.buttons,isTouchEvent:g.type==="touch",originalEvent:c.originalEvent,userData:f.userData}));return}A=F.getById(g.id),A?(A.insideElementPressed=!0,A.insideElement=!0,A.originalTarget=c.originalEvent.target,A.contactPos=g.currentPos,A.contactTime=g.currentTime,A.lastPos=A.currentPos,A.lastTime=A.currentTime,A.currentPos=g.currentPos,A.currentTime=g.currentTime,g=A):(g.captured=!1,g.insideElementPressed=!0,g.insideElement=!0,g.originalTarget=c.originalEvent.target,Se(F,g)),F.addContact(),!c.preventGesture&&!c.defaultPrevented?(c.shouldCapture=!0,c.shouldReleaseCapture=!1,c.preventDefault=!0,(f.dragHandler||f.dragEndHandler||f.pinchHandler)&&e.MouseTracker.gesturePointVelocityTracker.addPoint(f,g),F.contacts===1?f.pressHandler&&!c.preventGesture&&f.pressHandler({eventSource:f,pointerType:g.type,position:_(g.contactPos,f.element),buttons:F.buttons,isTouchEvent:g.type==="touch",originalEvent:c.originalEvent,userData:f.userData}):F.contacts===2&&f.pinchHandler&&g.type==="touch"&&(R.pinchGPoints=F.asArray(),R.lastPinchDist=R.currentPinchDist=R.pinchGPoints[0].currentPos.distanceTo(R.pinchGPoints[1].currentPos),R.lastPinchCenter=R.currentPinchCenter=S(R.pinchGPoints[0].currentPos,R.pinchGPoints[1].currentPos))):(c.shouldCapture=!1,c.shouldReleaseCapture=!1)}function q(f,c,g,w){var R=t[f.hash],F=f.getActivePointersListByType(g.type),A,X,z,le=!1,ie;if(typeof c.originalEvent.buttons<"u"?F.buttons=c.originalEvent.buttons:w===0?F.buttons^=-2:w===1?F.buttons^=-5:w===2?F.buttons^=-3:w===3?F.buttons^=-9:w===4?F.buttons^=-17:w===5&&(F.buttons^=-33),c.shouldCapture=!1,w!==0){c.shouldReleaseCapture=!1,f.nonPrimaryReleaseHandler&&!c.preventGesture&&!c.defaultPrevented&&(c.preventDefault=!0,f.nonPrimaryReleaseHandler({eventSource:f,pointerType:g.type,position:_(g.currentPos,f.element),button:w,buttons:F.buttons,isTouchEvent:g.type==="touch",originalEvent:c.originalEvent,userData:f.userData}));return}z=F.getById(g.id),z?(F.removeContact(),z.captured&&(le=!0),z.lastPos=z.currentPos,z.lastTime=z.currentTime,z.currentPos=g.currentPos,z.currentTime=g.currentTime,z.insideElement||xe(f,F,z),A=z.currentPos,X=z.currentTime):(g.captured=!1,g.insideElementPressed=!1,g.insideElement=!0,Se(F,g),z=g),!c.preventGesture&&!c.defaultPrevented&&(le?(c.shouldReleaseCapture=!0,c.preventDefault=!0,(f.dragHandler||f.dragEndHandler||f.pinchHandler)&&e.MouseTracker.gesturePointVelocityTracker.removePoint(f,z),F.contacts===0?(f.releaseHandler&&A&&f.releaseHandler({eventSource:f,pointerType:z.type,position:_(A,f.element),buttons:F.buttons,insideElementPressed:z.insideElementPressed,insideElementReleased:z.insideElement,isTouchEvent:z.type==="touch",originalEvent:c.originalEvent,userData:f.userData}),f.dragEndHandler&&R.sentDragEvent&&f.dragEndHandler({eventSource:f,pointerType:z.type,position:_(z.currentPos,f.element),speed:z.speed,direction:z.direction,shift:c.originalEvent.shiftKey,isTouchEvent:z.type==="touch",originalEvent:c.originalEvent,userData:f.userData}),R.sentDragEvent=!1,(f.clickHandler||f.dblClickHandler)&&z.insideElement&&(ie=X-z.contactTime<=f.clickTimeThreshold&&z.contactPos.distanceTo(A)<=f.clickDistThreshold,f.clickHandler&&f.clickHandler({eventSource:f,pointerType:z.type,position:_(z.currentPos,f.element),quick:ie,shift:c.originalEvent.shiftKey,isTouchEvent:z.type==="touch",originalEvent:c.originalEvent,originalTarget:z.originalTarget,userData:f.userData}),f.dblClickHandler&&ie&&(F.clicks++,F.clicks===1?(R.lastClickPos=A,R.dblClickTimeOut=setTimeout(function(){F.clicks=0},f.dblClickTimeThreshold)):F.clicks===2&&(clearTimeout(R.dblClickTimeOut),F.clicks=0,R.lastClickPos.distanceTo(A)<=f.dblClickDistThreshold&&f.dblClickHandler({eventSource:f,pointerType:z.type,position:_(z.currentPos,f.element),shift:c.originalEvent.shiftKey,isTouchEvent:z.type==="touch",originalEvent:c.originalEvent,userData:f.userData}),R.lastClickPos=null)))):F.contacts===2&&f.pinchHandler&&z.type==="touch"&&(R.pinchGPoints=F.asArray(),R.lastPinchDist=R.currentPinchDist=R.pinchGPoints[0].currentPos.distanceTo(R.pinchGPoints[1].currentPos),R.lastPinchCenter=R.currentPinchCenter=S(R.pinchGPoints[0].currentPos,R.pinchGPoints[1].currentPos))):(c.shouldReleaseCapture=!1,f.releaseHandler&&A&&(f.releaseHandler({eventSource:f,pointerType:z.type,position:_(A,f.element),buttons:F.buttons,insideElementPressed:z.insideElementPressed,insideElementReleased:z.insideElement,isTouchEvent:z.type==="touch",originalEvent:c.originalEvent,userData:f.userData}),c.preventDefault=!0)))}function Q(f,c,g){var w=t[f.hash],R=f.getActivePointersListByType(g.type),F,A,X;if(typeof c.originalEvent.buttons<"u"&&(R.buttons=c.originalEvent.buttons),F=R.getById(g.id),F)F.lastPos=F.currentPos,F.lastTime=F.currentTime,F.currentPos=g.currentPos,F.currentTime=g.currentTime;else return;c.shouldCapture=!1,c.shouldReleaseCapture=!1,f.stopHandler&&g.type==="mouse"&&(clearTimeout(f.stopTimeOut),f.stopTimeOut=setTimeout(function(){K(f,c.originalEvent,g.type)},f.stopDelay)),R.contacts===0?f.moveHandler&&f.moveHandler({eventSource:f,pointerType:g.type,position:_(g.currentPos,f.element),buttons:R.buttons,isTouchEvent:g.type==="touch",originalEvent:c.originalEvent,userData:f.userData}):R.contacts===1?(f.moveHandler&&(F=R.asArray()[0],f.moveHandler({eventSource:f,pointerType:F.type,position:_(F.currentPos,f.element),buttons:R.buttons,isTouchEvent:F.type==="touch",originalEvent:c.originalEvent,userData:f.userData})),f.dragHandler&&!c.preventGesture&&!c.defaultPrevented&&(F=R.asArray()[0],X=F.currentPos.minus(F.lastPos),f.dragHandler({eventSource:f,pointerType:F.type,position:_(F.currentPos,f.element),buttons:R.buttons,delta:X,speed:F.speed,direction:F.direction,shift:c.originalEvent.shiftKey,isTouchEvent:F.type==="touch",originalEvent:c.originalEvent,userData:f.userData}),c.preventDefault=!0,w.sentDragEvent=!0)):R.contacts===2&&(f.moveHandler&&(A=R.asArray(),f.moveHandler({eventSource:f,pointerType:A[0].type,position:_(S(A[0].currentPos,A[1].currentPos),f.element),buttons:R.buttons,isTouchEvent:A[0].type==="touch",originalEvent:c.originalEvent,userData:f.userData})),f.pinchHandler&&g.type==="touch"&&!c.preventGesture&&!c.defaultPrevented&&(X=w.pinchGPoints[0].currentPos.distanceTo(w.pinchGPoints[1].currentPos),X!==w.currentPinchDist&&(w.lastPinchDist=w.currentPinchDist,w.currentPinchDist=X,w.lastPinchCenter=w.currentPinchCenter,w.currentPinchCenter=S(w.pinchGPoints[0].currentPos,w.pinchGPoints[1].currentPos),f.pinchHandler({eventSource:f,pointerType:"touch",gesturePoints:w.pinchGPoints,lastCenter:_(w.lastPinchCenter,f.element),center:_(w.currentPinchCenter,f.element),lastDistance:w.lastPinchDist,distance:w.currentPinchDist,shift:c.originalEvent.shiftKey,originalEvent:c.originalEvent,userData:f.userData}),c.preventDefault=!0)))}function N(f,c,g){var w=f.getActivePointersListByType(g.type),R;R=w.getById(g.id),R&&xe(f,w,R)}function K(f,c,g){f.stopHandler&&f.stopHandler({eventSource:f,pointerType:g,position:T(c,f.element),buttons:f.getActivePointersListByType(g).buttons,isTouchEvent:g==="touch",originalEvent:c,userData:f.userData})}}(x),function(e){e.ControlAnchor={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_RIGHT:3,BOTTOM_LEFT:4,ABSOLUTE:5},e.Control=function(t,n,i){var r=t.parentNode;typeof n=="number"&&(e.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"),n={anchor:n}),n.attachToViewer=typeof n.attachToViewer>"u"?!0:n.attachToViewer,this.autoFade=typeof n.autoFade>"u"?!0:n.autoFade,this.element=t,this.anchor=n.anchor,this.container=i,this.anchor===e.ControlAnchor.ABSOLUTE?(this.wrapper=e.makeNeutralElement("div"),this.wrapper.style.position="absolute",this.wrapper.style.top=typeof n.top=="number"?n.top+"px":n.top,this.wrapper.style.left=typeof n.left=="number"?n.left+"px":n.left,this.wrapper.style.height=typeof n.height=="number"?n.height+"px":n.height,this.wrapper.style.width=typeof n.width=="number"?n.width+"px":n.width,this.wrapper.style.margin="0px",this.wrapper.style.padding="0px",this.element.style.position="relative",this.element.style.top="0px",this.element.style.left="0px",this.element.style.height="100%",this.element.style.width="100%"):(this.wrapper=e.makeNeutralElement("div"),this.wrapper.style.display="inline-block",this.anchor===e.ControlAnchor.NONE&&(this.wrapper.style.width=this.wrapper.style.height="100%")),this.wrapper.appendChild(this.element),n.attachToViewer?this.anchor===e.ControlAnchor.TOP_RIGHT||this.anchor===e.ControlAnchor.BOTTOM_RIGHT?this.container.insertBefore(this.wrapper,this.container.firstChild):this.container.appendChild(this.wrapper):r.appendChild(this.wrapper)},e.Control.prototype={destroy:function(){this.wrapper.removeChild(this.element),this.anchor!==e.ControlAnchor.NONE&&this.container.removeChild(this.wrapper)},isVisible:function(){return this.wrapper.style.display!=="none"},setVisible:function(t){this.wrapper.style.display=t?this.anchor===e.ControlAnchor.ABSOLUTE?"block":"inline-block":"none"},setOpacity:function(t){e.setElementOpacity(this.wrapper,t,!0)}}}(x),function(e){e.ControlDock=function(n){var i=["topleft","topright","bottomright","bottomleft"],r,a;for(e.extend(!0,this,{id:"controldock-"+e.now()+"-"+Math.floor(Math.random()*1e6),container:e.makeNeutralElement("div"),controls:[]},n),this.container.onsubmit=function(){return!1},this.element&&(this.element=e.getElement(this.element),this.element.appendChild(this.container),e.getElementStyle(this.element).position==="static"&&(this.element.style.position="relative"),this.container.style.width="100%",this.container.style.height="100%"),a=0;a<i.length;a++)r=i[a],this.controls[r]=e.makeNeutralElement("div"),this.controls[r].style.position="absolute",r.match("left")&&(this.controls[r].style.left="0px"),r.match("right")&&(this.controls[r].style.right="0px"),r.match("top")&&(this.controls[r].style.top="0px"),r.match("bottom")&&(this.controls[r].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)},e.ControlDock.prototype={addControl:function(n,i){n=e.getElement(n);var r=null;if(!(t(this,n)>=0)){switch(i.anchor){case e.ControlAnchor.TOP_RIGHT:r=this.controls.topright,n.style.position="relative",n.style.paddingRight="0px",n.style.paddingTop="0px";break;case e.ControlAnchor.BOTTOM_RIGHT:r=this.controls.bottomright,n.style.position="relative",n.style.paddingRight="0px",n.style.paddingBottom="0px";break;case e.ControlAnchor.BOTTOM_LEFT:r=this.controls.bottomleft,n.style.position="relative",n.style.paddingLeft="0px",n.style.paddingBottom="0px";break;case e.ControlAnchor.TOP_LEFT:r=this.controls.topleft,n.style.position="relative",n.style.paddingLeft="0px",n.style.paddingTop="0px";break;case e.ControlAnchor.ABSOLUTE:r=this.container,n.style.margin="0px",n.style.padding="0px";break;default:case e.ControlAnchor.NONE:r=this.container,n.style.margin="0px",n.style.padding="0px";break}this.controls.push(new e.Control(n,i,r)),n.style.display="inline-block"}},removeControl:function(n){n=e.getElement(n);var i=t(this,n);return i>=0&&(this.controls[i].destroy(),this.controls.splice(i,1)),this},clearControls:function(){for(;this.controls.length>0;)this.controls.pop().destroy();return this},areControlsEnabled:function(){var n;for(n=this.controls.length-1;n>=0;n--)if(this.controls[n].isVisible())return!0;return!1},setControlsEnabled:function(n){var i;for(i=this.controls.length-1;i>=0;i--)this.controls[i].setVisible(n);return this}};function t(n,i){var r=n.controls,a;for(a=r.length-1;a>=0;a--)if(r[a].element===i)return a;return-1}}(x),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}}})}(x),function(e){var t={},n=1;e.Viewer=function(h){var p=arguments,E=this,D;e.isPlainObject(h)||(h={id:p[0],xmlPath:p.length>1?p[1]:void 0,prefixUrl:p.length>2?p[2]:void 0,controls:p.length>3?p[3]:void 0,overlays:p.length>4?p[4]:void 0}),h.config&&(e.extend(!0,h,h.config),delete h.config);let B=["useCanvas"];if(h.drawerOptions=Object.assign({},B.reduce((C,k)=>(C[k]=h[k],delete h[k],C),{}),h.drawerOptions),e.extend(!0,this,{id:h.id,hash:h.hash||n++,initialPage:0,element:null,container:null,canvas:null,overlays:[],overlaysContainer:null,previousBody:[],customControls:[],source:null,drawer:null,world:null,viewport:null,navigator:null,collectionViewport:null,collectionDrawer:null,navImages:null,buttonGroup:null,profiler:null},e.DEFAULT_SETTINGS,h),typeof this.hash>"u")throw new Error("A hash must be defined, either by specifying options.id or options.hash.");typeof t[this.hash]<"u"&&e.console.warn("Hash "+this.hash+" has already been used."),t[this.hash]={fsBoundsDelta:new e.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=e.now(),e.EventSource.call(this),this.addHandler("open-failed",function(C){var k=e.getString("Errors.OpenFailed",C.eventSource,C.message);E._showMessage(k)}),e.ControlDock.call(this,h),this.xmlPath&&(this.tileSources=[this.xmlPath]),this.element=this.element||document.getElementById(this.id),this.canvas=e.makeNeutralElement("div"),this.canvas.className="openseadragon-canvas",function(C){C.width="100%",C.height="100%",C.overflow="hidden",C.position="absolute",C.top="0px",C.left="0px"}(this.canvas.style),e.setElementTouchActionNone(this.canvas),h.tabIndex!==""&&(this.canvas.tabIndex=h.tabIndex===void 0?0:h.tabIndex),this.container.className="openseadragon-container",function(C){C.width="100%",C.height="100%",C.position="relative",C.overflow="hidden",C.left="0px",C.top="0px",C.textAlign="left"}(this.container.style),e.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 e.MouseTracker({userData:"Viewer.innerTracker",element:this.canvas,startDisabled:!this.mouseNavEnabled,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,contextMenuHandler:e.delegate(this,T),keyDownHandler:e.delegate(this,_),keyHandler:e.delegate(this,S),clickHandler:e.delegate(this,b),dblClickHandler:e.delegate(this,L),dragHandler:e.delegate(this,I),dragEndHandler:e.delegate(this,M),enterHandler:e.delegate(this,Z),leaveHandler:e.delegate(this,V),pressHandler:e.delegate(this,j),releaseHandler:e.delegate(this,J),nonPrimaryPressHandler:e.delegate(this,W),nonPrimaryReleaseHandler:e.delegate(this,U),scrollHandler:e.delegate(this,se),pinchHandler:e.delegate(this,$),focusHandler:e.delegate(this,ne),blurHandler:e.delegate(this,te)}),this.outerTracker=new e.MouseTracker({userData:"Viewer.outerTracker",element:this.container,startDisabled:!this.mouseNavEnabled,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,enterHandler:e.delegate(this,re),leaveHandler:e.delegate(this,ge)}),this.toolbar&&(this.toolbar=new e.ControlDock({element:this.toolbar})),this.bindStandardControls(),t[this.hash].prevContainerSize=i(this.container),window.ResizeObserver?(this._autoResizePolling=!1,this._resizeObserver=new ResizeObserver(function(){t[E.hash].needsResize=!0}),this._resizeObserver.observe(this.container,{})):this._autoResizePolling=!0,this.world=new e.World({viewer:this}),this.world.addHandler("add-item",function(C){E.source=E.world.getItemAt(0).source,t[E.hash].forceRedraw=!0,E._updateRequestId||(E._updateRequestId=o(E,ye))}),this.world.addHandler("remove-item",function(C){E.world.getItemCount()?E.source=E.world.getItemAt(0).source:E.source=null,t[E.hash].forceRedraw=!0}),this.world.addHandler("metrics-change",function(C){E.viewport&&E.viewport._setContentBounds(E.world.getHomeBounds(),E.world.getContentFactor())}),this.world.addHandler("item-index-change",function(C){E.source=E.world.getItemAt(0).source}),this.viewport=new e.Viewport({containerSize:t[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 e.ImageLoader({jobLimit:this.imageLoaderLimit,timeout:h.timeout,tileRetryMax:this.tileRetryMax,tileRetryDelay:this.tileRetryDelay}),this.tileCache=new e.TileCache({maxImageCacheCount:this.maxImageCacheCount}),Object.prototype.hasOwnProperty.call(this.drawerOptions,"useCanvas")&&(e.console.error('useCanvas is deprecated, use the "drawer" option to indicate preferred drawer(s)'),this.drawerOptions.useCanvas||(this.drawer=e.HTMLDrawer),delete this.drawerOptions.useCanvas);let O=Array.isArray(this.drawer)?this.drawer:[this.drawer];O.length===0&&(O=[e.DEFAULT_SETTINGS.drawer].flat(),e.console.warn("No valid drawers were selected. Using the default value.")),this.drawer=null;for(const C of O)if(this.requestDrawer(C,{mainDrawer:!0,redrawImmediately:!1}))break;if(!this.drawer)throw e.console.error("No drawer could be created!"),"Error with creating the selected drawer(s)";for(this.drawer.setImageSmoothingEnabled(this.imageSmoothingEnabled),this.overlaysContainer=e.makeNeutralElement("div"),this.canvas.appendChild(this.overlaysContainer),this.drawer.canRotate()||(this.rotateLeft&&(D=this.buttonGroup.buttons.indexOf(this.rotateLeft),this.buttonGroup.buttons.splice(D,1),this.buttonGroup.element.removeChild(this.rotateLeft.element)),this.rotateRight&&(D=this.buttonGroup.buttons.indexOf(this.rotateRight),this.buttonGroup.buttons.splice(D,1),this.buttonGroup.element.removeChild(this.rotateRight.element))),this._addUpdatePixelDensityRatioEvent(),this.showNavigator&&(this.navigator=new e.Navigator({element:this.navigatorElement,id:this.navigatorId,position:this.navigatorPosition,sizeRatio:this.navigatorSizeRatio,maintainSizeRatio:this.navigatorMaintainSizeRatio,top:this.navigatorTop,left:this.navigatorLeft,width:this.navigatorWidth,height:this.navigatorHeight,autoResize:this.navigatorAutoResize,autoFade:this.navigatorAutoFade,prefixUrl:this.prefixUrl,viewer:this,navigatorRotate:this.navigatorRotate,background:this.navigatorBackground,opacity:this.navigatorOpacity,borderColor:this.navigatorBorderColor,displayRegionColor:this.navigatorDisplayRegionColor,crossOriginPolicy:this.crossOriginPolicy,animationTime:this.animationTime,drawer:this.drawer.getType(),loadTilesWithAjax:this.loadTilesWithAjax,ajaxHeaders:this.ajaxHeaders,ajaxWithCredentials:this.ajaxWithCredentials})),this.sequenceMode&&this.bindSequenceControls(),this.tileSources&&this.open(this.tileSources),D=0;D<this.customControls.length;D++)this.addControl(this.customControls[D].id,{anchor:this.customControls[D].anchor});e.requestAnimationFrame(function(){u(E)}),e._viewers.set(this.element,this)},e.extend(e.Viewer.prototype,e.EventSource.prototype,e.ControlDock.prototype,{isOpen:function(){return!!this.world.getItemCount()},openDzi:function(h){return e.console.error("[Viewer.openDzi] this function is deprecated; use Viewer.open() instead."),this.open(h)},openTileSource:function(h){return e.console.error("[Viewer.openTileSource] this function is deprecated; use Viewer.open() instead."),this.open(h)},get buttons(){return e.console.warn("Viewer.buttons is deprecated; Please use Viewer.buttonGroup"),this.buttonGroup},open:function(h,p){var E=this;if(this.close(),!h)return this;if(this.sequenceMode&&e.isArray(h))return this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),typeof p<"u"&&!isNaN(p)&&(this.initialPage=p),this.tileSources=h,this._sequenceIndex=Math.max(0,Math.min(this.tileSources.length-1,this.initialPage)),this.tileSources.length&&(this.open(this.tileSources[this._sequenceIndex]),this.showReferenceStrip&&this.addReferenceStrip()),this._updateSequenceButtons(this._sequenceIndex),this;if(e.isArray(h)||(h=[h]),!h.length)return this;this._opening=!0;for(var D=h.length,B=0,O=0,C,k=function(){if(B+O===D)if(B){(E._firstOpen||!E.preserveViewport)&&(E.viewport.goHome(!0),E.viewport.update()),E._firstOpen=!1;var N=h[0];if(N.tileSource&&(N=N.tileSource),E.overlays&&!E.preserveOverlays)for(var K=0;K<E.overlays.length;K++)E.currentOverlays[K]=a(E,E.overlays[K]);E._drawOverlays(),E._opening=!1,E.raiseEvent("open",{source:N})}else E._opening=!1,E.raiseEvent("open-failed",C)},q=function(N){(!e.isPlainObject(N)||!N.tileSource)&&(N={tileSource:N}),N.index!==void 0&&(e.console.error("[Viewer.open] setting indexes here is not supported; use addTiledImage instead"),delete N.index),N.collectionImmediately===void 0&&(N.collectionImmediately=!0);var K=N.success;N.success=function(c){if(B++,N.tileSource.overlays)for(var g=0;g<N.tileSource.overlays.length;g++)E.addOverlay(N.tileSource.overlays[g]);K&&K(c),k()};var f=N.error;N.error=function(c){O++,C||(C=c),f&&f(c),k()},E.addTiledImage(N)},Q=0;Q<h.length;Q++)q(h[Q]);return this},close:function(){return t[this.hash]?(this._opening=!1,this.navigator&&this.navigator.close(),this.preserveOverlays||(this.clearOverlays(),this.overlaysContainer.innerHTML=""),t[this.hash].animating=!1,this.world.removeAll(),this.imageLoader.clear(),this.raiseEvent("close"),this):this},destroy:function(){if(t[this.hash]){if(this.raiseEvent("before-destroy"),this._removeUpdatePixelDensityRatioEvent(),this.close(),this.clearOverlays(),this.overlaysContainer.innerHTML="",this._resizeObserver&&this._resizeObserver.disconnect(),this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),this._updateRequestId!==null&&(e.cancelAnimationFrame(this._updateRequestId),this._updateRequestId=null),this.drawer&&this.drawer.destroy(),this.navigator&&(this.navigator.destroy(),t[this.navigator.hash]=null,delete t[this.navigator.hash],this.navigator=null),this.buttonGroup)this.buttonGroup.destroy();else if(this.customButtons)for(;this.customButtons.length;)this.customButtons.pop().destroy();if(this.paging&&this.paging.destroy(),this.element)for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);this.container.onsubmit=null,this.clearControls(),this.innerTracker&&this.innerTracker.destroy(),this.outerTracker&&this.outerTracker.destroy(),t[this.hash]=null,delete t[this.hash],this.canvas=null,this.container=null,e._viewers.delete(this.element),this.element=null,this.raiseEvent("destroy"),this.removeAllHandlers()}},requestDrawer(h,p){const E={mainDrawer:!0,redrawImmediately:!0,drawerOptions:null};p=e.extend(!0,E,p);const D=p.mainDrawer,B=p.redrawImmediately,O=p.drawerOptions,C=this.drawer;let k=null;if(h&&h.prototype instanceof e.DrawerBase?(k=h,h="custom"):typeof h=="string"&&(k=e.determineDrawer(h)),k||e.console.warn("Unsupported drawer! Drawer must be an existing string type, or a class that extends OpenSeadragon.DrawerBase."),k&&k.isSupported()){C&&D&&C.destroy();const q=new k({viewer:this,viewport:this.viewport,element:this.canvas,debugGridColor:this.debugGridColor,options:O||this.drawerOptions[h]});return D&&(this.drawer=q,B&&this.forceRedraw()),q}return!1},isMouseNavEnabled:function(){return this.innerTracker.isTracking()},setMouseNavEnabled:function(h){return this.innerTracker.setTracking(h),this.outerTracker.setTracking(h),this.raiseEvent("mouse-enabled",{enabled:h}),this},areControlsEnabled:function(){var h=this.controls.length,p;for(p=0;p<this.controls.length;p++)h=h&&this.controls[p].isVisible();return h},setControlsEnabled:function(h){return h?m(this):u(this),this.raiseEvent("controls-enabled",{enabled:h}),this},setDebugMode:function(h){for(var p=0;p<this.world.getItemCount();p++)this.world.getItemAt(p).debugMode=h;this.debugMode=h,this.forceRedraw()},setAjaxHeaders:function(h,p){if(h===null&&(h={}),!e.isPlainObject(h)){console.error("[Viewer.setAjaxHeaders] Ignoring invalid headers, must be a plain object");return}if(p===void 0&&(p=!0),this.ajaxHeaders=h,p){for(var E=0;E<this.world.getItemCount();E++)this.world.getItemAt(E)._updateAjaxHeaders(!0);if(this.navigator&&this.navigator.setAjaxHeaders(this.ajaxHeaders,!0),this.referenceStrip&&this.referenceStrip.miniViewers)for(var D in this.referenceStrip.miniViewers)this.referenceStrip.miniViewers[D].setAjaxHeaders(this.ajaxHeaders,!0)}},addButton:function(h){this.buttonGroup.addButton(h)},isFullPage:function(){return t[this.hash]&&t[this.hash].fullPage},setFullPage:function(h){var p=document.body,E=p.style,D=document.documentElement.style,B=this,O,C;if(h===this.isFullPage())return this;var k={fullPage:h,preventDefaultAction:!1};if(this.raiseEvent("pre-full-page",k),k.preventDefaultAction)return this;if(h&&this.element){for(this.elementSize=e.getElementSize(this.element),this.pageScroll=e.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=E.margin,this.docMargin=D.margin,E.margin="0",D.margin="0",this.bodyPadding=E.padding,this.docPadding=D.padding,E.padding="0",D.padding="0",this.bodyWidth=E.width,this.docWidth=D.width,E.width="100%",D.width="100%",this.bodyHeight=E.height,this.docHeight=D.height,E.height="100%",D.height="100%",this.bodyDisplay=E.display,E.display="block",this.previousBody=[],t[this.hash].prevElementParent=this.element.parentNode,t[this.hash].prevNextSibling=this.element.nextSibling,t[this.hash].prevElementWidth=this.element.style.width,t[this.hash].prevElementHeight=this.element.style.height,O=p.childNodes.length,C=0;C<O;C++)this.previousBody.push(p.childNodes[0]),p.removeChild(p.childNodes[0]);this.toolbar&&this.toolbar.element&&(this.toolbar.parentNode=this.toolbar.element.parentNode,this.toolbar.nextSibling=this.toolbar.element.nextSibling,p.appendChild(this.toolbar.element),e.addClass(this.toolbar.element,"fullpage")),e.addClass(this.element,"fullpage"),p.appendChild(this.element),this.element.style.height="100vh",this.element.style.width="100vw",this.toolbar&&this.toolbar.element&&(this.element.style.height=e.getElementSize(this.element).y-e.getElementSize(this.toolbar.element).y+"px"),t[this.hash].fullPage=!0,e.delegate(this,re)({})}else{for(this.element.style.margin=this.elementMargin,this.element.style.padding=this.elementPadding,E.margin=this.bodyMargin,D.margin=this.docMargin,E.padding=this.bodyPadding,D.padding=this.docPadding,E.width=this.bodyWidth,D.width=this.docWidth,E.height=this.bodyHeight,D.height=this.docHeight,E.display=this.bodyDisplay,p.removeChild(this.element),O=this.previousBody.length,C=0;C<O;C++)p.appendChild(this.previousBody.shift());e.removeClass(this.element,"fullpage"),t[this.hash].prevElementParent.insertBefore(this.element,t[this.hash].prevNextSibling),this.toolbar&&this.toolbar.element&&(p.removeChild(this.toolbar.element),e.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=t[this.hash].prevElementWidth,this.element.style.height=t[this.hash].prevElementHeight;var q=0,Q=function(){e.setPageScroll(B.pageScroll);var N=e.getPageScroll();q++,q<10&&(N.x!==B.pageScroll.x||N.y!==B.pageScroll.y)&&e.requestAnimationFrame(Q)};e.requestAnimationFrame(Q),t[this.hash].fullPage=!1,e.delegate(this,ge)({})}return this.navigator&&this.viewport&&this.navigator.update(this.viewport),this.raiseEvent("full-page",{fullPage:h}),this},setFullScreen:function(h){var p=this;if(!e.supportsFullScreen)return this.setFullPage(h);if(e.isFullScreen()===h)return this;var E={fullScreen:h,preventDefaultAction:!1};if(this.raiseEvent("pre-full-screen",E),E.preventDefaultAction)return this;if(h){if(this.setFullPage(!0),!this.isFullPage())return this;this.fullPageStyleWidth=this.element.style.width,this.fullPageStyleHeight=this.element.style.height,this.element.style.width="100%",this.element.style.height="100%";var D=function(){var B=e.isFullScreen();B||(e.removeEvent(document,e.fullScreenEventName,D),e.removeEvent(document,e.fullScreenErrorEventName,D),p.setFullPage(!1),p.isFullPage()&&(p.element.style.width=p.fullPageStyleWidth,p.element.style.height=p.fullPageStyleHeight)),p.navigator&&p.viewport&&setTimeout(function(){p.navigator.update(p.viewport)}),p.raiseEvent("full-screen",{fullScreen:B})};e.addEvent(document,e.fullScreenEventName,D),e.addEvent(document,e.fullScreenErrorEventName,D),e.requestFullScreen(document.body)}else e.exitFullScreen();return this},isVisible:function(){return this.container.style.visibility!=="hidden"},isFullScreen:function(){return e.isFullScreen()&&this.isFullPage()},setVisible:function(h){return this.container.style.visibility=h?"":"hidden",this.raiseEvent("visible",{visible:h}),this},addTiledImage:function(h){e.console.assert(h,"[Viewer.addTiledImage] options is required"),e.console.assert(h.tileSource,"[Viewer.addTiledImage] options.tileSource is required"),e.console.assert(!h.replace||h.index>-1&&h.index<this.world.getItemCount(),"[Viewer.addTiledImage] if options.replace is used, options.index must be a valid index in Viewer.world");var p=this;h.replace&&(h.replaceItem=p.world.getItemAt(h.index)),this._hideMessage(),h.placeholderFillStyle===void 0&&(h.placeholderFillStyle=this.placeholderFillStyle),h.opacity===void 0&&(h.opacity=this.opacity),h.preload===void 0&&(h.preload=this.preload),h.compositeOperation===void 0&&(h.compositeOperation=this.compositeOperation),h.crossOriginPolicy===void 0&&(h.crossOriginPolicy=h.tileSource.crossOriginPolicy!==void 0?h.tileSource.crossOriginPolicy:this.crossOriginPolicy),h.ajaxWithCredentials===void 0&&(h.ajaxWithCredentials=this.ajaxWithCredentials),h.loadTilesWithAjax===void 0&&(h.loadTilesWithAjax=this.loadTilesWithAjax),e.isPlainObject(h.ajaxHeaders)||(h.ajaxHeaders={});var E={options:h};function D(C){for(var k=0;k<p._loadQueue.length;k++)if(p._loadQueue[k]===E){p._loadQueue.splice(k,1);break}p._loadQueue.length===0&&B(E),p.raiseEvent("add-item-failed",C),h.error&&h.error(C)}function B(C){p.collectionMode&&(p.world.arrange({immediately:C.options.collectionImmediately,rows:p.collectionRows,columns:p.collectionColumns,layout:p.collectionLayout,tileSize:p.collectionTileSize,tileMargin:p.collectionTileMargin}),p.world.setAutoRefigureSizes(!0))}if(e.isArray(h.tileSource)){setTimeout(function(){D({message:"[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead.",source:h.tileSource,options:h})});return}this._loadQueue.push(E);function O(){for(var C,k,q;p._loadQueue.length&&(C=p._loadQueue[0],!!C.tileSource);){if(p._loadQueue.splice(0,1),C.options.replace){var Q=p.world.getIndexOfItem(C.options.replaceItem);Q!==-1&&(C.options.index=Q),p.world.removeItem(C.options.replaceItem)}k=new e.TiledImage({viewer:p,source:C.tileSource,viewport:p.viewport,drawer:p.drawer,tileCache:p.tileCache,imageLoader:p.imageLoader,x:C.options.x,y:C.options.y,width:C.options.width,height:C.options.height,fitBounds:C.options.fitBounds,fitBoundsPlacement:C.options.fitBoundsPlacement,clip:C.options.clip,placeholderFillStyle:C.options.placeholderFillStyle,opacity:C.options.opacity,preload:C.options.preload,degrees:C.options.degrees,flipped:C.options.flipped,compositeOperation:C.options.compositeOperation,springStiffness:p.springStiffness,animationTime:p.animationTime,minZoomImageRatio:p.minZoomImageRatio,wrapHorizontal:p.wrapHorizontal,wrapVertical:p.wrapVertical,maxTilesPerFrame:p.maxTilesPerFrame,immediateRender:p.immediateRender,blendTime:p.blendTime,alwaysBlend:p.alwaysBlend,minPixelRatio:p.minPixelRatio,smoothTileEdgesMinZoom:p.smoothTileEdgesMinZoom,iOSDevice:p.iOSDevice,crossOriginPolicy:C.options.crossOriginPolicy,ajaxWithCredentials:C.options.ajaxWithCredentials,loadTilesWithAjax:C.options.loadTilesWithAjax,ajaxHeaders:C.options.ajaxHeaders,debugMode:p.debugMode,subPixelRoundingForTransparency:p.subPixelRoundingForTransparency}),p.collectionMode&&p.world.setAutoRefigureSizes(!1),p.navigator&&(q=e.extend({},C.options,{replace:!1,originalTiledImage:k,tileSource:C.tileSource}),p.navigator.addTiledImage(q)),p.world.addItem(k,{index:C.options.index}),p._loadQueue.length===0&&B(C),p.world.getItemCount()===1&&!p.preserveViewport&&p.viewport.goHome(!0),C.options.success&&C.options.success({item:k})}}r(this,h.tileSource,h,function(C){E.tileSource=C,O()},function(C){C.options=h,D(C),O()})},addSimpleImage:function(h){e.console.assert(h,"[Viewer.addSimpleImage] options is required"),e.console.assert(h.url,"[Viewer.addSimpleImage] options.url is required");var p=e.extend({},h,{tileSource:{type:"image",url:h.url}});delete p.url,this.addTiledImage(p)},addLayer:function(h){var p=this;e.console.error("[Viewer.addLayer] this function is deprecated; use Viewer.addTiledImage() instead.");var E=e.extend({},h,{success:function(D){p.raiseEvent("add-layer",{options:h,drawer:D.item})},error:function(D){p.raiseEvent("add-layer-failed",D)}});return this.addTiledImage(E),this},getLayerAtLevel:function(h){return e.console.error("[Viewer.getLayerAtLevel] this function is deprecated; use World.getItemAt() instead."),this.world.getItemAt(h)},getLevelOfLayer:function(h){return e.console.error("[Viewer.getLevelOfLayer] this function is deprecated; use World.getIndexOfItem() instead."),this.world.getIndexOfItem(h)},getLayersCount:function(){return e.console.error("[Viewer.getLayersCount] this function is deprecated; use World.getItemCount() instead."),this.world.getItemCount()},setLayerLevel:function(h,p){return e.console.error("[Viewer.setLayerLevel] this function is deprecated; use World.setItemIndex() instead."),this.world.setItemIndex(h,p)},removeLayer:function(h){return e.console.error("[Viewer.removeLayer] this function is deprecated; use World.removeItem() instead."),this.world.removeItem(h)},forceRedraw:function(){return t[this.hash].forceRedraw=!0,this},forceResize:function(){t[this.hash].needsResize=!0,t[this.hash].forceResize=!0},bindSequenceControls:function(){var h=e.delegate(this,v),p=e.delegate(this,y),E=e.delegate(this,this.goToNextPage),D=e.delegate(this,this.goToPreviousPage),B=this.navImages,O=!0;return this.showSequenceControl&&((this.previousButton||this.nextButton)&&(O=!1),this.previousButton=new e.Button({element:this.previousButton?e.getElement(this.previousButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.PreviousPage"),srcRest:G(this.prefixUrl,B.previous.REST),srcGroup:G(this.prefixUrl,B.previous.GROUP),srcHover:G(this.prefixUrl,B.previous.HOVER),srcDown:G(this.prefixUrl,B.previous.DOWN),onRelease:D,onFocus:h,onBlur:p}),this.nextButton=new e.Button({element:this.nextButton?e.getElement(this.nextButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.NextPage"),srcRest:G(this.prefixUrl,B.next.REST),srcGroup:G(this.prefixUrl,B.next.GROUP),srcHover:G(this.prefixUrl,B.next.HOVER),srcDown:G(this.prefixUrl,B.next.DOWN),onRelease:E,onFocus:h,onBlur:p}),this.navPrevNextWrap||this.previousButton.disable(),(!this.tileSources||!this.tileSources.length)&&this.nextButton.disable(),O&&(this.paging=new e.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:e.ControlAnchor.BOTTOM_RIGHT}):this.addControl(this.pagingControl,{anchor:this.sequenceControlAnchor||e.ControlAnchor.TOP_LEFT}))),this},bindStandardControls:function(){var h=e.delegate(this,Re),p=e.delegate(this,Ce),E=e.delegate(this,He),D=e.delegate(this,be),B=e.delegate(this,Fe),O=e.delegate(this,ke),C=e.delegate(this,Ie),k=e.delegate(this,Ne),q=e.delegate(this,Se),Q=e.delegate(this,xe),N=e.delegate(this,v),K=e.delegate(this,y),f=this.navImages,c=[],g=!0;return this.showNavigationControl&&((this.zoomInButton||this.zoomOutButton||this.homeButton||this.fullPageButton||this.rotateLeftButton||this.rotateRightButton||this.flipButton)&&(g=!1),this.showZoomControl&&(c.push(this.zoomInButton=new e.Button({element:this.zoomInButton?e.getElement(this.zoomInButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.ZoomIn"),srcRest:G(this.prefixUrl,f.zoomIn.REST),srcGroup:G(this.prefixUrl,f.zoomIn.GROUP),srcHover:G(this.prefixUrl,f.zoomIn.HOVER),srcDown:G(this.prefixUrl,f.zoomIn.DOWN),onPress:h,onRelease:p,onClick:E,onEnter:h,onExit:p,onFocus:N,onBlur:K})),c.push(this.zoomOutButton=new e.Button({element:this.zoomOutButton?e.getElement(this.zoomOutButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.ZoomOut"),srcRest:G(this.prefixUrl,f.zoomOut.REST),srcGroup:G(this.prefixUrl,f.zoomOut.GROUP),srcHover:G(this.prefixUrl,f.zoomOut.HOVER),srcDown:G(this.prefixUrl,f.zoomOut.DOWN),onPress:D,onRelease:p,onClick:B,onEnter:D,onExit:p,onFocus:N,onBlur:K}))),this.showHomeControl&&c.push(this.homeButton=new e.Button({element:this.homeButton?e.getElement(this.homeButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.Home"),srcRest:G(this.prefixUrl,f.home.REST),srcGroup:G(this.prefixUrl,f.home.GROUP),srcHover:G(this.prefixUrl,f.home.HOVER),srcDown:G(this.prefixUrl,f.home.DOWN),onRelease:O,onFocus:N,onBlur:K})),this.showFullPageControl&&c.push(this.fullPageButton=new e.Button({element:this.fullPageButton?e.getElement(this.fullPageButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.FullPage"),srcRest:G(this.prefixUrl,f.fullpage.REST),srcGroup:G(this.prefixUrl,f.fullpage.GROUP),srcHover:G(this.prefixUrl,f.fullpage.HOVER),srcDown:G(this.prefixUrl,f.fullpage.DOWN),onRelease:C,onFocus:N,onBlur:K})),this.showRotationControl&&(c.push(this.rotateLeftButton=new e.Button({element:this.rotateLeftButton?e.getElement(this.rotateLeftButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.RotateLeft"),srcRest:G(this.prefixUrl,f.rotateleft.REST),srcGroup:G(this.prefixUrl,f.rotateleft.GROUP),srcHover:G(this.prefixUrl,f.rotateleft.HOVER),srcDown:G(this.prefixUrl,f.rotateleft.DOWN),onRelease:k,onFocus:N,onBlur:K})),c.push(this.rotateRightButton=new e.Button({element:this.rotateRightButton?e.getElement(this.rotateRightButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.RotateRight"),srcRest:G(this.prefixUrl,f.rotateright.REST),srcGroup:G(this.prefixUrl,f.rotateright.GROUP),srcHover:G(this.prefixUrl,f.rotateright.HOVER),srcDown:G(this.prefixUrl,f.rotateright.DOWN),onRelease:q,onFocus:N,onBlur:K}))),this.showFlipControl&&c.push(this.flipButton=new e.Button({element:this.flipButton?e.getElement(this.flipButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:e.getString("Tooltips.Flip"),srcRest:G(this.prefixUrl,f.flip.REST),srcGroup:G(this.prefixUrl,f.flip.GROUP),srcHover:G(this.prefixUrl,f.flip.HOVER),srcDown:G(this.prefixUrl,f.flip.DOWN),onRelease:Q,onFocus:N,onBlur:K})),g?(this.buttonGroup=new e.ButtonGroup({buttons:c,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.navControl=this.buttonGroup.element,this.addHandler("open",e.delegate(this,Be)),this.toolbar?this.toolbar.addControl(this.navControl,{anchor:this.navigationControlAnchor||e.ControlAnchor.TOP_LEFT}):this.addControl(this.navControl,{anchor:this.navigationControlAnchor||e.ControlAnchor.TOP_LEFT})):this.customButtons=c),this},currentPage:function(){return this._sequenceIndex},goToPage:function(h){return this.tileSources&&h>=0&&h<this.tileSources.length&&(this._sequenceIndex=h,this._updateSequenceButtons(h),this.open(this.tileSources[h]),this.referenceStrip&&this.referenceStrip.setFocus(h),this.raiseEvent("page",{page:h})),this},addOverlay:function(h,p,E,D){var B;if(e.isPlainObject(h)?B=h:B={element:h,location:p,placement:E,onDraw:D},h=e.getElement(B.element),s(this.currentOverlays,h)>=0)return this;var O=a(this,B);return this.currentOverlays.push(O),O.drawHTML(this.overlaysContainer,this.viewport),this.raiseEvent("add-overlay",{element:h,location:B.location,placement:B.placement}),this},updateOverlay:function(h,p,E){var D;return h=e.getElement(h),D=s(this.currentOverlays,h),D>=0&&(this.currentOverlays[D].update(p,E),t[this.hash].forceRedraw=!0,this.raiseEvent("update-overlay",{element:h,location:p,placement:E})),this},removeOverlay:function(h){var p;return h=e.getElement(h),p=s(this.currentOverlays,h),p>=0&&(this.currentOverlays[p].destroy(),this.currentOverlays.splice(p,1),t[this.hash].forceRedraw=!0,this.raiseEvent("remove-overlay",{element:h})),this},clearOverlays:function(){for(;this.currentOverlays.length>0;)this.currentOverlays.pop().destroy();return t[this.hash].forceRedraw=!0,this.raiseEvent("clear-overlay",{}),this},getOverlayById:function(h){var p;return h=e.getElement(h),p=s(this.currentOverlays,h),p>=0?this.currentOverlays[p]:null},_updateSequenceButtons:function(h){this.nextButton&&(!this.tileSources||this.tileSources.length-1===h?this.navPrevNextWrap||this.nextButton.disable():this.nextButton.enable()),this.previousButton&&(h>0?this.previousButton.enable():this.navPrevNextWrap||this.previousButton.disable())},_showMessage:function(h){this._hideMessage();var p=e.makeNeutralElement("div");p.appendChild(document.createTextNode(h)),this.messageDiv=e.makeCenteredNode(p),e.addClass(this.messageDiv,"openseadragon-message"),this.container.appendChild(this.messageDiv)},_hideMessage:function(){var h=this.messageDiv;h&&(h.parentNode.removeChild(h),delete this.messageDiv)},gestureSettingsByDeviceType:function(h){switch(h){case"mouse":return this.gestureSettingsMouse;case"touch":return this.gestureSettingsTouch;case"pen":return this.gestureSettingsPen;default:return this.gestureSettingsUnknown}},_drawOverlays:function(){var h,p=this.currentOverlays.length;for(h=0;h<p;h++)this.currentOverlays[h].drawHTML(this.overlaysContainer,this.viewport)},_cancelPendingImages:function(){this._loadQueue=[]},removeReferenceStrip:function(){this.showReferenceStrip=!1,this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null)},addReferenceStrip:function(){if(this.showReferenceStrip=!0,this.sequenceMode){if(this.referenceStrip)return;this.tileSources.length&&this.tileSources.length>1&&(this.referenceStrip=new e.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 e.console.warn('Attempting to display a reference strip while "sequenceMode" is off.')},_addUpdatePixelDensityRatioEvent:function(){this._updatePixelDensityRatioBind=this._updatePixelDensityRatio.bind(this),e.addEvent(window,"resize",this._updatePixelDensityRatioBind)},_removeUpdatePixelDensityRatioEvent:function(){e.removeEvent(window,"resize",this._updatePixelDensityRatioBind)},_updatePixelDensityRatio:function(){var h=e.pixelDensityRatio,p=e.getCurrentPixelDensityRatio();h!==p&&(e.pixelDensityRatio=p,this.world.resetItems(),this.forceRedraw())},goToPreviousPage:function(){var h=this._sequenceIndex-1;this.navPrevNextWrap&&h<0&&(h+=this.tileSources.length),this.goToPage(h)},goToNextPage:function(){var h=this._sequenceIndex+1;this.navPrevNextWrap&&h>=this.tileSources.length&&(h=0),this.goToPage(h)},isAnimating:function(){return t[this.hash].animating}});function i(h){return h=e.getElement(h),new e.Point(h.clientWidth===0?1:h.clientWidth,h.clientHeight===0?1:h.clientHeight)}function r(h,p,E,D,B){var O=h;if(e.type(p)==="string"){if(p.match(/^\s*<.*>\s*$/))p=e.parseXml(p);else if(p.match(/^\s*[{[].*[}\]]\s*$/))try{var C=e.parseJSON(p);p=C}catch{}}function k(q,Q){q.ready?D(q):(q.addHandler("ready",function(){D(q)}),q.addHandler("open-failed",function(N){B({message:N.message,source:Q})}))}setTimeout(function(){if(e.type(p)==="string")p=new e.TileSource({url:p,crossOriginPolicy:E.crossOriginPolicy!==void 0?E.crossOriginPolicy:h.crossOriginPolicy,ajaxWithCredentials:h.ajaxWithCredentials,ajaxHeaders:E.ajaxHeaders?E.ajaxHeaders:h.ajaxHeaders,splitHashDataForPost:h.splitHashDataForPost,success:function(K){D(K.tileSource)}}),p.addHandler("open-failed",function(K){B(K)});else if(e.isPlainObject(p)||p.nodeType)if(p.crossOriginPolicy===void 0&&(E.crossOriginPolicy!==void 0||h.crossOriginPolicy!==void 0)&&(p.crossOriginPolicy=E.crossOriginPolicy!==void 0?E.crossOriginPolicy:h.crossOriginPolicy),p.ajaxWithCredentials===void 0&&(p.ajaxWithCredentials=h.ajaxWithCredentials),e.isFunction(p.getTileUrl)){var q=new e.TileSource(p);q.getTileUrl=p.getTileUrl,D(q)}else{var Q=e.TileSource.determineType(O,p);if(!Q){B({message:"Unable to load TileSource",source:p});return}var N=Q.prototype.configure.apply(O,[p]);k(new Q(N),p)}else k(p,p)})}function a(h,p){if(p instanceof e.Overlay)return p;var E=null;if(p.element)E=e.getElement(p.element);else{var D=p.id?p.id:"openseadragon-overlay-"+Math.floor(Math.random()*1e7);E=e.getElement(p.id),E||(E=document.createElement("a"),E.href="#/overlay/"+D),E.id=D,e.addClass(E,p.className?p.className:"openseadragon-overlay")}var B=p.location,O=p.width,C=p.height;if(!B){var k=p.x,q=p.y;if(p.px!==void 0){var Q=h.viewport.imageToViewportRectangle(new e.Rect(p.px,p.py,O||0,C||0));k=Q.x,q=Q.y,O=O!==void 0?Q.width:void 0,C=C!==void 0?Q.height:void 0}B=new e.Point(k,q)}var N=p.placement;return N&&e.type(N)==="string"&&(N=e.Placement[p.placement.toUpperCase()]),new e.Overlay({element:E,location:B,placement:N,onDraw:p.onDraw,checkResize:p.checkResize,width:O,height:C,rotationMode:p.rotationMode})}function s(h,p){var E;for(E=h.length-1;E>=0;E--)if(h[E].element===p)return E;return-1}function o(h,p){return e.requestAnimationFrame(function(){p(h)})}function l(h){e.requestAnimationFrame(function(){d(h)})}function u(h){h.autoHideControls&&(h.controlsShouldFade=!0,h.controlsFadeBeginTime=e.now()+h.controlsFadeDelay,window.setTimeout(function(){l(h)},h.controlsFadeDelay))}function d(h){var p,E,D,B;if(h.controlsShouldFade){for(p=e.now(),E=p-h.controlsFadeBeginTime,D=1-E/h.controlsFadeLength,D=Math.min(1,D),D=Math.max(0,D),B=h.controls.length-1;B>=0;B--)h.controls[B].autoFade&&h.controls[B].setOpacity(D);D>0&&l(h)}}function m(h){var p;for(h.controlsShouldFade=!1,p=h.controls.length-1;p>=0;p--)h.controls[p].setOpacity(1)}function v(){m(this)}function y(){u(this)}function T(h){var p={tracker:h.eventSource,position:h.position,originalEvent:h.originalEvent,preventDefault:h.preventDefault};this.raiseEvent("canvas-contextmenu",p),h.preventDefault=p.preventDefault}function _(h){var p={originalEvent:h.originalEvent,preventDefaultAction:!1,preventVerticalPan:h.preventVerticalPan||!this.panVertical,preventHorizontalPan:h.preventHorizontalPan||!this.panHorizontal};if(this.raiseEvent("canvas-key",p),!p.preventDefaultAction&&!h.ctrl&&!h.alt&&!h.meta)switch(h.keyCode){case 38:p.preventVerticalPan||(h.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,-this.pixelsPerArrowPress))),this.viewport.applyConstraints()),h.preventDefault=!0;break;case 40:p.preventVerticalPan||(h.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,this.pixelsPerArrowPress))),this.viewport.applyConstraints()),h.preventDefault=!0;break;case 37:p.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(-this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),h.preventDefault=!0;break;case 39:p.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),h.preventDefault=!0;break;case 187:this.viewport.zoomBy(1.1),this.viewport.applyConstraints(),h.preventDefault=!0;break;case 189:this.viewport.zoomBy(.9),this.viewport.applyConstraints(),h.preventDefault=!0;break;case 48:this.viewport.goHome(),this.viewport.applyConstraints(),h.preventDefault=!0;break;case 87:p.preventVerticalPan||(h.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,-40))),this.viewport.applyConstraints()),h.preventDefault=!0;break;case 83:p.preventVerticalPan||(h.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,40))),this.viewport.applyConstraints()),h.preventDefault=!0;break;case 65:p.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(-40,0))),this.viewport.applyConstraints()),h.preventDefault=!0;break;case 68:p.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(40,0))),this.viewport.applyConstraints()),h.preventDefault=!0;break;case 82:h.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(),h.preventDefault=!0;break;case 70:this.viewport.toggleFlip(),h.preventDefault=!0;break;case 74:this.goToPreviousPage();break;case 75:this.goToNextPage();break;default:h.preventDefault=!1;break}else h.preventDefault=!1}function S(h){var p={originalEvent:h.originalEvent};this.raiseEvent("canvas-key-press",p)}function b(h){var p,E=document.activeElement===this.canvas;E||this.canvas.focus(),this.viewport.flipped&&(h.position.x=this.viewport.getContainerSize().x-h.position.x);var D={tracker:h.eventSource,position:h.position,quick:h.quick,shift:h.shift,originalEvent:h.originalEvent,originalTarget:h.originalTarget,preventDefaultAction:!1};this.raiseEvent("canvas-click",D),!D.preventDefaultAction&&this.viewport&&h.quick&&(p=this.gestureSettingsByDeviceType(h.pointerType),p.clickToZoom===!0&&(this.viewport.zoomBy(h.shift?1/this.zoomPerClick:this.zoomPerClick,p.zoomToRefPoint?this.viewport.pointFromPixel(h.position,!0):null),this.viewport.applyConstraints()),p.dblClickDragToZoom&&(t[this.hash].draggingToZoom===!0?(t[this.hash].lastClickTime=null,t[this.hash].draggingToZoom=!1):t[this.hash].lastClickTime=e.now()))}function L(h){var p,E={tracker:h.eventSource,position:h.position,shift:h.shift,originalEvent:h.originalEvent,preventDefaultAction:!1};this.raiseEvent("canvas-double-click",E),!E.preventDefaultAction&&this.viewport&&(p=this.gestureSettingsByDeviceType(h.pointerType),p.dblClickToZoom&&(this.viewport.zoomBy(h.shift?1/this.zoomPerClick:this.zoomPerClick,p.zoomToRefPoint?this.viewport.pointFromPixel(h.position,!0):null),this.viewport.applyConstraints()))}function I(h){var p,E={tracker:h.eventSource,pointerType:h.pointerType,position:h.position,delta:h.delta,speed:h.speed,direction:h.direction,shift:h.shift,originalEvent:h.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag",E),p=this.gestureSettingsByDeviceType(h.pointerType),!E.preventDefaultAction&&this.viewport){if(p.dblClickDragToZoom&&t[this.hash].draggingToZoom){var D=Math.pow(this.zoomPerDblClickDrag,h.delta.y/50);this.viewport.zoomBy(D)}else if(p.dragToPan&&!t[this.hash].draggingToZoom){if(this.panHorizontal||(h.delta.x=0),this.panVertical||(h.delta.y=0),this.viewport.flipped&&(h.delta.x=-h.delta.x),this.constrainDuringPan){var B=this.viewport.deltaPointsFromPixels(h.delta.negate());this.viewport.centerSpringX.target.value+=B.x,this.viewport.centerSpringY.target.value+=B.y;var O=this.viewport.getConstrainedBounds();this.viewport.centerSpringX.target.value-=B.x,this.viewport.centerSpringY.target.value-=B.y,O.xConstrained&&(h.delta.x=0),O.yConstrained&&(h.delta.y=0)}this.viewport.panBy(this.viewport.deltaPointsFromPixels(h.delta.negate()),p.flickEnabled&&!this.constrainDuringPan)}}}function M(h){var p,E={tracker:h.eventSource,pointerType:h.pointerType,position:h.position,speed:h.speed,direction:h.direction,shift:h.shift,originalEvent:h.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag-end",E),p=this.gestureSettingsByDeviceType(h.pointerType),!E.preventDefaultAction&&this.viewport){if(!t[this.hash].draggingToZoom&&p.dragToPan&&p.flickEnabled&&h.speed>=p.flickMinSpeed){var D=0;this.panHorizontal&&(D=p.flickMomentum*h.speed*Math.cos(h.direction));var B=0;this.panVertical&&(B=p.flickMomentum*h.speed*Math.sin(h.direction));var O=this.viewport.pixelFromPoint(this.viewport.getCenter(!0)),C=this.viewport.pointFromPixel(new e.Point(O.x-D,O.y-B));this.viewport.panTo(C,!1)}this.viewport.applyConstraints()}p.dblClickDragToZoom&&t[this.hash].draggingToZoom===!0&&(t[this.hash].draggingToZoom=!1)}function Z(h){this.raiseEvent("canvas-enter",{tracker:h.eventSource,pointerType:h.pointerType,position:h.position,buttons:h.buttons,pointers:h.pointers,insideElementPressed:h.insideElementPressed,buttonDownAny:h.buttonDownAny,originalEvent:h.originalEvent})}function V(h){this.raiseEvent("canvas-exit",{tracker:h.eventSource,pointerType:h.pointerType,position:h.position,buttons:h.buttons,pointers:h.pointers,insideElementPressed:h.insideElementPressed,buttonDownAny:h.buttonDownAny,originalEvent:h.originalEvent})}function j(h){var p;if(this.raiseEvent("canvas-press",{tracker:h.eventSource,pointerType:h.pointerType,position:h.position,insideElementPressed:h.insideElementPressed,insideElementReleased:h.insideElementReleased,originalEvent:h.originalEvent}),p=this.gestureSettingsByDeviceType(h.pointerType),p.dblClickDragToZoom){var E=t[this.hash].lastClickTime,D=e.now();if(E===null)return;D-E<this.dblClickTimeThreshold&&(t[this.hash].draggingToZoom=!0),t[this.hash].lastClickTime=null}}function J(h){this.raiseEvent("canvas-release",{tracker:h.eventSource,pointerType:h.pointerType,position:h.position,insideElementPressed:h.insideElementPressed,insideElementReleased:h.insideElementReleased,originalEvent:h.originalEvent})}function W(h){this.raiseEvent("canvas-nonprimary-press",{tracker:h.eventSource,position:h.position,pointerType:h.pointerType,button:h.button,buttons:h.buttons,originalEvent:h.originalEvent})}function U(h){this.raiseEvent("canvas-nonprimary-release",{tracker:h.eventSource,position:h.position,pointerType:h.pointerType,button:h.button,buttons:h.buttons,originalEvent:h.originalEvent})}function $(h){var p,E,D,B,O={tracker:h.eventSource,pointerType:h.pointerType,gesturePoints:h.gesturePoints,lastCenter:h.lastCenter,center:h.center,lastDistance:h.lastDistance,distance:h.distance,shift:h.shift,originalEvent:h.originalEvent,preventDefaultPanAction:!1,preventDefaultZoomAction:!1,preventDefaultRotateAction:!1};if(this.raiseEvent("canvas-pinch",O),this.viewport&&(p=this.gestureSettingsByDeviceType(h.pointerType),p.pinchToZoom&&(!O.preventDefaultPanAction||!O.preventDefaultZoomAction)&&(E=this.viewport.pointFromPixel(h.center,!0),p.zoomToRefPoint&&!O.preventDefaultPanAction&&(D=this.viewport.pointFromPixel(h.lastCenter,!0),B=D.minus(E),this.panHorizontal||(B.x=0),this.panVertical||(B.y=0),this.viewport.panBy(B,!0)),O.preventDefaultZoomAction||this.viewport.zoomBy(h.distance/h.lastDistance,E,!0),this.viewport.applyConstraints()),p.pinchRotate&&!O.preventDefaultRotateAction)){var C=Math.atan2(h.gesturePoints[0].currentPos.y-h.gesturePoints[1].currentPos.y,h.gesturePoints[0].currentPos.x-h.gesturePoints[1].currentPos.x),k=Math.atan2(h.gesturePoints[0].lastPos.y-h.gesturePoints[1].lastPos.y,h.gesturePoints[0].lastPos.x-h.gesturePoints[1].lastPos.x);E=this.viewport.pointFromPixel(h.center,!0),this.viewport.rotateTo(this.viewport.getRotation(!0)+(C-k)*(180/Math.PI),E,!0)}}function ne(h){this.raiseEvent("canvas-focus",{tracker:h.eventSource,originalEvent:h.originalEvent})}function te(h){this.raiseEvent("canvas-blur",{tracker:h.eventSource,originalEvent:h.originalEvent})}function se(h){var p,E,D,B,O;B=e.now(),O=B-this._lastScrollTime,O>this.minScrollDeltaTime?(this._lastScrollTime=B,p={tracker:h.eventSource,position:h.position,scroll:h.scroll,shift:h.shift,originalEvent:h.originalEvent,preventDefaultAction:!1,preventDefault:!0},this.raiseEvent("canvas-scroll",p),!p.preventDefaultAction&&this.viewport&&(this.viewport.flipped&&(h.position.x=this.viewport.getContainerSize().x-h.position.x),E=this.gestureSettingsByDeviceType(h.pointerType),E.scrollToZoom&&(D=Math.pow(this.zoomPerScroll,h.scroll),this.viewport.zoomBy(D,E.zoomToRefPoint?this.viewport.pointFromPixel(h.position,!0):null),this.viewport.applyConstraints())),h.preventDefault=p.preventDefault):h.preventDefault=!0}function re(h){t[this.hash].mouseInside=!0,m(this),this.raiseEvent("container-enter",{tracker:h.eventSource,pointerType:h.pointerType,position:h.position,buttons:h.buttons,pointers:h.pointers,insideElementPressed:h.insideElementPressed,buttonDownAny:h.buttonDownAny,originalEvent:h.originalEvent})}function ge(h){h.pointers<1&&(t[this.hash].mouseInside=!1,t[this.hash].animating||u(this)),this.raiseEvent("container-exit",{tracker:h.eventSource,pointerType:h.pointerType,position:h.position,buttons:h.buttons,pointers:h.pointers,insideElementPressed:h.insideElementPressed,buttonDownAny:h.buttonDownAny,originalEvent:h.originalEvent})}function ye(h){Me(h),h.isOpen()?h._updateRequestId=o(h,ye):h._updateRequestId=!1}function ve(h,p){var E=h.viewport,D=E.getZoom(),B=E.getCenter();E.resize(p,h.preserveImageSizeOnResize),E.panTo(B,!0);var O;if(h.preserveImageSizeOnResize)O=t[h.hash].prevContainerSize.x/p.x;else{var C=new e.Point(0,0),k=new e.Point(t[h.hash].prevContainerSize.x,t[h.hash].prevContainerSize.y).distanceTo(C),q=new e.Point(p.x,p.y).distanceTo(C);O=q/k*t[h.hash].prevContainerSize.x/p.x}E.zoomTo(D*O,null,!0),t[h.hash].prevContainerSize=p,t[h.hash].forceRedraw=!0,t[h.hash].needsResize=!1,t[h.hash].forceResize=!1}function Me(h){if(!(h._opening||!t[h.hash])){if(h.autoResize||t[h.hash].forceResize){var p;if(h._autoResizePolling){p=i(h.container);var E=t[h.hash].prevContainerSize;p.equals(E)||(t[h.hash].needsResize=!0)}t[h.hash].needsResize&&ve(h,p||i(h.container))}var D=h.viewport.update(),B=h.world.update(D)||D;D&&h.raiseEvent("viewport-change"),h.referenceStrip&&(B=h.referenceStrip.update(h.viewport)||B);var O=t[h.hash].animating;!O&&B&&(h.raiseEvent("animation-start"),m(h));var C=O&&!B;C&&(t[h.hash].animating=!1),(B||C||t[h.hash].forceRedraw||h.world.needsDraw())&&(Le(h),h._drawOverlays(),h.navigator&&h.navigator.update(h.viewport),t[h.hash].forceRedraw=!1,B&&h.raiseEvent("animation")),C&&(h.raiseEvent("animation-finish"),t[h.hash].mouseInside||u(h)),t[h.hash].animating=B}}function Le(h){h.imageLoader.clear(),h.world.draw(),h.raiseEvent("update-viewport",{})}function G(h,p){return h?h+p:p}function Re(){t[this.hash].lastZoomTime=e.now(),t[this.hash].zoomFactor=this.zoomPerSecond,t[this.hash].zooming=!0,_e(this)}function be(){t[this.hash].lastZoomTime=e.now(),t[this.hash].zoomFactor=1/this.zoomPerSecond,t[this.hash].zooming=!0,_e(this)}function Ce(){t[this.hash].zooming=!1}function _e(h){e.requestAnimationFrame(e.delegate(h,De))}function De(){var h,p,E;t[this.hash].zooming&&this.viewport&&(h=e.now(),p=h-t[this.hash].lastZoomTime,E=Math.pow(t[this.hash].zoomFactor,p/1e3),this.viewport.zoomBy(E),this.viewport.applyConstraints(),t[this.hash].lastZoomTime=h,_e(this))}function He(){this.viewport&&(t[this.hash].zooming=!1,this.viewport.zoomBy(this.zoomPerClick/1),this.viewport.applyConstraints())}function Fe(){this.viewport&&(t[this.hash].zooming=!1,this.viewport.zoomBy(1/this.zoomPerClick),this.viewport.applyConstraints())}function Be(){this.buttonGroup&&(this.buttonGroup.emulateEnter(),this.buttonGroup.emulateLeave())}function ke(){this.viewport&&this.viewport.goHome()}function Ie(){this.isFullPage()&&!e.isFullScreen()?this.setFullPage(!1):this.setFullScreen(!this.isFullPage()),this.buttonGroup&&this.buttonGroup.emulateLeave(),this.fullPageButton.element.focus(),this.viewport&&this.viewport.applyConstraints()}function Ne(){if(this.viewport){var h=this.viewport.getRotation();this.viewport.flipped?h+=this.rotationIncrement:h-=this.rotationIncrement,this.viewport.setRotation(h)}}function Se(){if(this.viewport){var h=this.viewport.getRotation();this.viewport.flipped?h-=this.rotationIncrement:h+=this.rotationIncrement,this.viewport.setRotation(h)}}function xe(){this.viewport.toggleFlip()}e.determineDrawer=function(h){for(let p in x){const E=x[p],D=E.prototype;if(D&&D instanceof x.DrawerBase&&e.isFunction(D.getType)&&D.getType.call(E)===h)return E}return null}}(x),function(e){e.Navigator=function(o){var l=o.viewer,u=this,d,m;o.element||o.id?(o.element?(o.id&&e.console.warn("Given option.id for Navigator was ignored since option.element was provided and is being used instead."),o.element.id?o.id=o.element.id:o.id="navigator-"+e.now(),this.element=o.element):this.element=document.getElementById(o.id),o.controlOptions={anchor:e.ControlAnchor.NONE,attachToViewer:!1,autoFade:!1}):(o.id="navigator-"+e.now(),this.element=e.makeNeutralElement("div"),o.controlOptions={anchor:e.ControlAnchor.TOP_RIGHT,attachToViewer:!0,autoFade:o.autoFade},o.position&&(o.position==="BOTTOM_RIGHT"?o.controlOptions.anchor=e.ControlAnchor.BOTTOM_RIGHT:o.position==="BOTTOM_LEFT"?o.controlOptions.anchor=e.ControlAnchor.BOTTOM_LEFT:o.position==="TOP_RIGHT"?o.controlOptions.anchor=e.ControlAnchor.TOP_RIGHT:o.position==="TOP_LEFT"?o.controlOptions.anchor=e.ControlAnchor.TOP_LEFT:o.position==="ABSOLUTE"&&(o.controlOptions.anchor=e.ControlAnchor.ABSOLUTE,o.controlOptions.top=o.top,o.controlOptions.left=o.left,o.controlOptions.height=o.height,o.controlOptions.width=o.width))),this.element.id=o.id,this.element.className+=" navigator",o=e.extend(!0,{sizeRatio:e.DEFAULT_SETTINGS.navigatorSizeRatio},o,{element:this.element,tabIndex:-1,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:o.animationTime,autoResize:!1,minZoomImageRatio:1,background:o.background,opacity:o.opacity,borderColor:o.borderColor,displayRegionColor:o.displayRegionColor}),o.minPixelRatio=this.minPixelRatio=l.minPixelRatio,e.setElementTouchActionNone(this.element),this.borderWidth=2,this.fudge=new e.Point(1,1),this.totalBorderWidths=new e.Point(this.borderWidth*2,this.borderWidth*2).minus(this.fudge),o.controlOptions.anchor!==e.ControlAnchor.NONE&&function(T,_){T.margin="0px",T.border=_+"px solid "+o.borderColor,T.padding="0px",T.background=o.background,T.opacity=o.opacity,T.overflow="hidden"}(this.element.style,this.borderWidth),this.displayRegion=e.makeNeutralElement("div"),this.displayRegion.id=this.element.id+"-displayregion",this.displayRegion.className="displayregion",function(T,_){T.position="relative",T.top="0px",T.left="0px",T.fontSize="0px",T.overflow="hidden",T.border=_+"px solid "+o.displayRegionColor,T.margin="0px",T.padding="0px",T.background="transparent",T.float="left",T.cssFloat="left",T.zIndex=999999999,T.cursor="default",T.boxSizing="content-box"}(this.displayRegion.style,this.borderWidth),e.setElementPointerEventsNone(this.displayRegion),e.setElementTouchActionNone(this.displayRegion),this.displayRegionContainer=e.makeNeutralElement("div"),this.displayRegionContainer.id=this.element.id+"-displayregioncontainer",this.displayRegionContainer.className="displayregioncontainer",this.displayRegionContainer.style.width="100%",this.displayRegionContainer.style.height="100%",e.setElementPointerEventsNone(this.displayRegionContainer),e.setElementTouchActionNone(this.displayRegionContainer),l.addControl(this.element,o.controlOptions),this._resizeWithViewer=o.controlOptions.anchor!==e.ControlAnchor.ABSOLUTE&&o.controlOptions.anchor!==e.ControlAnchor.NONE,o.width&&o.height?(this.setWidth(o.width),this.setHeight(o.height)):this._resizeWithViewer&&(d=e.getElementSize(l.element),this.element.style.height=Math.round(d.y*o.sizeRatio)+"px",this.element.style.width=Math.round(d.x*o.sizeRatio)+"px",this.oldViewerSize=d,m=e.getElementSize(this.element),this.elementArea=m.x*m.y),this.oldContainerSize=new e.Point(0,0),e.Viewer.apply(this,[o]),this.displayRegionContainer.appendChild(this.displayRegion),this.element.getElementsByTagName("div")[0].appendChild(this.displayRegionContainer);function v(T,_){a(u.displayRegionContainer,T),a(u.displayRegion,-T),u.viewport.setRotation(T,_)}if(o.navigatorRotate){var y=o.viewer.viewport?o.viewer.viewport.getRotation():o.viewer.degrees||0;v(y,!0),o.viewer.addHandler("rotate",function(T){v(T.degrees,T.immediately)})}this.innerTracker.destroy(),this.innerTracker=new e.MouseTracker({userData:"Navigator.innerTracker",element:this.element,dragHandler:e.delegate(this,n),clickHandler:e.delegate(this,t),releaseHandler:e.delegate(this,i),scrollHandler:e.delegate(this,r),preProcessEventHandler:function(T){T.eventType==="wheel"&&(T.preventDefault=!0)}}),this.outerTracker.userData="Navigator.outerTracker",e.setElementPointerEventsNone(this.canvas),e.setElementPointerEventsNone(this.container),this.addHandler("reset-size",function(){u.viewport&&u.viewport.goHome(!0)}),l.world.addHandler("item-index-change",function(T){window.setTimeout(function(){var _=u.world.getItemAt(T.previousIndex);u.world.setItemIndex(_,T.newIndex)},1)}),l.world.addHandler("remove-item",function(T){var _=T.item,S=u._getMatchingItem(_);S&&u.world.removeItem(S)}),this.update(l.viewport)},e.extend(e.Navigator.prototype,e.EventSource.prototype,e.Viewer.prototype,{updateSize:function(){if(this.viewport){var o=new e.Point(this.container.clientWidth===0?1:this.container.clientWidth,this.container.clientHeight===0?1:this.container.clientHeight);o.equals(this.oldContainerSize)||(this.viewport.resize(o,!0),this.viewport.goHome(!0),this.oldContainerSize=o,this.world.update(),this.world.draw(),this.update(this.viewer.viewport))}},setWidth:function(o){this.width=o,this.element.style.width=typeof o=="number"?o+"px":o,this._resizeWithViewer=!1,this.updateSize()},setHeight:function(o){this.height=o,this.element.style.height=typeof o=="number"?o+"px":o,this._resizeWithViewer=!1,this.updateSize()},setFlip:function(o){return this.viewport.setFlip(o),this.setDisplayTransform(this.viewer.viewport.getFlip()?"scale(-1,1)":"scale(1,1)"),this},setDisplayTransform:function(o){s(this.displayRegion,o),s(this.canvas,o),s(this.element,o)},update:function(o){var l,u,d,m,v,y;if(o||(o=this.viewer.viewport),l=e.getElementSize(this.viewer.element),this._resizeWithViewer&&l.x&&l.y&&!l.equals(this.oldViewerSize)&&(this.oldViewerSize=l,this.maintainSizeRatio||!this.elementArea?(u=l.x*this.sizeRatio,d=l.y*this.sizeRatio):(u=Math.sqrt(this.elementArea*(l.x/l.y)),d=this.elementArea/u),this.element.style.width=Math.round(u)+"px",this.element.style.height=Math.round(d)+"px",this.elementArea||(this.elementArea=u*d),this.updateSize()),o&&this.viewport){if(m=o.getBoundsNoRotate(!0),v=this.viewport.pixelFromPointNoRotate(m.getTopLeft(),!1),y=this.viewport.pixelFromPointNoRotate(m.getBottomRight(),!1).minus(this.totalBorderWidths),!this.navigatorRotate){var T=o.getRotation(!0);a(this.displayRegion,-T)}var _=this.displayRegion.style;_.display=this.world.getItemCount()?"block":"none",_.top=v.y.toFixed(2)+"px",_.left=v.x.toFixed(2)+"px";var S=y.x-v.x,b=y.y-v.y;_.width=Math.round(Math.max(S,0))+"px",_.height=Math.round(Math.max(b,0))+"px"}},addTiledImage:function(o){var l=this,u=o.originalTiledImage;delete o.original;var d=e.extend({},o,{success:function(m){var v=m.item;v._originalForNavigator=u,l._matchBounds(v,u,!0),l._matchOpacity(v,u),l._matchCompositeOperation(v,u);function y(){l._matchBounds(v,u)}function T(){l._matchOpacity(v,u)}function _(){l._matchCompositeOperation(v,u)}u.addHandler("bounds-change",y),u.addHandler("clip-change",y),u.addHandler("opacity-change",T),u.addHandler("composite-operation-change",_)}});return e.Viewer.prototype.addTiledImage.apply(this,[d])},destroy:function(){return e.Viewer.prototype.destroy.apply(this)},_getMatchingItem:function(o){for(var l=this.world.getItemCount(),u,d=0;d<l;d++)if(u=this.world.getItemAt(d),u._originalForNavigator===o)return u;return null},_matchBounds:function(o,l,u){var d=l.getBoundsNoRotate();o.setPosition(d.getTopLeft(),u),o.setWidth(d.width,u),o.setRotation(l.getRotation(),u),o.setClip(l.getClip()),o.setFlip(l.getFlip())},_matchOpacity:function(o,l){o.setOpacity(l.opacity)},_matchCompositeOperation:function(o,l){o.setCompositeOperation(l.compositeOperation)}});function t(o){var l={tracker:o.eventSource,position:o.position,quick:o.quick,shift:o.shift,originalEvent:o.originalEvent,preventDefaultAction:!1};if(this.viewer.raiseEvent("navigator-click",l),!l.preventDefaultAction&&o.quick&&this.viewer.viewport&&(this.panVertical||this.panHorizontal)){this.viewer.viewport.flipped&&(o.position.x=this.viewport.getContainerSize().x-o.position.x);var u=this.viewport.pointFromPixel(o.position);this.panVertical?this.panHorizontal||(u.x=this.viewer.viewport.getCenter(!0).x):u.y=this.viewer.viewport.getCenter(!0).y,this.viewer.viewport.panTo(u),this.viewer.viewport.applyConstraints()}}function n(o){var l={tracker:o.eventSource,position:o.position,delta:o.delta,speed:o.speed,direction:o.direction,shift:o.shift,originalEvent:o.originalEvent,preventDefaultAction:!1};this.viewer.raiseEvent("navigator-drag",l),!l.preventDefaultAction&&this.viewer.viewport&&(this.panHorizontal||(o.delta.x=0),this.panVertical||(o.delta.y=0),this.viewer.viewport.flipped&&(o.delta.x=-o.delta.x),this.viewer.viewport.panBy(this.viewport.deltaPointsFromPixels(o.delta)),this.viewer.constrainDuringPan&&this.viewer.viewport.applyConstraints())}function i(o){o.insideElementPressed&&this.viewer.viewport&&this.viewer.viewport.applyConstraints()}function r(o){var l={tracker:o.eventSource,position:o.position,scroll:o.scroll,shift:o.shift,originalEvent:o.originalEvent,preventDefault:o.preventDefault};this.viewer.raiseEvent("navigator-scroll",l),o.preventDefault=l.preventDefault}function a(o,l){s(o,"rotate("+l+"deg)")}function s(o,l){o.style.webkitTransform=l,o.style.mozTransform=l,o.style.msTransform=l,o.style.oTransform=l,o.style.transform=l}}(x),function(e){var t={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"}};e.extend(e,{getString:function(n){var i=n.split("."),r=null,a=arguments,s=t,o;for(o=0;o<i.length-1;o++)s=s[i[o]]||{};return r=s[i[o]],typeof r!="string"&&(e.console.error("Untranslated source string:",n),r=""),r.replace(/\{\d+\}/g,function(l){var u=parseInt(l.match(/\d+/),10)+1;return u<a.length?a[u]:""})},setString:function(n,i){var r=n.split("."),a=t,s;for(s=0;s<r.length-1;s++)a[r[s]]||(a[r[s]]={}),a=a[r[s]];a[r[s]]=i}})}(x),function(e){e.Point=function(t,n){this.x=typeof t=="number"?t:0,this.y=typeof n=="number"?n:0},e.Point.prototype={clone:function(){return new e.Point(this.x,this.y)},plus:function(t){return new e.Point(this.x+t.x,this.y+t.y)},minus:function(t){return new e.Point(this.x-t.x,this.y-t.y)},times:function(t){return new e.Point(this.x*t,this.y*t)},divide:function(t){return new e.Point(this.x/t,this.y/t)},negate:function(){return new e.Point(-this.x,-this.y)},distanceTo:function(t){return Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))},squaredDistanceTo:function(t){return Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2)},apply:function(t){return new e.Point(t(this.x),t(this.y))},equals:function(t){return t instanceof e.Point&&this.x===t.x&&this.y===t.y},rotate:function(t,n){n=n||new e.Point(0,0);var i,r;if(t%90===0){var a=e.positiveModulo(t,360);switch(a){case 0:i=1,r=0;break;case 90:i=0,r=1;break;case 180:i=-1,r=0;break;case 270:i=0,r=-1;break}}else{var s=t*Math.PI/180;i=Math.cos(s),r=Math.sin(s)}var o=i*(this.x-n.x)-r*(this.y-n.y)+n.x,l=r*(this.x-n.x)+i*(this.y-n.y)+n.y;return new e.Point(o,l)},toString:function(){return"("+Math.round(this.x*100)/100+","+Math.round(this.y*100)/100+")"}}}(x),function(e){e.TileSource=function(n,i,r,a,s,o){var l=this,u=arguments,d,m;if(e.isPlainObject(n)?d=n:d={width:u[0],height:u[1],tileSize:u[2],tileOverlap:u[3],minLevel:u[4],maxLevel:u[5]},e.EventSource.call(this),e.extend(!0,this,d),!this.success){for(m=0;m<arguments.length;m++)if(e.isFunction(arguments[m])){this.success=arguments[m];break}}this.success&&this.addHandler("ready",function(v){l.success(v)}),e.type(arguments[0])==="string"&&(this.url=arguments[0]),this.url?(this.aspectRatio=1,this.dimensions=new e.Point(10,10),this._tileWidth=0,this._tileHeight=0,this.tileOverlap=0,this.minLevel=0,this.maxLevel=0,this.ready=!1,this.getImageInfo(this.url)):(this.ready=!0,this.aspectRatio=d.width&&d.height?d.width/d.height:1,this.dimensions=new e.Point(d.width,d.height),this.tileSize?(this._tileWidth=this._tileHeight=this.tileSize,delete this.tileSize):(this.tileWidth?(this._tileWidth=this.tileWidth,delete this.tileWidth):this._tileWidth=0,this.tileHeight?(this._tileHeight=this.tileHeight,delete this.tileHeight):this._tileHeight=0),this.tileOverlap=d.tileOverlap?d.tileOverlap:0,this.minLevel=d.minLevel?d.minLevel:0,this.maxLevel=d.maxLevel!==void 0&&d.maxLevel!==null?d.maxLevel:d.width&&d.height?Math.ceil(Math.log(Math.max(d.width,d.height))/Math.log(2)):0,this.success&&e.isFunction(this.success)&&this.success(this))},e.TileSource.prototype={getTileSize:function(n){return e.console.error("[TileSource.getTileSize] is deprecated. Use TileSource.getTileWidth() and TileSource.getTileHeight() instead"),this._tileWidth},getTileWidth:function(n){return this._tileWidth?this._tileWidth:this.getTileSize(n)},getTileHeight:function(n){return this._tileHeight?this._tileHeight:this.getTileSize(n)},setMaxLevel:function(n){this.maxLevel=n,this._memoizeLevelScale()},getLevelScale:function(n){return this._memoizeLevelScale(),this.getLevelScale(n)},_memoizeLevelScale:function(){var n={},i;for(i=0;i<=this.maxLevel;i++)n[i]=1/Math.pow(2,this.maxLevel-i);this.getLevelScale=function(r){return n[r]}},getNumTiles:function(n){var i=this.getLevelScale(n),r=Math.ceil(i*this.dimensions.x/this.getTileWidth(n)),a=Math.ceil(i*this.dimensions.y/this.getTileHeight(n));return new e.Point(r,a)},getPixelRatio:function(n){var i=this.dimensions.times(this.getLevelScale(n)),r=1/i.x*e.pixelDensityRatio,a=1/i.y*e.pixelDensityRatio;return new e.Point(r,a)},getClosestLevel:function(){var n,i;for(n=this.minLevel+1;n<=this.maxLevel&&(i=this.getNumTiles(n),!(i.x>1||i.y>1));n++);return n-1},getTileAtPoint:function(n,i){var r=i.x>=0&&i.x<=1&&i.y>=0&&i.y<=1/this.aspectRatio;e.console.assert(r,"[TileSource.getTileAtPoint] must be called with a valid point.");var a=this.dimensions.x*this.getLevelScale(n),s=i.x*a,o=i.y*a,l=Math.floor(s/this.getTileWidth(n)),u=Math.floor(o/this.getTileHeight(n));i.x>=1&&(l=this.getNumTiles(n).x-1);var d=1e-15;return i.y>=1/this.aspectRatio-d&&(u=this.getNumTiles(n).y-1),new e.Point(l,u)},getTileBounds:function(n,i,r,a){var s=this.dimensions.times(this.getLevelScale(n)),o=this.getTileWidth(n),l=this.getTileHeight(n),u=i===0?0:o*i-this.tileOverlap,d=r===0?0:l*r-this.tileOverlap,m=o+(i===0?1:2)*this.tileOverlap,v=l+(r===0?1:2)*this.tileOverlap,y=1/s.x;return m=Math.min(m,s.x-u),v=Math.min(v,s.y-d),a?new e.Rect(0,0,m,v):new e.Rect(u*y,d*y,m*y,v*y)},getImageInfo:function(n){var i=this,r,a,s,o,l,u,d;n&&(l=n.split("/"),u=l[l.length-1],d=u.lastIndexOf("."),d>-1&&(l[l.length-1]=u.slice(0,d)));var m=null;if(this.splitHashDataForPost){var v=n.indexOf("#");v!==-1&&(m=n.substring(v+1),n=n.substr(0,v))}a=function(y){typeof y=="string"&&(y=e.parseXml(y));var T=e.TileSource.determineType(i,y,n);if(!T){i.raiseEvent("open-failed",{message:"Unable to load TileSource",source:n});return}o=T.prototype.configure.apply(i,[y,n,m]),o.ajaxWithCredentials===void 0&&(o.ajaxWithCredentials=i.ajaxWithCredentials),s=new T(o),i.ready=!0,i.raiseEvent("ready",{tileSource:s})},n.match(/\.js$/)?(r=n.split("/").pop().replace(".js",""),e.jsonp({url:n,async:!1,callbackName:r,callback:a})):e.makeAjaxRequest({url:n,postData:m,withCredentials:this.ajaxWithCredentials,headers:this.ajaxHeaders,success:function(y){var T=t(y);a(T)},error:function(y,T){var _;try{_="HTTP "+y.status+" attempting to load TileSource: "+n}catch{var S;typeof T>"u"||!T.toString?S="Unknown error":S=T.toString(),_=S+" attempting to load TileSource: "+n}e.console.error(_),i.raiseEvent("open-failed",{message:_,source:n,postData:m})}})},supports:function(n,i){return!1},configure:function(n,i,r){throw new Error("Method not implemented.")},getTileUrl:function(n,i,r){throw new Error("Method not implemented.")},getTilePostData:function(n,i,r){return null},getTileAjaxHeaders:function(n,i,r){return{}},getTileHashKey:function(n,i,r,a,s,o){function l(u){return s?u+"+"+JSON.stringify(s):u}return l(typeof a!="string"?n+"/"+i+"_"+r:a)},tileExists:function(n,i,r){var a=this.getNumTiles(n);return n>=this.minLevel&&n<=this.maxLevel&&i>=0&&r>=0&&i<a.x&&r<a.y},hasTransparency:function(n,i,r,a){return!!n||i.match(".png")},downloadTileStart:function(n){var i=n.userData,r=new Image;i.image=r,i.request=null;var a=function(s){if(!r){n.finish(null,i.request,"Image load failed: undefined Image instance.");return}r.onload=r.onerror=r.onabort=null,n.finish(s?null:r,i.request,s)};r.onload=function(){a()},r.onabort=r.onerror=function(){a("Image load aborted.")},n.loadWithAjax?i.request=e.makeAjaxRequest({url:n.src,withCredentials:n.ajaxWithCredentials,headers:n.ajaxHeaders,responseType:"arraybuffer",postData:n.postData,success:function(s){var o;try{o=new window.Blob([s.response])}catch(d){var l=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if(d.name==="TypeError"&&l){var u=new l;u.append(s.response),o=u.getBlob()}}o.size===0?a("Empty image response."):r.src=(window.URL||window.webkitURL).createObjectURL(o)},error:function(s){a("Image load aborted - XHR error")}}):(n.crossOriginPolicy!==!1&&(r.crossOrigin=n.crossOriginPolicy),r.src=n.src)},downloadTileAbort:function(n){n.userData.request&&n.userData.request.abort();var i=n.userData.image;n.userData.image&&(i.onload=i.onerror=i.onabort=null)},createTileCache:function(n,i,r){n._data=i},destroyTileCache:function(n){n._data=null,n._renderedContext=null},getTileCacheData:function(n){return n._data},getTileCacheDataAsImage:function(n){return n._data},getTileCacheDataAsContext2D:function(n){if(!n._renderedContext){var i=document.createElement("canvas");i.width=n._data.width,i.height=n._data.height,n._renderedContext=i.getContext("2d"),n._renderedContext.drawImage(n._data,0,0),n._data=null}return n._renderedContext}},e.extend(!0,e.TileSource.prototype,e.EventSource.prototype);function t(n){var i=n.responseText,r=n.status,a,s;if(n){if(n.status!==200&&n.status!==0)throw r=n.status,a=r===404?"Not Found":n.statusText,new Error(e.getString("Errors.Status",r,a))}else throw new Error(e.getString("Errors.Security"));if(i.match(/^\s*<.*/))try{s=n.responseXML&&n.responseXML.documentElement?n.responseXML:e.parseXml(i)}catch{s=n.responseText}else if(i.match(/\s*[{[].*/))try{s=e.parseJSON(i)}catch{s=i}else s=i;return s}e.TileSource.determineType=function(n,i,r){var a;for(a in x)if(a.match(/.+TileSource$/)&&e.isFunction(x[a])&&e.isFunction(x[a].prototype.supports)&&x[a].prototype.supports.call(n,i,r))return x[a];return e.console.error("No TileSource was able to open %s %s",r,i),null}}(x),function(e){e.DziTileSource=function(i,r,a,s,o,l,u,d,m){var v,y,T,_;if(e.isPlainObject(i)?_=i:_={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4],fileFormat:arguments[5],displayRects:arguments[6],minLevel:arguments[7],maxLevel:arguments[8]},this._levelRects={},this.tilesUrl=_.tilesUrl,this.fileFormat=_.fileFormat,this.displayRects=_.displayRects,this.displayRects)for(v=this.displayRects.length-1;v>=0;v--)for(y=this.displayRects[v],T=y.minLevel;T<=y.maxLevel;T++)this._levelRects[T]||(this._levelRects[T]=[]),this._levelRects[T].push(y);e.TileSource.apply(this,[_])},e.extend(e.DziTileSource.prototype,e.TileSource.prototype,{supports:function(i,r){var a;return i.Image?a=i.Image.xmlns:i.documentElement&&(i.documentElement.localName==="Image"||i.documentElement.tagName==="Image")&&(a=i.documentElement.namespaceURI),a=(a||"").toLowerCase(),a.indexOf("schemas.microsoft.com/deepzoom/2008")!==-1||a.indexOf("schemas.microsoft.com/deepzoom/2009")!==-1},configure:function(i,r,a){var s;return e.isPlainObject(i)?s=n(this,i):s=t(this,i),r&&!s.tilesUrl&&(s.tilesUrl=r.replace(/([^/]+?)(\.(dzi|xml|js)?(\?[^/]*)?)?\/?$/,"$1_files/"),r.search(/\.(dzi|xml|js)\?/)!==-1?s.queryParams=r.match(/\?.*/):s.queryParams=""),s},getTileUrl:function(i,r,a){return[this.tilesUrl,i,"/",r,"_",a,".",this.fileFormat,this.queryParams].join("")},tileExists:function(i,r,a){var s=this._levelRects[i],o,l,u,d,m,v,y;if(this.minLevel&&i<this.minLevel||this.maxLevel&&i>this.maxLevel)return!1;if(!s||!s.length)return!0;for(y=s.length-1;y>=0;y--)if(o=s[y],!(i<o.minLevel||i>o.maxLevel)&&(l=this.getLevelScale(i),u=o.x*l,d=o.y*l,m=u+o.width*l,v=d+o.height*l,u=Math.floor(u/this._tileWidth),d=Math.floor(d/this._tileWidth),m=Math.ceil(m/this._tileWidth),v=Math.ceil(v/this._tileWidth),u<=r&&r<m&&d<=a&&a<v))return!0;return!1}});function t(i,r){if(!r||!r.documentElement)throw new Error(e.getString("Errors.Xml"));var a=r.documentElement,s=a.localName||a.tagName,o=r.documentElement.namespaceURI,l=null,u=[],d,m,v,y,T;if(s==="Image")try{if(y=a.getElementsByTagName("Size")[0],y===void 0&&(y=a.getElementsByTagNameNS(o,"Size")[0]),l={Image:{xmlns:"http://schemas.microsoft.com/deepzoom/2008",Url:a.getAttribute("Url"),Format:a.getAttribute("Format"),DisplayRect:null,Overlap:parseInt(a.getAttribute("Overlap"),10),TileSize:parseInt(a.getAttribute("TileSize"),10),Size:{Height:parseInt(y.getAttribute("Height"),10),Width:parseInt(y.getAttribute("Width"),10)}}},!e.imageFormatSupported(l.Image.Format))throw new Error(e.getString("Errors.ImageFormat",l.Image.Format.toUpperCase()));for(d=a.getElementsByTagName("DisplayRect"),d===void 0&&(d=a.getElementsByTagNameNS(o,"DisplayRect")[0]),T=0;T<d.length;T++)m=d[T],v=m.getElementsByTagName("Rect")[0],v===void 0&&(v=m.getElementsByTagNameNS(o,"Rect")[0]),u.push({Rect:{X:parseInt(v.getAttribute("X"),10),Y:parseInt(v.getAttribute("Y"),10),Width:parseInt(v.getAttribute("Width"),10),Height:parseInt(v.getAttribute("Height"),10),MinLevel:parseInt(m.getAttribute("MinLevel"),10),MaxLevel:parseInt(m.getAttribute("MaxLevel"),10)}});return u.length&&(l.Image.DisplayRect=u),n(i,l)}catch(b){throw b instanceof Error?b:new Error(e.getString("Errors.Dzi"))}else{if(s==="Collection")throw new Error(e.getString("Errors.Dzc"));if(s==="Error"){var _=a.getElementsByTagName("Message")[0],S=_.firstChild.nodeValue;throw new Error(S)}}throw new Error(e.getString("Errors.Dzi"))}function n(i,r){var a=r.Image,s=a.Url,o=a.Format,l=a.Size,u=a.DisplayRect||[],d=parseInt(l.Width,10),m=parseInt(l.Height,10),v=parseInt(a.TileSize,10),y=parseInt(a.Overlap,10),T=[],_,S;for(S=0;S<u.length;S++)_=u[S].Rect,T.push(new e.DisplayRect(parseInt(_.X,10),parseInt(_.Y,10),parseInt(_.Width,10),parseInt(_.Height,10),parseInt(_.MinLevel,10),parseInt(_.MaxLevel,10)));return e.extend(!0,{width:d,height:m,tileSize:v,tileOverlap:y,minLevel:null,maxLevel:null,tilesUrl:s,fileFormat:o,displayRects:T},r)}}(x),function(e){e.IIIFTileSource=function(a){if(e.extend(!0,this,a),this._id=this["@id"]||this.id||this.identifier||null,!(this.height&&this.width&&this._id))throw new Error("IIIF required parameters (width, height, or id) not provided.");if(a.tileSizePerScaleFactor={},this.tileFormat=this.tileFormat||"jpg",this.version=a.version,this.tile_width&&this.tile_height)a.tileWidth=this.tile_width,a.tileHeight=this.tile_height;else if(this.tile_width)a.tileSize=this.tile_width;else if(this.tile_height)a.tileSize=this.tile_height;else if(this.tiles)if(this.tiles.length===1)a.tileWidth=this.tiles[0].width,a.tileHeight=this.tiles[0].height||this.tiles[0].width,this.scale_factors=this.tiles[0].scaleFactors;else{this.scale_factors=[];for(var s=0;s<this.tiles.length;s++)for(var o=0;o<this.tiles[s].scaleFactors.length;o++){var l=this.tiles[s].scaleFactors[o];this.scale_factors.push(l),a.tileSizePerScaleFactor[l]={width:this.tiles[s].width,height:this.tiles[s].height||this.tiles[s].width}}}else if(t(a)){for(var u=Math.min(this.height,this.width),d=[256,512,1024],m=[],v=0;v<d.length;v++)d[v]<=u&&m.push(d[v]);m.length>0?a.tileSize=Math.max.apply(null,m):a.tileSize=u}else this.sizes&&this.sizes.length>0?(this.emulateLegacyImagePyramid=!0,a.levels=n(this),e.extend(!0,a,{width:a.levels[a.levels.length-1].width,height:a.levels[a.levels.length-1].height,tileSize:Math.max(a.height,a.width),tileOverlap:0,minLevel:0,maxLevel:a.levels.length-1}),this.levels=a.levels):e.console.error("Nothing in the info.json to construct image pyramids from");if(!a.maxLevel&&!this.emulateLegacyImagePyramid)if(!this.scale_factors)a.maxLevel=Number(Math.round(Math.log(Math.max(this.width,this.height),2)));else{var y=Math.max.apply(null,this.scale_factors);a.maxLevel=Math.round(Math.log(y)*Math.LOG2E)}if(this.sizes){var T=this.sizes.length;(T===a.maxLevel||T===a.maxLevel+1)&&(this.levelSizes=this.sizes.slice().sort((_,S)=>_.width-S.width),T===a.maxLevel&&this.levelSizes.push({width:this.width,height:this.height}))}e.TileSource.apply(this,[a])},e.extend(e.IIIFTileSource.prototype,e.TileSource.prototype,{supports:function(a,s){return a.protocol&&a.protocol==="http://iiif.io/api/image"||a["@context"]&&(a["@context"]==="http://library.stanford.edu/iiif/image-api/1.1/context.json"||a["@context"]==="http://iiif.io/api/image/1/context.json")||a.profile&&a.profile.indexOf("http://library.stanford.edu/iiif/image-api/compliance.html")===0||a.identifier&&a.width&&a.height?!0:!!(a.documentElement&&a.documentElement.tagName==="info"&&a.documentElement.namespaceURI==="http://library.stanford.edu/iiif/image-api/ns/")},configure:function(a,s,o){if(e.isPlainObject(a)){if(!a["@context"])a["@context"]="http://iiif.io/api/image/1.0/context.json",a["@id"]=s.replace("/info.json",""),a.version=1;else{var u=a["@context"];if(Array.isArray(u)){for(var d=0;d<u.length;d++)if(typeof u[d]=="string"&&(/^http:\/\/iiif\.io\/api\/image\/[1-3]\/context\.json$/.test(u[d])||u[d]==="http://library.stanford.edu/iiif/image-api/1.1/context.json")){u=u[d];break}}switch(u){case"http://iiif.io/api/image/1/context.json":case"http://library.stanford.edu/iiif/image-api/1.1/context.json":a.version=1;break;case"http://iiif.io/api/image/2/context.json":a.version=2;break;case"http://iiif.io/api/image/3/context.json":a.version=3;break;default:e.console.error("Data has a @context property which contains no known IIIF context URI.")}}if(a.preferredFormats){for(var m=0;m<a.preferredFormats.length;m++)if(x.imageFormatSupported(a.preferredFormats[m])){a.tileFormat=a.preferredFormats[m];break}}return a}else{var l=i(a);return l["@context"]="http://iiif.io/api/image/1.0/context.json",l["@id"]=s.replace("/info.xml",""),l.version=1,l}},getTileWidth:function(a){if(this.emulateLegacyImagePyramid)return e.TileSource.prototype.getTileWidth.call(this,a);var s=Math.pow(2,this.maxLevel-a);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[s]?this.tileSizePerScaleFactor[s].width:this._tileWidth},getTileHeight:function(a){if(this.emulateLegacyImagePyramid)return e.TileSource.prototype.getTileHeight.call(this,a);var s=Math.pow(2,this.maxLevel-a);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[s]?this.tileSizePerScaleFactor[s].height:this._tileHeight},getLevelScale:function(a){if(this.emulateLegacyImagePyramid){var s=NaN;return this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(s=this.levels[a].width/this.levels[this.maxLevel].width),s}return e.TileSource.prototype.getLevelScale.call(this,a)},getNumTiles:function(a){if(this.emulateLegacyImagePyramid){var s=this.getLevelScale(a);return s?new e.Point(1,1):new e.Point(0,0)}if(this.levelSizes){var o=this.levelSizes[a],l=Math.ceil(o.width/this.getTileWidth(a)),u=Math.ceil(o.height/this.getTileHeight(a));return new e.Point(l,u)}else return e.TileSource.prototype.getNumTiles.call(this,a)},getTileAtPoint:function(a,s){if(this.emulateLegacyImagePyramid)return new e.Point(0,0);if(this.levelSizes){var o=s.x>=0&&s.x<=1&&s.y>=0&&s.y<=1/this.aspectRatio;e.console.assert(o,"[TileSource.getTileAtPoint] must be called with a valid point.");var l=this.levelSizes[a].width,u=s.x*l,d=s.y*l,m=Math.floor(u/this.getTileWidth(a)),v=Math.floor(d/this.getTileHeight(a));s.x>=1&&(m=this.getNumTiles(a).x-1);var y=1e-15;return s.y>=1/this.aspectRatio-y&&(v=this.getNumTiles(a).y-1),new e.Point(m,v)}return e.TileSource.prototype.getTileAtPoint.call(this,a,s)},getTileUrl:function(a,s,o){if(this.emulateLegacyImagePyramid){var l=null;return this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(l=this.levels[a].url),l}var u="0",d=Math.pow(.5,this.maxLevel-a),m,v,y,T,_,S,b,L,I,M,Z,V,j,J,W,U;return this.levelSizes?(m=this.levelSizes[a].width,v=this.levelSizes[a].height):(m=Math.ceil(this.width*d),v=Math.ceil(this.height*d)),y=this.getTileWidth(a),T=this.getTileHeight(a),_=Math.round(y/d),S=Math.round(T/d),this.version===1?W="native."+this.tileFormat:W="default."+this.tileFormat,m<y&&v<T?(this.version===2&&m===this.width?V="full":this.version===3&&m===this.width&&v===this.height?V="max":this.version===3?V=m+","+v:V=m+",",b="full"):(L=s*_,I=o*S,M=Math.min(_,this.width-L),Z=Math.min(S,this.height-I),s===0&&o===0&&M===this.width&&Z===this.height?b="full":b=[L,I,M,Z].join(","),j=Math.min(y,m-s*y),J=Math.min(T,v-o*T),this.version===2&&j===this.width?V="full":this.version===3&&j===this.width&&J===this.height?V="max":this.version===3?V=j+","+J:V=j+","),U=[this._id,b,V,u,W].join("/"),U},__testonly__:{canBeTiled:t,constructLevels:n}});function t(a){var s=["http://library.stanford.edu/iiif/image-api/compliance.html#level0","http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0","http://iiif.io/api/image/2/level0.json","level0","https://iiif.io/api/image/3/level0.json"],o=Array.isArray(a.profile)?a.profile[0]:a.profile,l=s.indexOf(o)!==-1,u=!1;return a.version===2&&a.profile.length>1&&a.profile[1].supports&&(u=a.profile[1].supports.indexOf("sizeByW")!==-1),a.version===3&&a.extraFeatures&&(u=a.extraFeatures.indexOf("sizeByWh")!==-1),!l||u}function n(a){for(var s=[],o=0;o<a.sizes.length;o++)s.push({url:a._id+"/full/"+a.sizes[o].width+","+(a.version===3?a.sizes[o].height:"")+"/0/default."+a.tileFormat,width:a.sizes[o].width,height:a.sizes[o].height});return s.sort(function(l,u){return l.width-u.width})}function i(a){if(!a||!a.documentElement)throw new Error(e.getString("Errors.Xml"));var s=a.documentElement,o=s.tagName,l=null;if(o==="info")try{return l={},r(s,l),l}catch(u){throw u instanceof Error?u:new Error(e.getString("Errors.IIIF"))}throw new Error(e.getString("Errors.IIIF"))}function r(a,s,o){var l,u;if(a.nodeType===3&&o)u=a.nodeValue.trim(),u.match(/^\d*$/)&&(u=Number(u)),s[o]?(e.isArray(s[o])||(s[o]=[s[o]]),s[o].push(u)):s[o]=u;else if(a.nodeType===1)for(l=0;l<a.childNodes.length;l++)r(a.childNodes[l],s,a.nodeName)}}(x),function(e){e.OsmTileSource=function(t,n,i,r,a){var s;e.isPlainObject(t)?s=t:s={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]},(!s.width||!s.height)&&(s.width=65572864,s.height=65572864),s.tileSize||(s.tileSize=256,s.tileOverlap=0),s.tilesUrl||(s.tilesUrl="http://tile.openstreetmap.org/"),s.minLevel=8,e.TileSource.apply(this,[s])},e.extend(e.OsmTileSource.prototype,e.TileSource.prototype,{supports:function(t,n){return t.type&&t.type==="openstreetmaps"},configure:function(t,n,i){return t},getTileUrl:function(t,n,i){return this.tilesUrl+(t-8)+"/"+n+"/"+i+".png"}})}(x),function(e){e.TmsTileSource=function(t,n,i,r,a){var s;e.isPlainObject(t)?s=t:s={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]};var o=Math.ceil(s.width/256)*256,l=Math.ceil(s.height/256)*256,u;o>l?u=o/256:u=l/256,s.maxLevel=Math.ceil(Math.log(u)/Math.log(2))-1,s.tileSize=256,s.width=o,s.height=l,e.TileSource.apply(this,[s])},e.extend(e.TmsTileSource.prototype,e.TileSource.prototype,{supports:function(t,n){return t.type&&t.type==="tiledmapservice"},configure:function(t,n,i){return t},getTileUrl:function(t,n,i){var r=this.getNumTiles(t).y-1;return this.tilesUrl+t+"/"+n+"/"+(r-i)+".png"}})}(x),function(e){e.ZoomifyTileSource=function(t){typeof t.tileSize>"u"&&(t.tileSize=256),typeof t.fileFormat>"u"&&(t.fileFormat="jpg",this.fileFormat=t.fileFormat);var n={x:t.width,y:t.height};for(t.imageSizes=[{x:t.width,y:t.height}],t.gridSize=[this._getGridSize(t.width,t.height,t.tileSize)];parseInt(n.x,10)>t.tileSize||parseInt(n.y,10)>t.tileSize;)n.x=Math.floor(n.x/2),n.y=Math.floor(n.y/2),t.imageSizes.push({x:n.x,y:n.y}),t.gridSize.push(this._getGridSize(n.x,n.y,t.tileSize));t.imageSizes.reverse(),t.gridSize.reverse(),t.minLevel=0,t.maxLevel=t.gridSize.length-1,x.TileSource.apply(this,[t])},e.extend(e.ZoomifyTileSource.prototype,e.TileSource.prototype,{_getGridSize:function(t,n,i){return{x:Math.ceil(t/i),y:Math.ceil(n/i)}},_calculateAbsoluteTileNumber:function(t,n,i){for(var r=0,a={},s=0;s<t;s++)a=this.gridSize[s],r+=a.x*a.y;return a=this.gridSize[t],r+=a.x*i+n,r},supports:function(t,n){return t.type&&t.type==="zoomifytileservice"},configure:function(t,n,i){return t},getTileUrl:function(t,n,i){var r=0,a=this._calculateAbsoluteTileNumber(t,n,i);return r=Math.floor(a/256),this.tilesUrl+"TileGroup"+r+"/"+t+"-"+n+"-"+i+"."+this.fileFormat}})}(x),function(e){e.LegacyTileSource=function(r){var a,s,o;e.isArray(r)&&(a={type:"legacy-image-pyramid",levels:r}),a.levels=t(a.levels),a.levels.length>0?(s=a.levels[a.levels.length-1].width,o=a.levels[a.levels.length-1].height):(s=0,o=0,e.console.error("No supported image formats found")),e.extend(!0,a,{width:s,height:o,tileSize:Math.max(o,s),tileOverlap:0,minLevel:0,maxLevel:a.levels.length>0?a.levels.length-1:0}),e.TileSource.apply(this,[a]),this.levels=a.levels},e.extend(e.LegacyTileSource.prototype,e.TileSource.prototype,{supports:function(r,a){return r.type&&r.type==="legacy-image-pyramid"||r.documentElement&&r.documentElement.getAttribute("type")==="legacy-image-pyramid"},configure:function(r,a,s){var o;return e.isPlainObject(r)?o=i(this,r):o=n(this,r),o},getLevelScale:function(r){var a=NaN;return this.levels.length>0&&r>=this.minLevel&&r<=this.maxLevel&&(a=this.levels[r].width/this.levels[this.maxLevel].width),a},getNumTiles:function(r){var a=this.getLevelScale(r);return a?new e.Point(1,1):new e.Point(0,0)},getTileUrl:function(r,a,s){var o=null;return this.levels.length>0&&r>=this.minLevel&&r<=this.maxLevel&&(o=this.levels[r].url),o}});function t(r){var a=[],s,o;for(o=0;o<r.length;o++)s=r[o],s.height&&s.width&&s.url?a.push({url:s.url,width:Number(s.width),height:Number(s.height)}):e.console.error("Unsupported image format: %s",s.url?s.url:"<no URL>");return a.sort(function(l,u){return l.height-u.height})}function n(r,a){if(!a||!a.documentElement)throw new Error(e.getString("Errors.Xml"));var s=a.documentElement,o=s.tagName,l=null,u=[],d,m;if(o==="image")try{for(l={type:s.getAttribute("type"),levels:[]},u=s.getElementsByTagName("level"),m=0;m<u.length;m++)d=u[m],l.levels.push({url:d.getAttribute("url"),width:parseInt(d.getAttribute("width"),10),height:parseInt(d.getAttribute("height"),10)});return i(r,l)}catch(v){throw v instanceof Error?v:new Error("Unknown error parsing Legacy Image Pyramid XML.")}else{if(o==="collection")throw new Error("Legacy Image Pyramid Collections not yet supported.");if(o==="error")throw new Error("Error: "+a)}throw new Error("Unknown element "+o)}function i(r,a){return a.levels}}(x),function(e){e.ImageTileSource=function(t){t=e.extend({buildPyramid:!0,crossOriginPolicy:!1,ajaxWithCredentials:!1},t),e.TileSource.apply(this,[t])},e.extend(e.ImageTileSource.prototype,e.TileSource.prototype,{supports:function(t,n){return t.type&&t.type==="image"},configure:function(t,n,i){return t},getImageInfo:function(t){var n=this._image=new Image,i=this;this.crossOriginPolicy&&(n.crossOrigin=this.crossOriginPolicy),this.ajaxWithCredentials&&(n.useCredentials=this.ajaxWithCredentials),e.addEvent(n,"load",function(){i.width=n.naturalWidth,i.height=n.naturalHeight,i.aspectRatio=i.width/i.height,i.dimensions=new e.Point(i.width,i.height),i._tileWidth=i.width,i._tileHeight=i.height,i.tileOverlap=0,i.minLevel=0,i.levels=i._buildLevels(),i.maxLevel=i.levels.length-1,i.ready=!0,i.raiseEvent("ready",{tileSource:i})}),e.addEvent(n,"error",function(){i.raiseEvent("open-failed",{message:"Error loading image at "+t,source:t})}),n.src=t},getLevelScale:function(t){var n=NaN;return t>=this.minLevel&&t<=this.maxLevel&&(n=this.levels[t].width/this.levels[this.maxLevel].width),n},getNumTiles:function(t){var n=this.getLevelScale(t);return n?new e.Point(1,1):new e.Point(0,0)},getTileUrl:function(t,n,i){var r=null;return t>=this.minLevel&&t<=this.maxLevel&&(r=this.levels[t].url),r},getContext2D:function(t,n,i){var r=null;return t>=this.minLevel&&t<=this.maxLevel&&(r=this.levels[t].context2D),r},destroy:function(t){this._freeupCanvasMemory(t)},_buildLevels:function(){var t=[{url:this._image.src,width:this._image.naturalWidth,height:this._image.naturalHeight}];if(!this.buildPyramid||!e.supportsCanvas)return delete this._image,t;var n=this._image.naturalWidth,i=this._image.naturalHeight,r=document.createElement("canvas"),a=r.getContext("2d");if(r.width=n,r.height=i,a.drawImage(this._image,0,0,n,i),t[0].context2D=a,delete this._image,e.isCanvasTainted(r))return t;for(;n>=2&&i>=2;){n=Math.floor(n/2),i=Math.floor(i/2);var s=document.createElement("canvas"),o=s.getContext("2d");s.width=n,s.height=i,o.drawImage(r,0,0,n,i),t.splice(0,0,{context2D:o,width:n,height:i}),r=s,a=o}return t},_freeupCanvasMemory:function(t){for(var n=0;n<this.levels.length;n++)this.levels[n].context2D&&(this.levels[n].context2D.canvas.height=0,this.levels[n].context2D.canvas.width=0,t&&t.raiseEvent("image-unloaded",{context2D:this.levels[n].context2D}))}})}(x),function(e){e.TileSourceCollection=function(t,n,i,r){e.console.error("TileSourceCollection is deprecated; use World instead")}}(x),function(e){e.ButtonState={REST:0,GROUP:1,HOVER:2,DOWN:3},e.Button=function(o){var l=this;e.EventSource.call(this),e.extend(!0,this,{tooltip:null,srcRest:null,srcGroup:null,srcHover:null,srcDown:null,clickTimeThreshold:e.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:e.DEFAULT_SETTINGS.clickDistThreshold,fadeDelay:0,fadeLength:2e3,onPress:null,onRelease:null,onClick:null,onEnter:null,onExit:null,onFocus:null,onBlur:null,userData:null},o),this.element=o.element||e.makeNeutralElement("div"),o.element||(this.imgRest=e.makeTransparentImage(this.srcRest),this.imgGroup=e.makeTransparentImage(this.srcGroup),this.imgHover=e.makeTransparentImage(this.srcHover),this.imgDown=e.makeTransparentImage(this.srcDown),this.imgRest.alt=this.imgGroup.alt=this.imgHover.alt=this.imgDown.alt=this.tooltip,e.setElementPointerEventsNone(this.imgRest),e.setElementPointerEventsNone(this.imgGroup),e.setElementPointerEventsNone(this.imgHover),e.setElementPointerEventsNone(this.imgDown),this.element.style.position="relative",e.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=e.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 e.MouseTracker({userData:"Button.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(u){u.insideElementPressed?(a(l,e.ButtonState.DOWN),l.raiseEvent("enter",{originalEvent:u.originalEvent})):u.buttonDownAny||a(l,e.ButtonState.HOVER)},focusHandler:function(u){l.tracker.enterHandler(u),l.raiseEvent("focus",{originalEvent:u.originalEvent})},leaveHandler:function(u){s(l,e.ButtonState.GROUP),u.insideElementPressed&&l.raiseEvent("exit",{originalEvent:u.originalEvent})},blurHandler:function(u){l.tracker.leaveHandler(u),l.raiseEvent("blur",{originalEvent:u.originalEvent})},pressHandler:function(u){a(l,e.ButtonState.DOWN),l.raiseEvent("press",{originalEvent:u.originalEvent})},releaseHandler:function(u){u.insideElementPressed&&u.insideElementReleased?(s(l,e.ButtonState.HOVER),l.raiseEvent("release",{originalEvent:u.originalEvent})):u.insideElementPressed?s(l,e.ButtonState.GROUP):a(l,e.ButtonState.HOVER)},clickHandler:function(u){u.quick&&l.raiseEvent("click",{originalEvent:u.originalEvent})},keyHandler:function(u){u.keyCode===13?(l.raiseEvent("click",{originalEvent:u.originalEvent}),l.raiseEvent("release",{originalEvent:u.originalEvent}),u.preventDefault=!0):u.preventDefault=!1}}),s(this,e.ButtonState.REST)},e.extend(e.Button.prototype,e.EventSource.prototype,{notifyGroupEnter:function(){a(this,e.ButtonState.GROUP)},notifyGroupExit:function(){s(this,e.ButtonState.REST)},disable:function(){this.notifyGroupExit(),this.element.disabled=!0,this.tracker.setTracking(!1),e.setElementOpacity(this.element,.2,!0)},enable:function(){this.element.disabled=!1,this.tracker.setTracking(!0),e.setElementOpacity(this.element,1,!0),this.notifyGroupEnter()},destroy:function(){this.imgRest&&(this.element.removeChild(this.imgRest),this.imgRest=null),this.imgGroup&&(this.element.removeChild(this.imgGroup),this.imgGroup=null),this.imgHover&&(this.element.removeChild(this.imgHover),this.imgHover=null),this.imgDown&&(this.element.removeChild(this.imgDown),this.imgDown=null),this.removeAllHandlers(),this.tracker.destroy(),this.element=null}});function t(o){e.requestAnimationFrame(function(){n(o)})}function n(o){var l,u,d;o.shouldFade&&(l=e.now(),u=l-o.fadeBeginTime,d=1-u/o.fadeLength,d=Math.min(1,d),d=Math.max(0,d),o.imgGroup&&e.setElementOpacity(o.imgGroup,d,!0),d>0&&t(o))}function i(o){o.shouldFade=!0,o.fadeBeginTime=e.now()+o.fadeDelay,window.setTimeout(function(){t(o)},o.fadeDelay)}function r(o){o.shouldFade=!1,o.imgGroup&&e.setElementOpacity(o.imgGroup,1,!0)}function a(o,l){o.element.disabled||(l>=e.ButtonState.GROUP&&o.currentState===e.ButtonState.REST&&(r(o),o.currentState=e.ButtonState.GROUP),l>=e.ButtonState.HOVER&&o.currentState===e.ButtonState.GROUP&&(o.imgHover&&(o.imgHover.style.visibility=""),o.currentState=e.ButtonState.HOVER),l>=e.ButtonState.DOWN&&o.currentState===e.ButtonState.HOVER&&(o.imgDown&&(o.imgDown.style.visibility=""),o.currentState=e.ButtonState.DOWN))}function s(o,l){o.element.disabled||(l<=e.ButtonState.HOVER&&o.currentState===e.ButtonState.DOWN&&(o.imgDown&&(o.imgDown.style.visibility="hidden"),o.currentState=e.ButtonState.HOVER),l<=e.ButtonState.GROUP&&o.currentState===e.ButtonState.HOVER&&(o.imgHover&&(o.imgHover.style.visibility="hidden"),o.currentState=e.ButtonState.GROUP),l<=e.ButtonState.REST&&o.currentState===e.ButtonState.GROUP&&(i(o),o.currentState=e.ButtonState.REST))}}(x),function(e){e.ButtonGroup=function(t){e.extend(!0,this,{buttons:[],clickTimeThreshold:e.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:e.DEFAULT_SETTINGS.clickDistThreshold,labelText:""},t);var n=this.buttons.concat([]),i=this,r;if(this.element=t.element||e.makeNeutralElement("div"),!t.group)for(this.element.style.display="inline-block",r=0;r<n.length;r++)this.element.appendChild(n[r].element);e.setElementTouchActionNone(this.element),this.tracker=new e.MouseTracker({userData:"ButtonGroup.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(a){var s;for(s=0;s<i.buttons.length;s++)i.buttons[s].notifyGroupEnter()},leaveHandler:function(a){var s;if(!a.insideElementPressed)for(s=0;s<i.buttons.length;s++)i.buttons[s].notifyGroupExit()}})},e.ButtonGroup.prototype={addButton:function(t){this.buttons.push(t),this.element.appendChild(t.element)},emulateEnter:function(){this.tracker.enterHandler({eventSource:this.tracker})},emulateLeave:function(){this.tracker.leaveHandler({eventSource:this.tracker})},destroy:function(){for(;this.buttons.length;){var t=this.buttons.pop();this.element.removeChild(t.element),t.destroy()}this.tracker.destroy(),this.element=null}}}(x),function(e){e.Rect=function(t,n,i,r,a){this.x=typeof t=="number"?t:0,this.y=typeof n=="number"?n:0,this.width=typeof i=="number"?i:0,this.height=typeof r=="number"?r:0,this.degrees=typeof a=="number"?a:0,this.degrees=e.positiveModulo(this.degrees,360);var s,o;this.degrees>=270?(s=this.getTopRight(),this.x=s.x,this.y=s.y,o=this.height,this.height=this.width,this.width=o,this.degrees-=270):this.degrees>=180?(s=this.getBottomRight(),this.x=s.x,this.y=s.y,this.degrees-=180):this.degrees>=90&&(s=this.getBottomLeft(),this.x=s.x,this.y=s.y,o=this.height,this.height=this.width,this.width=o,this.degrees-=90)},e.Rect.fromSummits=function(t,n,i){var r=t.distanceTo(n),a=t.distanceTo(i),s=n.minus(t),o=Math.atan(s.y/s.x);return s.x<0?o+=Math.PI:s.y<0&&(o+=2*Math.PI),new e.Rect(t.x,t.y,r,a,o/Math.PI*180)},e.Rect.prototype={clone:function(){return new e.Rect(this.x,this.y,this.width,this.height,this.degrees)},getAspectRatio:function(){return this.width/this.height},getTopLeft:function(){return new e.Point(this.x,this.y)},getBottomRight:function(){return new e.Point(this.x+this.width,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getTopRight:function(){return new e.Point(this.x+this.width,this.y).rotate(this.degrees,this.getTopLeft())},getBottomLeft:function(){return new e.Point(this.x,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getCenter:function(){return new e.Point(this.x+this.width/2,this.y+this.height/2).rotate(this.degrees,this.getTopLeft())},getSize:function(){return new e.Point(this.width,this.height)},equals:function(t){return t instanceof e.Rect&&this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height&&this.degrees===t.degrees},times:function(t){return new e.Rect(this.x*t,this.y*t,this.width*t,this.height*t,this.degrees)},translate:function(t){return new e.Rect(this.x+t.x,this.y+t.y,this.width,this.height,this.degrees)},union:function(t){var n=this.getBoundingBox(),i=t.getBoundingBox(),r=Math.min(n.x,i.x),a=Math.min(n.y,i.y),s=Math.max(n.x+n.width,i.x+i.width),o=Math.max(n.y+n.height,i.y+i.height);return new e.Rect(r,a,s-r,o-a)},intersection:function(t){var n=1e-10,i=[],r=this.getTopLeft();t.containsPoint(r,n)&&i.push(r);var a=this.getTopRight();t.containsPoint(a,n)&&i.push(a);var s=this.getBottomLeft();t.containsPoint(s,n)&&i.push(s);var o=this.getBottomRight();t.containsPoint(o,n)&&i.push(o);var l=t.getTopLeft();this.containsPoint(l,n)&&i.push(l);var u=t.getTopRight();this.containsPoint(u,n)&&i.push(u);var d=t.getBottomLeft();this.containsPoint(d,n)&&i.push(d);var m=t.getBottomRight();this.containsPoint(m,n)&&i.push(m);for(var v=this._getSegments(),y=t._getSegments(),T=0;T<v.length;T++)for(var _=v[T],S=0;S<y.length;S++){var b=y[S],L=I(_[0],_[1],b[0],b[1]);L&&i.push(L)}function I(U,$,ne,te){var se=$.minus(U),re=te.minus(ne),ge=-re.x*se.y+se.x*re.y;if(ge===0)return null;var ye=(se.x*(U.y-ne.y)-se.y*(U.x-ne.x))/ge,ve=(re.x*(U.y-ne.y)-re.y*(U.x-ne.x))/ge;return-n<=ye&&ye<=1-n&&-n<=ve&&ve<=1-n?new e.Point(U.x+ve*se.x,U.y+ve*se.y):null}if(i.length===0)return null;for(var M=i[0].x,Z=i[0].x,V=i[0].y,j=i[0].y,J=1;J<i.length;J++){var W=i[J];W.x<M&&(M=W.x),W.x>Z&&(Z=W.x),W.y<V&&(V=W.y),W.y>j&&(j=W.y)}return new e.Rect(M,V,Z-M,j-V)},_getSegments:function(){var t=this.getTopLeft(),n=this.getTopRight(),i=this.getBottomLeft(),r=this.getBottomRight();return[[t,n],[n,r],[r,i],[i,t]]},rotate:function(t,n){if(t=e.positiveModulo(t,360),t===0)return this.clone();n=n||this.getCenter();var i=this.getTopLeft().rotate(t,n),r=this.getTopRight().rotate(t,n),a=r.minus(i);a=a.apply(function(o){var l=1e-15;return Math.abs(o)<l?0:o});var s=Math.atan(a.y/a.x);return a.x<0?s+=Math.PI:a.y<0&&(s+=2*Math.PI),new e.Rect(i.x,i.y,this.width,this.height,s/Math.PI*180)},getBoundingBox:function(){if(this.degrees===0)return this.clone();var t=this.getTopLeft(),n=this.getTopRight(),i=this.getBottomLeft(),r=this.getBottomRight(),a=Math.min(t.x,n.x,i.x,r.x),s=Math.max(t.x,n.x,i.x,r.x),o=Math.min(t.y,n.y,i.y,r.y),l=Math.max(t.y,n.y,i.y,r.y);return new e.Rect(a,o,s-a,l-o)},getIntegerBoundingBox:function(){var t=this.getBoundingBox(),n=Math.floor(t.x),i=Math.floor(t.y),r=Math.ceil(t.width+t.x-n),a=Math.ceil(t.height+t.y-i);return new e.Rect(n,i,r,a)},containsPoint:function(t,n){n=n||0;var i=this.getTopLeft(),r=this.getTopRight(),a=this.getBottomLeft(),s=r.minus(i),o=a.minus(i);return(t.x-i.x)*s.x+(t.y-i.y)*s.y>=-n&&(t.x-r.x)*s.x+(t.y-r.y)*s.y<=n&&(t.x-i.x)*o.x+(t.y-i.y)*o.y>=-n&&(t.x-a.x)*o.x+(t.y-a.y)*o.y<=n},toString:function(){return"["+Math.round(this.x*100)/100+", "+Math.round(this.y*100)/100+", "+Math.round(this.width*100)/100+"x"+Math.round(this.height*100)/100+", "+Math.round(this.degrees*100)/100+"deg]"}}}(x),function(e){var t={};e.ReferenceStrip=function(d){var m=this,v=d.viewer,y=e.getElementSize(v.element),T,_,S;for(d.id||(d.id="referencestrip-"+e.now(),this.element=e.makeNeutralElement("div"),this.element.id=d.id,this.element.className="referencestrip"),d=e.extend(!0,{sizeRatio:e.DEFAULT_SETTINGS.referenceStripSizeRatio,position:e.DEFAULT_SETTINGS.referenceStripPosition,scroll:e.DEFAULT_SETTINGS.referenceStripScroll,clickTimeThreshold:e.DEFAULT_SETTINGS.clickTimeThreshold},d,{element:this.element}),e.extend(this,d),t[this.id]={animating:!1},this.minPixelRatio=this.viewer.minPixelRatio,this.element.tabIndex=0,_=this.element.style,_.marginTop="0px",_.marginRight="0px",_.marginBottom="0px",_.marginLeft="0px",_.left="0px",_.bottom="0px",_.border="0px",_.background="#000",_.position="relative",e.setElementTouchActionNone(this.element),e.setElementOpacity(this.element,.8),this.viewer=v,this.tracker=new e.MouseTracker({userData:"ReferenceStrip.tracker",element:this.element,clickHandler:e.delegate(this,n),dragHandler:e.delegate(this,i),scrollHandler:e.delegate(this,r),enterHandler:e.delegate(this,s),leaveHandler:e.delegate(this,o),keyDownHandler:e.delegate(this,l),keyHandler:e.delegate(this,u),preProcessEventHandler:function(b){b.eventType==="wheel"&&(b.preventDefault=!0)}}),d.width&&d.height?(this.element.style.width=d.width+"px",this.element.style.height=d.height+"px",v.addControl(this.element,{anchor:e.ControlAnchor.BOTTOM_LEFT})):d.scroll==="horizontal"?(this.element.style.width=y.x*d.sizeRatio*v.tileSources.length+12*v.tileSources.length+"px",this.element.style.height=y.y*d.sizeRatio+"px",v.addControl(this.element,{anchor:e.ControlAnchor.BOTTOM_LEFT})):(this.element.style.height=y.y*d.sizeRatio*v.tileSources.length+12*v.tileSources.length+"px",this.element.style.width=y.x*d.sizeRatio+"px",v.addControl(this.element,{anchor:e.ControlAnchor.TOP_LEFT})),this.panelWidth=y.x*this.sizeRatio+8,this.panelHeight=y.y*this.sizeRatio+8,this.panels=[],this.miniViewers={},S=0;S<v.tileSources.length;S++)T=e.makeNeutralElement("div"),T.id=this.element.id+"-"+S,T.style.width=m.panelWidth+"px",T.style.height=m.panelHeight+"px",T.style.display="inline",T.style.float="left",T.style.cssFloat="left",T.style.padding="2px",e.setElementTouchActionNone(T),e.setElementPointerEventsNone(T),this.element.appendChild(T),T.activePanel=!1,this.panels.push(T);a(this,this.scroll==="vertical"?y.y:y.x,0),this.setFocus(0)},e.ReferenceStrip.prototype={setFocus:function(d){var m=this.element.querySelector("#"+this.element.id+"-"+d),v=e.getElementSize(this.viewer.canvas),y=Number(this.element.style.width.replace("px","")),T=Number(this.element.style.height.replace("px","")),_=-Number(this.element.style.marginLeft.replace("px","")),S=-Number(this.element.style.marginTop.replace("px","")),b;this.currentSelected!==m&&(this.currentSelected&&(this.currentSelected.style.background="#000"),this.currentSelected=m,this.currentSelected.style.background="#999",this.scroll==="horizontal"?(b=Number(d)*(this.panelWidth+3),b>_+v.x-this.panelWidth?(b=Math.min(b,y-v.x),this.element.style.marginLeft=-b+"px",a(this,v.x,-b)):b<_&&(b=Math.max(0,b-v.x/2),this.element.style.marginLeft=-b+"px",a(this,v.x,-b))):(b=Number(d)*(this.panelHeight+3),b>S+v.y-this.panelHeight?(b=Math.min(b,T-v.y),this.element.style.marginTop=-b+"px",a(this,v.y,-b)):b<S&&(b=Math.max(0,b-v.y/2),this.element.style.marginTop=-b+"px",a(this,v.y,-b))),this.currentPage=d,s.call(this,{eventSource:this.tracker}))},update:function(){return!!t[this.id].animating},destroy:function(){if(this.miniViewers)for(var d in this.miniViewers)this.miniViewers[d].destroy();this.tracker.destroy(),this.element&&this.viewer.removeControl(this.element)}};function n(d){if(d.quick){var m;this.scroll==="horizontal"?m=Math.floor(d.position.x/(this.panelWidth+4)):m=Math.floor(d.position.y/this.panelHeight),this.viewer.goToPage(m)}this.element.focus()}function i(d){if(this.dragging=!0,this.element){var m=Number(this.element.style.marginLeft.replace("px","")),v=Number(this.element.style.marginTop.replace("px","")),y=Number(this.element.style.width.replace("px","")),T=Number(this.element.style.height.replace("px","")),_=e.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?-d.delta.x>0?m>-(y-_.x)&&(this.element.style.marginLeft=m+d.delta.x*2+"px",a(this,_.x,m+d.delta.x*2)):-d.delta.x<0&&m<0&&(this.element.style.marginLeft=m+d.delta.x*2+"px",a(this,_.x,m+d.delta.x*2)):-d.delta.y>0?v>-(T-_.y)&&(this.element.style.marginTop=v+d.delta.y*2+"px",a(this,_.y,v+d.delta.y*2)):-d.delta.y<0&&v<0&&(this.element.style.marginTop=v+d.delta.y*2+"px",a(this,_.y,v+d.delta.y*2))}}function r(d){if(this.element){var m=Number(this.element.style.marginLeft.replace("px","")),v=Number(this.element.style.marginTop.replace("px","")),y=Number(this.element.style.width.replace("px","")),T=Number(this.element.style.height.replace("px","")),_=e.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?d.scroll>0?m>-(y-_.x)&&(this.element.style.marginLeft=m-d.scroll*60+"px",a(this,_.x,m-d.scroll*60)):d.scroll<0&&m<0&&(this.element.style.marginLeft=m-d.scroll*60+"px",a(this,_.x,m-d.scroll*60)):d.scroll<0?v>_.y-T&&(this.element.style.marginTop=v+d.scroll*60+"px",a(this,_.y,v+d.scroll*60)):d.scroll>0&&v<0&&(this.element.style.marginTop=v+d.scroll*60+"px",a(this,_.y,v+d.scroll*60)),d.preventDefault=!0}}function a(d,m,v){var y,T,_,S,b,L;for(d.scroll==="horizontal"?y=d.panelWidth:y=d.panelHeight,T=Math.ceil(m/y)+5,_=Math.ceil((Math.abs(v)+m)/y)+1,T=_-T,T=T<0?0:T,b=T;b<_&&b<d.panels.length;b++)if(L=d.panels[b],!L.activePanel){var I,M=d.viewer.tileSources[b];M.referenceStripThumbnailUrl?I={type:"image",url:M.referenceStripThumbnailUrl}:I=M,S=new e.Viewer({id:L.id,tileSources:[I],element:L,navigatorSizeRatio:d.sizeRatio,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:0,loadTilesWithAjax:d.viewer.loadTilesWithAjax,ajaxHeaders:d.viewer.ajaxHeaders,drawer:"canvas"}),e.setElementPointerEventsNone(S.canvas),e.setElementPointerEventsNone(S.container),S.innerTracker.setTracking(!1),S.outerTracker.setTracking(!1),d.miniViewers[L.id]=S,L.activePanel=!0}}function s(d){var m=d.eventSource.element;this.scroll==="horizontal"?m.style.marginBottom="0px":m.style.marginLeft="0px"}function o(d){var m=d.eventSource.element;this.scroll==="horizontal"?m.style.marginBottom="-"+e.getElementSize(m).y/2+"px":m.style.marginLeft="-"+e.getElementSize(m).x/2+"px"}function l(d){if(!d.ctrl&&!d.alt&&!d.meta)switch(d.keyCode){case 38:r.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 40:r.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 37:r.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 39:r.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;default:d.preventDefault=!1;break}else d.preventDefault=!1}function u(d){if(!d.ctrl&&!d.alt&&!d.meta)switch(d.keyCode){case 61:r.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 45:r.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 48:case 119:case 87:r.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 115:case 83:r.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 97:r.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 100:r.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;default:d.preventDefault=!1;break}else d.preventDefault=!1}}(x),function(e){e.DisplayRect=function(t,n,i,r,a,s){e.Rect.apply(this,[t,n,i,r]),this.minLevel=a,this.maxLevel=s},e.extend(e.DisplayRect.prototype,e.Rect.prototype)}(x),function(e){e.Spring=function(n){var i=arguments;typeof n!="object"&&(n={initial:i.length&&typeof i[0]=="number"?i[0]:void 0,springStiffness:i.length>1?i[1].springStiffness:5,animationTime:i.length>1?i[1].animationTime:1.5}),e.console.assert(typeof n.springStiffness=="number"&&n.springStiffness!==0,"[OpenSeadragon.Spring] options.springStiffness must be a non-zero number"),e.console.assert(typeof n.animationTime=="number"&&n.animationTime>=0,"[OpenSeadragon.Spring] options.animationTime must be a number greater than or equal to 0"),n.exponential&&(this._exponential=!0,delete n.exponential),e.extend(!0,this,n),this.current={value:typeof this.initial=="number"?this.initial:this._exponential?0:1,time:e.now()},e.console.assert(!this._exponential||this.current.value!==0,"[OpenSeadragon.Spring] value must be non-zero for exponential springs"),this.start={value:this.current.value,time:this.current.time},this.target={value:this.current.value,time:this.current.time},this._exponential&&(this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value),this.current._logValue=Math.log(this.current.value))},e.Spring.prototype={resetTo:function(n){e.console.assert(!this._exponential||n!==0,"[OpenSeadragon.Spring.resetTo] target must be non-zero for exponential springs"),this.start.value=this.target.value=this.current.value=n,this.start.time=this.target.time=this.current.time=e.now(),this._exponential&&(this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value),this.current._logValue=Math.log(this.current.value))},springTo:function(n){e.console.assert(!this._exponential||n!==0,"[OpenSeadragon.Spring.springTo] target must be non-zero for exponential springs"),this.start.value=this.current.value,this.start.time=this.current.time,this.target.value=n,this.target.time=this.start.time+1e3*this.animationTime,this._exponential&&(this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value))},shiftBy:function(n){this.start.value+=n,this.target.value+=n,this._exponential&&(e.console.assert(this.target.value!==0&&this.start.value!==0,"[OpenSeadragon.Spring.shiftBy] spring value must be non-zero for exponential springs"),this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value))},setExponential:function(n){this._exponential=n,this._exponential&&(e.console.assert(this.current.value!==0&&this.target.value!==0&&this.start.value!==0,"[OpenSeadragon.Spring.setExponential] spring value must be non-zero for exponential springs"),this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value),this.current._logValue=Math.log(this.current.value))},update:function(){this.current.time=e.now();let n,i;if(this._exponential?(n=this.start._logValue,i=this.target._logValue):(n=this.start.value,i=this.target.value),this.current.time>=this.target.time)this.current.value=this.target.value;else{let r=n+(i-n)*t(this.springStiffness,(this.current.time-this.start.time)/(this.target.time-this.start.time));this._exponential?this.current.value=Math.exp(r):this.current.value=r}return this.current.value!==this.target.value},isAtTargetValue:function(){return this.current.value===this.target.value}};function t(n,i){return(1-Math.exp(n*-i))/(1-Math.exp(-n))}}(x),function(e){e.ImageJob=function(n){e.extend(!0,this,{timeout:e.DEFAULT_SETTINGS.timeout,jobId:null,tries:0},n),this.data=null,this.userData={},this.errorMsg=null},e.ImageJob.prototype={start:function(){this.tries++;var n=this,i=this.abort;this.jobId=window.setTimeout(function(){n.finish(null,null,"Image load exceeded timeout ("+n.timeout+" ms)")},this.timeout),this.abort=function(){n.source.downloadTileAbort(n),typeof i=="function"&&i()},this.source.downloadTileStart(this)},finish:function(n,i,r){this.data=n,this.request=i,this.errorMsg=r,this.jobId&&window.clearTimeout(this.jobId),this.callback(this)}},e.ImageLoader=function(n){e.extend(!0,this,{jobLimit:e.DEFAULT_SETTINGS.imageLoaderLimit,timeout:e.DEFAULT_SETTINGS.timeout,jobQueue:[],failedTiles:[],jobsInProgress:0},n)},e.ImageLoader.prototype={addJob:function(n){if(!n.source){e.console.error("ImageLoader.prototype.addJob() requires [options.source]. TileSource since new API defines how images are fetched. Creating a dummy TileSource.");var i=e.TileSource.prototype;n.source={downloadTileStart:i.downloadTileStart,downloadTileAbort:i.downloadTileAbort}}var r=this,a=function(l){t(r,l,n.callback)},s={src:n.src,tile:n.tile||{},source:n.source,loadWithAjax:n.loadWithAjax,ajaxHeaders:n.loadWithAjax?n.ajaxHeaders:null,crossOriginPolicy:n.crossOriginPolicy,ajaxWithCredentials:n.ajaxWithCredentials,postData:n.postData,callback:a,abort:n.abort,timeout:this.timeout},o=new e.ImageJob(s);!this.jobLimit||this.jobsInProgress<this.jobLimit?(o.start(),this.jobsInProgress++):this.jobQueue.push(o)},clear:function(){for(var n=0;n<this.jobQueue.length;n++){var i=this.jobQueue[n];typeof i.abort=="function"&&i.abort()}this.jobQueue=[]}};function t(n,i,r){i.errorMsg!==""&&(i.data===null||i.data===void 0)&&i.tries<1+n.tileRetryMax&&n.failedTiles.push(i);var a;n.jobsInProgress--,(!n.jobLimit||n.jobsInProgress<n.jobLimit)&&n.jobQueue.length>0&&(a=n.jobQueue.shift(),a.start(),n.jobsInProgress++),n.tileRetryMax>0&&n.jobQueue.length===0&&(!n.jobLimit||n.jobsInProgress<n.jobLimit)&&n.failedTiles.length>0&&(a=n.failedTiles.shift(),setTimeout(function(){a.start()},n.tileRetryDelay),n.jobsInProgress++),r(i.data,i.errorMsg,i.request)}}(x),function(e){e.Tile=function(t,n,i,r,a,s,o,l,u,d,m,v){this.level=t,this.x=n,this.y=i,this.bounds=r,this.positionedBounds=new x.Rect(r.x,r.y,r.width,r.height),this.sourceBounds=d,this.exists=a,this._url=s,this.postData=m,this.context2D=o,this.loadWithAjax=l,this.ajaxHeaders=u,v===void 0&&(e.console.warn("Tile constructor needs 'cacheKey' variable: creation tile cache in Tile class is deprecated. TileSource.prototype.getTileHashKey will be used."),v=e.TileSource.prototype.getTileHashKey(t,n,i,s,u,m)),this.cacheKey=v,this.loaded=!1,this.loading=!1,this.element=null,this.imgElement=null,this.style=null,this.position=null,this.size=null,this.flipped=!1,this.blendStart=null,this.opacity=null,this.squaredDistance=null,this.visibility=null,this.hasTransparency=!1,this.beingDrawn=!1,this.lastTouchTime=0,this.isRightMost=!1,this.isBottomMost=!1},e.Tile.prototype={toString:function(){return this.level+"/"+this.x+"_"+this.y},_hasTransparencyChannel:function(){return console.warn("Tile.prototype._hasTransparencyChannel() has been deprecated and will be removed in the future. Use TileSource.prototype.hasTransparency() instead."),!!this.context2D||this.getUrl().match(".png")},get image(){return e.console.error("[Tile.image] property has been deprecated. Use [Tile.prototype.getImage] instead."),this.getImage()},get url(){return e.console.error("[Tile.url] property has been deprecated. Use [Tile.prototype.getUrl] instead."),this.getUrl()},getImage:function(){return this.cacheImageRecord.getImage()},getUrl:function(){return typeof this._url=="function"?this._url():this._url},getCanvasContext:function(){return this.context2D||this.cacheImageRecord&&this.cacheImageRecord.getRenderedContext()},getScaleForEdgeSmoothing:function(){var t;if(this.cacheImageRecord)t=this.cacheImageRecord.getRenderedContext();else if(this.context2D)t=this.context2D;else return e.console.warn("[Tile.drawCanvas] attempting to get tile scale %s when tile's not cached",this.toString()),1;return t.canvas.width/(this.size.x*e.pixelDensityRatio)},getTranslationForEdgeSmoothing:function(t,n,i){var r=Math.max(1,Math.ceil((i.x-n.x)/2)),a=Math.max(1,Math.ceil((i.y-n.y)/2));return new e.Point(r,a).minus(this.position.times(e.pixelDensityRatio).times(t||1).apply(function(s){return s%1}))},unload:function(){this.imgElement&&this.imgElement.parentNode&&this.imgElement.parentNode.removeChild(this.imgElement),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.imgElement=null,this.loaded=!1,this.loading=!1}}}(x),function(e){e.OverlayPlacement=e.Placement,e.OverlayRotationMode=e.freezeObject({NO_ROTATION:1,EXACT:2,BOUNDING_BOX:3}),e.Overlay=function(t,n,i){var r;e.isPlainObject(t)?r=t:r={element:t,location:n,placement:i},this.element=r.element,this.element.innerHTML="<div>"+this.element.innerHTML+"</div>",this.style=r.element.style,this._init(r)},e.Overlay.prototype={_init:function(t){this.location=t.location,this.placement=t.placement===void 0?e.Placement.TOP_LEFT:t.placement,this.onDraw=t.onDraw,this.checkResize=t.checkResize===void 0?!0:t.checkResize,this.width=t.width===void 0?null:t.width,this.height=t.height===void 0?null:t.height,this.rotationMode=t.rotationMode||e.OverlayRotationMode.EXACT,this.location instanceof e.Rect&&(this.width=this.location.width,this.height=this.location.height,this.location=this.location.getTopLeft(),this.placement=e.Placement.TOP_LEFT),this.scales=this.width!==null&&this.height!==null,this.bounds=new e.Rect(this.location.x,this.location.y,this.width,this.height),this.position=this.location},adjust:function(t,n){var i=e.Placement.properties[this.placement];i&&(i.isHorizontallyCentered?t.x-=n.x/2:i.isRight&&(t.x-=n.x),i.isVerticallyCentered?t.y-=n.y/2:i.isBottom&&(t.y-=n.y))},destroy:function(){var t=this.element,n=this.style;t.parentNode&&(t.parentNode.removeChild(t),t.prevElementParent&&(n.display="none",document.body.appendChild(t))),this.onDraw=null,n.top="",n.left="",n.position="",this.width!==null&&(n.width=""),this.height!==null&&(n.height="");var i=e.getCssPropertyWithVendorPrefix("transformOrigin"),r=e.getCssPropertyWithVendorPrefix("transform");i&&r&&(n[i]="",n[r]="")},drawHTML:function(t,n){var i=this.element;i.parentNode!==t&&(i.prevElementParent=i.parentNode,i.prevNextSibling=i.nextSibling,t.appendChild(i),this.style.position="absolute",this.size=e.getElementSize(i));var r=this._getOverlayPositionAndSize(n),a=r.position,s=this.size=r.size,o="";n.overlayPreserveContentDirection&&(o=n.flipped?" scaleX(-1)":" scaleX(1)");var l=n.flipped?-r.rotate:r.rotate,u=n.flipped?" scaleX(-1)":"";if(this.onDraw)this.onDraw(a,s,this.element);else{var d=this.style,m=i.firstChild,v=m.style;d.left=a.x+"px",d.top=a.y+"px",this.width!==null&&(d.width=s.x+"px"),this.height!==null&&(d.height=s.y+"px");var y=e.getCssPropertyWithVendorPrefix("transformOrigin"),T=e.getCssPropertyWithVendorPrefix("transform");y&&T&&(l&&!n.flipped?(v[T]="",d[y]=this._getTransformOrigin(),d[T]="rotate("+l+"deg)"):!l&&n.flipped?(v[T]=o,d[y]=this._getTransformOrigin(),d[T]=u):l&&n.flipped?(v[T]=o,d[y]=this._getTransformOrigin(),d[T]="rotate("+l+"deg)"+u):(v[T]="",d[y]="",d[T]="")),d.display="block"}},_getOverlayPositionAndSize:function(t){var n=t.pixelFromPoint(this.location,!0),i=this._getSizeInPixels(t);this.adjust(n,i);var r=0;if(t.getRotation(!0)&&this.rotationMode!==e.OverlayRotationMode.NO_ROTATION)if(this.rotationMode===e.OverlayRotationMode.BOUNDING_BOX&&this.width!==null&&this.height!==null){var a=new e.Rect(n.x,n.y,i.x,i.y),s=this._getBoundingBox(a,t.getRotation(!0));n=s.getTopLeft(),i=s.getSize()}else r=t.getRotation(!0);return t.flipped&&(n.x=t.getContainerSize().x-n.x),{position:n,size:i,rotate:r}},_getSizeInPixels:function(t){var n=this.size.x,i=this.size.y;if(this.width!==null||this.height!==null){var r=t.deltaPixelsFromPointsNoRotate(new e.Point(this.width||0,this.height||0),!0);this.width!==null&&(n=r.x),this.height!==null&&(i=r.y)}if(this.checkResize&&(this.width===null||this.height===null)){var a=this.size=e.getElementSize(this.element);this.width===null&&(n=a.x),this.height===null&&(i=a.y)}return new e.Point(n,i)},_getBoundingBox:function(t,n){var i=this._getPlacementPoint(t);return t.rotate(n,i).getBoundingBox()},_getPlacementPoint:function(t){var n=new e.Point(t.x,t.y),i=e.Placement.properties[this.placement];return i&&(i.isHorizontallyCentered?n.x+=t.width/2:i.isRight&&(n.x+=t.width),i.isVerticallyCentered?n.y+=t.height/2:i.isBottom&&(n.y+=t.height)),n},_getTransformOrigin:function(){var t="",n=e.Placement.properties[this.placement];return n&&(n.isLeft?t="left":n.isRight&&(t="right"),n.isTop?t+=" top":n.isBottom&&(t+=" bottom")),t},update:function(t,n){var i=e.isPlainObject(t)?t:{location:t,placement:n};this._init({location:i.location||this.location,placement:i.placement!==void 0?i.placement:this.placement,onDraw:i.onDraw||this.onDraw,checkResize:i.checkResize||this.checkResize,width:i.width!==void 0?i.width:this.width,height:i.height!==void 0?i.height:this.height,rotationMode:i.rotationMode||this.rotationMode})},getBounds:function(t){e.console.assert(t,"A viewport must now be passed to Overlay.getBounds.");var n=this.width,i=this.height;if(n===null||i===null){var r=t.deltaPointsFromPixelsNoRotate(this.size,!0);n===null&&(n=r.x),i===null&&(i=r.y)}var a=this.location.clone();return this.adjust(a,new e.Point(n,i)),this._adjustBoundsForRotation(t,new e.Rect(a.x,a.y,n,i))},_adjustBoundsForRotation:function(t,n){if(!t||t.getRotation(!0)===0||this.rotationMode===e.OverlayRotationMode.EXACT)return n;if(this.rotationMode===e.OverlayRotationMode.BOUNDING_BOX){if(this.width===null||this.height===null)return n;var i=this._getOverlayPositionAndSize(t);return t.viewerElementToViewportRectangle(new e.Rect(i.position.x,i.position.y,i.size.x,i.size.y))}return n.rotate(-t.getRotation(!0),this._getPlacementPoint(n))}}}(x),function(e){const t=e;t.DrawerBase=class{constructor(i){e.console.assert(i.viewer,"[Drawer] options.viewer is required"),e.console.assert(i.viewport,"[Drawer] options.viewport is required"),e.console.assert(i.element,"[Drawer] options.element is required"),this.viewer=i.viewer,this.viewport=i.viewport,this.debugGridColor=typeof i.debugGridColor=="string"?[i.debugGridColor]:i.debugGridColor||e.DEFAULT_SETTINGS.debugGridColor,this.options=i.options||{},this.container=e.getElement(i.element),this._renderingTarget=this._createDrawingElement(),this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.position="absolute",this.canvas.style.left="0",e.setElementOpacity(this.canvas,this.viewer.opacity,!0),e.setElementPointerEventsNone(this.canvas),e.setElementTouchActionNone(this.canvas),this.container.style.textAlign="left",this.container.appendChild(this.canvas),this._checkForAPIOverrides()}get canvas(){return this._renderingTarget}get element(){return e.console.error("Drawer.element is deprecated. Use Drawer.container instead."),this.container}getType(){e.console.error("Drawer.getType must be implemented by child class")}static isSupported(){e.console.error("Drawer.isSupported must be implemented by child class")}_createDrawingElement(){return e.console.error("Drawer._createDrawingElement must be implemented by child class"),null}draw(i){e.console.error("Drawer.draw must be implemented by child class")}canRotate(){e.console.error("Drawer.canRotate must be implemented by child class")}destroy(){e.console.error("Drawer.destroy must be implemented by child class")}minimumOverlapRequired(i){return!1}setImageSmoothingEnabled(i){e.console.error("Drawer.setImageSmoothingEnabled must be implemented by child class")}drawDebuggingRect(i){e.console.warn("[drawer].drawDebuggingRect is not implemented by this drawer")}clear(){e.console.warn("[drawer].clear() is deprecated. The drawer is responsible for clearing itself as needed before drawing tiles.")}_checkForAPIOverrides(){if(this._createDrawingElement===e.DrawerBase.prototype._createDrawingElement)throw new Error("[drawer]._createDrawingElement must be implemented by child class");if(this.draw===e.DrawerBase.prototype.draw)throw new Error("[drawer].draw must be implemented by child class");if(this.canRotate===e.DrawerBase.prototype.canRotate)throw new Error("[drawer].canRotate must be implemented by child class");if(this.destroy===e.DrawerBase.prototype.destroy)throw new Error("[drawer].destroy must be implemented by child class");if(this.setImageSmoothingEnabled===e.DrawerBase.prototype.setImageSmoothingEnabled)throw new Error("[drawer].setImageSmoothingEnabled must be implemented by child class")}viewportToDrawerRectangle(i){var r=this.viewport.pixelFromPointNoRotate(i.getTopLeft(),!0),a=this.viewport.deltaPixelsFromPointsNoRotate(i.getSize(),!0);return new e.Rect(r.x*e.pixelDensityRatio,r.y*e.pixelDensityRatio,a.x*e.pixelDensityRatio,a.y*e.pixelDensityRatio)}viewportCoordToDrawerCoord(i){var r=this.viewport.pixelFromPointNoRotate(i,!0);return new e.Point(r.x*e.pixelDensityRatio,r.y*e.pixelDensityRatio)}_calculateCanvasSize(){var i=e.pixelDensityRatio,r=this.viewport.getContainerSize();return new t.Point(Math.round(r.x*i),Math.round(r.y*i))}_raiseTiledImageDrawnEvent(i,r){this.viewer&&this.viewer.raiseEvent("tiled-image-drawn",{tiledImage:i,tiles:r})}_raiseDrawerErrorEvent(i,r){this.viewer&&this.viewer.raiseEvent("drawer-error",{tiledImage:i,drawer:this,error:r})}}}(x),function(e){const t=e;class n extends t.DrawerBase{constructor(r){super(r),this.viewer.rejectEventHandler("tile-drawing","The HTMLDrawer does not raise the tile-drawing event"),this.viewer.allowEventHandler("tile-drawn")}static isSupported(){return!0}getType(){return"html"}minimumOverlapRequired(r){return!0}_createDrawingElement(){return e.makeNeutralElement("div")}draw(r){var a=this;this._prepareNewFrame(),r.forEach(function(s){s.opacity!==0&&a._drawTiles(s)})}canRotate(){return!1}destroy(){this.container.removeChild(this.canvas)}setImageSmoothingEnabled(){}_prepareNewFrame(){this.canvas.innerHTML=""}_drawTiles(r){var a=r.getTilesToDraw().map(l=>l.tile);if(!(r.opacity===0||a.length===0&&!r.placeholderFillStyle))for(var s=a.length-1;s>=0;s--){var o=a[s];this._drawTile(o),this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:r,tile:o})}}_drawTile(r){e.console.assert(r,"[Drawer._drawTile] tile is required");let a=this.canvas;if(!r.cacheImageRecord){e.console.warn("[Drawer._drawTileToHTML] attempting to draw tile %s when it's not cached",r.toString());return}if(!r.loaded){e.console.warn("Attempting to draw tile %s when it's not yet loaded.",r.toString());return}if(!r.element){var s=r.getImage();if(!s)return;r.element=e.makeNeutralElement("div"),r.imgElement=s.cloneNode(),r.imgElement.style.msInterpolationMode="nearest-neighbor",r.imgElement.style.width="100%",r.imgElement.style.height="100%",r.style=r.element.style,r.style.position="absolute"}r.element.parentNode!==a&&a.appendChild(r.element),r.imgElement.parentNode!==r.element&&r.element.appendChild(r.imgElement),r.style.top=r.position.y+"px",r.style.left=r.position.x+"px",r.style.height=r.size.y+"px",r.style.width=r.size.x+"px",r.flipped&&(r.style.transform="scaleX(-1)"),e.setElementOpacity(r.element,r.opacity)}}e.HTMLDrawer=n}(x),function(e){const t=e;class n extends t.DrawerBase{constructor(l){super(l),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 e.supportsCanvas}getType(){return"canvas"}_createDrawingElement(){let l=e.makeNeutralElement("canvas"),u=this._calculateCanvasSize();return l.width=u.x,l.height=u.y,l}draw(l){this._prepareNewFrame(),this.viewer.viewport.getFlip()!==this._viewportFlipped&&this._flip();for(const u of l)u.opacity!==0&&this._drawTiles(u)}canRotate(){return!0}destroy(){this.canvas.width=1,this.canvas.height=1,this.sketchCanvas=null,this.sketchContext=null,this.container.removeChild(this.canvas)}minimumOverlapRequired(l){return!0}setImageSmoothingEnabled(l){this._imageSmoothingEnabled=!!l,this._updateImageSmoothingEnabled(this.context),this.viewer.forceRedraw()}drawDebuggingRect(l){var u=this.context;u.save(),u.lineWidth=2*e.pixelDensityRatio,u.strokeStyle=this.debugGridColor[0],u.fillStyle=this.debugGridColor[0],u.strokeRect(l.x*e.pixelDensityRatio,l.y*e.pixelDensityRatio,l.width*e.pixelDensityRatio,l.height*e.pixelDensityRatio),u.restore()}get _viewportFlipped(){return this.context.getTransform().a<0}_raiseTileDrawingEvent(l,u,d,m){this.viewer.raiseEvent("tile-drawing",{tiledImage:l,context:u,tile:d,rendered:m})}_prepareNewFrame(){var l=this._calculateCanvasSize();if((this.canvas.width!==l.x||this.canvas.height!==l.y)&&(this.canvas.width=l.x,this.canvas.height=l.y,this._updateImageSmoothingEnabled(this.context),this.sketchCanvas!==null)){var u=this._calculateSketchCanvasSize();this.sketchCanvas.width=u.x,this.sketchCanvas.height=u.y,this._updateImageSmoothingEnabled(this.sketchContext)}this._clear()}_clear(l,u){var d=this._getContext(l);if(u)d.clearRect(u.x,u.y,u.width,u.height);else{var m=d.canvas;d.clearRect(0,0,m.width,m.height)}}_drawTiles(l){var u=l.getTilesToDraw().map(U=>U.tile);if(!(l.opacity===0||u.length===0&&!l.placeholderFillStyle)){var d=u[0],m;d&&(m=l.opacity<1||l.compositeOperation&&l.compositeOperation!=="source-over"||!l._isBottomItem()&&l.source.hasTransparency(d.context2D,d.getUrl(),d.ajaxHeaders,d.postData));var v,y,T=this.viewport.getZoom(!0),_=l.viewportToImageZoom(T);u.length>1&&_>l.smoothTileEdgesMinZoom&&!l.iOSDevice&&l.getRotation(!0)%360===0&&(m=!0,v=d.getScaleForEdgeSmoothing(),y=d.getTranslationForEdgeSmoothing(v,this._getCanvasSize(!1),this._getCanvasSize(!0)));var S;m&&(v||(S=this.viewport.viewportToViewerElementRectangle(l.getClippedBounds(!0)).getIntegerBoundingBox(),S=S.times(e.pixelDensityRatio)),this._clear(!0,S)),v||this._setRotations(l,m);var b=!1;if(l._clip){this._saveContext(m);var L=l.imageToViewportRectangle(l._clip,!0);L=L.rotate(-l.getRotation(!0),l._getRotationPoint(!0));var I=this.viewportToDrawerRectangle(L);v&&(I=I.times(v)),y&&(I=I.translate(y)),this._setClip(I,m),b=!0}if(l._croppingPolygons){var M=this;b||this._saveContext(m);try{var Z=l._croppingPolygons.map(function(U){return U.map(function($){var ne=l.imageToViewportCoordinates($.x,$.y,!0).rotate(-l.getRotation(!0),l._getRotationPoint(!0)),te=M.viewportCoordToDrawerCoord(ne);return v&&(te=te.times(v)),y&&(te=te.plus(y)),te})});this._clipWithPolygons(Z,m)}catch(U){e.console.error(U)}b=!0}if(l._hasOpaqueTile=!1,l.placeholderFillStyle&&l._hasOpaqueTile===!1){let U=this.viewportToDrawerRectangle(l.getBoundsNoRotate(!0));v&&(U=U.times(v)),y&&(U=U.translate(y));let $=null;typeof l.placeholderFillStyle=="function"?$=l.placeholderFillStyle(l,this.context):$=l.placeholderFillStyle,this._drawRectangle(U,$,m)}var V=s(l.subPixelRoundingForTransparency),j=!1;if(V===e.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS)j=!0;else if(V===e.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST){var J=this.viewer&&this.viewer.isAnimating();j=!J}for(var W=0;W<u.length;W++)d=u[W],this._drawTile(d,l,m,v,y,j,l.source),this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:l,tile:d});b&&this._restoreContext(m),v||(l.getRotation(!0)%360!==0&&this._restoreRotationChanges(m),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(m)),m&&(v&&this._setRotations(l),this.blendSketch({opacity:l.opacity,scale:v,translate:y,compositeOperation:l.compositeOperation,bounds:S}),v&&(l.getRotation(!0)%360!==0&&this._restoreRotationChanges(!1),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(!1))),this._drawDebugInfo(l,u),this._raiseTiledImageDrawnEvent(l,u)}}_drawDebugInfo(l,u){if(l.debugMode)for(var d=u.length-1;d>=0;d--){var m=u[d];try{this._drawDebugInfoOnTile(m,u.length,d,l)}catch(v){e.console.error(v)}}}_clipWithPolygons(l,u){var d=this._getContext(u);d.beginPath();for(const m of l)for(const[v,y]of m.entries())d[v===0?"moveTo":"lineTo"](y.x,y.y);d.clip()}_drawTile(l,u,d,m,v,y,T){e.console.assert(l,"[Drawer._drawTile] tile is required"),e.console.assert(u,"[Drawer._drawTile] drawingHandler is required");var _=this._getContext(d);m=m||1,this._drawTileToCanvas(l,_,u,m,v,y,T)}_drawTileToCanvas(l,u,d,m,v,y,T){var _=l.position.times(e.pixelDensityRatio),S=l.size.times(e.pixelDensityRatio),b;if(!l.context2D&&!l.cacheImageRecord){e.console.warn("[Drawer._drawTileToCanvas] attempting to draw tile %s when it's not cached",l.toString());return}if(b=l.getCanvasContext(),!l.loaded||!b){e.console.warn("Attempting to draw tile %s when it's not yet loaded.",l.toString());return}u.save(),typeof m=="number"&&m!==1&&(_=_.times(m),S=S.times(m)),v instanceof e.Point&&(_=_.plus(v)),u.globalAlpha===1&&l.hasTransparency&&(y&&(_.x=Math.round(_.x),_.y=Math.round(_.y),S.x=Math.round(S.x),S.y=Math.round(S.y)),u.clearRect(_.x,_.y,S.x,S.y)),this._raiseTileDrawingEvent(d,u,l,b);var L,I;l.sourceBounds?(L=Math.min(l.sourceBounds.width,b.canvas.width),I=Math.min(l.sourceBounds.height,b.canvas.height)):(L=b.canvas.width,I=b.canvas.height),u.translate(_.x+S.x/2,0),l.flipped&&u.scale(-1,1),u.drawImage(b.canvas,0,0,L,I,-S.x/2,_.y,S.x,S.y),u.restore()}_getContext(l){var u=this.context;if(l){if(this.sketchCanvas===null){this.sketchCanvas=document.createElement("canvas");var d=this._calculateSketchCanvasSize();if(this.sketchCanvas.width=d.x,this.sketchCanvas.height=d.y,this.sketchContext=this.sketchCanvas.getContext("2d"),this.viewport.getRotation()===0){var m=this;this.viewer.addHandler("rotate",function v(){if(m.viewport.getRotation()!==0){m.viewer.removeHandler("rotate",v);var y=m._calculateSketchCanvasSize();m.sketchCanvas.width=y.x,m.sketchCanvas.height=y.y}})}this._updateImageSmoothingEnabled(this.sketchContext)}u=this.sketchContext}return u}_saveContext(l){this._getContext(l).save()}_restoreContext(l){this._getContext(l).restore()}_setClip(l,u){var d=this._getContext(u);d.beginPath(),d.rect(l.x,l.y,l.width,l.height),d.clip()}_drawRectangle(l,u,d){var m=this._getContext(d);m.save(),m.fillStyle=u,m.fillRect(l.x,l.y,l.width,l.height),m.restore()}blendSketch(l,u,d,m){var v=l;e.isPlainObject(v)||(v={opacity:l,scale:u,translate:d,compositeOperation:m}),l=v.opacity,m=v.compositeOperation;var y=v.bounds;if(this.context.save(),this.context.globalAlpha=l,m&&(this.context.globalCompositeOperation=m),y)y.x<0&&(y.width+=y.x,y.x=0),y.x+y.width>this.canvas.width&&(y.width=this.canvas.width-y.x),y.y<0&&(y.height+=y.y,y.y=0),y.y+y.height>this.canvas.height&&(y.height=this.canvas.height-y.y),this.context.drawImage(this.sketchCanvas,y.x,y.y,y.width,y.height,y.x,y.y,y.width,y.height);else{u=v.scale||1,d=v.translate;var T=d instanceof e.Point?d:new e.Point(0,0),_=0,S=0;if(d){var b=this.sketchCanvas.width-this.canvas.width,L=this.sketchCanvas.height-this.canvas.height;_=Math.round(b/2),S=Math.round(L/2)}this.context.drawImage(this.sketchCanvas,T.x-_*u,T.y-S*u,(this.canvas.width+2*_)*u,(this.canvas.height+2*S)*u,-_,-S,this.canvas.width+2*_,this.canvas.height+2*S)}this.context.restore()}_drawDebugInfoOnTile(l,u,d,m){var v=this.viewer.world.getIndexOfItem(m)%this.debugGridColor.length,y=this.context;y.save(),y.lineWidth=2*e.pixelDensityRatio,y.font="small-caps bold "+13*e.pixelDensityRatio+"px arial",y.strokeStyle=this.debugGridColor[v],y.fillStyle=this.debugGridColor[v],this._setRotations(m),this._viewportFlipped&&this._flip({point:l.position.plus(l.size.divide(2))}),y.strokeRect(l.position.x*e.pixelDensityRatio,l.position.y*e.pixelDensityRatio,l.size.x*e.pixelDensityRatio,l.size.y*e.pixelDensityRatio);var T=(l.position.x+l.size.x/2)*e.pixelDensityRatio,_=(l.position.y+l.size.y/2)*e.pixelDensityRatio;y.translate(T,_);const S=this.viewport.getRotation(!0);y.rotate(Math.PI/180*-S),y.translate(-T,-_),l.x===0&&l.y===0&&(y.fillText("Zoom: "+this.viewport.getZoom(),l.position.x*e.pixelDensityRatio,(l.position.y-30)*e.pixelDensityRatio),y.fillText("Pan: "+this.viewport.getBounds().toString(),l.position.x*e.pixelDensityRatio,(l.position.y-20)*e.pixelDensityRatio)),y.fillText("Level: "+l.level,(l.position.x+10)*e.pixelDensityRatio,(l.position.y+20)*e.pixelDensityRatio),y.fillText("Column: "+l.x,(l.position.x+10)*e.pixelDensityRatio,(l.position.y+30)*e.pixelDensityRatio),y.fillText("Row: "+l.y,(l.position.x+10)*e.pixelDensityRatio,(l.position.y+40)*e.pixelDensityRatio),y.fillText("Order: "+d+" of "+u,(l.position.x+10)*e.pixelDensityRatio,(l.position.y+50)*e.pixelDensityRatio),y.fillText("Size: "+l.size.toString(),(l.position.x+10)*e.pixelDensityRatio,(l.position.y+60)*e.pixelDensityRatio),y.fillText("Position: "+l.position.toString(),(l.position.x+10)*e.pixelDensityRatio,(l.position.y+70)*e.pixelDensityRatio),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(),m.getRotation(!0)%360!==0&&this._restoreRotationChanges(),y.restore()}_updateImageSmoothingEnabled(l){l.msImageSmoothingEnabled=this._imageSmoothingEnabled,l.imageSmoothingEnabled=this._imageSmoothingEnabled}_getCanvasSize(l){var u=this._getContext(l).canvas;return new e.Point(u.width,u.height)}_getCanvasCenter(){return new e.Point(this.canvas.width/2,this.canvas.height/2)}_setRotations(l,u=!1){var d=!1;this.viewport.getRotation(!0)%360!==0&&(this._offsetForRotation({degrees:this.viewport.getRotation(!0),useSketch:u,saveContext:d}),d=!1),l.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:l.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(l._getRotationPoint(!0),!0),useSketch:u,saveContext:d})}_offsetForRotation(l){var u=l.point?l.point.times(e.pixelDensityRatio):this._getCanvasCenter(),d=this._getContext(l.useSketch);d.save(),d.translate(u.x,u.y),d.rotate(Math.PI/180*l.degrees),d.translate(-u.x,-u.y)}_flip(l){l=l||{};var u=l.point?l.point.times(e.pixelDensityRatio):this._getCanvasCenter(),d=this._getContext(l.useSketch);d.translate(u.x,0),d.scale(-1,1),d.translate(-u.x,0)}_restoreRotationChanges(l){var u=this._getContext(l);u.restore()}_calculateCanvasSize(){var l=e.pixelDensityRatio,u=this.viewport.getContainerSize();return{x:Math.round(u.x*l),y:Math.round(u.y*l)}}_calculateSketchCanvasSize(){var l=this._calculateCanvasSize();if(this.viewport.getRotation()===0)return l;var u=Math.ceil(Math.sqrt(l.x*l.x+l.y*l.y));return{x:u,y:u}}}e.CanvasDrawer=n;var i=e.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER;function r(o){return o!==e.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS&&o!==e.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST&&o!==e.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER}function a(o){return r(o)?i:o}function s(o){if(typeof o=="number")return a(o);if(!o||!e.Browser)return i;var l=o[e.Browser.vendor];return r(l)&&(l=o["*"]),a(l)}}(x),function(e){const t=e;t.WebGLDrawer=class extends t.DrawerBase{constructor(i){super(i),this._destroyed=!1,this._TextureMap=new Map,this._TileMap=new Map,this._gl=null,this._firstPass=null,this._secondPass=null,this._glFrameBuffer=null,this._renderToTexture=null,this._glFramebufferToCanvasTransform=null,this._outputCanvas=null,this._outputContext=null,this._clippingCanvas=null,this._clippingContext=null,this._renderingCanvas=null,this._backupCanvasDrawer=null,this._boundToTileReady=r=>this._tileReadyHandler(r),this._boundToImageUnloaded=r=>this._imageUnloadedHandler(r),this.viewer.addHandler("tile-ready",this._boundToTileReady),this.viewer.addHandler("image-unloaded",this._boundToImageUnloaded),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.context=this._outputContext}destroy(){if(this._destroyed)return;let i=this._gl;var r=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS);for(let o=0;o<r;++o)i.activeTexture(i.TEXTURE0+o),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),Array.from(this._TextureMap.keys()).forEach(o=>{this._cleanupImageData(o)}),i.deleteBuffer(this._secondPass.bufferOutputPosition),i.deleteFramebuffer(this._glFrameBuffer),this._renderingCanvas.width=this._renderingCanvas.height=1,this._clippingCanvas.width=this._clippingCanvas.height=1,this._outputCanvas.width=this._outputCanvas.height=1,this._renderingCanvas=null,this._clippingCanvas=this._clippingContext=null,this._outputCanvas=this._outputContext=null;let s=i.getExtension("WEBGL_lose_context");s&&s.loseContext(),this.viewer.removeHandler("tile-ready",this._boundToTileReady),this.viewer.removeHandler("image-unloaded",this._boundToImageUnloaded),this._gl=null,this._backupCanvasDrawer&&(this._backupCanvasDrawer.destroy(),this._backupCanvasDrawer=null),this.container.removeChild(this.canvas),this.viewer.drawer===this&&(this.viewer.drawer=null),this._destroyed=!0}canRotate(){return!0}static isSupported(){let i=document.createElement("canvas"),r=e.isFunction(i.getContext)&&i.getContext("webgl"),a=r&&r.getExtension("WEBGL_lose_context");return a&&a.loseContext(),!!r}getType(){return"webgl"}minimumOverlapRequired(i){return i.isTainted()}_createDrawingElement(){let i=e.makeNeutralElement("canvas"),r=this._calculateCanvasSize();return i.width=r.x,i.height=r.y,i}_getBackupCanvasDrawer(){return this._backupCanvasDrawer||(this._backupCanvasDrawer=this.viewer.requestDrawer("canvas",{mainDrawer:!1}),this._backupCanvasDrawer.canvas.style.setProperty("visibility","hidden")),this._backupCanvasDrawer}draw(i){let r=this._gl,a={bounds:this.viewport.getBoundsNoRotate(!0),center:this.viewport.getCenter(!0),rotation:this.viewport.getRotation(!0)*Math.PI/180},s=this.viewport.flipped?-1:1,o=e.Mat3.makeTranslation(-a.center.x,-a.center.y),l=e.Mat3.makeScaling(2/a.bounds.width*s,-2/a.bounds.height),u=e.Mat3.makeRotation(-a.rotation),d=l.multiply(u).multiply(o);r.bindFramebuffer(r.FRAMEBUFFER,null),r.clear(r.COLOR_BUFFER_BIT),this._outputContext.clearRect(0,0,this._outputCanvas.width,this._outputCanvas.height);let m=!1;i.forEach((v,y)=>{if(v.isTainted()){m&&(this._outputContext.drawImage(this._renderingCanvas,0,0),r.bindFramebuffer(r.FRAMEBUFFER,null),r.clear(r.COLOR_BUFFER_BIT),m=!1);const T=this._getBackupCanvasDrawer();T.draw([v]),this._outputContext.drawImage(T.canvas,0,0)}else{let T=v.getTilesToDraw();if(v.placeholderFillStyle&&v._hasOpaqueTile===!1&&this._drawPlaceholder(v),T.length===0||v.getOpacity()===0)return;let _=T[0],S=v.compositeOperation||this.viewer.compositeOperation||v._clip||v._croppingPolygons||v.debugMode,b=S||v.opacity<1||_.hasTransparency;S&&(m&&this._outputContext.drawImage(this._renderingCanvas,0,0),r.bindFramebuffer(r.FRAMEBUFFER,null),r.clear(r.COLOR_BUFFER_BIT)),r.useProgram(this._firstPass.shaderProgram),b?(r.bindFramebuffer(r.FRAMEBUFFER,this._glFrameBuffer),r.clear(r.COLOR_BUFFER_BIT)):r.bindFramebuffer(r.FRAMEBUFFER,null);let L=d,I=v.getRotation(!0);if(I%360!==0){let W=e.Mat3.makeRotation(-I*Math.PI/180),U=v.getBoundsNoRotate(!0).getCenter(),$=e.Mat3.makeTranslation(U.x,U.y),ne=e.Mat3.makeTranslation(-U.x,-U.y),te=$.multiply(W).multiply(ne);L=d.multiply(te)}let M=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);if(M<=0)throw new Error(`WegGL error: bad value for gl parameter MAX_TEXTURE_IMAGE_UNITS (${M}). This could happen if too many contexts have been created and not released, or there is another problem with the graphics card.`);let Z=new Float32Array(M*12),V=new Array(M),j=new Array(M),J=new Array(M);for(let W=0;W<T.length;W++){let U=T[W].tile,$=W%M,ne=$+1,te=U.getCanvasContext(),se=te?this._TextureMap.get(te.canvas):null;if(se||(this._tileReadyHandler({tile:U,tiledImage:v}),se=te?this._TextureMap.get(te.canvas):null),se&&this._getTileData(U,v,se,L,$,Z,V,j,J),ne===M||W===T.length-1){for(let re=0;re<=ne;re++)r.activeTexture(r.TEXTURE0+re),r.bindTexture(r.TEXTURE_2D,V[re]);r.bindBuffer(r.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),r.bufferData(r.ARRAY_BUFFER,Z,r.DYNAMIC_DRAW),j.forEach((re,ge)=>{r.uniformMatrix3fv(this._firstPass.uTransformMatrices[ge],!1,re)}),r.uniform1fv(this._firstPass.uOpacities,new Float32Array(J)),r.bindBuffer(r.ARRAY_BUFFER,this._firstPass.bufferOutputPosition),r.vertexAttribPointer(this._firstPass.aOutputPosition,2,r.FLOAT,!1,0,0),r.bindBuffer(r.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),r.vertexAttribPointer(this._firstPass.aTexturePosition,2,r.FLOAT,!1,0,0),r.bindBuffer(r.ARRAY_BUFFER,this._firstPass.bufferIndex),r.vertexAttribPointer(this._firstPass.aIndex,1,r.FLOAT,!1,0,0),r.drawArrays(r.TRIANGLES,0,6*ne)}}b&&(r.useProgram(this._secondPass.shaderProgram),r.bindFramebuffer(r.FRAMEBUFFER,null),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this._renderToTexture),this._gl.uniform1f(this._secondPass.uOpacityMultiplier,v.opacity),r.bindBuffer(r.ARRAY_BUFFER,this._secondPass.bufferTexturePosition),r.vertexAttribPointer(this._secondPass.aTexturePosition,2,r.FLOAT,!1,0,0),r.bindBuffer(r.ARRAY_BUFFER,this._secondPass.bufferOutputPosition),r.vertexAttribPointer(this._firstPass.aOutputPosition,2,r.FLOAT,!1,0,0),r.drawArrays(r.TRIANGLES,0,6)),m=!0,S&&(this._applyContext2dPipeline(v,T,y),m=!1,r.bindFramebuffer(r.FRAMEBUFFER,null),r.clear(r.COLOR_BUFFER_BIT)),y===0&&this._raiseTiledImageDrawnEvent(v,T.map(W=>W.tile))}}),m&&this._outputContext.drawImage(this._renderingCanvas,0,0)}setImageSmoothingEnabled(i){}drawDebuggingRect(i){let r=this._outputContext;r.save(),r.lineWidth=2*e.pixelDensityRatio,r.strokeStyle=this.debugGridColor[0],r.fillStyle=this.debugGridColor[0],r.strokeRect(i.x*e.pixelDensityRatio,i.y*e.pixelDensityRatio,i.width*e.pixelDensityRatio,i.height*e.pixelDensityRatio),r.restore()}_getTextureDataFromTile(i){return i.getCanvasContext().canvas}_applyContext2dPipeline(i,r,a){if(this._outputContext.save(),this._outputContext.globalCompositeOperation=a===0?null:i.compositeOperation||this.viewer.compositeOperation,i._croppingPolygons||i._clip?(this._renderToClippingCanvas(i),this._outputContext.drawImage(this._clippingCanvas,0,0)):this._outputContext.drawImage(this._renderingCanvas,0,0),this._outputContext.restore(),i.debugMode){const s=this.viewer.viewport.getFlip();s&&this._flip(),this._drawDebugInfo(r,i,s),s&&this._flip()}}_getTileData(i,r,a,s,o,l,u,d,m){let v=a.texture,y=a.position;l.set(y,o*12);let T=this._calculateOverlapFraction(i,r),_=i.positionedBounds.width*T.x,S=i.positionedBounds.height*T.y,b=i.positionedBounds.x+(i.x===0?0:_),L=i.positionedBounds.y+(i.y===0?0:S),I=i.positionedBounds.x+i.positionedBounds.width-(i.isRightMost?0:_),M=i.positionedBounds.y+i.positionedBounds.height-(i.isBottomMost?0:S),Z=I-b,V=M-L,j=new e.Mat3([Z,0,0,0,V,0,b,L,1]);if(i.flipped){let W=e.Mat3.makeTranslation(.5,0),U=e.Mat3.makeTranslation(-.5,0),$=W.multiply(e.Mat3.makeScaling(-1,1)).multiply(U);j=j.multiply($)}let J=s.multiply(j);m[o]=i.opacity,u[o]=v,d[o]=J.values}_setupRenderer(){let i=this._gl;i||e.console.error("_setupCanvases must be called before _setupRenderer"),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,this._renderingCanvas.width,this._renderingCanvas.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),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)}_makeFirstPassShaderProgram(){let i=this._glNumTextures=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),r=()=>[...Array(i).keys()].map(v=>`uniform mat3 u_matrix_${v};`).join(` `),a=()=>[...Array(i).keys()].map(v=>`${v>0?"else ":""}if(int(a_index) == ${v}) { transform_matrix = u_matrix_${v}; }`).join(` `);const s=` attribute vec2 a_output_position; attribute vec2 a_texture_position; attribute float a_index; ${r()} // 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() ${a()} gl_Position = vec4(transform_matrix * vec3(a_output_position, 1), 1); v_texture_position = a_texture_position; v_image_index = a_index; } `,o=` precision mediump float; // our textures uniform sampler2D u_images[${i}]; // our opacities uniform float u_opacities[${i}]; // 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 < ${i}; ++i){ if(i == int(v_image_index)){ gl_FragColor = texture2D(u_images[i], v_texture_position) * u_opacities[i]; } } } `;let l=this._gl,u=this.constructor.initShaderProgram(l,s,o);l.useProgram(u),this._firstPass={shaderProgram:u,aOutputPosition:l.getAttribLocation(u,"a_output_position"),aTexturePosition:l.getAttribLocation(u,"a_texture_position"),aIndex:l.getAttribLocation(u,"a_index"),uTransformMatrices:[...Array(this._glNumTextures).keys()].map(v=>l.getUniformLocation(u,`u_matrix_${v}`)),uImages:l.getUniformLocation(u,"u_images"),uOpacities:l.getUniformLocation(u,"u_opacities"),bufferOutputPosition:l.createBuffer(),bufferTexturePosition:l.createBuffer(),bufferIndex:l.createBuffer()},l.uniform1iv(this._firstPass.uImages,[...Array(i).keys()]);let d=new Float32Array(i*12);for(let v=0;v<i;++v)d.set(Float32Array.from(this._unitQuad),v*12);l.bindBuffer(l.ARRAY_BUFFER,this._firstPass.bufferOutputPosition),l.bufferData(l.ARRAY_BUFFER,d,l.STATIC_DRAW),l.enableVertexAttribArray(this._firstPass.aOutputPosition),l.bindBuffer(l.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),l.enableVertexAttribArray(this._firstPass.aTexturePosition),l.bindBuffer(l.ARRAY_BUFFER,this._firstPass.bufferIndex);let m=[...Array(this._glNumTextures).keys()].map(v=>Array(6).fill(v)).flat();l.bufferData(l.ARRAY_BUFFER,new Float32Array(m),l.STATIC_DRAW),l.enableVertexAttribArray(this._firstPass.aIndex)}_makeSecondPassShaderProgram(){const i=` attribute vec2 a_output_position; attribute vec2 a_texture_position; uniform mat3 u_matrix; varying vec2 v_texture_position; void main() { gl_Position = vec4(u_matrix * vec3(a_output_position, 1), 1); v_texture_position = a_texture_position; } `,r=` 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; } `;let a=this._gl,s=this.constructor.initShaderProgram(a,i,r);a.useProgram(s),this._secondPass={shaderProgram:s,aOutputPosition:a.getAttribLocation(s,"a_output_position"),aTexturePosition:a.getAttribLocation(s,"a_texture_position"),uMatrix:a.getUniformLocation(s,"u_matrix"),uImage:a.getUniformLocation(s,"u_image"),uOpacityMultiplier:a.getUniformLocation(s,"u_opacity_multiplier"),bufferOutputPosition:a.createBuffer(),bufferTexturePosition:a.createBuffer()},a.bindBuffer(a.ARRAY_BUFFER,this._secondPass.bufferOutputPosition),a.bufferData(a.ARRAY_BUFFER,this._unitQuad,a.STATIC_DRAW),a.enableVertexAttribArray(this._secondPass.aOutputPosition),a.bindBuffer(a.ARRAY_BUFFER,this._secondPass.bufferTexturePosition),a.bufferData(a.ARRAY_BUFFER,this._unitQuad,a.DYNAMIC_DRAW),a.enableVertexAttribArray(this._secondPass.aTexturePosition);let o=e.Mat3.makeScaling(2,2).multiply(e.Mat3.makeTranslation(-.5,-.5));a.uniformMatrix3fv(this._secondPass.uMatrix,!1,o.values)}_resizeRenderer(){let i=this._gl,r=this._renderingCanvas.width,a=this._renderingCanvas.height;i.viewport(0,0,r,a),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,r,a,0,i.RGBA,i.UNSIGNED_BYTE,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),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)}_setupCanvases(){let i=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._gl=this._renderingCanvas.getContext("webgl"),this.viewer.addHandler("resize",function(){i._outputCanvas!==i.viewer.drawer.canvas&&(i._outputCanvas.style.width=i.viewer.drawer.canvas.clientWidth+"px",i._outputCanvas.style.height=i.viewer.drawer.canvas.clientHeight+"px");let r=i._calculateCanvasSize();(i._outputCanvas.width!==r.x||i._outputCanvas.height!==r.y)&&(i._outputCanvas.width=r.x,i._outputCanvas.height=r.y),i._renderingCanvas.style.width=i._outputCanvas.clientWidth+"px",i._renderingCanvas.style.height=i._outputCanvas.clientHeight+"px",i._renderingCanvas.width=i._clippingCanvas.width=i._outputCanvas.width,i._renderingCanvas.height=i._clippingCanvas.height=i._outputCanvas.height,i._resizeRenderer()})}_makeQuadVertexBuffer(i,r,a,s){return new Float32Array([i,s,r,s,i,a,i,a,r,s,r,a])}_tileReadyHandler(i){let r=i.tile,a=i.tiledImage;if(a.isTainted())return;let s=r.getCanvasContext(),o=s&&s.canvas;if(!o||e.isCanvasTainted(o)){a.isTainted()||(a.setTainted(!0),e.console.warn("WebGL cannot be used to draw this TiledImage because it has tainted data. Does crossOriginPolicy need to be set?"),this._raiseDrawerErrorEvent(a,"Tainted data cannot be used by the WebGLDrawer. Falling back to CanvasDrawer for this TiledImage."));return}if(!this._TextureMap.get(o)){let u=this._gl,d=u.createTexture(),m,v=a.source.tileOverlap,y,T;if(r.sourceBounds?(y=Math.min(r.sourceBounds.width,o.width)/o.width,T=Math.min(r.sourceBounds.height,o.height)/o.height):(y=1,T=1),v>0){let S=this._calculateOverlapFraction(r,a),b=(r.x===0?0:S.x)*y,L=(r.y===0?0:S.y)*T,I=(r.isRightMost?1:1-S.x)*y,M=(r.isBottomMost?1:1-S.y)*T;m=this._makeQuadVertexBuffer(b,I,L,M)}else y===1&&T===1?m=this._unitQuad:m=this._makeQuadVertexBuffer(0,y,0,T);let _={texture:d,position:m};this._TextureMap.set(o,_),u.activeTexture(u.TEXTURE0),u.bindTexture(u.TEXTURE_2D,d),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,u.LINEAR),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,u.LINEAR),this._uploadImageData(s)}}_calculateOverlapFraction(i,r){let a=r.source.tileOverlap,s=i.sourceBounds.width,o=i.sourceBounds.height,l=(i.x===0?0:a)+(i.isRightMost?0:a),u=(i.y===0?0:a)+(i.isBottomMost?0:a),d=a/(s+l),m=a/(o+u);return{x:d,y:m}}_uploadImageData(i){let r=this._gl,a=i.canvas;try{if(!a)throw i;r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,a)}catch(s){e.console.error("Error uploading image data to WebGL",s)}}_imageUnloadedHandler(i){let r=i.context2D.canvas;this._cleanupImageData(r)}_cleanupImageData(i){let r=this._TextureMap.get(i);this._TextureMap.delete(i),r&&this._gl.deleteTexture(r.texture)}_setClip(){}_renderToClippingCanvas(i){if(this._clippingContext.clearRect(0,0,this._clippingCanvas.width,this._clippingCanvas.height),this._clippingContext.save(),this.viewer.viewport.getFlip()){const r=new e.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(r.x,0),this._clippingContext.scale(-1,1),this._clippingContext.translate(-r.x,0)}if(i._clip){let a=[{x:i._clip.x,y:i._clip.y},{x:i._clip.x+i._clip.width,y:i._clip.y},{x:i._clip.x+i._clip.width,y:i._clip.y+i._clip.height},{x:i._clip.x,y:i._clip.y+i._clip.height}].map(s=>{let o=i.imageToViewportCoordinates(s.x,s.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(o)});this._clippingContext.beginPath(),a.forEach((s,o)=>{this._clippingContext[o===0?"moveTo":"lineTo"](s.x,s.y)}),this._clippingContext.clip(),this._setClip()}if(i._croppingPolygons){let r=i._croppingPolygons.map(a=>a.map(s=>{let o=i.imageToViewportCoordinates(s.x,s.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(o)}));this._clippingContext.beginPath(),r.forEach(a=>{a.forEach((s,o)=>{this._clippingContext[o===0?"moveTo":"lineTo"](s.x,s.y)})}),this._clippingContext.clip()}if(this.viewer.viewport.getFlip()){const r=new e.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(r.x,0),this._clippingContext.scale(-1,1),this._clippingContext.translate(-r.x,0)}this._clippingContext.drawImage(this._renderingCanvas,0,0),this._clippingContext.restore()}_setRotations(i){var r=!1;this.viewport.getRotation(!0)%360!==0&&(this._offsetForRotation({degrees:this.viewport.getRotation(!0),saveContext:r}),r=!1),i.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:i.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(i._getRotationPoint(!0),!0),saveContext:r})}_offsetForRotation(i){var r=i.point?i.point.times(e.pixelDensityRatio):this._getCanvasCenter(),a=this._outputContext;a.save(),a.translate(r.x,r.y),a.rotate(Math.PI/180*i.degrees),a.translate(-r.x,-r.y)}_flip(i){i=i||{};var r=i.point?i.point.times(e.pixelDensityRatio):this._getCanvasCenter(),a=this._outputContext;a.translate(r.x,0),a.scale(-1,1),a.translate(-r.x,0)}_drawDebugInfo(i,r,a){for(var s=i.length-1;s>=0;s--){var o=i[s].tile;try{this._drawDebugInfoOnTile(o,i.length,s,r,a)}catch(l){e.console.error(l)}}}_drawDebugInfoOnTile(i,r,a,s,o){var l=this.viewer.world.getIndexOfItem(s)%this.debugGridColor.length,u=this.context;u.save(),u.lineWidth=2*e.pixelDensityRatio,u.font="small-caps bold "+13*e.pixelDensityRatio+"px arial",u.strokeStyle=this.debugGridColor[l],u.fillStyle=this.debugGridColor[l],this._setRotations(s),o&&this._flip({point:i.position.plus(i.size.divide(2))}),u.strokeRect(i.position.x*e.pixelDensityRatio,i.position.y*e.pixelDensityRatio,i.size.x*e.pixelDensityRatio,i.size.y*e.pixelDensityRatio);var d=(i.position.x+i.size.x/2)*e.pixelDensityRatio,m=(i.position.y+i.size.y/2)*e.pixelDensityRatio;u.translate(d,m);const v=this.viewport.getRotation(!0);u.rotate(Math.PI/180*-v),u.translate(-d,-m),i.x===0&&i.y===0&&(u.fillText("Zoom: "+this.viewport.getZoom(),i.position.x*e.pixelDensityRatio,(i.position.y-30)*e.pixelDensityRatio),u.fillText("Pan: "+this.viewport.getBounds().toString(),i.position.x*e.pixelDensityRatio,(i.position.y-20)*e.pixelDensityRatio)),u.fillText("Level: "+i.level,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+20)*e.pixelDensityRatio),u.fillText("Column: "+i.x,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+30)*e.pixelDensityRatio),u.fillText("Row: "+i.y,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+40)*e.pixelDensityRatio),u.fillText("Order: "+a+" of "+r,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+50)*e.pixelDensityRatio),u.fillText("Size: "+i.size.toString(),(i.position.x+10)*e.pixelDensityRatio,(i.position.y+60)*e.pixelDensityRatio),u.fillText("Position: "+i.position.toString(),(i.position.x+10)*e.pixelDensityRatio,(i.position.y+70)*e.pixelDensityRatio),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(),s.getRotation(!0)%360!==0&&this._restoreRotationChanges(),u.restore()}_drawPlaceholder(i){const r=i.getBounds(!0),a=this.viewportToDrawerRectangle(i.getBounds(!0)),s=this._outputContext;let o;typeof i.placeholderFillStyle=="function"?o=i.placeholderFillStyle(i,s):o=i.placeholderFillStyle,this._offsetForRotation({degrees:this.viewer.viewport.getRotation(!0)}),s.fillStyle=o,s.translate(a.x,a.y),s.rotate(Math.PI/180*r.degrees),s.translate(-a.x,-a.y),s.fillRect(a.x,a.y,a.width,a.height),this._restoreRotationChanges()}_getCanvasCenter(){return new e.Point(this.canvas.width/2,this.canvas.height/2)}_restoreRotationChanges(){var i=this._outputContext;i.restore()}static initShaderProgram(i,r,a){function s(d,m,v){const y=d.createShader(m);return d.shaderSource(y,v),d.compileShader(y),d.getShaderParameter(y,d.COMPILE_STATUS)?y:(e.console.error(`An error occurred compiling the shaders: ${d.getShaderInfoLog(y)}`),d.deleteShader(y),null)}const o=s(i,i.VERTEX_SHADER,r),l=s(i,i.FRAGMENT_SHADER,a),u=i.createProgram();return i.attachShader(u,o),i.attachShader(u,l),i.linkProgram(u),i.getProgramParameter(u,i.LINK_STATUS)?u:(e.console.error(`Unable to initialize the shader program: ${i.getProgramInfoLog(u)}`),null)}}}(x),function(e){e.Viewport=function(t){var n=arguments;n.length&&n[0]instanceof e.Point&&(t={containerSize:n[0],contentSize:n[1],config:n[2]}),t.config&&(e.extend(!0,t,t.config),delete t.config),this._margins=e.extend({left:0,top:0,right:0,bottom:0},t.margins||{}),delete t.margins,t.initialDegrees=t.degrees,delete t.degrees,e.extend(!0,this,{containerSize:null,contentSize:null,zoomPoint:null,rotationPivot:null,viewer:null,springStiffness:e.DEFAULT_SETTINGS.springStiffness,animationTime:e.DEFAULT_SETTINGS.animationTime,minZoomImageRatio:e.DEFAULT_SETTINGS.minZoomImageRatio,maxZoomPixelRatio:e.DEFAULT_SETTINGS.maxZoomPixelRatio,visibilityRatio:e.DEFAULT_SETTINGS.visibilityRatio,wrapHorizontal:e.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:e.DEFAULT_SETTINGS.wrapVertical,defaultZoomLevel:e.DEFAULT_SETTINGS.defaultZoomLevel,minZoomLevel:e.DEFAULT_SETTINGS.minZoomLevel,maxZoomLevel:e.DEFAULT_SETTINGS.maxZoomLevel,initialDegrees:e.DEFAULT_SETTINGS.degrees,flipped:e.DEFAULT_SETTINGS.flipped,homeFillsViewer:e.DEFAULT_SETTINGS.homeFillsViewer,silenceMultiImageWarnings:e.DEFAULT_SETTINGS.silenceMultiImageWarnings},t),this._updateContainerInnerSize(),this.centerSpringX=new e.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.centerSpringY=new e.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.zoomSpring=new e.Spring({exponential:!0,initial:1,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.degreesSpring=new e.Spring({initial:t.initialDegrees,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._oldCenterX=this.centerSpringX.current.value,this._oldCenterY=this.centerSpringY.current.value,this._oldZoom=this.zoomSpring.current.value,this._oldDegrees=this.degreesSpring.current.value,this._setContentBounds(new e.Rect(0,0,1,1),1),this.goHome(!0),this.update()},e.Viewport.prototype={get degrees(){return e.console.warn("Accessing [Viewport.degrees] is deprecated. Use viewport.getRotation instead."),this.getRotation()},set degrees(t){e.console.warn("Setting [Viewport.degrees] is deprecated. Use viewport.rotateTo, viewport.rotateBy, or viewport.setRotation instead."),this.rotateTo(t)},resetContentSize:function(t){return e.console.assert(t,"[Viewport.resetContentSize] contentSize is required"),e.console.assert(t instanceof e.Point,"[Viewport.resetContentSize] contentSize must be an OpenSeadragon.Point"),e.console.assert(t.x>0,"[Viewport.resetContentSize] contentSize.x must be greater than 0"),e.console.assert(t.y>0,"[Viewport.resetContentSize] contentSize.y must be greater than 0"),this._setContentBounds(new e.Rect(0,0,1,t.y/t.x),t.x),this},setHomeBounds:function(t,n){e.console.error("[Viewport.setHomeBounds] this function is deprecated; The content bounds should not be set manually."),this._setContentBounds(t,n)},_setContentBounds:function(t,n){e.console.assert(t,"[Viewport._setContentBounds] bounds is required"),e.console.assert(t instanceof e.Rect,"[Viewport._setContentBounds] bounds must be an OpenSeadragon.Rect"),e.console.assert(t.width>0,"[Viewport._setContentBounds] bounds.width must be greater than 0"),e.console.assert(t.height>0,"[Viewport._setContentBounds] bounds.height must be greater than 0"),this._contentBoundsNoRotate=t.clone(),this._contentSizeNoRotate=this._contentBoundsNoRotate.getSize().times(n),this._contentBounds=t.rotate(this.getRotation()).getBoundingBox(),this._contentSize=this._contentBounds.getSize().times(n),this._contentAspectRatio=this._contentSize.x/this._contentSize.y,this.viewer&&this.viewer.raiseEvent("reset-size",{contentSize:this._contentSizeNoRotate.clone(),contentFactor:n,homeBounds:this._contentBoundsNoRotate.clone(),contentBounds:this._contentBounds.clone()})},getHomeZoom:function(){if(this.defaultZoomLevel)return this.defaultZoomLevel;var t=this._contentAspectRatio/this.getAspectRatio(),n;return this.homeFillsViewer?n=t>=1?t:1:n=t>=1?1:t,n/this._contentBounds.width},getHomeBounds:function(){return this.getHomeBoundsNoRotate().rotate(-this.getRotation())},getHomeBoundsNoRotate:function(){var t=this._contentBounds.getCenter(),n=1/this.getHomeZoom(),i=n/this.getAspectRatio();return new e.Rect(t.x-n/2,t.y-i/2,n,i)},goHome:function(t){return this.viewer&&this.viewer.raiseEvent("home",{immediately:t}),this.fitBounds(this.getHomeBounds(),t)},getMinZoom:function(){var t=this.getHomeZoom(),n=this.minZoomLevel?this.minZoomLevel:this.minZoomImageRatio*t;return n},getMaxZoom:function(){var t=this.maxZoomLevel;return t||(t=this._contentSize.x*this.maxZoomPixelRatio/this._containerInnerSize.x,t/=this._contentBounds.width),Math.max(t,this.getHomeZoom())},getAspectRatio:function(){return this._containerInnerSize.x/this._containerInnerSize.y},getContainerSize:function(){return new e.Point(this.containerSize.x,this.containerSize.y)},getMargins:function(){return e.extend({},this._margins)},setMargins:function(t){e.console.assert(e.type(t)==="object","[Viewport.setMargins] margins must be an object"),this._margins=e.extend({left:0,top:0,right:0,bottom:0},t),this._updateContainerInnerSize(),this.viewer&&this.viewer.forceRedraw()},getBounds:function(t){return this.getBoundsNoRotate(t).rotate(-this.getRotation(t))},getBoundsNoRotate:function(t){var n=this.getCenter(t),i=1/this.getZoom(t),r=i/this.getAspectRatio();return new e.Rect(n.x-i/2,n.y-r/2,i,r)},getBoundsWithMargins:function(t){return this.getBoundsNoRotateWithMargins(t).rotate(-this.getRotation(t),this.getCenter(t))},getBoundsNoRotateWithMargins:function(t){var n=this.getBoundsNoRotate(t),i=this._containerInnerSize.x*this.getZoom(t);return n.x-=this._margins.left/i,n.y-=this._margins.top/i,n.width+=(this._margins.left+this._margins.right)/i,n.height+=(this._margins.top+this._margins.bottom)/i,n},getCenter:function(t){var n=new e.Point(this.centerSpringX.current.value,this.centerSpringY.current.value),i=new e.Point(this.centerSpringX.target.value,this.centerSpringY.target.value),r,a,s,o,l,u,d,m;return t?n:this.zoomPoint?(r=this.pixelFromPoint(this.zoomPoint,!0),a=this.getZoom(),s=1/a,o=s/this.getAspectRatio(),l=new e.Rect(n.x-s/2,n.y-o/2,s,o),u=this._pixelFromPoint(this.zoomPoint,l),d=u.minus(r).rotate(-this.getRotation(!0)),m=d.divide(this._containerInnerSize.x*a),i.plus(m)):i},getZoom:function(t){return t?this.zoomSpring.current.value:this.zoomSpring.target.value},_applyZoomConstraints:function(t){return Math.max(Math.min(t,this.getMaxZoom()),this.getMinZoom())},_applyBoundaryConstraints:function(t){var n=this.viewportToViewerElementRectangle(t).getBoundingBox(),i=this.viewportToViewerElementRectangle(this._contentBoundsNoRotate).getBoundingBox(),r=!1,a=!1;if(!this.wrapHorizontal){var s=n.x+n.width,o=i.x+i.width,l,u,d;n.width>i.width?l=this.visibilityRatio*i.width:l=this.visibilityRatio*n.width,u=i.x-s+l,d=o-n.x-l,l>i.width?(n.x+=(u+d)/2,r=!0):d<0?(n.x+=d,r=!0):u>0&&(n.x+=u,r=!0)}if(!this.wrapVertical){var m=n.y+n.height,v=i.y+i.height,y,T,_;n.height>i.height?y=this.visibilityRatio*i.height:y=this.visibilityRatio*n.height,T=i.y-m+y,_=v-n.y-y,y>i.height?(n.y+=(T+_)/2,a=!0):_<0?(n.y+=_,a=!0):T>0&&(n.y+=T,a=!0)}var S=r||a,b=S?this.viewerElementToViewportRectangle(n):t.clone();return b.xConstrained=r,b.yConstrained=a,b.constraintApplied=S,b},_raiseConstraintsEvent:function(t){this.viewer&&this.viewer.raiseEvent("constrain",{immediately:t})},applyConstraints:function(t){var n=this.getZoom(),i=this._applyZoomConstraints(n);n!==i&&this.zoomTo(i,this.zoomPoint,t);var r=this.getConstrainedBounds(!1);return r.constraintApplied&&(this.fitBounds(r,t),this._raiseConstraintsEvent(t)),this},ensureVisible:function(t){return this.applyConstraints(t)},_fitBounds:function(t,n){n=n||{};var i=n.immediately||!1,r=n.constraints||!1,a=this.getAspectRatio(),s=t.getCenter(),o=new e.Rect(t.x,t.y,t.width,t.height,t.degrees+this.getRotation()).getBoundingBox();o.getAspectRatio()>=a?o.height=o.width/a:o.width=o.height*a,o.x=s.x-o.width/2,o.y=s.y-o.height/2;var l=1/o.width;if(i)return this.panTo(s,!0),this.zoomTo(l,null,!0),r&&this.applyConstraints(!0),this;var u=this.getCenter(!0),d=this.getZoom(!0);this.panTo(u,!0),this.zoomTo(d,null,!0);var m=this.getBounds(),v=this.getZoom();if(v===0||Math.abs(l/v-1)<1e-8)return this.zoomTo(l,null,!0),this.panTo(s,i),r&&this.applyConstraints(!1),this;if(r){this.panTo(s,!1),l=this._applyZoomConstraints(l),this.zoomTo(l,null,!1);var y=this.getConstrainedBounds();this.panTo(u,!0),this.zoomTo(d,null,!0),this.fitBounds(y)}else{var T=o.rotate(-this.getRotation()),_=T.getTopLeft().times(l).minus(m.getTopLeft().times(v)).divide(l-v);this.zoomTo(l,_,i)}return this},fitBounds:function(t,n){return this._fitBounds(t,{immediately:n,constraints:!1})},fitBoundsWithConstraints:function(t,n){return this._fitBounds(t,{immediately:n,constraints:!0})},fitVertically:function(t){var n=new e.Rect(this._contentBounds.x+this._contentBounds.width/2,this._contentBounds.y,0,this._contentBounds.height);return this.fitBounds(n,t)},fitHorizontally:function(t){var n=new e.Rect(this._contentBounds.x,this._contentBounds.y+this._contentBounds.height/2,this._contentBounds.width,0);return this.fitBounds(n,t)},getConstrainedBounds:function(t){var n,i;return n=this.getBounds(t),i=this._applyBoundaryConstraints(n),i},panBy:function(t,n){var i=new e.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return this.panTo(i.plus(t),n)},panTo:function(t,n){return n?(this.centerSpringX.resetTo(t.x),this.centerSpringY.resetTo(t.y)):(this.centerSpringX.springTo(t.x),this.centerSpringY.springTo(t.y)),this.viewer&&this.viewer.raiseEvent("pan",{center:t,immediately:n}),this},zoomBy:function(t,n,i){return this.zoomTo(this.zoomSpring.target.value*t,n,i)},zoomTo:function(t,n,i){var r=this;return this.zoomPoint=n instanceof e.Point&&!isNaN(n.x)&&!isNaN(n.y)?n:null,i?this._adjustCenterSpringsForZoomPoint(function(){r.zoomSpring.resetTo(t)}):this.zoomSpring.springTo(t),this.viewer&&this.viewer.raiseEvent("zoom",{zoom:t,refPoint:n,immediately:i}),this},setRotation:function(t,n){return this.rotateTo(t,null,n)},getRotation:function(t){return t?this.degreesSpring.current.value:this.degreesSpring.target.value},setRotationWithPivot:function(t,n,i){return this.rotateTo(t,n,i)},rotateTo:function(t,n,i){if(!this.viewer||!this.viewer.drawer.canRotate())return this;if(this.degreesSpring.target.value===t&&this.degreesSpring.isAtTargetValue())return this;if(this.rotationPivot=n instanceof e.Point&&!isNaN(n.x)&&!isNaN(n.y)?n:null,i)if(this.rotationPivot){var r=t-this._oldDegrees;if(!r)return this.rotationPivot=null,this;this._rotateAboutPivot(t)}else this.degreesSpring.resetTo(t);else{var a=e.positiveModulo(this.degreesSpring.current.value,360),s=e.positiveModulo(t,360),o=s-a;o>180?s-=360:o<-180&&(s+=360);var l=a-s;this.degreesSpring.resetTo(t+l),this.degreesSpring.springTo(t)}return this._setContentBounds(this.viewer.world.getHomeBounds(),this.viewer.world.getContentFactor()),this.viewer.forceRedraw(),this.viewer.raiseEvent("rotate",{degrees:t,immediately:!!i,pivot:this.rotationPivot||this.getCenter()}),this},rotateBy:function(t,n,i){return this.rotateTo(this.degreesSpring.target.value+t,n,i)},resize:function(t,n){var i=this.getBoundsNoRotate(),r=i,a;this.containerSize.x=t.x,this.containerSize.y=t.y,this._updateContainerInnerSize(),n&&(a=t.x/this.containerSize.x,r.width=i.width*a,r.height=r.width/this.getAspectRatio()),this.viewer&&this.viewer.raiseEvent("resize",{newContainerSize:t,maintain:n});var s=this.fitBounds(r,!0);return this.viewer&&this.viewer.raiseEvent("after-resize",{newContainerSize:t,maintain:n}),s},_updateContainerInnerSize:function(){this._containerInnerSize=new e.Point(Math.max(1,this.containerSize.x-(this._margins.left+this._margins.right)),Math.max(1,this.containerSize.y-(this._margins.top+this._margins.bottom)))},update:function(){var t=this;this._adjustCenterSpringsForZoomPoint(function(){t.zoomSpring.update()}),this.degreesSpring.isAtTargetValue()&&(this.rotationPivot=null),this.centerSpringX.update(),this.centerSpringY.update(),this.rotationPivot?this._rotateAboutPivot(!0):this.degreesSpring.update();var n=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._oldCenterX=this.centerSpringX.current.value,this._oldCenterY=this.centerSpringY.current.value,this._oldZoom=this.zoomSpring.current.value,this._oldDegrees=this.degreesSpring.current.value;var i=n||!this.zoomSpring.isAtTargetValue()||!this.centerSpringX.isAtTargetValue()||!this.centerSpringY.isAtTargetValue()||!this.degreesSpring.isAtTargetValue();return i},_rotateAboutPivot:function(t){var n=t===!0,i=this.rotationPivot.minus(this.getCenter());this.centerSpringX.shiftBy(i.x),this.centerSpringY.shiftBy(i.y),n?this.degreesSpring.update():this.degreesSpring.resetTo(t);var r=this.degreesSpring.current.value-this._oldDegrees,a=i.rotate(r*-1).times(-1);this.centerSpringX.shiftBy(a.x),this.centerSpringY.shiftBy(a.y)},_adjustCenterSpringsForZoomPoint:function(t){if(this.zoomPoint){var n=this.pixelFromPoint(this.zoomPoint,!0);t();var i=this.pixelFromPoint(this.zoomPoint,!0),r=i.minus(n),a=this.deltaPointsFromPixels(r,!0);this.centerSpringX.shiftBy(a.x),this.centerSpringY.shiftBy(a.y),this.zoomSpring.isAtTargetValue()&&(this.zoomPoint=null)}else t()},deltaPixelsFromPointsNoRotate:function(t,n){return t.times(this._containerInnerSize.x*this.getZoom(n))},deltaPixelsFromPoints:function(t,n){return this.deltaPixelsFromPointsNoRotate(t.rotate(this.getRotation(n)),n)},deltaPointsFromPixelsNoRotate:function(t,n){return t.divide(this._containerInnerSize.x*this.getZoom(n))},deltaPointsFromPixels:function(t,n){return this.deltaPointsFromPixelsNoRotate(t,n).rotate(-this.getRotation(n))},pixelFromPointNoRotate:function(t,n){return this._pixelFromPointNoRotate(t,this.getBoundsNoRotate(n))},pixelFromPoint:function(t,n){return this._pixelFromPoint(t,this.getBoundsNoRotate(n))},_pixelFromPointNoRotate:function(t,n){return t.minus(n.getTopLeft()).times(this._containerInnerSize.x/n.width).plus(new e.Point(this._margins.left,this._margins.top))},_pixelFromPoint:function(t,n){return this._pixelFromPointNoRotate(t.rotate(this.getRotation(!0),this.getCenter(!0)),n)},pointFromPixelNoRotate:function(t,n){var i=this.getBoundsNoRotate(n);return t.minus(new e.Point(this._margins.left,this._margins.top)).divide(this._containerInnerSize.x/i.width).plus(i.getTopLeft())},pointFromPixel:function(t,n){return this.pointFromPixelNoRotate(t,n).rotate(-this.getRotation(n),this.getCenter(n))},_viewportToImageDelta:function(t,n){var i=this._contentBoundsNoRotate.width;return new e.Point(t*this._contentSizeNoRotate.x/i,n*this._contentSizeNoRotate.x/i)},viewportToImageCoordinates:function(t,n){if(t instanceof e.Point)return this.viewportToImageCoordinates(t.x,t.y);if(this.viewer){var i=this.viewer.world.getItemCount();if(i>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageCoordinates] is not accurate with multi-image; use TiledImage.viewportToImageCoordinates instead.");else if(i===1){var r=this.viewer.world.getItemAt(0);return r.viewportToImageCoordinates(t,n,!0)}}return this._viewportToImageDelta(t-this._contentBoundsNoRotate.x,n-this._contentBoundsNoRotate.y)},_imageToViewportDelta:function(t,n){var i=this._contentBoundsNoRotate.width;return new e.Point(t/this._contentSizeNoRotate.x*i,n/this._contentSizeNoRotate.x*i)},imageToViewportCoordinates:function(t,n){if(t instanceof e.Point)return this.imageToViewportCoordinates(t.x,t.y);if(this.viewer){var i=this.viewer.world.getItemCount();if(i>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.imageToViewportCoordinates] is not accurate with multi-image; use TiledImage.imageToViewportCoordinates instead.");else if(i===1){var r=this.viewer.world.getItemAt(0);return r.imageToViewportCoordinates(t,n,!0)}}var a=this._imageToViewportDelta(t,n);return a.x+=this._contentBoundsNoRotate.x,a.y+=this._contentBoundsNoRotate.y,a},imageToViewportRectangle:function(t,n,i,r){var a=t;if(a instanceof e.Rect||(a=new e.Rect(t,n,i,r)),this.viewer){var s=this.viewer.world.getItemCount();if(s>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.imageToViewportRectangle] is not accurate with multi-image; use TiledImage.imageToViewportRectangle instead.");else if(s===1){var o=this.viewer.world.getItemAt(0);return o.imageToViewportRectangle(t,n,i,r,!0)}}var l=this.imageToViewportCoordinates(a.x,a.y),u=this._imageToViewportDelta(a.width,a.height);return new e.Rect(l.x,l.y,u.x,u.y,a.degrees)},viewportToImageRectangle:function(t,n,i,r){var a=t;if(a instanceof e.Rect||(a=new e.Rect(t,n,i,r)),this.viewer){var s=this.viewer.world.getItemCount();if(s>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageRectangle] is not accurate with multi-image; use TiledImage.viewportToImageRectangle instead.");else if(s===1){var o=this.viewer.world.getItemAt(0);return o.viewportToImageRectangle(t,n,i,r,!0)}}var l=this.viewportToImageCoordinates(a.x,a.y),u=this._viewportToImageDelta(a.width,a.height);return new e.Rect(l.x,l.y,u.x,u.y,a.degrees)},viewerElementToImageCoordinates:function(t){var n=this.pointFromPixel(t,!0);return this.viewportToImageCoordinates(n)},imageToViewerElementCoordinates:function(t){var n=this.imageToViewportCoordinates(t);return this.pixelFromPoint(n,!0)},windowToImageCoordinates:function(t){e.console.assert(this.viewer,"[Viewport.windowToImageCoordinates] the viewport must have a viewer.");var n=t.minus(e.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(n)},imageToWindowCoordinates:function(t){e.console.assert(this.viewer,"[Viewport.imageToWindowCoordinates] the viewport must have a viewer.");var n=this.imageToViewerElementCoordinates(t);return n.plus(e.getElementPosition(this.viewer.element))},viewerElementToViewportCoordinates:function(t){return this.pointFromPixel(t,!0)},viewportToViewerElementCoordinates:function(t){return this.pixelFromPoint(t,!0)},viewerElementToViewportRectangle:function(t){return e.Rect.fromSummits(this.pointFromPixel(t.getTopLeft(),!0),this.pointFromPixel(t.getTopRight(),!0),this.pointFromPixel(t.getBottomLeft(),!0))},viewportToViewerElementRectangle:function(t){return e.Rect.fromSummits(this.pixelFromPoint(t.getTopLeft(),!0),this.pixelFromPoint(t.getTopRight(),!0),this.pixelFromPoint(t.getBottomLeft(),!0))},windowToViewportCoordinates:function(t){e.console.assert(this.viewer,"[Viewport.windowToViewportCoordinates] the viewport must have a viewer.");var n=t.minus(e.getElementPosition(this.viewer.element));return this.viewerElementToViewportCoordinates(n)},viewportToWindowCoordinates:function(t){e.console.assert(this.viewer,"[Viewport.viewportToWindowCoordinates] the viewport must have a viewer.");var n=this.viewportToViewerElementCoordinates(t);return n.plus(e.getElementPosition(this.viewer.element))},viewportToImageZoom:function(t){if(this.viewer){var n=this.viewer.world.getItemCount();if(n>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageZoom] is not accurate with multi-image.");else if(n===1){var i=this.viewer.world.getItemAt(0);return i.viewportToImageZoom(t)}}var r=this._contentSizeNoRotate.x,a=this._containerInnerSize.x,s=this._contentBoundsNoRotate.width,o=a/r*s;return t*o},imageToViewportZoom:function(t){if(this.viewer){var n=this.viewer.world.getItemCount();if(n>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.imageToViewportZoom] is not accurate with multi-image. Instead, use [TiledImage.imageToViewportZoom] for the specific image of interest");else if(n===1){var i=this.viewer.world.getItemAt(0);return i.imageToViewportZoom(t)}}var r=this._contentSizeNoRotate.x,a=this._containerInnerSize.x,s=this._contentBoundsNoRotate.width,o=r/a/s;return t*o},toggleFlip:function(){return this.setFlip(!this.getFlip()),this},getFlip:function(){return this.flipped},setFlip:function(t){return this.flipped===t?this:(this.flipped=t,this.viewer.navigator&&this.viewer.navigator.setFlip(this.getFlip()),this.viewer.forceRedraw(),this.viewer.raiseEvent("flip",{flipped:t}),this)},getMaxZoomPixelRatio:function(){return this.maxZoomPixelRatio},setMaxZoomPixelRatio:function(t,n=!0,i=!1){e.console.assert(!isNaN(t),"[Viewport.setMaxZoomPixelRatio] ratio must be a number"),!isNaN(t)&&(this.maxZoomPixelRatio=t,n&&this.getZoom()>this.getMaxZoom()&&this.applyConstraints(i))}}}(x),function(e){e.TiledImage=function(t){this._initialized=!1,e.console.assert(t.tileCache,"[TiledImage] options.tileCache is required"),e.console.assert(t.drawer,"[TiledImage] options.drawer is required"),e.console.assert(t.viewer,"[TiledImage] options.viewer is required"),e.console.assert(t.imageLoader,"[TiledImage] options.imageLoader is required"),e.console.assert(t.source,"[TiledImage] options.source is required"),e.console.assert(!t.clip||t.clip instanceof e.Rect,"[TiledImage] options.clip must be an OpenSeadragon.Rect if present"),e.EventSource.call(this),this._tileCache=t.tileCache,delete t.tileCache,this._drawer=t.drawer,delete t.drawer,this._imageLoader=t.imageLoader,delete t.imageLoader,t.clip instanceof e.Rect&&(this._clip=t.clip.clone()),delete t.clip;var n=t.x||0;delete t.x;var i=t.y||0;delete t.y,this.normHeight=t.source.dimensions.y/t.source.dimensions.x,this.contentAspectX=t.source.dimensions.x/t.source.dimensions.y;var r=1;t.width?(r=t.width,delete t.width,t.height&&(e.console.error("specifying both width and height to a tiledImage is not supported"),delete t.height)):t.height&&(r=t.height/this.normHeight,delete t.height);var a=t.fitBounds;delete t.fitBounds;var s=t.fitBoundsPlacement||x.Placement.CENTER;delete t.fitBoundsPlacement;var o=t.degrees||0;delete t.degrees;var l=t.ajaxHeaders;delete t.ajaxHeaders,e.extend(!0,this,{viewer:null,tilesMatrix:{},coverage:{},loadingCoverage:{},lastDrawn:[],lastResetTime:0,_needsDraw:!0,_needsUpdate:!0,_hasOpaqueTile:!1,_tilesLoading:0,_tilesToDraw:[],_lastDrawn:[],_isBlending:!1,_wasBlending:!1,_isTainted:!1,springStiffness:e.DEFAULT_SETTINGS.springStiffness,animationTime:e.DEFAULT_SETTINGS.animationTime,minZoomImageRatio:e.DEFAULT_SETTINGS.minZoomImageRatio,wrapHorizontal:e.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:e.DEFAULT_SETTINGS.wrapVertical,immediateRender:e.DEFAULT_SETTINGS.immediateRender,blendTime:e.DEFAULT_SETTINGS.blendTime,alwaysBlend:e.DEFAULT_SETTINGS.alwaysBlend,minPixelRatio:e.DEFAULT_SETTINGS.minPixelRatio,smoothTileEdgesMinZoom:e.DEFAULT_SETTINGS.smoothTileEdgesMinZoom,iOSDevice:e.DEFAULT_SETTINGS.iOSDevice,debugMode:e.DEFAULT_SETTINGS.debugMode,crossOriginPolicy:e.DEFAULT_SETTINGS.crossOriginPolicy,ajaxWithCredentials:e.DEFAULT_SETTINGS.ajaxWithCredentials,placeholderFillStyle:e.DEFAULT_SETTINGS.placeholderFillStyle,opacity:e.DEFAULT_SETTINGS.opacity,preload:e.DEFAULT_SETTINGS.preload,compositeOperation:e.DEFAULT_SETTINGS.compositeOperation,subPixelRoundingForTransparency:e.DEFAULT_SETTINGS.subPixelRoundingForTransparency,maxTilesPerFrame:e.DEFAULT_SETTINGS.maxTilesPerFrame},t),this._preload=this.preload,delete this.preload,this._fullyLoaded=!1,this._xSpring=new e.Spring({initial:n,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._ySpring=new e.Spring({initial:i,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._scaleSpring=new e.Spring({initial:r,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._degreesSpring=new e.Spring({initial:o,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._updateForScale(),a&&this.fitBounds(a,s,!0),this._ownAjaxHeaders={},this.setAjaxHeaders(l,!1),this._initialized=!0},e.extend(e.TiledImage.prototype,e.EventSource.prototype,{needsDraw:function(){return this._needsDraw},redraw:function(){this._needsDraw=!0},getFullyLoaded:function(){return this._fullyLoaded},_setFullyLoaded:function(t){t!==this._fullyLoaded&&(this._fullyLoaded=t,this.raiseEvent("fully-loaded-change",{fullyLoaded:this._fullyLoaded}))},reset:function(){this._tileCache.clearTilesFor(this),this.lastResetTime=e.now(),this._needsDraw=!0},update:function(t){let n=this._xSpring.update(),i=this._ySpring.update(),r=this._scaleSpring.update(),a=this._degreesSpring.update(),s=n||i||r||a||this._needsUpdate;if(s||t||!this._fullyLoaded){let o=this._updateLevelsForViewport();this._setFullyLoaded(o)}return this._needsUpdate=!1,s?(this._updateForScale(),this._raiseBoundsChange(),this._needsDraw=!0,!0):!1},setDrawn:function(){return this._needsDraw=this._isBlending||this._wasBlending,this._needsDraw},setTainted(t){this._isTainted=t},isTainted(){return this._isTainted},destroy:function(){this.reset(),this.source.destroy&&this.source.destroy(this.viewer)},getBounds:function(t){return this.getBoundsNoRotate(t).rotate(this.getRotation(t),this._getRotationPoint(t))},getBoundsNoRotate:function(t){return t?new e.Rect(this._xSpring.current.value,this._ySpring.current.value,this._worldWidthCurrent,this._worldHeightCurrent):new e.Rect(this._xSpring.target.value,this._ySpring.target.value,this._worldWidthTarget,this._worldHeightTarget)},getWorldBounds:function(){return e.console.error("[TiledImage.getWorldBounds] is deprecated; use TiledImage.getBounds instead"),this.getBounds()},getClippedBounds:function(t){var n=this.getBoundsNoRotate(t);if(this._clip){var i=t?this._worldWidthCurrent:this._worldWidthTarget,r=i/this.source.dimensions.x,a=this._clip.times(r);n=new e.Rect(n.x+a.x,n.y+a.y,a.width,a.height)}return n.rotate(this.getRotation(t),this._getRotationPoint(t))},getTileBounds:function(t,n,i){var r=this.source.getNumTiles(t),a=(r.x+n%r.x)%r.x,s=(r.y+i%r.y)%r.y,o=this.source.getTileBounds(t,a,s);return this.getFlip()&&(o.x=Math.max(0,1-o.x-o.width)),o.x+=(n-a)/r.x,o.y+=this._worldHeightCurrent/this._worldWidthCurrent*((i-s)/r.y),o},getContentSize:function(){return new e.Point(this.source.dimensions.x,this.source.dimensions.y)},getSizeInWindowCoordinates:function(){var t=this.imageToWindowCoordinates(new e.Point(0,0)),n=this.imageToWindowCoordinates(this.getContentSize());return new e.Point(n.x-t.x,n.y-t.y)},_viewportToImageDelta:function(t,n,i){var r=i?this._scaleSpring.current.value:this._scaleSpring.target.value;return new e.Point(t*(this.source.dimensions.x/r),n*(this.source.dimensions.y*this.contentAspectX/r))},viewportToImageCoordinates:function(t,n,i){var r;return t instanceof e.Point?(i=n,r=t):r=new e.Point(t,n),r=r.rotate(-this.getRotation(i),this._getRotationPoint(i)),i?this._viewportToImageDelta(r.x-this._xSpring.current.value,r.y-this._ySpring.current.value):this._viewportToImageDelta(r.x-this._xSpring.target.value,r.y-this._ySpring.target.value)},_imageToViewportDelta:function(t,n,i){var r=i?this._scaleSpring.current.value:this._scaleSpring.target.value;return new e.Point(t/this.source.dimensions.x*r,n/this.source.dimensions.y/this.contentAspectX*r)},imageToViewportCoordinates:function(t,n,i){t instanceof e.Point&&(i=n,n=t.y,t=t.x);var r=this._imageToViewportDelta(t,n,i);return i?(r.x+=this._xSpring.current.value,r.y+=this._ySpring.current.value):(r.x+=this._xSpring.target.value,r.y+=this._ySpring.target.value),r.rotate(this.getRotation(i),this._getRotationPoint(i))},imageToViewportRectangle:function(t,n,i,r,a){var s=t;s instanceof e.Rect?a=n:s=new e.Rect(t,n,i,r);var o=this.imageToViewportCoordinates(s.getTopLeft(),a),l=this._imageToViewportDelta(s.width,s.height,a);return new e.Rect(o.x,o.y,l.x,l.y,s.degrees+this.getRotation(a))},viewportToImageRectangle:function(t,n,i,r,a){var s=t;t instanceof e.Rect?a=n:s=new e.Rect(t,n,i,r);var o=this.viewportToImageCoordinates(s.getTopLeft(),a),l=this._viewportToImageDelta(s.width,s.height,a);return new e.Rect(o.x,o.y,l.x,l.y,s.degrees-this.getRotation(a))},viewerElementToImageCoordinates:function(t){var n=this.viewport.pointFromPixel(t,!0);return this.viewportToImageCoordinates(n)},imageToViewerElementCoordinates:function(t){var n=this.imageToViewportCoordinates(t);return this.viewport.pixelFromPoint(n,!0)},windowToImageCoordinates:function(t){var n=t.minus(x.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(n)},imageToWindowCoordinates:function(t){var n=this.imageToViewerElementCoordinates(t);return n.plus(x.getElementPosition(this.viewer.element))},_viewportToTiledImageRectangle:function(t){var n=this._scaleSpring.current.value;return t=t.rotate(-this.getRotation(!0),this._getRotationPoint(!0)),new e.Rect((t.x-this._xSpring.current.value)/n,(t.y-this._ySpring.current.value)/n,t.width/n,t.height/n,t.degrees)},viewportToImageZoom:function(t){var n=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return n*t},imageToViewportZoom:function(t){var n=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return t/n},setPosition:function(t,n){var i=this._xSpring.target.value===t.x&&this._ySpring.target.value===t.y;if(n){if(i&&this._xSpring.current.value===t.x&&this._ySpring.current.value===t.y)return;this._xSpring.resetTo(t.x),this._ySpring.resetTo(t.y),this._needsDraw=!0,this._needsUpdate=!0}else{if(i)return;this._xSpring.springTo(t.x),this._ySpring.springTo(t.y),this._needsDraw=!0,this._needsUpdate=!0}i||this._raiseBoundsChange()},setWidth:function(t,n){this._setScale(t,n)},setHeight:function(t,n){this._setScale(t/this.normHeight,n)},setCroppingPolygons:function(t){var n=function(r){return r instanceof e.Point||typeof r.x=="number"&&typeof r.y=="number"},i=function(r){return r.map(function(a){try{if(n(a))return{x:a.x,y:a.y};throw new Error}catch{throw new Error("A Provided cropping polygon point is not supported")}})};try{if(!e.isArray(t))throw new Error("Provided cropping polygon is not an array");this._croppingPolygons=t.map(function(r){return i(r)}),this._needsDraw=!0}catch(r){e.console.error("[TiledImage.setCroppingPolygons] Cropping polygon format not supported"),e.console.error(r),this.resetCroppingPolygons()}},resetCroppingPolygons:function(){this._croppingPolygons=null,this._needsDraw=!0},fitBounds:function(t,n,i){n=n||e.Placement.CENTER;var r=e.Placement.properties[n],a=this.contentAspectX,s=0,o=0,l=1,u=1;if(this._clip&&(a=this._clip.getAspectRatio(),l=this._clip.width/this.source.dimensions.x,u=this._clip.height/this.source.dimensions.y,t.getAspectRatio()>a?(s=this._clip.x/this._clip.height*t.height,o=this._clip.y/this._clip.height*t.height):(s=this._clip.x/this._clip.width*t.width,o=this._clip.y/this._clip.width*t.width)),t.getAspectRatio()>a){var d=t.height/u,m=0;r.isHorizontallyCentered?m=(t.width-t.height*a)/2:r.isRight&&(m=t.width-t.height*a),this.setPosition(new e.Point(t.x-s+m,t.y-o),i),this.setHeight(d,i)}else{var v=t.width/l,y=0;r.isVerticallyCentered?y=(t.height-t.width/a)/2:r.isBottom&&(y=t.height-t.width/a),this.setPosition(new e.Point(t.x-s,t.y-o+y),i),this.setWidth(v,i)}},getClip:function(){return this._clip?this._clip.clone():null},setClip:function(t){e.console.assert(!t||t instanceof e.Rect,"[TiledImage.setClip] newClip must be an OpenSeadragon.Rect or null"),t instanceof e.Rect?this._clip=t.clone():this._clip=null,this._needsDraw=!0,this.raiseEvent("clip-change")},getFlip:function(){return this.flipped},setFlip:function(t){this.flipped=t},get flipped(){return this._flipped},set flipped(t){let n=this._flipped!==!!t;this._flipped=!!t,n&&(this.update(!0),this._needsDraw=!0,this._raiseBoundsChange())},get wrapHorizontal(){return this._wrapHorizontal},set wrapHorizontal(t){let n=this._wrapHorizontal!==!!t;this._wrapHorizontal=!!t,this._initialized&&n&&(this.update(!0),this._needsDraw=!0)},get wrapVertical(){return this._wrapVertical},set wrapVertical(t){let n=this._wrapVertical!==!!t;this._wrapVertical=!!t,this._initialized&&n&&(this.update(!0),this._needsDraw=!0)},get debugMode(){return this._debugMode},set debugMode(t){this._debugMode=!!t,this._needsDraw=!0},getOpacity:function(){return this.opacity},setOpacity:function(t){this.opacity=t},get opacity(){return this._opacity},set opacity(t){t!==this.opacity&&(this._opacity=t,this._needsDraw=!0,this.raiseEvent("opacity-change",{opacity:this.opacity}))},getPreload:function(){return this._preload},setPreload:function(t){this._preload=!!t,this._needsDraw=!0},getRotation:function(t){return t?this._degreesSpring.current.value:this._degreesSpring.target.value},setRotation:function(t,n){this._degreesSpring.target.value===t&&this._degreesSpring.isAtTargetValue()||(n?this._degreesSpring.resetTo(t):this._degreesSpring.springTo(t),this._needsDraw=!0,this._needsUpdate=!0,this._raiseBoundsChange())},getDrawArea:function(){if(this._opacity===0&&!this._preload)return!1;var t=this._viewportToTiledImageRectangle(this.viewport.getBoundsWithMargins(!0));if(!this.wrapHorizontal&&!this.wrapVertical){var n=this._viewportToTiledImageRectangle(this.getClippedBounds(!0));t=t.intersection(n)}return t},getTilesToDraw:function(){let t=this._tilesToDraw.flat();return this._updateTilesInViewport(t),t=this._tilesToDraw.flat(),t.forEach(n=>{n.tile.beingDrawn=!0}),this._lastDrawn=t,t},_getRotationPoint:function(t){return this.getBoundsNoRotate(t).getCenter()},get compositeOperation(){return this._compositeOperation},set compositeOperation(t){t!==this._compositeOperation&&(this._compositeOperation=t,this._needsDraw=!0,this.raiseEvent("composite-operation-change",{compositeOperation:this._compositeOperation}))},getCompositeOperation:function(){return this._compositeOperation},setCompositeOperation:function(t){this.compositeOperation=t},setAjaxHeaders:function(t,n){if(t===null&&(t={}),!e.isPlainObject(t)){console.error("[TiledImage.setAjaxHeaders] Ignoring invalid headers, must be a plain object");return}this._ownAjaxHeaders=t,this._updateAjaxHeaders(n)},_updateAjaxHeaders:function(t){if(t===void 0&&(t=!0),e.isPlainObject(this.viewer.ajaxHeaders)?this.ajaxHeaders=e.extend({},this.viewer.ajaxHeaders,this._ownAjaxHeaders):this.ajaxHeaders=this._ownAjaxHeaders,t){var n,i,r,a;for(var s in this.tilesMatrix){n=this.source.getNumTiles(s);for(var o in this.tilesMatrix[s]){i=(n.x+o%n.x)%n.x;for(var l in this.tilesMatrix[s][o])if(r=(n.y+l%n.y)%n.y,a=this.tilesMatrix[s][o][l],a.loadWithAjax=this.loadTilesWithAjax,a.loadWithAjax){var u=this.source.getTileAjaxHeaders(s,i,r);a.ajaxHeaders=e.extend({},this.ajaxHeaders,u)}else a.ajaxHeaders=null}}for(var d=0;d<this._imageLoader.jobQueue.length;d++){var m=this._imageLoader.jobQueue[d];m.loadWithAjax=m.tile.loadWithAjax,m.ajaxHeaders=m.tile.loadWithAjax?m.tile.ajaxHeaders:null}}},_setScale:function(t,n){var i=this._scaleSpring.target.value===t;if(n){if(i&&this._scaleSpring.current.value===t)return;this._scaleSpring.resetTo(t),this._updateForScale(),this._needsDraw=!0,this._needsUpdate=!0}else{if(i)return;this._scaleSpring.springTo(t),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 t=Math.max(this.source.minLevel,Math.floor(Math.log(this.minZoomImageRatio)/Math.log(2))),n=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(0),!0).x*this._scaleSpring.current.value,i=Math.min(Math.abs(this.source.maxLevel),Math.abs(Math.floor(Math.log(n/this.minPixelRatio)/Math.log(2))));return i=Math.max(i,this.source.minLevel||0),t=Math.min(t,i),{lowestLevel:t,highestLevel:i}},_updateLevelsForViewport:function(){var t=this._getLevelsInterval(),n=t.lowestLevel,i=t.highestLevel,r=[],a=this.getDrawArea(),s=e.now();if(this._lastDrawn.forEach(I=>{I.tile.beingDrawn=!1}),this._tilesToDraw=[],this._tilesLoading=0,this.loadingCoverage={},!a)return this._needsDraw=!1,this._fullyLoaded;var o=new Array(i-n+1);for(let I=0,M=i;M>=n;M--,I++)o[I]=M;for(let I=i+1;I<=this.source.maxLevel;I++){var l=this.tilesMatrix[I]&&this.tilesMatrix[I][0]&&this.tilesMatrix[I][0][0];if(l&&l.isBottomMost&&l.isRightMost&&l.loaded){o.push(I);break}}let u=!1;for(let I=0;I<o.length;I++){let M=o[I];var d=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(M),!0).x*this._scaleSpring.current.value;if(I===o.length-1||d>=this.minPixelRatio)u=!0;else if(!u)continue;var m=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(M),!1).x*this._scaleSpring.current.value,v=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(Math.max(this.source.getClosestLevel(),0)),!1).x*this._scaleSpring.current.value,y=this.immediateRender?1:v,T=Math.min(1,(d-.5)/.5),_=y/Math.abs(y-m),S=this._updateLevel(M,T,_,a,s,r);r=S.bestTiles;var b=S.updatedTiles.filter(Z=>Z.loaded),L=function(Z,V,j){return function(J){return{tile:J,level:Z,levelOpacity:V,currentTime:j}}}(M,T,s);if(this._tilesToDraw[M]=b.map(L),this._providesCoverage(this.coverage,M))break}return r&&r.length>0?(r.forEach(function(I){I&&!I.context2D&&this._loadTile(I,s)},this),this._needsDraw=!0,!1):this._tilesLoading===0},_updateTilesInViewport:function(t){let n=e.now(),i=this;this._tilesLoading=0,this._wasBlending=this._isBlending,this._isBlending=!1,this.loadingCoverage={};let r=t.length?t[0].level:0;if(!this.getDrawArea())return;function s(l){let u=l.tile;if(u&&u.loaded){let d=i._blendTile(u,u.x,u.y,l.level,l.levelOpacity,n,r);i._isBlending=i._isBlending||d,i._needsDraw=i._needsDraw||d||i._wasBlending}}let o=0;for(let l=0;l<t.length;l++){let u=t[l];s(u),this._providesCoverage(this.coverage,u.level)&&(o=Math.max(o,u.level))}if(o>0)for(let l in this._tilesToDraw)l<o&&delete this._tilesToDraw[l]},_blendTile:function(t,n,i,r,a,s,o){let l=1e3*this.blendTime,u,d;return t.blendStart||(t.blendStart=s),u=s-t.blendStart,d=l?Math.min(1,u/l):1,r===o&&(d=1,u=l),this.alwaysBlend&&(d*=a),t.opacity=d,d===1&&(this._setCoverage(this.coverage,r,n,i,!0),this._hasOpaqueTile=!0),u<l},_updateLevel:function(t,n,i,r,a,s){var o=r.getBoundingBox().getTopLeft(),l=r.getBoundingBox().getBottomRight();this.viewer&&this.viewer.raiseEvent("update-level",{tiledImage:this,havedrawn:!0,level:t,opacity:n,visibility:i,drawArea:r,topleft:o,bottomright:l,currenttime:a,best:s}),this._resetCoverage(this.coverage,t),this._resetCoverage(this.loadingCoverage,t);var u=this._getCornerTiles(t,o,l),d=u.topLeft,m=u.bottomRight,v=this.source.getNumTiles(t),y=this.viewport.pixelFromPoint(this.viewport.getCenter());this.getFlip()&&(m.x+=1,this.wrapHorizontal||(m.x=Math.min(m.x,v.x-1)));for(var T=Math.max(0,(m.x-d.x)*(m.y-d.y)),_=new Array(T),S=0,b=d.x;b<=m.x;b++)for(var L=d.y;L<=m.y;L++){var I;if(this.getFlip()){var M=(v.x+b%v.x)%v.x;I=b+v.x-M-M-1}else I=b;if(r.intersection(this.getTileBounds(t,I,L))!==null){var Z=this._updateTile(I,L,t,i,y,v,a,s);s=Z.bestTiles,_[S]=Z.tile,S+=1}}return{bestTiles:s,updatedTiles:_}},_positionTile:function(t,n,i,r,a){var s=t.bounds.getTopLeft();s.x*=this._scaleSpring.current.value,s.y*=this._scaleSpring.current.value,s.x+=this._xSpring.current.value,s.y+=this._ySpring.current.value;var o=t.bounds.getSize();o.x*=this._scaleSpring.current.value,o.y*=this._scaleSpring.current.value,t.positionedBounds.x=s.x,t.positionedBounds.y=s.y,t.positionedBounds.width=o.x,t.positionedBounds.height=o.y;var l=i.pixelFromPointNoRotate(s,!0),u=i.pixelFromPointNoRotate(s,!1),d=i.deltaPixelsFromPointsNoRotate(o,!0),m=i.deltaPixelsFromPointsNoRotate(o,!1),v=u.plus(m.divide(2)),y=r.squaredDistanceTo(v);this.viewer.drawer.minimumOverlapRequired(this)&&(n||(d=d.plus(new e.Point(1,1))),t.isRightMost&&this.wrapHorizontal&&(d.x+=.75),t.isBottomMost&&this.wrapVertical&&(d.y+=.75)),t.position=l,t.size=d,t.squaredDistance=y,t.visibility=a},_updateTile:function(t,n,i,r,a,s,o,l){var u=this._getTile(t,n,i,o,s);this.viewer&&this.viewer.raiseEvent("update-tile",{tiledImage:this,tile:u}),this._setCoverage(this.coverage,i,t,n,!1);var d=u.loaded||u.loading||this._isCovered(this.loadingCoverage,i,t,n);if(this._setCoverage(this.loadingCoverage,i,t,n,d),!u.exists)return{bestTiles:l,tile:u};if(u.loaded&&u.opacity===1&&this._setCoverage(this.coverage,i,t,n,!0),this._positionTile(u,this.source.tileOverlap,this.viewport,a,r),!u.loaded)if(u.context2D)this._setTileLoaded(u);else{var m=this._tileCache.getImageRecord(u.cacheKey);m&&this._setTileLoaded(u,m.getData())}return u.loading?this._tilesLoading++:d||(l=this._compareTiles(l,u,this.maxTilesPerFrame)),{bestTiles:l,tile:u}},_getCornerTiles:function(t,n,i){var r,a;this.wrapHorizontal?(r=e.positiveModulo(n.x,1),a=e.positiveModulo(i.x,1)):(r=Math.max(0,n.x),a=Math.min(1,i.x));var s,o,l=1/this.source.aspectRatio;this.wrapVertical?(s=e.positiveModulo(n.y,l),o=e.positiveModulo(i.y,l)):(s=Math.max(0,n.y),o=Math.min(l,i.y));var u=this.source.getTileAtPoint(t,new e.Point(r,s)),d=this.source.getTileAtPoint(t,new e.Point(a,o)),m=this.source.getNumTiles(t);return this.wrapHorizontal&&(u.x+=m.x*Math.floor(n.x),d.x+=m.x*Math.floor(i.x)),this.wrapVertical&&(u.y+=m.y*Math.floor(n.y/l),d.y+=m.y*Math.floor(i.y/l)),{topLeft:u,bottomRight:d}},_getTile:function(t,n,i,r,a){var s,o,l,u,d,m,v,y,T,_,S=this.tilesMatrix,b=this.source;return S[i]||(S[i]={}),S[i][t]||(S[i][t]={}),(!S[i][t][n]||!S[i][t][n].flipped!=!this.flipped)&&(s=(a.x+t%a.x)%a.x,o=(a.y+n%a.y)%a.y,l=this.getTileBounds(i,t,n),u=b.getTileBounds(i,s,o,!0),d=b.tileExists(i,s,o),m=b.getTileUrl(i,s,o),v=b.getTilePostData(i,s,o),this.loadTilesWithAjax?(y=b.getTileAjaxHeaders(i,s,o),e.isPlainObject(this.ajaxHeaders)&&(y=e.extend({},this.ajaxHeaders,y))):y=null,T=b.getContext2D?b.getContext2D(i,s,o):void 0,_=new e.Tile(i,t,n,l,d,m,T,this.loadTilesWithAjax,y,u,v,b.getTileHashKey(i,s,o,m,y,v)),this.getFlip()?s===0&&(_.isRightMost=!0):s===a.x-1&&(_.isRightMost=!0),o===a.y-1&&(_.isBottomMost=!0),_.flipped=this.flipped,S[i][t][n]=_),_=S[i][t][n],_.lastTouchTime=r,_},_loadTile:function(t,n){var i=this;t.loading=!0,this._imageLoader.addJob({src:t.getUrl(),tile:t,source:this.source,postData:t.postData,loadWithAjax:t.loadWithAjax,ajaxHeaders:t.ajaxHeaders,crossOriginPolicy:this.crossOriginPolicy,ajaxWithCredentials:this.ajaxWithCredentials,callback:function(r,a,s){i._onTileLoad(t,n,r,a,s)},abort:function(){t.loading=!1}})},_onTileLoad:function(t,n,i,r,a){if(i)t.exists=!0;else{e.console.error("Tile %s failed to load: %s - error: %s",t,t.getUrl(),r),this.viewer.raiseEvent("tile-load-failed",{tile:t,tiledImage:this,time:n,message:r,tileRequest:a}),t.loading=!1,t.exists=!1;return}if(n<this.lastResetTime){e.console.warn("Ignoring tile %s loaded before reset: %s",t,t.getUrl()),t.loading=!1;return}var s=this,o=function(){var l=s.source,u=l.getClosestLevel();s._setTileLoaded(t,i,u,a)};o()},_setTileLoaded:function(t,n,i,r){var a=0,s=!1,o=this;function l(){return s&&e.console.error("Event 'tile-loaded' argument getCompletionCallback must be called synchronously. Its return value should be called asynchronously."),a++,u}function u(){a--,a===0&&(t.loading=!1,t.loaded=!0,t.hasTransparency=o.source.hasTransparency(t.context2D,t.getUrl(),t.ajaxHeaders,t.postData),t.context2D||o._tileCache.cacheTile({data:n,tile:t,cutoff:i,tiledImage:o}),o.viewer.raiseEvent("tile-ready",{tile:t,tiledImage:o,tileRequest:r}),o._needsDraw=!0)}var d=l();this.viewer.raiseEvent("tile-loaded",{tile:t,tiledImage:this,tileRequest:r,get image(){return e.console.error("[tile-loaded] event 'image' has been deprecated. Use 'data' property instead."),n},data:n,getCompletionCallback:l}),s=!0,d()},_compareTiles:function(t,n,i){return t?(t.push(n),this._sortTiles(t),t.length>i&&t.pop(),t):[n]},_sortTiles:function(t){t.sort(function(n,i){return n===null?1:i===null?-1:n.visibility===i.visibility?n.squaredDistance-i.squaredDistance:i.visibility-n.visibility})},_providesCoverage:function(t,n,i,r){var a,s,o,l;if(!t[n])return!1;if(i===void 0||r===void 0){a=t[n];for(o in a)if(Object.prototype.hasOwnProperty.call(a,o)){s=a[o];for(l in s)if(Object.prototype.hasOwnProperty.call(s,l)&&!s[l])return!1}return!0}return t[n][i]===void 0||t[n][i][r]===void 0||t[n][i][r]===!0},_isCovered:function(t,n,i,r){return i===void 0||r===void 0?this._providesCoverage(t,n+1):this._providesCoverage(t,n+1,2*i,2*r)&&this._providesCoverage(t,n+1,2*i,2*r+1)&&this._providesCoverage(t,n+1,2*i+1,2*r)&&this._providesCoverage(t,n+1,2*i+1,2*r+1)},_setCoverage:function(t,n,i,r,a){if(!t[n]){e.console.warn("Setting coverage for a tile before its level's coverage has been reset: %s",n);return}t[n][i]||(t[n][i]={}),t[n][i][r]=a},_resetCoverage:function(t,n){t[n]={}}})}(x),function(e){var t=function(i){e.console.assert(i,"[TileCache.cacheTile] options is required"),e.console.assert(i.tile,"[TileCache.cacheTile] options.tile is required"),e.console.assert(i.tiledImage,"[TileCache.cacheTile] options.tiledImage is required"),this.tile=i.tile,this.tiledImage=i.tiledImage},n=function(i){e.console.assert(i,"[ImageRecord] options is required"),e.console.assert(i.data,"[ImageRecord] options.data is required"),this._tiles=[],i.create.apply(null,[this,i.data,i.ownerTile]),this._destroyImplementation=i.destroy.bind(null,this),this.getImage=i.getImage.bind(null,this),this.getData=i.getData.bind(null,this),this.getRenderedContext=i.getRenderedContext.bind(null,this)};n.prototype={destroy:function(){this._destroyImplementation(),this._tiles=null},addTile:function(i){e.console.assert(i,"[ImageRecord.addTile] tile is required"),this._tiles.push(i)},removeTile:function(i){for(var r=0;r<this._tiles.length;r++)if(this._tiles[r]===i){this._tiles.splice(r,1);return}e.console.warn("[ImageRecord.removeTile] trying to remove unknown tile",i)},getTileCount:function(){return this._tiles.length}},e.TileCache=function(i){i=i||{},this._maxImageCacheCount=i.maxImageCacheCount||e.DEFAULT_SETTINGS.maxImageCacheCount,this._tilesLoaded=[],this._imagesLoaded=[],this._imagesLoadedCount=0},e.TileCache.prototype={numTilesLoaded:function(){return this._tilesLoaded.length},cacheTile:function(i){e.console.assert(i,"[TileCache.cacheTile] options is required"),e.console.assert(i.tile,"[TileCache.cacheTile] options.tile is required"),e.console.assert(i.tile.cacheKey,"[TileCache.cacheTile] options.tile.cacheKey is required"),e.console.assert(i.tiledImage,"[TileCache.cacheTile] options.tiledImage is required");var r=i.cutoff||0,a=this._tilesLoaded.length,s=this._imagesLoaded[i.tile.cacheKey];if(s||(i.data||(e.console.error("[TileCache.cacheTile] options.image was renamed to options.data. '.image' attribute has been deprecated and will be removed in the future."),i.data=i.image),e.console.assert(i.data,"[TileCache.cacheTile] options.data is required to create an ImageRecord"),s=this._imagesLoaded[i.tile.cacheKey]=new n({data:i.data,ownerTile:i.tile,create:i.tiledImage.source.createTileCache,destroy:i.tiledImage.source.destroyTileCache,getImage:i.tiledImage.source.getTileCacheDataAsImage,getData:i.tiledImage.source.getTileCacheData,getRenderedContext:i.tiledImage.source.getTileCacheDataAsContext2D}),this._imagesLoadedCount++),s.addTile(i.tile),i.tile.cacheImageRecord=s,this._imagesLoadedCount>this._maxImageCacheCount){for(var o=null,l=-1,u=null,d,m,v,y,T,_,S=this._tilesLoaded.length-1;S>=0;S--)if(_=this._tilesLoaded[S],d=_.tile,!(d.level<=r||d.beingDrawn)){if(!o){o=d,l=S,u=_;continue}y=d.lastTouchTime,m=o.lastTouchTime,T=d.level,v=o.level,(y<m||y===m&&T>v)&&(o=d,l=S,u=_)}o&&l>=0&&(this._unloadTile(u),a=l)}this._tilesLoaded[a]=new t({tile:i.tile,tiledImage:i.tiledImage})},clearTilesFor:function(i){e.console.assert(i,"[TileCache.clearTilesFor] tiledImage is required");for(var r,a=0;a<this._tilesLoaded.length;++a)r=this._tilesLoaded[a],r.tiledImage===i&&(this._unloadTile(r),this._tilesLoaded.splice(a,1),a--)},getImageRecord:function(i){return e.console.assert(i,"[TileCache.getImageRecord] cacheKey is required"),this._imagesLoaded[i]},_unloadTile:function(i){e.console.assert(i,"[TileCache._unloadTile] tileRecord is required");var r=i.tile,a=i.tiledImage;let s=r.getCanvasContext&&r.getCanvasContext();r.unload(),r.cacheImageRecord=null;var o=this._imagesLoaded[r.cacheKey];o&&(o.removeTile(r),o.getTileCount()||(o.destroy(),delete this._imagesLoaded[r.cacheKey],this._imagesLoadedCount--,s&&(s.canvas.width=0,s.canvas.height=0,a.viewer.raiseEvent("image-unloaded",{context2D:s,tile:r}))),a.viewer.raiseEvent("tile-unloaded",{tile:r,tiledImage:a}))}}}(x),function(e){e.World=function(t){var n=this;e.console.assert(t.viewer,"[World] options.viewer is required"),e.EventSource.call(this),this.viewer=t.viewer,this._items=[],this._needsDraw=!1,this._autoRefigureSizes=!0,this._needsSizesFigured=!1,this._delegatedFigureSizes=function(i){n._autoRefigureSizes?n._figureSizes():n._needsSizesFigured=!0},this._figureSizes()},e.extend(e.World.prototype,e.EventSource.prototype,{addItem:function(t,n){if(e.console.assert(t,"[World.addItem] item is required"),e.console.assert(t instanceof e.TiledImage,"[World.addItem] only TiledImages supported at this time"),n=n||{},n.index!==void 0){var i=Math.max(0,Math.min(this._items.length,n.index));this._items.splice(i,0,t)}else this._items.push(t);this._autoRefigureSizes?this._figureSizes():this._needsSizesFigured=!0,this._needsDraw=!0,t.addHandler("bounds-change",this._delegatedFigureSizes),t.addHandler("clip-change",this._delegatedFigureSizes),this.raiseEvent("add-item",{item:t})},getItemAt:function(t){return e.console.assert(t!==void 0,"[World.getItemAt] index is required"),this._items[t]},getIndexOfItem:function(t){return e.console.assert(t,"[World.getIndexOfItem] item is required"),e.indexOf(this._items,t)},getItemCount:function(){return this._items.length},setItemIndex:function(t,n){e.console.assert(t,"[World.setItemIndex] item is required"),e.console.assert(n!==void 0,"[World.setItemIndex] index is required");var i=this.getIndexOfItem(t);if(n>=this._items.length)throw new Error("Index bigger than number of layers.");n===i||i===-1||(this._items.splice(i,1),this._items.splice(n,0,t),this._needsDraw=!0,this.raiseEvent("item-index-change",{item:t,previousIndex:i,newIndex:n}))},removeItem:function(t){e.console.assert(t,"[World.removeItem] item is required");var n=e.indexOf(this._items,t);n!==-1&&(t.removeHandler("bounds-change",this._delegatedFigureSizes),t.removeHandler("clip-change",this._delegatedFigureSizes),t.destroy(),this._items.splice(n,1),this._figureSizes(),this._needsDraw=!0,this._raiseRemoveItem(t))},removeAll:function(){this.viewer._cancelPendingImages();var t,n;for(n=0;n<this._items.length;n++)t=this._items[n],t.removeHandler("bounds-change",this._delegatedFigureSizes),t.removeHandler("clip-change",this._delegatedFigureSizes),t.destroy();var i=this._items;for(this._items=[],this._figureSizes(),this._needsDraw=!0,n=0;n<i.length;n++)t=i[n],this._raiseRemoveItem(t)},resetItems:function(){for(var t=0;t<this._items.length;t++)this._items[t].reset()},update:function(t){for(var n=!1,i=0;i<this._items.length;i++)n=this._items[i].update(t)||n;return n},draw:function(){this.viewer.drawer.draw(this._items),this._needsDraw=!1,this._items.forEach(t=>{this._needsDraw=t.setDrawn()||this._needsDraw})},needsDraw:function(){for(var t=0;t<this._items.length;t++)if(this._items[t].needsDraw())return!0;return this._needsDraw},getHomeBounds:function(){return this._homeBounds.clone()},getContentFactor:function(){return this._contentFactor},setAutoRefigureSizes:function(t){this._autoRefigureSizes=t,t&this._needsSizesFigured&&(this._figureSizes(),this._needsSizesFigured=!1)},arrange:function(t){t=t||{};var n=t.immediately||!1,i=t.layout||e.DEFAULT_SETTINGS.collectionLayout,r=t.rows||e.DEFAULT_SETTINGS.collectionRows,a=t.columns||e.DEFAULT_SETTINGS.collectionColumns,s=t.tileSize||e.DEFAULT_SETTINGS.collectionTileSize,o=t.tileMargin||e.DEFAULT_SETTINGS.collectionTileMargin,l=s+o,u;!t.rows&&a?u=a:u=Math.ceil(this._items.length/r);var d=0,m=0,v,y,T,_,S;this.setAutoRefigureSizes(!1);for(var b=0;b<this._items.length;b++)b&&b%u===0&&(i==="horizontal"?(m+=l,d=0):(d+=l,m=0)),v=this._items[b],y=v.getBounds(),y.width>y.height?T=s:T=s*(y.width/y.height),_=T*(y.height/y.width),S=new e.Point(d+(s-T)/2,m+(s-_)/2),v.setPosition(S,n),v.setWidth(T,n),i==="horizontal"?d+=l:m+=l;this.setAutoRefigureSizes(!0)},_figureSizes:function(){var t=this._homeBounds?this._homeBounds.clone():null,n=this._contentSize?this._contentSize.clone():null,i=this._contentFactor||0;if(!this._items.length)this._homeBounds=new e.Rect(0,0,1,1),this._contentSize=new e.Point(1,1),this._contentFactor=1;else{var r=this._items[0],a=r.getBounds();this._contentFactor=r.getContentSize().x/a.width;for(var s=r.getClippedBounds().getBoundingBox(),o=s.x,l=s.y,u=s.x+s.width,d=s.y+s.height,m=1;m<this._items.length;m++)r=this._items[m],a=r.getBounds(),this._contentFactor=Math.max(this._contentFactor,r.getContentSize().x/a.width),s=r.getClippedBounds().getBoundingBox(),o=Math.min(o,s.x),l=Math.min(l,s.y),u=Math.max(u,s.x+s.width),d=Math.max(d,s.y+s.height);this._homeBounds=new e.Rect(o,l,u-o,d-l),this._contentSize=new e.Point(this._homeBounds.width*this._contentFactor,this._homeBounds.height*this._contentFactor)}(this._contentFactor!==i||!this._homeBounds.equals(t)||!this._contentSize.equals(n))&&this.raiseEvent("metrics-change",{})},_raiseRemoveItem:function(t){this.raiseEvent("remove-item",{item:t})}})}(x)})(rt);var Dt=rt.exports;const Ge=ct(Dt);var he={fullscreenEnabled:0,fullscreenElement:1,requestFullscreen:2,exitFullscreen:3,fullscreenchange:4,fullscreenerror:5,fullscreen:6},$e=["webkitFullscreenEnabled","webkitFullscreenElement","webkitRequestFullscreen","webkitExitFullscreen","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"],et=["mozFullScreenEnabled","mozFullScreenElement","mozRequestFullScreen","mozCancelFullScreen","mozfullscreenchange","mozfullscreenerror","-moz-full-screen"],tt=["msFullscreenEnabled","msFullscreenElement","msRequestFullscreen","msExitFullscreen","MSFullscreenChange","MSFullscreenError","-ms-fullscreen"],ae=typeof window<"u"&&typeof window.document<"u"?window.document:{},ue="fullscreenEnabled"in ae&&Object.keys(he)||$e[0]in ae&&$e||et[0]in ae&&et||tt[0]in ae&&tt||[],Te={requestFullscreen:function(P){return P[ue[he.requestFullscreen]]()},requestFullscreenFunction:function(P){return P[ue[he.requestFullscreen]]},get exitFullscreen(){return ae[ue[he.exitFullscreen]].bind(ae)},get fullscreenPseudoClass(){return":"+ue[he.fullscreen]},addEventListener:function(P,x,e){return ae.addEventListener(ue[he[P]],x,e)},removeEventListener:function(P,x,e){return ae.removeEventListener(ue[he[P]],x,e)},get fullscreenEnabled(){return!!ae[ue[he.fullscreenEnabled]]},set fullscreenEnabled(P){},get fullscreenElement(){return ae[ue[he.fullscreenElement]]},set fullscreenElement(P){},get onfullscreenchange(){return ae[("on"+ue[he.fullscreenchange]).toLowerCase()]},set onfullscreenchange(P){return ae[("on"+ue[he.fullscreenchange]).toLowerCase()]=P},get onfullscreenerror(){return ae[("on"+ue[he.fullscreenerror]).toLowerCase()]},set onfullscreenerror(P){return ae[("on"+ue[he.fullscreenerror]).toLowerCase()]=P}};const Ft={name:"ViewerButton",props:{buttonIcon:{type:String,required:!0,default:null},tooltipText:{type:String,required:!1,default:null},iconSize:{type:String,required:!1,default:"24"},disabled:{type:Boolean,required:!1,default:!1}}},Bt={style:{padding:"0 0"}};function It(P,x,e,t,n,i){return ee(),oe("div",Bt,[H(fe,{icon:e.buttonIcon,size:"28",style:{"border-radius":"4px"},disabled:e.disabled},{default:Y(()=>[H(de,{size:e.iconSize},null,8,["size"]),P.$vuetify.display.sm||P.$vuetify.display.xs?ce("",!0):(ee(),Pe(dt,{key:0,disabled:e.disabled,location:"bottom","open-delay":"500",activator:"parent"},{default:Y(()=>[me("span",null,we(e.tooltipText),1)]),_:1},8,["disabled"]))]),_:1},8,["icon","disabled"])])}const Ot=it(Ft,[["render",It]]),At="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAMAAAAM7l6QAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyhpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTMyIDc5LjE1OTI4NCwgMjAxNi8wNC8xOS0xMzoxMzo0MCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTUuNSAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OTVEQzM5QTI4NTZFMTFFNkE0OUFBNDg2MDVDN0IxNjYiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OTVEQzM5QTM4NTZFMTFFNkE0OUFBNDg2MDVDN0IxNjYiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo5NURDMzlBMDg1NkUxMUU2QTQ5QUE0ODYwNUM3QjE2NiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo5NURDMzlBMTg1NkUxMUU2QTQ5QUE0ODYwNUM3QjE2NiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PkHtxoIAAAA8UExURdra2s7Ozr6+vsbGxtXV1e7u7sHBwba2tujo6Pn5+aqqqv39/fT09OHh4aampq6urrq6uvf396Wlpf///4ypwX8AAACnSURBVHja1NLbCsMgDABQjfGSeFmb/P+/LnYM9KXsbVQwRI+SIDq9He5x3IEXdoBVtaRAPnXVGkRk4SEC2i1620dF2fllyzKDs8lkGfuF5/F5MVew2G2GrTVkjjCgKYWRy+S4sMfTWqs9Neikk8daO4ndRCvZZtXJsrO1luVi4YvHLQPd8tb5Dxz/xMgfPgjGxQO3N68dYsJm2YlHORw99iN/x1uAAQCk8zs3N8QNGAAAAABJRU5ErkJggg==",zt={name:"ImageViewer",components:{ImageViewerButton:Ot,LoadingSpinner:ft},props:{objectid:{type:Number,required:!1,default:0},imageData:{type:Array,required:!0},fallbackImage:{type:String,required:!0},height:{type:String,required:!1,default:"400"},copyright:{type:String,required:!1,default:""},comparisonPage:{type:Boolean,required:!1,default:!1}},data(){return{viewer:null,viewport_overlays:{},overlays_shown:!1,zoom_in_disabled:!1,zoom_out_disabled:!1,reset_to_page_disabled:!1,reset_to_selection_disabled:!1,focus_margin_x:.02,focus_margin_y:.02,image_loaded:!1,selection_bounds:null,selection_zoom:null,max_zoom_level:18,min_zoom_level:.35,zoom_level:1,zoom_level_log:1,fullscreen_active:!1,startY:0,currentY:0,velocity:0,isScrolling:0,lastTouchTime:0,must_add_overlays:!0,is_fallback_mode:!1,image_tiles:[]}},computed:{identifier(){return this.comparisonPage?this.objectid:"1"},prev_disabled(){return this.viewer?this.viewer._sequenceIndex==0:!0},next_disabled(){return this.viewer?this.viewer._sequenceIndex==this.imageData.length-1:!0}},watch:{objectid:function(){if(this.is_fallback_mode)this.$emit("fallbackForceRerender");else if(this.image_loaded)if(this.viewer.clearOverlays(),this.add_overlays(),this.highlight_focused_overlay(),this.overlays_shown=!0,"areas"in this.imageData[this.viewer._sequenceIndex]&&this.imageData[this.viewer._sequenceIndex].areas.length&&this.imageData[this.viewer._sequenceIndex].areas.find(P=>P.objectId==parseInt(this.objectid)))this.zoom_to_overlay(2),this.selection_bounds=this.viewer.viewport.getBounds(),this.selection_zoom=this.viewer.viewport.getZoom(),this.reset_to_selection_disabled=!0;else{for(const P of this.viewer.currentOverlays)P.element.classList.remove("image-region-focused");this.viewer.viewport.setRotation(this.imageData[this.viewer._sequenceIndex].rotation),this.viewer.viewport.goHome()}},imageData:function(){this.create_image_tiles()}},mounted(){this.assemble_tiles_and_viewer()},methods:{assemble_tiles_and_viewer(){this.must_add_overlays=!0,this.create_image_tiles(),this.image_tiles.length&&this.init_viewer()},fallback_tile(){if(this.is_fallback_mode=!0,this.fallbackImage){if(this.fallbackImage.fallback_url)return{type:"image",url:this.fallbackImage.fallback_url};console.log("no fallback url",this.fallbackImage)}return{type:"image",url:"http://localhost:8080/src/assets/logo.jpg"}},create_image_tiles(){this.is_fallback_mode=!1;const P=[];for(const x of this.imageData)if("iiif_url"in x)if(x.iiif_url.startsWith("https://www.e-rara.ch")){fetch(x.iiif_url).then(e=>{e.json().then(t=>{"sizes"in t&&delete t.sizes,this.image_tiles=[t],this.init_viewer()})});return}else P.push(x.iiif_url);else P.push({type:"image",buildPyramid:!0,url:x.image_url});this.image_tiles=P},fullscreen_change(){Te.fullscreenElement?(this.fullscreen_active=!0,this.viewer.navigator.element.style.display="inline-block"):(this.fullscreen_active=!1,this.viewer.navigator.element.style.display="none","rotation"in this.imageData[this.viewer._sequenceIndex]?this.viewer.viewport.setRotation(this.imageData[this.viewer._sequenceIndex].rotation):this.viewer.viewport.setRotation(0,!1),this.show_overlays(),Te.removeEventListener("fullscreenchange",this.fullscreen_change,!1))},enter_fullscreen(){let P=document.getElementById(`viewer-image-${this.identifier}`);if(Te.fullscreenEnabled){Te.addEventListener("fullscreenchange",this.fullscreen_change,!1);let x=document.getElementById(`fullscreen-elements-${this.identifier}`);P.appendChild(x),Te.requestFullscreen(P),this.hide_overlays()}},exit_fullscreen(){Te.fullscreenElement&&Te.exitFullscreen()},next_image(){this.image_loaded=!1,this.viewer.goToNextPage(),"rotation"in this.imageData[this.viewer._sequenceIndex]&&this.viewer.viewport.setRotation(this.imageData[this.viewer._sequenceIndex].rotation),this.$emit("image-index-change",this.viewer._sequenceIndex)},prev_image(){this.image_loaded=!1,this.viewer.goToPreviousPage(),"rotation"in this.imageData[this.viewer._sequenceIndex]&&this.viewer.viewport.setRotation(this.imageData[this.viewer._sequenceIndex].rotation),this.$emit("image-index-change",this.viewer._sequenceIndex)},handleTouchStart(P){P.touches.length==1&&(this.startY=P.touches[0].clientY,this.currentY=this.startY,this.velocity=0,this.isScrolling=!0,this.lastTouchTime=Date.now())},handleTouchMove(P){if(P.touches.length!=1||!this.isScrolling)return;const x=P.touches[0].clientY,e=x-this.currentY;this.currentY=x;const t=Date.now(),n=t-this.lastTouchTime;this.velocity=e/n,window.scrollBy(0,-e),this.lastTouchTime=t},handleTouchEnd(P){if(P.touches.length!=1)return;this.isScrolling=!1;const x=()=>{Math.abs(this.velocity)>.01&&(window.scrollBy(0,-this.velocity*16),this.velocity*=.95,requestAnimationFrame(x))};requestAnimationFrame(x)},init_viewer(){this.viewer=Ge({id:`viewer-image-${this.identifier}`,animationTime:1,showNavigator:!0,navigatorPosition:"BOTTOM_RIGHT",navigatorHeight:"180px",navigatorWidth:"150px",sequenceMode:!0,maxZoomLevel:this.max_zoom_level,minZoomLevel:this.min_zoom_level,zoomPerScroll:1.3,minPixelRatio:.7,timeout:5e3,gestureSettingsTouch:{dragToPan:!1,flickEnabled:!1,scrollToZoom:!1,clickToZoom:!1,pinchToZoom:!0},showNavigationControl:!1,showSequenceControl:!1,gestureSettingsMouse:{clickToZoom:!1},degrees:this.imageData[0].rotation,tileSources:this.image_tiles}),this.viewer.navigator.element.style.display="none",this.viewer.addHandler("open",()=>{this.zoom_level=this.viewer.viewport.getZoom(),this.zoom_level_log=Math.log(this.zoom_level),this.viewer.world.getItemAt(0).addOnceHandler("fully-loaded-change",()=>{"areas"in this.imageData[this.viewer._sequenceIndex]&&this.imageData[this.viewer._sequenceIndex].areas.length&&this.must_add_overlays&&(this.add_overlays(),this.highlight_focused_overlay(),this.overlays_shown=!0,this.zoom_to_overlay(2),this.selection_bounds=this.viewer.viewport.getBounds(),this.selection_zoom=this.viewer.viewport.getZoom(),this.reset_to_selection_disabled=!0),this.image_loaded=!0})}),this.viewer.addHandler("open-failed",()=>{this.must_add_overlays=!1,this.viewer.open(this.fallback_tile()),this.image_loaded=!0}),this.viewer.addHandler("pan",()=>{this.is_same_zoom_level(this.zoom_level,this.viewer.viewport.getHomeZoom())&&this.check_if_same_bounds(this.viewer.viewport.getBounds(),this.viewer.viewport.getHomeBounds())?this.reset_to_page_disabled=!0:this.reset_to_page_disabled=!1,this.selection_bounds&&this.is_same_zoom_level(this.zoom_level,this.selection_zoom)&&this.check_if_same_bounds(this.viewer.viewport.getBounds(),this.selection_bounds)?this.reset_to_selection_disabled=!0:this.reset_to_selection_disabled=!1}),this.viewer.addHandler("zoom",()=>{this.zoom_level=this.viewer.viewport.getZoom(),this.zoom_level_log=Math.log(this.zoom_level),this.zoom_level>=this.max_zoom_level-.05?this.zoom_in_disabled=!0:this.zoom_level<=this.min_zoom_level+.05?this.zoom_out_disabled=!0:this.is_same_zoom_level(this.zoom_level,this.viewer.viewport.getHomeZoom())&&this.check_if_same_bounds(this.viewer.viewport.getBounds(),this.viewer.viewport.getHomeBounds())?this.reset_to_page_disabled=!0:(this.zoom_in_disabled=!1,this.zoom_out_disabled=!1,this.reset_to_page_disabled=!1),this.selection_bounds&&this.is_same_zoom_level(this.zoom_level,this.selection_zoom)&&this.check_if_same_bounds(this.viewer.viewport.getBounds(),this.selection_bounds)?this.reset_to_selection_disabled=!0:this.reset_to_selection_disabled=!1}),this.viewer.addHandler("full-screen",P=>{P.fullScreen?(this.fullscreen_active=!0,this.hide_overlays(),this.viewer.navigator.element.style.display="inline-block"):(this.fullscreen_active=!1,this.viewer.navigator.element.style.display="none","rotation"in this.imageData[this.viewer._sequenceIndex]&&this.viewer.viewport.setRotation(this.imageData[this.viewer._sequenceIndex].rotation),this.show_overlays())})},is_same_zoom_level(P,x){return Math.abs(Math.log(P)-Math.log(x))<.05},check_if_same_bounds(P,x){return Math.abs(P.x-x.x)<.001&&Math.abs(P.width-x.width)<.001&&Math.abs(P.y-x.y)<.001&&Math.abs(P.height-x.height)<.001},add_overlays(){if(this.must_add_overlays){let P=this.imageData;this.comparisonPage&&(P[this.viewer._sequenceIndex].areas=P[this.viewer._sequenceIndex].areas.filter(x=>x.objectId==this.objectid)),this.viewport_overlays[this.viewer._sequenceIndex]={};for(const x of P[this.viewer._sequenceIndex].areas){let e=new Ge.Rect(+x.h_offset,+x.v_offset,+x.width,+x.height),t=this.viewer.viewport.imageToViewportRectangle(e),n=document.createElement("div");n.id="region-"+x.objectId,n.className="image-region",n.style=`z-index:${x.z_index}`,this.viewer.addOverlay({element:n,location:t}),t.x-=t.width*this.focus_margin_x,t.width+=t.width*2*this.focus_margin_x,t.y-=t.height*this.focus_margin_y,t.height+=t.height*2*this.focus_margin_y,this.viewport_overlays[this.viewer._sequenceIndex][x.objectId]={viewport_coord:t,rotation:x.rotation},new Ge.MouseTracker({element:n,clickTimeThreshold:700,clickHandler:i=>{i.quick&&this.objectid!=x.objectId&&this.$router.push(`/object/${x.objectId}`)}})}}},update_zoom_level(P){this.fullscreen_active&&this.viewer.viewport.zoomTo(Math.exp(P))},show_overlays(){"areas"in this.imageData[this.viewer._sequenceIndex]&&this.imageData[this.viewer._sequenceIndex].areas.length&&(this.overlays_shown=!0,this.add_overlays(),this.highlight_focused_overlay())},hide_overlays(){this.overlays_shown=!1,this.viewer.currentOverlays.length&&this.viewer.clearOverlays()},zoom_to_overlay(P){const x=this.viewer.viewport.zoomSpring.animationTime,e=this.viewer.viewport.degreesSpring.animationTime;this.viewer.viewport.zoomSpring.animationTime=P,this.viewer.viewport.degreesSpring.animationTime=P;let t=this.viewport_overlays[this.viewer._sequenceIndex][this.objectid];t&&(this.viewer.viewport.setRotation(+t.rotation),this.viewer.viewport.fitBounds(t.viewport_coord)),this.viewer.viewport.zoomSpring.animationTime=x,this.viewer.viewport.degreesSpring.animationTime=e},highlight_focused_overlay(){for(const P of this.viewer.currentOverlays)P.element.id.includes(this.objectid)?P.element.classList.add("image-region-focused"):P.element.classList.remove("image-region-focused")}}},Mt=["id"],Lt={class:"fullscreen-zoom-btns"},Ht={key:0},kt={key:0,class:"copyright"},Nt={class:"viewer-scan-buttons"},Ut={elevation:"0",class:"pa-3"},Gt={key:2},Vt={key:0,class:"d-flex flex-row-reverse align-center",style:{height:"100%"}},Wt={key:1},jt={key:0,class:"pa-0 ma-0 image-selection-number"};function qt(P,x,e,t,n,i){const r=Ye("LoadingSpinner"),a=Ye("ImageViewerButton");return ee(),oe("div",{id:"parent",ref:"parent",onTouchstart:x[13]||(x[13]=(...s)=>i.handleTouchStart&&i.handleTouchStart(...s)),onTouchmove:x[14]||(x[14]=(...s)=>i.handleTouchMove&&i.handleTouchMove(...s)),onTouchend:x[15]||(x[15]=(...s)=>i.handleTouchEnd&&i.handleTouchEnd(...s))},[Oe(me("div",{id:`fullscreen-elements-${i.identifier}`},[me("div",Lt,[H(ze,{class:"pa-2 ma-2"},{default:Y(()=>[H(pe,{justify:"center"},{default:Y(()=>[H(fe,{icon:"mdi-fit-to-page-outline",width:"34",height:"34",style:{"border-radius":"2px"},disabled:n.reset_to_page_disabled,onClick:x[0]||(x[0]=s=>n.viewer.viewport.goHome())},{default:Y(()=>[H(de,{size:"34",color:"#757575"})]),_:1},8,["disabled"])]),_:1}),H(pe,{justify:"center"},{default:Y(()=>[H(fe,{icon:"mdi-plus",width:"34",height:"34",style:{"border-radius":"2px"},disabled:n.zoom_in_disabled,onClick:x[1]||(x[1]=s=>n.viewer.viewport.zoomBy(1.5))},{default:Y(()=>[H(de,{size:"36",color:"#757575"})]),_:1},8,["disabled"])]),_:1}),n.viewer?(ee(),Pe(pe,{key:0,justify:"center"},{default:Y(()=>[H(gt,{modelValue:n.zoom_level_log,"onUpdate:modelValue":[x[2]||(x[2]=s=>n.zoom_level_log=s),i.update_zoom_level],class:"zoom-slider",direction:"vertical","hide-details":"",density:"compact","thumb-size":"20",step:"0.05",color:"#757575",ripple:!1,max:Math.log(n.max_zoom_level),min:Math.log(n.min_zoom_level)},null,8,["modelValue","max","min","onUpdate:modelValue"])]),_:1})):ce("",!0),H(pe,{justify:"center"},{default:Y(()=>[H(fe,{icon:"mdi-minus",width:"34",height:"34",style:{"border-radius":"2px"},disabled:n.zoom_out_disabled,onClick:x[3]||(x[3]=s=>n.viewer.viewport.zoomBy(.675))},{default:Y(()=>[H(de,{size:"36",color:"#757575"})]),_:1},8,["disabled"])]),_:1}),H(pe,{justify:"center"},{default:Y(()=>[H(fe,{icon:"mdi-rotate-left",width:"34",height:"34",style:{"border-radius":"2px"},onClick:x[4]||(x[4]=s=>n.viewer.viewport.setRotation(n.viewer.viewport.getRotation()-90))},{default:Y(()=>[H(de,{size:"34",color:"#757575"})]),_:1})]),_:1}),H(pe,{justify:"center"},{default:Y(()=>[H(fe,{icon:"mdi-rotate-right",width:"34",height:"34",style:{"border-radius":"2px"},onClick:x[5]||(x[5]=s=>n.viewer.viewport.setRotation(n.viewer.viewport.getRotation()+90))},{default:Y(()=>[H(de,{size:"34",color:"#757575"})]),_:1})]),_:1})]),_:1})]),H(fe,{class:"fullscreen-exit-btn",icon:"mdi-fullscreen-exit",height:"50",width:"50",style:{"border-radius":"2px"},onClick:x[6]||(x[6]=s=>n.viewer.setFullScreen(!1))},{default:Y(()=>[H(de,{size:70,color:"#757575"})]),_:1}),n.viewer&&e.imageData.length>1?(ee(),oe("div",Ht,[H(fe,{class:"fullscreen-next-btn",icon:"",width:"60",height:"60",disabled:i.next_disabled,onClick:i.next_image},{default:Y(()=>[H(de,{size:"60",color:"#757575"},{default:Y(()=>x[16]||(x[16]=[Qe("mdi-chevron-right")])),_:1})]),_:1},8,["disabled","onClick"]),H(fe,{class:"fullscreen-prev-btn",icon:"",width:"60",height:"60",disabled:i.prev_disabled,onClick:i.prev_image},{default:Y(()=>[H(de,{size:"60",color:"#757575"},{default:Y(()=>x[17]||(x[17]=[Qe("mdi-chevron-left")])),_:1})]),_:1},8,["disabled","onClick"])])):ce("",!0)],8,Mt),[[Ae,n.fullscreen_active]]),H(lt,{id:`viewer-image-${i.identifier}`,ref:"image",elevation:"0",class:"viewer-image","min-height":e.height},{default:Y(()=>[H(at,{contained:"","model-value":!n.image_loaded,class:"align-center justify-center",scrim:!1,transition:"fade-transition"},{default:Y(()=>[H(r,{style:{opacity:"0.3"}})]),_:1},8,["model-value"]),e.copyright?(ee(),oe("div",kt,[me("span",null,"© "+we(e.copyright),1)])):ce("",!0)]),_:1},8,["id","min-height"]),me("div",Nt,[me("div",Ut,[H(pe,{justify:"space-between",class:"py-2 px-1"},{default:Y(()=>[H(ze,{cols:"3"}),H(ze,{cols:"6",class:"ma-0 pa-0","align-self":"center"},{default:Y(()=>[H(pe,{class:"ma-0 pa-0",justify:"center"},{default:Y(()=>[Oe(H(a,{"tooltip-text":P.$t("site_navigation.reset_to_section"),"button-icon":"mdi-home",disabled:n.reset_to_selection_disabled,onClick:x[7]||(x[7]=s=>i.zoom_to_overlay(1))},null,8,["tooltip-text","disabled"]),[[Ae,n.viewer&&"areas"in e.imageData[n.viewer._sequenceIndex]&&e.imageData[n.viewer._sequenceIndex].areas.length&&e.imageData[n.viewer._sequenceIndex].areas.map(s=>s.objectId).includes(parseInt(e.objectid))]]),H(a,{"tooltip-text":P.$t("site_navigation.fit_to_page"),"button-icon":"mdi-fit-to-page-outline",disabled:n.reset_to_page_disabled,onClick:x[8]||(x[8]=s=>n.viewer.viewport.goHome())},null,8,["tooltip-text","disabled"]),H(a,{"tooltip-text":P.$t("site_navigation.zoom_in"),"button-icon":"mdi-plus","icon-size":"28",disabled:n.zoom_in_disabled,onClick:x[9]||(x[9]=s=>n.viewer.viewport.zoomBy(1.5))},null,8,["tooltip-text","disabled"]),H(a,{"tooltip-text":P.$t("site_navigation.zoom_out"),"button-icon":"mdi-minus","icon-size":"28",disabled:n.zoom_out_disabled,onClick:x[10]||(x[10]=s=>n.viewer.viewport.zoomBy(.675))},null,8,["tooltip-text","disabled"]),e.comparisonPage?(ee(),Pe(a,{key:0,"tooltip-text":"Linksdrehung","button-icon":"mdi-rotate-left","icon-size":"28",onClick:x[11]||(x[11]=s=>n.viewer.viewport.setRotation(n.viewer.viewport.getRotation()-90))})):ce("",!0),e.comparisonPage?(ee(),Pe(a,{key:1,"tooltip-text":"Rechtsdrehung","button-icon":"mdi-rotate-right","icon-size":"28",onClick:x[12]||(x[12]=s=>n.viewer.viewport.setRotation(n.viewer.viewport.getRotation()+90))})):ce("",!0),n.viewer&&"areas"in e.imageData[n.viewer._sequenceIndex]&&e.imageData[n.viewer._sequenceIndex].areas.length?(ee(),oe("div",Gt,[Oe(H(a,{"tooltip-text":P.$t("site_navigation.show_sections"),"button-icon":"mdi-selection",onClick:i.show_overlays},null,8,["tooltip-text","onClick"]),[[Ae,!n.overlays_shown]]),Oe(H(a,{"tooltip-text":P.$t("site_navigation.hide_sections"),"button-icon":"mdi-selection-remove",onClick:i.hide_overlays},null,8,["tooltip-text","onClick"]),[[Ae,n.overlays_shown]])])):ce("",!0),P.$vuetify.display.mobile?ce("",!0):(ee(),Pe(a,{key:3,"tooltip-text":P.$t("site_navigation.fullscreen"),"button-icon":"mdi-overscan","icon-size":"26",disabled:n.fullscreen_active,onClick:i.enter_fullscreen},null,8,["tooltip-text","disabled","onClick"]))]),_:1})]),_:1}),H(ze,{cols:"3",class:"ma-0 pa-0"},{default:Y(()=>[n.viewer&&e.imageData[0].iiif_url&&!n.is_fallback_mode?(ee(),oe("div",Vt,[me("div",null,[H(ht,{src:At,alt:"iiif Logo",width:"26",height:"20",cover:""})])])):ce("",!0),n.viewer&&e.imageData.length>1?(ee(),oe("div",Wt,[H(pe,{justify:"end",align:"center",class:"ma-0 pa-0"},{default:Y(()=>[H(fe,{icon:"mdi-chevron-left",size:"28",disabled:i.prev_disabled,style:{"justify-content":"end",width:"24px"},onClick:i.prev_image},{default:Y(()=>[H(de,{size:"24"})]),_:1},8,["disabled","onClick"]),me("div",{class:Ve(["pa-0 ma-0 image-selection-number",e.imageData.length>9?"two-digit-width":"one-digit-width"])},we(n.viewer._sequenceIndex+1),3),n.viewer?(ee(),oe("div",jt,"/")):ce("",!0),me("div",{class:Ve(["pa-0 ma-0 image-selection-number",e.imageData.length>9?"two-digit-width":"one-digit-width"])},we(e.imageData.length),3),H(fe,{icon:"mdi-chevron-right",size:"28",disabled:i.next_disabled,style:{"justify-content":"start",width:"24px"},onClick:i.next_image},{default:Y(()=>[H(de,{size:"24"})]),_:1},8,["disabled","onClick"])]),_:1})])):ce("",!0)]),_:1})]),_:1})])])],544)}const ti=it(zt,[["render",qt],["__scopeId","data-v-0dd9d4d2"]]);export{ti as I,Jt as _,St as u};