@triiiceratops/plugin-image-export 1.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/catalog.d.ts +11 -0
- package/dist/contextKey.d.ts +17 -0
- package/dist/exportImage.d.ts +46 -0
- package/dist/icons.d.ts +3 -0
- package/dist/iife.d.ts +24 -0
- package/dist/iife.js +200 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +3578 -0
- package/dist/plugin.d.ts +20 -0
- package/dist/reportError.d.ts +1 -0
- package/dist/styles.d.ts +14 -0
- package/package.json +67 -0
package/dist/iife.js
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
(function(){"use strict";function Nn(n,o){for(var e=0;e<o.length;e++){const t=o[e];if(typeof t!="string"&&!Array.isArray(t)){for(const r in t)if(r!=="default"&&!(r in n)){const i=Object.getOwnPropertyDescriptor(t,r);i&&Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:()=>t[r]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}const Pi=!1;var Ri=Array.isArray,Un=Array.prototype.indexOf,ri=Array.from,Wn=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,Vn=Object.getOwnPropertyDescriptors,jn=Object.prototype,Gn=Array.prototype,ir=Object.getPrototypeOf,rr=Object.isExtensible;const nr=()=>{};function qn(n){for(var o=0;o<n.length;o++)n[o]()}function sr(){var n,o,e=new Promise((t,r)=>{n=t,o=r});return{promise:e,resolve:n,reject:o}}const Ee=2,Ci=4,Di=8,or=1<<24,Je=16,$e=32,ft=64,ni=128,Ne=512,Re=1024,Ie=2048,et=4096,Me=8192,tt=16384,Ai=32768,pt=65536,ar=1<<17,lr=1<<18,Ct=1<<19,Zn=1<<20,it=1<<25,gt=32768,Ii=1<<21,Oi=1<<22,ot=1<<23,mt=Symbol("$state"),Xn=Symbol("legacy props"),Yn=Symbol(""),Dt=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"};function Kn(n){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function Qn(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Jn(n){throw new Error("https://svelte.dev/e/effect_in_teardown")}function $n(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function es(n){throw new Error("https://svelte.dev/e/effect_orphan")}function ts(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function is(n){throw new Error("https://svelte.dev/e/props_invalid_value")}function rs(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function ns(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function ss(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function os(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const as=1,ls=2,ur=4,us=8,hs=16,cs=1,ds=4,fs=8,ps=16,gs=1,ms=2,be=Symbol(),vs="http://www.w3.org/1999/xhtml",ws="@attach";function ys(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function _s(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function hr(n){return n===this.v}function Ts(n,o){return n!=n?o==o:n!==o||n!==null&&typeof n=="object"||typeof n=="function"}function cr(n){return!Ts(n,this.v)}let xs=!1,De=null;function At(n){De=n}function Es(n){return bs().get(n)}function Fi(n,o=!1,e){De={p:De,i:!1,c:null,e:null,s:n,x:null,l:null}}function Li(n){var o=De,e=o.e;if(e!==null){o.e=null;for(var t of e)Or(t)}return o.i=!0,De=o.p,{}}function dr(){return!0}function bs(n){return De===null&&Kn(),De.c??=new Map(Ss(De)||void 0)}function Ss(n){let o=n.p;for(;o!==null;){const e=o.c;if(e!==null)return e;o=o.p}return null}let It=[];function Ps(){var n=It;It=[],qn(n)}function vt(n){if(It.length===0){var o=It;queueMicrotask(()=>{o===It&&Ps()})}It.push(n)}function fr(n){var o=ne;if(o===null)return ee.f|=ot,n;if((o.f&Ai)===0){if((o.f&ni)===0)throw n;o.b.error(n)}else Ot(n,o)}function Ot(n,o){for(;o!==null;){if((o.f&ni)!==0)try{o.b.error(n);return}catch(e){n=e}o=o.parent}throw n}const si=new Set;let ae=null,oi=null,ze=null,We=[],Mi=null,Bi=!1;class Ve{committed=!1;current=new Map;previous=new Map;#e=new Set;#t=new Set;#r=0;#i=0;#l=null;#s=[];#n=[];skipped_effects=new Set;is_fork=!1;is_deferred(){return this.is_fork||this.#i>0}process(o){We=[],oi=null,this.apply();var e={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const t of o)this.#o(t,e);this.is_fork||this.#h(),this.is_deferred()?(this.#a(e.effects),this.#a(e.render_effects),this.#a(e.block_effects)):(oi=this,ae=null,pr(e.render_effects),pr(e.effects),oi=null,this.#l?.resolve()),ze=null}#o(o,e){o.f^=Re;for(var t=o.first;t!==null;){var r=t.f,i=(r&($e|ft))!==0,s=i&&(r&Re)!==0,l=s||(r&Me)!==0||this.skipped_effects.has(t);if((t.f&ni)!==0&&t.b?.is_pending()&&(e={parent:e,effect:t,effects:[],render_effects:[],block_effects:[]}),!l&&t.fn!==null){i?t.f^=Re:(r&Ci)!==0?e.effects.push(t):Yt(t)&&((t.f&Je)!==0&&e.block_effects.push(t),Kt(t));var a=t.first;if(a!==null){t=a;continue}}var u=t.parent;for(t=t.next;t===null&&u!==null;)u===e.effect&&(this.#a(e.effects),this.#a(e.render_effects),this.#a(e.block_effects),e=e.parent),t=u.next,u=u.parent}}#a(o){for(const e of o)((e.f&Ie)!==0?this.#s:this.#n).push(e),this.#u(e.deps),Ce(e,Re)}#u(o){if(o!==null)for(const e of o)(e.f&Ee)===0||(e.f>)===0||(e.f^=gt,this.#u(e.deps))}capture(o,e){this.previous.has(o)||this.previous.set(o,e),(o.f&ot)===0&&(this.current.set(o,o.v),ze?.set(o,o.v))}activate(){ae=this,this.apply()}deactivate(){ae===this&&(ae=null,ze=null)}flush(){if(this.activate(),We.length>0){if(Rs(),ae!==null&&ae!==this)return}else this.#r===0&&this.process([]);this.deactivate()}discard(){for(const o of this.#t)o(this);this.#t.clear()}#h(){if(this.#i===0){for(const o of this.#e)o();this.#e.clear()}this.#r===0&&this.#c()}#c(){if(si.size>1){this.previous.clear();var o=ze,e=!0,t={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const i of si){if(i===this){e=!1;continue}const s=[];for(const[a,u]of this.current){if(i.current.has(a))if(e&&u!==i.current.get(a))i.current.set(a,u);else continue;s.push(a)}if(s.length===0)continue;const l=[...i.current.keys()].filter(a=>!this.current.has(a));if(l.length>0){var r=We;We=[];const a=new Set,u=new Map;for(const h of s)gr(h,l,a,u);if(We.length>0){ae=i,i.apply();for(const h of We)i.#o(h,t);i.deactivate()}We=r}}ae=null,ze=o}this.committed=!0,si.delete(this)}increment(o){this.#r+=1,o&&(this.#i+=1)}decrement(o){this.#r-=1,o&&(this.#i-=1),this.revive()}revive(){for(const o of this.#s)Ce(o,Ie),wt(o);for(const o of this.#n)Ce(o,et),wt(o);this.#s=[],this.#n=[],this.flush()}oncommit(o){this.#e.add(o)}ondiscard(o){this.#t.add(o)}settled(){return(this.#l??=sr()).promise}static ensure(){if(ae===null){const o=ae=new Ve;si.add(ae),Ve.enqueue(()=>{ae===o&&o.flush()})}return ae}static enqueue(o){vt(o)}apply(){}}function Rs(){var n=Tt;Bi=!0;var o=null;try{var e=0;for(di(!0);We.length>0;){var t=Ve.ensure();if(e++>1e3){var r,i;Cs()}t.process(We),at.clear()}}finally{Bi=!1,di(n),Mi=null}}function Cs(){try{ts()}catch(n){Ot(n,Mi)}}let rt=null;function pr(n){var o=n.length;if(o!==0){for(var e=0;e<o;){var t=n[e++];if((t.f&(tt|Me))===0&&Yt(t)&&(rt=new Set,Kt(t),t.deps===null&&t.first===null&&t.nodes===null&&(t.teardown===null&&t.ac===null?Hr(t):t.fn=null),rt?.size>0)){at.clear();for(const r of rt){if((r.f&(tt|Me))!==0)continue;const i=[r];let s=r.parent;for(;s!==null;)rt.has(s)&&(rt.delete(s),i.push(s)),s=s.parent;for(let l=i.length-1;l>=0;l--){const a=i[l];(a.f&(tt|Me))===0&&Kt(a)}}rt.clear()}}rt=null}}function gr(n,o,e,t){if(!e.has(n)&&(e.add(n),n.reactions!==null))for(const r of n.reactions){const i=r.f;(i&Ee)!==0?gr(r,o,e,t):(i&(Oi|Je))!==0&&(i&Ie)===0&&mr(r,o,t)&&(Ce(r,Ie),wt(r))}}function mr(n,o,e){const t=e.get(n);if(t!==void 0)return t;if(n.deps!==null)for(const r of n.deps){if(o.includes(r))return!0;if((r.f&Ee)!==0&&mr(r,o,e))return e.set(r,!0),!0}return e.set(n,!1),!1}function wt(n){for(var o=Mi=n;o.parent!==null;){o=o.parent;var e=o.f;if(Bi&&o===ne&&(e&Je)!==0&&(e&lr)===0)return;if((e&(ft|$e))!==0){if((e&Re)===0)return;o.f^=Re}}We.push(o)}function Ds(n){let o=0,e=yt(0),t;return()=>{Gt()&&(b(e),Fr(()=>(o===0&&(t=pi(()=>n(()=>Wt(e)))),o+=1,()=>{vt(()=>{o-=1,o===0&&(t?.(),t=void 0,Wt(e))})})))}}var As=pt|Ct|ni;function Is(n,o,e){new Os(n,o,e)}class Os{parent;#e=!1;#t;#r=null;#i;#l;#s;#n=null;#o=null;#a=null;#u=null;#h=null;#c=0;#d=0;#p=!1;#f=null;#y=Ds(()=>(this.#f=yt(this.#c),()=>{this.#f=null}));constructor(o,e,t){this.#t=o,this.#i=e,this.#l=t,this.parent=ne.b,this.#e=!!this.#i.pending,this.#s=ci(()=>{ne.b=this;{var r=this.#v();try{this.#n=Oe(()=>t(r))}catch(i){this.error(i)}this.#d>0?this.#m():this.#e=!1}return()=>{this.#h?.remove()}},As)}#_(){try{this.#n=Oe(()=>this.#l(this.#t))}catch(o){this.error(o)}this.#e=!1}#T(){const o=this.#i.pending;o&&(this.#o=Oe(()=>o(this.#t)),Ve.enqueue(()=>{var e=this.#v();this.#n=this.#g(()=>(Ve.ensure(),Oe(()=>this.#l(e)))),this.#d>0?this.#m():(_t(this.#o,()=>{this.#o=null}),this.#e=!1)}))}#v(){var o=this.#t;return this.#e&&(this.#h=ut(),this.#t.before(this.#h),o=this.#h),o}is_pending(){return this.#e||!!this.parent&&this.parent.is_pending()}has_pending_snippet(){return!!this.#i.pending}#g(o){var e=ne,t=ee,r=De;qe(this.#s),Fe(this.#s),At(this.#s.ctx);try{return o()}catch(i){return fr(i),null}finally{qe(e),Fe(t),At(r)}}#m(){const o=this.#i.pending;this.#n!==null&&(this.#u=document.createDocumentFragment(),this.#u.append(this.#h),Nr(this.#n,this.#u)),this.#o===null&&(this.#o=Oe(()=>o(this.#t)))}#w(o){if(!this.has_pending_snippet()){this.parent&&this.parent.#w(o);return}this.#d+=o,this.#d===0&&(this.#e=!1,this.#o&&_t(this.#o,()=>{this.#o=null}),this.#u&&(this.#t.before(this.#u),this.#u=null))}update_pending_count(o){this.#w(o),this.#c+=o,this.#f&&Ft(this.#f,this.#c)}get_effect_pending(){return this.#y(),b(this.#f)}error(o){var e=this.#i.onerror;let t=this.#i.failed;if(this.#p||!e&&!t)throw o;this.#n&&(Pe(this.#n),this.#n=null),this.#o&&(Pe(this.#o),this.#o=null),this.#a&&(Pe(this.#a),this.#a=null);var r=!1,i=!1;const s=()=>{if(r){_s();return}r=!0,i&&os(),Ve.ensure(),this.#c=0,this.#a!==null&&_t(this.#a,()=>{this.#a=null}),this.#e=this.has_pending_snippet(),this.#n=this.#g(()=>(this.#p=!1,Oe(()=>this.#l(this.#t)))),this.#d>0?this.#m():this.#e=!1};var l=ee;try{Fe(null),i=!0,e?.(o,s),i=!1}catch(a){Ot(a,this.#s&&this.#s.parent)}finally{Fe(l)}t&&vt(()=>{this.#a=this.#g(()=>{Ve.ensure(),this.#p=!0;try{return Oe(()=>{t(this.#t,()=>o,()=>s)})}catch(a){return Ot(a,this.#s.parent),null}finally{this.#p=!1}})})}}function vr(n,o,e,t){const r=li;if(e.length===0&&n.length===0){t(o.map(r));return}var i=ae,s=ne,l=Fs();function a(){Promise.all(e.map(u=>Ls(u))).then(u=>{l();try{t([...o.map(r),...u])}catch(h){(s.f&tt)===0&&Ot(h,s)}i?.deactivate(),ai()}).catch(u=>{Ot(u,s)})}n.length>0?Promise.all(n).then(()=>{l();try{return a()}finally{i?.deactivate(),ai()}}):a()}function Fs(){var n=ne,o=ee,e=De,t=ae;return function(i=!0){qe(n),Fe(o),At(e),i&&t?.activate()}}function ai(){qe(null),Fe(null),At(null)}function li(n){var o=Ee|Ie,e=ee!==null&&(ee.f&Ee)!==0?ee:null;return ne!==null&&(ne.f|=Ct),{ctx:De,deps:null,effects:null,equals:hr,f:o,fn:n,reactions:null,rv:0,v:be,wv:0,parent:e??ne,ac:null}}function Ls(n,o){let e=ne;e===null&&Qn();var t=e.b,r=void 0,i=yt(be),s=!ee,l=new Map;return Zs(()=>{var a=sr();r=a.promise;try{Promise.resolve(n()).then(a.resolve,a.reject).then(()=>{u===ae&&u.committed&&u.deactivate(),ai()})}catch(d){a.reject(d),ai()}var u=ae;if(s){var h=!t.is_pending();t.update_pending_count(1),u.increment(h),l.get(u)?.reject(Dt),l.delete(u),l.set(u,a)}const c=(d,m=void 0)=>{if(u.activate(),m)m!==Dt&&(i.f|=ot,Ft(i,m));else{(i.f&ot)!==0&&(i.f^=ot),Ft(i,d);for(const[v,y]of l){if(l.delete(v),v===u)break;y.reject(Dt)}}s&&(t.update_pending_count(-1),u.decrement(h))};a.promise.then(c,d=>c(null,d||"unknown"))}),Ir(()=>{for(const a of l.values())a.reject(Dt)}),new Promise(a=>{function u(h){function c(){h===r?a(i):u(r)}h.then(c,c)}u(r)})}function le(n){const o=li(n);return Wr(o),o}function wr(n){const o=li(n);return o.equals=cr,o}function yr(n){var o=n.effects;if(o!==null){n.effects=null;for(var e=0;e<o.length;e+=1)Pe(o[e])}}function Ms(n){for(var o=n.parent;o!==null;){if((o.f&Ee)===0)return(o.f&tt)===0?o:null;o=o.parent}return null}function Hi(n){var o,e=ne;qe(Ms(n));try{n.f&=~gt,yr(n),o=Zr(n)}finally{qe(e)}return o}function _r(n){var o=Hi(n);if(n.equals(o)||(ae?.is_fork||(n.v=o),n.wv=Gr()),!xt)if(ze!==null)(Gt()||ae?.is_fork)&&ze.set(n,o);else{var e=(n.f&Ne)===0?et:Re;Ce(n,e)}}let zi=new Set;const at=new Map;let Tr=!1;function yt(n,o){var e={f:0,v:n,reactions:null,equals:hr,rv:0,wv:0};return e}function ue(n,o){const e=yt(n);return Wr(e),e}function Bs(n,o=!1,e=!0){const t=yt(n);return o||(t.equals=cr),t}function G(n,o,e=!1){ee!==null&&(!Ge||(ee.f&ar)!==0)&&dr()&&(ee.f&(Ee|Je|Oi|ar))!==0&&!nt?.includes(n)&&ss();let t=e?lt(o):o;return Ft(n,t)}function Ft(n,o){if(!n.equals(o)){var e=n.v;xt?at.set(n,o):at.set(n,e),n.v=o;var t=Ve.ensure();t.capture(n,e),(n.f&Ee)!==0&&((n.f&Ie)!==0&&Hi(n),Ce(n,(n.f&Ne)!==0?Re:et)),n.wv=Gr(),Er(n,Ie),ne!==null&&(ne.f&Re)!==0&&(ne.f&($e|ft))===0&&(ke===null?Ks([n]):ke.push(n)),!t.is_fork&&zi.size>0&&!Tr&&Hs()}return o}function Hs(){Tr=!1;var n=Tt;di(!0);const o=Array.from(zi);try{for(const e of o)(e.f&Re)!==0&&Ce(e,et),Yt(e)&&Kt(e)}finally{di(n)}zi.clear()}function xr(n,o=1){var e=b(n),t=o===1?e++:e--;return G(n,e),t}function Wt(n){G(n,n.v+1)}function Er(n,o){var e=n.reactions;if(e!==null)for(var t=e.length,r=0;r<t;r++){var i=e[r],s=i.f,l=(s&Ie)===0;if(l&&Ce(i,o),(s&Ee)!==0){var a=i;ze?.delete(a),(s>)===0&&(s&Ne&&(i.f|=gt),Er(a,et))}else l&&((s&Je)!==0&&rt!==null&&rt.add(i),wt(i))}}function lt(n){if(typeof n!="object"||n===null||mt in n)return n;const o=ir(n);if(o!==jn&&o!==Gn)return n;var e=new Map,t=Ri(n),r=ue(0),i=Et,s=l=>{if(Et===i)return l();var a=ee,u=Et;Fe(null),jr(i);var h=l();return Fe(a),jr(u),h};return t&&e.set("length",ue(n.length)),new Proxy(n,{defineProperty(l,a,u){(!("value"in u)||u.configurable===!1||u.enumerable===!1||u.writable===!1)&&rs();var h=e.get(a);return h===void 0?h=s(()=>{var c=ue(u.value);return e.set(a,c),c}):G(h,u.value,!0),!0},deleteProperty(l,a){var u=e.get(a);if(u===void 0){if(a in l){const h=s(()=>ue(be));e.set(a,h),Wt(r)}}else G(u,be),Wt(r);return!0},get(l,a,u){if(a===mt)return n;var h=e.get(a),c=a in l;if(h===void 0&&(!c||Rt(l,a)?.writable)&&(h=s(()=>{var m=lt(c?l[a]:be),v=ue(m);return v}),e.set(a,h)),h!==void 0){var d=b(h);return d===be?void 0:d}return Reflect.get(l,a,u)},getOwnPropertyDescriptor(l,a){var u=Reflect.getOwnPropertyDescriptor(l,a);if(u&&"value"in u){var h=e.get(a);h&&(u.value=b(h))}else if(u===void 0){var c=e.get(a),d=c?.v;if(c!==void 0&&d!==be)return{enumerable:!0,configurable:!0,value:d,writable:!0}}return u},has(l,a){if(a===mt)return!0;var u=e.get(a),h=u!==void 0&&u.v!==be||Reflect.has(l,a);if(u!==void 0||ne!==null&&(!h||Rt(l,a)?.writable)){u===void 0&&(u=s(()=>{var d=h?lt(l[a]):be,m=ue(d);return m}),e.set(a,u));var c=b(u);if(c===be)return!1}return h},set(l,a,u,h){var c=e.get(a),d=a in l;if(t&&a==="length")for(var m=u;m<c.v;m+=1){var v=e.get(m+"");v!==void 0?G(v,be):m in l&&(v=s(()=>ue(be)),e.set(m+"",v))}if(c===void 0)(!d||Rt(l,a)?.writable)&&(c=s(()=>ue(void 0)),G(c,lt(u)),e.set(a,c));else{d=c.v!==be;var y=s(()=>lt(u));G(c,y)}var _=Reflect.getOwnPropertyDescriptor(l,a);if(_?.set&&_.set.call(h,u),!d){if(t&&typeof a=="string"){var E=e.get("length"),S=Number(a);Number.isInteger(S)&&S>=E.v&&G(E,S+1)}Wt(r)}return!0},ownKeys(l){b(r);var a=Reflect.ownKeys(l).filter(c=>{var d=e.get(c);return d===void 0||d.v!==be});for(var[u,h]of e)h.v!==be&&!(u in l)&&a.push(u);return a},setPrototypeOf(){ns()}})}function br(n){try{if(n!==null&&typeof n=="object"&&mt in n)return n[mt]}catch{}return n}function zs(n,o){return Object.is(br(n),br(o))}var Sr,Pr,Rr,Cr;function ks(){if(Sr===void 0){Sr=window,Pr=/Firefox/.test(navigator.userAgent);var n=Element.prototype,o=Node.prototype,e=Text.prototype;Rr=Rt(o,"firstChild").get,Cr=Rt(o,"nextSibling").get,rr(n)&&(n.__click=void 0,n.__className=void 0,n.__attributes=null,n.__style=void 0,n.__e=void 0),rr(e)&&(e.__t=void 0)}}function ut(n=""){return document.createTextNode(n)}function ui(n){return Rr.call(n)}function Vt(n){return Cr.call(n)}function $(n,o){return ui(n)}function jt(n,o=!1){{var e=ui(n);return e instanceof Comment&&e.data===""?Vt(e):e}}function _e(n,o=1,e=!1){let t=n;for(;o--;)t=Vt(t);return t}function Ns(n){n.textContent=""}function Dr(){return!1}function Us(n,o){if(o){const e=document.body;n.autofocus=!0,vt(()=>{document.activeElement===e&&n.focus()})}}let Ar=!1;function Ws(){Ar||(Ar=!0,document.addEventListener("reset",n=>{Promise.resolve().then(()=>{if(!n.defaultPrevented)for(const o of n.target.elements)o.__on_r?.()})},{capture:!0}))}function hi(n){var o=ee,e=ne;Fe(null),qe(null);try{return n()}finally{Fe(o),qe(e)}}function Vs(n,o,e,t=e){n.addEventListener(o,()=>hi(e));const r=n.__on_r;r?n.__on_r=()=>{r(),t(!0)}:n.__on_r=()=>t(!0),Ws()}function js(n){ne===null&&(ee===null&&es(),$n()),xt&&Jn()}function Gs(n,o){var e=o.last;e===null?o.last=o.first=n:(e.next=n,n.prev=e,o.last=n)}function je(n,o,e){var t=ne;t!==null&&(t.f&Me)!==0&&(n|=Me);var r={ctx:De,deps:null,nodes:null,f:n|Ie|Ne,first:null,fn:o,last:null,next:null,parent:t,b:t&&t.b,prev:null,teardown:null,wv:0,ac:null};if(e)try{Kt(r),r.f|=Ai}catch(l){throw Pe(r),l}else o!==null&&wt(r);var i=r;if(e&&i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&Ct)===0&&(i=i.first,(n&Je)!==0&&(n&pt)!==0&&i!==null&&(i.f|=pt)),i!==null&&(i.parent=t,t!==null&&Gs(i,t),ee!==null&&(ee.f&Ee)!==0&&(n&ft)===0)){var s=ee;(s.effects??=[]).push(i)}return r}function Gt(){return ee!==null&&!Ge}function Ir(n){const o=je(Di,null,!1);return Ce(o,Re),o.teardown=n,o}function qt(n){js();var o=ne.f,e=!ee&&(o&$e)!==0&&(o&Ai)===0;if(e){var t=De;(t.e??=[]).push(n)}else return Or(n)}function Or(n){return je(Ci|Zn,n,!1)}function qs(n){Ve.ensure();const o=je(ft|Ct,n,!0);return(e={})=>new Promise(t=>{e.outro?_t(o,()=>{Pe(o),t(void 0)}):(Pe(o),t(void 0))})}function Zt(n){return je(Ci,n,!1)}function Zs(n){return je(Oi|Ct,n,!0)}function Fr(n,o=0){return je(Di|o,n,!0)}function Se(n,o=[],e=[],t=[]){vr(t,o,e,r=>{je(Di,()=>n(...r.map(b)),!0)})}function ci(n,o=0){var e=je(Je|o,n,!0);return e}function Lr(n,o=0){var e=je(or|o,n,!0);return e}function Oe(n){return je($e|Ct,n,!0)}function Mr(n){var o=n.teardown;if(o!==null){const e=xt,t=ee;Ur(!0),Fe(null);try{o.call(null)}finally{Ur(e),Fe(t)}}}function Br(n,o=!1){var e=n.first;for(n.first=n.last=null;e!==null;){const r=e.ac;r!==null&&hi(()=>{r.abort(Dt)});var t=e.next;(e.f&ft)!==0?e.parent=null:Pe(e,o),e=t}}function Xs(n){for(var o=n.first;o!==null;){var e=o.next;(o.f&$e)===0&&Pe(o),o=e}}function Pe(n,o=!0){var e=!1;(o||(n.f&lr)!==0)&&n.nodes!==null&&n.nodes.end!==null&&(Ys(n.nodes.start,n.nodes.end),e=!0),Br(n,o&&!e),fi(n,0),Ce(n,tt);var t=n.nodes&&n.nodes.t;if(t!==null)for(const i of t)i.stop();Mr(n);var r=n.parent;r!==null&&r.first!==null&&Hr(n),n.next=n.prev=n.teardown=n.ctx=n.deps=n.fn=n.nodes=n.ac=null}function Ys(n,o){for(;n!==null;){var e=n===o?null:Vt(n);n.remove(),n=e}}function Hr(n){var o=n.parent,e=n.prev,t=n.next;e!==null&&(e.next=t),t!==null&&(t.prev=e),o!==null&&(o.first===n&&(o.first=t),o.last===n&&(o.last=e))}function _t(n,o,e=!0){var t=[];zr(n,t,!0);var r=()=>{e&&Pe(n),o&&o()},i=t.length;if(i>0){var s=()=>--i||r();for(var l of t)l.out(s)}else r()}function zr(n,o,e){if((n.f&Me)===0){n.f^=Me;var t=n.nodes&&n.nodes.t;if(t!==null)for(const l of t)(l.is_global||e)&&o.push(l);for(var r=n.first;r!==null;){var i=r.next,s=(r.f&pt)!==0||(r.f&$e)!==0&&(n.f&Je)!==0;zr(r,o,s?e:!1),r=i}}}function ki(n){kr(n,!0)}function kr(n,o){if((n.f&Me)!==0){n.f^=Me,(n.f&Re)===0&&(Ce(n,Ie),wt(n));for(var e=n.first;e!==null;){var t=e.next,r=(e.f&pt)!==0||(e.f&$e)!==0;kr(e,r?o:!1),e=t}var i=n.nodes&&n.nodes.t;if(i!==null)for(const s of i)(s.is_global||o)&&s.in()}}function Nr(n,o){if(n.nodes)for(var e=n.nodes.start,t=n.nodes.end;e!==null;){var r=e===t?null:Vt(e);o.append(e),e=r}}let Tt=!1;function di(n){Tt=n}let xt=!1;function Ur(n){xt=n}let ee=null,Ge=!1;function Fe(n){ee=n}let ne=null;function qe(n){ne=n}let nt=null;function Wr(n){ee!==null&&(nt===null?nt=[n]:nt.push(n))}let Ae=null,Be=0,ke=null;function Ks(n){ke=n}let Vr=1,Xt=0,Et=Xt;function jr(n){Et=n}function Gr(){return++Vr}function Yt(n){var o=n.f;if((o&Ie)!==0)return!0;if(o&Ee&&(n.f&=~gt),(o&et)!==0){var e=n.deps;if(e!==null)for(var t=e.length,r=0;r<t;r++){var i=e[r];if(Yt(i)&&_r(i),i.wv>n.wv)return!0}(o&Ne)!==0&&ze===null&&Ce(n,Re)}return!1}function qr(n,o,e=!0){var t=n.reactions;if(t!==null&&!nt?.includes(n))for(var r=0;r<t.length;r++){var i=t[r];(i.f&Ee)!==0?qr(i,o,!1):o===i&&(e?Ce(i,Ie):(i.f&Re)!==0&&Ce(i,et),wt(i))}}function Zr(n){var o=Ae,e=Be,t=ke,r=ee,i=nt,s=De,l=Ge,a=Et,u=n.f;Ae=null,Be=0,ke=null,ee=(u&($e|ft))===0?n:null,nt=null,At(n.ctx),Ge=!1,Et=++Xt,n.ac!==null&&(hi(()=>{n.ac.abort(Dt)}),n.ac=null);try{n.f|=Ii;var h=n.fn,c=h(),d=n.deps;if(Ae!==null){var m;if(fi(n,Be),d!==null&&Be>0)for(d.length=Be+Ae.length,m=0;m<Ae.length;m++)d[Be+m]=Ae[m];else n.deps=d=Ae;if(Gt()&&(n.f&Ne)!==0)for(m=Be;m<d.length;m++)(d[m].reactions??=[]).push(n)}else d!==null&&Be<d.length&&(fi(n,Be),d.length=Be);if(dr()&&ke!==null&&!Ge&&d!==null&&(n.f&(Ee|et|Ie))===0)for(m=0;m<ke.length;m++)qr(ke[m],n);return r!==null&&r!==n&&(Xt++,ke!==null&&(t===null?t=ke:t.push(...ke))),(n.f&ot)!==0&&(n.f^=ot),c}catch(v){return fr(v)}finally{n.f^=Ii,Ae=o,Be=e,ke=t,ee=r,nt=i,At(s),Ge=l,Et=a}}function Qs(n,o){let e=o.reactions;if(e!==null){var t=Un.call(e,n);if(t!==-1){var r=e.length-1;r===0?e=o.reactions=null:(e[t]=e[r],e.pop())}}e===null&&(o.f&Ee)!==0&&(Ae===null||!Ae.includes(o))&&(Ce(o,et),(o.f&Ne)!==0&&(o.f^=Ne,o.f&=~gt),yr(o),fi(o,0))}function fi(n,o){var e=n.deps;if(e!==null)for(var t=o;t<e.length;t++)Qs(n,e[t])}function Kt(n){var o=n.f;if((o&tt)===0){Ce(n,Re);var e=ne,t=Tt;ne=n,Tt=!0;try{(o&(Je|or))!==0?Xs(n):Br(n),Mr(n);var r=Zr(n);n.teardown=typeof r=="function"?r:null,n.wv=Vr;var i;Pi&&xs&&(n.f&Ie)!==0&&n.deps}finally{Tt=t,ne=e}}}function b(n){var o=n.f,e=(o&Ee)!==0;if(ee!==null&&!Ge){var t=ne!==null&&(ne.f&tt)!==0;if(!t&&!nt?.includes(n)){var r=ee.deps;if((ee.f&Ii)!==0)n.rv<Xt&&(n.rv=Xt,Ae===null&&r!==null&&r[Be]===n?Be++:Ae===null?Ae=[n]:Ae.includes(n)||Ae.push(n));else{(ee.deps??=[]).push(n);var i=n.reactions;i===null?n.reactions=[ee]:i.includes(ee)||i.push(ee)}}}if(xt){if(at.has(n))return at.get(n);if(e){var s=n,l=s.v;return((s.f&Re)===0&&s.reactions!==null||Yr(s))&&(l=Hi(s)),at.set(s,l),l}}else e&&(!ze?.has(n)||ae?.is_fork&&!Gt())&&(s=n,Yt(s)&&_r(s),Tt&&Gt()&&(s.f&Ne)===0&&Xr(s));if(ze?.has(n))return ze.get(n);if((n.f&ot)!==0)throw n.v;return n.v}function Xr(n){if(n.deps!==null){n.f^=Ne;for(const o of n.deps)(o.reactions??=[]).push(n),(o.f&Ee)!==0&&(o.f&Ne)===0&&Xr(o)}}function Yr(n){if(n.v===be)return!0;if(n.deps===null)return!1;for(const o of n.deps)if(at.has(o)||(o.f&Ee)!==0&&Yr(o))return!0;return!1}function pi(n){var o=Ge;try{return Ge=!0,n()}finally{Ge=o}}const Js=-7169;function Ce(n,o){n.f=n.f&Js|o}function $s(n){return n.endsWith("capture")&&n!=="gotpointercapture"&&n!=="lostpointercapture"}const eo=["beforeinput","click","change","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"];function to(n){return eo.includes(n)}const io={formnovalidate:"formNoValidate",ismap:"isMap",nomodule:"noModule",playsinline:"playsInline",readonly:"readOnly",defaultvalue:"defaultValue",defaultchecked:"defaultChecked",srcobject:"srcObject",novalidate:"noValidate",allowfullscreen:"allowFullscreen",disablepictureinpicture:"disablePictureInPicture",disableremoteplayback:"disableRemotePlayback"};function ro(n){return n=n.toLowerCase(),io[n]??n}const no=["touchstart","touchmove"];function so(n){return no.includes(n)}const Kr=new Set,Ni=new Set;function oo(n,o,e,t={}){function r(i){if(t.capture||Qt.call(o,i),!i.cancelBubble)return hi(()=>e?.call(this,i))}return n.startsWith("pointer")||n.startsWith("touch")||n==="wheel"?vt(()=>{o.addEventListener(n,r,t)}):o.addEventListener(n,r,t),r}function Qr(n){for(var o=0;o<n.length;o++)Kr.add(n[o]);for(var e of Ni)e(n)}let Jr=null;function Qt(n){var o=this,e=o.ownerDocument,t=n.type,r=n.composedPath?.()||[],i=r[0]||n.target;Jr=n;var s=0,l=Jr===n&&n.__root;if(l){var a=r.indexOf(l);if(a!==-1&&(o===document||o===window)){n.__root=o;return}var u=r.indexOf(o);if(u===-1)return;a<=u&&(s=a)}if(i=r[s]||n.target,i!==o){Wn(n,"currentTarget",{configurable:!0,get(){return i||e}});var h=ee,c=ne;Fe(null),qe(null);try{for(var d,m=[];i!==null;){var v=i.assignedSlot||i.parentNode||i.host||null;try{var y=i["__"+t];y!=null&&(!i.disabled||n.target===i)&&y.call(i,n)}catch(_){d?m.push(_):d=_}if(n.cancelBubble||v===o||v===null)break;i=v}if(d){for(let _ of m)queueMicrotask(()=>{throw _});throw d}}finally{n.__root=o,delete n.currentTarget,Fe(h),qe(c)}}}function ao(n){var o=document.createElement("template");return o.innerHTML=n.replaceAll("<!>","<!---->"),o.content}function Ui(n,o){var e=ne;e.nodes===null&&(e.nodes={start:n,end:o,a:null,t:null})}function me(n,o){var e=(o&gs)!==0,t=(o&ms)!==0,r,i=!n.startsWith("<!>");return()=>{r===void 0&&(r=ao(i?n:"<!>"+n),e||(r=ui(r)));var s=t||Pr?document.importNode(r,!0):r.cloneNode(!0);if(e){var l=ui(s),a=s.lastChild;Ui(l,a)}else Ui(s,s);return s}}function $r(){var n=document.createDocumentFragment(),o=document.createComment(""),e=ut();return n.append(o,e),Ui(o,e),n}function ge(n,o){n!==null&&n.before(o)}function Te(n,o){var e=o==null?"":typeof o=="object"?o+"":o;e!==(n.__t??=n.nodeValue)&&(n.__t=e,n.nodeValue=e+"")}function lo(n,o){return uo(n,o)}const Lt=new Map;function uo(n,{target:o,anchor:e,props:t={},events:r,context:i,intro:s=!0}){ks();var l=new Set,a=c=>{for(var d=0;d<c.length;d++){var m=c[d];if(!l.has(m)){l.add(m);var v=so(m);o.addEventListener(m,Qt,{passive:v});var y=Lt.get(m);y===void 0?(document.addEventListener(m,Qt,{passive:v}),Lt.set(m,1)):Lt.set(m,y+1)}}};a(ri(Kr)),Ni.add(a);var u=void 0,h=qs(()=>{var c=e??o.appendChild(ut());return Is(c,{pending:()=>{}},d=>{if(i){Fi({});var m=De;m.c=i}r&&(t.$$events=r),u=n(d,t)||{},i&&Li()}),()=>{for(var d of l){o.removeEventListener(d,Qt);var m=Lt.get(d);--m===0?(document.removeEventListener(d,Qt),Lt.delete(d)):Lt.set(d,m)}Ni.delete(a),c!==e&&c.parentNode?.removeChild(c)}});return Wi.set(u,h),u}let Wi=new WeakMap;function ho(n,o){const e=Wi.get(n);return e?(Wi.delete(n),e(o)):Promise.resolve()}class en{anchor;#e=new Map;#t=new Map;#r=new Map;#i=new Set;#l=!0;constructor(o,e=!0){this.anchor=o,this.#l=e}#s=()=>{var o=ae;if(this.#e.has(o)){var e=this.#e.get(o),t=this.#t.get(e);if(t)ki(t),this.#i.delete(e);else{var r=this.#r.get(e);r&&(this.#t.set(e,r.effect),this.#r.delete(e),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),t=r.effect)}for(const[i,s]of this.#e){if(this.#e.delete(i),i===o)break;const l=this.#r.get(s);l&&(Pe(l.effect),this.#r.delete(s))}for(const[i,s]of this.#t){if(i===e||this.#i.has(i))continue;const l=()=>{if(Array.from(this.#e.values()).includes(i)){var u=document.createDocumentFragment();Nr(s,u),u.append(ut()),this.#r.set(i,{effect:s,fragment:u})}else Pe(s);this.#i.delete(i),this.#t.delete(i)};this.#l||!t?(this.#i.add(i),_t(s,l,!1)):l()}}};#n=o=>{this.#e.delete(o);const e=Array.from(this.#e.values());for(const[t,r]of this.#r)e.includes(t)||(Pe(r.effect),this.#r.delete(t))};ensure(o,e){var t=ae,r=Dr();if(e&&!this.#t.has(o)&&!this.#r.has(o))if(r){var i=document.createDocumentFragment(),s=ut();i.append(s),this.#r.set(o,{effect:Oe(()=>e(s)),fragment:i})}else this.#t.set(o,Oe(()=>e(this.anchor)));if(this.#e.set(t,o),r){for(const[l,a]of this.#t)l===o?t.skipped_effects.delete(a):t.skipped_effects.add(a);for(const[l,a]of this.#r)l===o?t.skipped_effects.delete(a.effect):t.skipped_effects.add(a.effect);t.oncommit(this.#s),t.ondiscard(this.#n)}else this.#s()}}function st(n,o,e=!1){var t=new en(n),r=e?pt:0;function i(s,l){t.ensure(s,l)}ci(()=>{var s=!1;o((l,a=!0)=>{s=!0,i(a,l)}),s||i(!1,null)},r)}function Vi(n,o){return o}function co(n,o,e){for(var t=[],r=o.length,i,s=o.length,l=0;l<r;l++){let c=o[l];_t(c,()=>{if(i){if(i.pending.delete(c),i.done.add(c),i.pending.size===0){var d=n.outrogroups;ji(ri(i.done)),d.delete(i),d.size===0&&(n.outrogroups=null)}}else s-=1},!1)}if(s===0){var a=t.length===0&&e!==null;if(a){var u=e,h=u.parentNode;Ns(h),h.append(u),n.items.clear()}ji(o,!a)}else i={pending:new Set(o),done:new Set},(n.outrogroups??=new Set).add(i)}function ji(n,o=!0){for(var e=0;e<n.length;e++)Pe(n[e],o)}var tn;function gi(n,o,e,t,r,i=null){var s=n,l=new Map,a=(o&ur)!==0;if(a){var u=n;s=u.appendChild(ut())}var h=null,c=wr(()=>{var E=e();return Ri(E)?E:E==null?[]:ri(E)}),d,m=!0;function v(){_.fallback=h,fo(_,d,s,o,t),h!==null&&(d.length===0?(h.f&it)===0?ki(h):(h.f^=it,Jt(h,null,s)):_t(h,()=>{h=null}))}var y=ci(()=>{d=b(c);for(var E=d.length,S=new Set,P=ae,L=Dr(),F=0;F<E;F+=1){var H=d[F],B=t(H,F),V=m?null:l.get(B);V?(V.v&&Ft(V.v,H),V.i&&Ft(V.i,F),L&&P.skipped_effects.delete(V.e)):(V=po(l,m?s:tn??=ut(),H,B,F,r,o,e),m||(V.e.f|=it),l.set(B,V)),S.add(B)}if(E===0&&i&&!h&&(m?h=Oe(()=>i(s)):(h=Oe(()=>i(tn??=ut())),h.f|=it)),!m)if(L){for(const[Y,J]of l)S.has(Y)||P.skipped_effects.add(J.e);P.oncommit(v),P.ondiscard(()=>{})}else v();b(c)}),_={effect:y,items:l,outrogroups:null,fallback:h};m=!1}function fo(n,o,e,t,r){var i=(t&us)!==0,s=o.length,l=n.items,a=n.effect.first,u,h=null,c,d=[],m=[],v,y,_,E;if(i)for(E=0;E<s;E+=1)v=o[E],y=r(v,E),_=l.get(y).e,(_.f&it)===0&&(_.nodes?.a?.measure(),(c??=new Set).add(_));for(E=0;E<s;E+=1){if(v=o[E],y=r(v,E),_=l.get(y).e,n.outrogroups!==null)for(const J of n.outrogroups)J.pending.delete(_),J.done.delete(_);if((_.f&it)!==0)if(_.f^=it,_===a)Jt(_,null,e);else{var S=h?h.next:a;_===n.effect.last&&(n.effect.last=_.prev),_.prev&&(_.prev.next=_.next),_.next&&(_.next.prev=_.prev),ht(n,h,_),ht(n,_,S),Jt(_,S,e),h=_,d=[],m=[],a=h.next;continue}if((_.f&Me)!==0&&(ki(_),i&&(_.nodes?.a?.unfix(),(c??=new Set).delete(_))),_!==a){if(u!==void 0&&u.has(_)){if(d.length<m.length){var P=m[0],L;h=P.prev;var F=d[0],H=d[d.length-1];for(L=0;L<d.length;L+=1)Jt(d[L],P,e);for(L=0;L<m.length;L+=1)u.delete(m[L]);ht(n,F.prev,H.next),ht(n,h,F),ht(n,H,P),a=P,h=H,E-=1,d=[],m=[]}else u.delete(_),Jt(_,a,e),ht(n,_.prev,_.next),ht(n,_,h===null?n.effect.first:h.next),ht(n,h,_),h=_;continue}for(d=[],m=[];a!==null&&a!==_;)(u??=new Set).add(a),m.push(a),a=a.next;if(a===null)continue}(_.f&it)===0&&d.push(_),h=_,a=_.next}if(n.outrogroups!==null){for(const J of n.outrogroups)J.pending.size===0&&(ji(ri(J.done)),n.outrogroups?.delete(J));n.outrogroups.size===0&&(n.outrogroups=null)}if(a!==null||u!==void 0){var B=[];if(u!==void 0)for(_ of u)(_.f&Me)===0&&B.push(_);for(;a!==null;)(a.f&Me)===0&&a!==n.fallback&&B.push(a),a=a.next;var V=B.length;if(V>0){var Y=(t&ur)!==0&&s===0?e:null;if(i){for(E=0;E<V;E+=1)B[E].nodes?.a?.measure();for(E=0;E<V;E+=1)B[E].nodes?.a?.fix()}co(n,B,Y)}}i&&vt(()=>{if(c!==void 0)for(_ of c)_.nodes?.a?.apply()})}function po(n,o,e,t,r,i,s,l){var a=(s&as)!==0?(s&hs)===0?Bs(e,!1,!1):yt(e):null,u=(s&ls)!==0?yt(r):null;return{v:a,i:u,e:Oe(()=>(i(o,a??e,u??r,l),()=>{n.delete(t)}))}}function Jt(n,o,e){if(n.nodes)for(var t=n.nodes.start,r=n.nodes.end,i=o&&(o.f&it)===0?o.nodes.start:e;t!==null;){var s=Vt(t);if(i.before(t),t===r)return;t=s}}function ht(n,o,e){o===null?n.effect.first=e:o.next=e,e===null?n.effect.last=o:e.prev=o}function rn(n,o,...e){var t=new en(n);ci(()=>{const r=o()??null;t.ensure(r,r&&(i=>r(i,...e)))},pt)}function go(n,o,e){Zt(()=>{var t=pi(()=>o(n,e?.())||{});if(t?.destroy)return()=>t.destroy()})}function mo(n,o){var e=void 0,t;Lr(()=>{e!==(e=o())&&(t&&(Pe(t),t=null),e&&(t=Oe(()=>{Zt(()=>e(n))})))})}function nn(n){var o,e,t="";if(typeof n=="string"||typeof n=="number")t+=n;else if(typeof n=="object")if(Array.isArray(n)){var r=n.length;for(o=0;o<r;o++)n[o]&&(e=nn(n[o]))&&(t&&(t+=" "),t+=e)}else for(e in n)n[e]&&(t&&(t+=" "),t+=e);return t}function vo(){for(var n,o,e=0,t="",r=arguments.length;e<r;e++)(n=arguments[e])&&(o=nn(n))&&(t&&(t+=" "),t+=o);return t}function wo(n){return typeof n=="object"?vo(n):n??""}const sn=[...`
|
|
2
|
+
\r\f \v\uFEFF`];function yo(n,o,e){var t=n==null?"":""+n;if(o&&(t=t?t+" "+o:o),e){for(var r in e)if(e[r])t=t?t+" "+r:r;else if(t.length)for(var i=r.length,s=0;(s=t.indexOf(r,s))>=0;){var l=s+i;(s===0||sn.includes(t[s-1]))&&(l===t.length||sn.includes(t[l]))?t=(s===0?"":t.substring(0,s))+t.substring(l+1):s=l}}return t===""?null:t}function on(n,o=!1){var e=o?" !important;":";",t="";for(var r in n){var i=n[r];i!=null&&i!==""&&(t+=" "+r+": "+i+e)}return t}function Gi(n){return n[0]!=="-"||n[1]!=="-"?n.toLowerCase():n}function _o(n,o){if(o){var e="",t,r;if(Array.isArray(o)?(t=o[0],r=o[1]):t=o,n){n=String(n).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var i=!1,s=0,l=!1,a=[];t&&a.push(...Object.keys(t).map(Gi)),r&&a.push(...Object.keys(r).map(Gi));var u=0,h=-1;const y=n.length;for(var c=0;c<y;c++){var d=n[c];if(l?d==="/"&&n[c-1]==="*"&&(l=!1):i?i===d&&(i=!1):d==="/"&&n[c+1]==="*"?l=!0:d==='"'||d==="'"?i=d:d==="("?s++:d===")"&&s--,!l&&i===!1&&s===0){if(d===":"&&h===-1)h=c;else if(d===";"||c===y-1){if(h!==-1){var m=Gi(n.substring(u,h).trim());if(!a.includes(m)){d!==";"&&c++;var v=n.substring(u,c).trim();e+=" "+v+";"}}u=c+1,h=-1}}}}return t&&(e+=on(t)),r&&(e+=on(r,!0)),e=e.trim(),e===""?null:e}return n==null?null:String(n)}function $t(n,o,e,t,r,i){var s=n.__className;if(s!==e||s===void 0){var l=yo(e,t,i);l==null?n.removeAttribute("class"):o?n.className=l:n.setAttribute("class",l),n.__className=e}else if(i&&r!==i)for(var a in i){var u=!!i[a];(r==null||u!==!!r[a])&&n.classList.toggle(a,u)}return i}function qi(n,o={},e,t){for(var r in e){var i=e[r];o[r]!==i&&(e[r]==null?n.style.removeProperty(r):n.style.setProperty(r,i,t))}}function Zi(n,o,e,t){var r=n.__style;if(r!==o){var i=_o(o,t);i==null?n.removeAttribute("style"):n.style.cssText=i,n.__style=o}else t&&(Array.isArray(t)?(qi(n,e?.[0],t[0]),qi(n,e?.[1],t[1],"important")):qi(n,e,t));return t}function mi(n,o,e=!1){if(n.multiple){if(o==null)return;if(!Ri(o))return ys();for(var t of n.options)t.selected=o.includes(ei(t));return}for(t of n.options){var r=ei(t);if(zs(r,o)){t.selected=!0;return}}(!e||o!==void 0)&&(n.selectedIndex=-1)}function an(n){var o=new MutationObserver(()=>{mi(n,n.__value)});o.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Ir(()=>{o.disconnect()})}function To(n,o,e=o){var t=new WeakSet,r=!0;Vs(n,"change",i=>{var s=i?"[selected]":":checked",l;if(n.multiple)l=[].map.call(n.querySelectorAll(s),ei);else{var a=n.querySelector(s)??n.querySelector("option:not([disabled])");l=a&&ei(a)}e(l),ae!==null&&t.add(ae)}),Zt(()=>{var i=o();if(n===document.activeElement){var s=oi??ae;if(t.has(s))return}if(mi(n,i,r),r&&i===void 0){var l=n.querySelector(":checked");l!==null&&(i=ei(l),e(i))}n.__value=i,r=!1}),an(n)}function ei(n){return"__value"in n?n.__value:n.value}const Mt=Symbol("class"),ti=Symbol("style"),ln=Symbol("is custom element"),un=Symbol("is html");function xo(n,o){o?n.hasAttribute("selected")||n.setAttribute("selected",""):n.removeAttribute("selected")}function Ze(n,o,e,t){var r=cn(n);r[o]!==(r[o]=e)&&(o==="loading"&&(n[Yn]=e),e==null?n.removeAttribute(o):typeof e!="string"&&fn(n).includes(o)?n[o]=e:n.setAttribute(o,e))}function Eo(n,o,e,t,r=!1,i=!1){var s=cn(n),l=s[ln],a=!s[un],u=o||{},h=n.tagName==="OPTION";for(var c in o)c in e||(e[c]=null);e.class?e.class=wo(e.class):(t||e[Mt])&&(e.class=null),e[ti]&&(e.style??=null);var d=fn(n);for(const P in e){let L=e[P];if(h&&P==="value"&&L==null){n.value=n.__value="",u[P]=L;continue}if(P==="class"){var m=n.namespaceURI==="http://www.w3.org/1999/xhtml";$t(n,m,L,t,o?.[Mt],e[Mt]),u[P]=L,u[Mt]=e[Mt];continue}if(P==="style"){Zi(n,L,o?.[ti],e[ti]),u[P]=L,u[ti]=e[ti];continue}var v=u[P];if(!(L===v&&!(L===void 0&&n.hasAttribute(P)))){u[P]=L;var y=P[0]+P[1];if(y!=="$$")if(y==="on"){const F={},H="$$"+P;let B=P.slice(2);var _=to(B);if($s(B)&&(B=B.slice(0,-7),F.capture=!0),!_&&v){if(L!=null)continue;n.removeEventListener(B,u[H],F),u[H]=null}if(L!=null)if(_)n[`__${B}`]=L,Qr([B]);else{let V=function(Y){u[P].call(this,Y)};u[H]=oo(B,n,V,F)}else _&&(n[`__${B}`]=void 0)}else if(P==="style")Ze(n,P,L);else if(P==="autofocus")Us(n,!!L);else if(!l&&(P==="__value"||P==="value"&&L!=null))n.value=n.__value=L;else if(P==="selected"&&h)xo(n,L);else{var E=P;a||(E=ro(E));var S=E==="defaultValue"||E==="defaultChecked";if(L==null&&!l&&!S)if(s[P]=null,E==="value"||E==="checked"){let F=n;const H=o===void 0;if(E==="value"){let B=F.defaultValue;F.removeAttribute(E),F.defaultValue=B,F.value=F.__value=H?B:null}else{let B=F.defaultChecked;F.removeAttribute(E),F.defaultChecked=B,F.checked=H?B:!1}}else n.removeAttribute(P);else S||d.includes(E)&&(l||typeof L!="string")?(n[E]=L,E in s&&(s[E]=be)):typeof L!="function"&&Ze(n,E,L)}}}return u}function hn(n,o,e=[],t=[],r=[],i,s=!1,l=!1){vr(r,e,t,a=>{var u=void 0,h={},c=n.nodeName==="SELECT",d=!1;if(Lr(()=>{var v=o(...a.map(b)),y=Eo(n,u,v,i,s,l);d&&c&&"value"in v&&mi(n,v.value);for(let E of Object.getOwnPropertySymbols(h))v[E]||Pe(h[E]);for(let E of Object.getOwnPropertySymbols(v)){var _=v[E];E.description===ws&&(!u||_!==u[E])&&(h[E]&&Pe(h[E]),h[E]=Oe(()=>mo(n,()=>_))),y[E]=_}u=y}),c){var m=n;Zt(()=>{mi(m,u.value,!0),an(m)})}d=!0})}function cn(n){return n.__attributes??={[ln]:n.nodeName.includes("-"),[un]:n.namespaceURI===vs}}var dn=new Map;function fn(n){var o=n.getAttribute("is")||n.nodeName,e=dn.get(o);if(e)return e;dn.set(o,e=[]);for(var t,r=n,i=Element.prototype;i!==r;){t=Vn(r);for(var s in t)t[s].set&&e.push(s);r=ir(r)}return e}function pn(n,o){return n===o||n?.[mt]===o}function vi(n={},o,e,t){return Zt(()=>{var r,i;return Fr(()=>{r=i,i=[],pi(()=>{n!==e(...i)&&(o(n,...i),r&&pn(e(...r),n)&&o(null,...r))})}),()=>{vt(()=>{i&&pn(e(...i),n)&&o(null,...i)})}}),n}let wi=!1;function bo(n){var o=wi;try{return wi=!1,[n(),wi]}finally{wi=o}}const So={get(n,o){if(!n.exclude.includes(o))return n.props[o]},set(n,o){return!1},getOwnPropertyDescriptor(n,o){if(!n.exclude.includes(o)&&o in n.props)return{enumerable:!0,configurable:!0,value:n.props[o]}},has(n,o){return n.exclude.includes(o)?!1:o in n.props},ownKeys(n){return Reflect.ownKeys(n.props).filter(o=>!n.exclude.includes(o))}};function gn(n,o,e){return new Proxy({props:n,exclude:o},So)}function Le(n,o,e,t){var r=(e&fs)!==0,i=(e&ps)!==0,s=t,l=!0,a=()=>(l&&(l=!1,s=i?pi(t):t),s),u;if(r){var h=mt in n||Xn in n;u=Rt(n,o)?.set??(h&&o in n?S=>n[o]=S:void 0)}var c,d=!1;r?[c,d]=bo(()=>n[o]):c=n[o],c===void 0&&t!==void 0&&(c=a(),u&&(is(),u(c)));var m;if(m=()=>{var S=n[o];return S===void 0?a():(l=!0,S)},(e&ds)===0)return m;if(u){var v=n.$$legacy;return(function(S,P){return arguments.length>0?((!P||v||d)&&u(P?m():S),S):m()})}var y=!1,_=((e&cs)!==0?li:wr)(()=>(y=!1,m()));r&&b(_);var E=ne;return(function(S,P){if(arguments.length>0){const L=P?b(_):r?lt(S):S;return G(_,L),y=!0,s!==void 0&&(s=L),S}return xt&&y||(E.f&tt)!==0?_.v:b(_)})}const Po=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-.]+))?(?:\+[0-9A-Za-z-.]+)?$/;function yi(n){const o=Po.exec(n.trim());if(!o)return null;const[,e,t,r,i]=o,s=i?i.split(".").map(l=>/^\d+$/.test(l)?Number(l):l):[];return{major:Number(e),minor:Number(t),patch:Number(r),prerelease:s}}function Ro(n,o){return n.major-o.major||n.minor-o.minor||n.patch-o.patch}function Co(n,o){if(n.prerelease.length===0&&o.prerelease.length===0)return 0;if(n.prerelease.length===0)return 1;if(o.prerelease.length===0)return-1;const e=Math.max(n.prerelease.length,o.prerelease.length);for(let t=0;t<e;t++){const r=n.prerelease[t],i=o.prerelease[t];if(r===void 0)return-1;if(i===void 0)return 1;if(r===i)continue;const s=typeof r=="number",l=typeof i=="number";return s&&l?r<i?-1:1:s?-1:l?1:String(r)<String(i)?-1:1}return 0}function Do(n,o){return Ro(n,o)||Co(n,o)}function Ao(n){return n.major>0?{major:n.major+1,minor:0,patch:0,prerelease:[]}:n.minor>0?{major:0,minor:n.minor+1,patch:0,prerelease:[]}:{major:0,minor:0,patch:n.patch+1,prerelease:[]}}function Io(n){if(n===""||n==="*"||n==="x"||n==="X")return[];let o;if(o=/^\^\s*(.+)$/.exec(n)){const e=yi(o[1]??"");return e?[{op:">=",ver:e},{op:"<",ver:Ao(e)}]:null}if(o=/^~\s*(.+)$/.exec(n)){const e=yi(o[1]??"");return e?[{op:">=",ver:e},{op:"<",ver:{major:e.major,minor:e.minor+1,patch:0,prerelease:[]}}]:null}if(o=/^(>=|<=|>|<|=)?\s*(.+)$/.exec(n)){const e=yi(o[2]??"");return e?[{op:o[1]??"=",ver:e}]:null}return null}function Oo(n,o){const e=Do(n,o.ver);switch(o.op){case"<":return e<0;case"<=":return e<=0;case">":return e>0;case">=":return e>=0;case"=":return e===0}}function Fo(n,o){const e=o.trim();if(e===""||e==="*"||e==="x")return!0;const t=e.split(/\s+/).filter(Boolean);for(const r of t){const i=Io(r);if(i===null||!i.every(s=>Oo(n,s)))return!1}return!0}function mn(n,o){const e=yi(n);if(!e)return!1;const t=o.split("||").map(r=>r.trim()).filter(r=>r.length>0);return t.length===0?!0:t.some(r=>Fo(e,r))}class Xi extends Error{code="PLUGIN_INCOMPATIBLE";pluginName;pluginVersion;reasons;constructor(o,e,t){super(Lo(o,e,t)),this.name="PluginCompatibilityError",this.pluginName=o,this.pluginVersion=e,this.reasons=t,Object.setPrototypeOf(this,Xi.prototype)}}function Lo(n,o,e){const t=e.map(r=>` - ${r.message}`).join(`
|
|
3
|
+
`);return`Plugin "${n}"@${o} cannot activate — incompatible with this viewer:
|
|
4
|
+
${t}
|
|
5
|
+
Update the plugin or the core viewer so their declared ranges and capabilities overlap.`}function Mo(n,o){const e=[];mn(o.coreVersion,n.coreRange)||e.push({kind:"core",required:n.coreRange,actual:o.coreVersion,message:`requires core ${n.coreRange} but this viewer is core ${o.coreVersion}`}),mn(o.pluginApiVersion,n.pluginApiRange)||e.push({kind:"pluginApi",required:n.pluginApiRange,actual:o.pluginApiVersion,message:`requires plugin API ${n.pluginApiRange} but this viewer provides plugin API ${o.pluginApiVersion}`});const t=new Set(o.capabilities);for(const r of n.requiredCapabilities)t.has(r)||e.push({kind:"capability",required:r,actual:o.capabilities.join(", ")||"(none)",message:`requires capability "${r}" which this viewer does not provide (has: ${o.capabilities.join(", ")||"none"})`});return e}function Bo(n,o){const e=Mo(n,o);if(e.length>0)throw new Xi(n.name,n.version,e)}function Ho(n,o={}){let e=0,t=!1;const r=new Set,i=n.subscribe(()=>{e++;for(const l of[...r])l()},o.onListenerError);return{selectors:{select(l,a=Object.is){let u=-1,h;const c=()=>(u!==e&&(h=l(n),u=e),h);return{get:c,subscribe(d){if(t)return()=>{};let m=c();const v=()=>{let y;try{y=c()}catch(_){o.onProjectionError?.(_);return}a(m,y)||(m=y,d(y))};return r.add(v),()=>{r.delete(v)}}}}},dispose(){t||(t=!0,r.clear(),i())}}}const Yi=()=>{};function zo(){return{install(n,o){return Yi}}}function ko(){return{current:"en",t(n,o){return n},subscribe(n){return Yi}}}function No(){return{renderIcon(n,o){return Yi}}}function Uo(n){const o=new Set;return{service:{install(e,t){const r=n.install(e,t);let i=!1;const s=()=>{i||(i=!0,o.delete(s),r())};return o.add(s),s}},releaseAll(){for(const e of[...o])e();o.clear()}}}function Wo(n){const o=new Set;return{service:{get current(){return n.current},t(e,t){return n.t(e,t)},subscribe(e){const t=n.subscribe(e);let r=!1;const i=()=>{r||(r=!0,o.delete(i),t())};return o.add(i),i}},releaseAll(){for(const e of[...o])e();o.clear()}}}const Vo={deactivate(){}};function jo(n,o){const e=o.reportError;let t,r,i,s;try{Bo(n,o),t=Ho(o.viewerState,{onProjectionError:e?d=>e({phase:"command",error:d}):void 0,onListenerError:e?d=>e({phase:"subscription",error:d}):void 0}),r=Uo(o.styles??zo()),i=Wo(o.locale??ko()),s={viewerState:o.viewerState,selectors:t.selectors,styles:r.service,locale:i.service,ui:o.ui??No()}}catch(d){if(t?.dispose(),r?.releaseAll(),i?.releaseAll(),e)return e({phase:"setup",error:d}),Vo;throw d}const l=[],a=r,u=i,h=t;try{const d=n.view.mount(o.container,s);typeof d=="function"&&l.push(d)}catch(d){if(!e)throw a.releaseAll(),u.releaseAll(),h.dispose(),d;e({phase:"mount",error:d})}l.push(()=>a.releaseAll()),l.push(()=>u.releaseAll()),l.push(()=>h.dispose());let c=!1;return{deactivate(){if(!c){c=!0;for(let d=l.length-1;d>=0;d--)try{l[d]?.()}catch(m){e?e({phase:"cleanup",error:m}):console.error(`[triiiceratops] Plugin "${n.name}" cleanup threw during deactivation; teardown continues.`,m)}l.length=0}}}}const Go="triiiceratops-plugin";function qo(n){const o={name:n.name,uiId:n.uiId,version:n.version,coreRange:n.coreRange,pluginApiRange:n.pluginApiRange,requiredCapabilities:n.requiredCapabilities??[],icon:n.icon,target:n.target??"panel",dismiss:n.dismiss,catalog:n.catalog,view:n.view};return{kind:Go,...o,activate(e){return jo(o,e)}}}class Zo extends Error{name="SvgIconError";constructor(o){super(`svgIcon: ${o}`)}}const Xo="0 0 24 24";function bt(n,o){if(!n)throw new Zo(o)}const Yo=/<svg\b[^>]*>/i;function Ko(n){bt(typeof n=="string","expected an SVG string.");const o=n.trim();bt(o.length>0,"received an empty string.");const e=Yo.exec(o);bt(e!==null,"the markup must contain an <svg> root element."),bt(!/<script[\s/>]/i.test(o),"<script> elements are not allowed in plugin icons."),bt(!/<foreignObject[\s/>]/i.test(o),"<foreignObject> is not allowed in plugin icons."),bt(!/\son[a-z]+\s*=/i.test(o),"on* event-handler attributes (e.g. onload, onclick) are not allowed in plugin icons.");for(const l of o.matchAll(/(?:xlink:)?href\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/gi)){const a=(l[1]??l[2]??l[3]??"").trim();bt(a.startsWith("#"),`external href/xlink:href URLs are not allowed in plugin icons (found "${a}"); only internal "#id" references are.`)}const t=e[0],r=/\bviewBox\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t);let i=(r?.[1]??r?.[2])?.trim();if(!i){const l=/\bwidth\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t),a=/\bheight\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t),u=parseFloat(l?.[1]??l?.[2]??""),h=parseFloat(a?.[1]??a?.[2]??"");i=Number.isFinite(u)&&Number.isFinite(h)?`0 0 ${u} ${h}`:Xo}let s="";if(!/\/\s*>$/.test(t)){const l=e.index+t.length,a=o.lastIndexOf("</svg>");s=(a>=l?o.slice(l,a):o.slice(l)).trim()}return{kind:"svg",inner:s,viewBox:i}}function Qo(n,o){return{STYLES:n,STYLE_ID:o}}function Jo(n,o,e,t,r){const i={pluginName:o,pluginVersion:e,phase:"command",error:t,retry:r};n.dispatchEvent(new CustomEvent("pluginerror",{detail:i,bubbles:!0,composed:!0}))}const $o=".btn.svelte-kz0hjp{display:inline-flex;flex-wrap:nowrap;flex-shrink:0;justify-content:center;align-items:center;gap:.375rem;cursor:pointer;text-align:center;vertical-align:middle;user-select:none;-webkit-user-select:none;touch-action:manipulation;font-weight:600;height:var(--size);padding-inline:var(--btn-p);font-size:var(--fontsize, .875rem);color:var(--btn-fg);background-color:var(--btn-bg);border-width:var(--tri-border);border-style:solid;border-color:var(--btn-border);border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));outline-offset:2px;outline-color:var(--btn-color, var(--tri-content));text-shadow:0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * .15));box-shadow:0 .5px 0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * 6%)) inset,var(--btn-shadow);transition-property:color,background-color,border-color,box-shadow;transition-duration:.2s;transition-timing-function:cubic-bezier(0,0,.2,1);--size: calc(var(--tri-size-field, .25rem) * 10);--btn-bg: var(--btn-color, var(--tri-toolbar-bg));--btn-fg: var(--tri-content);--btn-p: 1rem;--btn-border: color-mix( in oklab, var(--btn-bg), #000 calc(var(--tri-depth) * 5%) );--btn-shadow: 0 3px 2px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 ), 0 4px 3px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 )}@media(hover:hover){.btn.svelte-kz0hjp:hover{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}}.btn.svelte-kz0hjp:focus-visible{isolation:isolate;outline-width:2px;outline-style:solid}.btn.svelte-kz0hjp:active:not(.active){--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 5% );--btn-border: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% );--btn-shadow: 0 0 0 0 oklch(0% 0 0 / 0), 0 0 0 0 oklch(0% 0 0 / 0);translate:0 .5px}.btn.active.svelte-kz0hjp{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}.btn.svelte-kz0hjp:disabled,.btn[disabled].svelte-kz0hjp{pointer-events:none;--btn-border: #0000;--btn-fg: color-mix(in oklch, var(--tri-content) 20%, #0000)}.btn.svelte-kz0hjp:disabled:not(.ghost):not(.outline),.btn[disabled].svelte-kz0hjp:not(.ghost):not(.outline){background-color:color-mix(in oklab,var(--tri-content) 10%,transparent);box-shadow:none}.circle.svelte-kz0hjp{width:var(--size);height:var(--size);border-radius:3.40282e38px;padding-inline:0}.square.svelte-kz0hjp{width:var(--size);height:var(--size);padding-inline:0}.ghost.svelte-kz0hjp{--btn-bg: transparent;--btn-border: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));box-shadow:none;text-shadow:none}@media(hover:hover){.ghost.svelte-kz0hjp:hover{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent)}}.ghost.svelte-kz0hjp:active:not(.active),.ghost.active.svelte-kz0hjp{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent);--btn-border: transparent}.outline.svelte-kz0hjp:not(:hover):not(:active):not(:focus-visible):not(.active):not(:disabled):not([disabled]){--btn-bg: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));--btn-border: var(--btn-color, var(--tri-content));box-shadow:none;text-shadow:none}.select-wrapper.svelte-1h1ta11{display:inline-flex;width:clamp(3rem,20rem,100%);max-width:100%}.native-select.svelte-1h1ta11{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;pointer-events:none}.select.svelte-1h1ta11{border:var(--tri-border) solid var(--input-color);appearance:none;background-color:var(--tri-input-bg);vertical-align:middle;width:100%;height:var(--size);touch-action:manipulation;white-space:nowrap;box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000) inset,0 -1px oklch(100% 0 0 / calc(var(--tri-depth) * .1)) inset;--input-color: color-mix(in oklab, var(--tri-content) 20%, #0000);--size: calc(var(--tri-size-field, .25rem) * 10);background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 20px) calc(1px + 50%),calc(100% - 16.1px) calc(1px + 50%);background-repeat:no-repeat;background-size:4px 4px,4px 4px;border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));align-items:center;gap:.375rem;padding-inline:.75rem 1.75rem;font-size:.875rem;display:inline-flex;position:relative;cursor:pointer;color:inherit;text-align:start}.select-label.svelte-1h1ta11{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-label.placeholder.svelte-1h1ta11{color:color-mix(in oklab,var(--tri-content) 55%,transparent)}.select.svelte-1h1ta11:hover:not(:disabled){--input-color: color-mix(in oklab, var(--tri-content) 40%, #0000)}.select.svelte-1h1ta11:focus-visible,.select.open.svelte-1h1ta11{--input-color: var(--tri-content);box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000);outline:2px solid var(--input-color);outline-offset:2px;isolation:isolate;z-index:1}.select.svelte-1h1ta11:is(:where(.svelte-1h1ta11):disabled,[disabled]:where(.svelte-1h1ta11)){cursor:not-allowed;border-color:var(--tri-panel-bg);background-color:var(--tri-panel-bg);color:color-mix(in oklab,var(--tri-content) 40%,transparent)}.ghost.svelte-1h1ta11{box-shadow:none;background-color:#0000;border-color:#0000;transition:background-color .2s}.ghost.svelte-1h1ta11:hover:not(:disabled){background-color:color-mix(in oklab,var(--tri-content) 8%,transparent)}.ghost.svelte-1h1ta11:focus-visible,.ghost.open.svelte-1h1ta11{background-color:var(--tri-input-bg);color:var(--tri-content)}.listbox.svelte-1h1ta11{position:fixed;inset:auto;margin:0;padding:.1875rem;border:var(--tri-border) solid color-mix(in oklab,var(--tri-content) 20%,#0000);background-color:var(--tri-input-bg);color:var(--tri-content);border-radius:var(--tri-radius-buttons);box-shadow:0 8px 24px oklch(0 0 0 / calc(.12 + var(--tri-depth) * .06));max-height:16rem;overflow-y:auto;min-width:8rem;z-index:1}.listbox.svelte-1h1ta11:not(:popover-open){display:none}.option.svelte-1h1ta11{padding:.25rem .5rem;border-radius:calc(var(--tri-radius-buttons) * .6);cursor:pointer;font-size:.8125rem;line-height:1.3;white-space:nowrap;color:inherit}.option.active.svelte-1h1ta11{background-color:color-mix(in oklab,var(--tri-content) 12%,#0000)}.option.selected.svelte-1h1ta11{background-color:color-mix(in oklab,var(--tri-color-primary) 90%,#0000);color:var(--tri-color-primary-content)}.option.selected.active.svelte-1h1ta11{background-color:var(--tri-color-primary)}.option[aria-disabled=true].svelte-1h1ta11{opacity:.5;cursor:not-allowed;color:color-mix(in oklab,var(--tri-content) 55%,transparent)}\n",ea={en:{image_download_title:"Download Image",image_download_close:"Close Download Image",image_download_description:"Download the current canvas as an image.",image_download_mode:"What to download",image_download_mode_composite:"Composite canvas",image_download_mode_composite_hint:"Every image on the current canvas, composited together.",image_download_mode_single:"Single image",image_download_mode_single_hint:"One image from the current canvas.",image_download_mode_world:"Current view",image_download_mode_world_hint:"Everything currently laid out together in the viewer.",image_download_canvas:"Canvas",image_download_image:"Image",image_download_resolution:"Resolution",image_download_resolution_placeholder:"Select a resolution",image_download_downloading:"Downloading...",image_download_download:"Download",image_download_disabled_no_canvas:"Load a manifest to download an image.",image_download_disabled_no_resolution:"Select a resolution to download.",image_download_result_downloaded:"Downloaded {filename}.",image_download_error_failed:"Unable to download image. Check the browser console for details."},de:{image_download_title:"Bild herunterladen",image_download_close:"Bild-Download schließen",image_download_description:"Die aktuelle Leinwand als Bild herunterladen.",image_download_mode:"Was heruntergeladen werden soll",image_download_mode_composite:"Zusammengesetzte Leinwand",image_download_mode_composite_hint:"Alle Bilder der aktuellen Leinwand, zusammengesetzt.",image_download_mode_single:"Einzelbild",image_download_mode_single_hint:"Ein Bild von der aktuellen Leinwand.",image_download_mode_world:"Aktuelle Ansicht",image_download_mode_world_hint:"Alles, was aktuell zusammen im Viewer angezeigt wird.",image_download_canvas:"Leinwand",image_download_image:"Bild",image_download_resolution:"Auflösung",image_download_resolution_placeholder:"Auflösung auswählen",image_download_downloading:"Wird heruntergeladen...",image_download_download:"Herunterladen",image_download_disabled_no_canvas:"Laden Sie ein Manifest, um ein Bild herunterzuladen.",image_download_disabled_no_resolution:"Wählen Sie eine Auflösung zum Herunterladen aus.",image_download_result_downloaded:"{filename} heruntergeladen.",image_download_error_failed:"Bild kann nicht heruntergeladen werden. Details in der Browserkonsole."}},vn=Symbol("triiiceratops:plugin-image-download"),wn=Ko('<svg viewBox="0 0 256 256"><path d="M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,124.69V32a8,8,0,0,0-16,0v92.69L93.66,98.34a8,8,0,0,0-11.32,11.32Z"/></svg>'),ta="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(ta);var ia=me("<button><!></button>");function ra(n,o){let e=Le(o,"variant",3,"default"),t=Le(o,"size",3,"md"),r=Le(o,"circle",3,!1),i=Le(o,"square",3,!1),s=Le(o,"ghost",3,!1),l=Le(o,"outline",3,!1),a=Le(o,"active",3,!1),u=Le(o,"class",3,""),h=Le(o,"style",3,""),c=gn(o,["$$slots","$$events","$$legacy","variant","size","circle","square","ghost","outline","active","class","style","children"]);const d={default:"",primary:"--btn-color:var(--tri-color-primary);--btn-color-text:var(--tri-color-primary-text);--btn-fg:var(--tri-color-primary-content);",neutral:"--btn-color:var(--tri-color-neutral);--btn-fg:var(--tri-color-neutral-content);",success:"--btn-color:var(--tri-color-success);--btn-fg:var(--tri-color-success-content);",warning:"--btn-color:var(--tri-color-warning);--btn-fg:var(--tri-color-warning-content);",error:"--btn-color:var(--tri-color-error);--btn-fg:var(--tri-color-error-content);"},m={xs:"--fontsize:0.6875rem;--btn-p:0.5rem;--size:calc(var(--tri-size-field,0.25rem)*6);",sm:"--fontsize:0.75rem;--btn-p:0.75rem;--size:calc(var(--tri-size-field,0.25rem)*8);",md:"--fontsize:0.875rem;--btn-p:1rem;--size:calc(var(--tri-size-field,0.25rem)*10);",lg:"--fontsize:1.125rem;--btn-p:1.25rem;--size:calc(var(--tri-size-field,0.25rem)*12);"};let v=le(()=>`${m[t()]}${d[e()]}${h()}`);var y=ia();hn(y,()=>({class:`btn ${u()??""}`,style:b(v),...c,[Mt]:{circle:r(),square:i(),ghost:s(),outline:l(),active:a()}}),void 0,void 0,void 0,"svelte-kz0hjp");var _=$(y);rn(_,()=>o.children??nr),ge(n,y)}let na=0;var sa=me('<div role="option"> </div>'),oa=me('<div><select><!></select> <button type="button" role="combobox" aria-haspopup="listbox"><span> </span></button> <div role="listbox" class="listbox svelte-1h1ta11" popover="manual" tabindex="-1"></div></div>');function _i(n,o){Fi(o,!0);let e=Le(o,"value",15),t=Le(o,"size",3,"md"),r=Le(o,"ghost",3,!1),i=Le(o,"class",3,""),s=Le(o,"style",3,""),l=gn(o,["$$slots","$$events","$$legacy","value","size","ghost","class","style","children"]);const a={xs:"calc(var(--tri-size-field,0.25rem)*6)",sm:"calc(var(--tri-size-field,0.25rem)*8)",md:"calc(var(--tri-size-field,0.25rem)*10)",lg:"calc(var(--tri-size-field,0.25rem)*12)"};let u=le(()=>`--size:${a[t()]};${s()}`);const h=`tri-listbox-${na++}`;let c=ue(null),d=ue(null),m=ue(null),v=ue(lt([])),y=ue(!1),_=ue(-1),E=le(()=>!!o.disabled),S=le(()=>e()==null?"":String(e())),P=le(()=>b(v).find(k=>k.value===b(S))??b(v)[0]);function L(){b(c)&&G(v,Array.from(b(c).querySelectorAll("option")).map(k=>({value:k.value,label:(k.textContent??"").trim(),disabled:k.disabled})),!0)}qt(()=>{if(!b(c))return;L();const k=new MutationObserver(()=>L());return k.observe(b(c),{childList:!0,subtree:!0,characterData:!0,attributes:!0}),()=>k.disconnect()});function F(k){const te=b(v)[k];!b(c)||!te||te.disabled||(b(c).value=te.value,b(c).dispatchEvent(new Event("input",{bubbles:!0})),b(c).dispatchEvent(new Event("change",{bubbles:!0})),J())}function H(){if(!b(d)||!b(m))return;const k=b(d).getBoundingClientRect();b(m).style.minWidth=`${k.width}px`,b(m).style.left=`${k.left}px`;const te=b(m).offsetHeight,de=window.innerHeight-k.bottom;de<te&&k.top>de?b(m).style.top=`${Math.max(4,k.top-te-4)}px`:b(m).style.top=`${k.bottom+4}px`}function B(){b(m)?.children[b(_)]?.scrollIntoView({block:"nearest"})}function V(k){const te=k.composedPath();b(d)&&te.includes(b(d))||b(m)&&te.includes(b(m))||J()}function Y(){b(E)||b(y)||!b(m)||(G(y,!0),b(m).showPopover(),H(),G(_,b(v).findIndex(k=>k.value===b(S)),!0),b(_)<0&&G(_,b(v).findIndex(k=>!k.disabled),!0),B(),window.addEventListener("scroll",H,!0),window.addEventListener("resize",H),document.addEventListener("pointerdown",V,!0))}function J(){b(y)&&(G(y,!1),b(m)?.hidePopover(),window.removeEventListener("scroll",H,!0),window.removeEventListener("resize",H),document.removeEventListener("pointerdown",V,!0),b(d)?.focus())}function re(){b(y)?J():Y()}function Z(k){if(!b(v).length)return;let te=b(_);for(let de=0;de<b(v).length;de++)if(te=(te+k+b(v).length)%b(v).length,!b(v)[te]?.disabled){G(_,te,!0),B();return}}function ie(k){const te=k==="start"?b(v).map((de,ye)=>ye):b(v).map((de,ye)=>b(v).length-1-ye);for(const de of te)if(!b(v)[de]?.disabled){G(_,de,!0),B();return}}let he="",pe;function ce(k){he+=k.toLowerCase(),clearTimeout(pe),pe=setTimeout(()=>he="",600);const te=b(v).findIndex(de=>!de.disabled&&de.label.toLowerCase().startsWith(he));te>=0&&(G(_,te,!0),B())}function ve(k){if(!b(E)){if(!b(y)){["ArrowDown","ArrowUp","Enter"," "].includes(k.key)&&(k.preventDefault(),Y());return}switch(k.key){case"ArrowDown":k.preventDefault(),Z(1);break;case"ArrowUp":k.preventDefault(),Z(-1);break;case"Home":k.preventDefault(),ie("start");break;case"End":k.preventDefault(),ie("end");break;case"Enter":case" ":k.preventDefault(),b(_)>=0&&F(b(_));break;case"Escape":k.preventDefault(),J();break;case"Tab":J();break;default:k.key.length===1&&!k.metaKey&&!k.ctrlKey&&ce(k.key)}}}var fe=oa(),we=$(fe);hn(we,()=>({class:"native-select",tabindex:"-1","aria-hidden":"true",...l}),void 0,void 0,void 0,"svelte-1h1ta11");var He=$(we);rn(He,()=>o.children??nr),vi(we,k=>G(c,k),()=>b(c));var xe=_e(we,2);let Xe;xe.__click=re,xe.__keydown=ve;var X=$(xe);let Ye;var ct=$(X);vi(xe,k=>G(d,k),()=>b(d));var Ue=_e(xe,2);gi(Ue,23,()=>b(v),(k,te)=>k.value+"\0"+te,(k,te,de)=>{var ye=sa();let Ke;ye.__click=()=>F(b(de)),ye.__pointermove=()=>G(_,b(de),!0);var St=$(ye);Se(()=>{Ze(ye,"id",`${h}-opt-${b(de)??""}`),Ke=$t(ye,1,"option svelte-1h1ta11",null,Ke,{active:b(de)===b(_),selected:b(te).value===b(S)}),Ze(ye,"aria-selected",b(te).value===b(S)),Ze(ye,"aria-disabled",b(te).disabled),Te(St,b(te).label)}),ge(k,ye)}),vi(Ue,k=>G(m,k),()=>b(m)),Se(()=>{$t(fe,1,`select-wrapper ${i()??""}`,"svelte-1h1ta11"),Zi(fe,s()),Xe=$t(xe,1,"select svelte-1h1ta11",null,Xe,{ghost:r(),open:b(y)}),Zi(xe,b(u)),xe.disabled=b(E),Ze(xe,"aria-expanded",b(y)),Ze(xe,"aria-controls",h),Ze(xe,"aria-activedescendant",b(y)&&b(_)>=0?`${h}-opt-${b(_)}`:void 0),Ze(xe,"aria-label",l["aria-label"]),Ye=$t(X,1,"select-label svelte-1h1ta11",null,Ye,{placeholder:b(P)?.disabled}),Te(ct,b(P)?.label??""),Ze(Ue,"id",h)}),To(we,e),ge(n,fe),Li()}Qr(["click","keydown","pointermove"]);function Bt(n){return n?.id||n?.["@id"]||n?.__jsonld?.id||n?.__jsonld?.["@id"]||(typeof n?.getId=="function"?n.getId():null)||null}function Ht(n){return Bt(n)||(typeof n?.getCanvasId=="function"?n.getCanvasId():null)||(typeof n?.getId=="function"?n.getId():null)||""}function aa(n){const o=n?.behavior||n?.__jsonld?.behavior||(typeof n?.getBehavior=="function"?n.getBehavior():[]);return o?(Array.isArray(o)?o:[o]).map(t=>{const r=String(t).trim().toLowerCase(),i=r.split(/[#/:]/);return i[i.length-1]||r}):[]}function yn(n){const o=aa(n);return o.includes("non-paged")||o.includes("facing-pages")}function la(n,o){const e=[];for(let t=0;t<Math.min(o,n.length);t++){const r=n[t],i=Ht(r);e.push({startIndex:t,endIndex:t,entries:i?[{canvasId:i,canvas:r}]:[]})}for(let t=o;t<n.length;){const r=n[t],i=Ht(r),s=n[t+1],l=Ht(s),a=!!s&&!!i&&!!l&&!yn(r)&&!yn(s);e.push({startIndex:t,endIndex:a?t+1:t,entries:[...i?[{canvasId:i,canvas:r}]:[],...a?[{canvasId:l,canvas:s}]:[]]}),t+=a?2:1}return e}function ua({canvases:n,currentCanvasId:o,currentCanvasIndex:e,viewingMode:t,pagedOffset:r}){if(!o)return[];if(e<0||e>=n.length)return[];const i=[],s=n[e];return s?t!=="paged"?(i.push({canvasId:o,canvas:s}),i):la(n,r).find(({startIndex:a,endIndex:u})=>e>=a&&e<=u)?.entries??i:i}function Ti(n,o){if(!n)return"";if(typeof n=="string")return n;if(typeof n=="object"&&!Array.isArray(n)){const e=n;if("@value"in e){const i=e["@value"];return Array.isArray(i)&&i.length>0?String(i[0]):i===void 0?"":String(i)}const t=Object.keys(e),r=i=>{const s=e[i];if(s!==void 0)return Array.isArray(s)&&s.length>0?String(s[0]):String(s)};for(const i of["en","none"]){const s=r(i);if(s!==void 0)return s}return t.length>0?r(t[0])??"":""}if(Array.isArray(n)&&n.length>0){if(typeof n[0]=="string")return n[0];const e=n,t=l=>l?.value??l?._value,i=(l=>e.find(a=>a.locale===l||a._locale===l||a.language===l))("en");{const l=t(i);if(l)return l}const s=e.find(l=>!l.locale&&!l._locale&&!l.language);{const l=t(s);if(l)return l}return t(e[0])??""}return String(n)}function _n(n,o){const e=o===void 0?"Untitled canvas":`Canvas ${o+1}`;try{const r=n.getLabel?.();if(Array.isArray(r)&&r.length>0)return Ti(r)||e}catch{}const t=n.label||n.__jsonld?.label;if(t){const r=Ti(t);if(r)return r}return e}function Ki(n){if(!n)return null;const o=n.match(/xywh=(?:pixel:)?([\d.]+),([\d.]+),([\d.]+),([\d.]+)/);return o?[Number(o[1]),Number(o[2]),Number(o[3]),Number(o[4])]:null}function ha(n){const[o]=n.split("#");return o||null}function Qi(n){if(!n)return null;if(typeof n=="string")return n;if(Array.isArray(n)){for(const e of n){const t=Qi(e);if(t)return t}return null}if(typeof n!="object")return null;const o=n;return typeof o.id=="string"?o.id:typeof o["@id"]=="string"?o["@id"]:o.source?Qi(o.source):null}function Ji(n){if(!n)return[];if(Array.isArray(n))return n.flatMap(e=>Ji(e));if(typeof n!="object")return[];const o=n;return o.item?Ji(o.item):[o]}function ca(n){const o=n.find(t=>t?.type==="FragmentSelector"&&typeof t?.value=="string"&&t.value.includes("xywh="));if(o)return Ki(o.value);const e=n.find(t=>typeof t?.value=="string"&&t.value.includes("xywh="));return e?Ki(e.value):null}function Tn(n){if(!n)return[];if(Array.isArray(n))return n.flatMap(r=>Tn(r));const o=Qi(n),e=typeof n=="object"&&n&&"selector"in n?Ji(n.selector):[],t=ca(e)||(o?Ki(o):null);return[{raw:n,targetId:o,canvasId:o?ha(o):null,selectors:e,xywh:t}]}function xn(n){return n.endsWith("/info.json")?n.slice(0,-10):n}function zt(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:null}function da(n){const o=n?.__jsonld||n;return{width:zt(n?.width)||zt(o?.width)||(typeof n?.getWidth=="function"?zt(n.getWidth()):null),height:zt(n?.height)||zt(o?.height)||(typeof n?.getHeight=="function"?zt(n.getHeight()):null)}}function En(n){const o=n?.__jsonld||n;return o?.type==="SpecificResource"&&o?.source?o.source:null}function fa(n,o){return o?.type==="Choice"||o?.type==="oa:Choice"||!!n&&!Array.isArray(n)&&(n.type==="Choice"||n.type==="oa:Choice")}function bn(n,o){return o&&(o.items||o.item)?o.items||o.item:Array.isArray(n)?n:n&&(n.items||n.item)?n.items||n.item:[]}function pa({body:n,rawBody:o,canvasId:e,getSelectedChoice:t}){const r=Array.isArray(n)?n:bn(n,null),i=bn(null,o),s=t?.(e);if(s){const l=r.find(u=>Bt(u)===s);if(l)return l;const a=i.findIndex(u=>Bt(u)===s);if(a>=0)return r[a]||i[a]}return r[0]||i[0]||null}function ga(n){let o=n.getImages?.()||[];return(!o||!o.length)&&n.getContent&&(o=n.getContent()),o||[]}function ma(n){const o=n?.width||n?.__jsonld?.width||(typeof n?.getWidth=="function"?n.getWidth():null),e=n?.height||n?.__jsonld?.height||(typeof n?.getHeight=="function"?n.getHeight():null);return typeof o!="number"||typeof e!="number"?null:{width:o,height:e}}function va(n){const o=Tn(n?.target||n?.__jsonld?.target).find(e=>e.xywh)?.xywh;return o?{x:o[0],y:o[1],width:o[2],height:o[3]}:null}function wa(n,o){if(typeof n!="string"||!n.trim())return null;const e=n.trim(),t=e.startsWith("pct:"),i=(t?e.slice(4):e).split(",").map(s=>Number(s.trim()));return i.length!==4||i.some(s=>!Number.isFinite(s)||s<0)?null:t?typeof o.width!="number"||typeof o.height!="number"?null:{x:i[0]/100*o.width,y:i[1]/100*o.height,width:i[2]/100*o.width,height:i[3]/100*o.height}:{x:i[0],y:i[1],width:i[2],height:i[3]}}function ya(n,o){const e=n?.__jsonld||n;return wa(e?.selector?.type==="ImageApiSelector"?e.selector.region:null,o)}function _a(n){return[n.x,n.y,n.width,n.height].map(o=>Math.round(o)).join(",")}function Ta(n){const o=n?.__jsonld||n,e=En(n);return!!(n&&(n.id||n["@id"]||o?.service||e||o?.id||o?.["@id"]))}function xa(n,o,e){let t=n.getResource?n.getResource():null;if(!t&&n.getBody){const r=n.getBody(),i=n.__jsonld?.body||n.body;fa(r,i)?t=pa({body:r,rawBody:i,canvasId:o,getSelectedChoice:e}):Array.isArray(r)&&r.length>0?t=r[0]:r&&(t=r)}if(t&&!Ta(t)&&(t=null),!t){const r=n.__jsonld||n;if(r.body){let i=r.body;if(i.type==="Choice"||i.type==="oa:Choice"){const s=i.items||i.item||[],l=e?.(o);i=(l?s.find(u=>Bt(u)===l):null)||s[0]||null}t=Array.isArray(i)?i[0]:i}}return t}function Sn(n){return typeof n=="string"?/^https?:\/\/iiif\.io\/api\/image\//.test(n)||n==="level0"||n==="level1"||n==="level2":Array.isArray(n)?n.some(o=>Sn(o)):!1}function Ea(n){return typeof n=="string"?n||null:Array.isArray(n)&&n.find(e=>typeof e=="string")||null}function ba(n){let o=[];const e=n?.__jsonld||n;return e?.service&&(o=Array.isArray(e.service)?e.service:[e.service]),!o.length&&n?.getServices&&(o=n.getServices()),o.length&&o.find(t=>{const r=t.getType?t.getType():t.type||t["@type"]||"",i=t.getProfile?t.getProfile():t.profile||"";return r==="ImageService1"||r==="ImageService2"||r==="ImageService3"||Sn(i)})||null}function Sa(n,o){for(const e of[n,o]){if(!e)continue;try{const r=e.getLabel?.();if(Array.isArray(r)&&r.length>0){const i=Ti(r);if(i)return i}}catch{}const t=e.label||e.__jsonld?.label;if(t){const r=Ti(t);if(r)return r}}return null}function Pa(n){const o=ba(n),e=Bt(o),t=o?o.getProfile?o.getProfile():o.profile||"":null;return{serviceId:e?xn(e):null,serviceProfile:Ea(t)}}function Ra(n){if(!n||!n.includes("/iiif/"))return null;const o=n.split("/"),e=o.findIndex(t=>t==="full"||/^\d+,\d+,\d+,\d+$/.test(t));return e>0?o.slice(0,e).join("/"):null}function xi(n,o={}){const e=Ht(n);if(!e)return[];const t=ma(n);if(!t)return[];const r=ga(n);return r.length?r.map(i=>{const s=xa(i,e,o.getSelectedChoice),l=En(s)||s;if(!l)return null;const a=Bt(l),u=da(l),h=Pa(l),c=h.serviceId||Ra(a),d=va(i),m=ya(s,u);return{canvasId:e,annotation:i,resource:l,resourceId:a,label:Sa(l,i),canvasWidth:t.width,canvasHeight:t.height,resourceWidth:m?.width||u.width,resourceHeight:m?.height||u.height,serviceId:c,serviceProfile:h.serviceProfile,imageApiRegion:m,x:d?d.x/t.width:0,y:d?d.y/t.width:0,width:d?d.width/t.width:1}}).filter(i=>i!==null):[]}function Ca(n,o={width:1600}){const e=xn(n),t=o.region||"full",r=o.quality||"default",i=o.format||"jpg",s=typeof o.width=="number"?Math.max(1,Math.round(o.width)):null,l=typeof o.height=="number"?Math.max(1,Math.round(o.height)):null,a=o.size||(s?`${s},`:`,${l||1600}`);return`${e}/${t}/${a}/0/${r}.${i}`}function Da(n){return typeof n=="string"?n:Array.isArray(n)&&typeof n[0]=="string"?n[0]:null}function Ei(n){const o=Da(n);return o?o==="level0"||o.endsWith("/level0.json")||o.endsWith("#level0"):!1}function Aa(n,o,e,t){if(!n?.IIIFTileSource?.prototype)return o;try{const r=n.IIIFTileSource.prototype.configure.call({},o,e,null),i=new n.IIIFTileSource(r);return Ia(i,t),i}catch{return o}}function Ia(n,o){if(!Ei(n?.profile)||typeof n?.getTileUrl!="function"||n.__triiiceratopsLevel0LowZoomPrepared)return;const e=n.getTileUrl.bind(n),t=typeof n.getNumTiles=="function"?n.getNumTiles.bind(n):null,r=La(),i=Fa(n),s=Oa(n,i,t);t&&(n.getNumTiles=function(l){return Rn(l,s,i,this)?{x:0,y:0}:Pn(this,l,r,i,t,s)?{x:1,y:1}:t(l)}),typeof n?.minLevel=="number"&&s>=0&&(n.minLevel=Math.max(n.minLevel,s)),n.getTileUrl=function(l,a,u){if(Rn(l,s,i,this)){const h=s>=0?s:l;return e(h,a,u)}return Pn(this,l,r,i,t,s)?Cn(this,l):e(l,a,u)},n.__triiiceratopsLevel0LowZoomPrepared=!0}function Pn(n,o,e,t,r,i){if(i>=0)return!1;if(e>=0&&o<=e||!$i(n,o,t))return!0;if(!r)return!1;const s=r(o);return s?.x===1&&s?.y===1}function Oa(n,o,e){if(!e||typeof n?.minLevel!="number"||typeof n?.maxLevel!="number"||o.size===0)return-1;for(let t=n.minLevel;t<=n.maxLevel;t++){if(!$i(n,t,o))continue;const r=e(t);if(r?.x>1||r?.y>1)return t}return-1}function Rn(n,o,e,t){return o<0?!1:n<o?!0:!$i(t,n,e)}function Fa(n){const o=new Set,e=n?.scale_factors;if(Array.isArray(e))for(const t of e)typeof t=="number"&&t>0&&o.add(t);return o}function $i(n,o,e){if(e.size===0||typeof n?.maxLevel!="number"||typeof o!="number")return!0;const t=Math.pow(2,n.maxLevel-o);return e.has(t)}function La(n,o){return-1}function Cn(n,o){const e=n.getLevelScale(o),t=Math.ceil(n.width*e),r=Math.ceil(n.height*e),i=n.version===3,s=Ei(n?.profile),l=i?t===n.width&&r===n.height?"max":s?`${t},`:`${t},${r}`:t===n.width?"full":`${t},`,a=i?"default":"native";return`${n._id}/full/${l}/0/${a}.${n.tileFormat}`}const bi=8e3,Dn=4e7;function Ma(n,o,e,t){const r=Math.max(1,Math.round(n.width*o*t)),i=n.resourceWidth&&n.resourceHeight?n.resourceHeight/n.resourceWidth:e/o;return{x:Math.round(n.x*o*t),y:Math.round(n.y*e*t),width:r,height:Math.max(1,Math.round(r*i))}}function Ba(n,o){const e=URL.createObjectURL(n),t=document.createElement("a");t.href=e,t.download=o,document.body.appendChild(t),t.click(),t.remove(),URL.revokeObjectURL(e)}async function er(n,o){const e=await fetch(n,o);if(!e.ok)throw new Error(`Image request failed with ${e.status}.`);return e.blob()}async function Ha(n){const o=URL.createObjectURL(n);try{return await new Promise((e,t)=>{const r=new Image;r.onload=()=>e(r),r.onerror=()=>t(new Error("Unable to decode image for export.")),r.src=o})}finally{URL.revokeObjectURL(o)}}async function An(n,o,e,t="image/png"){const r=document.createElement("canvas");r.width=Math.max(1,Math.round(o)),r.height=Math.max(1,Math.round(e));const i=r.getContext("2d");if(!i)throw new Error("Unable to create a canvas for image export.");for(const s of n){const l=await Ha(s.blob);i.drawImage(l,s.x,s.y,s.width,s.height)}return new Promise((s,l)=>{r.toBlob(a=>{if(a){s(a);return}l(new Error("Unable to export composed image."))},t)})}function In(n,o){let e=1;n>bi&&(e=Math.min(e,bi/n)),o>bi&&(e=Math.min(e,bi/o));const t=n*o;return t*e*e>Dn&&(e=Math.min(e,Math.sqrt(Dn/t))),e>=1?{width:Math.round(n),height:Math.round(o),clamped:!1}:{width:Math.max(1,Math.round(n*e)),height:Math.max(1,Math.round(o*e)),clamped:!0}}function ii(n,o={}){if(Ei(n.serviceProfile))return n.resourceId??null;if(n.serviceId){const e=n.imageApiRegion?_a(n.imageApiRegion):void 0,t=!!(o.width||o.height);return Ca(n.serviceId,{region:e,size:t?void 0:"max",width:o.width,height:o.height})}return n.resourceId??null}async function za(n){if(!n.serviceId)return[];const o=n.serviceId.endsWith("/info.json")?n.serviceId:`${n.serviceId}/info.json`;try{const e=await fetch(o);if(!e.ok)return[];const t=await e.json(),r=await Promise.resolve().then(()=>Al),i=r.default||r,s=Aa(i,t,o);if(!s||typeof s.minLevel!="number"||typeof s.maxLevel!="number"||typeof s.getLevelScale!="function")return[];const l=new Set,a=[];for(let u=s.minLevel;u<=s.maxLevel;u+=1){const h=s.getLevelScale(u),c=Math.ceil(s.width*h),d=Math.ceil(s.height*h),m=`${c}x${d}`;l.has(m)||(l.add(m),a.push({width:c,height:d,label:`${c} × ${d}px`,url:Cn(s,u)}))}return a.sort((u,h)=>h.width-u.width)}catch{return[]}}const ka=[{fraction:1,label:"Original"},{fraction:.5,label:"50%"},{fraction:.25,label:"25%"}];function tr(n,o,e){return ka.map(({fraction:t,label:r})=>{const i=Math.max(1,Math.round(n*t)),s=Math.max(1,Math.round(o*t)),l=e?.({width:i,height:s,isOriginal:t===1});return{width:i,height:s,label:`${r} (${i} × ${s}px)`,url:l??void 0}}).filter(t=>!e||!!t.url)}function Na(n){const o=n.resourceWidth,e=n.resourceHeight;if(!n.serviceId||!o||!e){const t=ii(n);return t?[{width:o??0,height:e??0,label:"Original",url:t}]:[]}return tr(o,e,({width:t,height:r,isOriginal:i})=>ii(n,i?{}:{width:t,height:r}))}async function Ua(n){if(Ei(n.serviceProfile)){const o=await za(n);return o.length?o:n.resourceId?[{width:n.resourceWidth??0,height:n.resourceHeight??0,label:"Original",url:n.resourceId}]:[]}return Na(n)}const Wa=.0125;function Va(n){return!!n&&typeof n=="object"&&"tileSource"in n}function On(n,o){if(!n||typeof n!="object")return null;const e=n[o];return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function ja(n,o,e){return Math.min(e,Math.max(o,n))}function Ga(n){const o=[...n].sort((t,r)=>t-r),e=Math.floor(o.length/2);return o.length%2===0?(o[e-1]+o[e])/2:o[e]}function qa(n){const o=new Map;return n.forEach((e,t)=>{const r=Va(e),i=r?e.tileSource:e,s=r?e.canvasId??`canvas-${t}`:`canvas-${t}`,l=r?e.x??0:0,a=r?e.y??0:0,u=r?e.width??1:1,h=On(i,"width"),c=On(i,"height"),d=h&&c?u*c/h:null;let m=o.get(s);m||(m={canvasId:s,sources:[],width:0,height:null},o.set(s,m)),m.sources.push({source:e,tileSource:i,localX:l,localY:a,localWidth:u,localHeight:d}),m.width=Math.max(m.width,l+u),m.height=d===null?null:Math.max(m.height??0,a+d)}),[...o.values()]}function Za(n){return{layouts:n.map(o=>({canvasId:o.canvasId,x:0,y:0,width:o.width,height:o.height??1})),sources:n.flatMap(o=>o.sources.map(({tileSource:e,localX:t,localY:r,localWidth:i})=>({tileSource:e,x:t,y:r,width:i,canvasId:o.canvasId})))}}function Xa(n,o){const e=qa(n);if(o.mode==="individuals"||e.length<=1)return Za(e);const t=!o.preserveCanvasScale&&e.every(s=>s.height!==null),r=t?Ga(e.map(s=>s.height)):1,i=e.map(s=>{const l=t?ja(r/s.height,.25,4):1;return{group:s,scale:l,width:s.width*l,height:(s.height??1)*l,x:0,y:0}});if(o.mode==="continuous"){let s=0;const l=o.direction==="top-to-bottom"||o.direction==="bottom-to-top",a=o.direction==="right-to-left"||o.direction==="bottom-to-top";for(const u of i)l?(u.y=a?-s:s,s+=(t?u.height:1)+o.gap):(u.x=a?-s:s,s+=(t?u.width:1)+o.gap)}else if(o.mode==="paged"){const s=Math.max(...i.map(a=>a.height)),l=o.direction==="right-to-left";i.forEach((a,u)=>{const h=l?i.slice(u+1):i.slice(0,u);a.x=h.reduce((c,d)=>c+(t?d.width:1)+o.gap,0),a.y=(s-a.height)/2})}return{layouts:i.map(s=>({canvasId:s.group.canvasId,x:s.x,y:s.y,width:s.width,height:s.height})),sources:i.flatMap(s=>s.group.sources.map(({tileSource:l,localX:a,localY:u,localWidth:h})=>({tileSource:l,x:s.x+a*s.scale,y:s.y+u*s.scale,width:h*s.scale,canvasId:s.group.canvasId})))}}function Ya(n,o,e){Jo(n,"@triiiceratops/plugin-image-export","1.0.0-rc.0",o,e)}function Ka(n){return n.replace(/[^a-z0-9-_]+/gi,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Qa(n,o,e){const r=Ka(n)||"image",i=o==="single"?"":`-${o}`;return`${r}${i}.png`}function Fn(n,o){return xi(n,{getSelectedChoice:o})}function Ja(n){return Ua(n)}function $a(n,o){const t=xi(n,{getSelectedChoice:o})[0];return!t?.canvasWidth||!t?.canvasHeight?[]:tr(t.canvasWidth,t.canvasHeight)}async function el(n,o){const e=o.url??ii(n,{width:o.width,height:o.height});if(!e)throw new Error("No exportable image found for this canvas.");return er(e)}async function tl(n,o,e={}){const t=xi(n,{getSelectedChoice:e.getSelectedChoice}),r=t[0];if(!r)throw new Error("No exportable image found for this canvas.");const{canvasWidth:i,canvasHeight:s}=r;if(!i||!s)throw new Error("Unable to determine canvas dimensions for export.");const{width:l,height:a}=In(o.width,o.height),u=l/i,h=await Promise.all(t.map(async c=>il(c,i,s,u)));return An(h,l,a,e.format??"image/png")}async function il(n,o,e,t){const r=Ma(n,o,e,t),i=ii(n,{width:r.width});if(!i)throw new Error("No exportable image found for this canvas.");return{blob:await er(i),...r}}function Ln(n){return ua({canvases:n.canvases,currentCanvasId:n.canvasId,currentCanvasIndex:n.currentCanvasIndex,viewingMode:n.viewingMode,pagedOffset:n.pagedOffset}).map(o=>o.canvas)}function Mn(n,o){const e=Ln(n);if(!e.length)return null;const t=e.flatMap((c,d)=>{const m=Ht(c)??`canvas-${d}`;return xi(c,{getSelectedChoice:o}).map(v=>({canvasId:m,x:v.x,y:v.y,width:v.width,tileSource:{width:v.resourceWidth||v.canvasWidth,height:v.resourceHeight||v.canvasHeight,resolved:v}}))});if(!t.length)return null;const{layouts:r,sources:i}=Xa(t,{mode:n.viewingMode,direction:n.viewingDirection,preserveCanvasScale:n.preserveCanvasScale,gap:Wa});if(!r.length)return null;const s=Math.min(...r.map(c=>c.x)),l=Math.min(...r.map(c=>c.y)),a=Math.max(...r.map(c=>c.x+c.width)),u=Math.max(...r.map(c=>c.y+c.height));return{entries:i.map(c=>({resolved:c.tileSource.resolved,x:c.x-s,y:c.y-l,width:c.width})),worldWidth:a-s,worldHeight:u-l}}function rl(n,o){const e=Mn(n,o);if(!e)return[];const t=e.entries[0],r=t?.resolved.resourceWidth&&t.width>0?t.resolved.resourceWidth/t.width:1600,i=Math.round(e.worldWidth*r),s=Math.round(e.worldHeight*r);return!i||!s?[]:tr(i,s)}async function nl(n,o,e={}){const t=Mn(n,e.getSelectedChoice);if(!t)throw new Error("Nothing is currently displayed in the viewer.");const{width:r,height:i}=In(o.width,o.height),s=r/t.worldWidth,l=await Promise.all(t.entries.map(async({resolved:a,x:u,y:h,width:c})=>{const d=Math.max(1,Math.round(c*s)),m=a.resourceWidth&&a.resourceHeight?a.resourceHeight/a.resourceWidth:1,v=Math.max(1,Math.round(d*m)),y=ii(a,{width:d});if(!y)throw new Error("No exportable image found for the current view.");return{blob:await er(y),x:Math.round(u*s),y:Math.round(h*s),width:d,height:v}}));return An(l,r,i,e.format??"image/png")}var sl=me("<option> </option>"),ol=me("<option> </option>"),al=me("<!> <option> </option> <!>",1),ll=me('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-mode"><span> </span></label> <!></div>'),ul=me("<option> </option>"),hl=me('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-canvas"><span> </span></label> <!></div>'),cl=me("<option> </option>"),dl=me('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-image"><span> </span></label> <!></div>'),fl=me("<option> </option>"),pl=me("<option disabled> </option> <!>",1),gl=me('<div class="tri-id-alert is-success" data-tri-id-result=""><span> </span></div>'),ml=me('<div class="tri-id-alert is-error" data-tri-id-error=""><span> </span></div>'),vl=me('<div class="tri-id-alert"><span> </span></div>'),wl=me('<div class="tri-id-card"><div class="tri-id-card-body"><!> <!> <!></div></div>'),yl=me('<span aria-hidden="true"></span> ',1),_l=me('<div class="tri-id" data-tri-id="" data-panel-id="image-download"><div class="tri-id-body"><p class="tri-id-desc"> </p> <div class="tri-id-fields"><!> <!> <!> <div class="tri-id-field"><label class="tri-id-label" for="tri-id-resolution"><span> </span></label> <!></div></div> <!></div> <div class="tri-id-footer"><!></div></div>');function Tl(n,o){Fi(o,!0);const{context:e}=Es(vn),{viewerState:t,selectors:r,locale:i,ui:s}=e;let l=ue(0),a=ue(0);r.select(I=>[I.canvasId,I.currentCanvasIndex,I.canvases,I.viewingMode,I.viewingDirection,I.pagedOffset,I.preserveCanvasScale]).subscribe(()=>{xr(l)}),i.subscribe(()=>{xr(a)});const u=(I,D)=>(b(a),i.t(I,D));let h=ue("single"),c=ue(0),d=ue(0),m=ue(lt([])),v=ue(null),y=ue(!1),_=ue(!1),E=ue(""),S=ue(""),P=ue(null);const L=I=>t.getSelectedChoice(I),F=le(()=>(b(l),t.currentCanvasIndex>=0?t.canvases[t.currentCanvasIndex]??null:null)),H=le(()=>(b(l),b(F)?Fn(b(F),L):[])),B=le(()=>b(H).length>1),V=le(()=>b(B)),Y=le(()=>(b(l),Ln(t))),J=le(()=>b(Y).length>1),re=le(()=>b(J)),Z=le(()=>b(V)||b(re)),ie=le(()=>(b(l),b(h)==="single"&&b(J)?b(Y)[b(c)]??b(F):b(F))),he=le(()=>(b(l),b(ie)?Fn(b(ie),L):[])),pe=le(()=>b(he).length>1),ce=le(()=>b(v)!==null?b(m)[b(v)]??null:null),ve=le(()=>!b(_)&&!b(y)&&!!b(F)&&!!b(ce)),fe=le(()=>(b(a),b(F)?!b(y)&&!b(m).length?u("image_download_disabled_no_resolution"):null:u("image_download_disabled_no_canvas")));qt(()=>{(b(h)==="composite"&&!b(V)||b(h)==="world"&&!b(re))&&G(h,"single")}),qt(()=>{b(l);const I=t.canvasId,D=b(Y).findIndex(z=>Ht(z)===I);G(c,D>=0?D:0,!0)}),qt(()=>{b(ie),G(d,0)}),qt(()=>{const I=b(F),D=b(h),z=b(d);let j=!1;if(G(m,[],!0),G(v,null),!!I){if(D==="single"){const q=b(he)[z];if(!q)return;G(y,!0),Ja(q).then(U=>{j||(G(m,U,!0),G(v,U.length?0:null,!0))}).finally(()=>{j||G(y,!1)})}else if(D==="composite"){const q=$a(I,L);G(m,q,!0),G(v,q.length?0:null,!0)}else{const q=rl(t,L);G(m,q,!0),G(v,q.length?0:null,!0)}return()=>{j=!0}}});function we(I){const D=Number(I);return Number.isInteger(D)?D:0}async function He(){if(!(!b(F)||!b(ce)||!b(ve))){G(_,!0),G(E,""),G(S,"");try{let I,D=b(F);if(b(h)==="single"){D=b(ie);const j=b(he)[b(d)];if(!j)return;I=await el(j,b(ce))}else b(h)==="composite"?I=await tl(b(F),b(ce),{getSelectedChoice:L}):I=await nl(t,b(ce),{getSelectedChoice:L});const z=Qa(_n(D,t.currentCanvasIndex),b(h),"image/png");Ba(I,z),G(S,u("image_download_result_downloaded",{filename:z}),!0)}catch(I){G(E,u("image_download_error_failed"),!0),b(P)&&Ya(b(P),I,()=>void He())}finally{G(_,!1)}}}function xe(I){return{destroy:s.renderIcon(wn,I)}}var Xe=_l(),X=$(Xe),Ye=$(X),ct=$(Ye),Ue=_e(Ye,2),k=$(Ue);{var te=I=>{var D=ll(),z=$(D),j=$(z),q=$(j),U=_e(z,2);{let K=le(()=>u("image_download_mode"));_i(U,{id:"tri-id-mode",class:"tri-id-field-select","data-tri-id-mode":!0,get"aria-label"(){return b(K)},get disabled(){return b(_)},get value(){return b(h)},onchange:g=>{G(h,g.currentTarget.value,!0)},children:(g,p)=>{var w=al(),x=jt(w);{var C=oe=>{var se=sl(),Qe=$(se);se.value=se.__value="composite",Se(Ut=>Te(Qe,Ut),[()=>u("image_download_mode_composite")]),ge(oe,se)};st(x,oe=>{b(V)&&oe(C)})}var A=_e(x,2),N=$(A);A.value=A.__value="single";var Q=_e(A,2);{var W=oe=>{var se=ol(),Qe=$(se);se.value=se.__value="world",Se(Ut=>Te(Qe,Ut),[()=>u("image_download_mode_world")]),ge(oe,se)};st(Q,oe=>{b(re)&&oe(W)})}Se(oe=>Te(N,oe),[()=>u("image_download_mode_single")]),ge(g,w)},$$slots:{default:!0}})}Se(K=>Te(q,K),[()=>u("image_download_mode")]),ge(I,D)};st(k,I=>{b(Z)&&I(te)})}var de=_e(k,2);{var ye=I=>{var D=hl(),z=$(D),j=$(z),q=$(j),U=_e(z,2);{let K=le(()=>u("image_download_canvas"));_i(U,{id:"tri-id-canvas",class:"tri-id-field-select",get"aria-label"(){return b(K)},get disabled(){return b(_)},get value(){return b(c)},onchange:g=>{G(c,we(g.currentTarget.value),!0)},children:(g,p)=>{var w=$r(),x=jt(w);gi(x,17,()=>b(Y),Vi,(C,A,N)=>{var Q=ul(),W=$(Q);Q.value=Q.__value=N,Se(oe=>Te(W,oe),[()=>_n(b(A),N)]),ge(C,Q)}),ge(g,w)},$$slots:{default:!0}})}Se(K=>Te(q,K),[()=>u("image_download_canvas")]),ge(I,D)};st(de,I=>{b(h)==="single"&&b(J)&&I(ye)})}var Ke=_e(de,2);{var St=I=>{var D=dl(),z=$(D),j=$(z),q=$(j),U=_e(z,2);{let K=le(()=>u("image_download_image"));_i(U,{id:"tri-id-image",class:"tri-id-field-select",get"aria-label"(){return b(K)},get disabled(){return b(_)},get value(){return b(d)},onchange:g=>{G(d,we(g.currentTarget.value),!0)},children:(g,p)=>{var w=$r(),x=jt(w);gi(x,17,()=>b(he),Vi,(C,A,N)=>{var Q=cl(),W=$(Q);Q.value=Q.__value=N,Se(oe=>Te(W,oe),[()=>b(A).label??`${u("image_download_image")} ${N+1}`]),ge(C,Q)}),ge(g,w)},$$slots:{default:!0}})}Se(K=>Te(q,K),[()=>u("image_download_image")]),ge(I,D)};st(Ke,I=>{b(h)==="single"&&b(pe)&&I(St)})}var kt=_e(Ke,2),Nt=$(kt),Pt=$(Nt),dt=$(Pt),f=_e(Nt,2);{let I=le(()=>u("image_download_resolution")),D=le(()=>b(_)||b(y)||!b(m).length),z=le(()=>b(v)??"");_i(f,{id:"tri-id-resolution",class:"tri-id-field-select","data-tri-id-resolution":!0,get"aria-label"(){return b(I)},get disabled(){return b(D)},get value(){return b(z)},onchange:j=>{G(v,we(j.currentTarget.value),!0)},children:(j,q)=>{var U=pl(),K=jt(U),g=$(K);K.value=K.__value="";var p=_e(K,2);gi(p,17,()=>b(m),Vi,(w,x,C)=>{var A=fl(),N=$(A);A.value=A.__value=C,Se(()=>Te(N,b(x).label)),ge(w,A)}),Se(w=>Te(g,w),[()=>u("image_download_resolution_placeholder")]),ge(j,U)},$$slots:{default:!0}})}var T=_e(Ue,2);{var R=I=>{var D=wl(),z=$(D),j=$(z);{var q=w=>{var x=gl(),C=$(x),A=$(C);Se(()=>Te(A,b(S))),ge(w,x)};st(j,w=>{b(S)&&w(q)})}var U=_e(j,2);{var K=w=>{var x=ml(),C=$(x),A=$(C);Se(()=>Te(A,b(E))),ge(w,x)};st(U,w=>{b(E)&&w(K)})}var g=_e(U,2);{var p=w=>{var x=vl(),C=$(x),A=$(C);Se(()=>Te(A,b(fe))),ge(w,x)};st(g,w=>{b(fe)&&w(p)})}ge(I,D)};st(T,I=>{(b(S)||b(E)||b(fe))&&I(R)})}var O=_e(X,2),M=$(O);{let I=le(()=>!b(ve));ra(M,{variant:"primary",class:"tri-id-download","data-tri-id-download":!0,style:"width:100%",get disabled(){return b(I)},onclick:He,children:(D,z)=>{var j=yl(),q=jt(j);go(q,K=>xe?.(K));var U=_e(q);Se(K=>Te(U,` ${K??""}`),[()=>b(_)?u("image_download_downloading"):u("image_download_download")]),ge(D,j)},$$slots:{default:!0}})}vi(Xe,I=>G(P,I),()=>b(P)),Se((I,D)=>{Te(ct,I),Te(dt,D)},[()=>u("image_download_description"),()=>u("image_download_resolution")]),ge(n,Xe),Li()}const{STYLES:xl,STYLE_ID:El}=Qo(`
|
|
6
|
+
.tri-id {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
min-height: 0;
|
|
10
|
+
width: 100%;
|
|
11
|
+
color: var(--panel-fg, var(--tri-panel-content, currentColor));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.tri-id-body {
|
|
15
|
+
width: 100%;
|
|
16
|
+
padding: 1rem;
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
gap: 1rem;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.tri-id-desc {
|
|
23
|
+
font-size: 0.875rem;
|
|
24
|
+
line-height: 1.25rem;
|
|
25
|
+
margin: 0;
|
|
26
|
+
color: color-mix(in oklab, var(--panel-fg, currentColor) 70%, transparent);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.tri-id-fields {
|
|
30
|
+
display: grid;
|
|
31
|
+
grid-template-columns: repeat(1, minmax(0, 1fr));
|
|
32
|
+
gap: 0.75rem;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.tri-id-field {
|
|
36
|
+
width: 100%;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.tri-id-label {
|
|
40
|
+
display: inline-flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
gap: 0.375rem;
|
|
43
|
+
margin-bottom: 0.25rem;
|
|
44
|
+
white-space: nowrap;
|
|
45
|
+
font-size: 0.75rem;
|
|
46
|
+
color: color-mix(in oklab, currentColor 60%, transparent);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* The themed Select renders its wrapper with this class; stretch it to fill. */
|
|
50
|
+
.tri-id-field-select {
|
|
51
|
+
width: 100%;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.tri-id-card {
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
position: relative;
|
|
58
|
+
border-radius: var(--tri-radius-panels, 0.75rem);
|
|
59
|
+
border: 1px solid var(--tri-surface-border, rgb(0 0 0 / 0.15));
|
|
60
|
+
background-color: var(--tri-input-bg, #fff);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.tri-id-card-body {
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
flex: auto;
|
|
67
|
+
gap: 0.5rem;
|
|
68
|
+
padding: 1rem;
|
|
69
|
+
font-size: 0.875rem;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/*
|
|
73
|
+
* Soft alert: tinted background/border derived from --alert-color, no shadow.
|
|
74
|
+
* The color variant sets --alert-color (drives bg/border) and overrides the
|
|
75
|
+
* text color to the variant's *-content token.
|
|
76
|
+
*/
|
|
77
|
+
.tri-id-alert {
|
|
78
|
+
--alert-color: var(--panel-fg, currentColor);
|
|
79
|
+
display: grid;
|
|
80
|
+
grid-auto-flow: column;
|
|
81
|
+
grid-template-columns: auto;
|
|
82
|
+
justify-content: start;
|
|
83
|
+
place-items: center start;
|
|
84
|
+
gap: 1rem;
|
|
85
|
+
text-align: start;
|
|
86
|
+
padding-block: 0.5rem;
|
|
87
|
+
padding-inline: 1rem;
|
|
88
|
+
font-size: 0.875rem;
|
|
89
|
+
line-height: 1.25rem;
|
|
90
|
+
border: 1px solid
|
|
91
|
+
color-mix(in oklab, var(--alert-color) 10%, var(--tri-input-bg, #fff));
|
|
92
|
+
border-radius: var(--tri-radius-panels, 0.75rem);
|
|
93
|
+
color: var(--panel-fg, currentColor);
|
|
94
|
+
background: color-mix(
|
|
95
|
+
in oklab,
|
|
96
|
+
var(--alert-color) 8%,
|
|
97
|
+
var(--tri-input-bg, #fff)
|
|
98
|
+
);
|
|
99
|
+
box-shadow: none;
|
|
100
|
+
}
|
|
101
|
+
.tri-id-alert.is-success {
|
|
102
|
+
--alert-color: var(--tri-color-success, #16a34a);
|
|
103
|
+
color: var(--tri-color-success-content, currentColor);
|
|
104
|
+
}
|
|
105
|
+
.tri-id-alert.is-error {
|
|
106
|
+
--alert-color: var(--tri-color-error, #dc2626);
|
|
107
|
+
color: var(--tri-color-error-content, currentColor);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.tri-id-footer {
|
|
111
|
+
width: 100%;
|
|
112
|
+
padding: 1rem;
|
|
113
|
+
border-top: 1px solid var(--tri-surface-border, rgb(0 0 0 / 0.15));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* The themed Button renders with this class; size its download glyph. */
|
|
117
|
+
.tri-id-download svg {
|
|
118
|
+
width: 1.125rem;
|
|
119
|
+
height: 1.125rem;
|
|
120
|
+
fill: currentColor;
|
|
121
|
+
}
|
|
122
|
+
`,"panel"),bl=qo({name:"@triiiceratops/plugin-image-export",uiId:"image-download",version:"1.0.0-rc.0",coreRange:">=1.0.0-rc.0",pluginApiRange:"^1.0.0",requiredCapabilities:["osd@5"],icon:wn,target:"panel",catalog:ea,view:{mount(n,o){const e=o.styles.install(xl,El),t=o.styles.install($o,"bundled"),r=lo(Tl,{target:n,context:new Map([[vn,{context:o}]])});return()=>{ho(r),t(),e()}}}});function Sl(){const n=new Map;return{register(o){const e=n.get(o.name);if(!e){n.set(o.name,o);return}e.version!==o.version&&console.warn(`[triiiceratops] Ignoring plugin "${o.name}" version ${o.version}: version ${e.version} is already registered on this page and wins (first registration wins).`)},get(o){return n.get(o)},has(o){return n.has(o)},list(){return[...n.values()]}}}function Pl(n){(window.Triiiceratops??={coreVersion:"",pluginApiVersion:"",capabilities:[],plugins:Sl()}).plugins.register(n)}Pl(bl);function Rl(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Si={exports:{}},Cl=Si.exports,Bn;function Dl(){return Bn||(Bn=1,(function(n){//! openseadragon 5.0.1
|
|
123
|
+
//! Built on 2024-12-09
|
|
124
|
+
//! Git commit: v5.0.1-0-480de92d
|
|
125
|
+
//! http://openseadragon.github.io
|
|
126
|
+
//! License: http://openseadragon.github.io/license/
|
|
127
|
+
function o(e){return new o.Viewer(e)}(function(e){e.version={versionStr:"5.0.1",major:parseInt("5",10),minor:parseInt("0",10),revision:parseInt("1",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"},r=Object.prototype.toString,i=Object.prototype.hasOwnProperty;e.isFunction=function(s){return e.type(s)==="function"},e.isArray=Array.isArray||function(s){return e.type(s)==="array"},e.isWindow=function(s){return s&&typeof s=="object"&&"setInterval"in s},e.type=function(s){return s==null?String(s):t[r.call(s)]||"object"},e.isPlainObject=function(s){if(!s||o.type(s)!=="object"||s.nodeType||e.isWindow(s)||s.constructor&&!i.call(s,"constructor")&&!i.call(s.constructor.prototype,"isPrototypeOf"))return!1;var l;for(var a in s)l=a;return l===void 0||i.call(s,l)},e.isEmptyObject=function(s){for(var l in s)return!1;return!0},e.freezeObject=function(s){return Object.freeze?e.freezeObject=Object.freeze:e.freezeObject=function(l){return l},e.freezeObject(s)},e.supportsCanvas=(function(){var s=document.createElement("canvas");return!!(e.isFunction(s.getContext)&&s.getContext("2d"))})(),e.isCanvasTainted=function(s){var l=!1;try{s.getContext("2d").getImageData(0,0,1,1)}catch{l=!0}return l},e.supportsAddEventListener=(function(){return!!(document.documentElement.addEventListener&&document.addEventListener)})(),e.supportsRemoveEventListener=(function(){return!!(document.documentElement.removeEventListener&&document.removeEventListener)})(),e.supportsEventListenerOptions=(function(){var s=0;if(e.supportsAddEventListener)try{var l={get capture(){return s++,!1},get once(){return s++,!1},get passive(){return s++,!1}};window.addEventListener("test",null,l),window.removeEventListener("test",null,l)}catch{s=0}return s>=3})(),e.getCurrentPixelDensityRatio=function(){if(e.supportsCanvas){var s=document.createElement("canvas").getContext("2d"),l=window.devicePixelRatio||1,a=s.webkitBackingStorePixelRatio||s.mozBackingStorePixelRatio||s.msBackingStorePixelRatio||s.oBackingStorePixelRatio||s.backingStorePixelRatio||1;return Math.max(l,1)/a}else return 1},e.pixelDensityRatio=e.getCurrentPixelDensityRatio()})(o),(function(e){e.extend=function(){var a,u,h,c,d,m,v=arguments[0]||{},y=arguments.length,_=!1,E=1;for(typeof v=="boolean"&&(_=v,v=arguments[1]||{},E=2),typeof v!="object"&&!o.isFunction(v)&&(v={}),y===E&&(v=this,--E);E<y;E++)if(a=arguments[E],a!==null||a!==void 0)for(u in a){var S=Object.getOwnPropertyDescriptor(a,u);if(S!==void 0){if(S.get||S.set){Object.defineProperty(v,u,S);continue}c=S.value}else{e.console.warn('Could not copy inherited property "'+u+'".');continue}v!==c&&(_&&c&&(o.isPlainObject(c)||(d=o.isArray(c)))?(h=v[u],d?(d=!1,m=h&&o.isArray(h)?h:[]):m=h&&o.isPlainObject(h)?h:{},v[u]=o.extend(_,m,c)):c!==void 0&&(v[u]=c))}return v};var t=function(){if(typeof navigator!="object")return!1;var a=navigator.userAgent;return typeof a!="string"?!1:a.indexOf("iPhone")!==-1||a.indexOf("iPad")!==-1||a.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(a,u){return function(){var h=arguments;return h===void 0&&(h=[]),u.apply(a,h)}},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(a){return e._viewers.get(this.getElement(a))},getElement:function(a){return typeof a=="string"&&(a=document.getElementById(a)),a},getElementPosition:function(a){var u=new e.Point,h,c;for(a=e.getElement(a),h=e.getElementStyle(a).position==="fixed",c=l(a,h);c;)u.x+=a.offsetLeft,u.y+=a.offsetTop,h&&(u=u.plus(e.getPageScroll())),a=c,h=e.getElementStyle(a).position==="fixed",c=l(a,h);return u},getElementOffset:function(a){a=e.getElement(a);var u=a&&a.ownerDocument,h,c,d={top:0,left:0};return u?(h=u.documentElement,typeof a.getBoundingClientRect<"u"&&(d=a.getBoundingClientRect()),c=u===u.window?u:u.nodeType===9?u.defaultView||u.parentWindow:!1,new e.Point(d.left+(c.pageXOffset||h.scrollLeft)-(h.clientLeft||0),d.top+(c.pageYOffset||h.scrollTop)-(h.clientTop||0))):new e.Point},getElementSize:function(a){return a=e.getElement(a),new e.Point(a.clientWidth,a.clientHeight)},getElementStyle:document.documentElement.currentStyle?function(a){return a=e.getElement(a),a.currentStyle}:function(a){return a=e.getElement(a),window.getComputedStyle(a,"")},getCssPropertyWithVendorPrefix:function(a){var u={};return e.getCssPropertyWithVendorPrefix=function(h){if(u[h]!==void 0)return u[h];var c=document.createElement("div").style,d=null;if(c[h]!==void 0)d=h;else for(var m=["Webkit","Moz","MS","O","webkit","moz","ms","o"],v=e.capitalizeFirstLetter(h),y=0;y<m.length;y++){var _=m[y]+v;if(c[_]!==void 0){d=_;break}}return u[h]=d,d},e.getCssPropertyWithVendorPrefix(a)},capitalizeFirstLetter:function(a){return a.charAt(0).toUpperCase()+a.slice(1)},positiveModulo:function(a,u){var h=a%u;return h<0&&(h+=u),h},pointInElement:function(a,u){a=e.getElement(a);var h=e.getElementOffset(a),c=e.getElementSize(a);return u.x>=h.x&&u.x<h.x+c.x&&u.y<h.y+c.y&&u.y>=h.y},getMousePosition:function(a){if(typeof a.pageX=="number")e.getMousePosition=function(u){var h=new e.Point;return h.x=u.pageX,h.y=u.pageY,h};else if(typeof a.clientX=="number")e.getMousePosition=function(u){var h=new e.Point;return h.x=u.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,h.y=u.clientY+document.body.scrollTop+document.documentElement.scrollTop,h};else throw new Error("Unknown event mouse position, no known technique.");return e.getMousePosition(a)},getPageScroll:function(){var a=document.documentElement||{},u=document.body||{};if(typeof window.pageXOffset=="number")e.getPageScroll=function(){return new e.Point(window.pageXOffset,window.pageYOffset)};else if(u.scrollLeft||u.scrollTop)e.getPageScroll=function(){return new e.Point(document.body.scrollLeft,document.body.scrollTop)};else if(a.scrollLeft||a.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(a){if(typeof window.scrollTo<"u")e.setPageScroll=function(c){window.scrollTo(c.x,c.y)};else{var u=e.getPageScroll();if(u.x===a.x&&u.y===a.y)return;document.body.scrollLeft=a.x,document.body.scrollTop=a.y;var h=e.getPageScroll();if(h.x!==u.x&&h.y!==u.y){e.setPageScroll=function(c){document.body.scrollLeft=c.x,document.body.scrollTop=c.y};return}if(document.documentElement.scrollLeft=a.x,document.documentElement.scrollTop=a.y,h=e.getPageScroll(),h.x!==u.x&&h.y!==u.y){e.setPageScroll=function(c){document.documentElement.scrollLeft=c.x,document.documentElement.scrollTop=c.y};return}e.setPageScroll=function(c){}}e.setPageScroll(a)},getWindowSize:function(){var a=document.documentElement||{},u=document.body||{};if(typeof window.innerWidth=="number")e.getWindowSize=function(){return new e.Point(window.innerWidth,window.innerHeight)};else if(a.clientWidth||a.clientHeight)e.getWindowSize=function(){return new e.Point(document.documentElement.clientWidth,document.documentElement.clientHeight)};else if(u.clientWidth||u.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(a){a=e.getElement(a);var u=[e.makeNeutralElement("div"),e.makeNeutralElement("div"),e.makeNeutralElement("div")];return e.extend(u[0].style,{display:"table",height:"100%",width:"100%"}),e.extend(u[1].style,{display:"table-row"}),e.extend(u[2].style,{display:"table-cell",verticalAlign:"middle",textAlign:"center"}),u[0].appendChild(u[1]),u[1].appendChild(u[2]),u[2].appendChild(a),u[0]},makeNeutralElement:function(a){var u=document.createElement(a),h=u.style;return h.background="transparent none",h.border="none",h.margin="0px",h.padding="0px",h.position="static",u},now:function(){return Date.now?e.now=Date.now:e.now=function(){return new Date().getTime()},e.now()},makeTransparentImage:function(a){var u=e.makeNeutralElement("img");return u.src=a,u},setElementOpacity:function(a,u,h){var c,d;a=e.getElement(a),h&&!e.Browser.alpha&&(u=Math.round(u)),e.Browser.opacity?a.style.opacity=u<1?u:"":u<1?(c=Math.round(100*u),d="alpha(opacity="+c+")",a.style.filter=d):a.style.filter=""},setElementTouchActionNone:function(a){a=e.getElement(a),typeof a.style.touchAction<"u"?a.style.touchAction="none":typeof a.style.msTouchAction<"u"&&(a.style.msTouchAction="none")},setElementPointerEvents:function(a,u){a=e.getElement(a),typeof a.style<"u"&&typeof a.style.pointerEvents<"u"&&(a.style.pointerEvents=u)},setElementPointerEventsNone:function(a){e.setElementPointerEvents(a,"none")},addClass:function(a,u){a=e.getElement(a),a.className?(" "+a.className+" ").indexOf(" "+u+" ")===-1&&(a.className+=" "+u):a.className=u},indexOf:function(a,u,h){return Array.prototype.indexOf?this.indexOf=function(c,d,m){return c.indexOf(d,m)}:this.indexOf=function(c,d,m){var v,y=m||0,_;if(!c)throw new TypeError;if(_=c.length,_===0||y>=_)return-1;for(y<0&&(y=_-Math.abs(y)),v=y;v<_;v++)if(c[v]===d)return v;return-1},this.indexOf(a,u,h)},removeClass:function(a,u){var h,c=[],d;for(a=e.getElement(a),h=a.className.split(/\s+/),d=0;d<h.length;d++)h[d]&&h[d]!==u&&c.push(h[d]);a.className=c.join(" ")},normalizeEventListenerOptions:function(a){var u;return typeof a<"u"?typeof a=="boolean"?u=e.supportsEventListenerOptions?{capture:a}:a:u=e.supportsEventListenerOptions?a:typeof a.capture<"u"?a.capture:!1:u=e.supportsEventListenerOptions?{capture:!1}:!1,u},addEvent:(function(){if(e.supportsAddEventListener)return function(a,u,h,c){c=e.normalizeEventListenerOptions(c),a=e.getElement(a),a.addEventListener(u,h,c)};if(document.documentElement.attachEvent&&document.attachEvent)return function(a,u,h){a=e.getElement(a),a.attachEvent("on"+u,h)};throw new Error("No known event model.")})(),removeEvent:(function(){if(e.supportsRemoveEventListener)return function(a,u,h,c){c=e.normalizeEventListenerOptions(c),a=e.getElement(a),a.removeEventListener(u,h,c)};if(document.documentElement.detachEvent&&document.detachEvent)return function(a,u,h){a=e.getElement(a),a.detachEvent("on"+u,h)};throw new Error("No known event model.")})(),cancelEvent:function(a){a.preventDefault()},eventIsCanceled:function(a){return a.defaultPrevented},stopEvent:function(a){a.stopPropagation()},createCallback:function(a,u){console.error("The createCallback function is deprecated and will be removed in future versions. Please use alternativeFunction instead.");var h=[],c;for(c=2;c<arguments.length;c++)h.push(arguments[c]);return function(){var d=h.concat([]),m;for(m=0;m<arguments.length;m++)d.push(arguments[m]);return u.apply(a,d)}},getUrlParameter:function(a){var u=s[a];return u||null},getUrlProtocol:function(a){var u=a.match(/^([a-z]+:)\/\//i);return u===null?window.location.protocol:u[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(a,u,h){var c,d,m,v;e.isPlainObject(a)&&(u=a.success,h=a.error,c=a.withCredentials,d=a.headers,m=a.responseType||null,v=a.postData||null,a=a.url);var y=e.getUrlProtocol(a),_=e.createAjaxRequest();if(!e.isFunction(u))throw new Error("makeAjaxRequest requires a success callback");_.onreadystatechange=function(){_.readyState===4&&(_.onreadystatechange=function(){},_.status>=200&&_.status<300||_.status===0&&y!=="http:"&&y!=="https:"?u(_):e.isFunction(h)?h(_):e.console.error("AJAX request returned %d: %s",_.status,a))};var E=v?"POST":"GET";try{if(_.open(E,a,!0),m&&(_.responseType=m),d)for(var S in d)Object.prototype.hasOwnProperty.call(d,S)&&d[S]&&_.setRequestHeader(S,d[S]);c&&(_.withCredentials=!0),_.send(v)}catch(P){e.console.error("%s while making AJAX request: %s",P.name,P.message),_.onreadystatechange=function(){},e.isFunction(h)&&h(_,P)}return _},jsonp:function(a){var u,h=a.url,c=document.head||document.getElementsByTagName("head")[0]||document.documentElement,d=a.callbackName||"openseadragon"+e.now(),m=window[d],v="$1"+d+"$2",y=a.param||"callback",_=a.callback;h=h.replace(/(=)\?(&|$)|\?\?/i,v),h+=(/\?/.test(h)?"&":"?")+y+"="+d,window[d]=function(E){if(m)window[d]=m;else try{delete window[d]}catch{}_&&e.isFunction(_)&&_(E)},u=document.createElement("script"),(a.async!==void 0||a.async!==!1)&&(u.async="async"),a.scriptCharset&&(u.charset=a.scriptCharset),u.src=h,u.onload=u.onreadystatechange=function(E,S){(S||!u.readyState||/loaded|complete/.test(u.readyState))&&(u.onload=u.onreadystatechange=null,c&&u.parentNode&&c.removeChild(u),u=void 0)},c.insertBefore(u,c.firstChild)},createFromDZI:function(){throw"OpenSeadragon.createFromDZI is deprecated, use Viewer.open."},parseXml:function(a){if(window.DOMParser)e.parseXml=function(u){var h=null,c;return c=new DOMParser,h=c.parseFromString(u,"text/xml"),h};else throw new Error("Browser doesn't support XML DOM.");return e.parseXml(a)},parseJSON:function(a){return e.parseJSON=window.JSON.parse,e.parseJSON(a)},imageFormatSupported:function(a){return a=a||"",!!i[a.toLowerCase()]},setImageFormatsSupported:function(a){e.extend(i,a)}});var r=function(a){};e.console=window.console||{log:r,debug:r,info:r,warn:r,error:r,assert:r},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},s={};(function(){var a=navigator.appVersion,u=navigator.userAgent,h;switch(navigator.appName){case"Microsoft Internet Explorer":window.attachEvent&&window.ActiveXObject&&(e.Browser.vendor=e.BROWSERS.IE,e.Browser.version=parseFloat(u.substring(u.indexOf("MSIE")+5,u.indexOf(";",u.indexOf("MSIE")))));break;case"Netscape":window.addEventListener&&(u.indexOf("Edge")>=0?(e.Browser.vendor=e.BROWSERS.EDGE,e.Browser.version=parseFloat(u.substring(u.indexOf("Edge")+5))):u.indexOf("Edg")>=0?(e.Browser.vendor=e.BROWSERS.CHROMEEDGE,e.Browser.version=parseFloat(u.substring(u.indexOf("Edg")+4))):u.indexOf("Firefox")>=0?(e.Browser.vendor=e.BROWSERS.FIREFOX,e.Browser.version=parseFloat(u.substring(u.indexOf("Firefox")+8))):u.indexOf("Safari")>=0?(e.Browser.vendor=u.indexOf("Chrome")>=0?e.BROWSERS.CHROME:e.BROWSERS.SAFARI,e.Browser.version=parseFloat(u.substring(u.substring(0,u.indexOf("Safari")).lastIndexOf("/")+1,u.indexOf("Safari")))):(h=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})"),h.exec(u)!==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(a);break}var c=window.location.search.substring(1),d=c.split("&"),m,v,y;for(y=0;y<d.length;y++)if(m=d[y],v=m.indexOf("="),v>0){var _=m.substring(0,v),E=m.substring(v+1);try{s[_]=decodeURIComponent(E)}catch{e.console.error("Ignoring malformed URL parameter: %s=%s",_,E)}}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(a){var u=a.requestAnimationFrame||a.mozRequestAnimationFrame||a.webkitRequestAnimationFrame||a.msRequestAnimationFrame,h=a.cancelAnimationFrame||a.mozCancelAnimationFrame||a.webkitCancelAnimationFrame||a.msCancelAnimationFrame;if(u&&h)e.requestAnimationFrame=function(){return u.apply(a,arguments)},e.cancelAnimationFrame=function(){return h.apply(a,arguments)};else{var c=[],d=[],m=0,v;e.requestAnimationFrame=function(y){return c.push([++m,y]),v||(v=setInterval(function(){if(c.length){var _=e.now(),E=d;for(d=c,c=E;d.length;)d.shift()[1](_)}else clearInterval(v),v=void 0},1e3/50)),m},e.cancelAnimationFrame=function(y){var _,E;for(_=0,E=c.length;_<E;_+=1)if(c[_][0]===y){c.splice(_,1);return}for(_=0,E=d.length;_<E;_+=1)if(d[_][0]===y){d.splice(_,1);return}}}})(window);function l(a,u){return u&&a!==document.body?document.body:a.offsetParent}})(o),(function(e,t){n.exports?n.exports=t():e.OpenSeadragon=t()})(Cl,function(){return o}),(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,s){return new t([1,0,0,0,1,0,i,s,1])}static makeRotation(i){var s=Math.cos(i),l=Math.sin(i);return new t([s,-l,0,l,s,0,0,0,1])}static makeScaling(i,s){return new t([i,0,0,0,s,0,0,0,1])}multiply(i){let s=this.values,l=i.values;var a=s[0],u=s[1],h=s[2],c=s[3],d=s[4],m=s[5],v=s[6],y=s[7],_=s[8],E=l[0],S=l[1],P=l[2],L=l[3],F=l[4],H=l[5],B=l[6],V=l[7],Y=l[8];return new t([E*a+S*c+P*v,E*u+S*d+P*y,E*h+S*m+P*_,L*a+F*c+H*v,L*u+F*d+H*y,L*h+F*m+H*_,B*a+V*c+Y*v,B*u+V*d+Y*y,B*h+V*m+Y*_])}}e.Mat3=t})(o),(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(r){return r.requestFullscreen().catch(function(i){e.console.error("Fullscreen request failed: ",i)})},t.exitFullScreen=function(){document.exitFullscreen().catch(function(r){e.console.error("Error while exiting fullscreen: ",r)})},t.fullScreenEventName="fullscreenchange",t.fullScreenErrorEventName="fullscreenerror"):document.msExitFullscreen?(t.supportsFullScreen=!0,t.getFullScreenElement=function(){return document.msFullscreenElement},t.requestFullScreen=function(r){return r.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(r){return r.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(r){return r.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(r){return r.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)})(o),(function(e){e.EventSource=function(){this.events={},this._rejectedEventList={}},e.EventSource.prototype={addOnceHandler:function(t,r,i,s,l){var a=this;s=s||1;var u=0,h=function(c){return u++,u===s&&a.removeHandler(t,h),r(c)};return this.addHandler(t,h,i,l)},addHandler:function(t,r,i,s){if(Object.prototype.hasOwnProperty.call(this._rejectedEventList,t))return e.console.error(`Error adding handler for ${t}. ${this._rejectedEventList[t]}`),!1;var l=this.events[t];if(l||(this.events[t]=l=[]),r&&e.isFunction(r)){var a=l.length,u={handler:r,userData:i||null,priority:s||0};for(l[a]=u;a>0&&l[a-1].priority<l[a].priority;)l[a]=l[a-1],l[a-1]=u,a--}return!0},removeHandler:function(t,r){var i=this.events[t],s=[],l;if(i&&e.isArray(i)){for(l=0;l<i.length;l++)i[l].handler!==r&&s.push(i[l]);this.events[t]=s}},numberOfHandlers:function(t){var r=this.events[t];return r?r.length:0},removeAllHandlers:function(t){if(t)this.events[t]=[];else for(var r in this.events)this.events[r]=[]},getHandler:function(t){var r=this.events[t];return!r||!r.length?null:(r=r.length===1?[r[0]]:Array.apply(null,r),function(i,s){var l,a=r.length;for(l=0;l<a;l++)r[l]&&(s.eventSource=i,s.userData=r[l].userData,r[l].handler(s))})},raiseEvent:function(t,r){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,r||{}),!0},rejectEventHandler(t,r=""){this._rejectedEventList[t]=r},allowEventHandler(t){delete this._rejectedEventList[t]}}})(o),(function(e){var t={};e.MouseTracker=function(g){var p=arguments;e.isPlainObject(g)||(g={element:p[0],clickTimeThreshold:p[1],clickDistThreshold:p[2]}),this.hash=Math.random(),this.element=e.getElement(g.element),this.clickTimeThreshold=g.clickTimeThreshold||e.DEFAULT_SETTINGS.clickTimeThreshold,this.clickDistThreshold=g.clickDistThreshold||e.DEFAULT_SETTINGS.clickDistThreshold,this.dblClickTimeThreshold=g.dblClickTimeThreshold||e.DEFAULT_SETTINGS.dblClickTimeThreshold,this.dblClickDistThreshold=g.dblClickDistThreshold||e.DEFAULT_SETTINGS.dblClickDistThreshold,this.userData=g.userData||null,this.stopDelay=g.stopDelay||50,this.preProcessEventHandler=g.preProcessEventHandler||null,this.contextMenuHandler=g.contextMenuHandler||null,this.enterHandler=g.enterHandler||null,this.leaveHandler=g.leaveHandler||null,this.exitHandler=g.exitHandler||null,this.overHandler=g.overHandler||null,this.outHandler=g.outHandler||null,this.pressHandler=g.pressHandler||null,this.nonPrimaryPressHandler=g.nonPrimaryPressHandler||null,this.releaseHandler=g.releaseHandler||null,this.nonPrimaryReleaseHandler=g.nonPrimaryReleaseHandler||null,this.moveHandler=g.moveHandler||null,this.scrollHandler=g.scrollHandler||null,this.clickHandler=g.clickHandler||null,this.dblClickHandler=g.dblClickHandler||null,this.dragHandler=g.dragHandler||null,this.dragEndHandler=g.dragEndHandler||null,this.pinchHandler=g.pinchHandler||null,this.stopHandler=g.stopHandler||null,this.keyDownHandler=g.keyDownHandler||null,this.keyUpHandler=g.keyUpHandler||null,this.keyHandler=g.keyHandler||null,this.focusHandler=g.focusHandler||null,this.blurHandler=g.blurHandler||null;var w=this;t[this.hash]={click:function(x){P(w,x)},dblclick:function(x){L(w,x)},keydown:function(x){F(w,x)},keyup:function(x){H(w,x)},keypress:function(x){B(w,x)},focus:function(x){V(w,x)},blur:function(x){Y(w,x)},contextmenu:function(x){J(w,x)},wheel:function(x){re(w,x)},mousewheel:function(x){Z(w,x)},DOMMouseScroll:function(x){Z(w,x)},MozMousePixelScroll:function(x){Z(w,x)},losecapture:function(x){he(w,x)},mouseenter:function(x){X(w,x)},mouseleave:function(x){Ye(w,x)},mouseover:function(x){ct(w,x)},mouseout:function(x){Ue(w,x)},mousedown:function(x){k(w,x)},mouseup:function(x){te(w,x)},mousemove:function(x){Ke(w,x)},touchstart:function(x){pe(w,x)},touchend:function(x){ce(w,x)},touchmove:function(x){ve(w,x)},touchcancel:function(x){fe(w,x)},gesturestart:function(x){we(w,x)},gesturechange:function(x){He(w,x)},gotpointercapture:function(x){xe(w,x)},lostpointercapture:function(x){Xe(w,x)},pointerenter:function(x){X(w,x)},pointerleave:function(x){Ye(w,x)},pointerover:function(x){ct(w,x)},pointerout:function(x){Ue(w,x)},pointerdown:function(x){k(w,x)},pointerup:function(x){te(w,x)},pointermove:function(x){Ke(w,x)},pointercancel:function(x){Nt(w,x)},pointerupcaptured:function(x){de(w,x)},pointermovecaptured:function(x){St(w,x)},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."),g.startDisabled||this.setTracking(!0)},e.MouseTracker.prototype={destroy:function(){a(this),this.element=null,t[this.hash]=null,delete t[this.hash]},isTracking:function(){return t[this.hash].tracking},setTracking:function(g){return g?l(this):a(this),this},getActivePointersListByType:function(g){var p=t[this.hash],w,x=p?p.activePointersLists.length:0,C;for(w=0;w<x;w++)if(p.activePointersLists[w].type===g)return p.activePointersLists[w];return C=new e.MouseTracker.GesturePointList(g),p&&p.activePointersLists.push(C),C},getActivePointerCount:function(){var g=t[this.hash],p,w=g.activePointersLists.length,x=0;for(p=0;p<w;p++)x+=g.activePointersLists[p].getLength();return x},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 r=(function(){try{return window.self!==window.top}catch{return!0}})();function i(g){try{return g.addEventListener&&g.removeEventListener}catch{return!1}}e.MouseTracker.gesturePointVelocityTracker=(function(){var g=[],p=0,w=0,x=function(Q,W){return Q.hash.toString()+W.type+W.id.toString()},C=function(){var Q,W=g.length,oe,se,Qe=e.now(),Ut,zn,kn;for(Ut=Qe-w,w=Qe,Q=0;Q<W;Q++)oe=g[Q],se=oe.gPoint,se.direction=Math.atan2(se.currentPos.y-oe.lastPos.y,se.currentPos.x-oe.lastPos.x),zn=oe.lastPos.distanceTo(se.currentPos),oe.lastPos=se.currentPos,kn=1e3*zn/(Ut+1),se.speed=.75*kn+.25*se.speed},A=function(Q,W){var oe=x(Q,W);g.push({guid:oe,gPoint:W,lastPos:W.currentPos}),g.length===1&&(w=e.now(),p=window.setInterval(C,50))},N=function(Q,W){var oe=x(Q,W),se,Qe=g.length;for(se=0;se<Qe;se++)if(g[se].guid===oe){g.splice(se,1),Qe--,Qe===0&&window.clearInterval(p);break}};return{addPoint:A,removePoint:N}})(),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 g=document.createElement("div");return e.isFunction(g.setPointerCapture)&&e.isFunction(g.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 g=document.createElement("div");return e.isFunction(g.setCapture)&&e.isFunction(g.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(g){this._gPoints=[],this.type=g,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(g){return this._gPoints.push(g)},removeById:function(g){var p,w=this._gPoints.length;for(p=0;p<w;p++)if(this._gPoints[p].id===g){this._gPoints.splice(p,1);break}return this._gPoints.length},getByIndex:function(g){return g<this._gPoints.length?this._gPoints[g]:null},getById:function(g){var p,w=this._gPoints.length;for(p=0;p<w;p++)if(this._gPoints[p].id===g)return this._gPoints[p];return null},getPrimary:function(g){var p,w=this._gPoints.length;for(p=0;p<w;p++)if(this._gPoints[p].isPrimary)return this._gPoints[p];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 s(g){var p=t[g.hash],w,x,C,A,N,Q=p.activePointersLists.length;for(w=0;w<Q;w++)if(C=p.activePointersLists[w],C.getLength()>0){for(N=[],A=C.asArray(),x=0;x<A.length;x++)N.push(A[x]);for(x=0;x<N.length;x++)dt(g,C,N[x])}for(w=0;w<Q;w++)p.activePointersLists.pop();p.sentDragEvent=!1}function l(g){var p=t[g.hash],w,x;if(!p.tracking){for(x=0;x<e.MouseTracker.subscribeEvents.length;x++)w=e.MouseTracker.subscribeEvents[x],e.addEvent(g.element,w,p[w],w===e.MouseTracker.wheelEventName?{passive:!1,capture:!1}:!1);s(g),p.tracking=!0}}function a(g){var p=t[g.hash],w,x;if(p.tracking){for(x=0;x<e.MouseTracker.subscribeEvents.length;x++)w=e.MouseTracker.subscribeEvents[x],e.removeEvent(g.element,w,p[w],!1);s(g),p.tracking=!1}}function u(g,p){var w=t[g.hash];if(p==="pointerevent")return{upName:"pointerup",upHandler:w.pointerupcaptured,moveName:"pointermove",moveHandler:w.pointermovecaptured};if(p==="mouse")return{upName:"pointerup",upHandler:w.pointerupcaptured,moveName:"pointermove",moveHandler:w.pointermovecaptured};if(p==="touch")return{upName:"touchend",upHandler:w.touchendcaptured,moveName:"touchmove",moveHandler:w.touchmovecaptured};throw new Error("MouseTracker.getCaptureEventParams: Unknown pointer type.")}function h(g,p){var w;if(e.MouseTracker.havePointerCapture)if(e.MouseTracker.havePointerEvents)try{g.element.setPointerCapture(p.id)}catch{e.console.warn("setPointerCapture() called on invalid pointer ID");return}else g.element.setCapture(!0);else w=u(g,e.MouseTracker.havePointerEvents?"pointerevent":p.type),r&&i(window.top)&&e.addEvent(window.top,w.upName,w.upHandler,!0),e.addEvent(e.MouseTracker.captureElement,w.upName,w.upHandler,!0),e.addEvent(e.MouseTracker.captureElement,w.moveName,w.moveHandler,!0);R(g,p,!0)}function c(g,p){var w,x,C;if(e.MouseTracker.havePointerCapture)if(e.MouseTracker.havePointerEvents){if(x=g.getActivePointersListByType(p.type),C=x.getById(p.id),!C||!C.captured)return;try{g.element.releasePointerCapture(p.id)}catch{}}else g.element.releaseCapture();else w=u(g,e.MouseTracker.havePointerEvents?"pointerevent":p.type),r&&i(window.top)&&e.removeEvent(window.top,w.upName,w.upHandler,!0),e.removeEvent(e.MouseTracker.captureElement,w.moveName,w.moveHandler,!0),e.removeEvent(e.MouseTracker.captureElement,w.upName,w.upHandler,!0);R(g,p,!1)}function d(g){return e.MouseTracker.havePointerEvents?g.pointerId:e.MouseTracker.mousePointerId}function m(g){return e.MouseTracker.havePointerEvents&&g.pointerType?g.pointerType:"mouse"}function v(g){return e.MouseTracker.havePointerEvents?g.isPrimary:!0}function y(g){return e.getMousePosition(g)}function _(g,p){return E(y(g),p)}function E(g,p){var w=e.getElementOffset(p);return g.minus(w)}function S(g,p){return new e.Point((g.x+p.x)/2,(g.y+p.y)/2)}function P(g,p){var w={originalEvent:p,eventType:"click",pointerType:"mouse",isEmulated:!1};T(g,w),w.preventDefault&&!w.defaultPrevented&&e.cancelEvent(p),w.stopPropagation&&e.stopEvent(p)}function L(g,p){var w={originalEvent:p,eventType:"dblclick",pointerType:"mouse",isEmulated:!1};T(g,w),w.preventDefault&&!w.defaultPrevented&&e.cancelEvent(p),w.stopPropagation&&e.stopEvent(p)}function F(g,p){var w=null,x={originalEvent:p,eventType:"keydown",pointerType:"",isEmulated:!1};T(g,x),g.keyDownHandler&&!x.preventGesture&&!x.defaultPrevented&&(w={eventSource:g,keyCode:p.keyCode?p.keyCode:p.charCode,ctrl:p.ctrlKey,shift:p.shiftKey,alt:p.altKey,meta:p.metaKey,originalEvent:p,preventDefault:x.preventDefault||x.defaultPrevented,userData:g.userData},g.keyDownHandler(w)),(w&&w.preventDefault||x.preventDefault&&!x.defaultPrevented)&&e.cancelEvent(p),x.stopPropagation&&e.stopEvent(p)}function H(g,p){var w=null,x={originalEvent:p,eventType:"keyup",pointerType:"",isEmulated:!1};T(g,x),g.keyUpHandler&&!x.preventGesture&&!x.defaultPrevented&&(w={eventSource:g,keyCode:p.keyCode?p.keyCode:p.charCode,ctrl:p.ctrlKey,shift:p.shiftKey,alt:p.altKey,meta:p.metaKey,originalEvent:p,preventDefault:x.preventDefault||x.defaultPrevented,userData:g.userData},g.keyUpHandler(w)),(w&&w.preventDefault||x.preventDefault&&!x.defaultPrevented)&&e.cancelEvent(p),x.stopPropagation&&e.stopEvent(p)}function B(g,p){var w=null,x={originalEvent:p,eventType:"keypress",pointerType:"",isEmulated:!1};T(g,x),g.keyHandler&&!x.preventGesture&&!x.defaultPrevented&&(w={eventSource:g,keyCode:p.keyCode?p.keyCode:p.charCode,ctrl:p.ctrlKey,shift:p.shiftKey,alt:p.altKey,meta:p.metaKey,originalEvent:p,preventDefault:x.preventDefault||x.defaultPrevented,userData:g.userData},g.keyHandler(w)),(w&&w.preventDefault||x.preventDefault&&!x.defaultPrevented)&&e.cancelEvent(p),x.stopPropagation&&e.stopEvent(p)}function V(g,p){var w={originalEvent:p,eventType:"focus",pointerType:"",isEmulated:!1};T(g,w),g.focusHandler&&!w.preventGesture&&g.focusHandler({eventSource:g,originalEvent:p,userData:g.userData})}function Y(g,p){var w={originalEvent:p,eventType:"blur",pointerType:"",isEmulated:!1};T(g,w),g.blurHandler&&!w.preventGesture&&g.blurHandler({eventSource:g,originalEvent:p,userData:g.userData})}function J(g,p){var w=null,x={originalEvent:p,eventType:"contextmenu",pointerType:"mouse",isEmulated:!1};T(g,x),g.contextMenuHandler&&!x.preventGesture&&!x.defaultPrevented&&(w={eventSource:g,position:E(y(p),g.element),originalEvent:x.originalEvent,preventDefault:x.preventDefault||x.defaultPrevented,userData:g.userData},g.contextMenuHandler(w)),(w&&w.preventDefault||x.preventDefault&&!x.defaultPrevented)&&e.cancelEvent(p),x.stopPropagation&&e.stopEvent(p)}function re(g,p){ie(g,p,p)}function Z(g,p){var w={target:p.target||p.srcElement,type:"wheel",shiftKey:p.shiftKey||!1,clientX:p.clientX,clientY:p.clientY,pageX:p.pageX?p.pageX:p.clientX,pageY:p.pageY?p.pageY:p.clientY,deltaMode:p.type==="MozMousePixelScroll"?0:1,deltaX:0,deltaZ:0};e.MouseTracker.wheelEventName==="mousewheel"?w.deltaY=-p.wheelDelta/e.DEFAULT_SETTINGS.pixelsPerWheelLine:w.deltaY=p.detail,ie(g,w,p)}function ie(g,p,w){var x=0,C,A=null;x=p.deltaY?p.deltaY<0?1:-1:0,C={originalEvent:p,eventType:"wheel",pointerType:"mouse",isEmulated:p!==w},T(g,C),g.scrollHandler&&!C.preventGesture&&!C.defaultPrevented&&(A={eventSource:g,pointerType:"mouse",position:_(p,g.element),scroll:x,shift:p.shiftKey,isTouchEvent:!1,originalEvent:w,preventDefault:C.preventDefault||C.defaultPrevented,userData:g.userData},g.scrollHandler(A)),C.stopPropagation&&e.stopEvent(w),(A&&A.preventDefault||C.preventDefault&&!C.defaultPrevented)&&e.cancelEvent(w)}function he(g,p){var w={id:e.MouseTracker.mousePointerId,type:"mouse"},x={originalEvent:p,eventType:"lostpointercapture",pointerType:"mouse",isEmulated:!1};T(g,x),p.target===g.element&&R(g,w,!1),x.stopPropagation&&e.stopEvent(p)}function pe(g,p){var w,x,C=p.changedTouches.length,A,N=g.getActivePointersListByType("touch");w=e.now(),N.getLength()>p.touches.length-C&&e.console.warn("Tracked touch contact count doesn't match event.touches.length");var Q={originalEvent:p,eventType:"pointerdown",pointerType:"touch",isEmulated:!1};for(T(g,Q),x=0;x<C;x++)A={id:p.changedTouches[x].identifier,type:"touch",isPrimary:N.getLength()===0,currentPos:y(p.changedTouches[x]),currentTime:w},O(g,Q,A),z(g,Q,A,0),R(g,A,!0);Q.preventDefault&&!Q.defaultPrevented&&e.cancelEvent(p),Q.stopPropagation&&e.stopEvent(p)}function ce(g,p){var w,x,C=p.changedTouches.length,A;w=e.now();var N={originalEvent:p,eventType:"pointerup",pointerType:"touch",isEmulated:!1};for(T(g,N),x=0;x<C;x++)A={id:p.changedTouches[x].identifier,type:"touch",currentPos:y(p.changedTouches[x]),currentTime:w},j(g,N,A,0),R(g,A,!1),M(g,N,A);N.preventDefault&&!N.defaultPrevented&&e.cancelEvent(p),N.stopPropagation&&e.stopEvent(p)}function ve(g,p){var w,x,C=p.changedTouches.length,A;w=e.now();var N={originalEvent:p,eventType:"pointermove",pointerType:"touch",isEmulated:!1};for(T(g,N),x=0;x<C;x++)A={id:p.changedTouches[x].identifier,type:"touch",currentPos:y(p.changedTouches[x]),currentTime:w},q(g,N,A);N.preventDefault&&!N.defaultPrevented&&e.cancelEvent(p),N.stopPropagation&&e.stopEvent(p)}function fe(g,p){var w=p.changedTouches.length,x,C,A={originalEvent:p,eventType:"pointercancel",pointerType:"touch",isEmulated:!1};for(T(g,A),x=0;x<w;x++)C={id:p.changedTouches[x].identifier,type:"touch"},U(g,A,C);A.stopPropagation&&e.stopEvent(p)}function we(g,p){return e.eventIsCanceled(p)||p.preventDefault(),!1}function He(g,p){return e.eventIsCanceled(p)||p.preventDefault(),!1}function xe(g,p){var w={originalEvent:p,eventType:"gotpointercapture",pointerType:m(p),isEmulated:!1};T(g,w),p.target===g.element&&R(g,{id:p.pointerId,type:m(p)},!0),w.stopPropagation&&e.stopEvent(p)}function Xe(g,p){var w={originalEvent:p,eventType:"lostpointercapture",pointerType:m(p),isEmulated:!1};T(g,w),p.target===g.element&&R(g,{id:p.pointerId,type:m(p)},!1),w.stopPropagation&&e.stopEvent(p)}function X(g,p){var w={id:d(p),type:m(p),isPrimary:v(p),currentPos:y(p),currentTime:e.now()},x={originalEvent:p,eventType:"pointerenter",pointerType:w.type,isEmulated:!1};T(g,x),O(g,x,w)}function Ye(g,p){var w={id:d(p),type:m(p),isPrimary:v(p),currentPos:y(p),currentTime:e.now()},x={originalEvent:p,eventType:"pointerleave",pointerType:w.type,isEmulated:!1};T(g,x),M(g,x,w)}function ct(g,p){var w={id:d(p),type:m(p),isPrimary:v(p),currentPos:y(p),currentTime:e.now()},x={originalEvent:p,eventType:"pointerover",pointerType:w.type,isEmulated:!1};T(g,x),I(g,x,w),x.preventDefault&&!x.defaultPrevented&&e.cancelEvent(p),x.stopPropagation&&e.stopEvent(p)}function Ue(g,p){var w={id:d(p),type:m(p),isPrimary:v(p),currentPos:y(p),currentTime:e.now()},x={originalEvent:p,eventType:"pointerout",pointerType:w.type,isEmulated:!1};T(g,x),D(g,x,w),x.preventDefault&&!x.defaultPrevented&&e.cancelEvent(p),x.stopPropagation&&e.stopEvent(p)}function k(g,p){var w={id:d(p),type:m(p),isPrimary:v(p),currentPos:y(p),currentTime:e.now()},x=e.MouseTracker.havePointerEvents&&w.type==="touch",C={originalEvent:p,eventType:"pointerdown",pointerType:w.type,isEmulated:!1};T(g,C),z(g,C,w,p.button),C.preventDefault&&!C.defaultPrevented&&e.cancelEvent(p),C.stopPropagation&&e.stopEvent(p),C.shouldCapture&&(x?R(g,w,!0):h(g,w))}function te(g,p){ye(g,p)}function de(g,p){var w=g.getActivePointersListByType(m(p));w.getById(p.pointerId)&&ye(g,p),e.stopEvent(p)}function ye(g,p){var w;w={id:d(p),type:m(p),isPrimary:v(p),currentPos:y(p),currentTime:e.now()};var x={originalEvent:p,eventType:"pointerup",pointerType:w.type,isEmulated:!1};T(g,x),j(g,x,w,p.button),x.preventDefault&&!x.defaultPrevented&&e.cancelEvent(p),x.stopPropagation&&e.stopEvent(p),x.shouldReleaseCapture&&(p.target===g.element?c(g,w):R(g,w,!1))}function Ke(g,p){kt(g,p)}function St(g,p){var w=g.getActivePointersListByType(m(p));w.getById(p.pointerId)&&kt(g,p),e.stopEvent(p)}function kt(g,p){var w={id:d(p),type:m(p),isPrimary:v(p),currentPos:y(p),currentTime:e.now()},x={originalEvent:p,eventType:"pointermove",pointerType:w.type,isEmulated:!1};T(g,x),q(g,x,w),x.preventDefault&&!x.defaultPrevented&&e.cancelEvent(p),x.stopPropagation&&e.stopEvent(p)}function Nt(g,p){var w={id:p.pointerId,type:m(p)},x={originalEvent:p,eventType:"pointercancel",pointerType:w.type,isEmulated:!1};T(g,x),U(g,x,w),x.stopPropagation&&e.stopEvent(p)}function Pt(g,p){return p.speed=0,p.direction=0,p.contactPos=p.currentPos,p.contactTime=p.currentTime,p.lastPos=p.currentPos,p.lastTime=p.currentTime,g.add(p)}function dt(g,p,w){var x,C=p.getById(w.id);return C?(C.captured&&(e.console.warn("stopTrackingPointer() called on captured pointer"),c(g,C)),p.removeContact(),x=p.removeById(w.id)):x=p.getLength(),x}function f(g,p){switch(p.eventType){case"pointermove":p.isStoppable=!0,p.isCancelable=!0,p.preventDefault=!1,p.preventGesture=!g.hasGestureHandlers,p.stopPropagation=!1;break;case"pointerover":case"pointerout":case"contextmenu":case"keydown":case"keyup":case"keypress":p.isStoppable=!0,p.isCancelable=!0,p.preventDefault=!1,p.preventGesture=!1,p.stopPropagation=!1;break;case"pointerdown":p.isStoppable=!0,p.isCancelable=!0,p.preventDefault=!1,p.preventGesture=!g.hasGestureHandlers,p.stopPropagation=!1;break;case"pointerup":p.isStoppable=!0,p.isCancelable=!0,p.preventDefault=!1,p.preventGesture=!g.hasGestureHandlers,p.stopPropagation=!1;break;case"wheel":p.isStoppable=!0,p.isCancelable=!0,p.preventDefault=!1,p.preventGesture=!g.hasScrollHandler,p.stopPropagation=!1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":p.isStoppable=!0,p.isCancelable=!1,p.preventDefault=!1,p.preventGesture=!1,p.stopPropagation=!1;break;case"click":p.isStoppable=!0,p.isCancelable=!0,p.preventDefault=!!g.clickHandler,p.preventGesture=!1,p.stopPropagation=!1;break;case"dblclick":p.isStoppable=!0,p.isCancelable=!0,p.preventDefault=!!g.dblClickHandler,p.preventGesture=!1,p.stopPropagation=!1;break;case"focus":case"blur":case"pointerenter":case"pointerleave":default:p.isStoppable=!1,p.isCancelable=!1,p.preventDefault=!1,p.preventGesture=!1,p.stopPropagation=!1;break}}function T(g,p){p.eventSource=g,p.eventPhase=p.originalEvent&&typeof p.originalEvent.eventPhase<"u"?p.originalEvent.eventPhase:0,p.defaultPrevented=e.eventIsCanceled(p.originalEvent),p.shouldCapture=!1,p.shouldReleaseCapture=!1,p.userData=g.userData,f(g,p),g.preProcessEventHandler&&g.preProcessEventHandler(p)}function R(g,p,w){var x=g.getActivePointersListByType(p.type),C=x.getById(p.id);C?w&&!C.captured?(C.captured=!0,x.captureCount++):!w&&C.captured&&(C.captured=!1,x.captureCount--,x.captureCount<0&&(x.captureCount=0,e.console.warn("updatePointerCaptured() - pointsList.captureCount went negative"))):e.console.warn("updatePointerCaptured() called on untracked pointer")}function O(g,p,w){var x=g.getActivePointersListByType(w.type),C;C=x.getById(w.id),C?(C.insideElement=!0,C.lastPos=C.currentPos,C.lastTime=C.currentTime,C.currentPos=w.currentPos,C.currentTime=w.currentTime,w=C):(w.captured=!1,w.insideElementPressed=!1,w.insideElement=!0,Pt(x,w)),g.enterHandler&&g.enterHandler({eventSource:g,pointerType:w.type,position:E(w.currentPos,g.element),buttons:x.buttons,pointers:g.getActivePointerCount(),insideElementPressed:w.insideElementPressed,buttonDownAny:x.buttons!==0,isTouchEvent:w.type==="touch",originalEvent:p.originalEvent,userData:g.userData})}function M(g,p,w){var x=g.getActivePointersListByType(w.type),C,A;C=x.getById(w.id),C?(C.captured?(C.insideElement=!1,C.lastPos=C.currentPos,C.lastTime=C.currentTime,C.currentPos=w.currentPos,C.currentTime=w.currentTime):dt(g,x,C),w=C):(w.captured=!1,w.insideElementPressed=!1),(g.leaveHandler||g.exitHandler)&&(A={eventSource:g,pointerType:w.type,position:w.currentPos&&E(w.currentPos,g.element),buttons:x.buttons,pointers:g.getActivePointerCount(),insideElementPressed:w.insideElementPressed,buttonDownAny:x.buttons!==0,isTouchEvent:w.type==="touch",originalEvent:p.originalEvent,userData:g.userData},g.leaveHandler&&g.leaveHandler(A),g.exitHandler&&g.exitHandler(A))}function I(g,p,w){var x,C;x=g.getActivePointersListByType(w.type),C=x.getById(w.id),C?w=C:(w.captured=!1,w.insideElementPressed=!1),g.overHandler&&g.overHandler({eventSource:g,pointerType:w.type,position:E(w.currentPos,g.element),buttons:x.buttons,pointers:g.getActivePointerCount(),insideElementPressed:w.insideElementPressed,buttonDownAny:x.buttons!==0,isTouchEvent:w.type==="touch",originalEvent:p.originalEvent,userData:g.userData})}function D(g,p,w){var x,C;x=g.getActivePointersListByType(w.type),C=x.getById(w.id),C?w=C:(w.captured=!1,w.insideElementPressed=!1),g.outHandler&&g.outHandler({eventSource:g,pointerType:w.type,position:w.currentPos&&E(w.currentPos,g.element),buttons:x.buttons,pointers:g.getActivePointerCount(),insideElementPressed:w.insideElementPressed,buttonDownAny:x.buttons!==0,isTouchEvent:w.type==="touch",originalEvent:p.originalEvent,userData:g.userData})}function z(g,p,w,x){var C=t[g.hash],A=g.getActivePointersListByType(w.type),N;if(typeof p.originalEvent.buttons<"u"?A.buttons=p.originalEvent.buttons:x===0?A.buttons|=1:x===1?A.buttons|=4:x===2?A.buttons|=2:x===3?A.buttons|=8:x===4?A.buttons|=16:x===5&&(A.buttons|=32),x!==0){p.shouldCapture=!1,p.shouldReleaseCapture=!1,g.nonPrimaryPressHandler&&!p.preventGesture&&!p.defaultPrevented&&(p.preventDefault=!0,g.nonPrimaryPressHandler({eventSource:g,pointerType:w.type,position:E(w.currentPos,g.element),button:x,buttons:A.buttons,isTouchEvent:w.type==="touch",originalEvent:p.originalEvent,userData:g.userData}));return}N=A.getById(w.id),N?(N.insideElementPressed=!0,N.insideElement=!0,N.originalTarget=p.originalEvent.target,N.contactPos=w.currentPos,N.contactTime=w.currentTime,N.lastPos=N.currentPos,N.lastTime=N.currentTime,N.currentPos=w.currentPos,N.currentTime=w.currentTime,w=N):(w.captured=!1,w.insideElementPressed=!0,w.insideElement=!0,w.originalTarget=p.originalEvent.target,Pt(A,w)),A.addContact(),!p.preventGesture&&!p.defaultPrevented?(p.shouldCapture=!0,p.shouldReleaseCapture=!1,p.preventDefault=!0,(g.dragHandler||g.dragEndHandler||g.pinchHandler)&&e.MouseTracker.gesturePointVelocityTracker.addPoint(g,w),A.contacts===1?g.pressHandler&&!p.preventGesture&&g.pressHandler({eventSource:g,pointerType:w.type,position:E(w.contactPos,g.element),buttons:A.buttons,isTouchEvent:w.type==="touch",originalEvent:p.originalEvent,userData:g.userData}):A.contacts===2&&g.pinchHandler&&w.type==="touch"&&(C.pinchGPoints=A.asArray(),C.lastPinchDist=C.currentPinchDist=C.pinchGPoints[0].currentPos.distanceTo(C.pinchGPoints[1].currentPos),C.lastPinchCenter=C.currentPinchCenter=S(C.pinchGPoints[0].currentPos,C.pinchGPoints[1].currentPos))):(p.shouldCapture=!1,p.shouldReleaseCapture=!1)}function j(g,p,w,x){var C=t[g.hash],A=g.getActivePointersListByType(w.type),N,Q,W,oe=!1,se;if(typeof p.originalEvent.buttons<"u"?A.buttons=p.originalEvent.buttons:x===0?A.buttons^=-2:x===1?A.buttons^=-5:x===2?A.buttons^=-3:x===3?A.buttons^=-9:x===4?A.buttons^=-17:x===5&&(A.buttons^=-33),p.shouldCapture=!1,x!==0){p.shouldReleaseCapture=!1,g.nonPrimaryReleaseHandler&&!p.preventGesture&&!p.defaultPrevented&&(p.preventDefault=!0,g.nonPrimaryReleaseHandler({eventSource:g,pointerType:w.type,position:E(w.currentPos,g.element),button:x,buttons:A.buttons,isTouchEvent:w.type==="touch",originalEvent:p.originalEvent,userData:g.userData}));return}W=A.getById(w.id),W?(A.removeContact(),W.captured&&(oe=!0),W.lastPos=W.currentPos,W.lastTime=W.currentTime,W.currentPos=w.currentPos,W.currentTime=w.currentTime,W.insideElement||dt(g,A,W),N=W.currentPos,Q=W.currentTime):(w.captured=!1,w.insideElementPressed=!1,w.insideElement=!0,Pt(A,w),W=w),!p.preventGesture&&!p.defaultPrevented&&(oe?(p.shouldReleaseCapture=!0,p.preventDefault=!0,(g.dragHandler||g.dragEndHandler||g.pinchHandler)&&e.MouseTracker.gesturePointVelocityTracker.removePoint(g,W),A.contacts===0?(g.releaseHandler&&N&&g.releaseHandler({eventSource:g,pointerType:W.type,position:E(N,g.element),buttons:A.buttons,insideElementPressed:W.insideElementPressed,insideElementReleased:W.insideElement,isTouchEvent:W.type==="touch",originalEvent:p.originalEvent,userData:g.userData}),g.dragEndHandler&&C.sentDragEvent&&g.dragEndHandler({eventSource:g,pointerType:W.type,position:E(W.currentPos,g.element),speed:W.speed,direction:W.direction,shift:p.originalEvent.shiftKey,isTouchEvent:W.type==="touch",originalEvent:p.originalEvent,userData:g.userData}),C.sentDragEvent=!1,(g.clickHandler||g.dblClickHandler)&&W.insideElement&&(se=Q-W.contactTime<=g.clickTimeThreshold&&W.contactPos.distanceTo(N)<=g.clickDistThreshold,g.clickHandler&&g.clickHandler({eventSource:g,pointerType:W.type,position:E(W.currentPos,g.element),quick:se,shift:p.originalEvent.shiftKey,isTouchEvent:W.type==="touch",originalEvent:p.originalEvent,originalTarget:W.originalTarget,userData:g.userData}),g.dblClickHandler&&se&&(A.clicks++,A.clicks===1?(C.lastClickPos=N,C.dblClickTimeOut=setTimeout(function(){A.clicks=0},g.dblClickTimeThreshold)):A.clicks===2&&(clearTimeout(C.dblClickTimeOut),A.clicks=0,C.lastClickPos.distanceTo(N)<=g.dblClickDistThreshold&&g.dblClickHandler({eventSource:g,pointerType:W.type,position:E(W.currentPos,g.element),shift:p.originalEvent.shiftKey,isTouchEvent:W.type==="touch",originalEvent:p.originalEvent,userData:g.userData}),C.lastClickPos=null)))):A.contacts===2&&g.pinchHandler&&W.type==="touch"&&(C.pinchGPoints=A.asArray(),C.lastPinchDist=C.currentPinchDist=C.pinchGPoints[0].currentPos.distanceTo(C.pinchGPoints[1].currentPos),C.lastPinchCenter=C.currentPinchCenter=S(C.pinchGPoints[0].currentPos,C.pinchGPoints[1].currentPos))):(p.shouldReleaseCapture=!1,g.releaseHandler&&N&&(g.releaseHandler({eventSource:g,pointerType:W.type,position:E(N,g.element),buttons:A.buttons,insideElementPressed:W.insideElementPressed,insideElementReleased:W.insideElement,isTouchEvent:W.type==="touch",originalEvent:p.originalEvent,userData:g.userData}),p.preventDefault=!0)))}function q(g,p,w){var x=t[g.hash],C=g.getActivePointersListByType(w.type),A,N,Q;if(typeof p.originalEvent.buttons<"u"&&(C.buttons=p.originalEvent.buttons),A=C.getById(w.id),A)A.lastPos=A.currentPos,A.lastTime=A.currentTime,A.currentPos=w.currentPos,A.currentTime=w.currentTime;else return;p.shouldCapture=!1,p.shouldReleaseCapture=!1,g.stopHandler&&w.type==="mouse"&&(clearTimeout(g.stopTimeOut),g.stopTimeOut=setTimeout(function(){K(g,p.originalEvent,w.type)},g.stopDelay)),C.contacts===0?g.moveHandler&&g.moveHandler({eventSource:g,pointerType:w.type,position:E(w.currentPos,g.element),buttons:C.buttons,isTouchEvent:w.type==="touch",originalEvent:p.originalEvent,userData:g.userData}):C.contacts===1?(g.moveHandler&&(A=C.asArray()[0],g.moveHandler({eventSource:g,pointerType:A.type,position:E(A.currentPos,g.element),buttons:C.buttons,isTouchEvent:A.type==="touch",originalEvent:p.originalEvent,userData:g.userData})),g.dragHandler&&!p.preventGesture&&!p.defaultPrevented&&(A=C.asArray()[0],Q=A.currentPos.minus(A.lastPos),g.dragHandler({eventSource:g,pointerType:A.type,position:E(A.currentPos,g.element),buttons:C.buttons,delta:Q,speed:A.speed,direction:A.direction,shift:p.originalEvent.shiftKey,isTouchEvent:A.type==="touch",originalEvent:p.originalEvent,userData:g.userData}),p.preventDefault=!0,x.sentDragEvent=!0)):C.contacts===2&&(g.moveHandler&&(N=C.asArray(),g.moveHandler({eventSource:g,pointerType:N[0].type,position:E(S(N[0].currentPos,N[1].currentPos),g.element),buttons:C.buttons,isTouchEvent:N[0].type==="touch",originalEvent:p.originalEvent,userData:g.userData})),g.pinchHandler&&w.type==="touch"&&!p.preventGesture&&!p.defaultPrevented&&(Q=x.pinchGPoints[0].currentPos.distanceTo(x.pinchGPoints[1].currentPos),Q!==x.currentPinchDist&&(x.lastPinchDist=x.currentPinchDist,x.currentPinchDist=Q,x.lastPinchCenter=x.currentPinchCenter,x.currentPinchCenter=S(x.pinchGPoints[0].currentPos,x.pinchGPoints[1].currentPos),g.pinchHandler({eventSource:g,pointerType:"touch",gesturePoints:x.pinchGPoints,lastCenter:E(x.lastPinchCenter,g.element),center:E(x.currentPinchCenter,g.element),lastDistance:x.lastPinchDist,distance:x.currentPinchDist,shift:p.originalEvent.shiftKey,originalEvent:p.originalEvent,userData:g.userData}),p.preventDefault=!0)))}function U(g,p,w){var x=g.getActivePointersListByType(w.type),C;C=x.getById(w.id),C&&dt(g,x,C)}function K(g,p,w){g.stopHandler&&g.stopHandler({eventSource:g,pointerType:w,position:_(p,g.element),buttons:g.getActivePointersListByType(w).buttons,isTouchEvent:w==="touch",originalEvent:p,userData:g.userData})}})(o),(function(e){e.ControlAnchor={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_RIGHT:3,BOTTOM_LEFT:4,ABSOLUTE:5},e.Control=function(t,r,i){var s=t.parentNode;typeof r=="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"),r={anchor:r}),r.attachToViewer=typeof r.attachToViewer>"u"?!0:r.attachToViewer,this.autoFade=typeof r.autoFade>"u"?!0:r.autoFade,this.element=t,this.anchor=r.anchor,this.container=i,this.anchor===e.ControlAnchor.ABSOLUTE?(this.wrapper=e.makeNeutralElement("div"),this.wrapper.style.position="absolute",this.wrapper.style.top=typeof r.top=="number"?r.top+"px":r.top,this.wrapper.style.left=typeof r.left=="number"?r.left+"px":r.left,this.wrapper.style.height=typeof r.height=="number"?r.height+"px":r.height,this.wrapper.style.width=typeof r.width=="number"?r.width+"px":r.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),r.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):s.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)}}})(o),(function(e){e.ControlDock=function(r){var i=["topleft","topright","bottomright","bottomleft"],s,l;for(e.extend(!0,this,{id:"controldock-"+e.now()+"-"+Math.floor(Math.random()*1e6),container:e.makeNeutralElement("div"),controls:[]},r),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%"),l=0;l<i.length;l++)s=i[l],this.controls[s]=e.makeNeutralElement("div"),this.controls[s].style.position="absolute",s.match("left")&&(this.controls[s].style.left="0px"),s.match("right")&&(this.controls[s].style.right="0px"),s.match("top")&&(this.controls[s].style.top="0px"),s.match("bottom")&&(this.controls[s].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(r,i){r=e.getElement(r);var s=null;if(!(t(this,r)>=0)){switch(i.anchor){case e.ControlAnchor.TOP_RIGHT:s=this.controls.topright,r.style.position="relative",r.style.paddingRight="0px",r.style.paddingTop="0px";break;case e.ControlAnchor.BOTTOM_RIGHT:s=this.controls.bottomright,r.style.position="relative",r.style.paddingRight="0px",r.style.paddingBottom="0px";break;case e.ControlAnchor.BOTTOM_LEFT:s=this.controls.bottomleft,r.style.position="relative",r.style.paddingLeft="0px",r.style.paddingBottom="0px";break;case e.ControlAnchor.TOP_LEFT:s=this.controls.topleft,r.style.position="relative",r.style.paddingLeft="0px",r.style.paddingTop="0px";break;case e.ControlAnchor.ABSOLUTE:s=this.container,r.style.margin="0px",r.style.padding="0px";break;default:case e.ControlAnchor.NONE:s=this.container,r.style.margin="0px",r.style.padding="0px";break}this.controls.push(new e.Control(r,i,s)),r.style.display="inline-block"}},removeControl:function(r){r=e.getElement(r);var i=t(this,r);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 r;for(r=this.controls.length-1;r>=0;r--)if(this.controls[r].isVisible())return!0;return!1},setControlsEnabled:function(r){var i;for(i=this.controls.length-1;i>=0;i--)this.controls[i].setVisible(r);return this}};function t(r,i){var s=r.controls,l;for(l=s.length-1;l>=0;l--)if(s[l].element===i)return l;return-1}})(o),(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}}})})(o),(function(e){var t={},r=1;e.Viewer=function(f){var T=arguments,R=this,O;e.isPlainObject(f)||(f={id:T[0],xmlPath:T.length>1?T[1]:void 0,prefixUrl:T.length>2?T[2]:void 0,controls:T.length>3?T[3]:void 0,overlays:T.length>4?T[4]:void 0}),f.config&&(e.extend(!0,f,f.config),delete f.config);let M=["useCanvas"];if(f.drawerOptions=Object.assign({},M.reduce((D,z)=>(D[z]=f[z],delete f[z],D),{}),f.drawerOptions),e.extend(!0,this,{id:f.id,hash:f.hash||r++,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,f),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(D){var z=e.getString("Errors.OpenFailed",D.eventSource,D.message);R._showMessage(z)}),e.ControlDock.call(this,f),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(D){D.width="100%",D.height="100%",D.overflow="hidden",D.position="absolute",D.top="0px",D.left="0px"})(this.canvas.style),e.setElementTouchActionNone(this.canvas),f.tabIndex!==""&&(this.canvas.tabIndex=f.tabIndex===void 0?0:f.tabIndex),this.container.className="openseadragon-container",(function(D){D.width="100%",D.height="100%",D.position="relative",D.overflow="hidden",D.left="0px",D.top="0px",D.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,_),keyDownHandler:e.delegate(this,E),keyHandler:e.delegate(this,S),clickHandler:e.delegate(this,P),dblClickHandler:e.delegate(this,L),dragHandler:e.delegate(this,F),dragEndHandler:e.delegate(this,H),enterHandler:e.delegate(this,B),leaveHandler:e.delegate(this,V),pressHandler:e.delegate(this,Y),releaseHandler:e.delegate(this,J),nonPrimaryPressHandler:e.delegate(this,re),nonPrimaryReleaseHandler:e.delegate(this,Z),scrollHandler:e.delegate(this,ce),pinchHandler:e.delegate(this,ie),focusHandler:e.delegate(this,he),blurHandler:e.delegate(this,pe)}),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,ve),leaveHandler:e.delegate(this,fe)}),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[R.hash].needsResize=!0}),this._resizeObserver.observe(this.container,{})):this._autoResizePolling=!0,this.world=new e.World({viewer:this}),this.world.addHandler("add-item",function(D){R.source=R.world.getItemAt(0).source,t[R.hash].forceRedraw=!0,R._updateRequestId||(R._updateRequestId=u(R,we))}),this.world.addHandler("remove-item",function(D){R.world.getItemCount()?R.source=R.world.getItemAt(0).source:R.source=null,t[R.hash].forceRedraw=!0}),this.world.addHandler("metrics-change",function(D){R.viewport&&R.viewport._setContentBounds(R.world.getHomeBounds(),R.world.getContentFactor())}),this.world.addHandler("item-index-change",function(D){R.source=R.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:f.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 I=Array.isArray(this.drawer)?this.drawer:[this.drawer];I.length===0&&(I=[e.DEFAULT_SETTINGS.drawer].flat(),e.console.warn("No valid drawers were selected. Using the default value.")),this.drawer=null;for(const D of I)if(this.requestDrawer(D,{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&&(O=this.buttonGroup.buttons.indexOf(this.rotateLeft),this.buttonGroup.buttons.splice(O,1),this.buttonGroup.element.removeChild(this.rotateLeft.element)),this.rotateRight&&(O=this.buttonGroup.buttons.indexOf(this.rotateRight),this.buttonGroup.buttons.splice(O,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),O=0;O<this.customControls.length;O++)this.addControl(this.customControls[O].id,{anchor:this.customControls[O].anchor});e.requestAnimationFrame(function(){c(R)}),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(f){return e.console.error("[Viewer.openDzi] this function is deprecated; use Viewer.open() instead."),this.open(f)},openTileSource:function(f){return e.console.error("[Viewer.openTileSource] this function is deprecated; use Viewer.open() instead."),this.open(f)},get buttons(){return e.console.warn("Viewer.buttons is deprecated; Please use Viewer.buttonGroup"),this.buttonGroup},open:function(f,T){var R=this;if(this.close(),!f)return this;if(this.sequenceMode&&e.isArray(f))return this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),typeof T<"u"&&!isNaN(T)&&(this.initialPage=T),this.tileSources=f,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(f)||(f=[f]),!f.length)return this;this._opening=!0;for(var O=f.length,M=0,I=0,D,z=function(){if(M+I===O)if(M){(R._firstOpen||!R.preserveViewport)&&(R.viewport.goHome(!0),R.viewport.update()),R._firstOpen=!1;var U=f[0];if(U.tileSource&&(U=U.tileSource),R.overlays&&!R.preserveOverlays)for(var K=0;K<R.overlays.length;K++)R.currentOverlays[K]=l(R,R.overlays[K]);R._drawOverlays(),R._opening=!1,R.raiseEvent("open",{source:U})}else R._opening=!1,R.raiseEvent("open-failed",D)},j=function(U){(!e.isPlainObject(U)||!U.tileSource)&&(U={tileSource:U}),U.index!==void 0&&(e.console.error("[Viewer.open] setting indexes here is not supported; use addTiledImage instead"),delete U.index),U.collectionImmediately===void 0&&(U.collectionImmediately=!0);var K=U.success;U.success=function(p){if(M++,U.tileSource.overlays)for(var w=0;w<U.tileSource.overlays.length;w++)R.addOverlay(U.tileSource.overlays[w]);K&&K(p),z()};var g=U.error;U.error=function(p){I++,D||(D=p),g&&g(p),z()},R.addTiledImage(U)},q=0;q<f.length;q++)j(f[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(f,T){const R={mainDrawer:!0,redrawImmediately:!0,drawerOptions:null};T=e.extend(!0,R,T);const O=T.mainDrawer,M=T.redrawImmediately,I=T.drawerOptions,D=this.drawer;let z=null;if(f&&f.prototype instanceof e.DrawerBase?(z=f,f="custom"):typeof f=="string"&&(z=e.determineDrawer(f)),z||e.console.warn("Unsupported drawer! Drawer must be an existing string type, or a class that extends OpenSeadragon.DrawerBase."),z&&z.isSupported()){D&&O&&D.destroy();const j=new z({viewer:this,viewport:this.viewport,element:this.canvas,debugGridColor:this.debugGridColor,options:I||this.drawerOptions[f]});return O&&(this.drawer=j,M&&this.forceRedraw()),j}return!1},isMouseNavEnabled:function(){return this.innerTracker.isTracking()},setMouseNavEnabled:function(f){return this.innerTracker.setTracking(f),this.outerTracker.setTracking(f),this.raiseEvent("mouse-enabled",{enabled:f}),this},areControlsEnabled:function(){var f=this.controls.length,T;for(T=0;T<this.controls.length;T++)f=f&&this.controls[T].isVisible();return f},setControlsEnabled:function(f){return f?m(this):c(this),this.raiseEvent("controls-enabled",{enabled:f}),this},setDebugMode:function(f){for(var T=0;T<this.world.getItemCount();T++)this.world.getItemAt(T).debugMode=f;this.debugMode=f,this.forceRedraw()},setAjaxHeaders:function(f,T){if(f===null&&(f={}),!e.isPlainObject(f)){console.error("[Viewer.setAjaxHeaders] Ignoring invalid headers, must be a plain object");return}if(T===void 0&&(T=!0),this.ajaxHeaders=f,T){for(var R=0;R<this.world.getItemCount();R++)this.world.getItemAt(R)._updateAjaxHeaders(!0);if(this.navigator&&this.navigator.setAjaxHeaders(this.ajaxHeaders,!0),this.referenceStrip&&this.referenceStrip.miniViewers)for(var O in this.referenceStrip.miniViewers)this.referenceStrip.miniViewers[O].setAjaxHeaders(this.ajaxHeaders,!0)}},addButton:function(f){this.buttonGroup.addButton(f)},isFullPage:function(){return t[this.hash]&&t[this.hash].fullPage},setFullPage:function(f){var T=document.body,R=T.style,O=document.documentElement.style,M=this,I,D;if(f===this.isFullPage())return this;var z={fullPage:f,preventDefaultAction:!1};if(this.raiseEvent("pre-full-page",z),z.preventDefaultAction)return this;if(f&&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=R.margin,this.docMargin=O.margin,R.margin="0",O.margin="0",this.bodyPadding=R.padding,this.docPadding=O.padding,R.padding="0",O.padding="0",this.bodyWidth=R.width,this.docWidth=O.width,R.width="100%",O.width="100%",this.bodyHeight=R.height,this.docHeight=O.height,R.height="100%",O.height="100%",this.bodyDisplay=R.display,R.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,I=T.childNodes.length,D=0;D<I;D++)this.previousBody.push(T.childNodes[0]),T.removeChild(T.childNodes[0]);this.toolbar&&this.toolbar.element&&(this.toolbar.parentNode=this.toolbar.element.parentNode,this.toolbar.nextSibling=this.toolbar.element.nextSibling,T.appendChild(this.toolbar.element),e.addClass(this.toolbar.element,"fullpage")),e.addClass(this.element,"fullpage"),T.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,ve)({})}else{for(this.element.style.margin=this.elementMargin,this.element.style.padding=this.elementPadding,R.margin=this.bodyMargin,O.margin=this.docMargin,R.padding=this.bodyPadding,O.padding=this.docPadding,R.width=this.bodyWidth,O.width=this.docWidth,R.height=this.bodyHeight,O.height=this.docHeight,R.display=this.bodyDisplay,T.removeChild(this.element),I=this.previousBody.length,D=0;D<I;D++)T.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&&(T.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 j=0,q=function(){e.setPageScroll(M.pageScroll);var U=e.getPageScroll();j++,j<10&&(U.x!==M.pageScroll.x||U.y!==M.pageScroll.y)&&e.requestAnimationFrame(q)};e.requestAnimationFrame(q),t[this.hash].fullPage=!1,e.delegate(this,fe)({})}return this.navigator&&this.viewport&&this.navigator.update(this.viewport),this.raiseEvent("full-page",{fullPage:f}),this},setFullScreen:function(f){var T=this;if(!e.supportsFullScreen)return this.setFullPage(f);if(e.isFullScreen()===f)return this;var R={fullScreen:f,preventDefaultAction:!1};if(this.raiseEvent("pre-full-screen",R),R.preventDefaultAction)return this;if(f){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 O=function(){var M=e.isFullScreen();M||(e.removeEvent(document,e.fullScreenEventName,O),e.removeEvent(document,e.fullScreenErrorEventName,O),T.setFullPage(!1),T.isFullPage()&&(T.element.style.width=T.fullPageStyleWidth,T.element.style.height=T.fullPageStyleHeight)),T.navigator&&T.viewport&&setTimeout(function(){T.navigator.update(T.viewport)}),T.raiseEvent("full-screen",{fullScreen:M})};e.addEvent(document,e.fullScreenEventName,O),e.addEvent(document,e.fullScreenErrorEventName,O),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(f){return this.container.style.visibility=f?"":"hidden",this.raiseEvent("visible",{visible:f}),this},addTiledImage:function(f){e.console.assert(f,"[Viewer.addTiledImage] options is required"),e.console.assert(f.tileSource,"[Viewer.addTiledImage] options.tileSource is required"),e.console.assert(!f.replace||f.index>-1&&f.index<this.world.getItemCount(),"[Viewer.addTiledImage] if options.replace is used, options.index must be a valid index in Viewer.world");var T=this;f.replace&&(f.replaceItem=T.world.getItemAt(f.index)),this._hideMessage(),f.placeholderFillStyle===void 0&&(f.placeholderFillStyle=this.placeholderFillStyle),f.opacity===void 0&&(f.opacity=this.opacity),f.preload===void 0&&(f.preload=this.preload),f.compositeOperation===void 0&&(f.compositeOperation=this.compositeOperation),f.crossOriginPolicy===void 0&&(f.crossOriginPolicy=f.tileSource.crossOriginPolicy!==void 0?f.tileSource.crossOriginPolicy:this.crossOriginPolicy),f.ajaxWithCredentials===void 0&&(f.ajaxWithCredentials=this.ajaxWithCredentials),f.loadTilesWithAjax===void 0&&(f.loadTilesWithAjax=this.loadTilesWithAjax),e.isPlainObject(f.ajaxHeaders)||(f.ajaxHeaders={});var R={options:f};function O(D){for(var z=0;z<T._loadQueue.length;z++)if(T._loadQueue[z]===R){T._loadQueue.splice(z,1);break}T._loadQueue.length===0&&M(R),T.raiseEvent("add-item-failed",D),f.error&&f.error(D)}function M(D){T.collectionMode&&(T.world.arrange({immediately:D.options.collectionImmediately,rows:T.collectionRows,columns:T.collectionColumns,layout:T.collectionLayout,tileSize:T.collectionTileSize,tileMargin:T.collectionTileMargin}),T.world.setAutoRefigureSizes(!0))}if(e.isArray(f.tileSource)){setTimeout(function(){O({message:"[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead.",source:f.tileSource,options:f})});return}this._loadQueue.push(R);function I(){for(var D,z,j;T._loadQueue.length&&(D=T._loadQueue[0],!!D.tileSource);){if(T._loadQueue.splice(0,1),D.options.replace){var q=T.world.getIndexOfItem(D.options.replaceItem);q!==-1&&(D.options.index=q),T.world.removeItem(D.options.replaceItem)}z=new e.TiledImage({viewer:T,source:D.tileSource,viewport:T.viewport,drawer:T.drawer,tileCache:T.tileCache,imageLoader:T.imageLoader,x:D.options.x,y:D.options.y,width:D.options.width,height:D.options.height,fitBounds:D.options.fitBounds,fitBoundsPlacement:D.options.fitBoundsPlacement,clip:D.options.clip,placeholderFillStyle:D.options.placeholderFillStyle,opacity:D.options.opacity,preload:D.options.preload,degrees:D.options.degrees,flipped:D.options.flipped,compositeOperation:D.options.compositeOperation,springStiffness:T.springStiffness,animationTime:T.animationTime,minZoomImageRatio:T.minZoomImageRatio,wrapHorizontal:T.wrapHorizontal,wrapVertical:T.wrapVertical,maxTilesPerFrame:T.maxTilesPerFrame,immediateRender:T.immediateRender,blendTime:T.blendTime,alwaysBlend:T.alwaysBlend,minPixelRatio:T.minPixelRatio,smoothTileEdgesMinZoom:T.smoothTileEdgesMinZoom,iOSDevice:T.iOSDevice,crossOriginPolicy:D.options.crossOriginPolicy,ajaxWithCredentials:D.options.ajaxWithCredentials,loadTilesWithAjax:D.options.loadTilesWithAjax,ajaxHeaders:D.options.ajaxHeaders,debugMode:T.debugMode,subPixelRoundingForTransparency:T.subPixelRoundingForTransparency}),T.collectionMode&&T.world.setAutoRefigureSizes(!1),T.navigator&&(j=e.extend({},D.options,{replace:!1,originalTiledImage:z,tileSource:D.tileSource}),T.navigator.addTiledImage(j)),T.world.addItem(z,{index:D.options.index}),T._loadQueue.length===0&&M(D),T.world.getItemCount()===1&&!T.preserveViewport&&T.viewport.goHome(!0),D.options.success&&D.options.success({item:z})}}s(this,f.tileSource,f,function(D){R.tileSource=D,I()},function(D){D.options=f,O(D),I()})},addSimpleImage:function(f){e.console.assert(f,"[Viewer.addSimpleImage] options is required"),e.console.assert(f.url,"[Viewer.addSimpleImage] options.url is required");var T=e.extend({},f,{tileSource:{type:"image",url:f.url}});delete T.url,this.addTiledImage(T)},addLayer:function(f){var T=this;e.console.error("[Viewer.addLayer] this function is deprecated; use Viewer.addTiledImage() instead.");var R=e.extend({},f,{success:function(O){T.raiseEvent("add-layer",{options:f,drawer:O.item})},error:function(O){T.raiseEvent("add-layer-failed",O)}});return this.addTiledImage(R),this},getLayerAtLevel:function(f){return e.console.error("[Viewer.getLayerAtLevel] this function is deprecated; use World.getItemAt() instead."),this.world.getItemAt(f)},getLevelOfLayer:function(f){return e.console.error("[Viewer.getLevelOfLayer] this function is deprecated; use World.getIndexOfItem() instead."),this.world.getIndexOfItem(f)},getLayersCount:function(){return e.console.error("[Viewer.getLayersCount] this function is deprecated; use World.getItemCount() instead."),this.world.getItemCount()},setLayerLevel:function(f,T){return e.console.error("[Viewer.setLayerLevel] this function is deprecated; use World.setItemIndex() instead."),this.world.setItemIndex(f,T)},removeLayer:function(f){return e.console.error("[Viewer.removeLayer] this function is deprecated; use World.removeItem() instead."),this.world.removeItem(f)},forceRedraw:function(){return t[this.hash].forceRedraw=!0,this},forceResize:function(){t[this.hash].needsResize=!0,t[this.hash].forceResize=!0},bindSequenceControls:function(){var f=e.delegate(this,v),T=e.delegate(this,y),R=e.delegate(this,this.goToNextPage),O=e.delegate(this,this.goToPreviousPage),M=this.navImages,I=!0;return this.showSequenceControl&&((this.previousButton||this.nextButton)&&(I=!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:X(this.prefixUrl,M.previous.REST),srcGroup:X(this.prefixUrl,M.previous.GROUP),srcHover:X(this.prefixUrl,M.previous.HOVER),srcDown:X(this.prefixUrl,M.previous.DOWN),onRelease:O,onFocus:f,onBlur:T}),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:X(this.prefixUrl,M.next.REST),srcGroup:X(this.prefixUrl,M.next.GROUP),srcHover:X(this.prefixUrl,M.next.HOVER),srcDown:X(this.prefixUrl,M.next.DOWN),onRelease:R,onFocus:f,onBlur:T}),this.navPrevNextWrap||this.previousButton.disable(),(!this.tileSources||!this.tileSources.length)&&this.nextButton.disable(),I&&(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 f=e.delegate(this,Ye),T=e.delegate(this,Ue),R=e.delegate(this,de),O=e.delegate(this,ct),M=e.delegate(this,ye),I=e.delegate(this,St),D=e.delegate(this,kt),z=e.delegate(this,Nt),j=e.delegate(this,Pt),q=e.delegate(this,dt),U=e.delegate(this,v),K=e.delegate(this,y),g=this.navImages,p=[],w=!0;return this.showNavigationControl&&((this.zoomInButton||this.zoomOutButton||this.homeButton||this.fullPageButton||this.rotateLeftButton||this.rotateRightButton||this.flipButton)&&(w=!1),this.showZoomControl&&(p.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:X(this.prefixUrl,g.zoomIn.REST),srcGroup:X(this.prefixUrl,g.zoomIn.GROUP),srcHover:X(this.prefixUrl,g.zoomIn.HOVER),srcDown:X(this.prefixUrl,g.zoomIn.DOWN),onPress:f,onRelease:T,onClick:R,onEnter:f,onExit:T,onFocus:U,onBlur:K})),p.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:X(this.prefixUrl,g.zoomOut.REST),srcGroup:X(this.prefixUrl,g.zoomOut.GROUP),srcHover:X(this.prefixUrl,g.zoomOut.HOVER),srcDown:X(this.prefixUrl,g.zoomOut.DOWN),onPress:O,onRelease:T,onClick:M,onEnter:O,onExit:T,onFocus:U,onBlur:K}))),this.showHomeControl&&p.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:X(this.prefixUrl,g.home.REST),srcGroup:X(this.prefixUrl,g.home.GROUP),srcHover:X(this.prefixUrl,g.home.HOVER),srcDown:X(this.prefixUrl,g.home.DOWN),onRelease:I,onFocus:U,onBlur:K})),this.showFullPageControl&&p.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:X(this.prefixUrl,g.fullpage.REST),srcGroup:X(this.prefixUrl,g.fullpage.GROUP),srcHover:X(this.prefixUrl,g.fullpage.HOVER),srcDown:X(this.prefixUrl,g.fullpage.DOWN),onRelease:D,onFocus:U,onBlur:K})),this.showRotationControl&&(p.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:X(this.prefixUrl,g.rotateleft.REST),srcGroup:X(this.prefixUrl,g.rotateleft.GROUP),srcHover:X(this.prefixUrl,g.rotateleft.HOVER),srcDown:X(this.prefixUrl,g.rotateleft.DOWN),onRelease:z,onFocus:U,onBlur:K})),p.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:X(this.prefixUrl,g.rotateright.REST),srcGroup:X(this.prefixUrl,g.rotateright.GROUP),srcHover:X(this.prefixUrl,g.rotateright.HOVER),srcDown:X(this.prefixUrl,g.rotateright.DOWN),onRelease:j,onFocus:U,onBlur:K}))),this.showFlipControl&&p.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:X(this.prefixUrl,g.flip.REST),srcGroup:X(this.prefixUrl,g.flip.GROUP),srcHover:X(this.prefixUrl,g.flip.HOVER),srcDown:X(this.prefixUrl,g.flip.DOWN),onRelease:q,onFocus:U,onBlur:K})),w?(this.buttonGroup=new e.ButtonGroup({buttons:p,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.navControl=this.buttonGroup.element,this.addHandler("open",e.delegate(this,Ke)),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=p),this},currentPage:function(){return this._sequenceIndex},goToPage:function(f){return this.tileSources&&f>=0&&f<this.tileSources.length&&(this._sequenceIndex=f,this._updateSequenceButtons(f),this.open(this.tileSources[f]),this.referenceStrip&&this.referenceStrip.setFocus(f),this.raiseEvent("page",{page:f})),this},addOverlay:function(f,T,R,O){var M;if(e.isPlainObject(f)?M=f:M={element:f,location:T,placement:R,onDraw:O},f=e.getElement(M.element),a(this.currentOverlays,f)>=0)return this;var I=l(this,M);return this.currentOverlays.push(I),I.drawHTML(this.overlaysContainer,this.viewport),this.raiseEvent("add-overlay",{element:f,location:M.location,placement:M.placement}),this},updateOverlay:function(f,T,R){var O;return f=e.getElement(f),O=a(this.currentOverlays,f),O>=0&&(this.currentOverlays[O].update(T,R),t[this.hash].forceRedraw=!0,this.raiseEvent("update-overlay",{element:f,location:T,placement:R})),this},removeOverlay:function(f){var T;return f=e.getElement(f),T=a(this.currentOverlays,f),T>=0&&(this.currentOverlays[T].destroy(),this.currentOverlays.splice(T,1),t[this.hash].forceRedraw=!0,this.raiseEvent("remove-overlay",{element:f})),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(f){var T;return f=e.getElement(f),T=a(this.currentOverlays,f),T>=0?this.currentOverlays[T]:null},_updateSequenceButtons:function(f){this.nextButton&&(!this.tileSources||this.tileSources.length-1===f?this.navPrevNextWrap||this.nextButton.disable():this.nextButton.enable()),this.previousButton&&(f>0?this.previousButton.enable():this.navPrevNextWrap||this.previousButton.disable())},_showMessage:function(f){this._hideMessage();var T=e.makeNeutralElement("div");T.appendChild(document.createTextNode(f)),this.messageDiv=e.makeCenteredNode(T),e.addClass(this.messageDiv,"openseadragon-message"),this.container.appendChild(this.messageDiv)},_hideMessage:function(){var f=this.messageDiv;f&&(f.parentNode.removeChild(f),delete this.messageDiv)},gestureSettingsByDeviceType:function(f){switch(f){case"mouse":return this.gestureSettingsMouse;case"touch":return this.gestureSettingsTouch;case"pen":return this.gestureSettingsPen;default:return this.gestureSettingsUnknown}},_drawOverlays:function(){var f,T=this.currentOverlays.length;for(f=0;f<T;f++)this.currentOverlays[f].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 f=e.pixelDensityRatio,T=e.getCurrentPixelDensityRatio();f!==T&&(e.pixelDensityRatio=T,this.forceResize())},goToPreviousPage:function(){var f=this._sequenceIndex-1;this.navPrevNextWrap&&f<0&&(f+=this.tileSources.length),this.goToPage(f)},goToNextPage:function(){var f=this._sequenceIndex+1;this.navPrevNextWrap&&f>=this.tileSources.length&&(f=0),this.goToPage(f)},isAnimating:function(){return t[this.hash].animating}});function i(f){return f=e.getElement(f),new e.Point(f.clientWidth===0?1:f.clientWidth,f.clientHeight===0?1:f.clientHeight)}function s(f,T,R,O,M){var I=f;if(e.type(T)==="string"){if(T.match(/^\s*<.*>\s*$/))T=e.parseXml(T);else if(T.match(/^\s*[{[].*[}\]]\s*$/))try{var D=e.parseJSON(T);T=D}catch{}}function z(j,q){j.ready?O(j):(j.addHandler("ready",function(){O(j)}),j.addHandler("open-failed",function(U){M({message:U.message,source:q})}))}setTimeout(function(){if(e.type(T)==="string")T=new e.TileSource({url:T,crossOriginPolicy:R.crossOriginPolicy!==void 0?R.crossOriginPolicy:f.crossOriginPolicy,ajaxWithCredentials:f.ajaxWithCredentials,ajaxHeaders:R.ajaxHeaders?R.ajaxHeaders:f.ajaxHeaders,splitHashDataForPost:f.splitHashDataForPost,success:function(K){O(K.tileSource)}}),T.addHandler("open-failed",function(K){M(K)});else if(e.isPlainObject(T)||T.nodeType)if(T.crossOriginPolicy===void 0&&(R.crossOriginPolicy!==void 0||f.crossOriginPolicy!==void 0)&&(T.crossOriginPolicy=R.crossOriginPolicy!==void 0?R.crossOriginPolicy:f.crossOriginPolicy),T.ajaxWithCredentials===void 0&&(T.ajaxWithCredentials=f.ajaxWithCredentials),e.isFunction(T.getTileUrl)){var j=new e.TileSource(T);j.getTileUrl=T.getTileUrl,O(j)}else{var q=e.TileSource.determineType(I,T);if(!q){M({message:"Unable to load TileSource",source:T});return}var U=q.prototype.configure.apply(I,[T]);z(new q(U),T)}else z(T,T)})}function l(f,T){if(T instanceof e.Overlay)return T;var R=null;if(T.element)R=e.getElement(T.element);else{var O=T.id?T.id:"openseadragon-overlay-"+Math.floor(Math.random()*1e7);R=e.getElement(T.id),R||(R=document.createElement("a"),R.href="#/overlay/"+O),R.id=O,e.addClass(R,T.className?T.className:"openseadragon-overlay")}var M=T.location,I=T.width,D=T.height;if(!M){var z=T.x,j=T.y;if(T.px!==void 0){var q=f.viewport.imageToViewportRectangle(new e.Rect(T.px,T.py,I||0,D||0));z=q.x,j=q.y,I=I!==void 0?q.width:void 0,D=D!==void 0?q.height:void 0}M=new e.Point(z,j)}var U=T.placement;return U&&e.type(U)==="string"&&(U=e.Placement[T.placement.toUpperCase()]),new e.Overlay({element:R,location:M,placement:U,onDraw:T.onDraw,checkResize:T.checkResize,width:I,height:D,rotationMode:T.rotationMode})}function a(f,T){var R;for(R=f.length-1;R>=0;R--)if(f[R].element===T)return R;return-1}function u(f,T){return e.requestAnimationFrame(function(){T(f)})}function h(f){e.requestAnimationFrame(function(){d(f)})}function c(f){f.autoHideControls&&(f.controlsShouldFade=!0,f.controlsFadeBeginTime=e.now()+f.controlsFadeDelay,window.setTimeout(function(){h(f)},f.controlsFadeDelay))}function d(f){var T,R,O,M;if(f.controlsShouldFade){for(T=e.now(),R=T-f.controlsFadeBeginTime,O=1-R/f.controlsFadeLength,O=Math.min(1,O),O=Math.max(0,O),M=f.controls.length-1;M>=0;M--)f.controls[M].autoFade&&f.controls[M].setOpacity(O);O>0&&h(f)}}function m(f){var T;for(f.controlsShouldFade=!1,T=f.controls.length-1;T>=0;T--)f.controls[T].setOpacity(1)}function v(){m(this)}function y(){c(this)}function _(f){var T={tracker:f.eventSource,position:f.position,originalEvent:f.originalEvent,preventDefault:f.preventDefault};this.raiseEvent("canvas-contextmenu",T),f.preventDefault=T.preventDefault}function E(f){var T={originalEvent:f.originalEvent,preventDefaultAction:!1,preventVerticalPan:f.preventVerticalPan||!this.panVertical,preventHorizontalPan:f.preventHorizontalPan||!this.panHorizontal};if(this.raiseEvent("canvas-key",T),!T.preventDefaultAction&&!f.ctrl&&!f.alt&&!f.meta)switch(f.keyCode){case 38:T.preventVerticalPan||(f.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,-this.pixelsPerArrowPress))),this.viewport.applyConstraints()),f.preventDefault=!0;break;case 40:T.preventVerticalPan||(f.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,this.pixelsPerArrowPress))),this.viewport.applyConstraints()),f.preventDefault=!0;break;case 37:T.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(-this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),f.preventDefault=!0;break;case 39:T.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),f.preventDefault=!0;break;case 187:this.viewport.zoomBy(1.1),this.viewport.applyConstraints(),f.preventDefault=!0;break;case 189:this.viewport.zoomBy(.9),this.viewport.applyConstraints(),f.preventDefault=!0;break;case 48:this.viewport.goHome(),this.viewport.applyConstraints(),f.preventDefault=!0;break;case 87:T.preventVerticalPan||(f.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,-40))),this.viewport.applyConstraints()),f.preventDefault=!0;break;case 83:T.preventVerticalPan||(f.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,40))),this.viewport.applyConstraints()),f.preventDefault=!0;break;case 65:T.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(-40,0))),this.viewport.applyConstraints()),f.preventDefault=!0;break;case 68:T.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(40,0))),this.viewport.applyConstraints()),f.preventDefault=!0;break;case 82:f.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(),f.preventDefault=!0;break;case 70:this.viewport.toggleFlip(),f.preventDefault=!0;break;case 74:this.goToPreviousPage();break;case 75:this.goToNextPage();break;default:f.preventDefault=!1;break}else f.preventDefault=!1}function S(f){var T={originalEvent:f.originalEvent};this.raiseEvent("canvas-key-press",T)}function P(f){var T,R=document.activeElement===this.canvas;R||this.canvas.focus(),this.viewport.flipped&&(f.position.x=this.viewport.getContainerSize().x-f.position.x);var O={tracker:f.eventSource,position:f.position,quick:f.quick,shift:f.shift,originalEvent:f.originalEvent,originalTarget:f.originalTarget,preventDefaultAction:!1};this.raiseEvent("canvas-click",O),!O.preventDefaultAction&&this.viewport&&f.quick&&(T=this.gestureSettingsByDeviceType(f.pointerType),T.clickToZoom===!0&&(this.viewport.zoomBy(f.shift?1/this.zoomPerClick:this.zoomPerClick,T.zoomToRefPoint?this.viewport.pointFromPixel(f.position,!0):null),this.viewport.applyConstraints()),T.dblClickDragToZoom&&(t[this.hash].draggingToZoom===!0?(t[this.hash].lastClickTime=null,t[this.hash].draggingToZoom=!1):t[this.hash].lastClickTime=e.now()))}function L(f){var T,R={tracker:f.eventSource,position:f.position,shift:f.shift,originalEvent:f.originalEvent,preventDefaultAction:!1};this.raiseEvent("canvas-double-click",R),!R.preventDefaultAction&&this.viewport&&(T=this.gestureSettingsByDeviceType(f.pointerType),T.dblClickToZoom&&(this.viewport.zoomBy(f.shift?1/this.zoomPerClick:this.zoomPerClick,T.zoomToRefPoint?this.viewport.pointFromPixel(f.position,!0):null),this.viewport.applyConstraints()))}function F(f){var T,R={tracker:f.eventSource,pointerType:f.pointerType,position:f.position,delta:f.delta,speed:f.speed,direction:f.direction,shift:f.shift,originalEvent:f.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag",R),T=this.gestureSettingsByDeviceType(f.pointerType),!R.preventDefaultAction&&this.viewport){if(T.dblClickDragToZoom&&t[this.hash].draggingToZoom){var O=Math.pow(this.zoomPerDblClickDrag,f.delta.y/50);this.viewport.zoomBy(O)}else if(T.dragToPan&&!t[this.hash].draggingToZoom){if(this.panHorizontal||(f.delta.x=0),this.panVertical||(f.delta.y=0),this.viewport.flipped&&(f.delta.x=-f.delta.x),this.constrainDuringPan){var M=this.viewport.deltaPointsFromPixels(f.delta.negate());this.viewport.centerSpringX.target.value+=M.x,this.viewport.centerSpringY.target.value+=M.y;var I=this.viewport.getConstrainedBounds();this.viewport.centerSpringX.target.value-=M.x,this.viewport.centerSpringY.target.value-=M.y,I.xConstrained&&(f.delta.x=0),I.yConstrained&&(f.delta.y=0)}this.viewport.panBy(this.viewport.deltaPointsFromPixels(f.delta.negate()),T.flickEnabled&&!this.constrainDuringPan)}}}function H(f){var T,R={tracker:f.eventSource,pointerType:f.pointerType,position:f.position,speed:f.speed,direction:f.direction,shift:f.shift,originalEvent:f.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag-end",R),T=this.gestureSettingsByDeviceType(f.pointerType),!R.preventDefaultAction&&this.viewport){if(!t[this.hash].draggingToZoom&&T.dragToPan&&T.flickEnabled&&f.speed>=T.flickMinSpeed){var O=0;this.panHorizontal&&(O=T.flickMomentum*f.speed*Math.cos(f.direction));var M=0;this.panVertical&&(M=T.flickMomentum*f.speed*Math.sin(f.direction));var I=this.viewport.pixelFromPoint(this.viewport.getCenter(!0)),D=this.viewport.pointFromPixel(new e.Point(I.x-O,I.y-M));this.viewport.panTo(D,!1)}this.viewport.applyConstraints()}T.dblClickDragToZoom&&t[this.hash].draggingToZoom===!0&&(t[this.hash].draggingToZoom=!1)}function B(f){this.raiseEvent("canvas-enter",{tracker:f.eventSource,pointerType:f.pointerType,position:f.position,buttons:f.buttons,pointers:f.pointers,insideElementPressed:f.insideElementPressed,buttonDownAny:f.buttonDownAny,originalEvent:f.originalEvent})}function V(f){this.raiseEvent("canvas-exit",{tracker:f.eventSource,pointerType:f.pointerType,position:f.position,buttons:f.buttons,pointers:f.pointers,insideElementPressed:f.insideElementPressed,buttonDownAny:f.buttonDownAny,originalEvent:f.originalEvent})}function Y(f){var T;if(this.raiseEvent("canvas-press",{tracker:f.eventSource,pointerType:f.pointerType,position:f.position,insideElementPressed:f.insideElementPressed,insideElementReleased:f.insideElementReleased,originalEvent:f.originalEvent}),T=this.gestureSettingsByDeviceType(f.pointerType),T.dblClickDragToZoom){var R=t[this.hash].lastClickTime,O=e.now();if(R===null)return;O-R<this.dblClickTimeThreshold&&(t[this.hash].draggingToZoom=!0),t[this.hash].lastClickTime=null}}function J(f){this.raiseEvent("canvas-release",{tracker:f.eventSource,pointerType:f.pointerType,position:f.position,insideElementPressed:f.insideElementPressed,insideElementReleased:f.insideElementReleased,originalEvent:f.originalEvent})}function re(f){this.raiseEvent("canvas-nonprimary-press",{tracker:f.eventSource,position:f.position,pointerType:f.pointerType,button:f.button,buttons:f.buttons,originalEvent:f.originalEvent})}function Z(f){this.raiseEvent("canvas-nonprimary-release",{tracker:f.eventSource,position:f.position,pointerType:f.pointerType,button:f.button,buttons:f.buttons,originalEvent:f.originalEvent})}function ie(f){var T,R,O,M,I={tracker:f.eventSource,pointerType:f.pointerType,gesturePoints:f.gesturePoints,lastCenter:f.lastCenter,center:f.center,lastDistance:f.lastDistance,distance:f.distance,shift:f.shift,originalEvent:f.originalEvent,preventDefaultPanAction:!1,preventDefaultZoomAction:!1,preventDefaultRotateAction:!1};if(this.raiseEvent("canvas-pinch",I),this.viewport&&(T=this.gestureSettingsByDeviceType(f.pointerType),T.pinchToZoom&&(!I.preventDefaultPanAction||!I.preventDefaultZoomAction)&&(R=this.viewport.pointFromPixel(f.center,!0),T.zoomToRefPoint&&!I.preventDefaultPanAction&&(O=this.viewport.pointFromPixel(f.lastCenter,!0),M=O.minus(R),this.panHorizontal||(M.x=0),this.panVertical||(M.y=0),this.viewport.panBy(M,!0)),I.preventDefaultZoomAction||this.viewport.zoomBy(f.distance/f.lastDistance,R,!0),this.viewport.applyConstraints()),T.pinchRotate&&!I.preventDefaultRotateAction)){var D=Math.atan2(f.gesturePoints[0].currentPos.y-f.gesturePoints[1].currentPos.y,f.gesturePoints[0].currentPos.x-f.gesturePoints[1].currentPos.x),z=Math.atan2(f.gesturePoints[0].lastPos.y-f.gesturePoints[1].lastPos.y,f.gesturePoints[0].lastPos.x-f.gesturePoints[1].lastPos.x);R=this.viewport.pointFromPixel(f.center,!0),this.viewport.rotateTo(this.viewport.getRotation(!0)+(D-z)*(180/Math.PI),R,!0)}}function he(f){this.raiseEvent("canvas-focus",{tracker:f.eventSource,originalEvent:f.originalEvent})}function pe(f){this.raiseEvent("canvas-blur",{tracker:f.eventSource,originalEvent:f.originalEvent})}function ce(f){var T,R,O,M,I;M=e.now(),I=M-this._lastScrollTime,I>this.minScrollDeltaTime?(this._lastScrollTime=M,T={tracker:f.eventSource,position:f.position,scroll:f.scroll,shift:f.shift,originalEvent:f.originalEvent,preventDefaultAction:!1,preventDefault:!0},this.raiseEvent("canvas-scroll",T),!T.preventDefaultAction&&this.viewport&&(this.viewport.flipped&&(f.position.x=this.viewport.getContainerSize().x-f.position.x),R=this.gestureSettingsByDeviceType(f.pointerType),R.scrollToZoom&&(O=Math.pow(this.zoomPerScroll,f.scroll),this.viewport.zoomBy(O,R.zoomToRefPoint?this.viewport.pointFromPixel(f.position,!0):null),this.viewport.applyConstraints())),f.preventDefault=T.preventDefault):f.preventDefault=!0}function ve(f){t[this.hash].mouseInside=!0,m(this),this.raiseEvent("container-enter",{tracker:f.eventSource,pointerType:f.pointerType,position:f.position,buttons:f.buttons,pointers:f.pointers,insideElementPressed:f.insideElementPressed,buttonDownAny:f.buttonDownAny,originalEvent:f.originalEvent})}function fe(f){f.pointers<1&&(t[this.hash].mouseInside=!1,t[this.hash].animating||c(this)),this.raiseEvent("container-exit",{tracker:f.eventSource,pointerType:f.pointerType,position:f.position,buttons:f.buttons,pointers:f.pointers,insideElementPressed:f.insideElementPressed,buttonDownAny:f.buttonDownAny,originalEvent:f.originalEvent})}function we(f){xe(f),f.isOpen()?f._updateRequestId=u(f,we):f._updateRequestId=!1}function He(f,T){var R=f.viewport,O=R.getZoom(),M=R.getCenter();R.resize(T,f.preserveImageSizeOnResize),R.panTo(M,!0);var I;if(f.preserveImageSizeOnResize)I=t[f.hash].prevContainerSize.x/T.x;else{var D=new e.Point(0,0),z=new e.Point(t[f.hash].prevContainerSize.x,t[f.hash].prevContainerSize.y).distanceTo(D),j=new e.Point(T.x,T.y).distanceTo(D);I=j/z*t[f.hash].prevContainerSize.x/T.x}R.zoomTo(O*I,null,!0),t[f.hash].prevContainerSize=T,t[f.hash].forceRedraw=!0,t[f.hash].needsResize=!1,t[f.hash].forceResize=!1}function xe(f){if(!(f._opening||!t[f.hash])){if(f.autoResize||t[f.hash].forceResize){var T;if(f._autoResizePolling){T=i(f.container);var R=t[f.hash].prevContainerSize;T.equals(R)||(t[f.hash].needsResize=!0)}t[f.hash].needsResize&&He(f,T||i(f.container))}var O=f.viewport.update(),M=f.world.update(O)||O;O&&f.raiseEvent("viewport-change"),f.referenceStrip&&(M=f.referenceStrip.update(f.viewport)||M);var I=t[f.hash].animating;!I&&M&&(f.raiseEvent("animation-start"),m(f));var D=I&&!M;D&&(t[f.hash].animating=!1),(M||D||t[f.hash].forceRedraw||f.world.needsDraw())&&(Xe(f),f._drawOverlays(),f.navigator&&f.navigator.update(f.viewport),t[f.hash].forceRedraw=!1,M&&f.raiseEvent("animation")),D&&(f.raiseEvent("animation-finish"),t[f.hash].mouseInside||c(f)),t[f.hash].animating=M}}function Xe(f){f.imageLoader.clear(),f.world.draw(),f.raiseEvent("update-viewport",{})}function X(f,T){return f?f+T:T}function Ye(){t[this.hash].lastZoomTime=e.now(),t[this.hash].zoomFactor=this.zoomPerSecond,t[this.hash].zooming=!0,k(this)}function ct(){t[this.hash].lastZoomTime=e.now(),t[this.hash].zoomFactor=1/this.zoomPerSecond,t[this.hash].zooming=!0,k(this)}function Ue(){t[this.hash].zooming=!1}function k(f){e.requestAnimationFrame(e.delegate(f,te))}function te(){var f,T,R;t[this.hash].zooming&&this.viewport&&(f=e.now(),T=f-t[this.hash].lastZoomTime,R=Math.pow(t[this.hash].zoomFactor,T/1e3),this.viewport.zoomBy(R),this.viewport.applyConstraints(),t[this.hash].lastZoomTime=f,k(this))}function de(){this.viewport&&(t[this.hash].zooming=!1,this.viewport.zoomBy(this.zoomPerClick/1),this.viewport.applyConstraints())}function ye(){this.viewport&&(t[this.hash].zooming=!1,this.viewport.zoomBy(1/this.zoomPerClick),this.viewport.applyConstraints())}function Ke(){this.buttonGroup&&(this.buttonGroup.emulateEnter(),this.buttonGroup.emulateLeave())}function St(){this.viewport&&this.viewport.goHome()}function kt(){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 Nt(){if(this.viewport){var f=this.viewport.getRotation();this.viewport.flipped?f+=this.rotationIncrement:f-=this.rotationIncrement,this.viewport.setRotation(f)}}function Pt(){if(this.viewport){var f=this.viewport.getRotation();this.viewport.flipped?f-=this.rotationIncrement:f+=this.rotationIncrement,this.viewport.setRotation(f)}}function dt(){this.viewport.toggleFlip()}e.determineDrawer=function(f){for(let T in o){const R=o[T],O=R.prototype;if(O&&O instanceof o.DrawerBase&&e.isFunction(O.getType)&&O.getType.call(R)===f)return R}return null}})(o),(function(e){e.Navigator=function(u){var h=u.viewer,c=this,d,m;u.element||u.id?(u.element?(u.id&&e.console.warn("Given option.id for Navigator was ignored since option.element was provided and is being used instead."),u.element.id?u.id=u.element.id:u.id="navigator-"+e.now(),this.element=u.element):this.element=document.getElementById(u.id),u.controlOptions={anchor:e.ControlAnchor.NONE,attachToViewer:!1,autoFade:!1}):(u.id="navigator-"+e.now(),this.element=e.makeNeutralElement("div"),u.controlOptions={anchor:e.ControlAnchor.TOP_RIGHT,attachToViewer:!0,autoFade:u.autoFade},u.position&&(u.position==="BOTTOM_RIGHT"?u.controlOptions.anchor=e.ControlAnchor.BOTTOM_RIGHT:u.position==="BOTTOM_LEFT"?u.controlOptions.anchor=e.ControlAnchor.BOTTOM_LEFT:u.position==="TOP_RIGHT"?u.controlOptions.anchor=e.ControlAnchor.TOP_RIGHT:u.position==="TOP_LEFT"?u.controlOptions.anchor=e.ControlAnchor.TOP_LEFT:u.position==="ABSOLUTE"&&(u.controlOptions.anchor=e.ControlAnchor.ABSOLUTE,u.controlOptions.top=u.top,u.controlOptions.left=u.left,u.controlOptions.height=u.height,u.controlOptions.width=u.width))),this.element.id=u.id,this.element.className+=" navigator",u=e.extend(!0,{sizeRatio:e.DEFAULT_SETTINGS.navigatorSizeRatio},u,{element:this.element,tabIndex:-1,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:u.animationTime,autoResize:!1,minZoomImageRatio:1,background:u.background,opacity:u.opacity,borderColor:u.borderColor,displayRegionColor:u.displayRegionColor}),u.minPixelRatio=this.minPixelRatio=h.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),u.controlOptions.anchor!==e.ControlAnchor.NONE&&(function(_,E){_.margin="0px",_.border=E+"px solid "+u.borderColor,_.padding="0px",_.background=u.background,_.opacity=u.opacity,_.overflow="hidden"})(this.element.style,this.borderWidth),this.displayRegion=e.makeNeutralElement("div"),this.displayRegion.id=this.element.id+"-displayregion",this.displayRegion.className="displayregion",(function(_,E){_.position="relative",_.top="0px",_.left="0px",_.fontSize="0px",_.overflow="hidden",_.border=E+"px solid "+u.displayRegionColor,_.margin="0px",_.padding="0px",_.background="transparent",_.float="left",_.cssFloat="left",_.zIndex=999999999,_.cursor="default",_.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),h.addControl(this.element,u.controlOptions),this._resizeWithViewer=u.controlOptions.anchor!==e.ControlAnchor.ABSOLUTE&&u.controlOptions.anchor!==e.ControlAnchor.NONE,u.width&&u.height?(this.setWidth(u.width),this.setHeight(u.height)):this._resizeWithViewer&&(d=e.getElementSize(h.element),this.element.style.height=Math.round(d.y*u.sizeRatio)+"px",this.element.style.width=Math.round(d.x*u.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,[u]),this.displayRegionContainer.appendChild(this.displayRegion),this.element.getElementsByTagName("div")[0].appendChild(this.displayRegionContainer);function v(_,E){l(c.displayRegionContainer,_),l(c.displayRegion,-_),c.viewport.setRotation(_,E)}if(u.navigatorRotate){var y=u.viewer.viewport?u.viewer.viewport.getRotation():u.viewer.degrees||0;v(y,!0),u.viewer.addHandler("rotate",function(_){v(_.degrees,_.immediately)})}this.innerTracker.destroy(),this.innerTracker=new e.MouseTracker({userData:"Navigator.innerTracker",element:this.element,dragHandler:e.delegate(this,r),clickHandler:e.delegate(this,t),releaseHandler:e.delegate(this,i),scrollHandler:e.delegate(this,s),preProcessEventHandler:function(_){_.eventType==="wheel"&&(_.preventDefault=!0)}}),this.outerTracker.userData="Navigator.outerTracker",e.setElementPointerEventsNone(this.canvas),e.setElementPointerEventsNone(this.container),this.addHandler("reset-size",function(){c.viewport&&c.viewport.goHome(!0)}),h.world.addHandler("item-index-change",function(_){window.setTimeout(function(){var E=c.world.getItemAt(_.previousIndex);c.world.setItemIndex(E,_.newIndex)},1)}),h.world.addHandler("remove-item",function(_){var E=_.item,S=c._getMatchingItem(E);S&&c.world.removeItem(S)}),this.update(h.viewport)},e.extend(e.Navigator.prototype,e.EventSource.prototype,e.Viewer.prototype,{updateSize:function(){if(this.viewport){var u=new e.Point(this.container.clientWidth===0?1:this.container.clientWidth,this.container.clientHeight===0?1:this.container.clientHeight);u.equals(this.oldContainerSize)||(this.viewport.resize(u,!0),this.viewport.goHome(!0),this.oldContainerSize=u,this.world.update(),this.world.draw(),this.update(this.viewer.viewport))}},setWidth:function(u){this.width=u,this.element.style.width=typeof u=="number"?u+"px":u,this._resizeWithViewer=!1,this.updateSize()},setHeight:function(u){this.height=u,this.element.style.height=typeof u=="number"?u+"px":u,this._resizeWithViewer=!1,this.updateSize()},setFlip:function(u){return this.viewport.setFlip(u),this.setDisplayTransform(this.viewer.viewport.getFlip()?"scale(-1,1)":"scale(1,1)"),this},setDisplayTransform:function(u){a(this.canvas,u),a(this.element,u)},update:function(u){var h,c,d,m,v,y;if(u||(u=this.viewer.viewport),h=e.getElementSize(this.viewer.element),this._resizeWithViewer&&h.x&&h.y&&!h.equals(this.oldViewerSize)&&(this.oldViewerSize=h,this.maintainSizeRatio||!this.elementArea?(c=h.x*this.sizeRatio,d=h.y*this.sizeRatio):(c=Math.sqrt(this.elementArea*(h.x/h.y)),d=this.elementArea/c),this.element.style.width=Math.round(c)+"px",this.element.style.height=Math.round(d)+"px",this.elementArea||(this.elementArea=c*d),this.updateSize()),u&&this.viewport){if(m=u.getBoundsNoRotate(!0),v=this.viewport.pixelFromPointNoRotate(m.getTopLeft(),!1),y=this.viewport.pixelFromPointNoRotate(m.getBottomRight(),!1).minus(this.totalBorderWidths),!this.navigatorRotate){var _=u.getRotation(!0);l(this.displayRegion,-_)}var E=this.displayRegion.style;E.display=this.world.getItemCount()?"block":"none",E.top=v.y.toFixed(2)+"px",E.left=v.x.toFixed(2)+"px";var S=y.x-v.x,P=y.y-v.y;E.width=Math.round(Math.max(S,0))+"px",E.height=Math.round(Math.max(P,0))+"px"}},addTiledImage:function(u){var h=this,c=u.originalTiledImage;delete u.original;var d=e.extend({},u,{success:function(m){var v=m.item;v._originalForNavigator=c,h._matchBounds(v,c,!0),h._matchOpacity(v,c),h._matchCompositeOperation(v,c);function y(){h._matchBounds(v,c)}function _(){h._matchOpacity(v,c)}function E(){h._matchCompositeOperation(v,c)}c.addHandler("bounds-change",y),c.addHandler("clip-change",y),c.addHandler("opacity-change",_),c.addHandler("composite-operation-change",E)}});return e.Viewer.prototype.addTiledImage.apply(this,[d])},destroy:function(){return e.Viewer.prototype.destroy.apply(this)},_getMatchingItem:function(u){for(var h=this.world.getItemCount(),c,d=0;d<h;d++)if(c=this.world.getItemAt(d),c._originalForNavigator===u)return c;return null},_matchBounds:function(u,h,c){var d=h.getBoundsNoRotate();u.setPosition(d.getTopLeft(),c),u.setWidth(d.width,c),u.setRotation(h.getRotation(),c),u.setClip(h.getClip()),u.setFlip(h.getFlip())},_matchOpacity:function(u,h){u.setOpacity(h.opacity)},_matchCompositeOperation:function(u,h){u.setCompositeOperation(h.compositeOperation)}});function t(u){var h={tracker:u.eventSource,position:u.position,quick:u.quick,shift:u.shift,originalEvent:u.originalEvent,preventDefaultAction:!1};if(this.viewer.raiseEvent("navigator-click",h),!h.preventDefaultAction&&u.quick&&this.viewer.viewport&&(this.panVertical||this.panHorizontal)){this.viewer.viewport.flipped&&(u.position.x=this.viewport.getContainerSize().x-u.position.x);var c=this.viewport.pointFromPixel(u.position);this.panVertical?this.panHorizontal||(c.x=this.viewer.viewport.getCenter(!0).x):c.y=this.viewer.viewport.getCenter(!0).y,this.viewer.viewport.panTo(c),this.viewer.viewport.applyConstraints()}}function r(u){var h={tracker:u.eventSource,position:u.position,delta:u.delta,speed:u.speed,direction:u.direction,shift:u.shift,originalEvent:u.originalEvent,preventDefaultAction:!1};this.viewer.raiseEvent("navigator-drag",h),!h.preventDefaultAction&&this.viewer.viewport&&(this.panHorizontal||(u.delta.x=0),this.panVertical||(u.delta.y=0),this.viewer.viewport.flipped&&(u.delta.x=-u.delta.x),this.viewer.viewport.panBy(this.viewport.deltaPointsFromPixels(u.delta)),this.viewer.constrainDuringPan&&this.viewer.viewport.applyConstraints())}function i(u){u.insideElementPressed&&this.viewer.viewport&&this.viewer.viewport.applyConstraints()}function s(u){var h={tracker:u.eventSource,position:u.position,scroll:u.scroll,shift:u.shift,originalEvent:u.originalEvent,preventDefault:u.preventDefault};this.viewer.raiseEvent("navigator-scroll",h),u.preventDefault=h.preventDefault}function l(u,h){a(u,"rotate("+h+"deg)")}function a(u,h){u.style.webkitTransform=h,u.style.mozTransform=h,u.style.msTransform=h,u.style.oTransform=h,u.style.transform=h}})(o),(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(r){var i=r.split("."),s=null,l=arguments,a=t,u;for(u=0;u<i.length-1;u++)a=a[i[u]]||{};return s=a[i[u]],typeof s!="string"&&(e.console.error("Untranslated source string:",r),s=""),s.replace(/\{\d+\}/g,function(h){var c=parseInt(h.match(/\d+/),10)+1;return c<l.length?l[c]:""})},setString:function(r,i){var s=r.split("."),l=t,a;for(a=0;a<s.length-1;a++)l[s[a]]||(l[s[a]]={}),l=l[s[a]];l[s[a]]=i}})})(o),(function(e){e.Point=function(t,r){this.x=typeof t=="number"?t:0,this.y=typeof r=="number"?r: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,r){r=r||new e.Point(0,0);var i,s;if(t%90===0){var l=e.positiveModulo(t,360);switch(l){case 0:i=1,s=0;break;case 90:i=0,s=1;break;case 180:i=-1,s=0;break;case 270:i=0,s=-1;break}}else{var a=t*Math.PI/180;i=Math.cos(a),s=Math.sin(a)}var u=i*(this.x-r.x)-s*(this.y-r.y)+r.x,h=s*(this.x-r.x)+i*(this.y-r.y)+r.y;return new e.Point(u,h)},toString:function(){return"("+Math.round(this.x*100)/100+","+Math.round(this.y*100)/100+")"}}})(o),(function(e){e.TileSource=function(r,i,s,l,a,u){var h=this,c=arguments,d,m;if(e.isPlainObject(r)?d=r:d={width:c[0],height:c[1],tileSize:c[2],tileOverlap:c[3],minLevel:c[4],maxLevel:c[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){h.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(r){return e.console.error("[TileSource.getTileSize] is deprecated. Use TileSource.getTileWidth() and TileSource.getTileHeight() instead"),this._tileWidth},getTileWidth:function(r){return this._tileWidth?this._tileWidth:this.getTileSize(r)},getTileHeight:function(r){return this._tileHeight?this._tileHeight:this.getTileSize(r)},setMaxLevel:function(r){this.maxLevel=r,this._memoizeLevelScale()},getLevelScale:function(r){return this._memoizeLevelScale(),this.getLevelScale(r)},_memoizeLevelScale:function(){var r={},i;for(i=0;i<=this.maxLevel;i++)r[i]=1/Math.pow(2,this.maxLevel-i);this.getLevelScale=function(s){return r[s]}},getNumTiles:function(r){var i=this.getLevelScale(r),s=Math.ceil(i*this.dimensions.x/this.getTileWidth(r)),l=Math.ceil(i*this.dimensions.y/this.getTileHeight(r));return new e.Point(s,l)},getPixelRatio:function(r){var i=this.dimensions.times(this.getLevelScale(r)),s=1/i.x*e.pixelDensityRatio,l=1/i.y*e.pixelDensityRatio;return new e.Point(s,l)},getClosestLevel:function(){var r,i;for(r=this.minLevel+1;r<=this.maxLevel&&(i=this.getNumTiles(r),!(i.x>1||i.y>1));r++);return r-1},getTileAtPoint:function(r,i){var s=i.x>=0&&i.x<=1&&i.y>=0&&i.y<=1/this.aspectRatio;e.console.assert(s,"[TileSource.getTileAtPoint] must be called with a valid point.");var l=this.dimensions.x*this.getLevelScale(r),a=i.x*l,u=i.y*l,h=Math.floor(a/this.getTileWidth(r)),c=Math.floor(u/this.getTileHeight(r));i.x>=1&&(h=this.getNumTiles(r).x-1);var d=1e-15;return i.y>=1/this.aspectRatio-d&&(c=this.getNumTiles(r).y-1),new e.Point(h,c)},getTileBounds:function(r,i,s,l){var a=this.dimensions.times(this.getLevelScale(r)),u=this.getTileWidth(r),h=this.getTileHeight(r),c=i===0?0:u*i-this.tileOverlap,d=s===0?0:h*s-this.tileOverlap,m=u+(i===0?1:2)*this.tileOverlap,v=h+(s===0?1:2)*this.tileOverlap,y=1/a.x;return m=Math.min(m,a.x-c),v=Math.min(v,a.y-d),l?new e.Rect(0,0,m,v):new e.Rect(c*y,d*y,m*y,v*y)},getImageInfo:function(r){var i=this,s,l,a,u,h,c,d;r&&(h=r.split("/"),c=h[h.length-1],d=c.lastIndexOf("."),d>-1&&(h[h.length-1]=c.slice(0,d)));var m=null;if(this.splitHashDataForPost){var v=r.indexOf("#");v!==-1&&(m=r.substring(v+1),r=r.substr(0,v))}l=function(y){typeof y=="string"&&(y=e.parseXml(y));var _=e.TileSource.determineType(i,y,r);if(!_){i.raiseEvent("open-failed",{message:"Unable to load TileSource",source:r});return}u=_.prototype.configure.apply(i,[y,r,m]),u.ajaxWithCredentials===void 0&&(u.ajaxWithCredentials=i.ajaxWithCredentials),a=new _(u),i.ready=!0,i.raiseEvent("ready",{tileSource:a})},r.match(/\.js$/)?(s=r.split("/").pop().replace(".js",""),e.jsonp({url:r,async:!1,callbackName:s,callback:l})):e.makeAjaxRequest({url:r,postData:m,withCredentials:this.ajaxWithCredentials,headers:this.ajaxHeaders,success:function(y){var _=t(y);l(_)},error:function(y,_){var E;try{E="HTTP "+y.status+" attempting to load TileSource: "+r}catch{var S;typeof _>"u"||!_.toString?S="Unknown error":S=_.toString(),E=S+" attempting to load TileSource: "+r}e.console.error(E),i.raiseEvent("open-failed",{message:E,source:r,postData:m})}})},supports:function(r,i){return!1},configure:function(r,i,s){throw new Error("Method not implemented.")},getTileUrl:function(r,i,s){throw new Error("Method not implemented.")},getTilePostData:function(r,i,s){return null},getTileAjaxHeaders:function(r,i,s){return{}},getTileHashKey:function(r,i,s,l,a,u){function h(c){return a?c+"+"+JSON.stringify(a):c}return h(typeof l!="string"?r+"/"+i+"_"+s:l)},tileExists:function(r,i,s){var l=this.getNumTiles(r);return r>=this.minLevel&&r<=this.maxLevel&&i>=0&&s>=0&&i<l.x&&s<l.y},hasTransparency:function(r,i,s,l){return!!r||i.match(".png")},downloadTileStart:function(r){var i=r.userData,s=new Image;i.image=s,i.request=null;var l=function(a){if(!s){r.finish(null,i.request,"Image load failed: undefined Image instance.");return}s.onload=s.onerror=s.onabort=null,r.finish(a?null:s,i.request,a)};s.onload=function(){l()},s.onabort=s.onerror=function(){l("Image load aborted.")},r.loadWithAjax?i.request=e.makeAjaxRequest({url:r.src,withCredentials:r.ajaxWithCredentials,headers:r.ajaxHeaders,responseType:"arraybuffer",postData:r.postData,success:function(a){var u;try{u=new window.Blob([a.response])}catch(d){var h=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if(d.name==="TypeError"&&h){var c=new h;c.append(a.response),u=c.getBlob()}}u.size===0?l("Empty image response."):s.src=(window.URL||window.webkitURL).createObjectURL(u)},error:function(a){l("Image load aborted - XHR error")}}):(r.crossOriginPolicy!==!1&&(s.crossOrigin=r.crossOriginPolicy),s.src=r.src)},downloadTileAbort:function(r){r.userData.request&&r.userData.request.abort();var i=r.userData.image;r.userData.image&&(i.onload=i.onerror=i.onabort=null)},createTileCache:function(r,i,s){r._data=i},destroyTileCache:function(r){r._data=null,r._renderedContext=null},getTileCacheData:function(r){return r._data},getTileCacheDataAsImage:function(r){return r._data},getTileCacheDataAsContext2D:function(r){if(!r._renderedContext){var i=document.createElement("canvas");i.width=r._data.width,i.height=r._data.height,r._renderedContext=i.getContext("2d"),r._renderedContext.drawImage(r._data,0,0),r._data=null}return r._renderedContext}},e.extend(!0,e.TileSource.prototype,e.EventSource.prototype);function t(r){var i=r.responseText,s=r.status,l,a;if(r){if(r.status!==200&&r.status!==0)throw s=r.status,l=s===404?"Not Found":r.statusText,new Error(e.getString("Errors.Status",s,l))}else throw new Error(e.getString("Errors.Security"));if(i.match(/^\s*<.*/))try{a=r.responseXML&&r.responseXML.documentElement?r.responseXML:e.parseXml(i)}catch{a=r.responseText}else if(i.match(/\s*[{[].*/))try{a=e.parseJSON(i)}catch{a=i}else a=i;return a}e.TileSource.determineType=function(r,i,s){var l;for(l in o)if(l.match(/.+TileSource$/)&&e.isFunction(o[l])&&e.isFunction(o[l].prototype.supports)&&o[l].prototype.supports.call(r,i,s))return o[l];return e.console.error("No TileSource was able to open %s %s",s,i),null}})(o),(function(e){e.DziTileSource=function(i,s,l,a,u,h,c,d,m){var v,y,_,E;if(e.isPlainObject(i)?E=i:E={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=E.tilesUrl,this.fileFormat=E.fileFormat,this.displayRects=E.displayRects,this.displayRects)for(v=this.displayRects.length-1;v>=0;v--)for(y=this.displayRects[v],_=y.minLevel;_<=y.maxLevel;_++)this._levelRects[_]||(this._levelRects[_]=[]),this._levelRects[_].push(y);e.TileSource.apply(this,[E])},e.extend(e.DziTileSource.prototype,e.TileSource.prototype,{supports:function(i,s){var l;return i.Image?l=i.Image.xmlns:i.documentElement&&(i.documentElement.localName==="Image"||i.documentElement.tagName==="Image")&&(l=i.documentElement.namespaceURI),l=(l||"").toLowerCase(),l.indexOf("schemas.microsoft.com/deepzoom/2008")!==-1||l.indexOf("schemas.microsoft.com/deepzoom/2009")!==-1},configure:function(i,s,l){var a;return e.isPlainObject(i)?a=r(this,i):a=t(this,i),s&&!a.tilesUrl&&(a.tilesUrl=s.replace(/([^/]+?)(\.(dzi|xml|js)?(\?[^/]*)?)?\/?$/,"$1_files/"),s.search(/\.(dzi|xml|js)\?/)!==-1?a.queryParams=s.match(/\?.*/):a.queryParams=""),a},getTileUrl:function(i,s,l){return[this.tilesUrl,i,"/",s,"_",l,".",this.fileFormat,this.queryParams].join("")},tileExists:function(i,s,l){var a=this._levelRects[i],u,h,c,d,m,v,y;if(this.minLevel&&i<this.minLevel||this.maxLevel&&i>this.maxLevel)return!1;if(!a||!a.length)return!0;for(y=a.length-1;y>=0;y--)if(u=a[y],!(i<u.minLevel||i>u.maxLevel)&&(h=this.getLevelScale(i),c=u.x*h,d=u.y*h,m=c+u.width*h,v=d+u.height*h,c=Math.floor(c/this._tileWidth),d=Math.floor(d/this._tileWidth),m=Math.ceil(m/this._tileWidth),v=Math.ceil(v/this._tileWidth),c<=s&&s<m&&d<=l&&l<v))return!0;return!1}});function t(i,s){if(!s||!s.documentElement)throw new Error(e.getString("Errors.Xml"));var l=s.documentElement,a=l.localName||l.tagName,u=s.documentElement.namespaceURI,h=null,c=[],d,m,v,y,_;if(a==="Image")try{if(y=l.getElementsByTagName("Size")[0],y===void 0&&(y=l.getElementsByTagNameNS(u,"Size")[0]),h={Image:{xmlns:"http://schemas.microsoft.com/deepzoom/2008",Url:l.getAttribute("Url"),Format:l.getAttribute("Format"),DisplayRect:null,Overlap:parseInt(l.getAttribute("Overlap"),10),TileSize:parseInt(l.getAttribute("TileSize"),10),Size:{Height:parseInt(y.getAttribute("Height"),10),Width:parseInt(y.getAttribute("Width"),10)}}},!e.imageFormatSupported(h.Image.Format))throw new Error(e.getString("Errors.ImageFormat",h.Image.Format.toUpperCase()));for(d=l.getElementsByTagName("DisplayRect"),d===void 0&&(d=l.getElementsByTagNameNS(u,"DisplayRect")[0]),_=0;_<d.length;_++)m=d[_],v=m.getElementsByTagName("Rect")[0],v===void 0&&(v=m.getElementsByTagNameNS(u,"Rect")[0]),c.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 c.length&&(h.Image.DisplayRect=c),r(i,h)}catch(P){throw P instanceof Error?P:new Error(e.getString("Errors.Dzi"))}else{if(a==="Collection")throw new Error(e.getString("Errors.Dzc"));if(a==="Error"){var E=l.getElementsByTagName("Message")[0],S=E.firstChild.nodeValue;throw new Error(S)}}throw new Error(e.getString("Errors.Dzi"))}function r(i,s){var l=s.Image,a=l.Url,u=l.Format,h=l.Size,c=l.DisplayRect||[],d=parseInt(h.Width,10),m=parseInt(h.Height,10),v=parseInt(l.TileSize,10),y=parseInt(l.Overlap,10),_=[],E,S;for(S=0;S<c.length;S++)E=c[S].Rect,_.push(new e.DisplayRect(parseInt(E.X,10),parseInt(E.Y,10),parseInt(E.Width,10),parseInt(E.Height,10),parseInt(E.MinLevel,10),parseInt(E.MaxLevel,10)));return e.extend(!0,{width:d,height:m,tileSize:v,tileOverlap:y,minLevel:null,maxLevel:null,tilesUrl:a,fileFormat:u,displayRects:_},s)}})(o),(function(e){e.IIIFTileSource=function(l){if(e.extend(!0,this,l),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(l.tileSizePerScaleFactor={},this.tileFormat=this.tileFormat||"jpg",this.version=l.version,this.tile_width&&this.tile_height)l.tileWidth=this.tile_width,l.tileHeight=this.tile_height;else if(this.tile_width)l.tileSize=this.tile_width;else if(this.tile_height)l.tileSize=this.tile_height;else if(this.tiles)if(this.tiles.length===1)l.tileWidth=this.tiles[0].width,l.tileHeight=this.tiles[0].height||this.tiles[0].width,this.scale_factors=this.tiles[0].scaleFactors;else{this.scale_factors=[];for(var a=0;a<this.tiles.length;a++)for(var u=0;u<this.tiles[a].scaleFactors.length;u++){var h=this.tiles[a].scaleFactors[u];this.scale_factors.push(h),l.tileSizePerScaleFactor[h]={width:this.tiles[a].width,height:this.tiles[a].height||this.tiles[a].width}}}else if(t(l)){for(var c=Math.min(this.height,this.width),d=[256,512,1024],m=[],v=0;v<d.length;v++)d[v]<=c&&m.push(d[v]);m.length>0?l.tileSize=Math.max.apply(null,m):l.tileSize=c}else this.sizes&&this.sizes.length>0?(this.emulateLegacyImagePyramid=!0,l.levels=r(this),e.extend(!0,l,{width:l.levels[l.levels.length-1].width,height:l.levels[l.levels.length-1].height,tileSize:Math.max(l.height,l.width),tileOverlap:0,minLevel:0,maxLevel:l.levels.length-1}),this.levels=l.levels):e.console.error("Nothing in the info.json to construct image pyramids from");if(!l.maxLevel&&!this.emulateLegacyImagePyramid)if(!this.scale_factors)l.maxLevel=Number(Math.round(Math.log(Math.max(this.width,this.height),2)));else{var y=Math.max.apply(null,this.scale_factors);l.maxLevel=Math.round(Math.log(y)*Math.LOG2E)}if(this.sizes){var _=this.sizes.length;(_===l.maxLevel||_===l.maxLevel+1)&&(this.levelSizes=this.sizes.slice().sort((E,S)=>E.width-S.width),_===l.maxLevel&&this.levelSizes.push({width:this.width,height:this.height}))}e.TileSource.apply(this,[l])},e.extend(e.IIIFTileSource.prototype,e.TileSource.prototype,{supports:function(l,a){return l.protocol&&l.protocol==="http://iiif.io/api/image"||l["@context"]&&(l["@context"]==="http://library.stanford.edu/iiif/image-api/1.1/context.json"||l["@context"]==="http://iiif.io/api/image/1/context.json")||l.profile&&l.profile.indexOf("http://library.stanford.edu/iiif/image-api/compliance.html")===0||l.identifier&&l.width&&l.height?!0:!!(l.documentElement&&l.documentElement.tagName==="info"&&l.documentElement.namespaceURI==="http://library.stanford.edu/iiif/image-api/ns/")},configure:function(l,a,u){if(e.isPlainObject(l)){if(!l["@context"])l["@context"]="http://iiif.io/api/image/1.0/context.json",l["@id"]=a.replace("/info.json",""),l.version=1;else{var c=l["@context"];if(Array.isArray(c)){for(var d=0;d<c.length;d++)if(typeof c[d]=="string"&&(/^http:\/\/iiif\.io\/api\/image\/[1-3]\/context\.json$/.test(c[d])||c[d]==="http://library.stanford.edu/iiif/image-api/1.1/context.json")){c=c[d];break}}switch(c){case"http://iiif.io/api/image/1/context.json":case"http://library.stanford.edu/iiif/image-api/1.1/context.json":l.version=1;break;case"http://iiif.io/api/image/2/context.json":l.version=2;break;case"http://iiif.io/api/image/3/context.json":l.version=3;break;default:e.console.error("Data has a @context property which contains no known IIIF context URI.")}}if(l.preferredFormats){for(var m=0;m<l.preferredFormats.length;m++)if(o.imageFormatSupported(l.preferredFormats[m])){l.tileFormat=l.preferredFormats[m];break}}return l}else{var h=i(l);return h["@context"]="http://iiif.io/api/image/1.0/context.json",h["@id"]=a.replace("/info.xml",""),h.version=1,h}},getTileWidth:function(l){if(this.emulateLegacyImagePyramid)return e.TileSource.prototype.getTileWidth.call(this,l);var a=Math.pow(2,this.maxLevel-l);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[a]?this.tileSizePerScaleFactor[a].width:this._tileWidth},getTileHeight:function(l){if(this.emulateLegacyImagePyramid)return e.TileSource.prototype.getTileHeight.call(this,l);var a=Math.pow(2,this.maxLevel-l);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[a]?this.tileSizePerScaleFactor[a].height:this._tileHeight},getLevelScale:function(l){if(this.emulateLegacyImagePyramid){var a=NaN;return this.levels.length>0&&l>=this.minLevel&&l<=this.maxLevel&&(a=this.levels[l].width/this.levels[this.maxLevel].width),a}return e.TileSource.prototype.getLevelScale.call(this,l)},getNumTiles:function(l){if(this.emulateLegacyImagePyramid){var a=this.getLevelScale(l);return a?new e.Point(1,1):new e.Point(0,0)}if(this.levelSizes){var u=this.levelSizes[l],h=Math.ceil(u.width/this.getTileWidth(l)),c=Math.ceil(u.height/this.getTileHeight(l));return new e.Point(h,c)}else return e.TileSource.prototype.getNumTiles.call(this,l)},getTileAtPoint:function(l,a){if(this.emulateLegacyImagePyramid)return new e.Point(0,0);if(this.levelSizes){var u=a.x>=0&&a.x<=1&&a.y>=0&&a.y<=1/this.aspectRatio;e.console.assert(u,"[TileSource.getTileAtPoint] must be called with a valid point.");var h=this.levelSizes[l].width,c=a.x*h,d=a.y*h,m=Math.floor(c/this.getTileWidth(l)),v=Math.floor(d/this.getTileHeight(l));a.x>=1&&(m=this.getNumTiles(l).x-1);var y=1e-15;return a.y>=1/this.aspectRatio-y&&(v=this.getNumTiles(l).y-1),new e.Point(m,v)}return e.TileSource.prototype.getTileAtPoint.call(this,l,a)},getTileUrl:function(l,a,u){if(this.emulateLegacyImagePyramid){var h=null;return this.levels.length>0&&l>=this.minLevel&&l<=this.maxLevel&&(h=this.levels[l].url),h}var c="0",d=Math.pow(.5,this.maxLevel-l),m,v,y,_,E,S,P,L,F,H,B,V,Y,J,re,Z;return this.levelSizes?(m=this.levelSizes[l].width,v=this.levelSizes[l].height):(m=Math.ceil(this.width*d),v=Math.ceil(this.height*d)),y=this.getTileWidth(l),_=this.getTileHeight(l),E=Math.round(y/d),S=Math.round(_/d),this.version===1?re="native."+this.tileFormat:re="default."+this.tileFormat,m<y&&v<_?(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+",",P="full"):(L=a*E,F=u*S,H=Math.min(E,this.width-L),B=Math.min(S,this.height-F),a===0&&u===0&&H===this.width&&B===this.height?P="full":P=[L,F,H,B].join(","),Y=Math.min(y,m-a*y),J=Math.min(_,v-u*_),this.version===2&&Y===this.width?V="full":this.version===3&&Y===this.width&&J===this.height?V="max":this.version===3?V=Y+","+J:V=Y+","),Z=[this._id,P,V,c,re].join("/"),Z},__testonly__:{canBeTiled:t,constructLevels:r}});function t(l){var a=["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"],u=Array.isArray(l.profile)?l.profile[0]:l.profile,h=a.indexOf(u)!==-1,c=!1;return l.version===2&&l.profile.length>1&&l.profile[1].supports&&(c=l.profile[1].supports.indexOf("sizeByW")!==-1),l.version===3&&l.extraFeatures&&(c=l.extraFeatures.indexOf("sizeByWh")!==-1),!h||c}function r(l){for(var a=[],u=0;u<l.sizes.length;u++)a.push({url:l._id+"/full/"+l.sizes[u].width+","+(l.version===3?l.sizes[u].height:"")+"/0/default."+l.tileFormat,width:l.sizes[u].width,height:l.sizes[u].height});return a.sort(function(h,c){return h.width-c.width})}function i(l){if(!l||!l.documentElement)throw new Error(e.getString("Errors.Xml"));var a=l.documentElement,u=a.tagName,h=null;if(u==="info")try{return h={},s(a,h),h}catch(c){throw c instanceof Error?c:new Error(e.getString("Errors.IIIF"))}throw new Error(e.getString("Errors.IIIF"))}function s(l,a,u){var h,c;if(l.nodeType===3&&u)c=l.nodeValue.trim(),c.match(/^\d*$/)&&(c=Number(c)),a[u]?(e.isArray(a[u])||(a[u]=[a[u]]),a[u].push(c)):a[u]=c;else if(l.nodeType===1)for(h=0;h<l.childNodes.length;h++)s(l.childNodes[h],a,l.nodeName)}})(o),(function(e){e.OsmTileSource=function(t,r,i,s,l){var a;e.isPlainObject(t)?a=t:a={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]},(!a.width||!a.height)&&(a.width=65572864,a.height=65572864),a.tileSize||(a.tileSize=256,a.tileOverlap=0),a.tilesUrl||(a.tilesUrl="http://tile.openstreetmap.org/"),a.minLevel=8,e.TileSource.apply(this,[a])},e.extend(e.OsmTileSource.prototype,e.TileSource.prototype,{supports:function(t,r){return t.type&&t.type==="openstreetmaps"},configure:function(t,r,i){return t},getTileUrl:function(t,r,i){return this.tilesUrl+(t-8)+"/"+r+"/"+i+".png"}})})(o),(function(e){e.TmsTileSource=function(t,r,i,s,l){var a;e.isPlainObject(t)?a=t:a={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]};var u=Math.ceil(a.width/256)*256,h=Math.ceil(a.height/256)*256,c;u>h?c=u/256:c=h/256,a.maxLevel=Math.ceil(Math.log(c)/Math.log(2))-1,a.tileSize=256,a.width=u,a.height=h,e.TileSource.apply(this,[a])},e.extend(e.TmsTileSource.prototype,e.TileSource.prototype,{supports:function(t,r){return t.type&&t.type==="tiledmapservice"},configure:function(t,r,i){return t},getTileUrl:function(t,r,i){var s=this.getNumTiles(t).y-1;return this.tilesUrl+t+"/"+r+"/"+(s-i)+".png"}})})(o),(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 r={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(r.x,10)>t.tileSize||parseInt(r.y,10)>t.tileSize;)r.x=Math.floor(r.x/2),r.y=Math.floor(r.y/2),t.imageSizes.push({x:r.x,y:r.y}),t.gridSize.push(this._getGridSize(r.x,r.y,t.tileSize));t.imageSizes.reverse(),t.gridSize.reverse(),t.minLevel=0,t.maxLevel=t.gridSize.length-1,o.TileSource.apply(this,[t])},e.extend(e.ZoomifyTileSource.prototype,e.TileSource.prototype,{_getGridSize:function(t,r,i){return{x:Math.ceil(t/i),y:Math.ceil(r/i)}},_calculateAbsoluteTileNumber:function(t,r,i){for(var s=0,l={},a=0;a<t;a++)l=this.gridSize[a],s+=l.x*l.y;return l=this.gridSize[t],s+=l.x*i+r,s},supports:function(t,r){return t.type&&t.type==="zoomifytileservice"},configure:function(t,r,i){return t},getTileUrl:function(t,r,i){var s=0,l=this._calculateAbsoluteTileNumber(t,r,i);return s=Math.floor(l/256),this.tilesUrl+"TileGroup"+s+"/"+t+"-"+r+"-"+i+"."+this.fileFormat}})})(o),(function(e){e.LegacyTileSource=function(s){var l,a,u;e.isArray(s)&&(l={type:"legacy-image-pyramid",levels:s}),l.levels=t(l.levels),l.levels.length>0?(a=l.levels[l.levels.length-1].width,u=l.levels[l.levels.length-1].height):(a=0,u=0,e.console.error("No supported image formats found")),e.extend(!0,l,{width:a,height:u,tileSize:Math.max(u,a),tileOverlap:0,minLevel:0,maxLevel:l.levels.length>0?l.levels.length-1:0}),e.TileSource.apply(this,[l]),this.levels=l.levels},e.extend(e.LegacyTileSource.prototype,e.TileSource.prototype,{supports:function(s,l){return s.type&&s.type==="legacy-image-pyramid"||s.documentElement&&s.documentElement.getAttribute("type")==="legacy-image-pyramid"},configure:function(s,l,a){var u;return e.isPlainObject(s)?u=i(this,s):u=r(this,s),u},getLevelScale:function(s){var l=NaN;return this.levels.length>0&&s>=this.minLevel&&s<=this.maxLevel&&(l=this.levels[s].width/this.levels[this.maxLevel].width),l},getNumTiles:function(s){var l=this.getLevelScale(s);return l?new e.Point(1,1):new e.Point(0,0)},getTileUrl:function(s,l,a){var u=null;return this.levels.length>0&&s>=this.minLevel&&s<=this.maxLevel&&(u=this.levels[s].url),u}});function t(s){var l=[],a,u;for(u=0;u<s.length;u++)a=s[u],a.height&&a.width&&a.url?l.push({url:a.url,width:Number(a.width),height:Number(a.height)}):e.console.error("Unsupported image format: %s",a.url?a.url:"<no URL>");return l.sort(function(h,c){return h.height-c.height})}function r(s,l){if(!l||!l.documentElement)throw new Error(e.getString("Errors.Xml"));var a=l.documentElement,u=a.tagName,h=null,c=[],d,m;if(u==="image")try{for(h={type:a.getAttribute("type"),levels:[]},c=a.getElementsByTagName("level"),m=0;m<c.length;m++)d=c[m],h.levels.push({url:d.getAttribute("url"),width:parseInt(d.getAttribute("width"),10),height:parseInt(d.getAttribute("height"),10)});return i(s,h)}catch(v){throw v instanceof Error?v:new Error("Unknown error parsing Legacy Image Pyramid XML.")}else{if(u==="collection")throw new Error("Legacy Image Pyramid Collections not yet supported.");if(u==="error")throw new Error("Error: "+l)}throw new Error("Unknown element "+u)}function i(s,l){return l.levels}})(o),(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,r){return t.type&&t.type==="image"},configure:function(t,r,i){return t},getImageInfo:function(t){var r=this._image=new Image,i=this;this.crossOriginPolicy&&(r.crossOrigin=this.crossOriginPolicy),this.ajaxWithCredentials&&(r.useCredentials=this.ajaxWithCredentials),e.addEvent(r,"load",function(){i.width=r.naturalWidth,i.height=r.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(r,"error",function(){i.raiseEvent("open-failed",{message:"Error loading image at "+t,source:t})}),r.src=t},getLevelScale:function(t){var r=NaN;return t>=this.minLevel&&t<=this.maxLevel&&(r=this.levels[t].width/this.levels[this.maxLevel].width),r},getNumTiles:function(t){var r=this.getLevelScale(t);return r?new e.Point(1,1):new e.Point(0,0)},getTileUrl:function(t,r,i){var s=null;return t>=this.minLevel&&t<=this.maxLevel&&(s=this.levels[t].url),s},getContext2D:function(t,r,i){var s=null;return t>=this.minLevel&&t<=this.maxLevel&&(s=this.levels[t].context2D),s},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 r=this._image.naturalWidth,i=this._image.naturalHeight,s=document.createElement("canvas"),l=s.getContext("2d");if(s.width=r,s.height=i,l.drawImage(this._image,0,0,r,i),t[0].context2D=l,delete this._image,e.isCanvasTainted(s))return t;for(;r>=2&&i>=2;){r=Math.floor(r/2),i=Math.floor(i/2);var a=document.createElement("canvas"),u=a.getContext("2d");a.width=r,a.height=i,u.drawImage(s,0,0,r,i),t.splice(0,0,{context2D:u,width:r,height:i}),s=a,l=u}return t},_freeupCanvasMemory:function(t){for(var r=0;r<this.levels.length;r++)this.levels[r].context2D&&(this.levels[r].context2D.canvas.height=0,this.levels[r].context2D.canvas.width=0,t&&t.raiseEvent("image-unloaded",{context2D:this.levels[r].context2D}))}})})(o),(function(e){e.TileSourceCollection=function(t,r,i,s){e.console.error("TileSourceCollection is deprecated; use World instead")}})(o),(function(e){e.ButtonState={REST:0,GROUP:1,HOVER:2,DOWN:3},e.Button=function(u){var h=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},u),this.element=u.element||e.makeNeutralElement("div"),u.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(c){c.insideElementPressed?(l(h,e.ButtonState.DOWN),h.raiseEvent("enter",{originalEvent:c.originalEvent})):c.buttonDownAny||l(h,e.ButtonState.HOVER)},focusHandler:function(c){h.tracker.enterHandler(c),h.raiseEvent("focus",{originalEvent:c.originalEvent})},leaveHandler:function(c){a(h,e.ButtonState.GROUP),c.insideElementPressed&&h.raiseEvent("exit",{originalEvent:c.originalEvent})},blurHandler:function(c){h.tracker.leaveHandler(c),h.raiseEvent("blur",{originalEvent:c.originalEvent})},pressHandler:function(c){l(h,e.ButtonState.DOWN),h.raiseEvent("press",{originalEvent:c.originalEvent})},releaseHandler:function(c){c.insideElementPressed&&c.insideElementReleased?(a(h,e.ButtonState.HOVER),h.raiseEvent("release",{originalEvent:c.originalEvent})):c.insideElementPressed?a(h,e.ButtonState.GROUP):l(h,e.ButtonState.HOVER)},clickHandler:function(c){c.quick&&h.raiseEvent("click",{originalEvent:c.originalEvent})},keyHandler:function(c){c.keyCode===13?(h.raiseEvent("click",{originalEvent:c.originalEvent}),h.raiseEvent("release",{originalEvent:c.originalEvent}),c.preventDefault=!0):c.preventDefault=!1}}),a(this,e.ButtonState.REST)},e.extend(e.Button.prototype,e.EventSource.prototype,{notifyGroupEnter:function(){l(this,e.ButtonState.GROUP)},notifyGroupExit:function(){a(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(u){e.requestAnimationFrame(function(){r(u)})}function r(u){var h,c,d;u.shouldFade&&(h=e.now(),c=h-u.fadeBeginTime,d=1-c/u.fadeLength,d=Math.min(1,d),d=Math.max(0,d),u.imgGroup&&e.setElementOpacity(u.imgGroup,d,!0),d>0&&t(u))}function i(u){u.shouldFade=!0,u.fadeBeginTime=e.now()+u.fadeDelay,window.setTimeout(function(){t(u)},u.fadeDelay)}function s(u){u.shouldFade=!1,u.imgGroup&&e.setElementOpacity(u.imgGroup,1,!0)}function l(u,h){u.element.disabled||(h>=e.ButtonState.GROUP&&u.currentState===e.ButtonState.REST&&(s(u),u.currentState=e.ButtonState.GROUP),h>=e.ButtonState.HOVER&&u.currentState===e.ButtonState.GROUP&&(u.imgHover&&(u.imgHover.style.visibility=""),u.currentState=e.ButtonState.HOVER),h>=e.ButtonState.DOWN&&u.currentState===e.ButtonState.HOVER&&(u.imgDown&&(u.imgDown.style.visibility=""),u.currentState=e.ButtonState.DOWN))}function a(u,h){u.element.disabled||(h<=e.ButtonState.HOVER&&u.currentState===e.ButtonState.DOWN&&(u.imgDown&&(u.imgDown.style.visibility="hidden"),u.currentState=e.ButtonState.HOVER),h<=e.ButtonState.GROUP&&u.currentState===e.ButtonState.HOVER&&(u.imgHover&&(u.imgHover.style.visibility="hidden"),u.currentState=e.ButtonState.GROUP),h<=e.ButtonState.REST&&u.currentState===e.ButtonState.GROUP&&(i(u),u.currentState=e.ButtonState.REST))}})(o),(function(e){e.ButtonGroup=function(t){e.extend(!0,this,{buttons:[],clickTimeThreshold:e.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:e.DEFAULT_SETTINGS.clickDistThreshold,labelText:""},t);var r=this.buttons.concat([]),i=this,s;if(this.element=t.element||e.makeNeutralElement("div"),!t.group)for(this.element.style.display="inline-block",s=0;s<r.length;s++)this.element.appendChild(r[s].element);e.setElementTouchActionNone(this.element),this.tracker=new e.MouseTracker({userData:"ButtonGroup.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(l){var a;for(a=0;a<i.buttons.length;a++)i.buttons[a].notifyGroupEnter()},leaveHandler:function(l){var a;if(!l.insideElementPressed)for(a=0;a<i.buttons.length;a++)i.buttons[a].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}}})(o),(function(e){e.Rect=function(t,r,i,s,l){this.x=typeof t=="number"?t:0,this.y=typeof r=="number"?r:0,this.width=typeof i=="number"?i:0,this.height=typeof s=="number"?s:0,this.degrees=typeof l=="number"?l:0,this.degrees=e.positiveModulo(this.degrees,360);var a,u;this.degrees>=270?(a=this.getTopRight(),this.x=a.x,this.y=a.y,u=this.height,this.height=this.width,this.width=u,this.degrees-=270):this.degrees>=180?(a=this.getBottomRight(),this.x=a.x,this.y=a.y,this.degrees-=180):this.degrees>=90&&(a=this.getBottomLeft(),this.x=a.x,this.y=a.y,u=this.height,this.height=this.width,this.width=u,this.degrees-=90)},e.Rect.fromSummits=function(t,r,i){var s=t.distanceTo(r),l=t.distanceTo(i),a=r.minus(t),u=Math.atan(a.y/a.x);return a.x<0?u+=Math.PI:a.y<0&&(u+=2*Math.PI),new e.Rect(t.x,t.y,s,l,u/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 r=this.getBoundingBox(),i=t.getBoundingBox(),s=Math.min(r.x,i.x),l=Math.min(r.y,i.y),a=Math.max(r.x+r.width,i.x+i.width),u=Math.max(r.y+r.height,i.y+i.height);return new e.Rect(s,l,a-s,u-l)},intersection:function(t){var r=1e-10,i=[],s=this.getTopLeft();t.containsPoint(s,r)&&i.push(s);var l=this.getTopRight();t.containsPoint(l,r)&&i.push(l);var a=this.getBottomLeft();t.containsPoint(a,r)&&i.push(a);var u=this.getBottomRight();t.containsPoint(u,r)&&i.push(u);var h=t.getTopLeft();this.containsPoint(h,r)&&i.push(h);var c=t.getTopRight();this.containsPoint(c,r)&&i.push(c);var d=t.getBottomLeft();this.containsPoint(d,r)&&i.push(d);var m=t.getBottomRight();this.containsPoint(m,r)&&i.push(m);for(var v=this._getSegments(),y=t._getSegments(),_=0;_<v.length;_++)for(var E=v[_],S=0;S<y.length;S++){var P=y[S],L=F(E[0],E[1],P[0],P[1]);L&&i.push(L)}function F(Z,ie,he,pe){var ce=ie.minus(Z),ve=pe.minus(he),fe=-ve.x*ce.y+ce.x*ve.y;if(fe===0)return null;var we=(ce.x*(Z.y-he.y)-ce.y*(Z.x-he.x))/fe,He=(ve.x*(Z.y-he.y)-ve.y*(Z.x-he.x))/fe;return-r<=we&&we<=1-r&&-r<=He&&He<=1-r?new e.Point(Z.x+He*ce.x,Z.y+He*ce.y):null}if(i.length===0)return null;for(var H=i[0].x,B=i[0].x,V=i[0].y,Y=i[0].y,J=1;J<i.length;J++){var re=i[J];re.x<H&&(H=re.x),re.x>B&&(B=re.x),re.y<V&&(V=re.y),re.y>Y&&(Y=re.y)}return new e.Rect(H,V,B-H,Y-V)},_getSegments:function(){var t=this.getTopLeft(),r=this.getTopRight(),i=this.getBottomLeft(),s=this.getBottomRight();return[[t,r],[r,s],[s,i],[i,t]]},rotate:function(t,r){if(t=e.positiveModulo(t,360),t===0)return this.clone();r=r||this.getCenter();var i=this.getTopLeft().rotate(t,r),s=this.getTopRight().rotate(t,r),l=s.minus(i);l=l.apply(function(u){var h=1e-15;return Math.abs(u)<h?0:u});var a=Math.atan(l.y/l.x);return l.x<0?a+=Math.PI:l.y<0&&(a+=2*Math.PI),new e.Rect(i.x,i.y,this.width,this.height,a/Math.PI*180)},getBoundingBox:function(){if(this.degrees===0)return this.clone();var t=this.getTopLeft(),r=this.getTopRight(),i=this.getBottomLeft(),s=this.getBottomRight(),l=Math.min(t.x,r.x,i.x,s.x),a=Math.max(t.x,r.x,i.x,s.x),u=Math.min(t.y,r.y,i.y,s.y),h=Math.max(t.y,r.y,i.y,s.y);return new e.Rect(l,u,a-l,h-u)},getIntegerBoundingBox:function(){var t=this.getBoundingBox(),r=Math.floor(t.x),i=Math.floor(t.y),s=Math.ceil(t.width+t.x-r),l=Math.ceil(t.height+t.y-i);return new e.Rect(r,i,s,l)},containsPoint:function(t,r){r=r||0;var i=this.getTopLeft(),s=this.getTopRight(),l=this.getBottomLeft(),a=s.minus(i),u=l.minus(i);return(t.x-i.x)*a.x+(t.y-i.y)*a.y>=-r&&(t.x-s.x)*a.x+(t.y-s.y)*a.y<=r&&(t.x-i.x)*u.x+(t.y-i.y)*u.y>=-r&&(t.x-l.x)*u.x+(t.y-l.y)*u.y<=r},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]"}}})(o),(function(e){var t={};e.ReferenceStrip=function(d){var m=this,v=d.viewer,y=e.getElementSize(v.element),_,E,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,E=this.element.style,E.marginTop="0px",E.marginRight="0px",E.marginBottom="0px",E.marginLeft="0px",E.left="0px",E.bottom="0px",E.border="0px",E.background="#000",E.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,r),dragHandler:e.delegate(this,i),scrollHandler:e.delegate(this,s),enterHandler:e.delegate(this,a),leaveHandler:e.delegate(this,u),keyDownHandler:e.delegate(this,h),keyHandler:e.delegate(this,c),preProcessEventHandler:function(P){P.eventType==="wheel"&&(P.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++)_=e.makeNeutralElement("div"),_.id=this.element.id+"-"+S,_.style.width=m.panelWidth+"px",_.style.height=m.panelHeight+"px",_.style.display="inline",_.style.float="left",_.style.cssFloat="left",_.style.padding="2px",e.setElementTouchActionNone(_),e.setElementPointerEventsNone(_),this.element.appendChild(_),_.activePanel=!1,this.panels.push(_);l(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","")),_=Number(this.element.style.height.replace("px","")),E=-Number(this.element.style.marginLeft.replace("px","")),S=-Number(this.element.style.marginTop.replace("px","")),P;this.currentSelected!==m&&(this.currentSelected&&(this.currentSelected.style.background="#000"),this.currentSelected=m,this.currentSelected.style.background="#999",this.scroll==="horizontal"?(P=Number(d)*(this.panelWidth+3),P>E+v.x-this.panelWidth?(P=Math.min(P,y-v.x),this.element.style.marginLeft=-P+"px",l(this,v.x,-P)):P<E&&(P=Math.max(0,P-v.x/2),this.element.style.marginLeft=-P+"px",l(this,v.x,-P))):(P=Number(d)*(this.panelHeight+3),P>S+v.y-this.panelHeight?(P=Math.min(P,_-v.y),this.element.style.marginTop=-P+"px",l(this,v.y,-P)):P<S&&(P=Math.max(0,P-v.y/2),this.element.style.marginTop=-P+"px",l(this,v.y,-P))),this.currentPage=d,a.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 r(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","")),_=Number(this.element.style.height.replace("px","")),E=e.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?-d.delta.x>0?m>-(y-E.x)&&(this.element.style.marginLeft=m+d.delta.x*2+"px",l(this,E.x,m+d.delta.x*2)):-d.delta.x<0&&m<0&&(this.element.style.marginLeft=m+d.delta.x*2+"px",l(this,E.x,m+d.delta.x*2)):-d.delta.y>0?v>-(_-E.y)&&(this.element.style.marginTop=v+d.delta.y*2+"px",l(this,E.y,v+d.delta.y*2)):-d.delta.y<0&&v<0&&(this.element.style.marginTop=v+d.delta.y*2+"px",l(this,E.y,v+d.delta.y*2))}}function s(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","")),_=Number(this.element.style.height.replace("px","")),E=e.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?d.scroll>0?m>-(y-E.x)&&(this.element.style.marginLeft=m-d.scroll*60+"px",l(this,E.x,m-d.scroll*60)):d.scroll<0&&m<0&&(this.element.style.marginLeft=m-d.scroll*60+"px",l(this,E.x,m-d.scroll*60)):d.scroll<0?v>E.y-_&&(this.element.style.marginTop=v+d.scroll*60+"px",l(this,E.y,v+d.scroll*60)):d.scroll>0&&v<0&&(this.element.style.marginTop=v+d.scroll*60+"px",l(this,E.y,v+d.scroll*60)),d.preventDefault=!0}}function l(d,m,v){var y,_,E,S,P,L;for(d.scroll==="horizontal"?y=d.panelWidth:y=d.panelHeight,_=Math.ceil(m/y)+5,E=Math.ceil((Math.abs(v)+m)/y)+1,_=E-_,_=_<0?0:_,P=_;P<E&&P<d.panels.length;P++)if(L=d.panels[P],!L.activePanel){var F,H=d.viewer.tileSources[P];H.referenceStripThumbnailUrl?F={type:"image",url:H.referenceStripThumbnailUrl}:F=H,S=new e.Viewer({id:L.id,tileSources:[F],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 a(d){var m=d.eventSource.element;this.scroll==="horizontal"?m.style.marginBottom="0px":m.style.marginLeft="0px"}function u(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 h(d){if(!d.ctrl&&!d.alt&&!d.meta)switch(d.keyCode){case 38:s.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 40:s.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 37:s.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 39:s.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 c(d){if(!d.ctrl&&!d.alt&&!d.meta)switch(d.keyCode){case 61:s.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 45:s.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 48:case 119:case 87:s.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 115:case 83:s.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 97:s.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 100:s.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;default:d.preventDefault=!1;break}else d.preventDefault=!1}})(o),(function(e){e.DisplayRect=function(t,r,i,s,l,a){e.Rect.apply(this,[t,r,i,s]),this.minLevel=l,this.maxLevel=a},e.extend(e.DisplayRect.prototype,e.Rect.prototype)})(o),(function(e){e.Spring=function(r){var i=arguments;typeof r!="object"&&(r={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 r.springStiffness=="number"&&r.springStiffness!==0,"[OpenSeadragon.Spring] options.springStiffness must be a non-zero number"),e.console.assert(typeof r.animationTime=="number"&&r.animationTime>=0,"[OpenSeadragon.Spring] options.animationTime must be a number greater than or equal to 0"),r.exponential&&(this._exponential=!0,delete r.exponential),e.extend(!0,this,r),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(r){e.console.assert(!this._exponential||r!==0,"[OpenSeadragon.Spring.resetTo] target must be non-zero for exponential springs"),this.start.value=this.target.value=this.current.value=r,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(r){e.console.assert(!this._exponential||r!==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=r,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(r){this.start.value+=r,this.target.value+=r,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(r){this._exponential=r,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 r,i;if(this._exponential?(r=this.start._logValue,i=this.target._logValue):(r=this.start.value,i=this.target.value),this.current.time>=this.target.time)this.current.value=this.target.value;else{let s=r+(i-r)*t(this.springStiffness,(this.current.time-this.start.time)/(this.target.time-this.start.time));this._exponential?this.current.value=Math.exp(s):this.current.value=s}return this.current.value!==this.target.value},isAtTargetValue:function(){return this.current.value===this.target.value}};function t(r,i){return(1-Math.exp(r*-i))/(1-Math.exp(-r))}})(o),(function(e){e.ImageJob=function(r){e.extend(!0,this,{timeout:e.DEFAULT_SETTINGS.timeout,jobId:null,tries:0},r),this.data=null,this.userData={},this.errorMsg=null},e.ImageJob.prototype={start:function(){this.tries++;var r=this,i=this.abort;this.jobId=window.setTimeout(function(){r.finish(null,null,"Image load exceeded timeout ("+r.timeout+" ms)")},this.timeout),this.abort=function(){r.source.downloadTileAbort(r),typeof i=="function"&&i()},this.source.downloadTileStart(this)},finish:function(r,i,s){this.data=r,this.request=i,this.errorMsg=s,this.jobId&&window.clearTimeout(this.jobId),this.callback(this)}},e.ImageLoader=function(r){e.extend(!0,this,{jobLimit:e.DEFAULT_SETTINGS.imageLoaderLimit,timeout:e.DEFAULT_SETTINGS.timeout,jobQueue:[],failedTiles:[],jobsInProgress:0},r)},e.ImageLoader.prototype={addJob:function(r){if(!r.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;r.source={downloadTileStart:i.downloadTileStart,downloadTileAbort:i.downloadTileAbort}}var s=this,l=function(h){t(s,h,r.callback)},a={src:r.src,tile:r.tile||{},source:r.source,loadWithAjax:r.loadWithAjax,ajaxHeaders:r.loadWithAjax?r.ajaxHeaders:null,crossOriginPolicy:r.crossOriginPolicy,ajaxWithCredentials:r.ajaxWithCredentials,postData:r.postData,callback:l,abort:r.abort,timeout:this.timeout},u=new e.ImageJob(a);!this.jobLimit||this.jobsInProgress<this.jobLimit?(u.start(),this.jobsInProgress++):this.jobQueue.push(u)},clear:function(){for(var r=0;r<this.jobQueue.length;r++){var i=this.jobQueue[r];typeof i.abort=="function"&&i.abort()}this.jobQueue=[]}};function t(r,i,s){i.errorMsg!==""&&(i.data===null||i.data===void 0)&&i.tries<1+r.tileRetryMax&&r.failedTiles.push(i);var l;r.jobsInProgress--,(!r.jobLimit||r.jobsInProgress<r.jobLimit)&&r.jobQueue.length>0&&(l=r.jobQueue.shift(),l.start(),r.jobsInProgress++),r.tileRetryMax>0&&r.jobQueue.length===0&&(!r.jobLimit||r.jobsInProgress<r.jobLimit)&&r.failedTiles.length>0&&(l=r.failedTiles.shift(),setTimeout(function(){l.start()},r.tileRetryDelay),r.jobsInProgress++),s(i.data,i.errorMsg,i.request)}})(o),(function(e){e.Tile=function(t,r,i,s,l,a,u,h,c,d,m,v){this.level=t,this.x=r,this.y=i,this.bounds=s,this.positionedBounds=new o.Rect(s.x,s.y,s.width,s.height),this.sourceBounds=d,this.exists=l,this._url=a,this.postData=m,this.context2D=u,this.loadWithAjax=h,this.ajaxHeaders=c,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,r,i,a,c,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,r,i){var s=Math.max(1,Math.ceil((i.x-r.x)/2)),l=Math.max(1,Math.ceil((i.y-r.y)/2));return new e.Point(s,l).minus(this.position.times(e.pixelDensityRatio).times(t||1).apply(function(a){return a%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}}})(o),(function(e){e.OverlayPlacement=e.Placement,e.OverlayRotationMode=e.freezeObject({NO_ROTATION:1,EXACT:2,BOUNDING_BOX:3}),e.Overlay=function(t,r,i){var s;e.isPlainObject(t)?s=t:s={element:t,location:r,placement:i},this.elementWrapper=document.createElement("div"),this.element=s.element,this.elementWrapper.appendChild(this.element),this.element.id?this.elementWrapper.id="overlay-wrapper-"+this.element.id:this.elementWrapper.id="overlay-wrapper",this.style=this.elementWrapper.style,this._init(s)},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,r){var i=e.Placement.properties[this.placement];i&&(i.isHorizontallyCentered?t.x-=r.x/2:i.isRight&&(t.x-=r.x),i.isVerticallyCentered?t.y-=r.y/2:i.isBottom&&(t.y-=r.y))},destroy:function(){var t=this.elementWrapper,r=this.style;t.parentNode&&(t.parentNode.removeChild(t),t.prevElementParent&&(r.display="none",document.body.appendChild(t))),this.onDraw=null,r.top="",r.left="",r.position="",this.width!==null&&(r.width=""),this.height!==null&&(r.height="");var i=e.getCssPropertyWithVendorPrefix("transformOrigin"),s=e.getCssPropertyWithVendorPrefix("transform");i&&s&&(r[i]="",r[s]="")},drawHTML:function(t,r){var i=this.elementWrapper;i.parentNode!==t&&(i.prevElementParent=i.parentNode,i.prevNextSibling=i.nextSibling,t.appendChild(i),this.style.position="absolute",this.size=e.getElementSize(this.elementWrapper));var s=this._getOverlayPositionAndSize(r),l=s.position,a=this.size=s.size,u="";r.overlayPreserveContentDirection&&(u=r.flipped?" scaleX(-1)":" scaleX(1)");var h=r.flipped?-s.rotate:s.rotate,c=r.flipped?" scaleX(-1)":"";if(this.onDraw)this.onDraw(l,a,this.element);else{var d=this.style,m=this.element.style;m.display="block",d.left=l.x+"px",d.top=l.y+"px",this.width!==null&&(m.width=a.x+"px"),this.height!==null&&(m.height=a.y+"px");var v=e.getCssPropertyWithVendorPrefix("transformOrigin"),y=e.getCssPropertyWithVendorPrefix("transform");v&&y&&(h&&!r.flipped?(m[y]="",d[v]=this._getTransformOrigin(),d[y]="rotate("+h+"deg)"):!h&&r.flipped?(m[y]=u,d[v]=this._getTransformOrigin(),d[y]=c):h&&r.flipped?(m[y]=u,d[v]=this._getTransformOrigin(),d[y]="rotate("+h+"deg)"+c):(m[y]="",d[v]="",d[y]="")),d.display="flex"}},_getOverlayPositionAndSize:function(t){var r=t.pixelFromPoint(this.location,!0),i=this._getSizeInPixels(t);this.adjust(r,i);var s=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 l=new e.Rect(r.x,r.y,i.x,i.y),a=this._getBoundingBox(l,t.getRotation(!0));r=a.getTopLeft(),i=a.getSize()}else s=t.getRotation(!0);return t.flipped&&(r.x=t.getContainerSize().x-r.x),{position:r,size:i,rotate:s}},_getSizeInPixels:function(t){var r=this.size.x,i=this.size.y;if(this.width!==null||this.height!==null){var s=t.deltaPixelsFromPointsNoRotate(new e.Point(this.width||0,this.height||0),!0);this.width!==null&&(r=s.x),this.height!==null&&(i=s.y)}if(this.checkResize&&(this.width===null||this.height===null)){var l=this.size=e.getElementSize(this.elementWrapper);this.width===null&&(r=l.x),this.height===null&&(i=l.y)}return new e.Point(r,i)},_getBoundingBox:function(t,r){var i=this._getPlacementPoint(t);return t.rotate(r,i).getBoundingBox()},_getPlacementPoint:function(t){var r=new e.Point(t.x,t.y),i=e.Placement.properties[this.placement];return i&&(i.isHorizontallyCentered?r.x+=t.width/2:i.isRight&&(r.x+=t.width),i.isVerticallyCentered?r.y+=t.height/2:i.isBottom&&(r.y+=t.height)),r},_getTransformOrigin:function(){var t="",r=e.Placement.properties[this.placement];return r&&(r.isLeft?t="left":r.isRight&&(t="right"),r.isTop?t+=" top":r.isBottom&&(t+=" bottom")),t},update:function(t,r){var i=e.isPlainObject(t)?t:{location:t,placement:r};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 r=this.width,i=this.height;if(r===null||i===null){var s=t.deltaPointsFromPixelsNoRotate(this.size,!0);r===null&&(r=s.x),i===null&&(i=s.y)}var l=this.location.clone();return this.adjust(l,new e.Point(r,i)),this._adjustBoundsForRotation(t,new e.Rect(l.x,l.y,r,i))},_adjustBoundsForRotation:function(t,r){if(!t||t.getRotation(!0)===0||this.rotationMode===e.OverlayRotationMode.EXACT)return r;if(this.rotationMode===e.OverlayRotationMode.BOUNDING_BOX){if(this.width===null||this.height===null)return r;var i=this._getOverlayPositionAndSize(t);return t.viewerElementToViewportRectangle(new e.Rect(i.position.x,i.position.y,i.size.x,i.size.y))}return r.rotate(-t.getRotation(!0),this._getPlacementPoint(r))}}})(o),(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 s=this.viewport.pixelFromPointNoRotate(i.getTopLeft(),!0),l=this.viewport.deltaPixelsFromPointsNoRotate(i.getSize(),!0);return new e.Rect(s.x*e.pixelDensityRatio,s.y*e.pixelDensityRatio,l.x*e.pixelDensityRatio,l.y*e.pixelDensityRatio)}viewportCoordToDrawerCoord(i){var s=this.viewport.pixelFromPointNoRotate(i,!0);return new e.Point(s.x*e.pixelDensityRatio,s.y*e.pixelDensityRatio)}_calculateCanvasSize(){var i=e.pixelDensityRatio,s=this.viewport.getContainerSize();return new t.Point(Math.round(s.x*i),Math.round(s.y*i))}_raiseTiledImageDrawnEvent(i,s){this.viewer&&this.viewer.raiseEvent("tiled-image-drawn",{tiledImage:i,tiles:s})}_raiseDrawerErrorEvent(i,s){this.viewer&&this.viewer.raiseEvent("drawer-error",{tiledImage:i,drawer:this,error:s})}}})(o),(function(e){const t=e;class r extends t.DrawerBase{constructor(s){super(s),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(s){return!0}_createDrawingElement(){return e.makeNeutralElement("div")}draw(s){var l=this;this._prepareNewFrame(),s.forEach(function(a){a.opacity!==0&&l._drawTiles(a)})}canRotate(){return!1}destroy(){this.container.removeChild(this.canvas)}setImageSmoothingEnabled(){}_prepareNewFrame(){this.canvas.innerHTML=""}_drawTiles(s){var l=s.getTilesToDraw().map(h=>h.tile);if(!(s.opacity===0||l.length===0&&!s.placeholderFillStyle))for(var a=l.length-1;a>=0;a--){var u=l[a];this._drawTile(u),this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:s,tile:u})}}_drawTile(s){e.console.assert(s,"[Drawer._drawTile] tile is required");let l=this.canvas;if(!s.cacheImageRecord){e.console.warn("[Drawer._drawTileToHTML] attempting to draw tile %s when it's not cached",s.toString());return}if(!s.loaded){e.console.warn("Attempting to draw tile %s when it's not yet loaded.",s.toString());return}if(!s.element){var a=s.getImage();if(!a)return;s.element=e.makeNeutralElement("div"),s.imgElement=a.cloneNode(),s.imgElement.style.msInterpolationMode="nearest-neighbor",s.imgElement.style.width="100%",s.imgElement.style.height="100%",s.style=s.element.style,s.style.position="absolute"}s.element.parentNode!==l&&l.appendChild(s.element),s.imgElement.parentNode!==s.element&&s.element.appendChild(s.imgElement),s.style.top=s.position.y+"px",s.style.left=s.position.x+"px",s.style.height=s.size.y+"px",s.style.width=s.size.x+"px",s.flipped&&(s.style.transform="scaleX(-1)"),e.setElementOpacity(s.element,s.opacity)}}e.HTMLDrawer=r})(o),(function(e){const t=e;class r extends t.DrawerBase{constructor(h){super(h),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 h=e.makeNeutralElement("canvas"),c=this._calculateCanvasSize();return h.width=c.x,h.height=c.y,h}draw(h){this._prepareNewFrame(),this.viewer.viewport.getFlip()!==this._viewportFlipped&&this._flip();for(const c of h)c.opacity!==0&&this._drawTiles(c)}canRotate(){return!0}destroy(){this.canvas.width=1,this.canvas.height=1,this.sketchCanvas=null,this.sketchContext=null,this.container.removeChild(this.canvas)}minimumOverlapRequired(h){return!0}setImageSmoothingEnabled(h){this._imageSmoothingEnabled=!!h,this._updateImageSmoothingEnabled(this.context),this.viewer.forceRedraw()}drawDebuggingRect(h){var c=this.context;c.save(),c.lineWidth=2*e.pixelDensityRatio,c.strokeStyle=this.debugGridColor[0],c.fillStyle=this.debugGridColor[0],c.strokeRect(h.x*e.pixelDensityRatio,h.y*e.pixelDensityRatio,h.width*e.pixelDensityRatio,h.height*e.pixelDensityRatio),c.restore()}get _viewportFlipped(){return this.context.getTransform().a<0}_raiseTileDrawingEvent(h,c,d,m){this.viewer.raiseEvent("tile-drawing",{tiledImage:h,context:c,tile:d,rendered:m})}_prepareNewFrame(){var h=this._calculateCanvasSize();if((this.canvas.width!==h.x||this.canvas.height!==h.y)&&(this.canvas.width=h.x,this.canvas.height=h.y,this._updateImageSmoothingEnabled(this.context),this.sketchCanvas!==null)){var c=this._calculateSketchCanvasSize();this.sketchCanvas.width=c.x,this.sketchCanvas.height=c.y,this._updateImageSmoothingEnabled(this.sketchContext)}this._clear()}_clear(h,c){var d=this._getContext(h);if(c)d.clearRect(c.x,c.y,c.width,c.height);else{var m=d.canvas;d.clearRect(0,0,m.width,m.height)}}_drawTiles(h){var c=h.getTilesToDraw().map(Z=>Z.tile);if(!(h.opacity===0||c.length===0&&!h.placeholderFillStyle)){var d=c[0],m;d&&(m=h.opacity<1||h.compositeOperation&&h.compositeOperation!=="source-over"||!h._isBottomItem()&&h.source.hasTransparency(d.context2D,d.getUrl(),d.ajaxHeaders,d.postData));var v,y,_=this.viewport.getZoom(!0),E=h.viewportToImageZoom(_);c.length>1&&E>h.smoothTileEdgesMinZoom&&!h.iOSDevice&&h.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(h.getClippedBounds(!0)).getIntegerBoundingBox(),S=S.times(e.pixelDensityRatio)),this._clear(!0,S)),v||this._setRotations(h,m);var P=!1;if(h._clip){this._saveContext(m);var L=h.imageToViewportRectangle(h._clip,!0);L=L.rotate(-h.getRotation(!0),h._getRotationPoint(!0));var F=this.viewportToDrawerRectangle(L);v&&(F=F.times(v)),y&&(F=F.translate(y)),this._setClip(F,m),P=!0}if(h._croppingPolygons){var H=this;P||this._saveContext(m);try{var B=h._croppingPolygons.map(function(Z){return Z.map(function(ie){var he=h.imageToViewportCoordinates(ie.x,ie.y,!0).rotate(-h.getRotation(!0),h._getRotationPoint(!0)),pe=H.viewportCoordToDrawerCoord(he);return v&&(pe=pe.times(v)),y&&(pe=pe.plus(y)),pe})});this._clipWithPolygons(B,m)}catch(Z){e.console.error(Z)}P=!0}if(h._hasOpaqueTile=!1,h.placeholderFillStyle&&h._hasOpaqueTile===!1){let Z=this.viewportToDrawerRectangle(h.getBoundsNoRotate(!0));v&&(Z=Z.times(v)),y&&(Z=Z.translate(y));let ie=null;typeof h.placeholderFillStyle=="function"?ie=h.placeholderFillStyle(h,this.context):ie=h.placeholderFillStyle,this._drawRectangle(Z,ie,m)}var V=a(h.subPixelRoundingForTransparency),Y=!1;if(V===e.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS)Y=!0;else if(V===e.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST){var J=this.viewer&&this.viewer.isAnimating();Y=!J}for(var re=0;re<c.length;re++)d=c[re],this._drawTile(d,h,m,v,y,Y,h.source),this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:h,tile:d});P&&this._restoreContext(m),v||(h.getRotation(!0)%360!==0&&this._restoreRotationChanges(m),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(m)),m&&(v&&this._setRotations(h),this.blendSketch({opacity:h.opacity,scale:v,translate:y,compositeOperation:h.compositeOperation,bounds:S}),v&&(h.getRotation(!0)%360!==0&&this._restoreRotationChanges(!1),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(!1))),this._drawDebugInfo(h,c),this._raiseTiledImageDrawnEvent(h,c)}}_drawDebugInfo(h,c){if(h.debugMode)for(var d=c.length-1;d>=0;d--){var m=c[d];try{this._drawDebugInfoOnTile(m,c.length,d,h)}catch(v){e.console.error(v)}}}_clipWithPolygons(h,c){var d=this._getContext(c);d.beginPath();for(const m of h)for(const[v,y]of m.entries())d[v===0?"moveTo":"lineTo"](y.x,y.y);d.clip()}_drawTile(h,c,d,m,v,y,_){e.console.assert(h,"[Drawer._drawTile] tile is required"),e.console.assert(c,"[Drawer._drawTile] drawingHandler is required");var E=this._getContext(d);m=m||1,this._drawTileToCanvas(h,E,c,m,v,y,_)}_drawTileToCanvas(h,c,d,m,v,y,_){var E=h.position.times(e.pixelDensityRatio),S=h.size.times(e.pixelDensityRatio),P;if(!h.context2D&&!h.cacheImageRecord){e.console.warn("[Drawer._drawTileToCanvas] attempting to draw tile %s when it's not cached",h.toString());return}if(P=h.getCanvasContext(),!h.loaded||!P){e.console.warn("Attempting to draw tile %s when it's not yet loaded.",h.toString());return}c.save(),typeof m=="number"&&m!==1&&(E=E.times(m),S=S.times(m)),v instanceof e.Point&&(E=E.plus(v)),c.globalAlpha===1&&h.hasTransparency&&(y&&(E.x=Math.round(E.x),E.y=Math.round(E.y),S.x=Math.round(S.x),S.y=Math.round(S.y)),c.clearRect(E.x,E.y,S.x,S.y)),this._raiseTileDrawingEvent(d,c,h,P);var L,F;h.sourceBounds?(L=Math.min(h.sourceBounds.width,P.canvas.width),F=Math.min(h.sourceBounds.height,P.canvas.height)):(L=P.canvas.width,F=P.canvas.height),c.translate(E.x+S.x/2,0),h.flipped&&c.scale(-1,1),c.drawImage(P.canvas,0,0,L,F,-S.x/2,E.y,S.x,S.y),c.restore()}_getContext(h){var c=this.context;if(h){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)}c=this.sketchContext}return c}_saveContext(h){this._getContext(h).save()}_restoreContext(h){this._getContext(h).restore()}_setClip(h,c){var d=this._getContext(c);d.beginPath(),d.rect(h.x,h.y,h.width,h.height),d.clip()}_drawRectangle(h,c,d){var m=this._getContext(d);m.save(),m.fillStyle=c,m.fillRect(h.x,h.y,h.width,h.height),m.restore()}blendSketch(h,c,d,m){var v=h;e.isPlainObject(v)||(v={opacity:h,scale:c,translate:d,compositeOperation:m}),h=v.opacity,m=v.compositeOperation;var y=v.bounds;if(this.context.save(),this.context.globalAlpha=h,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{c=v.scale||1,d=v.translate;var _=d instanceof e.Point?d:new e.Point(0,0),E=0,S=0;if(d){var P=this.sketchCanvas.width-this.canvas.width,L=this.sketchCanvas.height-this.canvas.height;E=Math.round(P/2),S=Math.round(L/2)}this.context.drawImage(this.sketchCanvas,_.x-E*c,_.y-S*c,(this.canvas.width+2*E)*c,(this.canvas.height+2*S)*c,-E,-S,this.canvas.width+2*E,this.canvas.height+2*S)}this.context.restore()}_drawDebugInfoOnTile(h,c,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:h.position.plus(h.size.divide(2))}),y.strokeRect(h.position.x*e.pixelDensityRatio,h.position.y*e.pixelDensityRatio,h.size.x*e.pixelDensityRatio,h.size.y*e.pixelDensityRatio);var _=(h.position.x+h.size.x/2)*e.pixelDensityRatio,E=(h.position.y+h.size.y/2)*e.pixelDensityRatio;y.translate(_,E);const S=this.viewport.getRotation(!0);y.rotate(Math.PI/180*-S),y.translate(-_,-E),h.x===0&&h.y===0&&(y.fillText("Zoom: "+this.viewport.getZoom(),h.position.x*e.pixelDensityRatio,(h.position.y-30)*e.pixelDensityRatio),y.fillText("Pan: "+this.viewport.getBounds().toString(),h.position.x*e.pixelDensityRatio,(h.position.y-20)*e.pixelDensityRatio)),y.fillText("Level: "+h.level,(h.position.x+10)*e.pixelDensityRatio,(h.position.y+20)*e.pixelDensityRatio),y.fillText("Column: "+h.x,(h.position.x+10)*e.pixelDensityRatio,(h.position.y+30)*e.pixelDensityRatio),y.fillText("Row: "+h.y,(h.position.x+10)*e.pixelDensityRatio,(h.position.y+40)*e.pixelDensityRatio),y.fillText("Order: "+d+" of "+c,(h.position.x+10)*e.pixelDensityRatio,(h.position.y+50)*e.pixelDensityRatio),y.fillText("Size: "+h.size.toString(),(h.position.x+10)*e.pixelDensityRatio,(h.position.y+60)*e.pixelDensityRatio),y.fillText("Position: "+h.position.toString(),(h.position.x+10)*e.pixelDensityRatio,(h.position.y+70)*e.pixelDensityRatio),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(),m.getRotation(!0)%360!==0&&this._restoreRotationChanges(),y.restore()}_updateImageSmoothingEnabled(h){h.msImageSmoothingEnabled=this._imageSmoothingEnabled,h.imageSmoothingEnabled=this._imageSmoothingEnabled}_getCanvasSize(h){var c=this._getContext(h).canvas;return new e.Point(c.width,c.height)}_getCanvasCenter(){return new e.Point(this.canvas.width/2,this.canvas.height/2)}_setRotations(h,c=!1){var d=!1;this.viewport.getRotation(!0)%360!==0&&(this._offsetForRotation({degrees:this.viewport.getRotation(!0),useSketch:c,saveContext:d}),d=!1),h.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:h.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(h._getRotationPoint(!0),!0),useSketch:c,saveContext:d})}_offsetForRotation(h){var c=h.point?h.point.times(e.pixelDensityRatio):this._getCanvasCenter(),d=this._getContext(h.useSketch);d.save(),d.translate(c.x,c.y),d.rotate(Math.PI/180*h.degrees),d.translate(-c.x,-c.y)}_flip(h){h=h||{};var c=h.point?h.point.times(e.pixelDensityRatio):this._getCanvasCenter(),d=this._getContext(h.useSketch);d.translate(c.x,0),d.scale(-1,1),d.translate(-c.x,0)}_restoreRotationChanges(h){var c=this._getContext(h);c.restore()}_calculateCanvasSize(){var h=e.pixelDensityRatio,c=this.viewport.getContainerSize();return{x:Math.round(c.x*h),y:Math.round(c.y*h)}}_calculateSketchCanvasSize(){var h=this._calculateCanvasSize();if(this.viewport.getRotation()===0)return h;var c=Math.ceil(Math.sqrt(h.x*h.x+h.y*h.y));return{x:c,y:c}}}e.CanvasDrawer=r;var i=e.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER;function s(u){return u!==e.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS&&u!==e.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST&&u!==e.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER}function l(u){return s(u)?i:u}function a(u){if(typeof u=="number")return l(u);if(!u||!e.Browser)return i;var h=u[e.Browser.vendor];return s(h)&&(h=u["*"]),l(h)}})(o),(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._imageSmoothingEnabled=!0,this._boundToTileReady=s=>this._tileReadyHandler(s),this._boundToImageUnloaded=s=>this._imageUnloadedHandler(s),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 s=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS);for(let a=0;a<s;++a)i.activeTexture(i.TEXTURE0+a),i.bindTexture(i.TEXTURE_2D,null),i.bindTexture(i.TEXTURE_CUBE_MAP,null);i.bindBuffer(i.ARRAY_BUFFER,null),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),i.bindRenderbuffer(i.RENDERBUFFER,null),i.bindFramebuffer(i.FRAMEBUFFER,null),this._unloadTextures(),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 l=i.getExtension("WEBGL_lose_context");l&&l.loseContext(),this.viewer.removeHandler("tile-ready",this._boundToTileReady),this.viewer.removeHandler("image-unloaded",this._boundToImageUnloaded),this.viewer.removeHandler("resize",this._resizeHandler),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"),s=e.isFunction(i.getContext)&&i.getContext("webgl"),l=s&&s.getExtension("WEBGL_lose_context");return l&&l.loseContext(),!!s}getType(){return"webgl"}minimumOverlapRequired(i){return i.isTainted()}_createDrawingElement(){let i=e.makeNeutralElement("canvas"),s=this._calculateCanvasSize();return i.width=s.x,i.height=s.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 s=this._gl;const l=this.viewport.getBoundsNoRotateWithMargins(!0);let a={bounds:l,center:new t.Point(l.x+l.width/2,l.y+l.height/2),rotation:this.viewport.getRotation(!0)*Math.PI/180},u=this.viewport.flipped?-1:1,h=e.Mat3.makeTranslation(-a.center.x,-a.center.y),c=e.Mat3.makeScaling(2/a.bounds.width*u,-2/a.bounds.height),d=e.Mat3.makeRotation(-a.rotation),m=c.multiply(d).multiply(h);s.bindFramebuffer(s.FRAMEBUFFER,null),s.clear(s.COLOR_BUFFER_BIT),this._outputContext.clearRect(0,0,this._outputCanvas.width,this._outputCanvas.height);let v=!1;i.forEach((y,_)=>{if(y.isTainted()){v&&(this._outputContext.drawImage(this._renderingCanvas,0,0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.clear(s.COLOR_BUFFER_BIT),v=!1);const E=this._getBackupCanvasDrawer();E.draw([y]),this._outputContext.drawImage(E.canvas,0,0)}else{let E=y.getTilesToDraw();if(y.placeholderFillStyle&&y._hasOpaqueTile===!1&&this._drawPlaceholder(y),E.length===0||y.getOpacity()===0)return;let S=E[0],P=y.compositeOperation||this.viewer.compositeOperation||y._clip||y._croppingPolygons||y.debugMode,L=P||y.opacity<1||S.hasTransparency;P&&(v&&this._outputContext.drawImage(this._renderingCanvas,0,0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.clear(s.COLOR_BUFFER_BIT)),s.useProgram(this._firstPass.shaderProgram),L?(s.bindFramebuffer(s.FRAMEBUFFER,this._glFrameBuffer),s.clear(s.COLOR_BUFFER_BIT)):s.bindFramebuffer(s.FRAMEBUFFER,null);let F=m,H=y.getRotation(!0);if(H%360!==0){let Z=e.Mat3.makeRotation(-H*Math.PI/180),ie=y.getBoundsNoRotate(!0).getCenter(),he=e.Mat3.makeTranslation(ie.x,ie.y),pe=e.Mat3.makeTranslation(-ie.x,-ie.y),ce=he.multiply(Z).multiply(pe);F=m.multiply(ce)}let B=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);if(B<=0)throw new Error(`WegGL error: bad value for gl parameter MAX_TEXTURE_IMAGE_UNITS (${B}). This could happen
|
|
128
|
+
if too many contexts have been created and not released, or there is another problem with the graphics card.`);let V=new Float32Array(B*12),Y=new Array(B),J=new Array(B),re=new Array(B);for(let Z=0;Z<E.length;Z++){let ie=E[Z].tile,he=Z%B,pe=he+1,ce=ie.getCanvasContext(),ve=ce?this._TextureMap.get(ce.canvas):null;if(ve||(this._tileReadyHandler({tile:ie,tiledImage:y}),ve=ce?this._TextureMap.get(ce.canvas):null),ve&&this._getTileData(ie,y,ve,F,he,V,Y,J,re),pe===B||Z===E.length-1){for(let fe=0;fe<=pe;fe++)s.activeTexture(s.TEXTURE0+fe),s.bindTexture(s.TEXTURE_2D,Y[fe]);s.bindBuffer(s.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),s.bufferData(s.ARRAY_BUFFER,V,s.DYNAMIC_DRAW),J.forEach((fe,we)=>{s.uniformMatrix3fv(this._firstPass.uTransformMatrices[we],!1,fe)}),s.uniform1fv(this._firstPass.uOpacities,new Float32Array(re)),s.bindBuffer(s.ARRAY_BUFFER,this._firstPass.bufferOutputPosition),s.vertexAttribPointer(this._firstPass.aOutputPosition,2,s.FLOAT,!1,0,0),s.bindBuffer(s.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),s.vertexAttribPointer(this._firstPass.aTexturePosition,2,s.FLOAT,!1,0,0),s.bindBuffer(s.ARRAY_BUFFER,this._firstPass.bufferIndex),s.vertexAttribPointer(this._firstPass.aIndex,1,s.FLOAT,!1,0,0),s.drawArrays(s.TRIANGLES,0,6*pe)}}L&&(s.useProgram(this._secondPass.shaderProgram),s.bindFramebuffer(s.FRAMEBUFFER,null),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this._renderToTexture),this._gl.uniform1f(this._secondPass.uOpacityMultiplier,y.opacity),s.bindBuffer(s.ARRAY_BUFFER,this._secondPass.bufferTexturePosition),s.vertexAttribPointer(this._secondPass.aTexturePosition,2,s.FLOAT,!1,0,0),s.bindBuffer(s.ARRAY_BUFFER,this._secondPass.bufferOutputPosition),s.vertexAttribPointer(this._secondPass.aOutputPosition,2,s.FLOAT,!1,0,0),s.drawArrays(s.TRIANGLES,0,6)),v=!0,P&&(this._applyContext2dPipeline(y,E,_),v=!1,s.bindFramebuffer(s.FRAMEBUFFER,null),s.clear(s.COLOR_BUFFER_BIT)),_===0&&this._raiseTiledImageDrawnEvent(y,E.map(Z=>Z.tile))}}),v&&this._outputContext.drawImage(this._renderingCanvas,0,0)}setImageSmoothingEnabled(i){this._imageSmoothingEnabled!==i&&(this._imageSmoothingEnabled=i,this._unloadTextures(),this.viewer.world.draw())}drawDebuggingRect(i){let s=this._outputContext;s.save(),s.lineWidth=2*e.pixelDensityRatio,s.strokeStyle=this.debugGridColor[0],s.fillStyle=this.debugGridColor[0],s.strokeRect(i.x*e.pixelDensityRatio,i.y*e.pixelDensityRatio,i.width*e.pixelDensityRatio,i.height*e.pixelDensityRatio),s.restore()}_getTextureDataFromTile(i){return i.getCanvasContext().canvas}_applyContext2dPipeline(i,s,l){if(this._outputContext.save(),this._outputContext.globalCompositeOperation=l===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 a=this.viewer.viewport.getFlip();a&&this._flip(),this._drawDebugInfo(s,i,a),a&&this._flip()}}_getTileData(i,s,l,a,u,h,c,d,m){let v=l.texture,y=l.position;h.set(y,u*12);let _=this._calculateOverlapFraction(i,s),E=i.positionedBounds.width*_.x,S=i.positionedBounds.height*_.y,P=i.positionedBounds.x+(i.x===0?0:E),L=i.positionedBounds.y+(i.y===0?0:S),F=i.positionedBounds.x+i.positionedBounds.width-(i.isRightMost?0:E),H=i.positionedBounds.y+i.positionedBounds.height-(i.isBottomMost?0:S),B=F-P,V=H-L,Y=new e.Mat3([B,0,0,0,V,0,P,L,1]);if(i.flipped){let re=e.Mat3.makeTranslation(.5,0),Z=e.Mat3.makeTranslation(-.5,0),ie=re.multiply(e.Mat3.makeScaling(-1,1)).multiply(Z);Y=Y.multiply(ie)}let J=a.multiply(Y);m[u]=i.opacity,c[u]=v,d[u]=J.values}_textureFilter(){return this._imageSmoothingEnabled?this._gl.LINEAR:this._gl.NEAREST}_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,this._textureFilter()),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),s=()=>[...Array(i).keys()].map(v=>`uniform mat3 u_matrix_${v};`).join(`
|
|
129
|
+
`),l=()=>[...Array(i).keys()].map(v=>`${v>0?"else ":""}if(int(a_index) == ${v}) { transform_matrix = u_matrix_${v}; }`).join(`
|
|
130
|
+
`);const a=`
|
|
131
|
+
attribute vec2 a_output_position;
|
|
132
|
+
attribute vec2 a_texture_position;
|
|
133
|
+
attribute float a_index;
|
|
134
|
+
|
|
135
|
+
${s()} // create a uniform mat3 for each potential tile to draw
|
|
136
|
+
|
|
137
|
+
varying vec2 v_texture_position;
|
|
138
|
+
varying float v_image_index;
|
|
139
|
+
|
|
140
|
+
void main() {
|
|
141
|
+
|
|
142
|
+
mat3 transform_matrix; // value will be set by the if/elses in makeConditional()
|
|
143
|
+
|
|
144
|
+
${l()}
|
|
145
|
+
|
|
146
|
+
gl_Position = vec4(transform_matrix * vec3(a_output_position, 1), 1);
|
|
147
|
+
|
|
148
|
+
v_texture_position = a_texture_position;
|
|
149
|
+
v_image_index = a_index;
|
|
150
|
+
}
|
|
151
|
+
`,u=`
|
|
152
|
+
precision mediump float;
|
|
153
|
+
|
|
154
|
+
// our textures
|
|
155
|
+
uniform sampler2D u_images[${i}];
|
|
156
|
+
// our opacities
|
|
157
|
+
uniform float u_opacities[${i}];
|
|
158
|
+
|
|
159
|
+
// the varyings passed in from the vertex shader.
|
|
160
|
+
varying vec2 v_texture_position;
|
|
161
|
+
varying float v_image_index;
|
|
162
|
+
|
|
163
|
+
void main() {
|
|
164
|
+
// can't index directly with a variable, need to use a loop iterator hack
|
|
165
|
+
for(int i = 0; i < ${i}; ++i){
|
|
166
|
+
if(i == int(v_image_index)){
|
|
167
|
+
gl_FragColor = texture2D(u_images[i], v_texture_position) * u_opacities[i];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
`;let h=this._gl,c=this.constructor.initShaderProgram(h,a,u);h.useProgram(c),this._firstPass={shaderProgram:c,aOutputPosition:h.getAttribLocation(c,"a_output_position"),aTexturePosition:h.getAttribLocation(c,"a_texture_position"),aIndex:h.getAttribLocation(c,"a_index"),uTransformMatrices:[...Array(this._glNumTextures).keys()].map(v=>h.getUniformLocation(c,`u_matrix_${v}`)),uImages:h.getUniformLocation(c,"u_images"),uOpacities:h.getUniformLocation(c,"u_opacities"),bufferOutputPosition:h.createBuffer(),bufferTexturePosition:h.createBuffer(),bufferIndex:h.createBuffer()},h.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);h.bindBuffer(h.ARRAY_BUFFER,this._firstPass.bufferOutputPosition),h.bufferData(h.ARRAY_BUFFER,d,h.STATIC_DRAW),h.enableVertexAttribArray(this._firstPass.aOutputPosition),h.bindBuffer(h.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),h.enableVertexAttribArray(this._firstPass.aTexturePosition),h.bindBuffer(h.ARRAY_BUFFER,this._firstPass.bufferIndex);let m=[...Array(this._glNumTextures).keys()].map(v=>Array(6).fill(v)).flat();h.bufferData(h.ARRAY_BUFFER,new Float32Array(m),h.STATIC_DRAW),h.enableVertexAttribArray(this._firstPass.aIndex)}_makeSecondPassShaderProgram(){const i=`
|
|
172
|
+
attribute vec2 a_output_position;
|
|
173
|
+
attribute vec2 a_texture_position;
|
|
174
|
+
|
|
175
|
+
uniform mat3 u_matrix;
|
|
176
|
+
|
|
177
|
+
varying vec2 v_texture_position;
|
|
178
|
+
|
|
179
|
+
void main() {
|
|
180
|
+
gl_Position = vec4(u_matrix * vec3(a_output_position, 1), 1);
|
|
181
|
+
|
|
182
|
+
v_texture_position = a_texture_position;
|
|
183
|
+
}
|
|
184
|
+
`,s=`
|
|
185
|
+
precision mediump float;
|
|
186
|
+
|
|
187
|
+
// our texture
|
|
188
|
+
uniform sampler2D u_image;
|
|
189
|
+
|
|
190
|
+
// the texCoords passed in from the vertex shader.
|
|
191
|
+
varying vec2 v_texture_position;
|
|
192
|
+
|
|
193
|
+
// the opacity multiplier for the image
|
|
194
|
+
uniform float u_opacity_multiplier;
|
|
195
|
+
|
|
196
|
+
void main() {
|
|
197
|
+
gl_FragColor = texture2D(u_image, v_texture_position);
|
|
198
|
+
gl_FragColor *= u_opacity_multiplier;
|
|
199
|
+
}
|
|
200
|
+
`;let l=this._gl,a=this.constructor.initShaderProgram(l,i,s);l.useProgram(a),this._secondPass={shaderProgram:a,aOutputPosition:l.getAttribLocation(a,"a_output_position"),aTexturePosition:l.getAttribLocation(a,"a_texture_position"),uMatrix:l.getUniformLocation(a,"u_matrix"),uImage:l.getUniformLocation(a,"u_image"),uOpacityMultiplier:l.getUniformLocation(a,"u_opacity_multiplier"),bufferOutputPosition:l.createBuffer(),bufferTexturePosition:l.createBuffer()},l.bindBuffer(l.ARRAY_BUFFER,this._secondPass.bufferOutputPosition),l.bufferData(l.ARRAY_BUFFER,this._unitQuad,l.STATIC_DRAW),l.enableVertexAttribArray(this._secondPass.aOutputPosition),l.bindBuffer(l.ARRAY_BUFFER,this._secondPass.bufferTexturePosition),l.bufferData(l.ARRAY_BUFFER,this._unitQuad,l.DYNAMIC_DRAW),l.enableVertexAttribArray(this._secondPass.aTexturePosition);let u=e.Mat3.makeScaling(2,2).multiply(e.Mat3.makeTranslation(-.5,-.5));l.uniformMatrix3fv(this._secondPass.uMatrix,!1,u.values)}_resizeRenderer(){let i=this._gl,s=this._renderingCanvas.width,l=this._renderingCanvas.height;i.viewport(0,0,s,l),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,s,l,0,i.RGBA,i.UNSIGNED_BYTE,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this._textureFilter()),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._resizeHandler=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 s=i._calculateCanvasSize();(i._outputCanvas.width!==s.x||i._outputCanvas.height!==s.y)&&(i._outputCanvas.width=s.x,i._outputCanvas.height=s.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()},this.viewer.addHandler("resize",this._resizeHandler)}_makeQuadVertexBuffer(i,s,l,a){return new Float32Array([i,a,s,a,i,l,i,l,s,a,s,l])}_tileReadyHandler(i){let s=i.tile,l=i.tiledImage;if(l.isTainted())return;let a=s.getCanvasContext(),u=a&&a.canvas;if(!u||e.isCanvasTainted(u)){l.isTainted()||(l.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(l,"Tainted data cannot be used by the WebGLDrawer. Falling back to CanvasDrawer for this TiledImage."));return}if(!this._TextureMap.get(u)){let c=this._gl,d=c.createTexture(),m,v=l.source.tileOverlap,y,_;if(s.sourceBounds?(y=Math.min(s.sourceBounds.width,u.width)/u.width,_=Math.min(s.sourceBounds.height,u.height)/u.height):(y=1,_=1),v>0){let S=this._calculateOverlapFraction(s,l),P=(s.x===0?0:S.x)*y,L=(s.y===0?0:S.y)*_,F=(s.isRightMost?1:1-S.x)*y,H=(s.isBottomMost?1:1-S.y)*_;m=this._makeQuadVertexBuffer(P,F,L,H)}else y===1&&_===1?m=this._unitQuad:m=this._makeQuadVertexBuffer(0,y,0,_);let E={texture:d,position:m};this._TextureMap.set(u,E),c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,d),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,this._textureFilter()),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,this._textureFilter()),this._uploadImageData(a)}}_calculateOverlapFraction(i,s){let l=s.source.tileOverlap,a=i.sourceBounds.width,u=i.sourceBounds.height,h=(i.x===0?0:l)+(i.isRightMost?0:l),c=(i.y===0?0:l)+(i.isBottomMost?0:l),d=l/(a+h),m=l/(u+c);return{x:d,y:m}}_unloadTextures(){Array.from(this._TextureMap.keys()).forEach(s=>{this._cleanupImageData(s)})}_uploadImageData(i){let s=this._gl,l=i.canvas;try{if(!l)throw i;s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,l)}catch(a){e.console.error("Error uploading image data to WebGL",a)}}_imageUnloadedHandler(i){let s=i.context2D.canvas;this._cleanupImageData(s)}_cleanupImageData(i){let s=this._TextureMap.get(i);this._TextureMap.delete(i),s&&this._gl.deleteTexture(s.texture)}_setClip(){}_renderToClippingCanvas(i){if(this._clippingContext.clearRect(0,0,this._clippingCanvas.width,this._clippingCanvas.height),this._clippingContext.save(),this.viewer.viewport.getFlip()){const s=new e.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(s.x,0),this._clippingContext.scale(-1,1),this._clippingContext.translate(-s.x,0)}if(i._clip){let l=[{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(a=>{let u=i.imageToViewportCoordinates(a.x,a.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(u)});this._clippingContext.beginPath(),l.forEach((a,u)=>{this._clippingContext[u===0?"moveTo":"lineTo"](a.x,a.y)}),this._clippingContext.clip(),this._setClip()}if(i._croppingPolygons){let s=i._croppingPolygons.map(l=>l.map(a=>{let u=i.imageToViewportCoordinates(a.x,a.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(u)}));this._clippingContext.beginPath(),s.forEach(l=>{l.forEach((a,u)=>{this._clippingContext[u===0?"moveTo":"lineTo"](a.x,a.y)})}),this._clippingContext.clip()}if(this.viewer.viewport.getFlip()){const s=new e.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(s.x,0),this._clippingContext.scale(-1,1),this._clippingContext.translate(-s.x,0)}this._clippingContext.drawImage(this._renderingCanvas,0,0),this._clippingContext.restore()}_setRotations(i){var s=!1;this.viewport.getRotation(!0)%360!==0&&(this._offsetForRotation({degrees:this.viewport.getRotation(!0),saveContext:s}),s=!1),i.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:i.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(i._getRotationPoint(!0),!0),saveContext:s})}_offsetForRotation(i){var s=i.point?i.point.times(e.pixelDensityRatio):this._getCanvasCenter(),l=this._outputContext;l.save(),l.translate(s.x,s.y),l.rotate(Math.PI/180*i.degrees),l.translate(-s.x,-s.y)}_flip(i){i=i||{};var s=i.point?i.point.times(e.pixelDensityRatio):this._getCanvasCenter(),l=this._outputContext;l.translate(s.x,0),l.scale(-1,1),l.translate(-s.x,0)}_drawDebugInfo(i,s,l){for(var a=i.length-1;a>=0;a--){var u=i[a].tile;try{this._drawDebugInfoOnTile(u,i.length,a,s,l)}catch(h){e.console.error(h)}}}_drawDebugInfoOnTile(i,s,l,a,u){var h=this.viewer.world.getIndexOfItem(a)%this.debugGridColor.length,c=this.context;c.save(),c.lineWidth=2*e.pixelDensityRatio,c.font="small-caps bold "+13*e.pixelDensityRatio+"px arial",c.strokeStyle=this.debugGridColor[h],c.fillStyle=this.debugGridColor[h],this._setRotations(a),u&&this._flip({point:i.position.plus(i.size.divide(2))}),c.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;c.translate(d,m);const v=this.viewport.getRotation(!0);c.rotate(Math.PI/180*-v),c.translate(-d,-m),i.x===0&&i.y===0&&(c.fillText("Zoom: "+this.viewport.getZoom(),i.position.x*e.pixelDensityRatio,(i.position.y-30)*e.pixelDensityRatio),c.fillText("Pan: "+this.viewport.getBounds().toString(),i.position.x*e.pixelDensityRatio,(i.position.y-20)*e.pixelDensityRatio)),c.fillText("Level: "+i.level,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+20)*e.pixelDensityRatio),c.fillText("Column: "+i.x,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+30)*e.pixelDensityRatio),c.fillText("Row: "+i.y,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+40)*e.pixelDensityRatio),c.fillText("Order: "+l+" of "+s,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+50)*e.pixelDensityRatio),c.fillText("Size: "+i.size.toString(),(i.position.x+10)*e.pixelDensityRatio,(i.position.y+60)*e.pixelDensityRatio),c.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(),a.getRotation(!0)%360!==0&&this._restoreRotationChanges(),c.restore()}_drawPlaceholder(i){const s=i.getBounds(!0),l=this.viewportToDrawerRectangle(i.getBounds(!0)),a=this._outputContext;let u;typeof i.placeholderFillStyle=="function"?u=i.placeholderFillStyle(i,a):u=i.placeholderFillStyle,this._offsetForRotation({degrees:this.viewer.viewport.getRotation(!0)}),a.fillStyle=u,a.translate(l.x,l.y),a.rotate(Math.PI/180*s.degrees),a.translate(-l.x,-l.y),a.fillRect(l.x,l.y,l.width,l.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,s,l){function a(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 u=a(i,i.VERTEX_SHADER,s),h=a(i,i.FRAGMENT_SHADER,l),c=i.createProgram();return i.attachShader(c,u),i.attachShader(c,h),i.linkProgram(c),i.getProgramParameter(c,i.LINK_STATUS)?c:(e.console.error(`Unable to initialize the shader program: ${i.getProgramInfoLog(c)}`),null)}}})(o),(function(e){e.Viewport=function(t){var r=arguments;r.length&&r[0]instanceof e.Point&&(t={containerSize:r[0],contentSize:r[1],config:r[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,r){e.console.error("[Viewport.setHomeBounds] this function is deprecated; The content bounds should not be set manually."),this._setContentBounds(t,r)},_setContentBounds:function(t,r){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(r),this._contentBounds=t.rotate(this.getRotation()).getBoundingBox(),this._contentSize=this._contentBounds.getSize().times(r),this._contentAspectRatio=this._contentSize.x/this._contentSize.y,this.viewer&&this.viewer.raiseEvent("reset-size",{contentSize:this._contentSizeNoRotate.clone(),contentFactor:r,homeBounds:this._contentBoundsNoRotate.clone(),contentBounds:this._contentBounds.clone()})},getHomeZoom:function(){if(this.defaultZoomLevel)return this.defaultZoomLevel;var t=this._contentAspectRatio/this.getAspectRatio(),r;return this.homeFillsViewer?r=t>=1?t:1:r=t>=1?1:t,r/this._contentBounds.width},getHomeBounds:function(){return this.getHomeBoundsNoRotate().rotate(-this.getRotation())},getHomeBoundsNoRotate:function(){var t=this._contentBounds.getCenter(),r=1/this.getHomeZoom(),i=r/this.getAspectRatio();return new e.Rect(t.x-r/2,t.y-i/2,r,i)},goHome:function(t){return this.viewer&&this.viewer.raiseEvent("home",{immediately:t}),this.fitBounds(this.getHomeBounds(),t)},getMinZoom:function(){var t=this.getHomeZoom(),r=this.minZoomLevel?this.minZoomLevel:this.minZoomImageRatio*t;return r},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 r=this.getCenter(t),i=1/this.getZoom(t),s=i/this.getAspectRatio();return new e.Rect(r.x-i/2,r.y-s/2,i,s)},getBoundsWithMargins:function(t){return this.getBoundsNoRotateWithMargins(t).rotate(-this.getRotation(t),this.getCenter(t))},getBoundsNoRotateWithMargins:function(t){var r=this.getBoundsNoRotate(t),i=this._containerInnerSize.x*this.getZoom(t);return r.x-=this._margins.left/i,r.y-=this._margins.top/i,r.width+=(this._margins.left+this._margins.right)/i,r.height+=(this._margins.top+this._margins.bottom)/i,r},getCenter:function(t){var r=new e.Point(this.centerSpringX.current.value,this.centerSpringY.current.value),i=new e.Point(this.centerSpringX.target.value,this.centerSpringY.target.value),s,l,a,u,h,c,d,m;return t?r:this.zoomPoint?(s=this.pixelFromPoint(this.zoomPoint,!0),l=this.getZoom(),a=1/l,u=a/this.getAspectRatio(),h=new e.Rect(r.x-a/2,r.y-u/2,a,u),c=this._pixelFromPoint(this.zoomPoint,h),d=c.minus(s).rotate(-this.getRotation(!0)),m=d.divide(this._containerInnerSize.x*l),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 r=this.viewportToViewerElementRectangle(t).getBoundingBox(),i=this.viewportToViewerElementRectangle(this._contentBoundsNoRotate).getBoundingBox(),s=!1,l=!1;if(!this.wrapHorizontal){var a=r.x+r.width,u=i.x+i.width,h,c,d;r.width>i.width?h=this.visibilityRatio*i.width:h=this.visibilityRatio*r.width,c=i.x-a+h,d=u-r.x-h,h>i.width?(r.x+=(c+d)/2,s=!0):d<0?(r.x+=d,s=!0):c>0&&(r.x+=c,s=!0)}if(!this.wrapVertical){var m=r.y+r.height,v=i.y+i.height,y,_,E;r.height>i.height?y=this.visibilityRatio*i.height:y=this.visibilityRatio*r.height,_=i.y-m+y,E=v-r.y-y,y>i.height?(r.y+=(_+E)/2,l=!0):E<0?(r.y+=E,l=!0):_>0&&(r.y+=_,l=!0)}var S=s||l,P=S?this.viewerElementToViewportRectangle(r):t.clone();return P.xConstrained=s,P.yConstrained=l,P.constraintApplied=S,P},_raiseConstraintsEvent:function(t){this.viewer&&this.viewer.raiseEvent("constrain",{immediately:t})},applyConstraints:function(t){var r=this.getZoom(),i=this._applyZoomConstraints(r);r!==i&&this.zoomTo(i,this.zoomPoint,t);var s=this.getConstrainedBounds(!1);return s.constraintApplied&&(this.fitBounds(s,t),this._raiseConstraintsEvent(t)),this},ensureVisible:function(t){return this.applyConstraints(t)},_fitBounds:function(t,r){r=r||{};var i=r.immediately||!1,s=r.constraints||!1,l=this.getAspectRatio(),a=t.getCenter(),u=new e.Rect(t.x,t.y,t.width,t.height,t.degrees+this.getRotation()).getBoundingBox();u.getAspectRatio()>=l?u.height=u.width/l:u.width=u.height*l,u.x=a.x-u.width/2,u.y=a.y-u.height/2;var h=1/u.width;if(i)return this.panTo(a,!0),this.zoomTo(h,null,!0),s&&this.applyConstraints(!0),this;var c=this.getCenter(!0),d=this.getZoom(!0);this.panTo(c,!0),this.zoomTo(d,null,!0);var m=this.getBounds(),v=this.getZoom();if(v===0||Math.abs(h/v-1)<1e-8)return this.zoomTo(h,null,!0),this.panTo(a,i),s&&this.applyConstraints(!1),this;if(s){this.panTo(a,!1),h=this._applyZoomConstraints(h),this.zoomTo(h,null,!1);var y=this.getConstrainedBounds();this.panTo(c,!0),this.zoomTo(d,null,!0),this.fitBounds(y)}else{var _=u.rotate(-this.getRotation()),E=_.getTopLeft().times(h).minus(m.getTopLeft().times(v)).divide(h-v);this.zoomTo(h,E,i)}return this},fitBounds:function(t,r){return this._fitBounds(t,{immediately:r,constraints:!1})},fitBoundsWithConstraints:function(t,r){return this._fitBounds(t,{immediately:r,constraints:!0})},fitVertically:function(t){var r=new e.Rect(this._contentBounds.x+this._contentBounds.width/2,this._contentBounds.y,0,this._contentBounds.height);return this.fitBounds(r,t)},fitHorizontally:function(t){var r=new e.Rect(this._contentBounds.x,this._contentBounds.y+this._contentBounds.height/2,this._contentBounds.width,0);return this.fitBounds(r,t)},getConstrainedBounds:function(t){var r,i;return r=this.getBounds(t),i=this._applyBoundaryConstraints(r),i},panBy:function(t,r){var i=new e.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return this.panTo(i.plus(t),r)},panTo:function(t,r){return r?(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:r}),this},zoomBy:function(t,r,i){return this.zoomTo(this.zoomSpring.target.value*t,r,i)},zoomTo:function(t,r,i){var s=this;return this.zoomPoint=r instanceof e.Point&&!isNaN(r.x)&&!isNaN(r.y)?r:null,i?this._adjustCenterSpringsForZoomPoint(function(){s.zoomSpring.resetTo(t)}):this.zoomSpring.springTo(t),this.viewer&&this.viewer.raiseEvent("zoom",{zoom:t,refPoint:r,immediately:i}),this},setRotation:function(t,r){return this.rotateTo(t,null,r)},getRotation:function(t){return t?this.degreesSpring.current.value:this.degreesSpring.target.value},setRotationWithPivot:function(t,r,i){return this.rotateTo(t,r,i)},rotateTo:function(t,r,i){if(!this.viewer||!this.viewer.drawer.canRotate())return this;if(this.degreesSpring.target.value===t&&this.degreesSpring.isAtTargetValue())return this;if(this.rotationPivot=r instanceof e.Point&&!isNaN(r.x)&&!isNaN(r.y)?r:null,i)if(this.rotationPivot){var s=t-this._oldDegrees;if(!s)return this.rotationPivot=null,this;this._rotateAboutPivot(t)}else this.degreesSpring.resetTo(t);else{var l=e.positiveModulo(this.degreesSpring.current.value,360),a=e.positiveModulo(t,360),u=a-l;u>180?a-=360:u<-180&&(a+=360);var h=l-a;this.degreesSpring.resetTo(t+h),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,r,i){return this.rotateTo(this.degreesSpring.target.value+t,r,i)},resize:function(t,r){var i=this.getBoundsNoRotate(),s=i,l;this.containerSize.x=t.x,this.containerSize.y=t.y,this._updateContainerInnerSize(),r&&(l=t.x/this.containerSize.x,s.width=i.width*l,s.height=s.width/this.getAspectRatio()),this.viewer&&this.viewer.raiseEvent("resize",{newContainerSize:t,maintain:r});var a=this.fitBounds(s,!0);return this.viewer&&this.viewer.raiseEvent("after-resize",{newContainerSize:t,maintain:r}),a},_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 r=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=r||!this.zoomSpring.isAtTargetValue()||!this.centerSpringX.isAtTargetValue()||!this.centerSpringY.isAtTargetValue()||!this.degreesSpring.isAtTargetValue();return i},_rotateAboutPivot:function(t){var r=t===!0,i=this.rotationPivot.minus(this.getCenter());this.centerSpringX.shiftBy(i.x),this.centerSpringY.shiftBy(i.y),r?this.degreesSpring.update():this.degreesSpring.resetTo(t);var s=this.degreesSpring.current.value-this._oldDegrees,l=i.rotate(s*-1).times(-1);this.centerSpringX.shiftBy(l.x),this.centerSpringY.shiftBy(l.y)},_adjustCenterSpringsForZoomPoint:function(t){if(this.zoomPoint){var r=this.pixelFromPoint(this.zoomPoint,!0);t();var i=this.pixelFromPoint(this.zoomPoint,!0),s=i.minus(r),l=this.deltaPointsFromPixels(s,!0);this.centerSpringX.shiftBy(l.x),this.centerSpringY.shiftBy(l.y),this.zoomSpring.isAtTargetValue()&&(this.zoomPoint=null)}else t()},deltaPixelsFromPointsNoRotate:function(t,r){return t.times(this._containerInnerSize.x*this.getZoom(r))},deltaPixelsFromPoints:function(t,r){return this.deltaPixelsFromPointsNoRotate(t.rotate(this.getRotation(r)),r)},deltaPointsFromPixelsNoRotate:function(t,r){return t.divide(this._containerInnerSize.x*this.getZoom(r))},deltaPointsFromPixels:function(t,r){return this.deltaPointsFromPixelsNoRotate(t,r).rotate(-this.getRotation(r))},pixelFromPointNoRotate:function(t,r){return this._pixelFromPointNoRotate(t,this.getBoundsNoRotate(r))},pixelFromPoint:function(t,r){return this._pixelFromPoint(t,this.getBoundsNoRotate(r))},_pixelFromPointNoRotate:function(t,r){return t.minus(r.getTopLeft()).times(this._containerInnerSize.x/r.width).plus(new e.Point(this._margins.left,this._margins.top))},_pixelFromPoint:function(t,r){return this._pixelFromPointNoRotate(t.rotate(this.getRotation(!0),this.getCenter(!0)),r)},pointFromPixelNoRotate:function(t,r){var i=this.getBoundsNoRotate(r);return t.minus(new e.Point(this._margins.left,this._margins.top)).divide(this._containerInnerSize.x/i.width).plus(i.getTopLeft())},pointFromPixel:function(t,r){return this.pointFromPixelNoRotate(t,r).rotate(-this.getRotation(r),this.getCenter(r))},_viewportToImageDelta:function(t,r){var i=this._contentBoundsNoRotate.width;return new e.Point(t*this._contentSizeNoRotate.x/i,r*this._contentSizeNoRotate.x/i)},viewportToImageCoordinates:function(t,r){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 s=this.viewer.world.getItemAt(0);return s.viewportToImageCoordinates(t,r,!0)}}return this._viewportToImageDelta(t-this._contentBoundsNoRotate.x,r-this._contentBoundsNoRotate.y)},_imageToViewportDelta:function(t,r){var i=this._contentBoundsNoRotate.width;return new e.Point(t/this._contentSizeNoRotate.x*i,r/this._contentSizeNoRotate.x*i)},imageToViewportCoordinates:function(t,r){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 s=this.viewer.world.getItemAt(0);return s.imageToViewportCoordinates(t,r,!0)}}var l=this._imageToViewportDelta(t,r);return l.x+=this._contentBoundsNoRotate.x,l.y+=this._contentBoundsNoRotate.y,l},imageToViewportRectangle:function(t,r,i,s){var l=t;if(l instanceof e.Rect||(l=new e.Rect(t,r,i,s)),this.viewer){var a=this.viewer.world.getItemCount();if(a>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.imageToViewportRectangle] is not accurate with multi-image; use TiledImage.imageToViewportRectangle instead.");else if(a===1){var u=this.viewer.world.getItemAt(0);return u.imageToViewportRectangle(t,r,i,s,!0)}}var h=this.imageToViewportCoordinates(l.x,l.y),c=this._imageToViewportDelta(l.width,l.height);return new e.Rect(h.x,h.y,c.x,c.y,l.degrees)},viewportToImageRectangle:function(t,r,i,s){var l=t;if(l instanceof e.Rect||(l=new e.Rect(t,r,i,s)),this.viewer){var a=this.viewer.world.getItemCount();if(a>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageRectangle] is not accurate with multi-image; use TiledImage.viewportToImageRectangle instead.");else if(a===1){var u=this.viewer.world.getItemAt(0);return u.viewportToImageRectangle(t,r,i,s,!0)}}var h=this.viewportToImageCoordinates(l.x,l.y),c=this._viewportToImageDelta(l.width,l.height);return new e.Rect(h.x,h.y,c.x,c.y,l.degrees)},viewerElementToImageCoordinates:function(t){var r=this.pointFromPixel(t,!0);return this.viewportToImageCoordinates(r)},imageToViewerElementCoordinates:function(t){var r=this.imageToViewportCoordinates(t);return this.pixelFromPoint(r,!0)},windowToImageCoordinates:function(t){e.console.assert(this.viewer,"[Viewport.windowToImageCoordinates] the viewport must have a viewer.");var r=t.minus(e.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(r)},imageToWindowCoordinates:function(t){e.console.assert(this.viewer,"[Viewport.imageToWindowCoordinates] the viewport must have a viewer.");var r=this.imageToViewerElementCoordinates(t);return r.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 r=t.minus(e.getElementPosition(this.viewer.element));return this.viewerElementToViewportCoordinates(r)},viewportToWindowCoordinates:function(t){e.console.assert(this.viewer,"[Viewport.viewportToWindowCoordinates] the viewport must have a viewer.");var r=this.viewportToViewerElementCoordinates(t);return r.plus(e.getElementPosition(this.viewer.element))},viewportToImageZoom:function(t){if(this.viewer){var r=this.viewer.world.getItemCount();if(r>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageZoom] is not accurate with multi-image.");else if(r===1){var i=this.viewer.world.getItemAt(0);return i.viewportToImageZoom(t)}}var s=this._contentSizeNoRotate.x,l=this._containerInnerSize.x,a=this._contentBoundsNoRotate.width,u=l/s*a;return t*u},imageToViewportZoom:function(t){if(this.viewer){var r=this.viewer.world.getItemCount();if(r>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(r===1){var i=this.viewer.world.getItemAt(0);return i.imageToViewportZoom(t)}}var s=this._contentSizeNoRotate.x,l=this._containerInnerSize.x,a=this._contentBoundsNoRotate.width,u=s/l/a;return t*u},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,r=!0,i=!1){e.console.assert(!isNaN(t),"[Viewport.setMaxZoomPixelRatio] ratio must be a number"),!isNaN(t)&&(this.maxZoomPixelRatio=t,r&&this.getZoom()>this.getMaxZoom()&&this.applyConstraints(i))}}})(o),(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 r=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 s=1;t.width?(s=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&&(s=t.height/this.normHeight,delete t.height);var l=t.fitBounds;delete t.fitBounds;var a=t.fitBoundsPlacement||o.Placement.CENTER;delete t.fitBoundsPlacement;var u=t.degrees||0;delete t.degrees;var h=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:r,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:s,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._degreesSpring=new e.Spring({initial:u,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._updateForScale(),l&&this.fitBounds(l,a,!0),this._ownAjaxHeaders={},this.setAjaxHeaders(h,!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 r=this._xSpring.update(),i=this._ySpring.update(),s=this._scaleSpring.update(),l=this._degreesSpring.update(),a=r||i||s||l||this._needsUpdate;if(a||t||!this._fullyLoaded){let u=this._updateLevelsForViewport();this._setFullyLoaded(u)}return this._needsUpdate=!1,a?(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 r=this.getBoundsNoRotate(t);if(this._clip){var i=t?this._worldWidthCurrent:this._worldWidthTarget,s=i/this.source.dimensions.x,l=this._clip.times(s);r=new e.Rect(r.x+l.x,r.y+l.y,l.width,l.height)}return r.rotate(this.getRotation(t),this._getRotationPoint(t))},getTileBounds:function(t,r,i){var s=this.source.getNumTiles(t),l=(s.x+r%s.x)%s.x,a=(s.y+i%s.y)%s.y,u=this.source.getTileBounds(t,l,a);return this.getFlip()&&(u.x=Math.max(0,1-u.x-u.width)),u.x+=(r-l)/s.x,u.y+=this._worldHeightCurrent/this._worldWidthCurrent*((i-a)/s.y),u},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)),r=this.imageToWindowCoordinates(this.getContentSize());return new e.Point(r.x-t.x,r.y-t.y)},_viewportToImageDelta:function(t,r,i){var s=i?this._scaleSpring.current.value:this._scaleSpring.target.value;return new e.Point(t*(this.source.dimensions.x/s),r*(this.source.dimensions.y*this.contentAspectX/s))},viewportToImageCoordinates:function(t,r,i){var s;return t instanceof e.Point?(i=r,s=t):s=new e.Point(t,r),s=s.rotate(-this.getRotation(i),this._getRotationPoint(i)),i?this._viewportToImageDelta(s.x-this._xSpring.current.value,s.y-this._ySpring.current.value):this._viewportToImageDelta(s.x-this._xSpring.target.value,s.y-this._ySpring.target.value)},_imageToViewportDelta:function(t,r,i){var s=i?this._scaleSpring.current.value:this._scaleSpring.target.value;return new e.Point(t/this.source.dimensions.x*s,r/this.source.dimensions.y/this.contentAspectX*s)},imageToViewportCoordinates:function(t,r,i){t instanceof e.Point&&(i=r,r=t.y,t=t.x);var s=this._imageToViewportDelta(t,r,i);return i?(s.x+=this._xSpring.current.value,s.y+=this._ySpring.current.value):(s.x+=this._xSpring.target.value,s.y+=this._ySpring.target.value),s.rotate(this.getRotation(i),this._getRotationPoint(i))},imageToViewportRectangle:function(t,r,i,s,l){var a=t;a instanceof e.Rect?l=r:a=new e.Rect(t,r,i,s);var u=this.imageToViewportCoordinates(a.getTopLeft(),l),h=this._imageToViewportDelta(a.width,a.height,l);return new e.Rect(u.x,u.y,h.x,h.y,a.degrees+this.getRotation(l))},viewportToImageRectangle:function(t,r,i,s,l){var a=t;t instanceof e.Rect?l=r:a=new e.Rect(t,r,i,s);var u=this.viewportToImageCoordinates(a.getTopLeft(),l),h=this._viewportToImageDelta(a.width,a.height,l);return new e.Rect(u.x,u.y,h.x,h.y,a.degrees-this.getRotation(l))},viewerElementToImageCoordinates:function(t){var r=this.viewport.pointFromPixel(t,!0);return this.viewportToImageCoordinates(r)},imageToViewerElementCoordinates:function(t){var r=this.imageToViewportCoordinates(t);return this.viewport.pixelFromPoint(r,!0)},windowToImageCoordinates:function(t){var r=t.minus(o.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(r)},imageToWindowCoordinates:function(t){var r=this.imageToViewerElementCoordinates(t);return r.plus(o.getElementPosition(this.viewer.element))},_viewportToTiledImageRectangle:function(t){var r=this._scaleSpring.current.value;return t=t.rotate(-this.getRotation(!0),this._getRotationPoint(!0)),new e.Rect((t.x-this._xSpring.current.value)/r,(t.y-this._ySpring.current.value)/r,t.width/r,t.height/r,t.degrees)},viewportToImageZoom:function(t){var r=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return r*t},imageToViewportZoom:function(t){var r=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return t/r},setPosition:function(t,r){var i=this._xSpring.target.value===t.x&&this._ySpring.target.value===t.y;if(r){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,r){this._setScale(t,r)},setHeight:function(t,r){this._setScale(t/this.normHeight,r)},setCroppingPolygons:function(t){var r=function(s){return s instanceof e.Point||typeof s.x=="number"&&typeof s.y=="number"},i=function(s){return s.map(function(l){try{if(r(l))return{x:l.x,y:l.y};throw new Error}catch{throw new Error("A Provided cropping polygon point is not supported")}})};try{if(!e.isArray(t))throw new Error("Provided cropping polygon is not an array");this._croppingPolygons=t.map(function(s){return i(s)}),this._needsDraw=!0}catch(s){e.console.error("[TiledImage.setCroppingPolygons] Cropping polygon format not supported"),e.console.error(s),this.resetCroppingPolygons()}},resetCroppingPolygons:function(){this._croppingPolygons=null,this._needsDraw=!0},fitBounds:function(t,r,i){r=r||e.Placement.CENTER;var s=e.Placement.properties[r],l=this.contentAspectX,a=0,u=0,h=1,c=1;if(this._clip&&(l=this._clip.getAspectRatio(),h=this._clip.width/this.source.dimensions.x,c=this._clip.height/this.source.dimensions.y,t.getAspectRatio()>l?(a=this._clip.x/this._clip.height*t.height,u=this._clip.y/this._clip.height*t.height):(a=this._clip.x/this._clip.width*t.width,u=this._clip.y/this._clip.width*t.width)),t.getAspectRatio()>l){var d=t.height/c,m=0;s.isHorizontallyCentered?m=(t.width-t.height*l)/2:s.isRight&&(m=t.width-t.height*l),this.setPosition(new e.Point(t.x-a+m,t.y-u),i),this.setHeight(d,i)}else{var v=t.width/h,y=0;s.isVerticallyCentered?y=(t.height-t.width/l)/2:s.isBottom&&(y=t.height-t.width/l),this.setPosition(new e.Point(t.x-a,t.y-u+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._needsUpdate=!0,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 r=this._flipped!==!!t;this._flipped=!!t,r&&(this.update(!0),this._needsDraw=!0,this._raiseBoundsChange())},get wrapHorizontal(){return this._wrapHorizontal},set wrapHorizontal(t){let r=this._wrapHorizontal!==!!t;this._wrapHorizontal=!!t,this._initialized&&r&&(this.update(!0),this._needsDraw=!0)},get wrapVertical(){return this._wrapVertical},set wrapVertical(t){let r=this._wrapVertical!==!!t;this._wrapVertical=!!t,this._initialized&&r&&(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,r){this._degreesSpring.target.value===t&&this._degreesSpring.isAtTargetValue()||(r?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 r=this._viewportToTiledImageRectangle(this.getClippedBounds(!0));t=t.intersection(r)}return t},getTilesToDraw:function(){let t=this._tilesToDraw.flat();return this._updateTilesInViewport(t),t=this._tilesToDraw.flat(),t.forEach(r=>{r.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,r){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(r)},_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 r,i,s,l;for(var a in this.tilesMatrix){r=this.source.getNumTiles(a);for(var u in this.tilesMatrix[a]){i=(r.x+u%r.x)%r.x;for(var h in this.tilesMatrix[a][u])if(s=(r.y+h%r.y)%r.y,l=this.tilesMatrix[a][u][h],l.loadWithAjax=this.loadTilesWithAjax,l.loadWithAjax){var c=this.source.getTileAjaxHeaders(a,i,s);l.ajaxHeaders=e.extend({},this.ajaxHeaders,c)}else l.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,r){var i=this._scaleSpring.target.value===t;if(r){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))),r=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(r/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(),r=t.lowestLevel,i=t.highestLevel,s=[],l=this.getDrawArea(),a=e.now();if(this._lastDrawn.forEach(F=>{F.tile.beingDrawn=!1}),this._tilesToDraw=[],this._tilesLoading=0,this.loadingCoverage={},!l)return this._needsDraw=!1,this._fullyLoaded;var u=new Array(i-r+1);for(let F=0,H=i;H>=r;H--,F++)u[F]=H;for(let F=i+1;F<=this.source.maxLevel;F++){var h=this.tilesMatrix[F]&&this.tilesMatrix[F][0]&&this.tilesMatrix[F][0][0];if(h&&h.isBottomMost&&h.isRightMost&&h.loaded){u.push(F);break}}let c=!1;for(let F=0;F<u.length;F++){let H=u[F];var d=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(H),!0).x*this._scaleSpring.current.value;if(F===u.length-1||d>=this.minPixelRatio)c=!0;else if(!c)continue;var m=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(H),!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,_=Math.min(1,(d-.5)/.5),E=y/Math.abs(y-m),S=this._updateLevel(H,_,E,l,a,s);s=S.bestTiles;var P=S.updatedTiles.filter(B=>B.loaded),L=(function(B,V,Y){return function(J){return{tile:J,level:B,levelOpacity:V,currentTime:Y}}})(H,_,a);if(this._tilesToDraw[H]=P.map(L),this._providesCoverage(this.coverage,H))break}return s&&s.length>0?(s.forEach(function(F){F&&!F.context2D&&this._loadTile(F,a)},this),this._needsDraw=!0,!1):this._tilesLoading===0},_updateTilesInViewport:function(t){let r=e.now(),i=this;this._tilesLoading=0,this._wasBlending=this._isBlending,this._isBlending=!1,this.loadingCoverage={};let s=t.length?t[0].level:0;if(!this.getDrawArea())return;function a(h){let c=h.tile;if(c&&c.loaded){let d=i._blendTile(c,c.x,c.y,h.level,h.levelOpacity,r,s);i._isBlending=i._isBlending||d,i._needsDraw=i._needsDraw||d||i._wasBlending}}let u=0;for(let h=0;h<t.length;h++){let c=t[h];a(c),this._providesCoverage(this.coverage,c.level)&&(u=Math.max(u,c.level))}if(u>0)for(let h in this._tilesToDraw)h<u&&delete this._tilesToDraw[h]},_blendTile:function(t,r,i,s,l,a,u){let h=1e3*this.blendTime,c,d;return t.blendStart||(t.blendStart=a),c=a-t.blendStart,d=h?Math.min(1,c/h):1,s===u&&(d=1,c=h),this.alwaysBlend&&(d*=l),t.opacity=d,d===1&&(this._setCoverage(this.coverage,s,r,i,!0),this._hasOpaqueTile=!0),c<h},_updateLevel:function(t,r,i,s,l,a){var u=s.getBoundingBox().getTopLeft(),h=s.getBoundingBox().getBottomRight();this.viewer&&this.viewer.raiseEvent("update-level",{tiledImage:this,havedrawn:!0,level:t,opacity:r,visibility:i,drawArea:s,topleft:u,bottomright:h,currenttime:l,best:a}),this._resetCoverage(this.coverage,t),this._resetCoverage(this.loadingCoverage,t);var c=this._getCornerTiles(t,u,h),d=c.topLeft,m=c.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 _=Math.max(0,(m.x-d.x)*(m.y-d.y)),E=new Array(_),S=0,P=d.x;P<=m.x;P++)for(var L=d.y;L<=m.y;L++){var F;if(this.getFlip()){var H=(v.x+P%v.x)%v.x;F=P+v.x-H-H-1}else F=P;if(s.intersection(this.getTileBounds(t,F,L))!==null){var B=this._updateTile(F,L,t,i,y,v,l,a);a=B.bestTiles,E[S]=B.tile,S+=1}}return{bestTiles:a,updatedTiles:E}},_positionTile:function(t,r,i,s,l){var a=t.bounds.getTopLeft();a.x*=this._scaleSpring.current.value,a.y*=this._scaleSpring.current.value,a.x+=this._xSpring.current.value,a.y+=this._ySpring.current.value;var u=t.bounds.getSize();u.x*=this._scaleSpring.current.value,u.y*=this._scaleSpring.current.value,t.positionedBounds.x=a.x,t.positionedBounds.y=a.y,t.positionedBounds.width=u.x,t.positionedBounds.height=u.y;var h=i.pixelFromPointNoRotate(a,!0),c=i.pixelFromPointNoRotate(a,!1),d=i.deltaPixelsFromPointsNoRotate(u,!0),m=i.deltaPixelsFromPointsNoRotate(u,!1),v=c.plus(m.divide(2)),y=s.squaredDistanceTo(v);this.viewer.drawer.minimumOverlapRequired(this)&&(r||(d=d.plus(new e.Point(1,1))),t.isRightMost&&this.wrapHorizontal&&(d.x+=.75),t.isBottomMost&&this.wrapVertical&&(d.y+=.75)),t.position=h,t.size=d,t.squaredDistance=y,t.visibility=l},_updateTile:function(t,r,i,s,l,a,u,h){var c=this._getTile(t,r,i,u,a);this.viewer&&this.viewer.raiseEvent("update-tile",{tiledImage:this,tile:c}),this._setCoverage(this.coverage,i,t,r,!1);var d=c.loaded||c.loading||this._isCovered(this.loadingCoverage,i,t,r);if(this._setCoverage(this.loadingCoverage,i,t,r,d),!c.exists)return{bestTiles:h,tile:c};if(c.loaded&&c.opacity===1&&this._setCoverage(this.coverage,i,t,r,!0),this._positionTile(c,this.source.tileOverlap,this.viewport,l,s),!c.loaded)if(c.context2D)this._setTileLoaded(c);else{var m=this._tileCache.getImageRecord(c.cacheKey);m&&this._setTileLoaded(c,m.getData())}return c.loading?this._tilesLoading++:d||(h=this._compareTiles(h,c,this.maxTilesPerFrame)),{bestTiles:h,tile:c}},_getCornerTiles:function(t,r,i){var s,l;this.wrapHorizontal?(s=e.positiveModulo(r.x,1),l=e.positiveModulo(i.x,1)):(s=Math.max(0,r.x),l=Math.min(1,i.x));var a,u,h=1/this.source.aspectRatio;this.wrapVertical?(a=e.positiveModulo(r.y,h),u=e.positiveModulo(i.y,h)):(a=Math.max(0,r.y),u=Math.min(h,i.y));var c=this.source.getTileAtPoint(t,new e.Point(s,a)),d=this.source.getTileAtPoint(t,new e.Point(l,u)),m=this.source.getNumTiles(t);return this.wrapHorizontal&&(c.x+=m.x*Math.floor(r.x),d.x+=m.x*Math.floor(i.x)),this.wrapVertical&&(c.y+=m.y*Math.floor(r.y/h),d.y+=m.y*Math.floor(i.y/h)),{topLeft:c,bottomRight:d}},_getTile:function(t,r,i,s,l){var a,u,h,c,d,m,v,y,_,E,S=this.tilesMatrix,P=this.source;return S[i]||(S[i]={}),S[i][t]||(S[i][t]={}),(!S[i][t][r]||!S[i][t][r].flipped!=!this.flipped)&&(a=(l.x+t%l.x)%l.x,u=(l.y+r%l.y)%l.y,h=this.getTileBounds(i,t,r),c=P.getTileBounds(i,a,u,!0),d=P.tileExists(i,a,u),m=P.getTileUrl(i,a,u),v=P.getTilePostData(i,a,u),this.loadTilesWithAjax?(y=P.getTileAjaxHeaders(i,a,u),e.isPlainObject(this.ajaxHeaders)&&(y=e.extend({},this.ajaxHeaders,y))):y=null,_=P.getContext2D?P.getContext2D(i,a,u):void 0,E=new e.Tile(i,t,r,h,d,m,_,this.loadTilesWithAjax,y,c,v,P.getTileHashKey(i,a,u,m,y,v)),this.getFlip()?a===0&&(E.isRightMost=!0):a===l.x-1&&(E.isRightMost=!0),u===l.y-1&&(E.isBottomMost=!0),E.flipped=this.flipped,S[i][t][r]=E),E=S[i][t][r],E.lastTouchTime=s,E},_loadTile:function(t,r){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(s,l,a){i._onTileLoad(t,r,s,l,a)},abort:function(){t.loading=!1}})},_onTileLoad:function(t,r,i,s,l){if(i)t.exists=!0;else{e.console.error("Tile %s failed to load: %s - error: %s",t,t.getUrl(),s),this.viewer.raiseEvent("tile-load-failed",{tile:t,tiledImage:this,time:r,message:s,tileRequest:l}),t.loading=!1,t.exists=!1;return}if(r<this.lastResetTime){e.console.warn("Ignoring tile %s loaded before reset: %s",t,t.getUrl()),t.loading=!1;return}var a=this,u=function(){var h=a.source,c=h.getClosestLevel();a._setTileLoaded(t,i,c,l)};u()},_setTileLoaded:function(t,r,i,s){var l=0,a=!1,u=this;function h(){return a&&e.console.error("Event 'tile-loaded' argument getCompletionCallback must be called synchronously. Its return value should be called asynchronously."),l++,c}function c(){l--,l===0&&(t.loading=!1,t.loaded=!0,t.hasTransparency=u.source.hasTransparency(t.context2D,t.getUrl(),t.ajaxHeaders,t.postData),t.context2D||u._tileCache.cacheTile({data:r,tile:t,cutoff:i,tiledImage:u}),u.viewer.raiseEvent("tile-ready",{tile:t,tiledImage:u,tileRequest:s}),u._needsDraw=!0)}var d=h();this.viewer.raiseEvent("tile-loaded",{tile:t,tiledImage:this,tileRequest:s,get image(){return e.console.error("[tile-loaded] event 'image' has been deprecated. Use 'data' property instead."),r},data:r,getCompletionCallback:h}),a=!0,d()},_compareTiles:function(t,r,i){return t?(t.push(r),this._sortTiles(t),t.length>i&&t.pop(),t):[r]},_sortTiles:function(t){t.sort(function(r,i){return r===null?1:i===null?-1:r.visibility===i.visibility?r.squaredDistance-i.squaredDistance:i.visibility-r.visibility})},_providesCoverage:function(t,r,i,s){var l,a,u,h;if(!t[r])return!1;if(i===void 0||s===void 0){l=t[r];for(u in l)if(Object.prototype.hasOwnProperty.call(l,u)){a=l[u];for(h in a)if(Object.prototype.hasOwnProperty.call(a,h)&&!a[h])return!1}return!0}return t[r][i]===void 0||t[r][i][s]===void 0||t[r][i][s]===!0},_isCovered:function(t,r,i,s){return i===void 0||s===void 0?this._providesCoverage(t,r+1):this._providesCoverage(t,r+1,2*i,2*s)&&this._providesCoverage(t,r+1,2*i,2*s+1)&&this._providesCoverage(t,r+1,2*i+1,2*s)&&this._providesCoverage(t,r+1,2*i+1,2*s+1)},_setCoverage:function(t,r,i,s,l){if(!t[r]){e.console.warn("Setting coverage for a tile before its level's coverage has been reset: %s",r);return}t[r][i]||(t[r][i]={}),t[r][i][s]=l},_resetCoverage:function(t,r){t[r]={}}})})(o),(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},r=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)};r.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 s=0;s<this._tiles.length;s++)if(this._tiles[s]===i){this._tiles.splice(s,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 s=i.cutoff||0,l=this._tilesLoaded.length,a=this._imagesLoaded[i.tile.cacheKey];if(a||(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"),a=this._imagesLoaded[i.tile.cacheKey]=new r({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++),a.addTile(i.tile),i.tile.cacheImageRecord=a,this._imagesLoadedCount>this._maxImageCacheCount){for(var u=null,h=-1,c=null,d,m,v,y,_,E,S=this._tilesLoaded.length-1;S>=0;S--)if(E=this._tilesLoaded[S],d=E.tile,!(d.level<=s||d.beingDrawn)){if(!u){u=d,h=S,c=E;continue}y=d.lastTouchTime,m=u.lastTouchTime,_=d.level,v=u.level,(y<m||y===m&&_>v)&&(u=d,h=S,c=E)}u&&h>=0&&(this._unloadTile(c),l=h)}this._tilesLoaded[l]=new t({tile:i.tile,tiledImage:i.tiledImage})},clearTilesFor:function(i){e.console.assert(i,"[TileCache.clearTilesFor] tiledImage is required");for(var s,l=0;l<this._tilesLoaded.length;++l)s=this._tilesLoaded[l],s.tiledImage===i&&(this._unloadTile(s),this._tilesLoaded.splice(l,1),l--)},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 s=i.tile,l=i.tiledImage;let a=s.getCanvasContext&&s.getCanvasContext();s.unload(),s.cacheImageRecord=null;var u=this._imagesLoaded[s.cacheKey];u&&(u.removeTile(s),u.getTileCount()||(u.destroy(),delete this._imagesLoaded[s.cacheKey],this._imagesLoadedCount--,a&&(a.canvas.width=0,a.canvas.height=0,l.viewer.raiseEvent("image-unloaded",{context2D:a,tile:s}))),l.viewer.raiseEvent("tile-unloaded",{tile:s,tiledImage:l}))}}})(o),(function(e){e.World=function(t){var r=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){r._autoRefigureSizes?r._figureSizes():r._needsSizesFigured=!0},this._figureSizes()},e.extend(e.World.prototype,e.EventSource.prototype,{addItem:function(t,r){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"),r=r||{},r.index!==void 0){var i=Math.max(0,Math.min(this._items.length,r.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,r){e.console.assert(t,"[World.setItemIndex] item is required"),e.console.assert(r!==void 0,"[World.setItemIndex] index is required");var i=this.getIndexOfItem(t);if(r>=this._items.length)throw new Error("Index bigger than number of layers.");r===i||i===-1||(this._items.splice(i,1),this._items.splice(r,0,t),this._needsDraw=!0,this.raiseEvent("item-index-change",{item:t,previousIndex:i,newIndex:r}))},removeItem:function(t){e.console.assert(t,"[World.removeItem] item is required");var r=e.indexOf(this._items,t);r!==-1&&(t.removeHandler("bounds-change",this._delegatedFigureSizes),t.removeHandler("clip-change",this._delegatedFigureSizes),t.destroy(),this._items.splice(r,1),this._figureSizes(),this._needsDraw=!0,this._raiseRemoveItem(t))},removeAll:function(){this.viewer._cancelPendingImages();var t,r;for(r=0;r<this._items.length;r++)t=this._items[r],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,r=0;r<i.length;r++)t=i[r],this._raiseRemoveItem(t)},resetItems:function(){for(var t=0;t<this._items.length;t++)this._items[t].reset()},update:function(t){for(var r=!1,i=0;i<this._items.length;i++)r=this._items[i].update(t)||r;return r},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 r=t.immediately||!1,i=t.layout||e.DEFAULT_SETTINGS.collectionLayout,s=t.rows||e.DEFAULT_SETTINGS.collectionRows,l=t.columns||e.DEFAULT_SETTINGS.collectionColumns,a=t.tileSize||e.DEFAULT_SETTINGS.collectionTileSize,u=t.tileMargin||e.DEFAULT_SETTINGS.collectionTileMargin,h=a+u,c;!t.rows&&l?c=l:c=Math.ceil(this._items.length/s);var d=0,m=0,v,y,_,E,S;this.setAutoRefigureSizes(!1);for(var P=0;P<this._items.length;P++)P&&P%c===0&&(i==="horizontal"?(m+=h,d=0):(d+=h,m=0)),v=this._items[P],y=v.getBounds(),y.width>y.height?_=a:_=a*(y.width/y.height),E=_*(y.height/y.width),S=new e.Point(d+(a-_)/2,m+(a-E)/2),v.setPosition(S,r),v.setWidth(_,r),i==="horizontal"?d+=h:m+=h;this.setAutoRefigureSizes(!0)},_figureSizes:function(){var t=this._homeBounds?this._homeBounds.clone():null,r=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 s=this._items[0],l=s.getBounds();this._contentFactor=s.getContentSize().x/l.width;for(var a=s.getClippedBounds().getBoundingBox(),u=a.x,h=a.y,c=a.x+a.width,d=a.y+a.height,m=1;m<this._items.length;m++)s=this._items[m],l=s.getBounds(),this._contentFactor=Math.max(this._contentFactor,s.getContentSize().x/l.width),a=s.getClippedBounds().getBoundingBox(),u=Math.min(u,a.x),h=Math.min(h,a.y),c=Math.max(c,a.x+a.width),d=Math.max(d,a.y+a.height);this._homeBounds=new e.Rect(u,h,c-u,d-h),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(r))&&this.raiseEvent("metrics-change",{})},_raiseRemoveItem:function(t){this.raiseEvent("remove-item",{item:t})}})})(o)})(Si)),Si.exports}var Hn=Dl();const Al=Nn({__proto__:null,default:Rl(Hn)},[Hn])})();
|