@triiiceratops/plugin-image-export 1.0.0-rc.5 → 1.0.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/dist/catalog.d.ts +5 -6
- package/dist/exportImage.d.ts +29 -7
- package/dist/identity.d.ts +10 -0
- package/dist/iife.js +1 -200
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -3579
- package/dist/plugin.d.ts +2 -2
- package/dist/reportError.d.ts +1 -1
- package/dist/styles.d.ts +3 -11
- package/package.json +9 -9
package/dist/iife.js
CHANGED
|
@@ -1,200 +1 @@
|
|
|
1
|
-
(function(){"use strict";var Pi=Array.isArray,Nr=Array.prototype.indexOf,ri=Array.from,Ur=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,Wr=Object.getOwnPropertyDescriptors,jr=Object.prototype,Vr=Array.prototype,tn=Object.getPrototypeOf,nn=Object.isExtensible;const rn=()=>{};function Gr(r){for(var s=0;s<r.length;s++)r[s]()}function on(){var r,s,e=new Promise((t,i)=>{r=t,s=i});return{promise:e,resolve:r,reject:s}}const Te=2,Ci=4,Ri=8,sn=1<<24,Qe=16,Je=32,pt=64,oi=128,Ne=512,Ce=1024,Be=2048,et=4096,Fe=8192,tt=16384,Di=32768,ft=65536,an=1<<17,ln=1<<18,Rt=1<<19,qr=1<<20,it=1<<25,gt=32768,Ii=1<<21,Ai=1<<22,st=1<<23,vt=Symbol("$state"),Zr=Symbol("legacy props"),Xr=Symbol(""),Dt=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"};function $r(r){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function Yr(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Kr(r){throw new Error("https://svelte.dev/e/effect_in_teardown")}function Qr(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function Jr(r){throw new Error("https://svelte.dev/e/effect_orphan")}function eo(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function to(r){throw new Error("https://svelte.dev/e/props_invalid_value")}function io(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function no(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function ro(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function oo(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const so=1,ao=2,un=4,lo=8,uo=16,ho=1,co=4,po=8,fo=16,go=1,vo=2,Ee=Symbol(),mo="http://www.w3.org/1999/xhtml",wo="@attach";function yo(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function _o(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function hn(r){return r===this.v}function xo(r,s){return r!=r?s==s:r!==s||r!==null&&typeof r=="object"||typeof r=="function"}function cn(r){return!xo(r,this.v)}let Bl=!1,De=null;function It(r){De=r}function To(r){return Eo().get(r)}function ki(r,s=!1,e){De={p:De,i:!1,c:null,e:null,s:r,x:null,l:null}}function Oi(r){var s=De,e=s.e;if(e!==null){s.e=null;for(var t of e)kn(t)}return s.i=!0,De=s.p,{}}function dn(){return!0}function Eo(r){return De===null&&$r(),De.c??=new Map(bo(De)||void 0)}function bo(r){let s=r.p;for(;s!==null;){const e=s.c;if(e!==null)return e;s=s.p}return null}let At=[];function So(){var r=At;At=[],Gr(r)}function mt(r){if(At.length===0){var s=At;queueMicrotask(()=>{s===At&&So()})}At.push(r)}function pn(r){var s=ne;if(s===null)return te.f|=st,r;if((s.f&Di)===0){if((s.f&oi)===0)throw r;s.b.error(r)}else kt(r,s)}function kt(r,s){for(;s!==null;){if((s.f&oi)!==0)try{s.b.error(r);return}catch(e){r=e}s=s.parent}throw r}const si=new Set;let ae=null,ai=null,ze=null,We=[],Bi=null,Fi=!1;class je{committed=!1;current=new Map;previous=new Map;#e=new Set;#t=new Set;#n=0;#i=0;#l=null;#o=[];#r=[];skipped_effects=new Set;is_fork=!1;is_deferred(){return this.is_fork||this.#i>0}process(s){We=[],ai=null,this.apply();var e={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const t of s)this.#s(t,e);this.is_fork||this.#h(),this.is_deferred()?(this.#a(e.effects),this.#a(e.render_effects),this.#a(e.block_effects)):(ai=this,ae=null,fn(e.render_effects),fn(e.effects),ai=null,this.#l?.resolve()),ze=null}#s(s,e){s.f^=Ce;for(var t=s.first;t!==null;){var i=t.f,n=(i&(Je|pt))!==0,o=n&&(i&Ce)!==0,u=o||(i&Fe)!==0||this.skipped_effects.has(t);if((t.f&oi)!==0&&t.b?.is_pending()&&(e={parent:e,effect:t,effects:[],render_effects:[],block_effects:[]}),!u&&t.fn!==null){n?t.f^=Ce:(i&Ci)!==0?e.effects.push(t):Yt(t)&&((t.f&Qe)!==0&&e.block_effects.push(t),Kt(t));var l=t.first;if(l!==null){t=l;continue}}var a=t.parent;for(t=t.next;t===null&&a!==null;)a===e.effect&&(this.#a(e.effects),this.#a(e.render_effects),this.#a(e.block_effects),e=e.parent),t=a.next,a=a.parent}}#a(s){for(const e of s)((e.f&Be)!==0?this.#o:this.#r).push(e),this.#u(e.deps),Re(e,Ce)}#u(s){if(s!==null)for(const e of s)(e.f&Te)===0||(e.f>)===0||(e.f^=gt,this.#u(e.deps))}capture(s,e){this.previous.has(s)||this.previous.set(s,e),(s.f&st)===0&&(this.current.set(s,s.v),ze?.set(s,s.v))}activate(){ae=this,this.apply()}deactivate(){ae===this&&(ae=null,ze=null)}flush(){if(this.activate(),We.length>0){if(Po(),ae!==null&&ae!==this)return}else this.#n===0&&this.process([]);this.deactivate()}discard(){for(const s of this.#t)s(this);this.#t.clear()}#h(){if(this.#i===0){for(const s of this.#e)s();this.#e.clear()}this.#n===0&&this.#c()}#c(){if(si.size>1){this.previous.clear();var s=ze,e=!0,t={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const n of si){if(n===this){e=!1;continue}const o=[];for(const[l,a]of this.current){if(n.current.has(l))if(e&&a!==n.current.get(l))n.current.set(l,a);else continue;o.push(l)}if(o.length===0)continue;const u=[...n.current.keys()].filter(l=>!this.current.has(l));if(u.length>0){var i=We;We=[];const l=new Set,a=new Map;for(const h of o)gn(h,u,l,a);if(We.length>0){ae=n,n.apply();for(const h of We)n.#s(h,t);n.deactivate()}We=i}}ae=null,ze=s}this.committed=!0,si.delete(this)}increment(s){this.#n+=1,s&&(this.#i+=1)}decrement(s){this.#n-=1,s&&(this.#i-=1),this.revive()}revive(){for(const s of this.#o)Re(s,Be),wt(s);for(const s of this.#r)Re(s,et),wt(s);this.#o=[],this.#r=[],this.flush()}oncommit(s){this.#e.add(s)}ondiscard(s){this.#t.add(s)}settled(){return(this.#l??=on()).promise}static ensure(){if(ae===null){const s=ae=new je;si.add(ae),je.enqueue(()=>{ae===s&&s.flush()})}return ae}static enqueue(s){mt(s)}apply(){}}function Po(){var r=xt;Fi=!0;var s=null;try{var e=0;for(pi(!0);We.length>0;){var t=je.ensure();if(e++>1e3){var i,n;Co()}t.process(We),at.clear()}}finally{Fi=!1,pi(r),Bi=null}}function Co(){try{eo()}catch(r){kt(r,Bi)}}let nt=null;function fn(r){var s=r.length;if(s!==0){for(var e=0;e<s;){var t=r[e++];if((t.f&(tt|Fe))===0&&Yt(t)&&(nt=new Set,Kt(t),t.deps===null&&t.first===null&&t.nodes===null&&(t.teardown===null&&t.ac===null?Ln(t):t.fn=null),nt?.size>0)){at.clear();for(const i of nt){if((i.f&(tt|Fe))!==0)continue;const n=[i];let o=i.parent;for(;o!==null;)nt.has(o)&&(nt.delete(o),n.push(o)),o=o.parent;for(let u=n.length-1;u>=0;u--){const l=n[u];(l.f&(tt|Fe))===0&&Kt(l)}}nt.clear()}}nt=null}}function gn(r,s,e,t){if(!e.has(r)&&(e.add(r),r.reactions!==null))for(const i of r.reactions){const n=i.f;(n&Te)!==0?gn(i,s,e,t):(n&(Ai|Qe))!==0&&(n&Be)===0&&vn(i,s,t)&&(Re(i,Be),wt(i))}}function vn(r,s,e){const t=e.get(r);if(t!==void 0)return t;if(r.deps!==null)for(const i of r.deps){if(s.includes(i))return!0;if((i.f&Te)!==0&&vn(i,s,e))return e.set(i,!0),!0}return e.set(r,!1),!1}function wt(r){for(var s=Bi=r;s.parent!==null;){s=s.parent;var e=s.f;if(Fi&&s===ne&&(e&Qe)!==0&&(e&ln)===0)return;if((e&(pt|Je))!==0){if((e&Ce)===0)return;s.f^=Ce}}We.push(s)}function Ro(r){let s=0,e=yt(0),t;return()=>{qt()&&(b(e),On(()=>(s===0&&(t=gi(()=>r(()=>jt(e)))),s+=1,()=>{mt(()=>{s-=1,s===0&&(t?.(),t=void 0,jt(e))})})))}}var Do=ft|Rt|oi;function Io(r,s,e){new Ao(r,s,e)}class Ao{parent;#e=!1;#t;#n=null;#i;#l;#o;#r=null;#s=null;#a=null;#u=null;#h=null;#c=0;#d=0;#f=!1;#p=null;#y=Ro(()=>(this.#p=yt(this.#c),()=>{this.#p=null}));constructor(s,e,t){this.#t=s,this.#i=e,this.#l=t,this.parent=ne.b,this.#e=!!this.#i.pending,this.#o=di(()=>{ne.b=this;{var i=this.#m();try{this.#r=Ae(()=>t(i))}catch(n){this.error(n)}this.#d>0?this.#v():this.#e=!1}return()=>{this.#h?.remove()}},Do)}#_(){try{this.#r=Ae(()=>this.#l(this.#t))}catch(s){this.error(s)}this.#e=!1}#x(){const s=this.#i.pending;s&&(this.#s=Ae(()=>s(this.#t)),je.enqueue(()=>{var e=this.#m();this.#r=this.#g(()=>(je.ensure(),Ae(()=>this.#l(e)))),this.#d>0?this.#v():(_t(this.#s,()=>{this.#s=null}),this.#e=!1)}))}#m(){var s=this.#t;return this.#e&&(this.#h=ut(),this.#t.before(this.#h),s=this.#h),s}is_pending(){return this.#e||!!this.parent&&this.parent.is_pending()}has_pending_snippet(){return!!this.#i.pending}#g(s){var e=ne,t=te,i=De;qe(this.#o),ke(this.#o),It(this.#o.ctx);try{return s()}catch(n){return pn(n),null}finally{qe(e),ke(t),It(i)}}#v(){const s=this.#i.pending;this.#r!==null&&(this.#u=document.createDocumentFragment(),this.#u.append(this.#h),Nn(this.#r,this.#u)),this.#s===null&&(this.#s=Ae(()=>s(this.#t)))}#w(s){if(!this.has_pending_snippet()){this.parent&&this.parent.#w(s);return}this.#d+=s,this.#d===0&&(this.#e=!1,this.#s&&_t(this.#s,()=>{this.#s=null}),this.#u&&(this.#t.before(this.#u),this.#u=null))}update_pending_count(s){this.#w(s),this.#c+=s,this.#p&&Ot(this.#p,this.#c)}get_effect_pending(){return this.#y(),b(this.#p)}error(s){var e=this.#i.onerror;let t=this.#i.failed;if(this.#f||!e&&!t)throw s;this.#r&&(Se(this.#r),this.#r=null),this.#s&&(Se(this.#s),this.#s=null),this.#a&&(Se(this.#a),this.#a=null);var i=!1,n=!1;const o=()=>{if(i){_o();return}i=!0,n&&oo(),je.ensure(),this.#c=0,this.#a!==null&&_t(this.#a,()=>{this.#a=null}),this.#e=this.has_pending_snippet(),this.#r=this.#g(()=>(this.#f=!1,Ae(()=>this.#l(this.#t)))),this.#d>0?this.#v():this.#e=!1};var u=te;try{ke(null),n=!0,e?.(s,o),n=!1}catch(l){kt(l,this.#o&&this.#o.parent)}finally{ke(u)}t&&mt(()=>{this.#a=this.#g(()=>{je.ensure(),this.#f=!0;try{return Ae(()=>{t(this.#t,()=>s,()=>o)})}catch(l){return kt(l,this.#o.parent),null}finally{this.#f=!1}})})}}function mn(r,s,e,t){const i=ui;if(e.length===0&&r.length===0){t(s.map(i));return}var n=ae,o=ne,u=ko();function l(){Promise.all(e.map(a=>Oo(a))).then(a=>{u();try{t([...s.map(i),...a])}catch(h){(o.f&tt)===0&&kt(h,o)}n?.deactivate(),li()}).catch(a=>{kt(a,o)})}r.length>0?Promise.all(r).then(()=>{u();try{return l()}finally{n?.deactivate(),li()}}):l()}function ko(){var r=ne,s=te,e=De,t=ae;return function(n=!0){qe(r),ke(s),It(e),n&&t?.activate()}}function li(){qe(null),ke(null),It(null)}function ui(r){var s=Te|Be,e=te!==null&&(te.f&Te)!==0?te:null;return ne!==null&&(ne.f|=Rt),{ctx:De,deps:null,effects:null,equals:hn,f:s,fn:r,reactions:null,rv:0,v:Ee,wv:0,parent:e??ne,ac:null}}function Oo(r,s){let e=ne;e===null&&Yr();var t=e.b,i=void 0,n=yt(Ee),o=!te,u=new Map;return qo(()=>{var l=on();i=l.promise;try{Promise.resolve(r()).then(l.resolve,l.reject).then(()=>{a===ae&&a.committed&&a.deactivate(),li()})}catch(d){l.reject(d),li()}var a=ae;if(o){var h=!t.is_pending();t.update_pending_count(1),a.increment(h),u.get(a)?.reject(Dt),u.delete(a),u.set(a,l)}const c=(d,g=void 0)=>{if(a.activate(),g)g!==Dt&&(n.f|=st,Ot(n,g));else{(n.f&st)!==0&&(n.f^=st),Ot(n,d);for(const[m,_]of u){if(u.delete(m),m===a)break;_.reject(Dt)}}o&&(t.update_pending_count(-1),a.decrement(h))};l.promise.then(c,d=>c(null,d||"unknown"))}),An(()=>{for(const l of u.values())l.reject(Dt)}),new Promise(l=>{function a(h){function c(){h===i?l(n):a(i)}h.then(c,c)}a(i)})}function le(r){const s=ui(r);return Wn(s),s}function wn(r){const s=ui(r);return s.equals=cn,s}function yn(r){var s=r.effects;if(s!==null){r.effects=null;for(var e=0;e<s.length;e+=1)Se(s[e])}}function Bo(r){for(var s=r.parent;s!==null;){if((s.f&Te)===0)return(s.f&tt)===0?s:null;s=s.parent}return null}function Mi(r){var s,e=ne;qe(Bo(r));try{r.f&=~gt,yn(r),s=Zn(r)}finally{qe(e)}return s}function _n(r){var s=Mi(r);if(r.equals(s)||(ae?.is_fork||(r.v=s),r.wv=Gn()),!Tt)if(ze!==null)(qt()||ae?.is_fork)&&ze.set(r,s);else{var e=(r.f&Ne)===0?et:Ce;Re(r,e)}}let Li=new Set;const at=new Map;let xn=!1;function yt(r,s){var e={f:0,v:r,reactions:null,equals:hn,rv:0,wv:0};return e}function ue(r,s){const e=yt(r);return Wn(e),e}function Fo(r,s=!1,e=!0){const t=yt(r);return s||(t.equals=cn),t}function Z(r,s,e=!1){te!==null&&(!Ge||(te.f&an)!==0)&&dn()&&(te.f&(Te|Qe|Ai|an))!==0&&!rt?.includes(r)&&ro();let t=e?lt(s):s;return Ot(r,t)}function Ot(r,s){if(!r.equals(s)){var e=r.v;Tt?at.set(r,s):at.set(r,e),r.v=s;var t=je.ensure();t.capture(r,e),(r.f&Te)!==0&&((r.f&Be)!==0&&Mi(r),Re(r,(r.f&Ne)!==0?Ce:et)),r.wv=Gn(),En(r,Be),ne!==null&&(ne.f&Ce)!==0&&(ne.f&(Je|pt))===0&&(He===null?$o([r]):He.push(r)),!t.is_fork&&Li.size>0&&!xn&&Mo()}return s}function Mo(){xn=!1;var r=xt;pi(!0);const s=Array.from(Li);try{for(const e of s)(e.f&Ce)!==0&&Re(e,et),Yt(e)&&Kt(e)}finally{pi(r)}Li.clear()}function Tn(r,s=1){var e=b(r),t=s===1?e++:e--;return Z(r,e),t}function jt(r){Z(r,r.v+1)}function En(r,s){var e=r.reactions;if(e!==null)for(var t=e.length,i=0;i<t;i++){var n=e[i],o=n.f,u=(o&Be)===0;if(u&&Re(n,s),(o&Te)!==0){var l=n;ze?.delete(l),(o>)===0&&(o&Ne&&(n.f|=gt),En(l,et))}else u&&((o&Qe)!==0&&nt!==null&&nt.add(n),wt(n))}}function lt(r){if(typeof r!="object"||r===null||vt in r)return r;const s=tn(r);if(s!==jr&&s!==Vr)return r;var e=new Map,t=Pi(r),i=ue(0),n=Et,o=u=>{if(Et===n)return u();var l=te,a=Et;ke(null),Vn(n);var h=u();return ke(l),Vn(a),h};return t&&e.set("length",ue(r.length)),new Proxy(r,{defineProperty(u,l,a){(!("value"in a)||a.configurable===!1||a.enumerable===!1||a.writable===!1)&&io();var h=e.get(l);return h===void 0?h=o(()=>{var c=ue(a.value);return e.set(l,c),c}):Z(h,a.value,!0),!0},deleteProperty(u,l){var a=e.get(l);if(a===void 0){if(l in u){const h=o(()=>ue(Ee));e.set(l,h),jt(i)}}else Z(a,Ee),jt(i);return!0},get(u,l,a){if(l===vt)return r;var h=e.get(l),c=l in u;if(h===void 0&&(!c||Ct(u,l)?.writable)&&(h=o(()=>{var g=lt(c?u[l]:Ee),m=ue(g);return m}),e.set(l,h)),h!==void 0){var d=b(h);return d===Ee?void 0:d}return Reflect.get(u,l,a)},getOwnPropertyDescriptor(u,l){var a=Reflect.getOwnPropertyDescriptor(u,l);if(a&&"value"in a){var h=e.get(l);h&&(a.value=b(h))}else if(a===void 0){var c=e.get(l),d=c?.v;if(c!==void 0&&d!==Ee)return{enumerable:!0,configurable:!0,value:d,writable:!0}}return a},has(u,l){if(l===vt)return!0;var a=e.get(l),h=a!==void 0&&a.v!==Ee||Reflect.has(u,l);if(a!==void 0||ne!==null&&(!h||Ct(u,l)?.writable)){a===void 0&&(a=o(()=>{var d=h?lt(u[l]):Ee,g=ue(d);return g}),e.set(l,a));var c=b(a);if(c===Ee)return!1}return h},set(u,l,a,h){var c=e.get(l),d=l in u;if(t&&l==="length")for(var g=a;g<c.v;g+=1){var m=e.get(g+"");m!==void 0?Z(m,Ee):g in u&&(m=o(()=>ue(Ee)),e.set(g+"",m))}if(c===void 0)(!d||Ct(u,l)?.writable)&&(c=o(()=>ue(void 0)),Z(c,lt(a)),e.set(l,c));else{d=c.v!==Ee;var _=o(()=>lt(a));Z(c,_)}var y=Reflect.getOwnPropertyDescriptor(u,l);if(y?.set&&y.set.call(h,a),!d){if(t&&typeof l=="string"){var E=e.get("length"),S=Number(l);Number.isInteger(S)&&S>=E.v&&Z(E,S+1)}jt(i)}return!0},ownKeys(u){b(i);var l=Reflect.ownKeys(u).filter(c=>{var d=e.get(c);return d===void 0||d.v!==Ee});for(var[a,h]of e)h.v!==Ee&&!(a in u)&&l.push(a);return l},setPrototypeOf(){no()}})}function bn(r){try{if(r!==null&&typeof r=="object"&&vt in r)return r[vt]}catch{}return r}function Lo(r,s){return Object.is(bn(r),bn(s))}var Sn,Pn,Cn,Rn;function zo(){if(Sn===void 0){Sn=window,Pn=/Firefox/.test(navigator.userAgent);var r=Element.prototype,s=Node.prototype,e=Text.prototype;Cn=Ct(s,"firstChild").get,Rn=Ct(s,"nextSibling").get,nn(r)&&(r.__click=void 0,r.__className=void 0,r.__attributes=null,r.__style=void 0,r.__e=void 0),nn(e)&&(e.__t=void 0)}}function ut(r=""){return document.createTextNode(r)}function hi(r){return Cn.call(r)}function Vt(r){return Rn.call(r)}function ee(r,s){return hi(r)}function Gt(r,s=!1){{var e=hi(r);return e instanceof Comment&&e.data===""?Vt(e):e}}function ye(r,s=1,e=!1){let t=r;for(;s--;)t=Vt(t);return t}function Ho(r){r.textContent=""}function Dn(){return!1}function No(r,s){if(s){const e=document.body;r.autofocus=!0,mt(()=>{document.activeElement===e&&r.focus()})}}let In=!1;function Uo(){In||(In=!0,document.addEventListener("reset",r=>{Promise.resolve().then(()=>{if(!r.defaultPrevented)for(const s of r.target.elements)s.__on_r?.()})},{capture:!0}))}function ci(r){var s=te,e=ne;ke(null),qe(null);try{return r()}finally{ke(s),qe(e)}}function Wo(r,s,e,t=e){r.addEventListener(s,()=>ci(e));const i=r.__on_r;i?r.__on_r=()=>{i(),t(!0)}:r.__on_r=()=>t(!0),Uo()}function jo(r){ne===null&&(te===null&&Jr(),Qr()),Tt&&Kr()}function Vo(r,s){var e=s.last;e===null?s.last=s.first=r:(e.next=r,r.prev=e,s.last=r)}function Ve(r,s,e){var t=ne;t!==null&&(t.f&Fe)!==0&&(r|=Fe);var i={ctx:De,deps:null,nodes:null,f:r|Be|Ne,first:null,fn:s,last:null,next:null,parent:t,b:t&&t.b,prev:null,teardown:null,wv:0,ac:null};if(e)try{Kt(i),i.f|=Di}catch(u){throw Se(i),u}else s!==null&&wt(i);var n=i;if(e&&n.deps===null&&n.teardown===null&&n.nodes===null&&n.first===n.last&&(n.f&Rt)===0&&(n=n.first,(r&Qe)!==0&&(r&ft)!==0&&n!==null&&(n.f|=ft)),n!==null&&(n.parent=t,t!==null&&Vo(n,t),te!==null&&(te.f&Te)!==0&&(r&pt)===0)){var o=te;(o.effects??=[]).push(n)}return i}function qt(){return te!==null&&!Ge}function An(r){const s=Ve(Ri,null,!1);return Re(s,Ce),s.teardown=r,s}function Zt(r){jo();var s=ne.f,e=!te&&(s&Je)!==0&&(s&Di)===0;if(e){var t=De;(t.e??=[]).push(r)}else return kn(r)}function kn(r){return Ve(Ci|qr,r,!1)}function Go(r){je.ensure();const s=Ve(pt|Rt,r,!0);return(e={})=>new Promise(t=>{e.outro?_t(s,()=>{Se(s),t(void 0)}):(Se(s),t(void 0))})}function Xt(r){return Ve(Ci,r,!1)}function qo(r){return Ve(Ai|Rt,r,!0)}function On(r,s=0){return Ve(Ri|s,r,!0)}function be(r,s=[],e=[],t=[]){mn(t,s,e,i=>{Ve(Ri,()=>r(...i.map(b)),!0)})}function di(r,s=0){var e=Ve(Qe|s,r,!0);return e}function Bn(r,s=0){var e=Ve(sn|s,r,!0);return e}function Ae(r){return Ve(Je|Rt,r,!0)}function Fn(r){var s=r.teardown;if(s!==null){const e=Tt,t=te;Un(!0),ke(null);try{s.call(null)}finally{Un(e),ke(t)}}}function Mn(r,s=!1){var e=r.first;for(r.first=r.last=null;e!==null;){const i=e.ac;i!==null&&ci(()=>{i.abort(Dt)});var t=e.next;(e.f&pt)!==0?e.parent=null:Se(e,s),e=t}}function Zo(r){for(var s=r.first;s!==null;){var e=s.next;(s.f&Je)===0&&Se(s),s=e}}function Se(r,s=!0){var e=!1;(s||(r.f&ln)!==0)&&r.nodes!==null&&r.nodes.end!==null&&(Xo(r.nodes.start,r.nodes.end),e=!0),Mn(r,s&&!e),fi(r,0),Re(r,tt);var t=r.nodes&&r.nodes.t;if(t!==null)for(const n of t)n.stop();Fn(r);var i=r.parent;i!==null&&i.first!==null&&Ln(r),r.next=r.prev=r.teardown=r.ctx=r.deps=r.fn=r.nodes=r.ac=null}function Xo(r,s){for(;r!==null;){var e=r===s?null:Vt(r);r.remove(),r=e}}function Ln(r){var s=r.parent,e=r.prev,t=r.next;e!==null&&(e.next=t),t!==null&&(t.prev=e),s!==null&&(s.first===r&&(s.first=t),s.last===r&&(s.last=e))}function _t(r,s,e=!0){var t=[];zn(r,t,!0);var i=()=>{e&&Se(r),s&&s()},n=t.length;if(n>0){var o=()=>--n||i();for(var u of t)u.out(o)}else i()}function zn(r,s,e){if((r.f&Fe)===0){r.f^=Fe;var t=r.nodes&&r.nodes.t;if(t!==null)for(const u of t)(u.is_global||e)&&s.push(u);for(var i=r.first;i!==null;){var n=i.next,o=(i.f&ft)!==0||(i.f&Je)!==0&&(r.f&Qe)!==0;zn(i,s,o?e:!1),i=n}}}function zi(r){Hn(r,!0)}function Hn(r,s){if((r.f&Fe)!==0){r.f^=Fe,(r.f&Ce)===0&&(Re(r,Be),wt(r));for(var e=r.first;e!==null;){var t=e.next,i=(e.f&ft)!==0||(e.f&Je)!==0;Hn(e,i?s:!1),e=t}var n=r.nodes&&r.nodes.t;if(n!==null)for(const o of n)(o.is_global||s)&&o.in()}}function Nn(r,s){if(r.nodes)for(var e=r.nodes.start,t=r.nodes.end;e!==null;){var i=e===t?null:Vt(e);s.append(e),e=i}}let xt=!1;function pi(r){xt=r}let Tt=!1;function Un(r){Tt=r}let te=null,Ge=!1;function ke(r){te=r}let ne=null;function qe(r){ne=r}let rt=null;function Wn(r){te!==null&&(rt===null?rt=[r]:rt.push(r))}let Ie=null,Me=0,He=null;function $o(r){He=r}let jn=1,$t=0,Et=$t;function Vn(r){Et=r}function Gn(){return++jn}function Yt(r){var s=r.f;if((s&Be)!==0)return!0;if(s&Te&&(r.f&=~gt),(s&et)!==0){var e=r.deps;if(e!==null)for(var t=e.length,i=0;i<t;i++){var n=e[i];if(Yt(n)&&_n(n),n.wv>r.wv)return!0}(s&Ne)!==0&&ze===null&&Re(r,Ce)}return!1}function qn(r,s,e=!0){var t=r.reactions;if(t!==null&&!rt?.includes(r))for(var i=0;i<t.length;i++){var n=t[i];(n.f&Te)!==0?qn(n,s,!1):s===n&&(e?Re(n,Be):(n.f&Ce)!==0&&Re(n,et),wt(n))}}function Zn(r){var s=Ie,e=Me,t=He,i=te,n=rt,o=De,u=Ge,l=Et,a=r.f;Ie=null,Me=0,He=null,te=(a&(Je|pt))===0?r:null,rt=null,It(r.ctx),Ge=!1,Et=++$t,r.ac!==null&&(ci(()=>{r.ac.abort(Dt)}),r.ac=null);try{r.f|=Ii;var h=r.fn,c=h(),d=r.deps;if(Ie!==null){var g;if(fi(r,Me),d!==null&&Me>0)for(d.length=Me+Ie.length,g=0;g<Ie.length;g++)d[Me+g]=Ie[g];else r.deps=d=Ie;if(qt()&&(r.f&Ne)!==0)for(g=Me;g<d.length;g++)(d[g].reactions??=[]).push(r)}else d!==null&&Me<d.length&&(fi(r,Me),d.length=Me);if(dn()&&He!==null&&!Ge&&d!==null&&(r.f&(Te|et|Be))===0)for(g=0;g<He.length;g++)qn(He[g],r);return i!==null&&i!==r&&($t++,He!==null&&(t===null?t=He:t.push(...He))),(r.f&st)!==0&&(r.f^=st),c}catch(m){return pn(m)}finally{r.f^=Ii,Ie=s,Me=e,He=t,te=i,rt=n,It(o),Ge=u,Et=l}}function Yo(r,s){let e=s.reactions;if(e!==null){var t=Nr.call(e,r);if(t!==-1){var i=e.length-1;i===0?e=s.reactions=null:(e[t]=e[i],e.pop())}}e===null&&(s.f&Te)!==0&&(Ie===null||!Ie.includes(s))&&(Re(s,et),(s.f&Ne)!==0&&(s.f^=Ne,s.f&=~gt),yn(s),fi(s,0))}function fi(r,s){var e=r.deps;if(e!==null)for(var t=s;t<e.length;t++)Yo(r,e[t])}function Kt(r){var s=r.f;if((s&tt)===0){Re(r,Ce);var e=ne,t=xt;ne=r,xt=!0;try{(s&(Qe|sn))!==0?Zo(r):Mn(r),Fn(r);var i=Zn(r);r.teardown=typeof i=="function"?i:null,r.wv=jn;var n}finally{xt=t,ne=e}}}function b(r){var s=r.f,e=(s&Te)!==0;if(te!==null&&!Ge){var t=ne!==null&&(ne.f&tt)!==0;if(!t&&!rt?.includes(r)){var i=te.deps;if((te.f&Ii)!==0)r.rv<$t&&(r.rv=$t,Ie===null&&i!==null&&i[Me]===r?Me++:Ie===null?Ie=[r]:Ie.includes(r)||Ie.push(r));else{(te.deps??=[]).push(r);var n=r.reactions;n===null?r.reactions=[te]:n.includes(te)||n.push(te)}}}if(Tt){if(at.has(r))return at.get(r);if(e){var o=r,u=o.v;return((o.f&Ce)===0&&o.reactions!==null||$n(o))&&(u=Mi(o)),at.set(o,u),u}}else e&&(!ze?.has(r)||ae?.is_fork&&!qt())&&(o=r,Yt(o)&&_n(o),xt&&qt()&&(o.f&Ne)===0&&Xn(o));if(ze?.has(r))return ze.get(r);if((r.f&st)!==0)throw r.v;return r.v}function Xn(r){if(r.deps!==null){r.f^=Ne;for(const s of r.deps)(s.reactions??=[]).push(r),(s.f&Te)!==0&&(s.f&Ne)===0&&Xn(s)}}function $n(r){if(r.v===Ee)return!0;if(r.deps===null)return!1;for(const s of r.deps)if(at.has(s)||(s.f&Te)!==0&&$n(s))return!0;return!1}function gi(r){var s=Ge;try{return Ge=!0,r()}finally{Ge=s}}const Ko=-7169;function Re(r,s){r.f=r.f&Ko|s}function Qo(r){return r.endsWith("capture")&&r!=="gotpointercapture"&&r!=="lostpointercapture"}const Jo=["beforeinput","click","change","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"];function es(r){return Jo.includes(r)}const ts={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 is(r){return r=r.toLowerCase(),ts[r]??r}const ns=["touchstart","touchmove"];function rs(r){return ns.includes(r)}const Yn=new Set,Hi=new Set;function os(r,s,e,t={}){function i(n){if(t.capture||Qt.call(s,n),!n.cancelBubble)return ci(()=>e?.call(this,n))}return r.startsWith("pointer")||r.startsWith("touch")||r==="wheel"?mt(()=>{s.addEventListener(r,i,t)}):s.addEventListener(r,i,t),i}function Kn(r){for(var s=0;s<r.length;s++)Yn.add(r[s]);for(var e of Hi)e(r)}let Qn=null;function Qt(r){var s=this,e=s.ownerDocument,t=r.type,i=r.composedPath?.()||[],n=i[0]||r.target;Qn=r;var o=0,u=Qn===r&&r.__root;if(u){var l=i.indexOf(u);if(l!==-1&&(s===document||s===window)){r.__root=s;return}var a=i.indexOf(s);if(a===-1)return;l<=a&&(o=l)}if(n=i[o]||r.target,n!==s){Ur(r,"currentTarget",{configurable:!0,get(){return n||e}});var h=te,c=ne;ke(null),qe(null);try{for(var d,g=[];n!==null;){var m=n.assignedSlot||n.parentNode||n.host||null;try{var _=n["__"+t];_!=null&&(!n.disabled||r.target===n)&&_.call(n,r)}catch(y){d?g.push(y):d=y}if(r.cancelBubble||m===s||m===null)break;n=m}if(d){for(let y of g)queueMicrotask(()=>{throw y});throw d}}finally{r.__root=s,delete r.currentTarget,ke(h),qe(c)}}}function ss(r){var s=document.createElement("template");return s.innerHTML=r.replaceAll("<!>","<!---->"),s.content}function Ni(r,s){var e=ne;e.nodes===null&&(e.nodes={start:r,end:s,a:null,t:null})}function ve(r,s){var e=(s&go)!==0,t=(s&vo)!==0,i,n=!r.startsWith("<!>");return()=>{i===void 0&&(i=ss(n?r:"<!>"+r),e||(i=hi(i)));var o=t||Pn?document.importNode(i,!0):i.cloneNode(!0);if(e){var u=hi(o),l=o.lastChild;Ni(u,l)}else Ni(o,o);return o}}function Jn(){var r=document.createDocumentFragment(),s=document.createComment(""),e=ut();return r.append(s,e),Ni(s,e),r}function fe(r,s){r!==null&&r.before(s)}function _e(r,s){var e=s==null?"":typeof s=="object"?s+"":s;e!==(r.__t??=r.nodeValue)&&(r.__t=e,r.nodeValue=e+"")}function as(r,s){return ls(r,s)}const Bt=new Map;function ls(r,{target:s,anchor:e,props:t={},events:i,context:n,intro:o=!0}){zo();var u=new Set,l=c=>{for(var d=0;d<c.length;d++){var g=c[d];if(!u.has(g)){u.add(g);var m=rs(g);s.addEventListener(g,Qt,{passive:m});var _=Bt.get(g);_===void 0?(document.addEventListener(g,Qt,{passive:m}),Bt.set(g,1)):Bt.set(g,_+1)}}};l(ri(Yn)),Hi.add(l);var a=void 0,h=Go(()=>{var c=e??s.appendChild(ut());return Io(c,{pending:()=>{}},d=>{if(n){ki({});var g=De;g.c=n}i&&(t.$$events=i),a=r(d,t)||{},n&&Oi()}),()=>{for(var d of u){s.removeEventListener(d,Qt);var g=Bt.get(d);--g===0?(document.removeEventListener(d,Qt),Bt.delete(d)):Bt.set(d,g)}Hi.delete(l),c!==e&&c.parentNode?.removeChild(c)}});return Ui.set(a,h),a}let Ui=new WeakMap;function us(r,s){const e=Ui.get(r);return e?(Ui.delete(r),e(s)):Promise.resolve()}class er{anchor;#e=new Map;#t=new Map;#n=new Map;#i=new Set;#l=!0;constructor(s,e=!0){this.anchor=s,this.#l=e}#o=()=>{var s=ae;if(this.#e.has(s)){var e=this.#e.get(s),t=this.#t.get(e);if(t)zi(t),this.#i.delete(e);else{var i=this.#n.get(e);i&&(this.#t.set(e,i.effect),this.#n.delete(e),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),t=i.effect)}for(const[n,o]of this.#e){if(this.#e.delete(n),n===s)break;const u=this.#n.get(o);u&&(Se(u.effect),this.#n.delete(o))}for(const[n,o]of this.#t){if(n===e||this.#i.has(n))continue;const u=()=>{if(Array.from(this.#e.values()).includes(n)){var a=document.createDocumentFragment();Nn(o,a),a.append(ut()),this.#n.set(n,{effect:o,fragment:a})}else Se(o);this.#i.delete(n),this.#t.delete(n)};this.#l||!t?(this.#i.add(n),_t(o,u,!1)):u()}}};#r=s=>{this.#e.delete(s);const e=Array.from(this.#e.values());for(const[t,i]of this.#n)e.includes(t)||(Se(i.effect),this.#n.delete(t))};ensure(s,e){var t=ae,i=Dn();if(e&&!this.#t.has(s)&&!this.#n.has(s))if(i){var n=document.createDocumentFragment(),o=ut();n.append(o),this.#n.set(s,{effect:Ae(()=>e(o)),fragment:n})}else this.#t.set(s,Ae(()=>e(this.anchor)));if(this.#e.set(t,s),i){for(const[u,l]of this.#t)u===s?t.skipped_effects.delete(l):t.skipped_effects.add(l);for(const[u,l]of this.#n)u===s?t.skipped_effects.delete(l.effect):t.skipped_effects.add(l.effect);t.oncommit(this.#o),t.ondiscard(this.#r)}else this.#o()}}function ot(r,s,e=!1){var t=new er(r),i=e?ft:0;function n(o,u){t.ensure(o,u)}di(()=>{var o=!1;s((u,l=!0)=>{o=!0,n(l,u)}),o||n(!1,null)},i)}function Wi(r,s){return s}function hs(r,s,e){for(var t=[],i=s.length,n,o=s.length,u=0;u<i;u++){let c=s[u];_t(c,()=>{if(n){if(n.pending.delete(c),n.done.add(c),n.pending.size===0){var d=r.outrogroups;ji(ri(n.done)),d.delete(n),d.size===0&&(r.outrogroups=null)}}else o-=1},!1)}if(o===0){var l=t.length===0&&e!==null;if(l){var a=e,h=a.parentNode;Ho(h),h.append(a),r.items.clear()}ji(s,!l)}else n={pending:new Set(s),done:new Set},(r.outrogroups??=new Set).add(n)}function ji(r,s=!0){for(var e=0;e<r.length;e++)Se(r[e],s)}var tr;function vi(r,s,e,t,i,n=null){var o=r,u=new Map,l=(s&un)!==0;if(l){var a=r;o=a.appendChild(ut())}var h=null,c=wn(()=>{var E=e();return Pi(E)?E:E==null?[]:ri(E)}),d,g=!0;function m(){y.fallback=h,cs(y,d,o,s,t),h!==null&&(d.length===0?(h.f&it)===0?zi(h):(h.f^=it,Jt(h,null,o)):_t(h,()=>{h=null}))}var _=di(()=>{d=b(c);for(var E=d.length,S=new Set,P=ae,B=Dn(),k=0;k<E;k+=1){var M=d[k],L=t(M,k),W=g?null:u.get(L);W?(W.v&&Ot(W.v,M),W.i&&Ot(W.i,k),B&&P.skipped_effects.delete(W.e)):(W=ds(u,g?o:tr??=ut(),M,L,k,i,s,e),g||(W.e.f|=it),u.set(L,W)),S.add(L)}if(E===0&&n&&!h&&(g?h=Ae(()=>n(o)):(h=Ae(()=>n(tr??=ut())),h.f|=it)),!g)if(B){for(const[$,Q]of u)S.has($)||P.skipped_effects.add(Q.e);P.oncommit(m),P.ondiscard(()=>{})}else m();b(c)}),y={effect:_,items:u,outrogroups:null,fallback:h};g=!1}function cs(r,s,e,t,i){var n=(t&lo)!==0,o=s.length,u=r.items,l=r.effect.first,a,h=null,c,d=[],g=[],m,_,y,E;if(n)for(E=0;E<o;E+=1)m=s[E],_=i(m,E),y=u.get(_).e,(y.f&it)===0&&(y.nodes?.a?.measure(),(c??=new Set).add(y));for(E=0;E<o;E+=1){if(m=s[E],_=i(m,E),y=u.get(_).e,r.outrogroups!==null)for(const Q of r.outrogroups)Q.pending.delete(y),Q.done.delete(y);if((y.f&it)!==0)if(y.f^=it,y===l)Jt(y,null,e);else{var S=h?h.next:l;y===r.effect.last&&(r.effect.last=y.prev),y.prev&&(y.prev.next=y.next),y.next&&(y.next.prev=y.prev),ht(r,h,y),ht(r,y,S),Jt(y,S,e),h=y,d=[],g=[],l=h.next;continue}if((y.f&Fe)!==0&&(zi(y),n&&(y.nodes?.a?.unfix(),(c??=new Set).delete(y))),y!==l){if(a!==void 0&&a.has(y)){if(d.length<g.length){var P=g[0],B;h=P.prev;var k=d[0],M=d[d.length-1];for(B=0;B<d.length;B+=1)Jt(d[B],P,e);for(B=0;B<g.length;B+=1)a.delete(g[B]);ht(r,k.prev,M.next),ht(r,h,k),ht(r,M,P),l=P,h=M,E-=1,d=[],g=[]}else a.delete(y),Jt(y,l,e),ht(r,y.prev,y.next),ht(r,y,h===null?r.effect.first:h.next),ht(r,h,y),h=y;continue}for(d=[],g=[];l!==null&&l!==y;)(a??=new Set).add(l),g.push(l),l=l.next;if(l===null)continue}(y.f&it)===0&&d.push(y),h=y,l=y.next}if(r.outrogroups!==null){for(const Q of r.outrogroups)Q.pending.size===0&&(ji(ri(Q.done)),r.outrogroups?.delete(Q));r.outrogroups.size===0&&(r.outrogroups=null)}if(l!==null||a!==void 0){var L=[];if(a!==void 0)for(y of a)(y.f&Fe)===0&&L.push(y);for(;l!==null;)(l.f&Fe)===0&&l!==r.fallback&&L.push(l),l=l.next;var W=L.length;if(W>0){var $=(t&un)!==0&&o===0?e:null;if(n){for(E=0;E<W;E+=1)L[E].nodes?.a?.measure();for(E=0;E<W;E+=1)L[E].nodes?.a?.fix()}hs(r,L,$)}}n&&mt(()=>{if(c!==void 0)for(y of c)y.nodes?.a?.apply()})}function ds(r,s,e,t,i,n,o,u){var l=(o&so)!==0?(o&uo)===0?Fo(e,!1,!1):yt(e):null,a=(o&ao)!==0?yt(i):null;return{v:l,i:a,e:Ae(()=>(n(s,l??e,a??i,u),()=>{r.delete(t)}))}}function Jt(r,s,e){if(r.nodes)for(var t=r.nodes.start,i=r.nodes.end,n=s&&(s.f&it)===0?s.nodes.start:e;t!==null;){var o=Vt(t);if(n.before(t),t===i)return;t=o}}function ht(r,s,e){s===null?r.effect.first=e:s.next=e,e===null?r.effect.last=s:e.prev=s}function ir(r,s,...e){var t=new er(r);di(()=>{const i=s()??null;t.ensure(i,i&&(n=>i(n,...e)))},ft)}function ps(r,s,e){Xt(()=>{var t=gi(()=>s(r,e?.())||{});if(t?.destroy)return()=>t.destroy()})}function fs(r,s){var e=void 0,t;Bn(()=>{e!==(e=s())&&(t&&(Se(t),t=null),e&&(t=Ae(()=>{Xt(()=>e(r))})))})}function nr(r){var s,e,t="";if(typeof r=="string"||typeof r=="number")t+=r;else if(typeof r=="object")if(Array.isArray(r)){var i=r.length;for(s=0;s<i;s++)r[s]&&(e=nr(r[s]))&&(t&&(t+=" "),t+=e)}else for(e in r)r[e]&&(t&&(t+=" "),t+=e);return t}function gs(){for(var r,s,e=0,t="",i=arguments.length;e<i;e++)(r=arguments[e])&&(s=nr(r))&&(t&&(t+=" "),t+=s);return t}function vs(r){return typeof r=="object"?gs(r):r??""}const rr=[...`
|
|
2
|
-
\r\f \v\uFEFF`];function ms(r,s,e){var t=r==null?"":""+r;if(s&&(t=t?t+" "+s:s),e){for(var i in e)if(e[i])t=t?t+" "+i:i;else if(t.length)for(var n=i.length,o=0;(o=t.indexOf(i,o))>=0;){var u=o+n;(o===0||rr.includes(t[o-1]))&&(u===t.length||rr.includes(t[u]))?t=(o===0?"":t.substring(0,o))+t.substring(u+1):o=u}}return t===""?null:t}function or(r,s=!1){var e=s?" !important;":";",t="";for(var i in r){var n=r[i];n!=null&&n!==""&&(t+=" "+i+": "+n+e)}return t}function Vi(r){return r[0]!=="-"||r[1]!=="-"?r.toLowerCase():r}function ws(r,s){if(s){var e="",t,i;if(Array.isArray(s)?(t=s[0],i=s[1]):t=s,r){r=String(r).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var n=!1,o=0,u=!1,l=[];t&&l.push(...Object.keys(t).map(Vi)),i&&l.push(...Object.keys(i).map(Vi));var a=0,h=-1;const _=r.length;for(var c=0;c<_;c++){var d=r[c];if(u?d==="/"&&r[c-1]==="*"&&(u=!1):n?n===d&&(n=!1):d==="/"&&r[c+1]==="*"?u=!0:d==='"'||d==="'"?n=d:d==="("?o++:d===")"&&o--,!u&&n===!1&&o===0){if(d===":"&&h===-1)h=c;else if(d===";"||c===_-1){if(h!==-1){var g=Vi(r.substring(a,h).trim());if(!l.includes(g)){d!==";"&&c++;var m=r.substring(a,c).trim();e+=" "+m+";"}}a=c+1,h=-1}}}}return t&&(e+=or(t)),i&&(e+=or(i,!0)),e=e.trim(),e===""?null:e}return r==null?null:String(r)}function ei(r,s,e,t,i,n){var o=r.__className;if(o!==e||o===void 0){var u=ms(e,t,n);u==null?r.removeAttribute("class"):s?r.className=u:r.setAttribute("class",u),r.__className=e}else if(n&&i!==n)for(var l in n){var a=!!n[l];(i==null||a!==!!i[l])&&r.classList.toggle(l,a)}return n}function Gi(r,s={},e,t){for(var i in e){var n=e[i];s[i]!==n&&(e[i]==null?r.style.removeProperty(i):r.style.setProperty(i,n,t))}}function qi(r,s,e,t){var i=r.__style;if(i!==s){var n=ws(s,t);n==null?r.removeAttribute("style"):r.style.cssText=n,r.__style=s}else t&&(Array.isArray(t)?(Gi(r,e?.[0],t[0]),Gi(r,e?.[1],t[1],"important")):Gi(r,e,t));return t}function mi(r,s,e=!1){if(r.multiple){if(s==null)return;if(!Pi(s))return yo();for(var t of r.options)t.selected=s.includes(ti(t));return}for(t of r.options){var i=ti(t);if(Lo(i,s)){t.selected=!0;return}}(!e||s!==void 0)&&(r.selectedIndex=-1)}function sr(r){var s=new MutationObserver(()=>{mi(r,r.__value)});s.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),An(()=>{s.disconnect()})}function ys(r,s,e=s){var t=new WeakSet,i=!0;Wo(r,"change",n=>{var o=n?"[selected]":":checked",u;if(r.multiple)u=[].map.call(r.querySelectorAll(o),ti);else{var l=r.querySelector(o)??r.querySelector("option:not([disabled])");u=l&&ti(l)}e(u),ae!==null&&t.add(ae)}),Xt(()=>{var n=s();if(r===document.activeElement){var o=ai??ae;if(t.has(o))return}if(mi(r,n,i),i&&n===void 0){var u=r.querySelector(":checked");u!==null&&(n=ti(u),e(n))}r.__value=n,i=!1}),sr(r)}function ti(r){return"__value"in r?r.__value:r.value}const Ft=Symbol("class"),ii=Symbol("style"),ar=Symbol("is custom element"),lr=Symbol("is html");function _s(r,s){s?r.hasAttribute("selected")||r.setAttribute("selected",""):r.removeAttribute("selected")}function Ze(r,s,e,t){var i=hr(r);i[s]!==(i[s]=e)&&(s==="loading"&&(r[Xr]=e),e==null?r.removeAttribute(s):typeof e!="string"&&dr(r).includes(s)?r[s]=e:r.setAttribute(s,e))}function xs(r,s,e,t,i=!1,n=!1){var o=hr(r),u=o[ar],l=!o[lr],a=s||{},h=r.tagName==="OPTION";for(var c in s)c in e||(e[c]=null);e.class?e.class=vs(e.class):(t||e[Ft])&&(e.class=null),e[ii]&&(e.style??=null);var d=dr(r);for(const P in e){let B=e[P];if(h&&P==="value"&&B==null){r.value=r.__value="",a[P]=B;continue}if(P==="class"){var g=r.namespaceURI==="http://www.w3.org/1999/xhtml";ei(r,g,B,t,s?.[Ft],e[Ft]),a[P]=B,a[Ft]=e[Ft];continue}if(P==="style"){qi(r,B,s?.[ii],e[ii]),a[P]=B,a[ii]=e[ii];continue}var m=a[P];if(!(B===m&&!(B===void 0&&r.hasAttribute(P)))){a[P]=B;var _=P[0]+P[1];if(_!=="$$")if(_==="on"){const k={},M="$$"+P;let L=P.slice(2);var y=es(L);if(Qo(L)&&(L=L.slice(0,-7),k.capture=!0),!y&&m){if(B!=null)continue;r.removeEventListener(L,a[M],k),a[M]=null}if(B!=null)if(y)r[`__${L}`]=B,Kn([L]);else{let W=function($){a[P].call(this,$)};a[M]=os(L,r,W,k)}else y&&(r[`__${L}`]=void 0)}else if(P==="style")Ze(r,P,B);else if(P==="autofocus")No(r,!!B);else if(!u&&(P==="__value"||P==="value"&&B!=null))r.value=r.__value=B;else if(P==="selected"&&h)_s(r,B);else{var E=P;l||(E=is(E));var S=E==="defaultValue"||E==="defaultChecked";if(B==null&&!u&&!S)if(o[P]=null,E==="value"||E==="checked"){let k=r;const M=s===void 0;if(E==="value"){let L=k.defaultValue;k.removeAttribute(E),k.defaultValue=L,k.value=k.__value=M?L:null}else{let L=k.defaultChecked;k.removeAttribute(E),k.defaultChecked=L,k.checked=M?L:!1}}else r.removeAttribute(P);else S||d.includes(E)&&(u||typeof B!="string")?(r[E]=B,E in o&&(o[E]=Ee)):typeof B!="function"&&Ze(r,E,B)}}}return a}function ur(r,s,e=[],t=[],i=[],n,o=!1,u=!1){mn(i,e,t,l=>{var a=void 0,h={},c=r.nodeName==="SELECT",d=!1;if(Bn(()=>{var m=s(...l.map(b)),_=xs(r,a,m,n,o,u);d&&c&&"value"in m&&mi(r,m.value);for(let E of Object.getOwnPropertySymbols(h))m[E]||Se(h[E]);for(let E of Object.getOwnPropertySymbols(m)){var y=m[E];E.description===wo&&(!a||y!==a[E])&&(h[E]&&Se(h[E]),h[E]=Ae(()=>fs(r,()=>y))),_[E]=y}a=_}),c){var g=r;Xt(()=>{mi(g,a.value,!0),sr(g)})}d=!0})}function hr(r){return r.__attributes??={[ar]:r.nodeName.includes("-"),[lr]:r.namespaceURI===mo}}var cr=new Map;function dr(r){var s=r.getAttribute("is")||r.nodeName,e=cr.get(s);if(e)return e;cr.set(s,e=[]);for(var t,i=r,n=Element.prototype;n!==i;){t=Wr(i);for(var o in t)t[o].set&&e.push(o);i=tn(i)}return e}function pr(r,s){return r===s||r?.[vt]===s}function wi(r={},s,e,t){return Xt(()=>{var i,n;return On(()=>{i=n,n=[],gi(()=>{r!==e(...n)&&(s(r,...n),i&&pr(e(...i),r)&&s(null,...i))})}),()=>{mt(()=>{n&&pr(e(...n),r)&&s(null,...n)})}}),r}let yi=!1;function Ts(r){var s=yi;try{return yi=!1,[r(),yi]}finally{yi=s}}const Es={get(r,s){if(!r.exclude.includes(s))return r.props[s]},set(r,s){return!1},getOwnPropertyDescriptor(r,s){if(!r.exclude.includes(s)&&s in r.props)return{enumerable:!0,configurable:!0,value:r.props[s]}},has(r,s){return r.exclude.includes(s)?!1:s in r.props},ownKeys(r){return Reflect.ownKeys(r.props).filter(s=>!r.exclude.includes(s))}};function fr(r,s,e){return new Proxy({props:r,exclude:s},Es)}function Oe(r,s,e,t){var i=(e&po)!==0,n=(e&fo)!==0,o=t,u=!0,l=()=>(u&&(u=!1,o=n?gi(t):t),o),a;if(i){var h=vt in r||Zr in r;a=Ct(r,s)?.set??(h&&s in r?S=>r[s]=S:void 0)}var c,d=!1;i?[c,d]=Ts(()=>r[s]):c=r[s],c===void 0&&t!==void 0&&(c=l(),a&&(to(),a(c)));var g;if(g=()=>{var S=r[s];return S===void 0?l():(u=!0,S)},(e&co)===0)return g;if(a){var m=r.$$legacy;return(function(S,P){return arguments.length>0?((!P||m||d)&&a(P?g():S),S):g()})}var _=!1,y=((e&ho)!==0?ui:wn)(()=>(_=!1,g()));i&&b(y);var E=ne;return(function(S,P){if(arguments.length>0){const B=P?b(y):i?lt(S):S;return Z(y,B),_=!0,o!==void 0&&(o=B),S}return Tt&&_||(E.f&tt)!==0?y.v:b(y)})}const bs=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-.]+))?(?:\+[0-9A-Za-z-.]+)?$/;function _i(r){const s=bs.exec(r.trim());if(!s)return null;const[,e,t,i,n]=s,o=n?n.split(".").map(u=>/^\d+$/.test(u)?Number(u):u):[];return{major:Number(e),minor:Number(t),patch:Number(i),prerelease:o}}function Ss(r,s){return r.major-s.major||r.minor-s.minor||r.patch-s.patch}function Ps(r,s){if(r.prerelease.length===0&&s.prerelease.length===0)return 0;if(r.prerelease.length===0)return 1;if(s.prerelease.length===0)return-1;const e=Math.max(r.prerelease.length,s.prerelease.length);for(let t=0;t<e;t++){const i=r.prerelease[t],n=s.prerelease[t];if(i===void 0)return-1;if(n===void 0)return 1;if(i===n)continue;const o=typeof i=="number",u=typeof n=="number";return o&&u?i<n?-1:1:o?-1:u?1:String(i)<String(n)?-1:1}return 0}function Cs(r,s){return Ss(r,s)||Ps(r,s)}function Rs(r){return r.major>0?{major:r.major+1,minor:0,patch:0,prerelease:[]}:r.minor>0?{major:0,minor:r.minor+1,patch:0,prerelease:[]}:{major:0,minor:0,patch:r.patch+1,prerelease:[]}}function Ds(r){if(r===""||r==="*"||r==="x"||r==="X")return[];let s;if(s=/^\^\s*(.+)$/.exec(r)){const e=_i(s[1]??"");return e?[{op:">=",ver:e},{op:"<",ver:Rs(e)}]:null}if(s=/^~\s*(.+)$/.exec(r)){const e=_i(s[1]??"");return e?[{op:">=",ver:e},{op:"<",ver:{major:e.major,minor:e.minor+1,patch:0,prerelease:[]}}]:null}if(s=/^(>=|<=|>|<|=)?\s*(.+)$/.exec(r)){const e=_i(s[2]??"");return e?[{op:s[1]??"=",ver:e}]:null}return null}function Is(r,s){const e=Cs(r,s.ver);switch(s.op){case"<":return e<0;case"<=":return e<=0;case">":return e>0;case">=":return e>=0;case"=":return e===0}}function As(r,s){const e=s.trim();if(e===""||e==="*"||e==="x")return!0;const t=e.split(/\s+/).filter(Boolean);for(const i of t){const n=Ds(i);if(n===null||!n.every(o=>Is(r,o)))return!1}return!0}function gr(r,s){const e=_i(r);if(!e)return!1;const t=s.split("||").map(i=>i.trim()).filter(i=>i.length>0);return t.length===0?!0:t.some(i=>As(e,i))}class Zi extends Error{code="PLUGIN_INCOMPATIBLE";pluginName;pluginVersion;reasons;constructor(s,e,t){super(ks(s,e,t)),this.name="PluginCompatibilityError",this.pluginName=s,this.pluginVersion=e,this.reasons=t,Object.setPrototypeOf(this,Zi.prototype)}}function ks(r,s,e){const t=e.map(i=>` - ${i.message}`).join(`
|
|
3
|
-
`);return`Plugin "${r}"@${s} cannot activate — incompatible with this viewer:
|
|
4
|
-
${t}
|
|
5
|
-
Update the plugin or the core viewer so their declared ranges and capabilities overlap.`}function Os(r,s){const e=[];gr(s.coreVersion,r.coreRange)||e.push({kind:"core",required:r.coreRange,actual:s.coreVersion,message:`requires core ${r.coreRange} but this viewer is core ${s.coreVersion}`}),gr(s.pluginApiVersion,r.pluginApiRange)||e.push({kind:"pluginApi",required:r.pluginApiRange,actual:s.pluginApiVersion,message:`requires plugin API ${r.pluginApiRange} but this viewer provides plugin API ${s.pluginApiVersion}`});const t=new Set(s.capabilities);for(const i of r.requiredCapabilities)t.has(i)||e.push({kind:"capability",required:i,actual:s.capabilities.join(", ")||"(none)",message:`requires capability "${i}" which this viewer does not provide (has: ${s.capabilities.join(", ")||"none"})`});return e}function Bs(r,s){const e=Os(r,s);if(e.length>0)throw new Zi(r.name,r.version,e)}let Fs=!1;function Ms(){return Fs}const vr=["animation","viewport-change","animation-finish"];function Ls(r,s={}){let e=!1,t=0,i=0;const n=new Set,o=new Set;let u=null;const l=()=>{i++;for(const g of[...o])try{g()}catch(m){s.onListenerError&&s.onListenerError(m)}},a=()=>{const g=!e&&o.size>0?r.osdViewer??null:null;if(g!==u){if(u)for(const m of vr)u.removeHandler(m,l);if(u=g,u)for(const m of vr)u.addHandler(m,l)}},h=r.subscribe(()=>{t++,a();for(const g of[...n])g();for(const g of[...o])g()},s.onListenerError);function c(g,m={}){const _=m.equals??Object.is,y=m.cadence??"state",E=y==="frame"?o:n;let S=-1,P=!1,B,k=null;const M=()=>y==="frame"?t+i:t,L=()=>y==="state"&&!0&&!0&&Ms(),W=()=>g(r),$=()=>{let q;try{q=W()}catch(V){k={error:V};return}if(P){let V;try{V=_(B,q)}catch(re){k={error:re};return}if(V){k=null;return}}B=q,P=!0,k=null},Q=()=>{if(k)throw k.error;return B};return{cadence:y,get version(){return M()},read(){const q=M();return(S!==q||L())&&(S=q,$()),Q()},recompute(){return S=M(),$(),Q()},subscribe(q){if(e)return()=>{};E.add(q),a();let V=!1;return()=>{V||(V=!0,E.delete(q),a())}}}}return{selectors:{select(g,m=Object.is){const _=c(g,{equals:m});return{get:()=>_.read(),subscribe(y){if(e)return()=>{};let E=_.read();return _.subscribe(()=>{let S;try{S=_.read()}catch(P){s.onProjectionError?.(P);return}m(E,S)||(E=S,y(S))})}}}},createProjection:c,dispose(){e||(e=!0,n.clear(),o.clear(),a(),h())}}}const Mt=()=>{};function zs(){return{install(r,s){return Mt}}}function Hs(){return{current:"en",t(r,s){return r},subscribe(r){return Mt}}}function Ns(){return{renderIcon(r,s){return Mt}}}function Us(r){return{id:r??"",isOpen:!0,target:"panel",open:Mt,close:Mt,toggle:Mt}}function Ws(r){const s=new Set;return{service:{install(e,t){const i=r.install(e,t);let n=!1;const o=()=>{n||(n=!0,s.delete(o),i())};return s.add(o),o}},releaseAll(){for(const e of[...s])e();s.clear()}}}function js(r){const s=new Set;return{service:{get current(){return r.current},t(e,t){return r.t(e,t)},subscribe(e){const t=r.subscribe(e);let i=!1;const n=()=>{i||(i=!0,s.delete(n),t())};return s.add(n),n}},releaseAll(){for(const e of[...s])e();s.clear()}}}const Vs={deactivate(){}};function Gs(r,s){const e=s.reportError;let t,i,n,o;try{Bs(r,s),t=Ls(s.viewerState,{onProjectionError:e?d=>e({phase:"command",error:d}):void 0,onListenerError:e?d=>e({phase:"subscription",error:d}):void 0}),i=Ws(s.styles??zs()),n=js(s.locale??Hs()),o={viewerState:s.viewerState,selectors:t.selectors,surface:s.surface??Us(r.uiId??r.name),styles:i.service,locale:n.service,ui:s.ui??Ns()}}catch(d){if(t?.dispose(),i?.releaseAll(),n?.releaseAll(),e)return e({phase:"setup",error:d}),Vs;throw d}const u=[],l=i,a=n,h=t;try{const d=r.view.mount(s.container,o);typeof d=="function"&&u.push(d)}catch(d){if(!e)throw l.releaseAll(),a.releaseAll(),h.dispose(),d;e({phase:"mount",error:d})}u.push(()=>l.releaseAll()),u.push(()=>a.releaseAll()),u.push(()=>h.dispose());let c=!1;return{deactivate(){if(!c){c=!0;for(let d=u.length-1;d>=0;d--)try{u[d]?.()}catch(g){e?e({phase:"cleanup",error:g}):console.error(`[triiiceratops] Plugin "${r.name}" cleanup threw during deactivation; teardown continues.`,g)}u.length=0}}}}const qs="triiiceratops-plugin";function Zs(r){const s={name:r.name,title:r.title,uiId:r.uiId,version:r.version,coreRange:r.coreRange,pluginApiRange:r.pluginApiRange,requiredCapabilities:r.requiredCapabilities??[],icon:r.icon,target:r.target??"panel",dismiss:r.dismiss,catalog:r.catalog,view:r.view};return{kind:qs,...s,activate(e){return Gs(s,e)}}}class Xs extends Error{name="SvgIconError";constructor(s){super(`svgIcon: ${s}`)}}const $s="0 0 24 24";function bt(r,s){if(!r)throw new Xs(s)}const Ys=/<svg\b[^>]*>/i;function Ks(r){bt(typeof r=="string","expected an SVG string.");const s=r.trim();bt(s.length>0,"received an empty string.");const e=Ys.exec(s);bt(e!==null,"the markup must contain an <svg> root element."),bt(!/<script[\s/>]/i.test(s),"<script> elements are not allowed in plugin icons."),bt(!/<foreignObject[\s/>]/i.test(s),"<foreignObject> is not allowed in plugin icons."),bt(!/\son[a-z]+\s*=/i.test(s),"on* event-handler attributes (e.g. onload, onclick) are not allowed in plugin icons.");for(const u of s.matchAll(/(?:xlink:)?href\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/gi)){const l=(u[1]??u[2]??u[3]??"").trim();bt(l.startsWith("#"),`external href/xlink:href URLs are not allowed in plugin icons (found "${l}"); only internal "#id" references are.`)}const t=e[0],i=/\bviewBox\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t);let n=(i?.[1]??i?.[2])?.trim();if(!n){const u=/\bwidth\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t),l=/\bheight\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t),a=parseFloat(u?.[1]??u?.[2]??""),h=parseFloat(l?.[1]??l?.[2]??"");n=Number.isFinite(a)&&Number.isFinite(h)?`0 0 ${a} ${h}`:$s}let o="";if(!/\/\s*>$/.test(t)){const u=e.index+t.length,l=s.lastIndexOf("</svg>");o=(l>=u?s.slice(u,l):s.slice(u)).trim()}return{kind:"svg",inner:o,viewBox:n}}function Qs(r,s){return{STYLES:r,STYLE_ID:s}}function Js(r,s,e,t,i){const n={pluginName:s,pluginVersion:e,phase:"command",error:t,retry:i};r.dispatchEvent(new CustomEvent("pluginerror",{detail:n,bubbles:!0,composed:!0}))}const ea=".btn.svelte-sgoebi{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-sgoebi:hover{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}}.btn.svelte-sgoebi:focus-visible{isolation:isolate;outline-width:2px;outline-style:solid}.btn.svelte-sgoebi: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-sgoebi{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}.btn.svelte-sgoebi:disabled,.btn[disabled].svelte-sgoebi{pointer-events:none;--btn-border: #0000;--btn-fg: color-mix(in oklch, var(--tri-content) 20%, #0000)}.btn.svelte-sgoebi:disabled:not(.ghost):not(.outline),.btn[disabled].svelte-sgoebi:not(.ghost):not(.outline){background-color:color-mix(in oklab,var(--tri-content) 10%,transparent);box-shadow:none}.circle.svelte-sgoebi{width:var(--size);height:var(--size);border-radius:3.40282e38px;padding-inline:0}.square.svelte-sgoebi{width:var(--size);height:var(--size);padding-inline:0}.ghost.svelte-sgoebi{--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-sgoebi:hover{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent)}}.ghost.svelte-sgoebi:active:not(.active),.ghost.active.svelte-sgoebi{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent);--btn-border: transparent}.outline.svelte-sgoebi: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-1hwvamm{display:inline-flex;width:clamp(3rem,20rem,100%);max-width:100%}.native-select.svelte-1hwvamm{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-1hwvamm{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-1hwvamm{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-label.placeholder.svelte-1hwvamm{color:color-mix(in oklab,var(--tri-content) 55%,transparent)}.select.svelte-1hwvamm:hover:not(:disabled){--input-color: color-mix(in oklab, var(--tri-content) 40%, #0000)}.select.svelte-1hwvamm:focus-visible,.select.open.svelte-1hwvamm{--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-1hwvamm:is(:where(.svelte-1hwvamm):disabled,[disabled]:where(.svelte-1hwvamm)){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-1hwvamm{box-shadow:none;background-color:#0000;border-color:#0000;transition:background-color .2s}.ghost.svelte-1hwvamm:hover:not(:disabled){background-color:color-mix(in oklab,var(--tri-content) 8%,transparent)}.ghost.svelte-1hwvamm:focus-visible,.ghost.open.svelte-1hwvamm{background-color:var(--tri-input-bg);color:var(--tri-content)}.listbox.svelte-1hwvamm{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-1hwvamm:not(:popover-open){display:none}.option.svelte-1hwvamm{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-1hwvamm{background-color:color-mix(in oklab,var(--tri-content) 12%,#0000)}.option.selected.svelte-1hwvamm{background-color:color-mix(in oklab,var(--tri-color-primary) 90%,#0000);color:var(--tri-color-primary-content)}.option.selected.active.svelte-1hwvamm{background-color:var(--tri-color-primary)}.option[aria-disabled=true].svelte-1hwvamm{opacity:.5;cursor:not-allowed;color:color-mix(in oklab,var(--tri-content) 55%,transparent)}\n",ta={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."}},mr=Symbol("triiiceratops:plugin-image-download"),wr=Ks('<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>'),ia="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(ia);var na=ve("<button><!></button>");function ra(r,s){let e=Oe(s,"variant",3,"default"),t=Oe(s,"size",3,"md"),i=Oe(s,"circle",3,!1),n=Oe(s,"square",3,!1),o=Oe(s,"ghost",3,!1),u=Oe(s,"outline",3,!1),l=Oe(s,"active",3,!1),a=Oe(s,"class",3,""),h=Oe(s,"style",3,""),c=fr(s,["$$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);"},g={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 m=le(()=>`${g[t()]}${d[e()]}${h()}`);var _=na();ur(_,()=>({class:`btn ${a()??""}`,style:b(m),...c,[Ft]:{circle:i(),square:n(),ghost:o(),outline:u(),active:l()}}),void 0,void 0,void 0,"svelte-sgoebi");var y=ee(_);ir(y,()=>s.children??rn),fe(r,_)}let oa=0;var sa=ve('<div role="option"> </div>'),aa=ve('<div><select><!></select> <button type="button" role="combobox" aria-haspopup="listbox"><span> </span></button> <div role="listbox" class="listbox svelte-1hwvamm" popover="manual" tabindex="-1"></div></div>');function xi(r,s){ki(s,!0);let e=Oe(s,"value",15),t=Oe(s,"size",3,"md"),i=Oe(s,"ghost",3,!1),n=Oe(s,"class",3,""),o=Oe(s,"style",3,""),u=fr(s,["$$slots","$$events","$$legacy","value","size","ghost","class","style","children"]);const l={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 a=le(()=>`--size:${l[t()]};${o()}`);const h=`tri-listbox-${oa++}`;let c=ue(null),d=ue(null),g=ue(null),m=ue(lt([])),_=ue(!1),y=ue(-1),E=le(()=>!!s.disabled),S=le(()=>e()==null?"":String(e())),P=le(()=>b(m).find(z=>z.value===b(S))??b(m)[0]);function B(){b(c)&&Z(m,Array.from(b(c).querySelectorAll("option")).map(z=>({value:z.value,label:(z.textContent??"").trim(),disabled:z.disabled})),!0)}Zt(()=>{if(!b(c))return;B();const z=new MutationObserver(()=>B());return z.observe(b(c),{childList:!0,subtree:!0,characterData:!0,attributes:!0}),()=>z.disconnect()});function k(z){const ie=b(m)[z];!b(c)||!ie||ie.disabled||(b(c).value=ie.value,b(c).dispatchEvent(new Event("input",{bubbles:!0})),b(c).dispatchEvent(new Event("change",{bubbles:!0})),Q())}function M(){if(!b(d)||!b(g))return;const z=b(d).getBoundingClientRect();b(g).style.minWidth=`${z.width}px`,b(g).style.left=`${z.left}px`;const ie=b(g).offsetHeight,ce=window.innerHeight-z.bottom;ce<ie&&z.top>ce?b(g).style.top=`${Math.max(4,z.top-ie-4)}px`:b(g).style.top=`${z.bottom+4}px`}function L(){b(g)?.children[b(y)]?.scrollIntoView({block:"nearest"})}function W(z){const ie=z.composedPath();b(d)&&ie.includes(b(d))||b(g)&&ie.includes(b(g))||Q()}function $(){b(E)||b(_)||!b(g)||(Z(_,!0),b(g).showPopover(),M(),Z(y,b(m).findIndex(z=>z.value===b(S)),!0),b(y)<0&&Z(y,b(m).findIndex(z=>!z.disabled),!0),L(),window.addEventListener("scroll",M,!0),window.addEventListener("resize",M),document.addEventListener("pointerdown",W,!0))}function Q(){b(_)&&(Z(_,!1),b(g)?.hidePopover(),window.removeEventListener("scroll",M,!0),window.removeEventListener("resize",M),document.removeEventListener("pointerdown",W,!0),b(d)?.focus())}function q(){b(_)?Q():$()}function V(z){if(!b(m).length)return;let ie=b(y);for(let ce=0;ce<b(m).length;ce++)if(ie=(ie+z+b(m).length)%b(m).length,!b(m)[ie]?.disabled){Z(y,ie,!0),L();return}}function re(z){const ie=z==="start"?b(m).map((ce,we)=>we):b(m).map((ce,we)=>b(m).length-1-we);for(const ce of ie)if(!b(m)[ce]?.disabled){Z(y,ce,!0),L();return}}let he="",de;function pe(z){he+=z.toLowerCase(),clearTimeout(de),de=setTimeout(()=>he="",600);const ie=b(m).findIndex(ce=>!ce.disabled&&ce.label.toLowerCase().startsWith(he));ie>=0&&(Z(y,ie,!0),L())}function ge(z){if(!b(E)){if(!b(_)){["ArrowDown","ArrowUp","Enter"," "].includes(z.key)&&(z.preventDefault(),$());return}switch(z.key){case"ArrowDown":z.preventDefault(),V(1);break;case"ArrowUp":z.preventDefault(),V(-1);break;case"Home":z.preventDefault(),re("start");break;case"End":z.preventDefault(),re("end");break;case"Enter":case" ":z.preventDefault(),b(y)>=0&&k(b(y));break;case"Escape":z.preventDefault(),Q();break;case"Tab":Q();break;default:z.key.length===1&&!z.metaKey&&!z.ctrlKey&&pe(z.key)}}}var me=aa(),Pe=ee(me);ur(Pe,()=>({class:"native-select",tabindex:"-1","aria-hidden":"true",...u}),void 0,void 0,void 0,"svelte-1hwvamm");var Le=ee(Pe);ir(Le,()=>s.children??rn),wi(Pe,z=>Z(c,z),()=>b(c));var xe=ye(Pe,2);let Xe;xe.__click=q,xe.__keydown=ge;var Y=ee(xe);let $e;var ct=ee(Y);wi(xe,z=>Z(d,z),()=>b(d));var Ue=ye(xe,2);vi(Ue,23,()=>b(m),(z,ie)=>z.value+"\0"+ie,(z,ie,ce)=>{var we=sa();let Ye;we.__click=()=>k(b(ce)),we.__pointermove=()=>Z(y,b(ce),!0);var St=ee(we);be(()=>{Ze(we,"id",`${h}-opt-${b(ce)??""}`),Ye=ei(we,1,"option svelte-1hwvamm",null,Ye,{active:b(ce)===b(y),selected:b(ie).value===b(S)}),Ze(we,"aria-selected",b(ie).value===b(S)),Ze(we,"aria-disabled",b(ie).disabled),_e(St,b(ie).label)}),fe(z,we)}),wi(Ue,z=>Z(g,z),()=>b(g)),be(()=>{ei(me,1,`select-wrapper ${n()??""}`,"svelte-1hwvamm"),qi(me,o()),Xe=ei(xe,1,"select svelte-1hwvamm",null,Xe,{ghost:i(),open:b(_)}),qi(xe,b(a)),xe.disabled=b(E),Ze(xe,"aria-expanded",b(_)),Ze(xe,"aria-controls",h),Ze(xe,"aria-activedescendant",b(_)&&b(y)>=0?`${h}-opt-${b(y)}`:void 0),Ze(xe,"aria-label",u["aria-label"]),$e=ei(Y,1,"select-label svelte-1hwvamm",null,$e,{placeholder:b(P)?.disabled}),_e(ct,b(P)?.label??""),Ze(Ue,"id",h)}),ys(Pe,e),fe(r,me),Oi()}Kn(["click","keydown","pointermove"]);function Lt(r){var s,e;return r?.id||r?.["@id"]||((s=r?.__jsonld)==null?void 0:s.id)||((e=r?.__jsonld)==null?void 0:e["@id"])||(typeof r?.getId=="function"?r.getId():null)||null}function zt(r){return Lt(r)||(typeof r?.getCanvasId=="function"?r.getCanvasId():null)||(typeof r?.getId=="function"?r.getId():null)||""}function la(r){var s;const e=r?.behavior||((s=r?.__jsonld)==null?void 0:s.behavior)||(typeof r?.getBehavior=="function"?r.getBehavior():[]);return e?(Array.isArray(e)?e:[e]).map(t=>{const i=String(t).trim().toLowerCase(),n=i.split(/[#/:]/);return n[n.length-1]||i}):[]}function yr(r){const s=la(r);return s.includes("non-paged")||s.includes("facing-pages")}function ua(r,s){const e=[];for(let t=0;t<Math.min(s,r.length);t++){const i=r[t],n=zt(i);e.push({startIndex:t,endIndex:t,entries:n?[{canvasId:n,canvas:i}]:[]})}for(let t=s;t<r.length;){const i=r[t],n=zt(i),o=r[t+1],u=zt(o),l=!!o&&!!n&&!!u&&!yr(i)&&!yr(o);e.push({startIndex:t,endIndex:l?t+1:t,entries:[...n?[{canvasId:n,canvas:i}]:[],...l?[{canvasId:u,canvas:o}]:[]]}),t+=l?2:1}return e}function ha({canvases:r,currentCanvasId:s,currentCanvasIndex:e,viewingMode:t,pagedOffset:i}){if(!s)return[];if(e<0||e>=r.length)return[];const n=[],o=r[e];if(!o)return n;if(t!=="paged")return n.push({canvasId:s,canvas:o}),n;const u=ua(r,i).find(({startIndex:l,endIndex:a})=>e>=l&&e<=a);return u?.entries??n}function Ti(r,s){if(!r)return"";if(typeof r=="string")return r;if(typeof r=="object"&&!Array.isArray(r)){const e=r;if("@value"in e){const n=e["@value"];return Array.isArray(n)&&n.length>0?String(n[0]):n===void 0?"":String(n)}const t=Object.keys(e),i=n=>{const o=e[n];if(o!==void 0)return Array.isArray(o)&&o.length>0?String(o[0]):String(o)};for(const n of["en","none"]){const o=i(n);if(o!==void 0)return o}return t.length>0?i(t[0])??"":""}if(Array.isArray(r)&&r.length>0){if(typeof r[0]=="string")return r[0];const e=r,t=o=>o?.value??o?._value,i=(o=>e.find(u=>u.locale===o||u._locale===o||u.language===o))("en");{const o=t(i);if(o)return o}const n=e.find(o=>!o.locale&&!o._locale&&!o.language);{const o=t(n);if(o)return o}return t(e[0])??""}return String(r)}function _r(r,s){var e,t;const i=s===void 0?"Untitled canvas":`Canvas ${s+1}`;try{const o=(e=r.getLabel)==null?void 0:e.call(r);if(Array.isArray(o)&&o.length>0)return Ti(o)||i}catch{}const n=r.label||((t=r.__jsonld)==null?void 0:t.label);if(n){const o=Ti(n);if(o)return o}return i}function Xi(r){if(!r)return null;const s=r.match(/xywh=(?:pixel:)?([\d.]+),([\d.]+),([\d.]+),([\d.]+)/);return s?[Number(s[1]),Number(s[2]),Number(s[3]),Number(s[4])]:null}function ca(r){const[s]=r.split("#");return s||null}function $i(r){if(!r)return null;if(typeof r=="string")return r;if(Array.isArray(r)){for(const e of r){const t=$i(e);if(t)return t}return null}if(typeof r!="object")return null;const s=r;return typeof s.id=="string"?s.id:typeof s["@id"]=="string"?s["@id"]:s.source?$i(s.source):null}function Yi(r){if(!r)return[];if(Array.isArray(r))return r.flatMap(e=>Yi(e));if(typeof r!="object")return[];const s=r;return s.item?Yi(s.item):[s]}function da(r){const s=r.find(t=>t?.type==="FragmentSelector"&&typeof t?.value=="string"&&t.value.includes("xywh="));if(s)return Xi(s.value);const e=r.find(t=>typeof t?.value=="string"&&t.value.includes("xywh="));return e?Xi(e.value):null}function xr(r){if(!r)return[];if(Array.isArray(r))return r.flatMap(i=>xr(i));const s=$i(r),e=typeof r=="object"&&r&&"selector"in r?Yi(r.selector):[],t=da(e)||(s?Xi(s):null);return[{raw:r,targetId:s,canvasId:s?ca(s):null,selectors:e,xywh:t}]}function Tr(r){return r.endsWith("/info.json")?r.slice(0,-10):r}function Ht(r){return typeof r=="number"&&Number.isFinite(r)&&r>0?r:null}function pa(r){const s=r?.__jsonld||r;return{width:Ht(r?.width)||Ht(s?.width)||(typeof r?.getWidth=="function"?Ht(r.getWidth()):null),height:Ht(r?.height)||Ht(s?.height)||(typeof r?.getHeight=="function"?Ht(r.getHeight()):null)}}function Er(r){const s=r?.__jsonld||r;return s?.type==="SpecificResource"&&s!=null&&s.source?s.source:null}function fa(r,s){return s?.type==="Choice"||s?.type==="oa:Choice"||!!r&&!Array.isArray(r)&&(r.type==="Choice"||r.type==="oa:Choice")}function br(r,s){return s&&(s.items||s.item)?s.items||s.item:Array.isArray(r)?r:r&&(r.items||r.item)?r.items||r.item:[]}function ga({body:r,rawBody:s,canvasId:e,getSelectedChoice:t}){const i=Array.isArray(r)?r:br(r,null),n=br(null,s),o=t?.(e);if(o){const u=i.find(a=>Lt(a)===o);if(u)return u;const l=n.findIndex(a=>Lt(a)===o);if(l>=0)return i[l]||n[l]}return i[0]||n[0]||null}function va(r){var s;let e=((s=r.getImages)==null?void 0:s.call(r))||[];return(!e||!e.length)&&r.getContent&&(e=r.getContent()),e||[]}function ma(r){var s,e;const t=r?.width||((s=r?.__jsonld)==null?void 0:s.width)||(typeof r?.getWidth=="function"?r.getWidth():null),i=r?.height||((e=r?.__jsonld)==null?void 0:e.height)||(typeof r?.getHeight=="function"?r.getHeight():null);return typeof t!="number"||typeof i!="number"?null:{width:t,height:i}}function wa(r){var s,e;const t=(e=xr(r?.target||((s=r?.__jsonld)==null?void 0:s.target)).find(i=>i.xywh))==null?void 0:e.xywh;return t?{x:t[0],y:t[1],width:t[2],height:t[3]}:null}function ya(r,s){if(typeof r!="string"||!r.trim())return null;const e=r.trim(),t=e.startsWith("pct:"),i=(t?e.slice(4):e).split(",").map(n=>Number(n.trim()));return i.length!==4||i.some(n=>!Number.isFinite(n)||n<0)?null:t?typeof s.width!="number"||typeof s.height!="number"?null:{x:i[0]/100*s.width,y:i[1]/100*s.height,width:i[2]/100*s.width,height:i[3]/100*s.height}:{x:i[0],y:i[1],width:i[2],height:i[3]}}function _a(r,s){var e;const t=r?.__jsonld||r;return ya(((e=t?.selector)==null?void 0:e.type)==="ImageApiSelector"?t.selector.region:null,s)}function xa(r){return[r.x,r.y,r.width,r.height].map(s=>Math.round(s)).join(",")}function Ta(r){const s=r?.__jsonld||r,e=Er(r);return!!(r&&(r.id||r["@id"]||s!=null&&s.service||e||s!=null&&s.id||s!=null&&s["@id"]))}function Ea(r,s,e){var t;let i=r.getResource?r.getResource():null;if(!i&&r.getBody){const n=r.getBody(),o=((t=r.__jsonld)==null?void 0:t.body)||r.body;fa(n,o)?i=ga({body:n,rawBody:o,canvasId:s,getSelectedChoice:e}):Array.isArray(n)&&n.length>0?i=n[0]:n&&(i=n)}if(i&&!Ta(i)&&(i=null),!i){const n=r.__jsonld||r;if(n.body){let o=n.body;if(o.type==="Choice"||o.type==="oa:Choice"){const u=o.items||o.item||[],l=e?.(s);o=(l?u.find(a=>Lt(a)===l):null)||u[0]||null}i=Array.isArray(o)?o[0]:o}}return i}function Sr(r){return typeof r=="string"?/^https?:\/\/iiif\.io\/api\/image\//.test(r)||r==="level0"||r==="level1"||r==="level2":Array.isArray(r)?r.some(s=>Sr(s)):!1}function ba(r){return typeof r=="string"?r||null:Array.isArray(r)&&r.find(s=>typeof s=="string")||null}function Sa(r){let s=[];const e=r?.__jsonld||r;return e!=null&&e.service&&(s=Array.isArray(e.service)?e.service:[e.service]),!s.length&&r!=null&&r.getServices&&(s=r.getServices()),s.length&&s.find(t=>{const i=t.getType?t.getType():t.type||t["@type"]||"",n=t.getProfile?t.getProfile():t.profile||"";return i==="ImageService1"||i==="ImageService2"||i==="ImageService3"||Sr(n)})||null}function Pa(r,s){var e,t;for(const i of[r,s]){if(!i)continue;try{const o=(e=i.getLabel)==null?void 0:e.call(i);if(Array.isArray(o)&&o.length>0){const u=Ti(o);if(u)return u}}catch{}const n=i.label||((t=i.__jsonld)==null?void 0:t.label);if(n){const o=Ti(n);if(o)return o}}return null}function Ca(r){const s=Sa(r),e=Lt(s),t=s?s.getProfile?s.getProfile():s.profile||"":null;return{serviceId:e?Tr(e):null,serviceProfile:ba(t)}}function Ra(r){if(!r||!r.includes("/iiif/"))return null;const s=r.split("/"),e=s.findIndex(t=>t==="full"||/^\d+,\d+,\d+,\d+$/.test(t));return e>0?s.slice(0,e).join("/"):null}function Ei(r,s={}){const e=zt(r);if(!e)return[];const t=ma(r);if(!t)return[];const i=va(r);return i.length?i.map(n=>{const o=Ea(n,e,s.getSelectedChoice),u=Er(o)||o;if(!u)return null;const l=Lt(u),a=pa(u),h=Ca(u),c=h.serviceId||Ra(l),d=wa(n),g=_a(o,a);return{canvasId:e,annotation:n,resource:u,resourceId:l,label:Pa(u,n),canvasWidth:t.width,canvasHeight:t.height,resourceWidth:g?.width||a.width,resourceHeight:g?.height||a.height,serviceId:c,serviceProfile:h.serviceProfile,imageApiRegion:g,x:d?d.x/t.width:0,y:d?d.y/t.width:0,width:d?d.width/t.width:1}}).filter(n=>n!==null):[]}function Da(r,s={width:1600}){const e=Tr(r),t=s.region||"full",i=s.quality||"default",n=s.format||"jpg",o=typeof s.width=="number"?Math.max(1,Math.round(s.width)):null,u=typeof s.height=="number"?Math.max(1,Math.round(s.height)):null,l=s.size||(o?`${o},`:`,${u||1600}`);return`${e}/${t}/${l}/0/${i}.${n}`}function Ia(r){return typeof r=="string"?r:Array.isArray(r)&&typeof r[0]=="string"?r[0]:null}function bi(r){const s=Ia(r);return s?s==="level0"||s.endsWith("/level0.json")||s.endsWith("#level0"):!1}function Aa(r,s,e,t){var i;if(!((i=r?.IIIFTileSource)!=null&&i.prototype))return s;try{const n=r.IIIFTileSource.prototype.configure.call({},s,e,null),o=new r.IIIFTileSource(n);return ka(o,t),o}catch{return s}}function ka(r,s){if(!bi(r?.profile)||typeof r?.getTileUrl!="function"||r.__triiiceratopsLevel0LowZoomPrepared)return;const e=r.getTileUrl.bind(r),t=typeof r.getNumTiles=="function"?r.getNumTiles.bind(r):null,i=Fa(),n=Ba(r),o=Oa(r,n,t);t&&(r.getNumTiles=function(u){return Cr(u,o,n,this)?{x:0,y:0}:Pr(this,u,i,n,t,o)?{x:1,y:1}:t(u)}),typeof r?.minLevel=="number"&&o>=0&&(r.minLevel=Math.max(r.minLevel,o)),r.getTileUrl=function(u,l,a){if(Cr(u,o,n,this)){const h=o>=0?o:u;return e(h,l,a)}return Pr(this,u,i,n,t,o)?Rr(this,u):e(u,l,a)},r.__triiiceratopsLevel0LowZoomPrepared=!0}function Pr(r,s,e,t,i,n){if(n>=0)return!1;if(!Ki(r,s,t))return!0;if(!i)return!1;const o=i(s);return o?.x===1&&o?.y===1}function Oa(r,s,e){if(!e||typeof r?.minLevel!="number"||typeof r?.maxLevel!="number"||s.size===0)return-1;for(let t=r.minLevel;t<=r.maxLevel;t++){if(!Ki(r,t,s))continue;const i=e(t);if(i?.x>1||i?.y>1)return t}return-1}function Cr(r,s,e,t){return s<0?!1:r<s?!0:!Ki(t,r,e)}function Ba(r){const s=new Set,e=r?.scale_factors;if(Array.isArray(e))for(const t of e)typeof t=="number"&&t>0&&s.add(t);return s}function Ki(r,s,e){if(e.size===0||typeof r?.maxLevel!="number"||typeof s!="number")return!0;const t=Math.pow(2,r.maxLevel-s);return e.has(t)}function Fa(r,s){return-1}function Rr(r,s){const e=r.getLevelScale(s),t=Math.ceil(r.width*e),i=Math.ceil(r.height*e),n=r.version===3,o=bi(r?.profile),u=n?t===r.width&&i===r.height?"max":o?`${t},`:`${t},${i}`:t===r.width?"full":`${t},`,l=n?"default":"native";return`${r._id}/full/${u}/0/${l}.${r.tileFormat}`}const Si=8e3,Dr=4e7;function Ma(r,s,e,t){const i=Math.max(1,Math.round(r.width*s*t)),n=r.resourceWidth&&r.resourceHeight?r.resourceHeight/r.resourceWidth:e/s;return{x:Math.round(r.x*s*t),y:Math.round(r.y*e*t),width:i,height:Math.max(1,Math.round(i*n))}}function La(r,s){const e=URL.createObjectURL(r),t=document.createElement("a");t.href=e,t.download=s,document.body.appendChild(t),t.click(),t.remove(),URL.revokeObjectURL(e)}async function Qi(r,s){const e=await fetch(r,s);if(!e.ok)throw new Error(`Image request failed with ${e.status}.`);return e.blob()}async function za(r){const s=URL.createObjectURL(r);try{return await new Promise((e,t)=>{const i=new Image;i.onload=()=>e(i),i.onerror=()=>t(new Error("Unable to decode image for export.")),i.src=s})}finally{URL.revokeObjectURL(s)}}async function Ir(r,s,e,t="image/png"){const i=document.createElement("canvas");i.width=Math.max(1,Math.round(s)),i.height=Math.max(1,Math.round(e));const n=i.getContext("2d");if(!n)throw new Error("Unable to create a canvas for image export.");for(const o of r){const u=await za(o.blob);n.drawImage(u,o.x,o.y,o.width,o.height)}return new Promise((o,u)=>{i.toBlob(l=>{if(l){o(l);return}u(new Error("Unable to export composed image."))},t)})}function Ar(r,s){let e=1;r>Si&&(e=Math.min(e,Si/r)),s>Si&&(e=Math.min(e,Si/s));const t=r*s;return t*e*e>Dr&&(e=Math.min(e,Math.sqrt(Dr/t))),e>=1?{width:Math.round(r),height:Math.round(s),clamped:!1}:{width:Math.max(1,Math.round(r*e)),height:Math.max(1,Math.round(s*e)),clamped:!0}}function ni(r,s={}){if(bi(r.serviceProfile))return r.resourceId??null;if(r.serviceId){const e=r.imageApiRegion?xa(r.imageApiRegion):void 0,t=!!(s.width||s.height);return Da(r.serviceId,{region:e,size:t?void 0:"max",width:s.width,height:s.height})}return r.resourceId??null}async function Ha(r){if(!r.serviceId)return[];const s=r.serviceId.endsWith("/info.json")?r.serviceId:`${r.serviceId}/info.json`;try{const e=await fetch(s);if(!e.ok)return[];const t=await e.json(),i=await Promise.resolve().then(()=>kl).then(a=>a.o),n=i.default||i,o=Aa(n,t,s);if(!o||typeof o.minLevel!="number"||typeof o.maxLevel!="number"||typeof o.getLevelScale!="function")return[];const u=new Set,l=[];for(let a=o.minLevel;a<=o.maxLevel;a+=1){const h=o.getLevelScale(a),c=Math.ceil(o.width*h),d=Math.ceil(o.height*h),g=`${c}x${d}`;u.has(g)||(u.add(g),l.push({width:c,height:d,label:`${c} × ${d}px`,url:Rr(o,a)}))}return l.sort((a,h)=>h.width-a.width)}catch{return[]}}const Na=[{fraction:1,label:"Original"},{fraction:.5,label:"50%"},{fraction:.25,label:"25%"}];function Ji(r,s,e){return Na.map(({fraction:t,label:i})=>{const n=Math.max(1,Math.round(r*t)),o=Math.max(1,Math.round(s*t)),u=e?.({width:n,height:o,isOriginal:t===1});return{width:n,height:o,label:`${i} (${n} × ${o}px)`,url:u??void 0}}).filter(t=>!e||!!t.url)}function Ua(r){const s=r.resourceWidth,e=r.resourceHeight;if(!r.serviceId||!s||!e){const t=ni(r);return t?[{width:s??0,height:e??0,label:"Original",url:t}]:[]}return Ji(s,e,({width:t,height:i,isOriginal:n})=>ni(r,n?{}:{width:t,height:i}))}async function Wa(r){if(bi(r.serviceProfile)){const s=await Ha(r);return s.length?s:r.resourceId?[{width:r.resourceWidth??0,height:r.resourceHeight??0,label:"Original",url:r.resourceId}]:[]}return Ua(r)}const ja=.0125;function Va(r){return!!r&&typeof r=="object"&&"tileSource"in r}function kr(r,s){if(!r||typeof r!="object")return null;const e=r[s];return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function Ga(r,s,e){return Math.min(e,Math.max(s,r))}function qa(r){const s=[...r].sort((t,i)=>t-i),e=Math.floor(s.length/2);return s.length%2===0?(s[e-1]+s[e])/2:s[e]}function Za(r){const s=new Map;return r.forEach((e,t)=>{const i=Va(e),n=i?e.tileSource:e,o=i?e.canvasId??`canvas-${t}`:`canvas-${t}`,u=i?e.x??0:0,l=i?e.y??0:0,a=i?e.width??1:1,h=kr(n,"width"),c=kr(n,"height"),d=h&&c?a*c/h:null;let g=s.get(o);g||(g={canvasId:o,sources:[],width:0,height:null},s.set(o,g)),g.sources.push({source:e,tileSource:n,localX:u,localY:l,localWidth:a,localHeight:d}),g.width=Math.max(g.width,u+a),g.height=d===null?null:Math.max(g.height??0,l+d)}),[...s.values()]}function Xa(r){return{layouts:r.map(s=>({canvasId:s.canvasId,x:0,y:0,width:s.width,height:s.height??1})),sources:r.flatMap(s=>s.sources.map(({tileSource:e,localX:t,localY:i,localWidth:n})=>({tileSource:e,x:t,y:i,width:n,canvasId:s.canvasId})))}}function $a(r,s){const e=Za(r);if(s.mode==="individuals"||e.length<=1)return Xa(e);const t=!s.preserveCanvasScale&&e.every(o=>o.height!==null),i=t?qa(e.map(o=>o.height)):1,n=e.map(o=>{const u=t?Ga(i/o.height,.25,4):1;return{group:o,scale:u,width:o.width*u,height:(o.height??1)*u,x:0,y:0}});if(s.mode==="continuous"){let o=0;const u=s.direction==="top-to-bottom"||s.direction==="bottom-to-top",l=s.direction==="right-to-left"||s.direction==="bottom-to-top";for(const a of n)u?(a.y=l?-o:o,o+=(t?a.height:1)+s.gap):(a.x=l?-o:o,o+=(t?a.width:1)+s.gap)}else if(s.mode==="paged"){const o=Math.max(...n.map(l=>l.height)),u=s.direction==="right-to-left";n.forEach((l,a)=>{const h=u?n.slice(a+1):n.slice(0,a);l.x=h.reduce((c,d)=>c+(t?d.width:1)+s.gap,0),l.y=(o-l.height)/2})}return{layouts:n.map(o=>({canvasId:o.group.canvasId,x:o.x,y:o.y,width:o.width,height:o.height})),sources:n.flatMap(o=>o.group.sources.map(({tileSource:u,localX:l,localY:a,localWidth:h})=>({tileSource:u,x:o.x+l*o.scale,y:o.y+a*o.scale,width:h*o.scale,canvasId:o.group.canvasId})))}}function Ya(r,s,e){Js(r,"@triiiceratops/plugin-image-export","1.0.0-rc.0",s,e)}function Ka(r){return r.replace(/[^a-z0-9-_]+/gi,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Qa(r,s,e){const i=Ka(r)||"image",n=s==="single"?"":`-${s}`;return`${i}${n}.png`}function Or(r,s){return Ei(r,{getSelectedChoice:s})}function Ja(r){return Wa(r)}function el(r,s){const t=Ei(r,{getSelectedChoice:s})[0];return!t?.canvasWidth||!t?.canvasHeight?[]:Ji(t.canvasWidth,t.canvasHeight)}async function tl(r,s){const e=s.url??ni(r,{width:s.width,height:s.height});if(!e)throw new Error("No exportable image found for this canvas.");return Qi(e)}async function il(r,s,e={}){const t=Ei(r,{getSelectedChoice:e.getSelectedChoice}),i=t[0];if(!i)throw new Error("No exportable image found for this canvas.");const{canvasWidth:n,canvasHeight:o}=i;if(!n||!o)throw new Error("Unable to determine canvas dimensions for export.");const{width:u,height:l}=Ar(s.width,s.height),a=u/n,h=await Promise.all(t.map(async c=>nl(c,n,o,a)));return Ir(h,u,l,e.format??"image/png")}async function nl(r,s,e,t){const i=Ma(r,s,e,t),n=ni(r,{width:i.width});if(!n)throw new Error("No exportable image found for this canvas.");return{blob:await Qi(n),...i}}function Br(r){return ha({canvases:r.canvases,currentCanvasId:r.canvasId,currentCanvasIndex:r.currentCanvasIndex,viewingMode:r.viewingMode,pagedOffset:r.pagedOffset}).map(s=>s.canvas)}function Fr(r,s){const e=Br(r);if(!e.length)return null;const t=e.flatMap((c,d)=>{const g=zt(c)??`canvas-${d}`;return Ei(c,{getSelectedChoice:s}).map(m=>({canvasId:g,x:m.x,y:m.y,width:m.width,tileSource:{width:m.resourceWidth||m.canvasWidth,height:m.resourceHeight||m.canvasHeight,resolved:m}}))});if(!t.length)return null;const{layouts:i,sources:n}=$a(t,{mode:r.viewingMode,direction:r.viewingDirection,preserveCanvasScale:r.preserveCanvasScale,gap:ja});if(!i.length)return null;const o=Math.min(...i.map(c=>c.x)),u=Math.min(...i.map(c=>c.y)),l=Math.max(...i.map(c=>c.x+c.width)),a=Math.max(...i.map(c=>c.y+c.height));return{entries:n.map(c=>({resolved:c.tileSource.resolved,x:c.x-o,y:c.y-u,width:c.width})),worldWidth:l-o,worldHeight:a-u}}function rl(r,s){const e=Fr(r,s);if(!e)return[];const t=e.entries[0],i=t?.resolved.resourceWidth&&t.width>0?t.resolved.resourceWidth/t.width:1600,n=Math.round(e.worldWidth*i),o=Math.round(e.worldHeight*i);return!n||!o?[]:Ji(n,o)}async function ol(r,s,e={}){const t=Fr(r,e.getSelectedChoice);if(!t)throw new Error("Nothing is currently displayed in the viewer.");const{width:i,height:n}=Ar(s.width,s.height),o=i/t.worldWidth,u=await Promise.all(t.entries.map(async({resolved:l,x:a,y:h,width:c})=>{const d=Math.max(1,Math.round(c*o)),g=l.resourceWidth&&l.resourceHeight?l.resourceHeight/l.resourceWidth:1,m=Math.max(1,Math.round(d*g)),_=ni(l,{width:d});if(!_)throw new Error("No exportable image found for the current view.");return{blob:await Qi(_),x:Math.round(a*o),y:Math.round(h*o),width:d,height:m}}));return Ir(u,i,n,e.format??"image/png")}var sl=ve("<option> </option>"),al=ve("<option> </option>"),ll=ve("<!> <option> </option> <!>",1),ul=ve('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-mode"><span> </span></label> <!></div>'),hl=ve("<option> </option>"),cl=ve('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-canvas"><span> </span></label> <!></div>'),dl=ve("<option> </option>"),pl=ve('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-image"><span> </span></label> <!></div>'),fl=ve("<option> </option>"),gl=ve("<option disabled> </option> <!>",1),vl=ve('<div class="tri-id-alert is-success" data-tri-id-result=""><span> </span></div>'),ml=ve('<div class="tri-id-alert is-error" data-tri-id-error=""><span> </span></div>'),wl=ve('<div class="tri-id-alert"><span> </span></div>'),yl=ve('<div class="tri-id-card"><div class="tri-id-card-body"><!> <!> <!></div></div>'),_l=ve('<span aria-hidden="true"></span> ',1),xl=ve('<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(r,s){ki(s,!0);const{context:e}=To(mr),{viewerState:t,selectors:i,locale:n,ui:o}=e;let u=ue(0),l=ue(0);i.select(A=>[A.canvasId,A.currentCanvasIndex,A.canvases,A.viewingMode,A.viewingDirection,A.pagedOffset,A.preserveCanvasScale]).subscribe(()=>{Tn(u)}),n.subscribe(()=>{Tn(l)});const a=(A,D)=>(b(l),n.t(A,D));let h=ue("single"),c=ue(0),d=ue(0),g=ue(lt([])),m=ue(null),_=ue(!1),y=ue(!1),E=ue(""),S=ue(""),P=ue(null);const B=A=>t.getSelectedChoice(A),k=le(()=>(b(u),t.currentCanvasIndex>=0?t.canvases[t.currentCanvasIndex]??null:null)),M=le(()=>(b(u),b(k)?Or(b(k),B):[])),L=le(()=>b(M).length>1),W=le(()=>b(L)),$=le(()=>(b(u),Br(t))),Q=le(()=>b($).length>1),q=le(()=>b(Q)),V=le(()=>b(W)||b(q)),re=le(()=>(b(u),b(h)==="single"&&b(Q)?b($)[b(c)]??b(k):b(k))),he=le(()=>(b(u),b(re)?Or(b(re),B):[])),de=le(()=>b(he).length>1),pe=le(()=>b(m)!==null?b(g)[b(m)]??null:null),ge=le(()=>!b(y)&&!b(_)&&!!b(k)&&!!b(pe)),me=le(()=>(b(l),b(k)?!b(_)&&!b(g).length?a("image_download_disabled_no_resolution"):null:a("image_download_disabled_no_canvas")));Zt(()=>{(b(h)==="composite"&&!b(W)||b(h)==="world"&&!b(q))&&Z(h,"single")}),Zt(()=>{b(u);const A=t.canvasId,D=b($).findIndex(H=>zt(H)===A);Z(c,D>=0?D:0,!0)}),Zt(()=>{b(re),Z(d,0)}),Zt(()=>{const A=b(k),D=b(h),H=b(d);let G=!1;if(Z(g,[],!0),Z(m,null),!!A){if(D==="single"){const X=b(he)[H];if(!X)return;Z(_,!0),Ja(X).then(U=>{G||(Z(g,U,!0),Z(m,U.length?0:null,!0))}).finally(()=>{G||Z(_,!1)})}else if(D==="composite"){const X=el(A,B);Z(g,X,!0),Z(m,X.length?0:null,!0)}else{const X=rl(t,B);Z(g,X,!0),Z(m,X.length?0:null,!0)}return()=>{G=!0}}});function Pe(A){const D=Number(A);return Number.isInteger(D)?D:0}async function Le(){if(!(!b(k)||!b(pe)||!b(ge))){Z(y,!0),Z(E,""),Z(S,"");try{let A,D=b(k);if(b(h)==="single"){D=b(re);const G=b(he)[b(d)];if(!G)return;A=await tl(G,b(pe))}else b(h)==="composite"?A=await il(b(k),b(pe),{getSelectedChoice:B}):A=await ol(t,b(pe),{getSelectedChoice:B});const H=Qa(_r(D,t.currentCanvasIndex),b(h),"image/png");La(A,H),Z(S,a("image_download_result_downloaded",{filename:H}),!0)}catch(A){Z(E,a("image_download_error_failed"),!0),b(P)&&Ya(b(P),A,()=>void Le())}finally{Z(y,!1)}}}function xe(A){return{destroy:o.renderIcon(wr,A)}}var Xe=xl(),Y=ee(Xe),$e=ee(Y),ct=ee($e),Ue=ye($e,2),z=ee(Ue);{var ie=A=>{var D=ul(),H=ee(D),G=ee(H),X=ee(G),U=ye(H,2);{let K=le(()=>a("image_download_mode"));xi(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(y)},get value(){return b(h)},onchange:v=>{Z(h,v.currentTarget.value,!0)},children:(v,f)=>{var w=ll(),T=Gt(w);{var R=se=>{var oe=sl(),Ke=ee(oe);oe.value=oe.__value="composite",be(Wt=>_e(Ke,Wt),[()=>a("image_download_mode_composite")]),fe(se,oe)};ot(T,se=>{b(W)&&se(R)})}var I=ye(T,2),N=ee(I);I.value=I.__value="single";var J=ye(I,2);{var j=se=>{var oe=al(),Ke=ee(oe);oe.value=oe.__value="world",be(Wt=>_e(Ke,Wt),[()=>a("image_download_mode_world")]),fe(se,oe)};ot(J,se=>{b(q)&&se(j)})}be(se=>_e(N,se),[()=>a("image_download_mode_single")]),fe(v,w)},$$slots:{default:!0}})}be(K=>_e(X,K),[()=>a("image_download_mode")]),fe(A,D)};ot(z,A=>{b(V)&&A(ie)})}var ce=ye(z,2);{var we=A=>{var D=cl(),H=ee(D),G=ee(H),X=ee(G),U=ye(H,2);{let K=le(()=>a("image_download_canvas"));xi(U,{id:"tri-id-canvas",class:"tri-id-field-select",get"aria-label"(){return b(K)},get disabled(){return b(y)},get value(){return b(c)},onchange:v=>{Z(c,Pe(v.currentTarget.value),!0)},children:(v,f)=>{var w=Jn(),T=Gt(w);vi(T,17,()=>b($),Wi,(R,I,N)=>{var J=hl(),j=ee(J);J.value=J.__value=N,be(se=>_e(j,se),[()=>_r(b(I),N)]),fe(R,J)}),fe(v,w)},$$slots:{default:!0}})}be(K=>_e(X,K),[()=>a("image_download_canvas")]),fe(A,D)};ot(ce,A=>{b(h)==="single"&&b(Q)&&A(we)})}var Ye=ye(ce,2);{var St=A=>{var D=pl(),H=ee(D),G=ee(H),X=ee(G),U=ye(H,2);{let K=le(()=>a("image_download_image"));xi(U,{id:"tri-id-image",class:"tri-id-field-select",get"aria-label"(){return b(K)},get disabled(){return b(y)},get value(){return b(d)},onchange:v=>{Z(d,Pe(v.currentTarget.value),!0)},children:(v,f)=>{var w=Jn(),T=Gt(w);vi(T,17,()=>b(he),Wi,(R,I,N)=>{var J=dl(),j=ee(J);J.value=J.__value=N,be(se=>_e(j,se),[()=>b(I).label??`${a("image_download_image")} ${N+1}`]),fe(R,J)}),fe(v,w)},$$slots:{default:!0}})}be(K=>_e(X,K),[()=>a("image_download_image")]),fe(A,D)};ot(Ye,A=>{b(h)==="single"&&b(de)&&A(St)})}var Nt=ye(Ye,2),Ut=ee(Nt),Pt=ee(Ut),dt=ee(Pt),p=ye(Ut,2);{let A=le(()=>a("image_download_resolution")),D=le(()=>b(y)||b(_)||!b(g).length),H=le(()=>b(m)??"");xi(p,{id:"tri-id-resolution",class:"tri-id-field-select","data-tri-id-resolution":!0,get"aria-label"(){return b(A)},get disabled(){return b(D)},get value(){return b(H)},onchange:G=>{Z(m,Pe(G.currentTarget.value),!0)},children:(G,X)=>{var U=gl(),K=Gt(U),v=ee(K);K.value=K.__value="";var f=ye(K,2);vi(f,17,()=>b(g),Wi,(w,T,R)=>{var I=fl(),N=ee(I);I.value=I.__value=R,be(()=>_e(N,b(T).label)),fe(w,I)}),be(w=>_e(v,w),[()=>a("image_download_resolution_placeholder")]),fe(G,U)},$$slots:{default:!0}})}var x=ye(Ue,2);{var C=A=>{var D=yl(),H=ee(D),G=ee(H);{var X=w=>{var T=vl(),R=ee(T),I=ee(R);be(()=>_e(I,b(S))),fe(w,T)};ot(G,w=>{b(S)&&w(X)})}var U=ye(G,2);{var K=w=>{var T=ml(),R=ee(T),I=ee(R);be(()=>_e(I,b(E))),fe(w,T)};ot(U,w=>{b(E)&&w(K)})}var v=ye(U,2);{var f=w=>{var T=wl(),R=ee(T),I=ee(R);be(()=>_e(I,b(me))),fe(w,T)};ot(v,w=>{b(me)&&w(f)})}fe(A,D)};ot(x,A=>{(b(S)||b(E)||b(me))&&A(C)})}var O=ye(Y,2),F=ee(O);{let A=le(()=>!b(ge));ra(F,{variant:"primary",class:"tri-id-download","data-tri-id-download":!0,style:"width:100%",get disabled(){return b(A)},onclick:Le,children:(D,H)=>{var G=_l(),X=Gt(G);ps(X,K=>xe?.(K));var U=ye(X);be(K=>_e(U,` ${K??""}`),[()=>b(y)?a("image_download_downloading"):a("image_download_download")]),fe(D,G)},$$slots:{default:!0}})}wi(Xe,A=>Z(P,A),()=>b(P)),be((A,D)=>{_e(ct,A),_e(dt,D)},[()=>a("image_download_description"),()=>a("image_download_resolution")]),fe(r,Xe),Oi()}const{STYLES:El,STYLE_ID:bl}=Qs(`
|
|
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"),Sl=Zs({name:"@triiiceratops/plugin-image-export",title:"image_download_title",uiId:"image-download",version:"1.0.0-rc.0",coreRange:">=1.0.0-rc.0",pluginApiRange:"^1.0.0",requiredCapabilities:["osd@5"],icon:wr,target:"panel",catalog:ta,view:{mount(r,s){const e=s.styles.install(El,bl),t=s.styles.install(ea,"bundled"),i=as(Tl,{target:r,context:new Map([[mr,{context:s}]])});return()=>{us(i),t(),e()}}}});function Pl(){const r=new Map;return{register(s){const e=r.get(s.name);if(!e){r.set(s.name,s);return}e.version!==s.version&&console.warn(`[triiiceratops] Ignoring plugin "${s.name}" version ${s.version}: version ${e.version} is already registered on this page and wins (first registration wins).`)},get(s){return r.get(s)},has(s){return r.has(s)},list(){return[...r.values()]}}}function Cl(r){(window.Triiiceratops??={coreVersion:"",pluginApiVersion:"",capabilities:[],plugins:Pl()}).plugins.register(r)}Cl(Sl);function Rl(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Dl(r,s){for(var e=0;e<s.length;e++){const t=s[e];if(typeof t!="string"&&!Array.isArray(t)){for(const i in t)if(i!=="default"&&!(i in r)){const n=Object.getOwnPropertyDescriptor(t,i);n&&Object.defineProperty(r,i,n.get?n:{enumerable:!0,get:()=>t[i]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}var en={exports:{}},Il=en.exports,Mr;function Al(){return Mr||(Mr=1,(function(r){//! 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 s(e){return new s.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"},i=Object.prototype.toString,n=Object.prototype.hasOwnProperty;e.isFunction=function(o){return e.type(o)==="function"},e.isArray=Array.isArray||function(o){return e.type(o)==="array"},e.isWindow=function(o){return o&&typeof o=="object"&&"setInterval"in o},e.type=function(o){return o==null?String(o):t[i.call(o)]||"object"},e.isPlainObject=function(o){if(!o||s.type(o)!=="object"||o.nodeType||e.isWindow(o)||o.constructor&&!n.call(o,"constructor")&&!n.call(o.constructor.prototype,"isPrototypeOf"))return!1;var u;for(var l in o)u=l;return u===void 0||n.call(o,u)},e.isEmptyObject=function(o){for(var u in o)return!1;return!0},e.freezeObject=function(o){return Object.freeze?e.freezeObject=Object.freeze:e.freezeObject=function(u){return u},e.freezeObject(o)},e.supportsCanvas=(function(){var o=document.createElement("canvas");return!!(e.isFunction(o.getContext)&&o.getContext("2d"))})(),e.isCanvasTainted=function(o){var u=!1;try{o.getContext("2d").getImageData(0,0,1,1)}catch{u=!0}return u},e.supportsAddEventListener=(function(){return!!(document.documentElement.addEventListener&&document.addEventListener)})(),e.supportsRemoveEventListener=(function(){return!!(document.documentElement.removeEventListener&&document.removeEventListener)})(),e.supportsEventListenerOptions=(function(){var o=0;if(e.supportsAddEventListener)try{var u={get capture(){return o++,!1},get once(){return o++,!1},get passive(){return o++,!1}};window.addEventListener("test",null,u),window.removeEventListener("test",null,u)}catch{o=0}return o>=3})(),e.getCurrentPixelDensityRatio=function(){if(e.supportsCanvas){var o=document.createElement("canvas").getContext("2d"),u=window.devicePixelRatio||1,l=o.webkitBackingStorePixelRatio||o.mozBackingStorePixelRatio||o.msBackingStorePixelRatio||o.oBackingStorePixelRatio||o.backingStorePixelRatio||1;return Math.max(u,1)/l}else return 1},e.pixelDensityRatio=e.getCurrentPixelDensityRatio()})(s),(function(e){e.extend=function(){var l,a,h,c,d,g,m=arguments[0]||{},_=arguments.length,y=!1,E=1;for(typeof m=="boolean"&&(y=m,m=arguments[1]||{},E=2),typeof m!="object"&&!s.isFunction(m)&&(m={}),_===E&&(m=this,--E);E<_;E++)if(l=arguments[E],l!==null||l!==void 0)for(a in l){var S=Object.getOwnPropertyDescriptor(l,a);if(S!==void 0){if(S.get||S.set){Object.defineProperty(m,a,S);continue}c=S.value}else{e.console.warn('Could not copy inherited property "'+a+'".');continue}m!==c&&(y&&c&&(s.isPlainObject(c)||(d=s.isArray(c)))?(h=m[a],d?(d=!1,g=h&&s.isArray(h)?h:[]):g=h&&s.isPlainObject(h)?h:{},m[a]=s.extend(y,g,c)):c!==void 0&&(m[a]=c))}return m};var t=function(){if(typeof navigator!="object")return!1;var l=navigator.userAgent;return typeof l!="string"?!1:l.indexOf("iPhone")!==-1||l.indexOf("iPad")!==-1||l.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(l,a){return function(){var h=arguments;return h===void 0&&(h=[]),a.apply(l,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(l){return e._viewers.get(this.getElement(l))},getElement:function(l){return typeof l=="string"&&(l=document.getElementById(l)),l},getElementPosition:function(l){var a=new e.Point,h,c;for(l=e.getElement(l),h=e.getElementStyle(l).position==="fixed",c=u(l,h);c;)a.x+=l.offsetLeft,a.y+=l.offsetTop,h&&(a=a.plus(e.getPageScroll())),l=c,h=e.getElementStyle(l).position==="fixed",c=u(l,h);return a},getElementOffset:function(l){l=e.getElement(l);var a=l&&l.ownerDocument,h,c,d={top:0,left:0};return a?(h=a.documentElement,typeof l.getBoundingClientRect<"u"&&(d=l.getBoundingClientRect()),c=a===a.window?a:a.nodeType===9?a.defaultView||a.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(l){return l=e.getElement(l),new e.Point(l.clientWidth,l.clientHeight)},getElementStyle:document.documentElement.currentStyle?function(l){return l=e.getElement(l),l.currentStyle}:function(l){return l=e.getElement(l),window.getComputedStyle(l,"")},getCssPropertyWithVendorPrefix:function(l){var a={};return e.getCssPropertyWithVendorPrefix=function(h){if(a[h]!==void 0)return a[h];var c=document.createElement("div").style,d=null;if(c[h]!==void 0)d=h;else for(var g=["Webkit","Moz","MS","O","webkit","moz","ms","o"],m=e.capitalizeFirstLetter(h),_=0;_<g.length;_++){var y=g[_]+m;if(c[y]!==void 0){d=y;break}}return a[h]=d,d},e.getCssPropertyWithVendorPrefix(l)},capitalizeFirstLetter:function(l){return l.charAt(0).toUpperCase()+l.slice(1)},positiveModulo:function(l,a){var h=l%a;return h<0&&(h+=a),h},pointInElement:function(l,a){l=e.getElement(l);var h=e.getElementOffset(l),c=e.getElementSize(l);return a.x>=h.x&&a.x<h.x+c.x&&a.y<h.y+c.y&&a.y>=h.y},getMousePosition:function(l){if(typeof l.pageX=="number")e.getMousePosition=function(a){var h=new e.Point;return h.x=a.pageX,h.y=a.pageY,h};else if(typeof l.clientX=="number")e.getMousePosition=function(a){var h=new e.Point;return h.x=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,h.y=a.clientY+document.body.scrollTop+document.documentElement.scrollTop,h};else throw new Error("Unknown event mouse position, no known technique.");return e.getMousePosition(l)},getPageScroll:function(){var l=document.documentElement||{},a=document.body||{};if(typeof window.pageXOffset=="number")e.getPageScroll=function(){return new e.Point(window.pageXOffset,window.pageYOffset)};else if(a.scrollLeft||a.scrollTop)e.getPageScroll=function(){return new e.Point(document.body.scrollLeft,document.body.scrollTop)};else if(l.scrollLeft||l.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(l){if(typeof window.scrollTo<"u")e.setPageScroll=function(c){window.scrollTo(c.x,c.y)};else{var a=e.getPageScroll();if(a.x===l.x&&a.y===l.y)return;document.body.scrollLeft=l.x,document.body.scrollTop=l.y;var h=e.getPageScroll();if(h.x!==a.x&&h.y!==a.y){e.setPageScroll=function(c){document.body.scrollLeft=c.x,document.body.scrollTop=c.y};return}if(document.documentElement.scrollLeft=l.x,document.documentElement.scrollTop=l.y,h=e.getPageScroll(),h.x!==a.x&&h.y!==a.y){e.setPageScroll=function(c){document.documentElement.scrollLeft=c.x,document.documentElement.scrollTop=c.y};return}e.setPageScroll=function(c){}}e.setPageScroll(l)},getWindowSize:function(){var l=document.documentElement||{},a=document.body||{};if(typeof window.innerWidth=="number")e.getWindowSize=function(){return new e.Point(window.innerWidth,window.innerHeight)};else if(l.clientWidth||l.clientHeight)e.getWindowSize=function(){return new e.Point(document.documentElement.clientWidth,document.documentElement.clientHeight)};else if(a.clientWidth||a.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(l){l=e.getElement(l);var a=[e.makeNeutralElement("div"),e.makeNeutralElement("div"),e.makeNeutralElement("div")];return e.extend(a[0].style,{display:"table",height:"100%",width:"100%"}),e.extend(a[1].style,{display:"table-row"}),e.extend(a[2].style,{display:"table-cell",verticalAlign:"middle",textAlign:"center"}),a[0].appendChild(a[1]),a[1].appendChild(a[2]),a[2].appendChild(l),a[0]},makeNeutralElement:function(l){var a=document.createElement(l),h=a.style;return h.background="transparent none",h.border="none",h.margin="0px",h.padding="0px",h.position="static",a},now:function(){return Date.now?e.now=Date.now:e.now=function(){return new Date().getTime()},e.now()},makeTransparentImage:function(l){var a=e.makeNeutralElement("img");return a.src=l,a},setElementOpacity:function(l,a,h){var c,d;l=e.getElement(l),h&&!e.Browser.alpha&&(a=Math.round(a)),e.Browser.opacity?l.style.opacity=a<1?a:"":a<1?(c=Math.round(100*a),d="alpha(opacity="+c+")",l.style.filter=d):l.style.filter=""},setElementTouchActionNone:function(l){l=e.getElement(l),typeof l.style.touchAction<"u"?l.style.touchAction="none":typeof l.style.msTouchAction<"u"&&(l.style.msTouchAction="none")},setElementPointerEvents:function(l,a){l=e.getElement(l),typeof l.style<"u"&&typeof l.style.pointerEvents<"u"&&(l.style.pointerEvents=a)},setElementPointerEventsNone:function(l){e.setElementPointerEvents(l,"none")},addClass:function(l,a){l=e.getElement(l),l.className?(" "+l.className+" ").indexOf(" "+a+" ")===-1&&(l.className+=" "+a):l.className=a},indexOf:function(l,a,h){return Array.prototype.indexOf?this.indexOf=function(c,d,g){return c.indexOf(d,g)}:this.indexOf=function(c,d,g){var m,_=g||0,y;if(!c)throw new TypeError;if(y=c.length,y===0||_>=y)return-1;for(_<0&&(_=y-Math.abs(_)),m=_;m<y;m++)if(c[m]===d)return m;return-1},this.indexOf(l,a,h)},removeClass:function(l,a){var h,c=[],d;for(l=e.getElement(l),h=l.className.split(/\s+/),d=0;d<h.length;d++)h[d]&&h[d]!==a&&c.push(h[d]);l.className=c.join(" ")},normalizeEventListenerOptions:function(l){var a;return typeof l<"u"?typeof l=="boolean"?a=e.supportsEventListenerOptions?{capture:l}:l:a=e.supportsEventListenerOptions?l:typeof l.capture<"u"?l.capture:!1:a=e.supportsEventListenerOptions?{capture:!1}:!1,a},addEvent:(function(){if(e.supportsAddEventListener)return function(l,a,h,c){c=e.normalizeEventListenerOptions(c),l=e.getElement(l),l.addEventListener(a,h,c)};if(document.documentElement.attachEvent&&document.attachEvent)return function(l,a,h){l=e.getElement(l),l.attachEvent("on"+a,h)};throw new Error("No known event model.")})(),removeEvent:(function(){if(e.supportsRemoveEventListener)return function(l,a,h,c){c=e.normalizeEventListenerOptions(c),l=e.getElement(l),l.removeEventListener(a,h,c)};if(document.documentElement.detachEvent&&document.detachEvent)return function(l,a,h){l=e.getElement(l),l.detachEvent("on"+a,h)};throw new Error("No known event model.")})(),cancelEvent:function(l){l.preventDefault()},eventIsCanceled:function(l){return l.defaultPrevented},stopEvent:function(l){l.stopPropagation()},createCallback:function(l,a){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([]),g;for(g=0;g<arguments.length;g++)d.push(arguments[g]);return a.apply(l,d)}},getUrlParameter:function(l){var a=o[l];return a||null},getUrlProtocol:function(l){var a=l.match(/^([a-z]+:)\/\//i);return a===null?window.location.protocol:a[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(l,a,h){var c,d,g,m;e.isPlainObject(l)&&(a=l.success,h=l.error,c=l.withCredentials,d=l.headers,g=l.responseType||null,m=l.postData||null,l=l.url);var _=e.getUrlProtocol(l),y=e.createAjaxRequest();if(!e.isFunction(a))throw new Error("makeAjaxRequest requires a success callback");y.onreadystatechange=function(){y.readyState===4&&(y.onreadystatechange=function(){},y.status>=200&&y.status<300||y.status===0&&_!=="http:"&&_!=="https:"?a(y):e.isFunction(h)?h(y):e.console.error("AJAX request returned %d: %s",y.status,l))};var E=m?"POST":"GET";try{if(y.open(E,l,!0),g&&(y.responseType=g),d)for(var S in d)Object.prototype.hasOwnProperty.call(d,S)&&d[S]&&y.setRequestHeader(S,d[S]);c&&(y.withCredentials=!0),y.send(m)}catch(P){e.console.error("%s while making AJAX request: %s",P.name,P.message),y.onreadystatechange=function(){},e.isFunction(h)&&h(y,P)}return y},jsonp:function(l){var a,h=l.url,c=document.head||document.getElementsByTagName("head")[0]||document.documentElement,d=l.callbackName||"openseadragon"+e.now(),g=window[d],m="$1"+d+"$2",_=l.param||"callback",y=l.callback;h=h.replace(/(=)\?(&|$)|\?\?/i,m),h+=(/\?/.test(h)?"&":"?")+_+"="+d,window[d]=function(E){if(g)window[d]=g;else try{delete window[d]}catch{}y&&e.isFunction(y)&&y(E)},a=document.createElement("script"),(l.async!==void 0||l.async!==!1)&&(a.async="async"),l.scriptCharset&&(a.charset=l.scriptCharset),a.src=h,a.onload=a.onreadystatechange=function(E,S){(S||!a.readyState||/loaded|complete/.test(a.readyState))&&(a.onload=a.onreadystatechange=null,c&&a.parentNode&&c.removeChild(a),a=void 0)},c.insertBefore(a,c.firstChild)},createFromDZI:function(){throw"OpenSeadragon.createFromDZI is deprecated, use Viewer.open."},parseXml:function(l){if(window.DOMParser)e.parseXml=function(a){var h=null,c;return c=new DOMParser,h=c.parseFromString(a,"text/xml"),h};else throw new Error("Browser doesn't support XML DOM.");return e.parseXml(l)},parseJSON:function(l){return e.parseJSON=window.JSON.parse,e.parseJSON(l)},imageFormatSupported:function(l){return l=l||"",!!n[l.toLowerCase()]},setImageFormatsSupported:function(l){e.extend(n,l)}});var i=function(l){};e.console=window.console||{log:i,debug:i,info:i,warn:i,error:i,assert:i},e.Browser={vendor:e.BROWSERS.UNKNOWN,version:0,alpha:!0};var n={avif:!0,bmp:!1,jpeg:!0,jpg:!0,png:!0,tif:!1,wdp:!1,webp:!0},o={};(function(){var l=navigator.appVersion,a=navigator.userAgent,h;switch(navigator.appName){case"Microsoft Internet Explorer":window.attachEvent&&window.ActiveXObject&&(e.Browser.vendor=e.BROWSERS.IE,e.Browser.version=parseFloat(a.substring(a.indexOf("MSIE")+5,a.indexOf(";",a.indexOf("MSIE")))));break;case"Netscape":window.addEventListener&&(a.indexOf("Edge")>=0?(e.Browser.vendor=e.BROWSERS.EDGE,e.Browser.version=parseFloat(a.substring(a.indexOf("Edge")+5))):a.indexOf("Edg")>=0?(e.Browser.vendor=e.BROWSERS.CHROMEEDGE,e.Browser.version=parseFloat(a.substring(a.indexOf("Edg")+4))):a.indexOf("Firefox")>=0?(e.Browser.vendor=e.BROWSERS.FIREFOX,e.Browser.version=parseFloat(a.substring(a.indexOf("Firefox")+8))):a.indexOf("Safari")>=0?(e.Browser.vendor=a.indexOf("Chrome")>=0?e.BROWSERS.CHROME:e.BROWSERS.SAFARI,e.Browser.version=parseFloat(a.substring(a.substring(0,a.indexOf("Safari")).lastIndexOf("/")+1,a.indexOf("Safari")))):(h=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})"),h.exec(a)!==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(l);break}var c=window.location.search.substring(1),d=c.split("&"),g,m,_;for(_=0;_<d.length;_++)if(g=d[_],m=g.indexOf("="),m>0){var y=g.substring(0,m),E=g.substring(m+1);try{o[y]=decodeURIComponent(E)}catch{e.console.error("Ignoring malformed URL parameter: %s=%s",y,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(l){var a=l.requestAnimationFrame||l.mozRequestAnimationFrame||l.webkitRequestAnimationFrame||l.msRequestAnimationFrame,h=l.cancelAnimationFrame||l.mozCancelAnimationFrame||l.webkitCancelAnimationFrame||l.msCancelAnimationFrame;if(a&&h)e.requestAnimationFrame=function(){return a.apply(l,arguments)},e.cancelAnimationFrame=function(){return h.apply(l,arguments)};else{var c=[],d=[],g=0,m;e.requestAnimationFrame=function(_){return c.push([++g,_]),m||(m=setInterval(function(){if(c.length){var y=e.now(),E=d;for(d=c,c=E;d.length;)d.shift()[1](y)}else clearInterval(m),m=void 0},1e3/50)),g},e.cancelAnimationFrame=function(_){var y,E;for(y=0,E=c.length;y<E;y+=1)if(c[y][0]===_){c.splice(y,1);return}for(y=0,E=d.length;y<E;y+=1)if(d[y][0]===_){d.splice(y,1);return}}}})(window);function u(l,a){return a&&l!==document.body?document.body:l.offsetParent}})(s),(function(e,t){r.exports?r.exports=t():e.OpenSeadragon=t()})(Il,function(){return s}),(function(e){class t{constructor(n){n||(n=[0,0,0,0,0,0,0,0,0]),this.values=n}static makeIdentity(){return new t([1,0,0,0,1,0,0,0,1])}static makeTranslation(n,o){return new t([1,0,0,0,1,0,n,o,1])}static makeRotation(n){var o=Math.cos(n),u=Math.sin(n);return new t([o,-u,0,u,o,0,0,0,1])}static makeScaling(n,o){return new t([n,0,0,0,o,0,0,0,1])}multiply(n){let o=this.values,u=n.values;var l=o[0],a=o[1],h=o[2],c=o[3],d=o[4],g=o[5],m=o[6],_=o[7],y=o[8],E=u[0],S=u[1],P=u[2],B=u[3],k=u[4],M=u[5],L=u[6],W=u[7],$=u[8];return new t([E*l+S*c+P*m,E*a+S*d+P*_,E*h+S*g+P*y,B*l+k*c+M*m,B*a+k*d+M*_,B*h+k*g+M*y,L*l+W*c+$*m,L*a+W*d+$*_,L*h+W*g+$*y])}}e.Mat3=t})(s),(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(i){return i.requestFullscreen().catch(function(n){e.console.error("Fullscreen request failed: ",n)})},t.exitFullScreen=function(){document.exitFullscreen().catch(function(i){e.console.error("Error while exiting fullscreen: ",i)})},t.fullScreenEventName="fullscreenchange",t.fullScreenErrorEventName="fullscreenerror"):document.msExitFullscreen?(t.supportsFullScreen=!0,t.getFullScreenElement=function(){return document.msFullscreenElement},t.requestFullScreen=function(i){return i.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(i){return i.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(i){return i.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(i){return i.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)})(s),(function(e){e.EventSource=function(){this.events={},this._rejectedEventList={}},e.EventSource.prototype={addOnceHandler:function(t,i,n,o,u){var l=this;o=o||1;var a=0,h=function(c){return a++,a===o&&l.removeHandler(t,h),i(c)};return this.addHandler(t,h,n,u)},addHandler:function(t,i,n,o){if(Object.prototype.hasOwnProperty.call(this._rejectedEventList,t))return e.console.error(`Error adding handler for ${t}. ${this._rejectedEventList[t]}`),!1;var u=this.events[t];if(u||(this.events[t]=u=[]),i&&e.isFunction(i)){var l=u.length,a={handler:i,userData:n||null,priority:o||0};for(u[l]=a;l>0&&u[l-1].priority<u[l].priority;)u[l]=u[l-1],u[l-1]=a,l--}return!0},removeHandler:function(t,i){var n=this.events[t],o=[],u;if(n&&e.isArray(n)){for(u=0;u<n.length;u++)n[u].handler!==i&&o.push(n[u]);this.events[t]=o}},numberOfHandlers:function(t){var i=this.events[t];return i?i.length:0},removeAllHandlers:function(t){if(t)this.events[t]=[];else for(var i in this.events)this.events[i]=[]},getHandler:function(t){var i=this.events[t];return!i||!i.length?null:(i=i.length===1?[i[0]]:Array.apply(null,i),function(n,o){var u,l=i.length;for(u=0;u<l;u++)i[u]&&(o.eventSource=n,o.userData=i[u].userData,i[u].handler(o))})},raiseEvent:function(t,i){if(Object.prototype.hasOwnProperty.call(this._rejectedEventList,t))return e.console.error(`Error adding handler for ${t}. ${this._rejectedEventList[t]}`),!1;var n=this.getHandler(t);return n&&n(this,i||{}),!0},rejectEventHandler(t,i=""){this._rejectedEventList[t]=i},allowEventHandler(t){delete this._rejectedEventList[t]}}})(s),(function(e){var t={};e.MouseTracker=function(v){var f=arguments;e.isPlainObject(v)||(v={element:f[0],clickTimeThreshold:f[1],clickDistThreshold:f[2]}),this.hash=Math.random(),this.element=e.getElement(v.element),this.clickTimeThreshold=v.clickTimeThreshold||e.DEFAULT_SETTINGS.clickTimeThreshold,this.clickDistThreshold=v.clickDistThreshold||e.DEFAULT_SETTINGS.clickDistThreshold,this.dblClickTimeThreshold=v.dblClickTimeThreshold||e.DEFAULT_SETTINGS.dblClickTimeThreshold,this.dblClickDistThreshold=v.dblClickDistThreshold||e.DEFAULT_SETTINGS.dblClickDistThreshold,this.userData=v.userData||null,this.stopDelay=v.stopDelay||50,this.preProcessEventHandler=v.preProcessEventHandler||null,this.contextMenuHandler=v.contextMenuHandler||null,this.enterHandler=v.enterHandler||null,this.leaveHandler=v.leaveHandler||null,this.exitHandler=v.exitHandler||null,this.overHandler=v.overHandler||null,this.outHandler=v.outHandler||null,this.pressHandler=v.pressHandler||null,this.nonPrimaryPressHandler=v.nonPrimaryPressHandler||null,this.releaseHandler=v.releaseHandler||null,this.nonPrimaryReleaseHandler=v.nonPrimaryReleaseHandler||null,this.moveHandler=v.moveHandler||null,this.scrollHandler=v.scrollHandler||null,this.clickHandler=v.clickHandler||null,this.dblClickHandler=v.dblClickHandler||null,this.dragHandler=v.dragHandler||null,this.dragEndHandler=v.dragEndHandler||null,this.pinchHandler=v.pinchHandler||null,this.stopHandler=v.stopHandler||null,this.keyDownHandler=v.keyDownHandler||null,this.keyUpHandler=v.keyUpHandler||null,this.keyHandler=v.keyHandler||null,this.focusHandler=v.focusHandler||null,this.blurHandler=v.blurHandler||null;var w=this;t[this.hash]={click:function(T){P(w,T)},dblclick:function(T){B(w,T)},keydown:function(T){k(w,T)},keyup:function(T){M(w,T)},keypress:function(T){L(w,T)},focus:function(T){W(w,T)},blur:function(T){$(w,T)},contextmenu:function(T){Q(w,T)},wheel:function(T){q(w,T)},mousewheel:function(T){V(w,T)},DOMMouseScroll:function(T){V(w,T)},MozMousePixelScroll:function(T){V(w,T)},losecapture:function(T){he(w,T)},mouseenter:function(T){Y(w,T)},mouseleave:function(T){$e(w,T)},mouseover:function(T){ct(w,T)},mouseout:function(T){Ue(w,T)},mousedown:function(T){z(w,T)},mouseup:function(T){ie(w,T)},mousemove:function(T){Ye(w,T)},touchstart:function(T){de(w,T)},touchend:function(T){pe(w,T)},touchmove:function(T){ge(w,T)},touchcancel:function(T){me(w,T)},gesturestart:function(T){Pe(w,T)},gesturechange:function(T){Le(w,T)},gotpointercapture:function(T){xe(w,T)},lostpointercapture:function(T){Xe(w,T)},pointerenter:function(T){Y(w,T)},pointerleave:function(T){$e(w,T)},pointerover:function(T){ct(w,T)},pointerout:function(T){Ue(w,T)},pointerdown:function(T){z(w,T)},pointerup:function(T){ie(w,T)},pointermove:function(T){Ye(w,T)},pointercancel:function(T){Ut(w,T)},pointerupcaptured:function(T){ce(w,T)},pointermovecaptured:function(T){St(w,T)},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."),v.startDisabled||this.setTracking(!0)},e.MouseTracker.prototype={destroy:function(){l(this),this.element=null,t[this.hash]=null,delete t[this.hash]},isTracking:function(){return t[this.hash].tracking},setTracking:function(v){return v?u(this):l(this),this},getActivePointersListByType:function(v){var f=t[this.hash],w,T=f?f.activePointersLists.length:0,R;for(w=0;w<T;w++)if(f.activePointersLists[w].type===v)return f.activePointersLists[w];return R=new e.MouseTracker.GesturePointList(v),f&&f.activePointersLists.push(R),R},getActivePointerCount:function(){var v=t[this.hash],f,w=v.activePointersLists.length,T=0;for(f=0;f<w;f++)T+=v.activePointersLists[f].getLength();return T},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 i=(function(){try{return window.self!==window.top}catch{return!0}})();function n(v){try{return v.addEventListener&&v.removeEventListener}catch{return!1}}e.MouseTracker.gesturePointVelocityTracker=(function(){var v=[],f=0,w=0,T=function(J,j){return J.hash.toString()+j.type+j.id.toString()},R=function(){var J,j=v.length,se,oe,Ke=e.now(),Wt,zr,Hr;for(Wt=Ke-w,w=Ke,J=0;J<j;J++)se=v[J],oe=se.gPoint,oe.direction=Math.atan2(oe.currentPos.y-se.lastPos.y,oe.currentPos.x-se.lastPos.x),zr=se.lastPos.distanceTo(oe.currentPos),se.lastPos=oe.currentPos,Hr=1e3*zr/(Wt+1),oe.speed=.75*Hr+.25*oe.speed},I=function(J,j){var se=T(J,j);v.push({guid:se,gPoint:j,lastPos:j.currentPos}),v.length===1&&(w=e.now(),f=window.setInterval(R,50))},N=function(J,j){var se=T(J,j),oe,Ke=v.length;for(oe=0;oe<Ke;oe++)if(v[oe].guid===se){v.splice(oe,1),Ke--,Ke===0&&window.clearInterval(f);break}};return{addPoint:I,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 v=document.createElement("div");return e.isFunction(v.setPointerCapture)&&e.isFunction(v.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 v=document.createElement("div");return e.isFunction(v.setCapture)&&e.isFunction(v.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(v){this._gPoints=[],this.type=v,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(v){return this._gPoints.push(v)},removeById:function(v){var f,w=this._gPoints.length;for(f=0;f<w;f++)if(this._gPoints[f].id===v){this._gPoints.splice(f,1);break}return this._gPoints.length},getByIndex:function(v){return v<this._gPoints.length?this._gPoints[v]:null},getById:function(v){var f,w=this._gPoints.length;for(f=0;f<w;f++)if(this._gPoints[f].id===v)return this._gPoints[f];return null},getPrimary:function(v){var f,w=this._gPoints.length;for(f=0;f<w;f++)if(this._gPoints[f].isPrimary)return this._gPoints[f];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 o(v){var f=t[v.hash],w,T,R,I,N,J=f.activePointersLists.length;for(w=0;w<J;w++)if(R=f.activePointersLists[w],R.getLength()>0){for(N=[],I=R.asArray(),T=0;T<I.length;T++)N.push(I[T]);for(T=0;T<N.length;T++)dt(v,R,N[T])}for(w=0;w<J;w++)f.activePointersLists.pop();f.sentDragEvent=!1}function u(v){var f=t[v.hash],w,T;if(!f.tracking){for(T=0;T<e.MouseTracker.subscribeEvents.length;T++)w=e.MouseTracker.subscribeEvents[T],e.addEvent(v.element,w,f[w],w===e.MouseTracker.wheelEventName?{passive:!1,capture:!1}:!1);o(v),f.tracking=!0}}function l(v){var f=t[v.hash],w,T;if(f.tracking){for(T=0;T<e.MouseTracker.subscribeEvents.length;T++)w=e.MouseTracker.subscribeEvents[T],e.removeEvent(v.element,w,f[w],!1);o(v),f.tracking=!1}}function a(v,f){var w=t[v.hash];if(f==="pointerevent")return{upName:"pointerup",upHandler:w.pointerupcaptured,moveName:"pointermove",moveHandler:w.pointermovecaptured};if(f==="mouse")return{upName:"pointerup",upHandler:w.pointerupcaptured,moveName:"pointermove",moveHandler:w.pointermovecaptured};if(f==="touch")return{upName:"touchend",upHandler:w.touchendcaptured,moveName:"touchmove",moveHandler:w.touchmovecaptured};throw new Error("MouseTracker.getCaptureEventParams: Unknown pointer type.")}function h(v,f){var w;if(e.MouseTracker.havePointerCapture)if(e.MouseTracker.havePointerEvents)try{v.element.setPointerCapture(f.id)}catch{e.console.warn("setPointerCapture() called on invalid pointer ID");return}else v.element.setCapture(!0);else w=a(v,e.MouseTracker.havePointerEvents?"pointerevent":f.type),i&&n(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);C(v,f,!0)}function c(v,f){var w,T,R;if(e.MouseTracker.havePointerCapture)if(e.MouseTracker.havePointerEvents){if(T=v.getActivePointersListByType(f.type),R=T.getById(f.id),!R||!R.captured)return;try{v.element.releasePointerCapture(f.id)}catch{}}else v.element.releaseCapture();else w=a(v,e.MouseTracker.havePointerEvents?"pointerevent":f.type),i&&n(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);C(v,f,!1)}function d(v){return e.MouseTracker.havePointerEvents?v.pointerId:e.MouseTracker.mousePointerId}function g(v){return e.MouseTracker.havePointerEvents&&v.pointerType?v.pointerType:"mouse"}function m(v){return e.MouseTracker.havePointerEvents?v.isPrimary:!0}function _(v){return e.getMousePosition(v)}function y(v,f){return E(_(v),f)}function E(v,f){var w=e.getElementOffset(f);return v.minus(w)}function S(v,f){return new e.Point((v.x+f.x)/2,(v.y+f.y)/2)}function P(v,f){var w={originalEvent:f,eventType:"click",pointerType:"mouse",isEmulated:!1};x(v,w),w.preventDefault&&!w.defaultPrevented&&e.cancelEvent(f),w.stopPropagation&&e.stopEvent(f)}function B(v,f){var w={originalEvent:f,eventType:"dblclick",pointerType:"mouse",isEmulated:!1};x(v,w),w.preventDefault&&!w.defaultPrevented&&e.cancelEvent(f),w.stopPropagation&&e.stopEvent(f)}function k(v,f){var w=null,T={originalEvent:f,eventType:"keydown",pointerType:"",isEmulated:!1};x(v,T),v.keyDownHandler&&!T.preventGesture&&!T.defaultPrevented&&(w={eventSource:v,keyCode:f.keyCode?f.keyCode:f.charCode,ctrl:f.ctrlKey,shift:f.shiftKey,alt:f.altKey,meta:f.metaKey,originalEvent:f,preventDefault:T.preventDefault||T.defaultPrevented,userData:v.userData},v.keyDownHandler(w)),(w&&w.preventDefault||T.preventDefault&&!T.defaultPrevented)&&e.cancelEvent(f),T.stopPropagation&&e.stopEvent(f)}function M(v,f){var w=null,T={originalEvent:f,eventType:"keyup",pointerType:"",isEmulated:!1};x(v,T),v.keyUpHandler&&!T.preventGesture&&!T.defaultPrevented&&(w={eventSource:v,keyCode:f.keyCode?f.keyCode:f.charCode,ctrl:f.ctrlKey,shift:f.shiftKey,alt:f.altKey,meta:f.metaKey,originalEvent:f,preventDefault:T.preventDefault||T.defaultPrevented,userData:v.userData},v.keyUpHandler(w)),(w&&w.preventDefault||T.preventDefault&&!T.defaultPrevented)&&e.cancelEvent(f),T.stopPropagation&&e.stopEvent(f)}function L(v,f){var w=null,T={originalEvent:f,eventType:"keypress",pointerType:"",isEmulated:!1};x(v,T),v.keyHandler&&!T.preventGesture&&!T.defaultPrevented&&(w={eventSource:v,keyCode:f.keyCode?f.keyCode:f.charCode,ctrl:f.ctrlKey,shift:f.shiftKey,alt:f.altKey,meta:f.metaKey,originalEvent:f,preventDefault:T.preventDefault||T.defaultPrevented,userData:v.userData},v.keyHandler(w)),(w&&w.preventDefault||T.preventDefault&&!T.defaultPrevented)&&e.cancelEvent(f),T.stopPropagation&&e.stopEvent(f)}function W(v,f){var w={originalEvent:f,eventType:"focus",pointerType:"",isEmulated:!1};x(v,w),v.focusHandler&&!w.preventGesture&&v.focusHandler({eventSource:v,originalEvent:f,userData:v.userData})}function $(v,f){var w={originalEvent:f,eventType:"blur",pointerType:"",isEmulated:!1};x(v,w),v.blurHandler&&!w.preventGesture&&v.blurHandler({eventSource:v,originalEvent:f,userData:v.userData})}function Q(v,f){var w=null,T={originalEvent:f,eventType:"contextmenu",pointerType:"mouse",isEmulated:!1};x(v,T),v.contextMenuHandler&&!T.preventGesture&&!T.defaultPrevented&&(w={eventSource:v,position:E(_(f),v.element),originalEvent:T.originalEvent,preventDefault:T.preventDefault||T.defaultPrevented,userData:v.userData},v.contextMenuHandler(w)),(w&&w.preventDefault||T.preventDefault&&!T.defaultPrevented)&&e.cancelEvent(f),T.stopPropagation&&e.stopEvent(f)}function q(v,f){re(v,f,f)}function V(v,f){var w={target:f.target||f.srcElement,type:"wheel",shiftKey:f.shiftKey||!1,clientX:f.clientX,clientY:f.clientY,pageX:f.pageX?f.pageX:f.clientX,pageY:f.pageY?f.pageY:f.clientY,deltaMode:f.type==="MozMousePixelScroll"?0:1,deltaX:0,deltaZ:0};e.MouseTracker.wheelEventName==="mousewheel"?w.deltaY=-f.wheelDelta/e.DEFAULT_SETTINGS.pixelsPerWheelLine:w.deltaY=f.detail,re(v,w,f)}function re(v,f,w){var T=0,R,I=null;T=f.deltaY?f.deltaY<0?1:-1:0,R={originalEvent:f,eventType:"wheel",pointerType:"mouse",isEmulated:f!==w},x(v,R),v.scrollHandler&&!R.preventGesture&&!R.defaultPrevented&&(I={eventSource:v,pointerType:"mouse",position:y(f,v.element),scroll:T,shift:f.shiftKey,isTouchEvent:!1,originalEvent:w,preventDefault:R.preventDefault||R.defaultPrevented,userData:v.userData},v.scrollHandler(I)),R.stopPropagation&&e.stopEvent(w),(I&&I.preventDefault||R.preventDefault&&!R.defaultPrevented)&&e.cancelEvent(w)}function he(v,f){var w={id:e.MouseTracker.mousePointerId,type:"mouse"},T={originalEvent:f,eventType:"lostpointercapture",pointerType:"mouse",isEmulated:!1};x(v,T),f.target===v.element&&C(v,w,!1),T.stopPropagation&&e.stopEvent(f)}function de(v,f){var w,T,R=f.changedTouches.length,I,N=v.getActivePointersListByType("touch");w=e.now(),N.getLength()>f.touches.length-R&&e.console.warn("Tracked touch contact count doesn't match event.touches.length");var J={originalEvent:f,eventType:"pointerdown",pointerType:"touch",isEmulated:!1};for(x(v,J),T=0;T<R;T++)I={id:f.changedTouches[T].identifier,type:"touch",isPrimary:N.getLength()===0,currentPos:_(f.changedTouches[T]),currentTime:w},O(v,J,I),H(v,J,I,0),C(v,I,!0);J.preventDefault&&!J.defaultPrevented&&e.cancelEvent(f),J.stopPropagation&&e.stopEvent(f)}function pe(v,f){var w,T,R=f.changedTouches.length,I;w=e.now();var N={originalEvent:f,eventType:"pointerup",pointerType:"touch",isEmulated:!1};for(x(v,N),T=0;T<R;T++)I={id:f.changedTouches[T].identifier,type:"touch",currentPos:_(f.changedTouches[T]),currentTime:w},G(v,N,I,0),C(v,I,!1),F(v,N,I);N.preventDefault&&!N.defaultPrevented&&e.cancelEvent(f),N.stopPropagation&&e.stopEvent(f)}function ge(v,f){var w,T,R=f.changedTouches.length,I;w=e.now();var N={originalEvent:f,eventType:"pointermove",pointerType:"touch",isEmulated:!1};for(x(v,N),T=0;T<R;T++)I={id:f.changedTouches[T].identifier,type:"touch",currentPos:_(f.changedTouches[T]),currentTime:w},X(v,N,I);N.preventDefault&&!N.defaultPrevented&&e.cancelEvent(f),N.stopPropagation&&e.stopEvent(f)}function me(v,f){var w=f.changedTouches.length,T,R,I={originalEvent:f,eventType:"pointercancel",pointerType:"touch",isEmulated:!1};for(x(v,I),T=0;T<w;T++)R={id:f.changedTouches[T].identifier,type:"touch"},U(v,I,R);I.stopPropagation&&e.stopEvent(f)}function Pe(v,f){return e.eventIsCanceled(f)||f.preventDefault(),!1}function Le(v,f){return e.eventIsCanceled(f)||f.preventDefault(),!1}function xe(v,f){var w={originalEvent:f,eventType:"gotpointercapture",pointerType:g(f),isEmulated:!1};x(v,w),f.target===v.element&&C(v,{id:f.pointerId,type:g(f)},!0),w.stopPropagation&&e.stopEvent(f)}function Xe(v,f){var w={originalEvent:f,eventType:"lostpointercapture",pointerType:g(f),isEmulated:!1};x(v,w),f.target===v.element&&C(v,{id:f.pointerId,type:g(f)},!1),w.stopPropagation&&e.stopEvent(f)}function Y(v,f){var w={id:d(f),type:g(f),isPrimary:m(f),currentPos:_(f),currentTime:e.now()},T={originalEvent:f,eventType:"pointerenter",pointerType:w.type,isEmulated:!1};x(v,T),O(v,T,w)}function $e(v,f){var w={id:d(f),type:g(f),isPrimary:m(f),currentPos:_(f),currentTime:e.now()},T={originalEvent:f,eventType:"pointerleave",pointerType:w.type,isEmulated:!1};x(v,T),F(v,T,w)}function ct(v,f){var w={id:d(f),type:g(f),isPrimary:m(f),currentPos:_(f),currentTime:e.now()},T={originalEvent:f,eventType:"pointerover",pointerType:w.type,isEmulated:!1};x(v,T),A(v,T,w),T.preventDefault&&!T.defaultPrevented&&e.cancelEvent(f),T.stopPropagation&&e.stopEvent(f)}function Ue(v,f){var w={id:d(f),type:g(f),isPrimary:m(f),currentPos:_(f),currentTime:e.now()},T={originalEvent:f,eventType:"pointerout",pointerType:w.type,isEmulated:!1};x(v,T),D(v,T,w),T.preventDefault&&!T.defaultPrevented&&e.cancelEvent(f),T.stopPropagation&&e.stopEvent(f)}function z(v,f){var w={id:d(f),type:g(f),isPrimary:m(f),currentPos:_(f),currentTime:e.now()},T=e.MouseTracker.havePointerEvents&&w.type==="touch",R={originalEvent:f,eventType:"pointerdown",pointerType:w.type,isEmulated:!1};x(v,R),H(v,R,w,f.button),R.preventDefault&&!R.defaultPrevented&&e.cancelEvent(f),R.stopPropagation&&e.stopEvent(f),R.shouldCapture&&(T?C(v,w,!0):h(v,w))}function ie(v,f){we(v,f)}function ce(v,f){var w=v.getActivePointersListByType(g(f));w.getById(f.pointerId)&&we(v,f),e.stopEvent(f)}function we(v,f){var w;w={id:d(f),type:g(f),isPrimary:m(f),currentPos:_(f),currentTime:e.now()};var T={originalEvent:f,eventType:"pointerup",pointerType:w.type,isEmulated:!1};x(v,T),G(v,T,w,f.button),T.preventDefault&&!T.defaultPrevented&&e.cancelEvent(f),T.stopPropagation&&e.stopEvent(f),T.shouldReleaseCapture&&(f.target===v.element?c(v,w):C(v,w,!1))}function Ye(v,f){Nt(v,f)}function St(v,f){var w=v.getActivePointersListByType(g(f));w.getById(f.pointerId)&&Nt(v,f),e.stopEvent(f)}function Nt(v,f){var w={id:d(f),type:g(f),isPrimary:m(f),currentPos:_(f),currentTime:e.now()},T={originalEvent:f,eventType:"pointermove",pointerType:w.type,isEmulated:!1};x(v,T),X(v,T,w),T.preventDefault&&!T.defaultPrevented&&e.cancelEvent(f),T.stopPropagation&&e.stopEvent(f)}function Ut(v,f){var w={id:f.pointerId,type:g(f)},T={originalEvent:f,eventType:"pointercancel",pointerType:w.type,isEmulated:!1};x(v,T),U(v,T,w),T.stopPropagation&&e.stopEvent(f)}function Pt(v,f){return f.speed=0,f.direction=0,f.contactPos=f.currentPos,f.contactTime=f.currentTime,f.lastPos=f.currentPos,f.lastTime=f.currentTime,v.add(f)}function dt(v,f,w){var T,R=f.getById(w.id);return R?(R.captured&&(e.console.warn("stopTrackingPointer() called on captured pointer"),c(v,R)),f.removeContact(),T=f.removeById(w.id)):T=f.getLength(),T}function p(v,f){switch(f.eventType){case"pointermove":f.isStoppable=!0,f.isCancelable=!0,f.preventDefault=!1,f.preventGesture=!v.hasGestureHandlers,f.stopPropagation=!1;break;case"pointerover":case"pointerout":case"contextmenu":case"keydown":case"keyup":case"keypress":f.isStoppable=!0,f.isCancelable=!0,f.preventDefault=!1,f.preventGesture=!1,f.stopPropagation=!1;break;case"pointerdown":f.isStoppable=!0,f.isCancelable=!0,f.preventDefault=!1,f.preventGesture=!v.hasGestureHandlers,f.stopPropagation=!1;break;case"pointerup":f.isStoppable=!0,f.isCancelable=!0,f.preventDefault=!1,f.preventGesture=!v.hasGestureHandlers,f.stopPropagation=!1;break;case"wheel":f.isStoppable=!0,f.isCancelable=!0,f.preventDefault=!1,f.preventGesture=!v.hasScrollHandler,f.stopPropagation=!1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":f.isStoppable=!0,f.isCancelable=!1,f.preventDefault=!1,f.preventGesture=!1,f.stopPropagation=!1;break;case"click":f.isStoppable=!0,f.isCancelable=!0,f.preventDefault=!!v.clickHandler,f.preventGesture=!1,f.stopPropagation=!1;break;case"dblclick":f.isStoppable=!0,f.isCancelable=!0,f.preventDefault=!!v.dblClickHandler,f.preventGesture=!1,f.stopPropagation=!1;break;case"focus":case"blur":case"pointerenter":case"pointerleave":default:f.isStoppable=!1,f.isCancelable=!1,f.preventDefault=!1,f.preventGesture=!1,f.stopPropagation=!1;break}}function x(v,f){f.eventSource=v,f.eventPhase=f.originalEvent&&typeof f.originalEvent.eventPhase<"u"?f.originalEvent.eventPhase:0,f.defaultPrevented=e.eventIsCanceled(f.originalEvent),f.shouldCapture=!1,f.shouldReleaseCapture=!1,f.userData=v.userData,p(v,f),v.preProcessEventHandler&&v.preProcessEventHandler(f)}function C(v,f,w){var T=v.getActivePointersListByType(f.type),R=T.getById(f.id);R?w&&!R.captured?(R.captured=!0,T.captureCount++):!w&&R.captured&&(R.captured=!1,T.captureCount--,T.captureCount<0&&(T.captureCount=0,e.console.warn("updatePointerCaptured() - pointsList.captureCount went negative"))):e.console.warn("updatePointerCaptured() called on untracked pointer")}function O(v,f,w){var T=v.getActivePointersListByType(w.type),R;R=T.getById(w.id),R?(R.insideElement=!0,R.lastPos=R.currentPos,R.lastTime=R.currentTime,R.currentPos=w.currentPos,R.currentTime=w.currentTime,w=R):(w.captured=!1,w.insideElementPressed=!1,w.insideElement=!0,Pt(T,w)),v.enterHandler&&v.enterHandler({eventSource:v,pointerType:w.type,position:E(w.currentPos,v.element),buttons:T.buttons,pointers:v.getActivePointerCount(),insideElementPressed:w.insideElementPressed,buttonDownAny:T.buttons!==0,isTouchEvent:w.type==="touch",originalEvent:f.originalEvent,userData:v.userData})}function F(v,f,w){var T=v.getActivePointersListByType(w.type),R,I;R=T.getById(w.id),R?(R.captured?(R.insideElement=!1,R.lastPos=R.currentPos,R.lastTime=R.currentTime,R.currentPos=w.currentPos,R.currentTime=w.currentTime):dt(v,T,R),w=R):(w.captured=!1,w.insideElementPressed=!1),(v.leaveHandler||v.exitHandler)&&(I={eventSource:v,pointerType:w.type,position:w.currentPos&&E(w.currentPos,v.element),buttons:T.buttons,pointers:v.getActivePointerCount(),insideElementPressed:w.insideElementPressed,buttonDownAny:T.buttons!==0,isTouchEvent:w.type==="touch",originalEvent:f.originalEvent,userData:v.userData},v.leaveHandler&&v.leaveHandler(I),v.exitHandler&&v.exitHandler(I))}function A(v,f,w){var T,R;T=v.getActivePointersListByType(w.type),R=T.getById(w.id),R?w=R:(w.captured=!1,w.insideElementPressed=!1),v.overHandler&&v.overHandler({eventSource:v,pointerType:w.type,position:E(w.currentPos,v.element),buttons:T.buttons,pointers:v.getActivePointerCount(),insideElementPressed:w.insideElementPressed,buttonDownAny:T.buttons!==0,isTouchEvent:w.type==="touch",originalEvent:f.originalEvent,userData:v.userData})}function D(v,f,w){var T,R;T=v.getActivePointersListByType(w.type),R=T.getById(w.id),R?w=R:(w.captured=!1,w.insideElementPressed=!1),v.outHandler&&v.outHandler({eventSource:v,pointerType:w.type,position:w.currentPos&&E(w.currentPos,v.element),buttons:T.buttons,pointers:v.getActivePointerCount(),insideElementPressed:w.insideElementPressed,buttonDownAny:T.buttons!==0,isTouchEvent:w.type==="touch",originalEvent:f.originalEvent,userData:v.userData})}function H(v,f,w,T){var R=t[v.hash],I=v.getActivePointersListByType(w.type),N;if(typeof f.originalEvent.buttons<"u"?I.buttons=f.originalEvent.buttons:T===0?I.buttons|=1:T===1?I.buttons|=4:T===2?I.buttons|=2:T===3?I.buttons|=8:T===4?I.buttons|=16:T===5&&(I.buttons|=32),T!==0){f.shouldCapture=!1,f.shouldReleaseCapture=!1,v.nonPrimaryPressHandler&&!f.preventGesture&&!f.defaultPrevented&&(f.preventDefault=!0,v.nonPrimaryPressHandler({eventSource:v,pointerType:w.type,position:E(w.currentPos,v.element),button:T,buttons:I.buttons,isTouchEvent:w.type==="touch",originalEvent:f.originalEvent,userData:v.userData}));return}N=I.getById(w.id),N?(N.insideElementPressed=!0,N.insideElement=!0,N.originalTarget=f.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=f.originalEvent.target,Pt(I,w)),I.addContact(),!f.preventGesture&&!f.defaultPrevented?(f.shouldCapture=!0,f.shouldReleaseCapture=!1,f.preventDefault=!0,(v.dragHandler||v.dragEndHandler||v.pinchHandler)&&e.MouseTracker.gesturePointVelocityTracker.addPoint(v,w),I.contacts===1?v.pressHandler&&!f.preventGesture&&v.pressHandler({eventSource:v,pointerType:w.type,position:E(w.contactPos,v.element),buttons:I.buttons,isTouchEvent:w.type==="touch",originalEvent:f.originalEvent,userData:v.userData}):I.contacts===2&&v.pinchHandler&&w.type==="touch"&&(R.pinchGPoints=I.asArray(),R.lastPinchDist=R.currentPinchDist=R.pinchGPoints[0].currentPos.distanceTo(R.pinchGPoints[1].currentPos),R.lastPinchCenter=R.currentPinchCenter=S(R.pinchGPoints[0].currentPos,R.pinchGPoints[1].currentPos))):(f.shouldCapture=!1,f.shouldReleaseCapture=!1)}function G(v,f,w,T){var R=t[v.hash],I=v.getActivePointersListByType(w.type),N,J,j,se=!1,oe;if(typeof f.originalEvent.buttons<"u"?I.buttons=f.originalEvent.buttons:T===0?I.buttons^=-2:T===1?I.buttons^=-5:T===2?I.buttons^=-3:T===3?I.buttons^=-9:T===4?I.buttons^=-17:T===5&&(I.buttons^=-33),f.shouldCapture=!1,T!==0){f.shouldReleaseCapture=!1,v.nonPrimaryReleaseHandler&&!f.preventGesture&&!f.defaultPrevented&&(f.preventDefault=!0,v.nonPrimaryReleaseHandler({eventSource:v,pointerType:w.type,position:E(w.currentPos,v.element),button:T,buttons:I.buttons,isTouchEvent:w.type==="touch",originalEvent:f.originalEvent,userData:v.userData}));return}j=I.getById(w.id),j?(I.removeContact(),j.captured&&(se=!0),j.lastPos=j.currentPos,j.lastTime=j.currentTime,j.currentPos=w.currentPos,j.currentTime=w.currentTime,j.insideElement||dt(v,I,j),N=j.currentPos,J=j.currentTime):(w.captured=!1,w.insideElementPressed=!1,w.insideElement=!0,Pt(I,w),j=w),!f.preventGesture&&!f.defaultPrevented&&(se?(f.shouldReleaseCapture=!0,f.preventDefault=!0,(v.dragHandler||v.dragEndHandler||v.pinchHandler)&&e.MouseTracker.gesturePointVelocityTracker.removePoint(v,j),I.contacts===0?(v.releaseHandler&&N&&v.releaseHandler({eventSource:v,pointerType:j.type,position:E(N,v.element),buttons:I.buttons,insideElementPressed:j.insideElementPressed,insideElementReleased:j.insideElement,isTouchEvent:j.type==="touch",originalEvent:f.originalEvent,userData:v.userData}),v.dragEndHandler&&R.sentDragEvent&&v.dragEndHandler({eventSource:v,pointerType:j.type,position:E(j.currentPos,v.element),speed:j.speed,direction:j.direction,shift:f.originalEvent.shiftKey,isTouchEvent:j.type==="touch",originalEvent:f.originalEvent,userData:v.userData}),R.sentDragEvent=!1,(v.clickHandler||v.dblClickHandler)&&j.insideElement&&(oe=J-j.contactTime<=v.clickTimeThreshold&&j.contactPos.distanceTo(N)<=v.clickDistThreshold,v.clickHandler&&v.clickHandler({eventSource:v,pointerType:j.type,position:E(j.currentPos,v.element),quick:oe,shift:f.originalEvent.shiftKey,isTouchEvent:j.type==="touch",originalEvent:f.originalEvent,originalTarget:j.originalTarget,userData:v.userData}),v.dblClickHandler&&oe&&(I.clicks++,I.clicks===1?(R.lastClickPos=N,R.dblClickTimeOut=setTimeout(function(){I.clicks=0},v.dblClickTimeThreshold)):I.clicks===2&&(clearTimeout(R.dblClickTimeOut),I.clicks=0,R.lastClickPos.distanceTo(N)<=v.dblClickDistThreshold&&v.dblClickHandler({eventSource:v,pointerType:j.type,position:E(j.currentPos,v.element),shift:f.originalEvent.shiftKey,isTouchEvent:j.type==="touch",originalEvent:f.originalEvent,userData:v.userData}),R.lastClickPos=null)))):I.contacts===2&&v.pinchHandler&&j.type==="touch"&&(R.pinchGPoints=I.asArray(),R.lastPinchDist=R.currentPinchDist=R.pinchGPoints[0].currentPos.distanceTo(R.pinchGPoints[1].currentPos),R.lastPinchCenter=R.currentPinchCenter=S(R.pinchGPoints[0].currentPos,R.pinchGPoints[1].currentPos))):(f.shouldReleaseCapture=!1,v.releaseHandler&&N&&(v.releaseHandler({eventSource:v,pointerType:j.type,position:E(N,v.element),buttons:I.buttons,insideElementPressed:j.insideElementPressed,insideElementReleased:j.insideElement,isTouchEvent:j.type==="touch",originalEvent:f.originalEvent,userData:v.userData}),f.preventDefault=!0)))}function X(v,f,w){var T=t[v.hash],R=v.getActivePointersListByType(w.type),I,N,J;if(typeof f.originalEvent.buttons<"u"&&(R.buttons=f.originalEvent.buttons),I=R.getById(w.id),I)I.lastPos=I.currentPos,I.lastTime=I.currentTime,I.currentPos=w.currentPos,I.currentTime=w.currentTime;else return;f.shouldCapture=!1,f.shouldReleaseCapture=!1,v.stopHandler&&w.type==="mouse"&&(clearTimeout(v.stopTimeOut),v.stopTimeOut=setTimeout(function(){K(v,f.originalEvent,w.type)},v.stopDelay)),R.contacts===0?v.moveHandler&&v.moveHandler({eventSource:v,pointerType:w.type,position:E(w.currentPos,v.element),buttons:R.buttons,isTouchEvent:w.type==="touch",originalEvent:f.originalEvent,userData:v.userData}):R.contacts===1?(v.moveHandler&&(I=R.asArray()[0],v.moveHandler({eventSource:v,pointerType:I.type,position:E(I.currentPos,v.element),buttons:R.buttons,isTouchEvent:I.type==="touch",originalEvent:f.originalEvent,userData:v.userData})),v.dragHandler&&!f.preventGesture&&!f.defaultPrevented&&(I=R.asArray()[0],J=I.currentPos.minus(I.lastPos),v.dragHandler({eventSource:v,pointerType:I.type,position:E(I.currentPos,v.element),buttons:R.buttons,delta:J,speed:I.speed,direction:I.direction,shift:f.originalEvent.shiftKey,isTouchEvent:I.type==="touch",originalEvent:f.originalEvent,userData:v.userData}),f.preventDefault=!0,T.sentDragEvent=!0)):R.contacts===2&&(v.moveHandler&&(N=R.asArray(),v.moveHandler({eventSource:v,pointerType:N[0].type,position:E(S(N[0].currentPos,N[1].currentPos),v.element),buttons:R.buttons,isTouchEvent:N[0].type==="touch",originalEvent:f.originalEvent,userData:v.userData})),v.pinchHandler&&w.type==="touch"&&!f.preventGesture&&!f.defaultPrevented&&(J=T.pinchGPoints[0].currentPos.distanceTo(T.pinchGPoints[1].currentPos),J!==T.currentPinchDist&&(T.lastPinchDist=T.currentPinchDist,T.currentPinchDist=J,T.lastPinchCenter=T.currentPinchCenter,T.currentPinchCenter=S(T.pinchGPoints[0].currentPos,T.pinchGPoints[1].currentPos),v.pinchHandler({eventSource:v,pointerType:"touch",gesturePoints:T.pinchGPoints,lastCenter:E(T.lastPinchCenter,v.element),center:E(T.currentPinchCenter,v.element),lastDistance:T.lastPinchDist,distance:T.currentPinchDist,shift:f.originalEvent.shiftKey,originalEvent:f.originalEvent,userData:v.userData}),f.preventDefault=!0)))}function U(v,f,w){var T=v.getActivePointersListByType(w.type),R;R=T.getById(w.id),R&&dt(v,T,R)}function K(v,f,w){v.stopHandler&&v.stopHandler({eventSource:v,pointerType:w,position:y(f,v.element),buttons:v.getActivePointersListByType(w).buttons,isTouchEvent:w==="touch",originalEvent:f,userData:v.userData})}})(s),(function(e){e.ControlAnchor={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_RIGHT:3,BOTTOM_LEFT:4,ABSOLUTE:5},e.Control=function(t,i,n){var o=t.parentNode;typeof i=="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"),i={anchor:i}),i.attachToViewer=typeof i.attachToViewer>"u"?!0:i.attachToViewer,this.autoFade=typeof i.autoFade>"u"?!0:i.autoFade,this.element=t,this.anchor=i.anchor,this.container=n,this.anchor===e.ControlAnchor.ABSOLUTE?(this.wrapper=e.makeNeutralElement("div"),this.wrapper.style.position="absolute",this.wrapper.style.top=typeof i.top=="number"?i.top+"px":i.top,this.wrapper.style.left=typeof i.left=="number"?i.left+"px":i.left,this.wrapper.style.height=typeof i.height=="number"?i.height+"px":i.height,this.wrapper.style.width=typeof i.width=="number"?i.width+"px":i.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),i.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):o.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)}}})(s),(function(e){e.ControlDock=function(i){var n=["topleft","topright","bottomright","bottomleft"],o,u;for(e.extend(!0,this,{id:"controldock-"+e.now()+"-"+Math.floor(Math.random()*1e6),container:e.makeNeutralElement("div"),controls:[]},i),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%"),u=0;u<n.length;u++)o=n[u],this.controls[o]=e.makeNeutralElement("div"),this.controls[o].style.position="absolute",o.match("left")&&(this.controls[o].style.left="0px"),o.match("right")&&(this.controls[o].style.right="0px"),o.match("top")&&(this.controls[o].style.top="0px"),o.match("bottom")&&(this.controls[o].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(i,n){i=e.getElement(i);var o=null;if(!(t(this,i)>=0)){switch(n.anchor){case e.ControlAnchor.TOP_RIGHT:o=this.controls.topright,i.style.position="relative",i.style.paddingRight="0px",i.style.paddingTop="0px";break;case e.ControlAnchor.BOTTOM_RIGHT:o=this.controls.bottomright,i.style.position="relative",i.style.paddingRight="0px",i.style.paddingBottom="0px";break;case e.ControlAnchor.BOTTOM_LEFT:o=this.controls.bottomleft,i.style.position="relative",i.style.paddingLeft="0px",i.style.paddingBottom="0px";break;case e.ControlAnchor.TOP_LEFT:o=this.controls.topleft,i.style.position="relative",i.style.paddingLeft="0px",i.style.paddingTop="0px";break;case e.ControlAnchor.ABSOLUTE:o=this.container,i.style.margin="0px",i.style.padding="0px";break;default:case e.ControlAnchor.NONE:o=this.container,i.style.margin="0px",i.style.padding="0px";break}this.controls.push(new e.Control(i,n,o)),i.style.display="inline-block"}},removeControl:function(i){i=e.getElement(i);var n=t(this,i);return n>=0&&(this.controls[n].destroy(),this.controls.splice(n,1)),this},clearControls:function(){for(;this.controls.length>0;)this.controls.pop().destroy();return this},areControlsEnabled:function(){var i;for(i=this.controls.length-1;i>=0;i--)if(this.controls[i].isVisible())return!0;return!1},setControlsEnabled:function(i){var n;for(n=this.controls.length-1;n>=0;n--)this.controls[n].setVisible(i);return this}};function t(i,n){var o=i.controls,u;for(u=o.length-1;u>=0;u--)if(o[u].element===n)return u;return-1}})(s),(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}}})})(s),(function(e){var t={},i=1;e.Viewer=function(p){var x=arguments,C=this,O;e.isPlainObject(p)||(p={id:x[0],xmlPath:x.length>1?x[1]:void 0,prefixUrl:x.length>2?x[2]:void 0,controls:x.length>3?x[3]:void 0,overlays:x.length>4?x[4]:void 0}),p.config&&(e.extend(!0,p,p.config),delete p.config);let F=["useCanvas"];if(p.drawerOptions=Object.assign({},F.reduce((D,H)=>(D[H]=p[H],delete p[H],D),{}),p.drawerOptions),e.extend(!0,this,{id:p.id,hash:p.hash||i++,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,p),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 H=e.getString("Errors.OpenFailed",D.eventSource,D.message);C._showMessage(H)}),e.ControlDock.call(this,p),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),p.tabIndex!==""&&(this.canvas.tabIndex=p.tabIndex===void 0?0:p.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,y),keyDownHandler:e.delegate(this,E),keyHandler:e.delegate(this,S),clickHandler:e.delegate(this,P),dblClickHandler:e.delegate(this,B),dragHandler:e.delegate(this,k),dragEndHandler:e.delegate(this,M),enterHandler:e.delegate(this,L),leaveHandler:e.delegate(this,W),pressHandler:e.delegate(this,$),releaseHandler:e.delegate(this,Q),nonPrimaryPressHandler:e.delegate(this,q),nonPrimaryReleaseHandler:e.delegate(this,V),scrollHandler:e.delegate(this,pe),pinchHandler:e.delegate(this,re),focusHandler:e.delegate(this,he),blurHandler:e.delegate(this,de)}),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,ge),leaveHandler:e.delegate(this,me)}),this.toolbar&&(this.toolbar=new e.ControlDock({element:this.toolbar})),this.bindStandardControls(),t[this.hash].prevContainerSize=n(this.container),window.ResizeObserver?(this._autoResizePolling=!1,this._resizeObserver=new ResizeObserver(function(){t[C.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){C.source=C.world.getItemAt(0).source,t[C.hash].forceRedraw=!0,C._updateRequestId||(C._updateRequestId=a(C,Pe))}),this.world.addHandler("remove-item",function(D){C.world.getItemCount()?C.source=C.world.getItemAt(0).source:C.source=null,t[C.hash].forceRedraw=!0}),this.world.addHandler("metrics-change",function(D){C.viewport&&C.viewport._setContentBounds(C.world.getHomeBounds(),C.world.getContentFactor())}),this.world.addHandler("item-index-change",function(D){C.source=C.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:p.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 A=Array.isArray(this.drawer)?this.drawer:[this.drawer];A.length===0&&(A=[e.DEFAULT_SETTINGS.drawer].flat(),e.console.warn("No valid drawers were selected. Using the default value.")),this.drawer=null;for(const D of A)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(C)}),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(p){return e.console.error("[Viewer.openDzi] this function is deprecated; use Viewer.open() instead."),this.open(p)},openTileSource:function(p){return e.console.error("[Viewer.openTileSource] this function is deprecated; use Viewer.open() instead."),this.open(p)},get buttons(){return e.console.warn("Viewer.buttons is deprecated; Please use Viewer.buttonGroup"),this.buttonGroup},open:function(p,x){var C=this;if(this.close(),!p)return this;if(this.sequenceMode&&e.isArray(p))return this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),typeof x<"u"&&!isNaN(x)&&(this.initialPage=x),this.tileSources=p,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(p)||(p=[p]),!p.length)return this;this._opening=!0;for(var O=p.length,F=0,A=0,D,H=function(){if(F+A===O)if(F){(C._firstOpen||!C.preserveViewport)&&(C.viewport.goHome(!0),C.viewport.update()),C._firstOpen=!1;var U=p[0];if(U.tileSource&&(U=U.tileSource),C.overlays&&!C.preserveOverlays)for(var K=0;K<C.overlays.length;K++)C.currentOverlays[K]=u(C,C.overlays[K]);C._drawOverlays(),C._opening=!1,C.raiseEvent("open",{source:U})}else C._opening=!1,C.raiseEvent("open-failed",D)},G=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(f){if(F++,U.tileSource.overlays)for(var w=0;w<U.tileSource.overlays.length;w++)C.addOverlay(U.tileSource.overlays[w]);K&&K(f),H()};var v=U.error;U.error=function(f){A++,D||(D=f),v&&v(f),H()},C.addTiledImage(U)},X=0;X<p.length;X++)G(p[X]);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(p,x){const C={mainDrawer:!0,redrawImmediately:!0,drawerOptions:null};x=e.extend(!0,C,x);const O=x.mainDrawer,F=x.redrawImmediately,A=x.drawerOptions,D=this.drawer;let H=null;if(p&&p.prototype instanceof e.DrawerBase?(H=p,p="custom"):typeof p=="string"&&(H=e.determineDrawer(p)),H||e.console.warn("Unsupported drawer! Drawer must be an existing string type, or a class that extends OpenSeadragon.DrawerBase."),H&&H.isSupported()){D&&O&&D.destroy();const G=new H({viewer:this,viewport:this.viewport,element:this.canvas,debugGridColor:this.debugGridColor,options:A||this.drawerOptions[p]});return O&&(this.drawer=G,F&&this.forceRedraw()),G}return!1},isMouseNavEnabled:function(){return this.innerTracker.isTracking()},setMouseNavEnabled:function(p){return this.innerTracker.setTracking(p),this.outerTracker.setTracking(p),this.raiseEvent("mouse-enabled",{enabled:p}),this},areControlsEnabled:function(){var p=this.controls.length,x;for(x=0;x<this.controls.length;x++)p=p&&this.controls[x].isVisible();return p},setControlsEnabled:function(p){return p?g(this):c(this),this.raiseEvent("controls-enabled",{enabled:p}),this},setDebugMode:function(p){for(var x=0;x<this.world.getItemCount();x++)this.world.getItemAt(x).debugMode=p;this.debugMode=p,this.forceRedraw()},setAjaxHeaders:function(p,x){if(p===null&&(p={}),!e.isPlainObject(p)){console.error("[Viewer.setAjaxHeaders] Ignoring invalid headers, must be a plain object");return}if(x===void 0&&(x=!0),this.ajaxHeaders=p,x){for(var C=0;C<this.world.getItemCount();C++)this.world.getItemAt(C)._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(p){this.buttonGroup.addButton(p)},isFullPage:function(){return t[this.hash]&&t[this.hash].fullPage},setFullPage:function(p){var x=document.body,C=x.style,O=document.documentElement.style,F=this,A,D;if(p===this.isFullPage())return this;var H={fullPage:p,preventDefaultAction:!1};if(this.raiseEvent("pre-full-page",H),H.preventDefaultAction)return this;if(p&&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=C.margin,this.docMargin=O.margin,C.margin="0",O.margin="0",this.bodyPadding=C.padding,this.docPadding=O.padding,C.padding="0",O.padding="0",this.bodyWidth=C.width,this.docWidth=O.width,C.width="100%",O.width="100%",this.bodyHeight=C.height,this.docHeight=O.height,C.height="100%",O.height="100%",this.bodyDisplay=C.display,C.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,A=x.childNodes.length,D=0;D<A;D++)this.previousBody.push(x.childNodes[0]),x.removeChild(x.childNodes[0]);this.toolbar&&this.toolbar.element&&(this.toolbar.parentNode=this.toolbar.element.parentNode,this.toolbar.nextSibling=this.toolbar.element.nextSibling,x.appendChild(this.toolbar.element),e.addClass(this.toolbar.element,"fullpage")),e.addClass(this.element,"fullpage"),x.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,ge)({})}else{for(this.element.style.margin=this.elementMargin,this.element.style.padding=this.elementPadding,C.margin=this.bodyMargin,O.margin=this.docMargin,C.padding=this.bodyPadding,O.padding=this.docPadding,C.width=this.bodyWidth,O.width=this.docWidth,C.height=this.bodyHeight,O.height=this.docHeight,C.display=this.bodyDisplay,x.removeChild(this.element),A=this.previousBody.length,D=0;D<A;D++)x.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&&(x.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 G=0,X=function(){e.setPageScroll(F.pageScroll);var U=e.getPageScroll();G++,G<10&&(U.x!==F.pageScroll.x||U.y!==F.pageScroll.y)&&e.requestAnimationFrame(X)};e.requestAnimationFrame(X),t[this.hash].fullPage=!1,e.delegate(this,me)({})}return this.navigator&&this.viewport&&this.navigator.update(this.viewport),this.raiseEvent("full-page",{fullPage:p}),this},setFullScreen:function(p){var x=this;if(!e.supportsFullScreen)return this.setFullPage(p);if(e.isFullScreen()===p)return this;var C={fullScreen:p,preventDefaultAction:!1};if(this.raiseEvent("pre-full-screen",C),C.preventDefaultAction)return this;if(p){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 F=e.isFullScreen();F||(e.removeEvent(document,e.fullScreenEventName,O),e.removeEvent(document,e.fullScreenErrorEventName,O),x.setFullPage(!1),x.isFullPage()&&(x.element.style.width=x.fullPageStyleWidth,x.element.style.height=x.fullPageStyleHeight)),x.navigator&&x.viewport&&setTimeout(function(){x.navigator.update(x.viewport)}),x.raiseEvent("full-screen",{fullScreen:F})};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(p){return this.container.style.visibility=p?"":"hidden",this.raiseEvent("visible",{visible:p}),this},addTiledImage:function(p){e.console.assert(p,"[Viewer.addTiledImage] options is required"),e.console.assert(p.tileSource,"[Viewer.addTiledImage] options.tileSource is required"),e.console.assert(!p.replace||p.index>-1&&p.index<this.world.getItemCount(),"[Viewer.addTiledImage] if options.replace is used, options.index must be a valid index in Viewer.world");var x=this;p.replace&&(p.replaceItem=x.world.getItemAt(p.index)),this._hideMessage(),p.placeholderFillStyle===void 0&&(p.placeholderFillStyle=this.placeholderFillStyle),p.opacity===void 0&&(p.opacity=this.opacity),p.preload===void 0&&(p.preload=this.preload),p.compositeOperation===void 0&&(p.compositeOperation=this.compositeOperation),p.crossOriginPolicy===void 0&&(p.crossOriginPolicy=p.tileSource.crossOriginPolicy!==void 0?p.tileSource.crossOriginPolicy:this.crossOriginPolicy),p.ajaxWithCredentials===void 0&&(p.ajaxWithCredentials=this.ajaxWithCredentials),p.loadTilesWithAjax===void 0&&(p.loadTilesWithAjax=this.loadTilesWithAjax),e.isPlainObject(p.ajaxHeaders)||(p.ajaxHeaders={});var C={options:p};function O(D){for(var H=0;H<x._loadQueue.length;H++)if(x._loadQueue[H]===C){x._loadQueue.splice(H,1);break}x._loadQueue.length===0&&F(C),x.raiseEvent("add-item-failed",D),p.error&&p.error(D)}function F(D){x.collectionMode&&(x.world.arrange({immediately:D.options.collectionImmediately,rows:x.collectionRows,columns:x.collectionColumns,layout:x.collectionLayout,tileSize:x.collectionTileSize,tileMargin:x.collectionTileMargin}),x.world.setAutoRefigureSizes(!0))}if(e.isArray(p.tileSource)){setTimeout(function(){O({message:"[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead.",source:p.tileSource,options:p})});return}this._loadQueue.push(C);function A(){for(var D,H,G;x._loadQueue.length&&(D=x._loadQueue[0],!!D.tileSource);){if(x._loadQueue.splice(0,1),D.options.replace){var X=x.world.getIndexOfItem(D.options.replaceItem);X!==-1&&(D.options.index=X),x.world.removeItem(D.options.replaceItem)}H=new e.TiledImage({viewer:x,source:D.tileSource,viewport:x.viewport,drawer:x.drawer,tileCache:x.tileCache,imageLoader:x.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:x.springStiffness,animationTime:x.animationTime,minZoomImageRatio:x.minZoomImageRatio,wrapHorizontal:x.wrapHorizontal,wrapVertical:x.wrapVertical,maxTilesPerFrame:x.maxTilesPerFrame,immediateRender:x.immediateRender,blendTime:x.blendTime,alwaysBlend:x.alwaysBlend,minPixelRatio:x.minPixelRatio,smoothTileEdgesMinZoom:x.smoothTileEdgesMinZoom,iOSDevice:x.iOSDevice,crossOriginPolicy:D.options.crossOriginPolicy,ajaxWithCredentials:D.options.ajaxWithCredentials,loadTilesWithAjax:D.options.loadTilesWithAjax,ajaxHeaders:D.options.ajaxHeaders,debugMode:x.debugMode,subPixelRoundingForTransparency:x.subPixelRoundingForTransparency}),x.collectionMode&&x.world.setAutoRefigureSizes(!1),x.navigator&&(G=e.extend({},D.options,{replace:!1,originalTiledImage:H,tileSource:D.tileSource}),x.navigator.addTiledImage(G)),x.world.addItem(H,{index:D.options.index}),x._loadQueue.length===0&&F(D),x.world.getItemCount()===1&&!x.preserveViewport&&x.viewport.goHome(!0),D.options.success&&D.options.success({item:H})}}o(this,p.tileSource,p,function(D){C.tileSource=D,A()},function(D){D.options=p,O(D),A()})},addSimpleImage:function(p){e.console.assert(p,"[Viewer.addSimpleImage] options is required"),e.console.assert(p.url,"[Viewer.addSimpleImage] options.url is required");var x=e.extend({},p,{tileSource:{type:"image",url:p.url}});delete x.url,this.addTiledImage(x)},addLayer:function(p){var x=this;e.console.error("[Viewer.addLayer] this function is deprecated; use Viewer.addTiledImage() instead.");var C=e.extend({},p,{success:function(O){x.raiseEvent("add-layer",{options:p,drawer:O.item})},error:function(O){x.raiseEvent("add-layer-failed",O)}});return this.addTiledImage(C),this},getLayerAtLevel:function(p){return e.console.error("[Viewer.getLayerAtLevel] this function is deprecated; use World.getItemAt() instead."),this.world.getItemAt(p)},getLevelOfLayer:function(p){return e.console.error("[Viewer.getLevelOfLayer] this function is deprecated; use World.getIndexOfItem() instead."),this.world.getIndexOfItem(p)},getLayersCount:function(){return e.console.error("[Viewer.getLayersCount] this function is deprecated; use World.getItemCount() instead."),this.world.getItemCount()},setLayerLevel:function(p,x){return e.console.error("[Viewer.setLayerLevel] this function is deprecated; use World.setItemIndex() instead."),this.world.setItemIndex(p,x)},removeLayer:function(p){return e.console.error("[Viewer.removeLayer] this function is deprecated; use World.removeItem() instead."),this.world.removeItem(p)},forceRedraw:function(){return t[this.hash].forceRedraw=!0,this},forceResize:function(){t[this.hash].needsResize=!0,t[this.hash].forceResize=!0},bindSequenceControls:function(){var p=e.delegate(this,m),x=e.delegate(this,_),C=e.delegate(this,this.goToNextPage),O=e.delegate(this,this.goToPreviousPage),F=this.navImages,A=!0;return this.showSequenceControl&&((this.previousButton||this.nextButton)&&(A=!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:Y(this.prefixUrl,F.previous.REST),srcGroup:Y(this.prefixUrl,F.previous.GROUP),srcHover:Y(this.prefixUrl,F.previous.HOVER),srcDown:Y(this.prefixUrl,F.previous.DOWN),onRelease:O,onFocus:p,onBlur:x}),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:Y(this.prefixUrl,F.next.REST),srcGroup:Y(this.prefixUrl,F.next.GROUP),srcHover:Y(this.prefixUrl,F.next.HOVER),srcDown:Y(this.prefixUrl,F.next.DOWN),onRelease:C,onFocus:p,onBlur:x}),this.navPrevNextWrap||this.previousButton.disable(),(!this.tileSources||!this.tileSources.length)&&this.nextButton.disable(),A&&(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 p=e.delegate(this,$e),x=e.delegate(this,Ue),C=e.delegate(this,ce),O=e.delegate(this,ct),F=e.delegate(this,we),A=e.delegate(this,St),D=e.delegate(this,Nt),H=e.delegate(this,Ut),G=e.delegate(this,Pt),X=e.delegate(this,dt),U=e.delegate(this,m),K=e.delegate(this,_),v=this.navImages,f=[],w=!0;return this.showNavigationControl&&((this.zoomInButton||this.zoomOutButton||this.homeButton||this.fullPageButton||this.rotateLeftButton||this.rotateRightButton||this.flipButton)&&(w=!1),this.showZoomControl&&(f.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:Y(this.prefixUrl,v.zoomIn.REST),srcGroup:Y(this.prefixUrl,v.zoomIn.GROUP),srcHover:Y(this.prefixUrl,v.zoomIn.HOVER),srcDown:Y(this.prefixUrl,v.zoomIn.DOWN),onPress:p,onRelease:x,onClick:C,onEnter:p,onExit:x,onFocus:U,onBlur:K})),f.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:Y(this.prefixUrl,v.zoomOut.REST),srcGroup:Y(this.prefixUrl,v.zoomOut.GROUP),srcHover:Y(this.prefixUrl,v.zoomOut.HOVER),srcDown:Y(this.prefixUrl,v.zoomOut.DOWN),onPress:O,onRelease:x,onClick:F,onEnter:O,onExit:x,onFocus:U,onBlur:K}))),this.showHomeControl&&f.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:Y(this.prefixUrl,v.home.REST),srcGroup:Y(this.prefixUrl,v.home.GROUP),srcHover:Y(this.prefixUrl,v.home.HOVER),srcDown:Y(this.prefixUrl,v.home.DOWN),onRelease:A,onFocus:U,onBlur:K})),this.showFullPageControl&&f.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:Y(this.prefixUrl,v.fullpage.REST),srcGroup:Y(this.prefixUrl,v.fullpage.GROUP),srcHover:Y(this.prefixUrl,v.fullpage.HOVER),srcDown:Y(this.prefixUrl,v.fullpage.DOWN),onRelease:D,onFocus:U,onBlur:K})),this.showRotationControl&&(f.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:Y(this.prefixUrl,v.rotateleft.REST),srcGroup:Y(this.prefixUrl,v.rotateleft.GROUP),srcHover:Y(this.prefixUrl,v.rotateleft.HOVER),srcDown:Y(this.prefixUrl,v.rotateleft.DOWN),onRelease:H,onFocus:U,onBlur:K})),f.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:Y(this.prefixUrl,v.rotateright.REST),srcGroup:Y(this.prefixUrl,v.rotateright.GROUP),srcHover:Y(this.prefixUrl,v.rotateright.HOVER),srcDown:Y(this.prefixUrl,v.rotateright.DOWN),onRelease:G,onFocus:U,onBlur:K}))),this.showFlipControl&&f.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:Y(this.prefixUrl,v.flip.REST),srcGroup:Y(this.prefixUrl,v.flip.GROUP),srcHover:Y(this.prefixUrl,v.flip.HOVER),srcDown:Y(this.prefixUrl,v.flip.DOWN),onRelease:X,onFocus:U,onBlur:K})),w?(this.buttonGroup=new e.ButtonGroup({buttons:f,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.navControl=this.buttonGroup.element,this.addHandler("open",e.delegate(this,Ye)),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=f),this},currentPage:function(){return this._sequenceIndex},goToPage:function(p){return this.tileSources&&p>=0&&p<this.tileSources.length&&(this._sequenceIndex=p,this._updateSequenceButtons(p),this.open(this.tileSources[p]),this.referenceStrip&&this.referenceStrip.setFocus(p),this.raiseEvent("page",{page:p})),this},addOverlay:function(p,x,C,O){var F;if(e.isPlainObject(p)?F=p:F={element:p,location:x,placement:C,onDraw:O},p=e.getElement(F.element),l(this.currentOverlays,p)>=0)return this;var A=u(this,F);return this.currentOverlays.push(A),A.drawHTML(this.overlaysContainer,this.viewport),this.raiseEvent("add-overlay",{element:p,location:F.location,placement:F.placement}),this},updateOverlay:function(p,x,C){var O;return p=e.getElement(p),O=l(this.currentOverlays,p),O>=0&&(this.currentOverlays[O].update(x,C),t[this.hash].forceRedraw=!0,this.raiseEvent("update-overlay",{element:p,location:x,placement:C})),this},removeOverlay:function(p){var x;return p=e.getElement(p),x=l(this.currentOverlays,p),x>=0&&(this.currentOverlays[x].destroy(),this.currentOverlays.splice(x,1),t[this.hash].forceRedraw=!0,this.raiseEvent("remove-overlay",{element:p})),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(p){var x;return p=e.getElement(p),x=l(this.currentOverlays,p),x>=0?this.currentOverlays[x]:null},_updateSequenceButtons:function(p){this.nextButton&&(!this.tileSources||this.tileSources.length-1===p?this.navPrevNextWrap||this.nextButton.disable():this.nextButton.enable()),this.previousButton&&(p>0?this.previousButton.enable():this.navPrevNextWrap||this.previousButton.disable())},_showMessage:function(p){this._hideMessage();var x=e.makeNeutralElement("div");x.appendChild(document.createTextNode(p)),this.messageDiv=e.makeCenteredNode(x),e.addClass(this.messageDiv,"openseadragon-message"),this.container.appendChild(this.messageDiv)},_hideMessage:function(){var p=this.messageDiv;p&&(p.parentNode.removeChild(p),delete this.messageDiv)},gestureSettingsByDeviceType:function(p){switch(p){case"mouse":return this.gestureSettingsMouse;case"touch":return this.gestureSettingsTouch;case"pen":return this.gestureSettingsPen;default:return this.gestureSettingsUnknown}},_drawOverlays:function(){var p,x=this.currentOverlays.length;for(p=0;p<x;p++)this.currentOverlays[p].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 p=e.pixelDensityRatio,x=e.getCurrentPixelDensityRatio();p!==x&&(e.pixelDensityRatio=x,this.forceResize())},goToPreviousPage:function(){var p=this._sequenceIndex-1;this.navPrevNextWrap&&p<0&&(p+=this.tileSources.length),this.goToPage(p)},goToNextPage:function(){var p=this._sequenceIndex+1;this.navPrevNextWrap&&p>=this.tileSources.length&&(p=0),this.goToPage(p)},isAnimating:function(){return t[this.hash].animating}});function n(p){return p=e.getElement(p),new e.Point(p.clientWidth===0?1:p.clientWidth,p.clientHeight===0?1:p.clientHeight)}function o(p,x,C,O,F){var A=p;if(e.type(x)==="string"){if(x.match(/^\s*<.*>\s*$/))x=e.parseXml(x);else if(x.match(/^\s*[{[].*[}\]]\s*$/))try{var D=e.parseJSON(x);x=D}catch{}}function H(G,X){G.ready?O(G):(G.addHandler("ready",function(){O(G)}),G.addHandler("open-failed",function(U){F({message:U.message,source:X})}))}setTimeout(function(){if(e.type(x)==="string")x=new e.TileSource({url:x,crossOriginPolicy:C.crossOriginPolicy!==void 0?C.crossOriginPolicy:p.crossOriginPolicy,ajaxWithCredentials:p.ajaxWithCredentials,ajaxHeaders:C.ajaxHeaders?C.ajaxHeaders:p.ajaxHeaders,splitHashDataForPost:p.splitHashDataForPost,success:function(K){O(K.tileSource)}}),x.addHandler("open-failed",function(K){F(K)});else if(e.isPlainObject(x)||x.nodeType)if(x.crossOriginPolicy===void 0&&(C.crossOriginPolicy!==void 0||p.crossOriginPolicy!==void 0)&&(x.crossOriginPolicy=C.crossOriginPolicy!==void 0?C.crossOriginPolicy:p.crossOriginPolicy),x.ajaxWithCredentials===void 0&&(x.ajaxWithCredentials=p.ajaxWithCredentials),e.isFunction(x.getTileUrl)){var G=new e.TileSource(x);G.getTileUrl=x.getTileUrl,O(G)}else{var X=e.TileSource.determineType(A,x);if(!X){F({message:"Unable to load TileSource",source:x});return}var U=X.prototype.configure.apply(A,[x]);H(new X(U),x)}else H(x,x)})}function u(p,x){if(x instanceof e.Overlay)return x;var C=null;if(x.element)C=e.getElement(x.element);else{var O=x.id?x.id:"openseadragon-overlay-"+Math.floor(Math.random()*1e7);C=e.getElement(x.id),C||(C=document.createElement("a"),C.href="#/overlay/"+O),C.id=O,e.addClass(C,x.className?x.className:"openseadragon-overlay")}var F=x.location,A=x.width,D=x.height;if(!F){var H=x.x,G=x.y;if(x.px!==void 0){var X=p.viewport.imageToViewportRectangle(new e.Rect(x.px,x.py,A||0,D||0));H=X.x,G=X.y,A=A!==void 0?X.width:void 0,D=D!==void 0?X.height:void 0}F=new e.Point(H,G)}var U=x.placement;return U&&e.type(U)==="string"&&(U=e.Placement[x.placement.toUpperCase()]),new e.Overlay({element:C,location:F,placement:U,onDraw:x.onDraw,checkResize:x.checkResize,width:A,height:D,rotationMode:x.rotationMode})}function l(p,x){var C;for(C=p.length-1;C>=0;C--)if(p[C].element===x)return C;return-1}function a(p,x){return e.requestAnimationFrame(function(){x(p)})}function h(p){e.requestAnimationFrame(function(){d(p)})}function c(p){p.autoHideControls&&(p.controlsShouldFade=!0,p.controlsFadeBeginTime=e.now()+p.controlsFadeDelay,window.setTimeout(function(){h(p)},p.controlsFadeDelay))}function d(p){var x,C,O,F;if(p.controlsShouldFade){for(x=e.now(),C=x-p.controlsFadeBeginTime,O=1-C/p.controlsFadeLength,O=Math.min(1,O),O=Math.max(0,O),F=p.controls.length-1;F>=0;F--)p.controls[F].autoFade&&p.controls[F].setOpacity(O);O>0&&h(p)}}function g(p){var x;for(p.controlsShouldFade=!1,x=p.controls.length-1;x>=0;x--)p.controls[x].setOpacity(1)}function m(){g(this)}function _(){c(this)}function y(p){var x={tracker:p.eventSource,position:p.position,originalEvent:p.originalEvent,preventDefault:p.preventDefault};this.raiseEvent("canvas-contextmenu",x),p.preventDefault=x.preventDefault}function E(p){var x={originalEvent:p.originalEvent,preventDefaultAction:!1,preventVerticalPan:p.preventVerticalPan||!this.panVertical,preventHorizontalPan:p.preventHorizontalPan||!this.panHorizontal};if(this.raiseEvent("canvas-key",x),!x.preventDefaultAction&&!p.ctrl&&!p.alt&&!p.meta)switch(p.keyCode){case 38:x.preventVerticalPan||(p.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,-this.pixelsPerArrowPress))),this.viewport.applyConstraints()),p.preventDefault=!0;break;case 40:x.preventVerticalPan||(p.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,this.pixelsPerArrowPress))),this.viewport.applyConstraints()),p.preventDefault=!0;break;case 37:x.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(-this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),p.preventDefault=!0;break;case 39:x.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),p.preventDefault=!0;break;case 187:this.viewport.zoomBy(1.1),this.viewport.applyConstraints(),p.preventDefault=!0;break;case 189:this.viewport.zoomBy(.9),this.viewport.applyConstraints(),p.preventDefault=!0;break;case 48:this.viewport.goHome(),this.viewport.applyConstraints(),p.preventDefault=!0;break;case 87:x.preventVerticalPan||(p.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,-40))),this.viewport.applyConstraints()),p.preventDefault=!0;break;case 83:x.preventVerticalPan||(p.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(0,40))),this.viewport.applyConstraints()),p.preventDefault=!0;break;case 65:x.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(-40,0))),this.viewport.applyConstraints()),p.preventDefault=!0;break;case 68:x.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new e.Point(40,0))),this.viewport.applyConstraints()),p.preventDefault=!0;break;case 82:p.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(),p.preventDefault=!0;break;case 70:this.viewport.toggleFlip(),p.preventDefault=!0;break;case 74:this.goToPreviousPage();break;case 75:this.goToNextPage();break;default:p.preventDefault=!1;break}else p.preventDefault=!1}function S(p){var x={originalEvent:p.originalEvent};this.raiseEvent("canvas-key-press",x)}function P(p){var x,C=document.activeElement===this.canvas;C||this.canvas.focus(),this.viewport.flipped&&(p.position.x=this.viewport.getContainerSize().x-p.position.x);var O={tracker:p.eventSource,position:p.position,quick:p.quick,shift:p.shift,originalEvent:p.originalEvent,originalTarget:p.originalTarget,preventDefaultAction:!1};this.raiseEvent("canvas-click",O),!O.preventDefaultAction&&this.viewport&&p.quick&&(x=this.gestureSettingsByDeviceType(p.pointerType),x.clickToZoom===!0&&(this.viewport.zoomBy(p.shift?1/this.zoomPerClick:this.zoomPerClick,x.zoomToRefPoint?this.viewport.pointFromPixel(p.position,!0):null),this.viewport.applyConstraints()),x.dblClickDragToZoom&&(t[this.hash].draggingToZoom===!0?(t[this.hash].lastClickTime=null,t[this.hash].draggingToZoom=!1):t[this.hash].lastClickTime=e.now()))}function B(p){var x,C={tracker:p.eventSource,position:p.position,shift:p.shift,originalEvent:p.originalEvent,preventDefaultAction:!1};this.raiseEvent("canvas-double-click",C),!C.preventDefaultAction&&this.viewport&&(x=this.gestureSettingsByDeviceType(p.pointerType),x.dblClickToZoom&&(this.viewport.zoomBy(p.shift?1/this.zoomPerClick:this.zoomPerClick,x.zoomToRefPoint?this.viewport.pointFromPixel(p.position,!0):null),this.viewport.applyConstraints()))}function k(p){var x,C={tracker:p.eventSource,pointerType:p.pointerType,position:p.position,delta:p.delta,speed:p.speed,direction:p.direction,shift:p.shift,originalEvent:p.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag",C),x=this.gestureSettingsByDeviceType(p.pointerType),!C.preventDefaultAction&&this.viewport){if(x.dblClickDragToZoom&&t[this.hash].draggingToZoom){var O=Math.pow(this.zoomPerDblClickDrag,p.delta.y/50);this.viewport.zoomBy(O)}else if(x.dragToPan&&!t[this.hash].draggingToZoom){if(this.panHorizontal||(p.delta.x=0),this.panVertical||(p.delta.y=0),this.viewport.flipped&&(p.delta.x=-p.delta.x),this.constrainDuringPan){var F=this.viewport.deltaPointsFromPixels(p.delta.negate());this.viewport.centerSpringX.target.value+=F.x,this.viewport.centerSpringY.target.value+=F.y;var A=this.viewport.getConstrainedBounds();this.viewport.centerSpringX.target.value-=F.x,this.viewport.centerSpringY.target.value-=F.y,A.xConstrained&&(p.delta.x=0),A.yConstrained&&(p.delta.y=0)}this.viewport.panBy(this.viewport.deltaPointsFromPixels(p.delta.negate()),x.flickEnabled&&!this.constrainDuringPan)}}}function M(p){var x,C={tracker:p.eventSource,pointerType:p.pointerType,position:p.position,speed:p.speed,direction:p.direction,shift:p.shift,originalEvent:p.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag-end",C),x=this.gestureSettingsByDeviceType(p.pointerType),!C.preventDefaultAction&&this.viewport){if(!t[this.hash].draggingToZoom&&x.dragToPan&&x.flickEnabled&&p.speed>=x.flickMinSpeed){var O=0;this.panHorizontal&&(O=x.flickMomentum*p.speed*Math.cos(p.direction));var F=0;this.panVertical&&(F=x.flickMomentum*p.speed*Math.sin(p.direction));var A=this.viewport.pixelFromPoint(this.viewport.getCenter(!0)),D=this.viewport.pointFromPixel(new e.Point(A.x-O,A.y-F));this.viewport.panTo(D,!1)}this.viewport.applyConstraints()}x.dblClickDragToZoom&&t[this.hash].draggingToZoom===!0&&(t[this.hash].draggingToZoom=!1)}function L(p){this.raiseEvent("canvas-enter",{tracker:p.eventSource,pointerType:p.pointerType,position:p.position,buttons:p.buttons,pointers:p.pointers,insideElementPressed:p.insideElementPressed,buttonDownAny:p.buttonDownAny,originalEvent:p.originalEvent})}function W(p){this.raiseEvent("canvas-exit",{tracker:p.eventSource,pointerType:p.pointerType,position:p.position,buttons:p.buttons,pointers:p.pointers,insideElementPressed:p.insideElementPressed,buttonDownAny:p.buttonDownAny,originalEvent:p.originalEvent})}function $(p){var x;if(this.raiseEvent("canvas-press",{tracker:p.eventSource,pointerType:p.pointerType,position:p.position,insideElementPressed:p.insideElementPressed,insideElementReleased:p.insideElementReleased,originalEvent:p.originalEvent}),x=this.gestureSettingsByDeviceType(p.pointerType),x.dblClickDragToZoom){var C=t[this.hash].lastClickTime,O=e.now();if(C===null)return;O-C<this.dblClickTimeThreshold&&(t[this.hash].draggingToZoom=!0),t[this.hash].lastClickTime=null}}function Q(p){this.raiseEvent("canvas-release",{tracker:p.eventSource,pointerType:p.pointerType,position:p.position,insideElementPressed:p.insideElementPressed,insideElementReleased:p.insideElementReleased,originalEvent:p.originalEvent})}function q(p){this.raiseEvent("canvas-nonprimary-press",{tracker:p.eventSource,position:p.position,pointerType:p.pointerType,button:p.button,buttons:p.buttons,originalEvent:p.originalEvent})}function V(p){this.raiseEvent("canvas-nonprimary-release",{tracker:p.eventSource,position:p.position,pointerType:p.pointerType,button:p.button,buttons:p.buttons,originalEvent:p.originalEvent})}function re(p){var x,C,O,F,A={tracker:p.eventSource,pointerType:p.pointerType,gesturePoints:p.gesturePoints,lastCenter:p.lastCenter,center:p.center,lastDistance:p.lastDistance,distance:p.distance,shift:p.shift,originalEvent:p.originalEvent,preventDefaultPanAction:!1,preventDefaultZoomAction:!1,preventDefaultRotateAction:!1};if(this.raiseEvent("canvas-pinch",A),this.viewport&&(x=this.gestureSettingsByDeviceType(p.pointerType),x.pinchToZoom&&(!A.preventDefaultPanAction||!A.preventDefaultZoomAction)&&(C=this.viewport.pointFromPixel(p.center,!0),x.zoomToRefPoint&&!A.preventDefaultPanAction&&(O=this.viewport.pointFromPixel(p.lastCenter,!0),F=O.minus(C),this.panHorizontal||(F.x=0),this.panVertical||(F.y=0),this.viewport.panBy(F,!0)),A.preventDefaultZoomAction||this.viewport.zoomBy(p.distance/p.lastDistance,C,!0),this.viewport.applyConstraints()),x.pinchRotate&&!A.preventDefaultRotateAction)){var D=Math.atan2(p.gesturePoints[0].currentPos.y-p.gesturePoints[1].currentPos.y,p.gesturePoints[0].currentPos.x-p.gesturePoints[1].currentPos.x),H=Math.atan2(p.gesturePoints[0].lastPos.y-p.gesturePoints[1].lastPos.y,p.gesturePoints[0].lastPos.x-p.gesturePoints[1].lastPos.x);C=this.viewport.pointFromPixel(p.center,!0),this.viewport.rotateTo(this.viewport.getRotation(!0)+(D-H)*(180/Math.PI),C,!0)}}function he(p){this.raiseEvent("canvas-focus",{tracker:p.eventSource,originalEvent:p.originalEvent})}function de(p){this.raiseEvent("canvas-blur",{tracker:p.eventSource,originalEvent:p.originalEvent})}function pe(p){var x,C,O,F,A;F=e.now(),A=F-this._lastScrollTime,A>this.minScrollDeltaTime?(this._lastScrollTime=F,x={tracker:p.eventSource,position:p.position,scroll:p.scroll,shift:p.shift,originalEvent:p.originalEvent,preventDefaultAction:!1,preventDefault:!0},this.raiseEvent("canvas-scroll",x),!x.preventDefaultAction&&this.viewport&&(this.viewport.flipped&&(p.position.x=this.viewport.getContainerSize().x-p.position.x),C=this.gestureSettingsByDeviceType(p.pointerType),C.scrollToZoom&&(O=Math.pow(this.zoomPerScroll,p.scroll),this.viewport.zoomBy(O,C.zoomToRefPoint?this.viewport.pointFromPixel(p.position,!0):null),this.viewport.applyConstraints())),p.preventDefault=x.preventDefault):p.preventDefault=!0}function ge(p){t[this.hash].mouseInside=!0,g(this),this.raiseEvent("container-enter",{tracker:p.eventSource,pointerType:p.pointerType,position:p.position,buttons:p.buttons,pointers:p.pointers,insideElementPressed:p.insideElementPressed,buttonDownAny:p.buttonDownAny,originalEvent:p.originalEvent})}function me(p){p.pointers<1&&(t[this.hash].mouseInside=!1,t[this.hash].animating||c(this)),this.raiseEvent("container-exit",{tracker:p.eventSource,pointerType:p.pointerType,position:p.position,buttons:p.buttons,pointers:p.pointers,insideElementPressed:p.insideElementPressed,buttonDownAny:p.buttonDownAny,originalEvent:p.originalEvent})}function Pe(p){xe(p),p.isOpen()?p._updateRequestId=a(p,Pe):p._updateRequestId=!1}function Le(p,x){var C=p.viewport,O=C.getZoom(),F=C.getCenter();C.resize(x,p.preserveImageSizeOnResize),C.panTo(F,!0);var A;if(p.preserveImageSizeOnResize)A=t[p.hash].prevContainerSize.x/x.x;else{var D=new e.Point(0,0),H=new e.Point(t[p.hash].prevContainerSize.x,t[p.hash].prevContainerSize.y).distanceTo(D),G=new e.Point(x.x,x.y).distanceTo(D);A=G/H*t[p.hash].prevContainerSize.x/x.x}C.zoomTo(O*A,null,!0),t[p.hash].prevContainerSize=x,t[p.hash].forceRedraw=!0,t[p.hash].needsResize=!1,t[p.hash].forceResize=!1}function xe(p){if(!(p._opening||!t[p.hash])){if(p.autoResize||t[p.hash].forceResize){var x;if(p._autoResizePolling){x=n(p.container);var C=t[p.hash].prevContainerSize;x.equals(C)||(t[p.hash].needsResize=!0)}t[p.hash].needsResize&&Le(p,x||n(p.container))}var O=p.viewport.update(),F=p.world.update(O)||O;O&&p.raiseEvent("viewport-change"),p.referenceStrip&&(F=p.referenceStrip.update(p.viewport)||F);var A=t[p.hash].animating;!A&&F&&(p.raiseEvent("animation-start"),g(p));var D=A&&!F;D&&(t[p.hash].animating=!1),(F||D||t[p.hash].forceRedraw||p.world.needsDraw())&&(Xe(p),p._drawOverlays(),p.navigator&&p.navigator.update(p.viewport),t[p.hash].forceRedraw=!1,F&&p.raiseEvent("animation")),D&&(p.raiseEvent("animation-finish"),t[p.hash].mouseInside||c(p)),t[p.hash].animating=F}}function Xe(p){p.imageLoader.clear(),p.world.draw(),p.raiseEvent("update-viewport",{})}function Y(p,x){return p?p+x:x}function $e(){t[this.hash].lastZoomTime=e.now(),t[this.hash].zoomFactor=this.zoomPerSecond,t[this.hash].zooming=!0,z(this)}function ct(){t[this.hash].lastZoomTime=e.now(),t[this.hash].zoomFactor=1/this.zoomPerSecond,t[this.hash].zooming=!0,z(this)}function Ue(){t[this.hash].zooming=!1}function z(p){e.requestAnimationFrame(e.delegate(p,ie))}function ie(){var p,x,C;t[this.hash].zooming&&this.viewport&&(p=e.now(),x=p-t[this.hash].lastZoomTime,C=Math.pow(t[this.hash].zoomFactor,x/1e3),this.viewport.zoomBy(C),this.viewport.applyConstraints(),t[this.hash].lastZoomTime=p,z(this))}function ce(){this.viewport&&(t[this.hash].zooming=!1,this.viewport.zoomBy(this.zoomPerClick/1),this.viewport.applyConstraints())}function we(){this.viewport&&(t[this.hash].zooming=!1,this.viewport.zoomBy(1/this.zoomPerClick),this.viewport.applyConstraints())}function Ye(){this.buttonGroup&&(this.buttonGroup.emulateEnter(),this.buttonGroup.emulateLeave())}function St(){this.viewport&&this.viewport.goHome()}function Nt(){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 Ut(){if(this.viewport){var p=this.viewport.getRotation();this.viewport.flipped?p+=this.rotationIncrement:p-=this.rotationIncrement,this.viewport.setRotation(p)}}function Pt(){if(this.viewport){var p=this.viewport.getRotation();this.viewport.flipped?p-=this.rotationIncrement:p+=this.rotationIncrement,this.viewport.setRotation(p)}}function dt(){this.viewport.toggleFlip()}e.determineDrawer=function(p){for(let x in s){const C=s[x],O=C.prototype;if(O&&O instanceof s.DrawerBase&&e.isFunction(O.getType)&&O.getType.call(C)===p)return C}return null}})(s),(function(e){e.Navigator=function(a){var h=a.viewer,c=this,d,g;a.element||a.id?(a.element?(a.id&&e.console.warn("Given option.id for Navigator was ignored since option.element was provided and is being used instead."),a.element.id?a.id=a.element.id:a.id="navigator-"+e.now(),this.element=a.element):this.element=document.getElementById(a.id),a.controlOptions={anchor:e.ControlAnchor.NONE,attachToViewer:!1,autoFade:!1}):(a.id="navigator-"+e.now(),this.element=e.makeNeutralElement("div"),a.controlOptions={anchor:e.ControlAnchor.TOP_RIGHT,attachToViewer:!0,autoFade:a.autoFade},a.position&&(a.position==="BOTTOM_RIGHT"?a.controlOptions.anchor=e.ControlAnchor.BOTTOM_RIGHT:a.position==="BOTTOM_LEFT"?a.controlOptions.anchor=e.ControlAnchor.BOTTOM_LEFT:a.position==="TOP_RIGHT"?a.controlOptions.anchor=e.ControlAnchor.TOP_RIGHT:a.position==="TOP_LEFT"?a.controlOptions.anchor=e.ControlAnchor.TOP_LEFT:a.position==="ABSOLUTE"&&(a.controlOptions.anchor=e.ControlAnchor.ABSOLUTE,a.controlOptions.top=a.top,a.controlOptions.left=a.left,a.controlOptions.height=a.height,a.controlOptions.width=a.width))),this.element.id=a.id,this.element.className+=" navigator",a=e.extend(!0,{sizeRatio:e.DEFAULT_SETTINGS.navigatorSizeRatio},a,{element:this.element,tabIndex:-1,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:a.animationTime,autoResize:!1,minZoomImageRatio:1,background:a.background,opacity:a.opacity,borderColor:a.borderColor,displayRegionColor:a.displayRegionColor}),a.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),a.controlOptions.anchor!==e.ControlAnchor.NONE&&(function(y,E){y.margin="0px",y.border=E+"px solid "+a.borderColor,y.padding="0px",y.background=a.background,y.opacity=a.opacity,y.overflow="hidden"})(this.element.style,this.borderWidth),this.displayRegion=e.makeNeutralElement("div"),this.displayRegion.id=this.element.id+"-displayregion",this.displayRegion.className="displayregion",(function(y,E){y.position="relative",y.top="0px",y.left="0px",y.fontSize="0px",y.overflow="hidden",y.border=E+"px solid "+a.displayRegionColor,y.margin="0px",y.padding="0px",y.background="transparent",y.float="left",y.cssFloat="left",y.zIndex=999999999,y.cursor="default",y.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,a.controlOptions),this._resizeWithViewer=a.controlOptions.anchor!==e.ControlAnchor.ABSOLUTE&&a.controlOptions.anchor!==e.ControlAnchor.NONE,a.width&&a.height?(this.setWidth(a.width),this.setHeight(a.height)):this._resizeWithViewer&&(d=e.getElementSize(h.element),this.element.style.height=Math.round(d.y*a.sizeRatio)+"px",this.element.style.width=Math.round(d.x*a.sizeRatio)+"px",this.oldViewerSize=d,g=e.getElementSize(this.element),this.elementArea=g.x*g.y),this.oldContainerSize=new e.Point(0,0),e.Viewer.apply(this,[a]),this.displayRegionContainer.appendChild(this.displayRegion),this.element.getElementsByTagName("div")[0].appendChild(this.displayRegionContainer);function m(y,E){u(c.displayRegionContainer,y),u(c.displayRegion,-y),c.viewport.setRotation(y,E)}if(a.navigatorRotate){var _=a.viewer.viewport?a.viewer.viewport.getRotation():a.viewer.degrees||0;m(_,!0),a.viewer.addHandler("rotate",function(y){m(y.degrees,y.immediately)})}this.innerTracker.destroy(),this.innerTracker=new e.MouseTracker({userData:"Navigator.innerTracker",element:this.element,dragHandler:e.delegate(this,i),clickHandler:e.delegate(this,t),releaseHandler:e.delegate(this,n),scrollHandler:e.delegate(this,o),preProcessEventHandler:function(y){y.eventType==="wheel"&&(y.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(y){window.setTimeout(function(){var E=c.world.getItemAt(y.previousIndex);c.world.setItemIndex(E,y.newIndex)},1)}),h.world.addHandler("remove-item",function(y){var E=y.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 a=new e.Point(this.container.clientWidth===0?1:this.container.clientWidth,this.container.clientHeight===0?1:this.container.clientHeight);a.equals(this.oldContainerSize)||(this.viewport.resize(a,!0),this.viewport.goHome(!0),this.oldContainerSize=a,this.world.update(),this.world.draw(),this.update(this.viewer.viewport))}},setWidth:function(a){this.width=a,this.element.style.width=typeof a=="number"?a+"px":a,this._resizeWithViewer=!1,this.updateSize()},setHeight:function(a){this.height=a,this.element.style.height=typeof a=="number"?a+"px":a,this._resizeWithViewer=!1,this.updateSize()},setFlip:function(a){return this.viewport.setFlip(a),this.setDisplayTransform(this.viewer.viewport.getFlip()?"scale(-1,1)":"scale(1,1)"),this},setDisplayTransform:function(a){l(this.canvas,a),l(this.element,a)},update:function(a){var h,c,d,g,m,_;if(a||(a=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()),a&&this.viewport){if(g=a.getBoundsNoRotate(!0),m=this.viewport.pixelFromPointNoRotate(g.getTopLeft(),!1),_=this.viewport.pixelFromPointNoRotate(g.getBottomRight(),!1).minus(this.totalBorderWidths),!this.navigatorRotate){var y=a.getRotation(!0);u(this.displayRegion,-y)}var E=this.displayRegion.style;E.display=this.world.getItemCount()?"block":"none",E.top=m.y.toFixed(2)+"px",E.left=m.x.toFixed(2)+"px";var S=_.x-m.x,P=_.y-m.y;E.width=Math.round(Math.max(S,0))+"px",E.height=Math.round(Math.max(P,0))+"px"}},addTiledImage:function(a){var h=this,c=a.originalTiledImage;delete a.original;var d=e.extend({},a,{success:function(g){var m=g.item;m._originalForNavigator=c,h._matchBounds(m,c,!0),h._matchOpacity(m,c),h._matchCompositeOperation(m,c);function _(){h._matchBounds(m,c)}function y(){h._matchOpacity(m,c)}function E(){h._matchCompositeOperation(m,c)}c.addHandler("bounds-change",_),c.addHandler("clip-change",_),c.addHandler("opacity-change",y),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(a){for(var h=this.world.getItemCount(),c,d=0;d<h;d++)if(c=this.world.getItemAt(d),c._originalForNavigator===a)return c;return null},_matchBounds:function(a,h,c){var d=h.getBoundsNoRotate();a.setPosition(d.getTopLeft(),c),a.setWidth(d.width,c),a.setRotation(h.getRotation(),c),a.setClip(h.getClip()),a.setFlip(h.getFlip())},_matchOpacity:function(a,h){a.setOpacity(h.opacity)},_matchCompositeOperation:function(a,h){a.setCompositeOperation(h.compositeOperation)}});function t(a){var h={tracker:a.eventSource,position:a.position,quick:a.quick,shift:a.shift,originalEvent:a.originalEvent,preventDefaultAction:!1};if(this.viewer.raiseEvent("navigator-click",h),!h.preventDefaultAction&&a.quick&&this.viewer.viewport&&(this.panVertical||this.panHorizontal)){this.viewer.viewport.flipped&&(a.position.x=this.viewport.getContainerSize().x-a.position.x);var c=this.viewport.pointFromPixel(a.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 i(a){var h={tracker:a.eventSource,position:a.position,delta:a.delta,speed:a.speed,direction:a.direction,shift:a.shift,originalEvent:a.originalEvent,preventDefaultAction:!1};this.viewer.raiseEvent("navigator-drag",h),!h.preventDefaultAction&&this.viewer.viewport&&(this.panHorizontal||(a.delta.x=0),this.panVertical||(a.delta.y=0),this.viewer.viewport.flipped&&(a.delta.x=-a.delta.x),this.viewer.viewport.panBy(this.viewport.deltaPointsFromPixels(a.delta)),this.viewer.constrainDuringPan&&this.viewer.viewport.applyConstraints())}function n(a){a.insideElementPressed&&this.viewer.viewport&&this.viewer.viewport.applyConstraints()}function o(a){var h={tracker:a.eventSource,position:a.position,scroll:a.scroll,shift:a.shift,originalEvent:a.originalEvent,preventDefault:a.preventDefault};this.viewer.raiseEvent("navigator-scroll",h),a.preventDefault=h.preventDefault}function u(a,h){l(a,"rotate("+h+"deg)")}function l(a,h){a.style.webkitTransform=h,a.style.mozTransform=h,a.style.msTransform=h,a.style.oTransform=h,a.style.transform=h}})(s),(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(i){var n=i.split("."),o=null,u=arguments,l=t,a;for(a=0;a<n.length-1;a++)l=l[n[a]]||{};return o=l[n[a]],typeof o!="string"&&(e.console.error("Untranslated source string:",i),o=""),o.replace(/\{\d+\}/g,function(h){var c=parseInt(h.match(/\d+/),10)+1;return c<u.length?u[c]:""})},setString:function(i,n){var o=i.split("."),u=t,l;for(l=0;l<o.length-1;l++)u[o[l]]||(u[o[l]]={}),u=u[o[l]];u[o[l]]=n}})})(s),(function(e){e.Point=function(t,i){this.x=typeof t=="number"?t:0,this.y=typeof i=="number"?i: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,i){i=i||new e.Point(0,0);var n,o;if(t%90===0){var u=e.positiveModulo(t,360);switch(u){case 0:n=1,o=0;break;case 90:n=0,o=1;break;case 180:n=-1,o=0;break;case 270:n=0,o=-1;break}}else{var l=t*Math.PI/180;n=Math.cos(l),o=Math.sin(l)}var a=n*(this.x-i.x)-o*(this.y-i.y)+i.x,h=o*(this.x-i.x)+n*(this.y-i.y)+i.y;return new e.Point(a,h)},toString:function(){return"("+Math.round(this.x*100)/100+","+Math.round(this.y*100)/100+")"}}})(s),(function(e){e.TileSource=function(i,n,o,u,l,a){var h=this,c=arguments,d,g;if(e.isPlainObject(i)?d=i: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(g=0;g<arguments.length;g++)if(e.isFunction(arguments[g])){this.success=arguments[g];break}}this.success&&this.addHandler("ready",function(m){h.success(m)}),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(i){return e.console.error("[TileSource.getTileSize] is deprecated. Use TileSource.getTileWidth() and TileSource.getTileHeight() instead"),this._tileWidth},getTileWidth:function(i){return this._tileWidth?this._tileWidth:this.getTileSize(i)},getTileHeight:function(i){return this._tileHeight?this._tileHeight:this.getTileSize(i)},setMaxLevel:function(i){this.maxLevel=i,this._memoizeLevelScale()},getLevelScale:function(i){return this._memoizeLevelScale(),this.getLevelScale(i)},_memoizeLevelScale:function(){var i={},n;for(n=0;n<=this.maxLevel;n++)i[n]=1/Math.pow(2,this.maxLevel-n);this.getLevelScale=function(o){return i[o]}},getNumTiles:function(i){var n=this.getLevelScale(i),o=Math.ceil(n*this.dimensions.x/this.getTileWidth(i)),u=Math.ceil(n*this.dimensions.y/this.getTileHeight(i));return new e.Point(o,u)},getPixelRatio:function(i){var n=this.dimensions.times(this.getLevelScale(i)),o=1/n.x*e.pixelDensityRatio,u=1/n.y*e.pixelDensityRatio;return new e.Point(o,u)},getClosestLevel:function(){var i,n;for(i=this.minLevel+1;i<=this.maxLevel&&(n=this.getNumTiles(i),!(n.x>1||n.y>1));i++);return i-1},getTileAtPoint:function(i,n){var o=n.x>=0&&n.x<=1&&n.y>=0&&n.y<=1/this.aspectRatio;e.console.assert(o,"[TileSource.getTileAtPoint] must be called with a valid point.");var u=this.dimensions.x*this.getLevelScale(i),l=n.x*u,a=n.y*u,h=Math.floor(l/this.getTileWidth(i)),c=Math.floor(a/this.getTileHeight(i));n.x>=1&&(h=this.getNumTiles(i).x-1);var d=1e-15;return n.y>=1/this.aspectRatio-d&&(c=this.getNumTiles(i).y-1),new e.Point(h,c)},getTileBounds:function(i,n,o,u){var l=this.dimensions.times(this.getLevelScale(i)),a=this.getTileWidth(i),h=this.getTileHeight(i),c=n===0?0:a*n-this.tileOverlap,d=o===0?0:h*o-this.tileOverlap,g=a+(n===0?1:2)*this.tileOverlap,m=h+(o===0?1:2)*this.tileOverlap,_=1/l.x;return g=Math.min(g,l.x-c),m=Math.min(m,l.y-d),u?new e.Rect(0,0,g,m):new e.Rect(c*_,d*_,g*_,m*_)},getImageInfo:function(i){var n=this,o,u,l,a,h,c,d;i&&(h=i.split("/"),c=h[h.length-1],d=c.lastIndexOf("."),d>-1&&(h[h.length-1]=c.slice(0,d)));var g=null;if(this.splitHashDataForPost){var m=i.indexOf("#");m!==-1&&(g=i.substring(m+1),i=i.substr(0,m))}u=function(_){typeof _=="string"&&(_=e.parseXml(_));var y=e.TileSource.determineType(n,_,i);if(!y){n.raiseEvent("open-failed",{message:"Unable to load TileSource",source:i});return}a=y.prototype.configure.apply(n,[_,i,g]),a.ajaxWithCredentials===void 0&&(a.ajaxWithCredentials=n.ajaxWithCredentials),l=new y(a),n.ready=!0,n.raiseEvent("ready",{tileSource:l})},i.match(/\.js$/)?(o=i.split("/").pop().replace(".js",""),e.jsonp({url:i,async:!1,callbackName:o,callback:u})):e.makeAjaxRequest({url:i,postData:g,withCredentials:this.ajaxWithCredentials,headers:this.ajaxHeaders,success:function(_){var y=t(_);u(y)},error:function(_,y){var E;try{E="HTTP "+_.status+" attempting to load TileSource: "+i}catch{var S;typeof y>"u"||!y.toString?S="Unknown error":S=y.toString(),E=S+" attempting to load TileSource: "+i}e.console.error(E),n.raiseEvent("open-failed",{message:E,source:i,postData:g})}})},supports:function(i,n){return!1},configure:function(i,n,o){throw new Error("Method not implemented.")},getTileUrl:function(i,n,o){throw new Error("Method not implemented.")},getTilePostData:function(i,n,o){return null},getTileAjaxHeaders:function(i,n,o){return{}},getTileHashKey:function(i,n,o,u,l,a){function h(c){return l?c+"+"+JSON.stringify(l):c}return h(typeof u!="string"?i+"/"+n+"_"+o:u)},tileExists:function(i,n,o){var u=this.getNumTiles(i);return i>=this.minLevel&&i<=this.maxLevel&&n>=0&&o>=0&&n<u.x&&o<u.y},hasTransparency:function(i,n,o,u){return!!i||n.match(".png")},downloadTileStart:function(i){var n=i.userData,o=new Image;n.image=o,n.request=null;var u=function(l){if(!o){i.finish(null,n.request,"Image load failed: undefined Image instance.");return}o.onload=o.onerror=o.onabort=null,i.finish(l?null:o,n.request,l)};o.onload=function(){u()},o.onabort=o.onerror=function(){u("Image load aborted.")},i.loadWithAjax?n.request=e.makeAjaxRequest({url:i.src,withCredentials:i.ajaxWithCredentials,headers:i.ajaxHeaders,responseType:"arraybuffer",postData:i.postData,success:function(l){var a;try{a=new window.Blob([l.response])}catch(d){var h=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if(d.name==="TypeError"&&h){var c=new h;c.append(l.response),a=c.getBlob()}}a.size===0?u("Empty image response."):o.src=(window.URL||window.webkitURL).createObjectURL(a)},error:function(l){u("Image load aborted - XHR error")}}):(i.crossOriginPolicy!==!1&&(o.crossOrigin=i.crossOriginPolicy),o.src=i.src)},downloadTileAbort:function(i){i.userData.request&&i.userData.request.abort();var n=i.userData.image;i.userData.image&&(n.onload=n.onerror=n.onabort=null)},createTileCache:function(i,n,o){i._data=n},destroyTileCache:function(i){i._data=null,i._renderedContext=null},getTileCacheData:function(i){return i._data},getTileCacheDataAsImage:function(i){return i._data},getTileCacheDataAsContext2D:function(i){if(!i._renderedContext){var n=document.createElement("canvas");n.width=i._data.width,n.height=i._data.height,i._renderedContext=n.getContext("2d"),i._renderedContext.drawImage(i._data,0,0),i._data=null}return i._renderedContext}},e.extend(!0,e.TileSource.prototype,e.EventSource.prototype);function t(i){var n=i.responseText,o=i.status,u,l;if(i){if(i.status!==200&&i.status!==0)throw o=i.status,u=o===404?"Not Found":i.statusText,new Error(e.getString("Errors.Status",o,u))}else throw new Error(e.getString("Errors.Security"));if(n.match(/^\s*<.*/))try{l=i.responseXML&&i.responseXML.documentElement?i.responseXML:e.parseXml(n)}catch{l=i.responseText}else if(n.match(/\s*[{[].*/))try{l=e.parseJSON(n)}catch{l=n}else l=n;return l}e.TileSource.determineType=function(i,n,o){var u;for(u in s)if(u.match(/.+TileSource$/)&&e.isFunction(s[u])&&e.isFunction(s[u].prototype.supports)&&s[u].prototype.supports.call(i,n,o))return s[u];return e.console.error("No TileSource was able to open %s %s",o,n),null}})(s),(function(e){e.DziTileSource=function(n,o,u,l,a,h,c,d,g){var m,_,y,E;if(e.isPlainObject(n)?E=n: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(m=this.displayRects.length-1;m>=0;m--)for(_=this.displayRects[m],y=_.minLevel;y<=_.maxLevel;y++)this._levelRects[y]||(this._levelRects[y]=[]),this._levelRects[y].push(_);e.TileSource.apply(this,[E])},e.extend(e.DziTileSource.prototype,e.TileSource.prototype,{supports:function(n,o){var u;return n.Image?u=n.Image.xmlns:n.documentElement&&(n.documentElement.localName==="Image"||n.documentElement.tagName==="Image")&&(u=n.documentElement.namespaceURI),u=(u||"").toLowerCase(),u.indexOf("schemas.microsoft.com/deepzoom/2008")!==-1||u.indexOf("schemas.microsoft.com/deepzoom/2009")!==-1},configure:function(n,o,u){var l;return e.isPlainObject(n)?l=i(this,n):l=t(this,n),o&&!l.tilesUrl&&(l.tilesUrl=o.replace(/([^/]+?)(\.(dzi|xml|js)?(\?[^/]*)?)?\/?$/,"$1_files/"),o.search(/\.(dzi|xml|js)\?/)!==-1?l.queryParams=o.match(/\?.*/):l.queryParams=""),l},getTileUrl:function(n,o,u){return[this.tilesUrl,n,"/",o,"_",u,".",this.fileFormat,this.queryParams].join("")},tileExists:function(n,o,u){var l=this._levelRects[n],a,h,c,d,g,m,_;if(this.minLevel&&n<this.minLevel||this.maxLevel&&n>this.maxLevel)return!1;if(!l||!l.length)return!0;for(_=l.length-1;_>=0;_--)if(a=l[_],!(n<a.minLevel||n>a.maxLevel)&&(h=this.getLevelScale(n),c=a.x*h,d=a.y*h,g=c+a.width*h,m=d+a.height*h,c=Math.floor(c/this._tileWidth),d=Math.floor(d/this._tileWidth),g=Math.ceil(g/this._tileWidth),m=Math.ceil(m/this._tileWidth),c<=o&&o<g&&d<=u&&u<m))return!0;return!1}});function t(n,o){if(!o||!o.documentElement)throw new Error(e.getString("Errors.Xml"));var u=o.documentElement,l=u.localName||u.tagName,a=o.documentElement.namespaceURI,h=null,c=[],d,g,m,_,y;if(l==="Image")try{if(_=u.getElementsByTagName("Size")[0],_===void 0&&(_=u.getElementsByTagNameNS(a,"Size")[0]),h={Image:{xmlns:"http://schemas.microsoft.com/deepzoom/2008",Url:u.getAttribute("Url"),Format:u.getAttribute("Format"),DisplayRect:null,Overlap:parseInt(u.getAttribute("Overlap"),10),TileSize:parseInt(u.getAttribute("TileSize"),10),Size:{Height:parseInt(_.getAttribute("Height"),10),Width:parseInt(_.getAttribute("Width"),10)}}},!e.imageFormatSupported(h.Image.Format))throw new Error(e.getString("Errors.ImageFormat",h.Image.Format.toUpperCase()));for(d=u.getElementsByTagName("DisplayRect"),d===void 0&&(d=u.getElementsByTagNameNS(a,"DisplayRect")[0]),y=0;y<d.length;y++)g=d[y],m=g.getElementsByTagName("Rect")[0],m===void 0&&(m=g.getElementsByTagNameNS(a,"Rect")[0]),c.push({Rect:{X:parseInt(m.getAttribute("X"),10),Y:parseInt(m.getAttribute("Y"),10),Width:parseInt(m.getAttribute("Width"),10),Height:parseInt(m.getAttribute("Height"),10),MinLevel:parseInt(g.getAttribute("MinLevel"),10),MaxLevel:parseInt(g.getAttribute("MaxLevel"),10)}});return c.length&&(h.Image.DisplayRect=c),i(n,h)}catch(P){throw P instanceof Error?P:new Error(e.getString("Errors.Dzi"))}else{if(l==="Collection")throw new Error(e.getString("Errors.Dzc"));if(l==="Error"){var E=u.getElementsByTagName("Message")[0],S=E.firstChild.nodeValue;throw new Error(S)}}throw new Error(e.getString("Errors.Dzi"))}function i(n,o){var u=o.Image,l=u.Url,a=u.Format,h=u.Size,c=u.DisplayRect||[],d=parseInt(h.Width,10),g=parseInt(h.Height,10),m=parseInt(u.TileSize,10),_=parseInt(u.Overlap,10),y=[],E,S;for(S=0;S<c.length;S++)E=c[S].Rect,y.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:g,tileSize:m,tileOverlap:_,minLevel:null,maxLevel:null,tilesUrl:l,fileFormat:a,displayRects:y},o)}})(s),(function(e){e.IIIFTileSource=function(u){if(e.extend(!0,this,u),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(u.tileSizePerScaleFactor={},this.tileFormat=this.tileFormat||"jpg",this.version=u.version,this.tile_width&&this.tile_height)u.tileWidth=this.tile_width,u.tileHeight=this.tile_height;else if(this.tile_width)u.tileSize=this.tile_width;else if(this.tile_height)u.tileSize=this.tile_height;else if(this.tiles)if(this.tiles.length===1)u.tileWidth=this.tiles[0].width,u.tileHeight=this.tiles[0].height||this.tiles[0].width,this.scale_factors=this.tiles[0].scaleFactors;else{this.scale_factors=[];for(var l=0;l<this.tiles.length;l++)for(var a=0;a<this.tiles[l].scaleFactors.length;a++){var h=this.tiles[l].scaleFactors[a];this.scale_factors.push(h),u.tileSizePerScaleFactor[h]={width:this.tiles[l].width,height:this.tiles[l].height||this.tiles[l].width}}}else if(t(u)){for(var c=Math.min(this.height,this.width),d=[256,512,1024],g=[],m=0;m<d.length;m++)d[m]<=c&&g.push(d[m]);g.length>0?u.tileSize=Math.max.apply(null,g):u.tileSize=c}else this.sizes&&this.sizes.length>0?(this.emulateLegacyImagePyramid=!0,u.levels=i(this),e.extend(!0,u,{width:u.levels[u.levels.length-1].width,height:u.levels[u.levels.length-1].height,tileSize:Math.max(u.height,u.width),tileOverlap:0,minLevel:0,maxLevel:u.levels.length-1}),this.levels=u.levels):e.console.error("Nothing in the info.json to construct image pyramids from");if(!u.maxLevel&&!this.emulateLegacyImagePyramid)if(!this.scale_factors)u.maxLevel=Number(Math.round(Math.log(Math.max(this.width,this.height),2)));else{var _=Math.max.apply(null,this.scale_factors);u.maxLevel=Math.round(Math.log(_)*Math.LOG2E)}if(this.sizes){var y=this.sizes.length;(y===u.maxLevel||y===u.maxLevel+1)&&(this.levelSizes=this.sizes.slice().sort((E,S)=>E.width-S.width),y===u.maxLevel&&this.levelSizes.push({width:this.width,height:this.height}))}e.TileSource.apply(this,[u])},e.extend(e.IIIFTileSource.prototype,e.TileSource.prototype,{supports:function(u,l){return u.protocol&&u.protocol==="http://iiif.io/api/image"||u["@context"]&&(u["@context"]==="http://library.stanford.edu/iiif/image-api/1.1/context.json"||u["@context"]==="http://iiif.io/api/image/1/context.json")||u.profile&&u.profile.indexOf("http://library.stanford.edu/iiif/image-api/compliance.html")===0||u.identifier&&u.width&&u.height?!0:!!(u.documentElement&&u.documentElement.tagName==="info"&&u.documentElement.namespaceURI==="http://library.stanford.edu/iiif/image-api/ns/")},configure:function(u,l,a){if(e.isPlainObject(u)){if(!u["@context"])u["@context"]="http://iiif.io/api/image/1.0/context.json",u["@id"]=l.replace("/info.json",""),u.version=1;else{var h=u["@context"];if(Array.isArray(h)){for(var c=0;c<h.length;c++)if(typeof h[c]=="string"&&(/^http:\/\/iiif\.io\/api\/image\/[1-3]\/context\.json$/.test(h[c])||h[c]==="http://library.stanford.edu/iiif/image-api/1.1/context.json")){h=h[c];break}}switch(h){case"http://iiif.io/api/image/1/context.json":case"http://library.stanford.edu/iiif/image-api/1.1/context.json":u.version=1;break;case"http://iiif.io/api/image/2/context.json":u.version=2;break;case"http://iiif.io/api/image/3/context.json":u.version=3;break;default:e.console.error("Data has a @context property which contains no known IIIF context URI.")}}if(u.preferredFormats){for(var d=0;d<u.preferredFormats.length;d++)if(s.imageFormatSupported(u.preferredFormats[d])){u.tileFormat=u.preferredFormats[d];break}}return u}else{var g=n(u);return g["@context"]="http://iiif.io/api/image/1.0/context.json",g["@id"]=l.replace("/info.xml",""),g.version=1,g}},getTileWidth:function(u){if(this.emulateLegacyImagePyramid)return e.TileSource.prototype.getTileWidth.call(this,u);var l=Math.pow(2,this.maxLevel-u);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[l]?this.tileSizePerScaleFactor[l].width:this._tileWidth},getTileHeight:function(u){if(this.emulateLegacyImagePyramid)return e.TileSource.prototype.getTileHeight.call(this,u);var l=Math.pow(2,this.maxLevel-u);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[l]?this.tileSizePerScaleFactor[l].height:this._tileHeight},getLevelScale:function(u){if(this.emulateLegacyImagePyramid){var l=NaN;return this.levels.length>0&&u>=this.minLevel&&u<=this.maxLevel&&(l=this.levels[u].width/this.levels[this.maxLevel].width),l}return e.TileSource.prototype.getLevelScale.call(this,u)},getNumTiles:function(u){if(this.emulateLegacyImagePyramid){var l=this.getLevelScale(u);return l?new e.Point(1,1):new e.Point(0,0)}if(this.levelSizes){var a=this.levelSizes[u],h=Math.ceil(a.width/this.getTileWidth(u)),c=Math.ceil(a.height/this.getTileHeight(u));return new e.Point(h,c)}else return e.TileSource.prototype.getNumTiles.call(this,u)},getTileAtPoint:function(u,l){if(this.emulateLegacyImagePyramid)return new e.Point(0,0);if(this.levelSizes){var a=l.x>=0&&l.x<=1&&l.y>=0&&l.y<=1/this.aspectRatio;e.console.assert(a,"[TileSource.getTileAtPoint] must be called with a valid point.");var h=this.levelSizes[u].width,c=l.x*h,d=l.y*h,g=Math.floor(c/this.getTileWidth(u)),m=Math.floor(d/this.getTileHeight(u));l.x>=1&&(g=this.getNumTiles(u).x-1);var _=1e-15;return l.y>=1/this.aspectRatio-_&&(m=this.getNumTiles(u).y-1),new e.Point(g,m)}return e.TileSource.prototype.getTileAtPoint.call(this,u,l)},getTileUrl:function(u,l,a){if(this.emulateLegacyImagePyramid){var h=null;return this.levels.length>0&&u>=this.minLevel&&u<=this.maxLevel&&(h=this.levels[u].url),h}var c="0",d=Math.pow(.5,this.maxLevel-u),g,m,_,y,E,S,P,B,k,M,L,W,$,Q,q,V;return this.levelSizes?(g=this.levelSizes[u].width,m=this.levelSizes[u].height):(g=Math.ceil(this.width*d),m=Math.ceil(this.height*d)),_=this.getTileWidth(u),y=this.getTileHeight(u),E=Math.round(_/d),S=Math.round(y/d),this.version===1?q="native."+this.tileFormat:q="default."+this.tileFormat,g<_&&m<y?(this.version===2&&g===this.width?W="full":this.version===3&&g===this.width&&m===this.height?W="max":this.version===3?W=g+","+m:W=g+",",P="full"):(B=l*E,k=a*S,M=Math.min(E,this.width-B),L=Math.min(S,this.height-k),l===0&&a===0&&M===this.width&&L===this.height?P="full":P=[B,k,M,L].join(","),$=Math.min(_,g-l*_),Q=Math.min(y,m-a*y),this.version===2&&$===this.width?W="full":this.version===3&&$===this.width&&Q===this.height?W="max":this.version===3?W=$+","+Q:W=$+","),V=[this._id,P,W,c,q].join("/"),V},__testonly__:{canBeTiled:t,constructLevels:i}});function t(u){var l=["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"],a=Array.isArray(u.profile)?u.profile[0]:u.profile,h=l.indexOf(a)!==-1,c=!1;return u.version===2&&u.profile.length>1&&u.profile[1].supports&&(c=u.profile[1].supports.indexOf("sizeByW")!==-1),u.version===3&&u.extraFeatures&&(c=u.extraFeatures.indexOf("sizeByWh")!==-1),!h||c}function i(u){for(var l=[],a=0;a<u.sizes.length;a++)l.push({url:u._id+"/full/"+u.sizes[a].width+","+(u.version===3?u.sizes[a].height:"")+"/0/default."+u.tileFormat,width:u.sizes[a].width,height:u.sizes[a].height});return l.sort(function(h,c){return h.width-c.width})}function n(u){if(!u||!u.documentElement)throw new Error(e.getString("Errors.Xml"));var l=u.documentElement,a=l.tagName,h=null;if(a==="info")try{return h={},o(l,h),h}catch(c){throw c instanceof Error?c:new Error(e.getString("Errors.IIIF"))}throw new Error(e.getString("Errors.IIIF"))}function o(u,l,a){var h,c;if(u.nodeType===3&&a)c=u.nodeValue.trim(),c.match(/^\d*$/)&&(c=Number(c)),l[a]?(e.isArray(l[a])||(l[a]=[l[a]]),l[a].push(c)):l[a]=c;else if(u.nodeType===1)for(h=0;h<u.childNodes.length;h++)o(u.childNodes[h],l,u.nodeName)}})(s),(function(e){e.OsmTileSource=function(t,i,n,o,u){var l;e.isPlainObject(t)?l=t:l={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]},(!l.width||!l.height)&&(l.width=65572864,l.height=65572864),l.tileSize||(l.tileSize=256,l.tileOverlap=0),l.tilesUrl||(l.tilesUrl="http://tile.openstreetmap.org/"),l.minLevel=8,e.TileSource.apply(this,[l])},e.extend(e.OsmTileSource.prototype,e.TileSource.prototype,{supports:function(t,i){return t.type&&t.type==="openstreetmaps"},configure:function(t,i,n){return t},getTileUrl:function(t,i,n){return this.tilesUrl+(t-8)+"/"+i+"/"+n+".png"}})})(s),(function(e){e.TmsTileSource=function(t,i,n,o,u){var l;e.isPlainObject(t)?l=t:l={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]};var a=Math.ceil(l.width/256)*256,h=Math.ceil(l.height/256)*256,c;a>h?c=a/256:c=h/256,l.maxLevel=Math.ceil(Math.log(c)/Math.log(2))-1,l.tileSize=256,l.width=a,l.height=h,e.TileSource.apply(this,[l])},e.extend(e.TmsTileSource.prototype,e.TileSource.prototype,{supports:function(t,i){return t.type&&t.type==="tiledmapservice"},configure:function(t,i,n){return t},getTileUrl:function(t,i,n){var o=this.getNumTiles(t).y-1;return this.tilesUrl+t+"/"+i+"/"+(o-n)+".png"}})})(s),(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 i={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(i.x,10)>t.tileSize||parseInt(i.y,10)>t.tileSize;)i.x=Math.floor(i.x/2),i.y=Math.floor(i.y/2),t.imageSizes.push({x:i.x,y:i.y}),t.gridSize.push(this._getGridSize(i.x,i.y,t.tileSize));t.imageSizes.reverse(),t.gridSize.reverse(),t.minLevel=0,t.maxLevel=t.gridSize.length-1,s.TileSource.apply(this,[t])},e.extend(e.ZoomifyTileSource.prototype,e.TileSource.prototype,{_getGridSize:function(t,i,n){return{x:Math.ceil(t/n),y:Math.ceil(i/n)}},_calculateAbsoluteTileNumber:function(t,i,n){for(var o=0,u={},l=0;l<t;l++)u=this.gridSize[l],o+=u.x*u.y;return u=this.gridSize[t],o+=u.x*n+i,o},supports:function(t,i){return t.type&&t.type==="zoomifytileservice"},configure:function(t,i,n){return t},getTileUrl:function(t,i,n){var o=0,u=this._calculateAbsoluteTileNumber(t,i,n);return o=Math.floor(u/256),this.tilesUrl+"TileGroup"+o+"/"+t+"-"+i+"-"+n+"."+this.fileFormat}})})(s),(function(e){e.LegacyTileSource=function(o){var u,l,a;e.isArray(o)&&(u={type:"legacy-image-pyramid",levels:o}),u.levels=t(u.levels),u.levels.length>0?(l=u.levels[u.levels.length-1].width,a=u.levels[u.levels.length-1].height):(l=0,a=0,e.console.error("No supported image formats found")),e.extend(!0,u,{width:l,height:a,tileSize:Math.max(a,l),tileOverlap:0,minLevel:0,maxLevel:u.levels.length>0?u.levels.length-1:0}),e.TileSource.apply(this,[u]),this.levels=u.levels},e.extend(e.LegacyTileSource.prototype,e.TileSource.prototype,{supports:function(o,u){return o.type&&o.type==="legacy-image-pyramid"||o.documentElement&&o.documentElement.getAttribute("type")==="legacy-image-pyramid"},configure:function(o,u,l){var a;return e.isPlainObject(o)?a=n(this,o):a=i(this,o),a},getLevelScale:function(o){var u=NaN;return this.levels.length>0&&o>=this.minLevel&&o<=this.maxLevel&&(u=this.levels[o].width/this.levels[this.maxLevel].width),u},getNumTiles:function(o){var u=this.getLevelScale(o);return u?new e.Point(1,1):new e.Point(0,0)},getTileUrl:function(o,u,l){var a=null;return this.levels.length>0&&o>=this.minLevel&&o<=this.maxLevel&&(a=this.levels[o].url),a}});function t(o){var u=[],l,a;for(a=0;a<o.length;a++)l=o[a],l.height&&l.width&&l.url?u.push({url:l.url,width:Number(l.width),height:Number(l.height)}):e.console.error("Unsupported image format: %s",l.url?l.url:"<no URL>");return u.sort(function(h,c){return h.height-c.height})}function i(o,u){if(!u||!u.documentElement)throw new Error(e.getString("Errors.Xml"));var l=u.documentElement,a=l.tagName,h=null,c=[],d,g;if(a==="image")try{for(h={type:l.getAttribute("type"),levels:[]},c=l.getElementsByTagName("level"),g=0;g<c.length;g++)d=c[g],h.levels.push({url:d.getAttribute("url"),width:parseInt(d.getAttribute("width"),10),height:parseInt(d.getAttribute("height"),10)});return n(o,h)}catch(m){throw m instanceof Error?m:new Error("Unknown error parsing Legacy Image Pyramid XML.")}else{if(a==="collection")throw new Error("Legacy Image Pyramid Collections not yet supported.");if(a==="error")throw new Error("Error: "+u)}throw new Error("Unknown element "+a)}function n(o,u){return u.levels}})(s),(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,i){return t.type&&t.type==="image"},configure:function(t,i,n){return t},getImageInfo:function(t){var i=this._image=new Image,n=this;this.crossOriginPolicy&&(i.crossOrigin=this.crossOriginPolicy),this.ajaxWithCredentials&&(i.useCredentials=this.ajaxWithCredentials),e.addEvent(i,"load",function(){n.width=i.naturalWidth,n.height=i.naturalHeight,n.aspectRatio=n.width/n.height,n.dimensions=new e.Point(n.width,n.height),n._tileWidth=n.width,n._tileHeight=n.height,n.tileOverlap=0,n.minLevel=0,n.levels=n._buildLevels(),n.maxLevel=n.levels.length-1,n.ready=!0,n.raiseEvent("ready",{tileSource:n})}),e.addEvent(i,"error",function(){n.raiseEvent("open-failed",{message:"Error loading image at "+t,source:t})}),i.src=t},getLevelScale:function(t){var i=NaN;return t>=this.minLevel&&t<=this.maxLevel&&(i=this.levels[t].width/this.levels[this.maxLevel].width),i},getNumTiles:function(t){var i=this.getLevelScale(t);return i?new e.Point(1,1):new e.Point(0,0)},getTileUrl:function(t,i,n){var o=null;return t>=this.minLevel&&t<=this.maxLevel&&(o=this.levels[t].url),o},getContext2D:function(t,i,n){var o=null;return t>=this.minLevel&&t<=this.maxLevel&&(o=this.levels[t].context2D),o},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 i=this._image.naturalWidth,n=this._image.naturalHeight,o=document.createElement("canvas"),u=o.getContext("2d");if(o.width=i,o.height=n,u.drawImage(this._image,0,0,i,n),t[0].context2D=u,delete this._image,e.isCanvasTainted(o))return t;for(;i>=2&&n>=2;){i=Math.floor(i/2),n=Math.floor(n/2);var l=document.createElement("canvas"),a=l.getContext("2d");l.width=i,l.height=n,a.drawImage(o,0,0,i,n),t.splice(0,0,{context2D:a,width:i,height:n}),o=l,u=a}return t},_freeupCanvasMemory:function(t){for(var i=0;i<this.levels.length;i++)this.levels[i].context2D&&(this.levels[i].context2D.canvas.height=0,this.levels[i].context2D.canvas.width=0,t&&t.raiseEvent("image-unloaded",{context2D:this.levels[i].context2D}))}})})(s),(function(e){e.TileSourceCollection=function(t,i,n,o){e.console.error("TileSourceCollection is deprecated; use World instead")}})(s),(function(e){e.ButtonState={REST:0,GROUP:1,HOVER:2,DOWN:3},e.Button=function(a){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},a),this.element=a.element||e.makeNeutralElement("div"),a.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?(u(h,e.ButtonState.DOWN),h.raiseEvent("enter",{originalEvent:c.originalEvent})):c.buttonDownAny||u(h,e.ButtonState.HOVER)},focusHandler:function(c){h.tracker.enterHandler(c),h.raiseEvent("focus",{originalEvent:c.originalEvent})},leaveHandler:function(c){l(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){u(h,e.ButtonState.DOWN),h.raiseEvent("press",{originalEvent:c.originalEvent})},releaseHandler:function(c){c.insideElementPressed&&c.insideElementReleased?(l(h,e.ButtonState.HOVER),h.raiseEvent("release",{originalEvent:c.originalEvent})):c.insideElementPressed?l(h,e.ButtonState.GROUP):u(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}}),l(this,e.ButtonState.REST)},e.extend(e.Button.prototype,e.EventSource.prototype,{notifyGroupEnter:function(){u(this,e.ButtonState.GROUP)},notifyGroupExit:function(){l(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(a){e.requestAnimationFrame(function(){i(a)})}function i(a){var h,c,d;a.shouldFade&&(h=e.now(),c=h-a.fadeBeginTime,d=1-c/a.fadeLength,d=Math.min(1,d),d=Math.max(0,d),a.imgGroup&&e.setElementOpacity(a.imgGroup,d,!0),d>0&&t(a))}function n(a){a.shouldFade=!0,a.fadeBeginTime=e.now()+a.fadeDelay,window.setTimeout(function(){t(a)},a.fadeDelay)}function o(a){a.shouldFade=!1,a.imgGroup&&e.setElementOpacity(a.imgGroup,1,!0)}function u(a,h){a.element.disabled||(h>=e.ButtonState.GROUP&&a.currentState===e.ButtonState.REST&&(o(a),a.currentState=e.ButtonState.GROUP),h>=e.ButtonState.HOVER&&a.currentState===e.ButtonState.GROUP&&(a.imgHover&&(a.imgHover.style.visibility=""),a.currentState=e.ButtonState.HOVER),h>=e.ButtonState.DOWN&&a.currentState===e.ButtonState.HOVER&&(a.imgDown&&(a.imgDown.style.visibility=""),a.currentState=e.ButtonState.DOWN))}function l(a,h){a.element.disabled||(h<=e.ButtonState.HOVER&&a.currentState===e.ButtonState.DOWN&&(a.imgDown&&(a.imgDown.style.visibility="hidden"),a.currentState=e.ButtonState.HOVER),h<=e.ButtonState.GROUP&&a.currentState===e.ButtonState.HOVER&&(a.imgHover&&(a.imgHover.style.visibility="hidden"),a.currentState=e.ButtonState.GROUP),h<=e.ButtonState.REST&&a.currentState===e.ButtonState.GROUP&&(n(a),a.currentState=e.ButtonState.REST))}})(s),(function(e){e.ButtonGroup=function(t){e.extend(!0,this,{buttons:[],clickTimeThreshold:e.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:e.DEFAULT_SETTINGS.clickDistThreshold,labelText:""},t);var i=this.buttons.concat([]),n=this,o;if(this.element=t.element||e.makeNeutralElement("div"),!t.group)for(this.element.style.display="inline-block",o=0;o<i.length;o++)this.element.appendChild(i[o].element);e.setElementTouchActionNone(this.element),this.tracker=new e.MouseTracker({userData:"ButtonGroup.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(u){var l;for(l=0;l<n.buttons.length;l++)n.buttons[l].notifyGroupEnter()},leaveHandler:function(u){var l;if(!u.insideElementPressed)for(l=0;l<n.buttons.length;l++)n.buttons[l].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}}})(s),(function(e){e.Rect=function(t,i,n,o,u){this.x=typeof t=="number"?t:0,this.y=typeof i=="number"?i:0,this.width=typeof n=="number"?n:0,this.height=typeof o=="number"?o:0,this.degrees=typeof u=="number"?u:0,this.degrees=e.positiveModulo(this.degrees,360);var l,a;this.degrees>=270?(l=this.getTopRight(),this.x=l.x,this.y=l.y,a=this.height,this.height=this.width,this.width=a,this.degrees-=270):this.degrees>=180?(l=this.getBottomRight(),this.x=l.x,this.y=l.y,this.degrees-=180):this.degrees>=90&&(l=this.getBottomLeft(),this.x=l.x,this.y=l.y,a=this.height,this.height=this.width,this.width=a,this.degrees-=90)},e.Rect.fromSummits=function(t,i,n){var o=t.distanceTo(i),u=t.distanceTo(n),l=i.minus(t),a=Math.atan(l.y/l.x);return l.x<0?a+=Math.PI:l.y<0&&(a+=2*Math.PI),new e.Rect(t.x,t.y,o,u,a/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 i=this.getBoundingBox(),n=t.getBoundingBox(),o=Math.min(i.x,n.x),u=Math.min(i.y,n.y),l=Math.max(i.x+i.width,n.x+n.width),a=Math.max(i.y+i.height,n.y+n.height);return new e.Rect(o,u,l-o,a-u)},intersection:function(t){var i=1e-10,n=[],o=this.getTopLeft();t.containsPoint(o,i)&&n.push(o);var u=this.getTopRight();t.containsPoint(u,i)&&n.push(u);var l=this.getBottomLeft();t.containsPoint(l,i)&&n.push(l);var a=this.getBottomRight();t.containsPoint(a,i)&&n.push(a);var h=t.getTopLeft();this.containsPoint(h,i)&&n.push(h);var c=t.getTopRight();this.containsPoint(c,i)&&n.push(c);var d=t.getBottomLeft();this.containsPoint(d,i)&&n.push(d);var g=t.getBottomRight();this.containsPoint(g,i)&&n.push(g);for(var m=this._getSegments(),_=t._getSegments(),y=0;y<m.length;y++)for(var E=m[y],S=0;S<_.length;S++){var P=_[S],B=k(E[0],E[1],P[0],P[1]);B&&n.push(B)}function k(V,re,he,de){var pe=re.minus(V),ge=de.minus(he),me=-ge.x*pe.y+pe.x*ge.y;if(me===0)return null;var Pe=(pe.x*(V.y-he.y)-pe.y*(V.x-he.x))/me,Le=(ge.x*(V.y-he.y)-ge.y*(V.x-he.x))/me;return-i<=Pe&&Pe<=1-i&&-i<=Le&&Le<=1-i?new e.Point(V.x+Le*pe.x,V.y+Le*pe.y):null}if(n.length===0)return null;for(var M=n[0].x,L=n[0].x,W=n[0].y,$=n[0].y,Q=1;Q<n.length;Q++){var q=n[Q];q.x<M&&(M=q.x),q.x>L&&(L=q.x),q.y<W&&(W=q.y),q.y>$&&($=q.y)}return new e.Rect(M,W,L-M,$-W)},_getSegments:function(){var t=this.getTopLeft(),i=this.getTopRight(),n=this.getBottomLeft(),o=this.getBottomRight();return[[t,i],[i,o],[o,n],[n,t]]},rotate:function(t,i){if(t=e.positiveModulo(t,360),t===0)return this.clone();i=i||this.getCenter();var n=this.getTopLeft().rotate(t,i),o=this.getTopRight().rotate(t,i),u=o.minus(n);u=u.apply(function(a){var h=1e-15;return Math.abs(a)<h?0:a});var l=Math.atan(u.y/u.x);return u.x<0?l+=Math.PI:u.y<0&&(l+=2*Math.PI),new e.Rect(n.x,n.y,this.width,this.height,l/Math.PI*180)},getBoundingBox:function(){if(this.degrees===0)return this.clone();var t=this.getTopLeft(),i=this.getTopRight(),n=this.getBottomLeft(),o=this.getBottomRight(),u=Math.min(t.x,i.x,n.x,o.x),l=Math.max(t.x,i.x,n.x,o.x),a=Math.min(t.y,i.y,n.y,o.y),h=Math.max(t.y,i.y,n.y,o.y);return new e.Rect(u,a,l-u,h-a)},getIntegerBoundingBox:function(){var t=this.getBoundingBox(),i=Math.floor(t.x),n=Math.floor(t.y),o=Math.ceil(t.width+t.x-i),u=Math.ceil(t.height+t.y-n);return new e.Rect(i,n,o,u)},containsPoint:function(t,i){i=i||0;var n=this.getTopLeft(),o=this.getTopRight(),u=this.getBottomLeft(),l=o.minus(n),a=u.minus(n);return(t.x-n.x)*l.x+(t.y-n.y)*l.y>=-i&&(t.x-o.x)*l.x+(t.y-o.y)*l.y<=i&&(t.x-n.x)*a.x+(t.y-n.y)*a.y>=-i&&(t.x-u.x)*a.x+(t.y-u.y)*a.y<=i},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]"}}})(s),(function(e){var t={};e.ReferenceStrip=function(d){var g=this,m=d.viewer,_=e.getElementSize(m.element),y,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=m,this.tracker=new e.MouseTracker({userData:"ReferenceStrip.tracker",element:this.element,clickHandler:e.delegate(this,i),dragHandler:e.delegate(this,n),scrollHandler:e.delegate(this,o),enterHandler:e.delegate(this,l),leaveHandler:e.delegate(this,a),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",m.addControl(this.element,{anchor:e.ControlAnchor.BOTTOM_LEFT})):d.scroll==="horizontal"?(this.element.style.width=_.x*d.sizeRatio*m.tileSources.length+12*m.tileSources.length+"px",this.element.style.height=_.y*d.sizeRatio+"px",m.addControl(this.element,{anchor:e.ControlAnchor.BOTTOM_LEFT})):(this.element.style.height=_.y*d.sizeRatio*m.tileSources.length+12*m.tileSources.length+"px",this.element.style.width=_.x*d.sizeRatio+"px",m.addControl(this.element,{anchor:e.ControlAnchor.TOP_LEFT})),this.panelWidth=_.x*this.sizeRatio+8,this.panelHeight=_.y*this.sizeRatio+8,this.panels=[],this.miniViewers={},S=0;S<m.tileSources.length;S++)y=e.makeNeutralElement("div"),y.id=this.element.id+"-"+S,y.style.width=g.panelWidth+"px",y.style.height=g.panelHeight+"px",y.style.display="inline",y.style.float="left",y.style.cssFloat="left",y.style.padding="2px",e.setElementTouchActionNone(y),e.setElementPointerEventsNone(y),this.element.appendChild(y),y.activePanel=!1,this.panels.push(y);u(this,this.scroll==="vertical"?_.y:_.x,0),this.setFocus(0)},e.ReferenceStrip.prototype={setFocus:function(d){var g=this.element.querySelector("#"+this.element.id+"-"+d),m=e.getElementSize(this.viewer.canvas),_=Number(this.element.style.width.replace("px","")),y=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!==g&&(this.currentSelected&&(this.currentSelected.style.background="#000"),this.currentSelected=g,this.currentSelected.style.background="#999",this.scroll==="horizontal"?(P=Number(d)*(this.panelWidth+3),P>E+m.x-this.panelWidth?(P=Math.min(P,_-m.x),this.element.style.marginLeft=-P+"px",u(this,m.x,-P)):P<E&&(P=Math.max(0,P-m.x/2),this.element.style.marginLeft=-P+"px",u(this,m.x,-P))):(P=Number(d)*(this.panelHeight+3),P>S+m.y-this.panelHeight?(P=Math.min(P,y-m.y),this.element.style.marginTop=-P+"px",u(this,m.y,-P)):P<S&&(P=Math.max(0,P-m.y/2),this.element.style.marginTop=-P+"px",u(this,m.y,-P))),this.currentPage=d,l.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 i(d){if(d.quick){var g;this.scroll==="horizontal"?g=Math.floor(d.position.x/(this.panelWidth+4)):g=Math.floor(d.position.y/this.panelHeight),this.viewer.goToPage(g)}this.element.focus()}function n(d){if(this.dragging=!0,this.element){var g=Number(this.element.style.marginLeft.replace("px","")),m=Number(this.element.style.marginTop.replace("px","")),_=Number(this.element.style.width.replace("px","")),y=Number(this.element.style.height.replace("px","")),E=e.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?-d.delta.x>0?g>-(_-E.x)&&(this.element.style.marginLeft=g+d.delta.x*2+"px",u(this,E.x,g+d.delta.x*2)):-d.delta.x<0&&g<0&&(this.element.style.marginLeft=g+d.delta.x*2+"px",u(this,E.x,g+d.delta.x*2)):-d.delta.y>0?m>-(y-E.y)&&(this.element.style.marginTop=m+d.delta.y*2+"px",u(this,E.y,m+d.delta.y*2)):-d.delta.y<0&&m<0&&(this.element.style.marginTop=m+d.delta.y*2+"px",u(this,E.y,m+d.delta.y*2))}}function o(d){if(this.element){var g=Number(this.element.style.marginLeft.replace("px","")),m=Number(this.element.style.marginTop.replace("px","")),_=Number(this.element.style.width.replace("px","")),y=Number(this.element.style.height.replace("px","")),E=e.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?d.scroll>0?g>-(_-E.x)&&(this.element.style.marginLeft=g-d.scroll*60+"px",u(this,E.x,g-d.scroll*60)):d.scroll<0&&g<0&&(this.element.style.marginLeft=g-d.scroll*60+"px",u(this,E.x,g-d.scroll*60)):d.scroll<0?m>E.y-y&&(this.element.style.marginTop=m+d.scroll*60+"px",u(this,E.y,m+d.scroll*60)):d.scroll>0&&m<0&&(this.element.style.marginTop=m+d.scroll*60+"px",u(this,E.y,m+d.scroll*60)),d.preventDefault=!0}}function u(d,g,m){var _,y,E,S,P,B;for(d.scroll==="horizontal"?_=d.panelWidth:_=d.panelHeight,y=Math.ceil(g/_)+5,E=Math.ceil((Math.abs(m)+g)/_)+1,y=E-y,y=y<0?0:y,P=y;P<E&&P<d.panels.length;P++)if(B=d.panels[P],!B.activePanel){var k,M=d.viewer.tileSources[P];M.referenceStripThumbnailUrl?k={type:"image",url:M.referenceStripThumbnailUrl}:k=M,S=new e.Viewer({id:B.id,tileSources:[k],element:B,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[B.id]=S,B.activePanel=!0}}function l(d){var g=d.eventSource.element;this.scroll==="horizontal"?g.style.marginBottom="0px":g.style.marginLeft="0px"}function a(d){var g=d.eventSource.element;this.scroll==="horizontal"?g.style.marginBottom="-"+e.getElementSize(g).y/2+"px":g.style.marginLeft="-"+e.getElementSize(g).x/2+"px"}function h(d){if(!d.ctrl&&!d.alt&&!d.meta)switch(d.keyCode){case 38:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 40:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 37:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 39:o.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:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 45:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 48:case 119:case 87:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 115:case 83:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 97:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 100:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;default:d.preventDefault=!1;break}else d.preventDefault=!1}})(s),(function(e){e.DisplayRect=function(t,i,n,o,u,l){e.Rect.apply(this,[t,i,n,o]),this.minLevel=u,this.maxLevel=l},e.extend(e.DisplayRect.prototype,e.Rect.prototype)})(s),(function(e){e.Spring=function(i){var n=arguments;typeof i!="object"&&(i={initial:n.length&&typeof n[0]=="number"?n[0]:void 0,springStiffness:n.length>1?n[1].springStiffness:5,animationTime:n.length>1?n[1].animationTime:1.5}),e.console.assert(typeof i.springStiffness=="number"&&i.springStiffness!==0,"[OpenSeadragon.Spring] options.springStiffness must be a non-zero number"),e.console.assert(typeof i.animationTime=="number"&&i.animationTime>=0,"[OpenSeadragon.Spring] options.animationTime must be a number greater than or equal to 0"),i.exponential&&(this._exponential=!0,delete i.exponential),e.extend(!0,this,i),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(i){e.console.assert(!this._exponential||i!==0,"[OpenSeadragon.Spring.resetTo] target must be non-zero for exponential springs"),this.start.value=this.target.value=this.current.value=i,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(i){e.console.assert(!this._exponential||i!==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=i,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(i){this.start.value+=i,this.target.value+=i,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(i){this._exponential=i,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 i,n;if(this._exponential?(i=this.start._logValue,n=this.target._logValue):(i=this.start.value,n=this.target.value),this.current.time>=this.target.time)this.current.value=this.target.value;else{let o=i+(n-i)*t(this.springStiffness,(this.current.time-this.start.time)/(this.target.time-this.start.time));this._exponential?this.current.value=Math.exp(o):this.current.value=o}return this.current.value!==this.target.value},isAtTargetValue:function(){return this.current.value===this.target.value}};function t(i,n){return(1-Math.exp(i*-n))/(1-Math.exp(-i))}})(s),(function(e){e.ImageJob=function(i){e.extend(!0,this,{timeout:e.DEFAULT_SETTINGS.timeout,jobId:null,tries:0},i),this.data=null,this.userData={},this.errorMsg=null},e.ImageJob.prototype={start:function(){this.tries++;var i=this,n=this.abort;this.jobId=window.setTimeout(function(){i.finish(null,null,"Image load exceeded timeout ("+i.timeout+" ms)")},this.timeout),this.abort=function(){i.source.downloadTileAbort(i),typeof n=="function"&&n()},this.source.downloadTileStart(this)},finish:function(i,n,o){this.data=i,this.request=n,this.errorMsg=o,this.jobId&&window.clearTimeout(this.jobId),this.callback(this)}},e.ImageLoader=function(i){e.extend(!0,this,{jobLimit:e.DEFAULT_SETTINGS.imageLoaderLimit,timeout:e.DEFAULT_SETTINGS.timeout,jobQueue:[],failedTiles:[],jobsInProgress:0},i)},e.ImageLoader.prototype={addJob:function(i){if(!i.source){e.console.error("ImageLoader.prototype.addJob() requires [options.source]. TileSource since new API defines how images are fetched. Creating a dummy TileSource.");var n=e.TileSource.prototype;i.source={downloadTileStart:n.downloadTileStart,downloadTileAbort:n.downloadTileAbort}}var o=this,u=function(h){t(o,h,i.callback)},l={src:i.src,tile:i.tile||{},source:i.source,loadWithAjax:i.loadWithAjax,ajaxHeaders:i.loadWithAjax?i.ajaxHeaders:null,crossOriginPolicy:i.crossOriginPolicy,ajaxWithCredentials:i.ajaxWithCredentials,postData:i.postData,callback:u,abort:i.abort,timeout:this.timeout},a=new e.ImageJob(l);!this.jobLimit||this.jobsInProgress<this.jobLimit?(a.start(),this.jobsInProgress++):this.jobQueue.push(a)},clear:function(){for(var i=0;i<this.jobQueue.length;i++){var n=this.jobQueue[i];typeof n.abort=="function"&&n.abort()}this.jobQueue=[]}};function t(i,n,o){n.errorMsg!==""&&(n.data===null||n.data===void 0)&&n.tries<1+i.tileRetryMax&&i.failedTiles.push(n);var u;i.jobsInProgress--,(!i.jobLimit||i.jobsInProgress<i.jobLimit)&&i.jobQueue.length>0&&(u=i.jobQueue.shift(),u.start(),i.jobsInProgress++),i.tileRetryMax>0&&i.jobQueue.length===0&&(!i.jobLimit||i.jobsInProgress<i.jobLimit)&&i.failedTiles.length>0&&(u=i.failedTiles.shift(),setTimeout(function(){u.start()},i.tileRetryDelay),i.jobsInProgress++),o(n.data,n.errorMsg,n.request)}})(s),(function(e){e.Tile=function(t,i,n,o,u,l,a,h,c,d,g,m){this.level=t,this.x=i,this.y=n,this.bounds=o,this.positionedBounds=new s.Rect(o.x,o.y,o.width,o.height),this.sourceBounds=d,this.exists=u,this._url=l,this.postData=g,this.context2D=a,this.loadWithAjax=h,this.ajaxHeaders=c,m===void 0&&(e.console.warn("Tile constructor needs 'cacheKey' variable: creation tile cache in Tile class is deprecated. TileSource.prototype.getTileHashKey will be used."),m=e.TileSource.prototype.getTileHashKey(t,i,n,l,c,g)),this.cacheKey=m,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,i,n){var o=Math.max(1,Math.ceil((n.x-i.x)/2)),u=Math.max(1,Math.ceil((n.y-i.y)/2));return new e.Point(o,u).minus(this.position.times(e.pixelDensityRatio).times(t||1).apply(function(l){return l%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}}})(s),(function(e){e.OverlayPlacement=e.Placement,e.OverlayRotationMode=e.freezeObject({NO_ROTATION:1,EXACT:2,BOUNDING_BOX:3}),e.Overlay=function(t,i,n){var o;e.isPlainObject(t)?o=t:o={element:t,location:i,placement:n},this.elementWrapper=document.createElement("div"),this.element=o.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(o)},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,i){var n=e.Placement.properties[this.placement];n&&(n.isHorizontallyCentered?t.x-=i.x/2:n.isRight&&(t.x-=i.x),n.isVerticallyCentered?t.y-=i.y/2:n.isBottom&&(t.y-=i.y))},destroy:function(){var t=this.elementWrapper,i=this.style;t.parentNode&&(t.parentNode.removeChild(t),t.prevElementParent&&(i.display="none",document.body.appendChild(t))),this.onDraw=null,i.top="",i.left="",i.position="",this.width!==null&&(i.width=""),this.height!==null&&(i.height="");var n=e.getCssPropertyWithVendorPrefix("transformOrigin"),o=e.getCssPropertyWithVendorPrefix("transform");n&&o&&(i[n]="",i[o]="")},drawHTML:function(t,i){var n=this.elementWrapper;n.parentNode!==t&&(n.prevElementParent=n.parentNode,n.prevNextSibling=n.nextSibling,t.appendChild(n),this.style.position="absolute",this.size=e.getElementSize(this.elementWrapper));var o=this._getOverlayPositionAndSize(i),u=o.position,l=this.size=o.size,a="";i.overlayPreserveContentDirection&&(a=i.flipped?" scaleX(-1)":" scaleX(1)");var h=i.flipped?-o.rotate:o.rotate,c=i.flipped?" scaleX(-1)":"";if(this.onDraw)this.onDraw(u,l,this.element);else{var d=this.style,g=this.element.style;g.display="block",d.left=u.x+"px",d.top=u.y+"px",this.width!==null&&(g.width=l.x+"px"),this.height!==null&&(g.height=l.y+"px");var m=e.getCssPropertyWithVendorPrefix("transformOrigin"),_=e.getCssPropertyWithVendorPrefix("transform");m&&_&&(h&&!i.flipped?(g[_]="",d[m]=this._getTransformOrigin(),d[_]="rotate("+h+"deg)"):!h&&i.flipped?(g[_]=a,d[m]=this._getTransformOrigin(),d[_]=c):h&&i.flipped?(g[_]=a,d[m]=this._getTransformOrigin(),d[_]="rotate("+h+"deg)"+c):(g[_]="",d[m]="",d[_]="")),d.display="flex"}},_getOverlayPositionAndSize:function(t){var i=t.pixelFromPoint(this.location,!0),n=this._getSizeInPixels(t);this.adjust(i,n);var o=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 u=new e.Rect(i.x,i.y,n.x,n.y),l=this._getBoundingBox(u,t.getRotation(!0));i=l.getTopLeft(),n=l.getSize()}else o=t.getRotation(!0);return t.flipped&&(i.x=t.getContainerSize().x-i.x),{position:i,size:n,rotate:o}},_getSizeInPixels:function(t){var i=this.size.x,n=this.size.y;if(this.width!==null||this.height!==null){var o=t.deltaPixelsFromPointsNoRotate(new e.Point(this.width||0,this.height||0),!0);this.width!==null&&(i=o.x),this.height!==null&&(n=o.y)}if(this.checkResize&&(this.width===null||this.height===null)){var u=this.size=e.getElementSize(this.elementWrapper);this.width===null&&(i=u.x),this.height===null&&(n=u.y)}return new e.Point(i,n)},_getBoundingBox:function(t,i){var n=this._getPlacementPoint(t);return t.rotate(i,n).getBoundingBox()},_getPlacementPoint:function(t){var i=new e.Point(t.x,t.y),n=e.Placement.properties[this.placement];return n&&(n.isHorizontallyCentered?i.x+=t.width/2:n.isRight&&(i.x+=t.width),n.isVerticallyCentered?i.y+=t.height/2:n.isBottom&&(i.y+=t.height)),i},_getTransformOrigin:function(){var t="",i=e.Placement.properties[this.placement];return i&&(i.isLeft?t="left":i.isRight&&(t="right"),i.isTop?t+=" top":i.isBottom&&(t+=" bottom")),t},update:function(t,i){var n=e.isPlainObject(t)?t:{location:t,placement:i};this._init({location:n.location||this.location,placement:n.placement!==void 0?n.placement:this.placement,onDraw:n.onDraw||this.onDraw,checkResize:n.checkResize||this.checkResize,width:n.width!==void 0?n.width:this.width,height:n.height!==void 0?n.height:this.height,rotationMode:n.rotationMode||this.rotationMode})},getBounds:function(t){e.console.assert(t,"A viewport must now be passed to Overlay.getBounds.");var i=this.width,n=this.height;if(i===null||n===null){var o=t.deltaPointsFromPixelsNoRotate(this.size,!0);i===null&&(i=o.x),n===null&&(n=o.y)}var u=this.location.clone();return this.adjust(u,new e.Point(i,n)),this._adjustBoundsForRotation(t,new e.Rect(u.x,u.y,i,n))},_adjustBoundsForRotation:function(t,i){if(!t||t.getRotation(!0)===0||this.rotationMode===e.OverlayRotationMode.EXACT)return i;if(this.rotationMode===e.OverlayRotationMode.BOUNDING_BOX){if(this.width===null||this.height===null)return i;var n=this._getOverlayPositionAndSize(t);return t.viewerElementToViewportRectangle(new e.Rect(n.position.x,n.position.y,n.size.x,n.size.y))}return i.rotate(-t.getRotation(!0),this._getPlacementPoint(i))}}})(s),(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 n=this.viewport.pixelFromPointNoRotate(i.getTopLeft(),!0),o=this.viewport.deltaPixelsFromPointsNoRotate(i.getSize(),!0);return new e.Rect(n.x*e.pixelDensityRatio,n.y*e.pixelDensityRatio,o.x*e.pixelDensityRatio,o.y*e.pixelDensityRatio)}viewportCoordToDrawerCoord(i){var n=this.viewport.pixelFromPointNoRotate(i,!0);return new e.Point(n.x*e.pixelDensityRatio,n.y*e.pixelDensityRatio)}_calculateCanvasSize(){var i=e.pixelDensityRatio,n=this.viewport.getContainerSize();return new t.Point(Math.round(n.x*i),Math.round(n.y*i))}_raiseTiledImageDrawnEvent(i,n){this.viewer&&this.viewer.raiseEvent("tiled-image-drawn",{tiledImage:i,tiles:n})}_raiseDrawerErrorEvent(i,n){this.viewer&&this.viewer.raiseEvent("drawer-error",{tiledImage:i,drawer:this,error:n})}}})(s),(function(e){const t=e;class i extends t.DrawerBase{constructor(o){super(o),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(o){return!0}_createDrawingElement(){return e.makeNeutralElement("div")}draw(o){var u=this;this._prepareNewFrame(),o.forEach(function(l){l.opacity!==0&&u._drawTiles(l)})}canRotate(){return!1}destroy(){this.container.removeChild(this.canvas)}setImageSmoothingEnabled(){}_prepareNewFrame(){this.canvas.innerHTML=""}_drawTiles(o){var u=o.getTilesToDraw().map(h=>h.tile);if(!(o.opacity===0||u.length===0&&!o.placeholderFillStyle))for(var l=u.length-1;l>=0;l--){var a=u[l];this._drawTile(a),this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:o,tile:a})}}_drawTile(o){e.console.assert(o,"[Drawer._drawTile] tile is required");let u=this.canvas;if(!o.cacheImageRecord){e.console.warn("[Drawer._drawTileToHTML] attempting to draw tile %s when it's not cached",o.toString());return}if(!o.loaded){e.console.warn("Attempting to draw tile %s when it's not yet loaded.",o.toString());return}if(!o.element){var l=o.getImage();if(!l)return;o.element=e.makeNeutralElement("div"),o.imgElement=l.cloneNode(),o.imgElement.style.msInterpolationMode="nearest-neighbor",o.imgElement.style.width="100%",o.imgElement.style.height="100%",o.style=o.element.style,o.style.position="absolute"}o.element.parentNode!==u&&u.appendChild(o.element),o.imgElement.parentNode!==o.element&&o.element.appendChild(o.imgElement),o.style.top=o.position.y+"px",o.style.left=o.position.x+"px",o.style.height=o.size.y+"px",o.style.width=o.size.x+"px",o.flipped&&(o.style.transform="scaleX(-1)"),e.setElementOpacity(o.element,o.opacity)}}e.HTMLDrawer=i})(s),(function(e){const t=e;class i 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,g){this.viewer.raiseEvent("tile-drawing",{tiledImage:h,context:c,tile:d,rendered:g})}_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 g=d.canvas;d.clearRect(0,0,g.width,g.height)}}_drawTiles(h){var c=h.getTilesToDraw().map(V=>V.tile);if(!(h.opacity===0||c.length===0&&!h.placeholderFillStyle)){var d=c[0],g;d&&(g=h.opacity<1||h.compositeOperation&&h.compositeOperation!=="source-over"||!h._isBottomItem()&&h.source.hasTransparency(d.context2D,d.getUrl(),d.ajaxHeaders,d.postData));var m,_,y=this.viewport.getZoom(!0),E=h.viewportToImageZoom(y);c.length>1&&E>h.smoothTileEdgesMinZoom&&!h.iOSDevice&&h.getRotation(!0)%360===0&&(g=!0,m=d.getScaleForEdgeSmoothing(),_=d.getTranslationForEdgeSmoothing(m,this._getCanvasSize(!1),this._getCanvasSize(!0)));var S;g&&(m||(S=this.viewport.viewportToViewerElementRectangle(h.getClippedBounds(!0)).getIntegerBoundingBox(),S=S.times(e.pixelDensityRatio)),this._clear(!0,S)),m||this._setRotations(h,g);var P=!1;if(h._clip){this._saveContext(g);var B=h.imageToViewportRectangle(h._clip,!0);B=B.rotate(-h.getRotation(!0),h._getRotationPoint(!0));var k=this.viewportToDrawerRectangle(B);m&&(k=k.times(m)),_&&(k=k.translate(_)),this._setClip(k,g),P=!0}if(h._croppingPolygons){var M=this;P||this._saveContext(g);try{var L=h._croppingPolygons.map(function(V){return V.map(function(re){var he=h.imageToViewportCoordinates(re.x,re.y,!0).rotate(-h.getRotation(!0),h._getRotationPoint(!0)),de=M.viewportCoordToDrawerCoord(he);return m&&(de=de.times(m)),_&&(de=de.plus(_)),de})});this._clipWithPolygons(L,g)}catch(V){e.console.error(V)}P=!0}if(h._hasOpaqueTile=!1,h.placeholderFillStyle&&h._hasOpaqueTile===!1){let V=this.viewportToDrawerRectangle(h.getBoundsNoRotate(!0));m&&(V=V.times(m)),_&&(V=V.translate(_));let re=null;typeof h.placeholderFillStyle=="function"?re=h.placeholderFillStyle(h,this.context):re=h.placeholderFillStyle,this._drawRectangle(V,re,g)}var W=l(h.subPixelRoundingForTransparency),$=!1;if(W===e.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS)$=!0;else if(W===e.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST){var Q=this.viewer&&this.viewer.isAnimating();$=!Q}for(var q=0;q<c.length;q++)d=c[q],this._drawTile(d,h,g,m,_,$,h.source),this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:h,tile:d});P&&this._restoreContext(g),m||(h.getRotation(!0)%360!==0&&this._restoreRotationChanges(g),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(g)),g&&(m&&this._setRotations(h),this.blendSketch({opacity:h.opacity,scale:m,translate:_,compositeOperation:h.compositeOperation,bounds:S}),m&&(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 g=c[d];try{this._drawDebugInfoOnTile(g,c.length,d,h)}catch(m){e.console.error(m)}}}_clipWithPolygons(h,c){var d=this._getContext(c);d.beginPath();for(const g of h)for(const[m,_]of g.entries())d[m===0?"moveTo":"lineTo"](_.x,_.y);d.clip()}_drawTile(h,c,d,g,m,_,y){e.console.assert(h,"[Drawer._drawTile] tile is required"),e.console.assert(c,"[Drawer._drawTile] drawingHandler is required");var E=this._getContext(d);g=g||1,this._drawTileToCanvas(h,E,c,g,m,_,y)}_drawTileToCanvas(h,c,d,g,m,_,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 g=="number"&&g!==1&&(E=E.times(g),S=S.times(g)),m instanceof e.Point&&(E=E.plus(m)),c.globalAlpha===1&&h.hasTransparency&&(_&&(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 B,k;h.sourceBounds?(B=Math.min(h.sourceBounds.width,P.canvas.width),k=Math.min(h.sourceBounds.height,P.canvas.height)):(B=P.canvas.width,k=P.canvas.height),c.translate(E.x+S.x/2,0),h.flipped&&c.scale(-1,1),c.drawImage(P.canvas,0,0,B,k,-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 g=this;this.viewer.addHandler("rotate",function m(){if(g.viewport.getRotation()!==0){g.viewer.removeHandler("rotate",m);var _=g._calculateSketchCanvasSize();g.sketchCanvas.width=_.x,g.sketchCanvas.height=_.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 g=this._getContext(d);g.save(),g.fillStyle=c,g.fillRect(h.x,h.y,h.width,h.height),g.restore()}blendSketch(h,c,d,g){var m=h;e.isPlainObject(m)||(m={opacity:h,scale:c,translate:d,compositeOperation:g}),h=m.opacity,g=m.compositeOperation;var _=m.bounds;if(this.context.save(),this.context.globalAlpha=h,g&&(this.context.globalCompositeOperation=g),_)_.x<0&&(_.width+=_.x,_.x=0),_.x+_.width>this.canvas.width&&(_.width=this.canvas.width-_.x),_.y<0&&(_.height+=_.y,_.y=0),_.y+_.height>this.canvas.height&&(_.height=this.canvas.height-_.y),this.context.drawImage(this.sketchCanvas,_.x,_.y,_.width,_.height,_.x,_.y,_.width,_.height);else{c=m.scale||1,d=m.translate;var y=d instanceof e.Point?d:new e.Point(0,0),E=0,S=0;if(d){var P=this.sketchCanvas.width-this.canvas.width,B=this.sketchCanvas.height-this.canvas.height;E=Math.round(P/2),S=Math.round(B/2)}this.context.drawImage(this.sketchCanvas,y.x-E*c,y.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,g){var m=this.viewer.world.getIndexOfItem(g)%this.debugGridColor.length,_=this.context;_.save(),_.lineWidth=2*e.pixelDensityRatio,_.font="small-caps bold "+13*e.pixelDensityRatio+"px arial",_.strokeStyle=this.debugGridColor[m],_.fillStyle=this.debugGridColor[m],this._setRotations(g),this._viewportFlipped&&this._flip({point:h.position.plus(h.size.divide(2))}),_.strokeRect(h.position.x*e.pixelDensityRatio,h.position.y*e.pixelDensityRatio,h.size.x*e.pixelDensityRatio,h.size.y*e.pixelDensityRatio);var y=(h.position.x+h.size.x/2)*e.pixelDensityRatio,E=(h.position.y+h.size.y/2)*e.pixelDensityRatio;_.translate(y,E);const S=this.viewport.getRotation(!0);_.rotate(Math.PI/180*-S),_.translate(-y,-E),h.x===0&&h.y===0&&(_.fillText("Zoom: "+this.viewport.getZoom(),h.position.x*e.pixelDensityRatio,(h.position.y-30)*e.pixelDensityRatio),_.fillText("Pan: "+this.viewport.getBounds().toString(),h.position.x*e.pixelDensityRatio,(h.position.y-20)*e.pixelDensityRatio)),_.fillText("Level: "+h.level,(h.position.x+10)*e.pixelDensityRatio,(h.position.y+20)*e.pixelDensityRatio),_.fillText("Column: "+h.x,(h.position.x+10)*e.pixelDensityRatio,(h.position.y+30)*e.pixelDensityRatio),_.fillText("Row: "+h.y,(h.position.x+10)*e.pixelDensityRatio,(h.position.y+40)*e.pixelDensityRatio),_.fillText("Order: "+d+" of "+c,(h.position.x+10)*e.pixelDensityRatio,(h.position.y+50)*e.pixelDensityRatio),_.fillText("Size: "+h.size.toString(),(h.position.x+10)*e.pixelDensityRatio,(h.position.y+60)*e.pixelDensityRatio),_.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(),g.getRotation(!0)%360!==0&&this._restoreRotationChanges(),_.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=i;var n=e.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER;function o(a){return a!==e.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS&&a!==e.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST&&a!==e.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER}function u(a){return o(a)?n:a}function l(a){if(typeof a=="number")return u(a);if(!a||!e.Browser)return n;var h=a[e.Browser.vendor];return o(h)&&(h=a["*"]),u(h)}})(s),(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=n=>this._tileReadyHandler(n),this._boundToImageUnloaded=n=>this._imageUnloadedHandler(n),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 n=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS);for(let u=0;u<n;++u)i.activeTexture(i.TEXTURE0+u),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 o=i.getExtension("WEBGL_lose_context");o&&o.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"),n=e.isFunction(i.getContext)&&i.getContext("webgl"),o=n&&n.getExtension("WEBGL_lose_context");return o&&o.loseContext(),!!n}getType(){return"webgl"}minimumOverlapRequired(i){return i.isTainted()}_createDrawingElement(){let i=e.makeNeutralElement("canvas"),n=this._calculateCanvasSize();return i.width=n.x,i.height=n.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 n=this._gl;const o=this.viewport.getBoundsNoRotateWithMargins(!0);let u={bounds:o,center:new t.Point(o.x+o.width/2,o.y+o.height/2),rotation:this.viewport.getRotation(!0)*Math.PI/180},l=this.viewport.flipped?-1:1,a=e.Mat3.makeTranslation(-u.center.x,-u.center.y),h=e.Mat3.makeScaling(2/u.bounds.width*l,-2/u.bounds.height),c=e.Mat3.makeRotation(-u.rotation),d=h.multiply(c).multiply(a);n.bindFramebuffer(n.FRAMEBUFFER,null),n.clear(n.COLOR_BUFFER_BIT),this._outputContext.clearRect(0,0,this._outputCanvas.width,this._outputCanvas.height);let g=!1;i.forEach((m,_)=>{if(m.isTainted()){g&&(this._outputContext.drawImage(this._renderingCanvas,0,0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.clear(n.COLOR_BUFFER_BIT),g=!1);const y=this._getBackupCanvasDrawer();y.draw([m]),this._outputContext.drawImage(y.canvas,0,0)}else{let y=m.getTilesToDraw();if(m.placeholderFillStyle&&m._hasOpaqueTile===!1&&this._drawPlaceholder(m),y.length===0||m.getOpacity()===0)return;let E=y[0],S=m.compositeOperation||this.viewer.compositeOperation||m._clip||m._croppingPolygons||m.debugMode,P=S||m.opacity<1||E.hasTransparency;S&&(g&&this._outputContext.drawImage(this._renderingCanvas,0,0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.clear(n.COLOR_BUFFER_BIT)),n.useProgram(this._firstPass.shaderProgram),P?(n.bindFramebuffer(n.FRAMEBUFFER,this._glFrameBuffer),n.clear(n.COLOR_BUFFER_BIT)):n.bindFramebuffer(n.FRAMEBUFFER,null);let B=d,k=m.getRotation(!0);if(k%360!==0){let q=e.Mat3.makeRotation(-k*Math.PI/180),V=m.getBoundsNoRotate(!0).getCenter(),re=e.Mat3.makeTranslation(V.x,V.y),he=e.Mat3.makeTranslation(-V.x,-V.y),de=re.multiply(q).multiply(he);B=d.multiply(de)}let M=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);if(M<=0)throw new Error(`WegGL error: bad value for gl parameter MAX_TEXTURE_IMAGE_UNITS (${M}). This could happen
|
|
128
|
-
if too many contexts have been created and not released, or there is another problem with the graphics card.`);let L=new Float32Array(M*12),W=new Array(M),$=new Array(M),Q=new Array(M);for(let q=0;q<y.length;q++){let V=y[q].tile,re=q%M,he=re+1,de=V.getCanvasContext(),pe=de?this._TextureMap.get(de.canvas):null;if(pe||(this._tileReadyHandler({tile:V,tiledImage:m}),pe=de?this._TextureMap.get(de.canvas):null),pe&&this._getTileData(V,m,pe,B,re,L,W,$,Q),he===M||q===y.length-1){for(let ge=0;ge<=he;ge++)n.activeTexture(n.TEXTURE0+ge),n.bindTexture(n.TEXTURE_2D,W[ge]);n.bindBuffer(n.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),n.bufferData(n.ARRAY_BUFFER,L,n.DYNAMIC_DRAW),$.forEach((ge,me)=>{n.uniformMatrix3fv(this._firstPass.uTransformMatrices[me],!1,ge)}),n.uniform1fv(this._firstPass.uOpacities,new Float32Array(Q)),n.bindBuffer(n.ARRAY_BUFFER,this._firstPass.bufferOutputPosition),n.vertexAttribPointer(this._firstPass.aOutputPosition,2,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),n.vertexAttribPointer(this._firstPass.aTexturePosition,2,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._firstPass.bufferIndex),n.vertexAttribPointer(this._firstPass.aIndex,1,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,6*he)}}P&&(n.useProgram(this._secondPass.shaderProgram),n.bindFramebuffer(n.FRAMEBUFFER,null),n.activeTexture(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,this._renderToTexture),this._gl.uniform1f(this._secondPass.uOpacityMultiplier,m.opacity),n.bindBuffer(n.ARRAY_BUFFER,this._secondPass.bufferTexturePosition),n.vertexAttribPointer(this._secondPass.aTexturePosition,2,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,this._secondPass.bufferOutputPosition),n.vertexAttribPointer(this._secondPass.aOutputPosition,2,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,6)),g=!0,S&&(this._applyContext2dPipeline(m,y,_),g=!1,n.bindFramebuffer(n.FRAMEBUFFER,null),n.clear(n.COLOR_BUFFER_BIT)),_===0&&this._raiseTiledImageDrawnEvent(m,y.map(q=>q.tile))}}),g&&this._outputContext.drawImage(this._renderingCanvas,0,0)}setImageSmoothingEnabled(i){this._imageSmoothingEnabled!==i&&(this._imageSmoothingEnabled=i,this._unloadTextures(),this.viewer.world.draw())}drawDebuggingRect(i){let n=this._outputContext;n.save(),n.lineWidth=2*e.pixelDensityRatio,n.strokeStyle=this.debugGridColor[0],n.fillStyle=this.debugGridColor[0],n.strokeRect(i.x*e.pixelDensityRatio,i.y*e.pixelDensityRatio,i.width*e.pixelDensityRatio,i.height*e.pixelDensityRatio),n.restore()}_getTextureDataFromTile(i){return i.getCanvasContext().canvas}_applyContext2dPipeline(i,n,o){if(this._outputContext.save(),this._outputContext.globalCompositeOperation=o===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 u=this.viewer.viewport.getFlip();u&&this._flip(),this._drawDebugInfo(n,i,u),u&&this._flip()}}_getTileData(i,n,o,u,l,a,h,c,d){let g=o.texture,m=o.position;a.set(m,l*12);let _=this._calculateOverlapFraction(i,n),y=i.positionedBounds.width*_.x,E=i.positionedBounds.height*_.y,S=i.positionedBounds.x+(i.x===0?0:y),P=i.positionedBounds.y+(i.y===0?0:E),B=i.positionedBounds.x+i.positionedBounds.width-(i.isRightMost?0:y),k=i.positionedBounds.y+i.positionedBounds.height-(i.isBottomMost?0:E),M=B-S,L=k-P,W=new e.Mat3([M,0,0,0,L,0,S,P,1]);if(i.flipped){let Q=e.Mat3.makeTranslation(.5,0),q=e.Mat3.makeTranslation(-.5,0),V=Q.multiply(e.Mat3.makeScaling(-1,1)).multiply(q);W=W.multiply(V)}let $=u.multiply(W);d[l]=i.opacity,h[l]=g,c[l]=$.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),n=()=>[...Array(i).keys()].map(g=>`uniform mat3 u_matrix_${g};`).join(`
|
|
129
|
-
`),o=()=>[...Array(i).keys()].map(g=>`${g>0?"else ":""}if(int(a_index) == ${g}) { transform_matrix = u_matrix_${g}; }`).join(`
|
|
130
|
-
`);const u=`
|
|
131
|
-
attribute vec2 a_output_position;
|
|
132
|
-
attribute vec2 a_texture_position;
|
|
133
|
-
attribute float a_index;
|
|
134
|
-
|
|
135
|
-
${n()} // 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
|
-
${o()}
|
|
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
|
-
`,l=`
|
|
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 a=this._gl,h=this.constructor.initShaderProgram(a,u,l);a.useProgram(h),this._firstPass={shaderProgram:h,aOutputPosition:a.getAttribLocation(h,"a_output_position"),aTexturePosition:a.getAttribLocation(h,"a_texture_position"),aIndex:a.getAttribLocation(h,"a_index"),uTransformMatrices:[...Array(this._glNumTextures).keys()].map(g=>a.getUniformLocation(h,`u_matrix_${g}`)),uImages:a.getUniformLocation(h,"u_images"),uOpacities:a.getUniformLocation(h,"u_opacities"),bufferOutputPosition:a.createBuffer(),bufferTexturePosition:a.createBuffer(),bufferIndex:a.createBuffer()},a.uniform1iv(this._firstPass.uImages,[...Array(i).keys()]);let c=new Float32Array(i*12);for(let g=0;g<i;++g)c.set(Float32Array.from(this._unitQuad),g*12);a.bindBuffer(a.ARRAY_BUFFER,this._firstPass.bufferOutputPosition),a.bufferData(a.ARRAY_BUFFER,c,a.STATIC_DRAW),a.enableVertexAttribArray(this._firstPass.aOutputPosition),a.bindBuffer(a.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),a.enableVertexAttribArray(this._firstPass.aTexturePosition),a.bindBuffer(a.ARRAY_BUFFER,this._firstPass.bufferIndex);let d=[...Array(this._glNumTextures).keys()].map(g=>Array(6).fill(g)).flat();a.bufferData(a.ARRAY_BUFFER,new Float32Array(d),a.STATIC_DRAW),a.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
|
-
`,n=`
|
|
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 o=this._gl,u=this.constructor.initShaderProgram(o,i,n);o.useProgram(u),this._secondPass={shaderProgram:u,aOutputPosition:o.getAttribLocation(u,"a_output_position"),aTexturePosition:o.getAttribLocation(u,"a_texture_position"),uMatrix:o.getUniformLocation(u,"u_matrix"),uImage:o.getUniformLocation(u,"u_image"),uOpacityMultiplier:o.getUniformLocation(u,"u_opacity_multiplier"),bufferOutputPosition:o.createBuffer(),bufferTexturePosition:o.createBuffer()},o.bindBuffer(o.ARRAY_BUFFER,this._secondPass.bufferOutputPosition),o.bufferData(o.ARRAY_BUFFER,this._unitQuad,o.STATIC_DRAW),o.enableVertexAttribArray(this._secondPass.aOutputPosition),o.bindBuffer(o.ARRAY_BUFFER,this._secondPass.bufferTexturePosition),o.bufferData(o.ARRAY_BUFFER,this._unitQuad,o.DYNAMIC_DRAW),o.enableVertexAttribArray(this._secondPass.aTexturePosition);let l=e.Mat3.makeScaling(2,2).multiply(e.Mat3.makeTranslation(-.5,-.5));o.uniformMatrix3fv(this._secondPass.uMatrix,!1,l.values)}_resizeRenderer(){let i=this._gl,n=this._renderingCanvas.width,o=this._renderingCanvas.height;i.viewport(0,0,n,o),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,n,o,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 n=i._calculateCanvasSize();(i._outputCanvas.width!==n.x||i._outputCanvas.height!==n.y)&&(i._outputCanvas.width=n.x,i._outputCanvas.height=n.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,n,o,u){return new Float32Array([i,u,n,u,i,o,i,o,n,u,n,o])}_tileReadyHandler(i){let n=i.tile,o=i.tiledImage;if(o.isTainted())return;let u=n.getCanvasContext(),l=u&&u.canvas;if(!l||e.isCanvasTainted(l)){o.isTainted()||(o.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(o,"Tainted data cannot be used by the WebGLDrawer. Falling back to CanvasDrawer for this TiledImage."));return}if(!this._TextureMap.get(l)){let a=this._gl,h=a.createTexture(),c,d=o.source.tileOverlap,g,m;if(n.sourceBounds?(g=Math.min(n.sourceBounds.width,l.width)/l.width,m=Math.min(n.sourceBounds.height,l.height)/l.height):(g=1,m=1),d>0){let y=this._calculateOverlapFraction(n,o),E=(n.x===0?0:y.x)*g,S=(n.y===0?0:y.y)*m,P=(n.isRightMost?1:1-y.x)*g,B=(n.isBottomMost?1:1-y.y)*m;c=this._makeQuadVertexBuffer(E,P,S,B)}else g===1&&m===1?c=this._unitQuad:c=this._makeQuadVertexBuffer(0,g,0,m);let _={texture:h,position:c};this._TextureMap.set(l,_),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,h),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,this._textureFilter()),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,this._textureFilter()),this._uploadImageData(u)}}_calculateOverlapFraction(i,n){let o=n.source.tileOverlap,u=i.sourceBounds.width,l=i.sourceBounds.height,a=(i.x===0?0:o)+(i.isRightMost?0:o),h=(i.y===0?0:o)+(i.isBottomMost?0:o),c=o/(u+a),d=o/(l+h);return{x:c,y:d}}_unloadTextures(){Array.from(this._TextureMap.keys()).forEach(i=>{this._cleanupImageData(i)})}_uploadImageData(i){let n=this._gl,o=i.canvas;try{if(!o)throw i;n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,o)}catch(u){e.console.error("Error uploading image data to WebGL",u)}}_imageUnloadedHandler(i){let n=i.context2D.canvas;this._cleanupImageData(n)}_cleanupImageData(i){let n=this._TextureMap.get(i);this._TextureMap.delete(i),n&&this._gl.deleteTexture(n.texture)}_setClip(){}_renderToClippingCanvas(i){if(this._clippingContext.clearRect(0,0,this._clippingCanvas.width,this._clippingCanvas.height),this._clippingContext.save(),this.viewer.viewport.getFlip()){const n=new e.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(n.x,0),this._clippingContext.scale(-1,1),this._clippingContext.translate(-n.x,0)}if(i._clip){let n=[{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(o=>{let u=i.imageToViewportCoordinates(o.x,o.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(u)});this._clippingContext.beginPath(),n.forEach((o,u)=>{this._clippingContext[u===0?"moveTo":"lineTo"](o.x,o.y)}),this._clippingContext.clip(),this._setClip()}if(i._croppingPolygons){let n=i._croppingPolygons.map(o=>o.map(u=>{let l=i.imageToViewportCoordinates(u.x,u.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(l)}));this._clippingContext.beginPath(),n.forEach(o=>{o.forEach((u,l)=>{this._clippingContext[l===0?"moveTo":"lineTo"](u.x,u.y)})}),this._clippingContext.clip()}if(this.viewer.viewport.getFlip()){const n=new e.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(n.x,0),this._clippingContext.scale(-1,1),this._clippingContext.translate(-n.x,0)}this._clippingContext.drawImage(this._renderingCanvas,0,0),this._clippingContext.restore()}_setRotations(i){var n=!1;this.viewport.getRotation(!0)%360!==0&&(this._offsetForRotation({degrees:this.viewport.getRotation(!0),saveContext:n}),n=!1),i.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:i.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(i._getRotationPoint(!0),!0),saveContext:n})}_offsetForRotation(i){var n=i.point?i.point.times(e.pixelDensityRatio):this._getCanvasCenter(),o=this._outputContext;o.save(),o.translate(n.x,n.y),o.rotate(Math.PI/180*i.degrees),o.translate(-n.x,-n.y)}_flip(i){i=i||{};var n=i.point?i.point.times(e.pixelDensityRatio):this._getCanvasCenter(),o=this._outputContext;o.translate(n.x,0),o.scale(-1,1),o.translate(-n.x,0)}_drawDebugInfo(i,n,o){for(var u=i.length-1;u>=0;u--){var l=i[u].tile;try{this._drawDebugInfoOnTile(l,i.length,u,n,o)}catch(a){e.console.error(a)}}}_drawDebugInfoOnTile(i,n,o,u,l){var a=this.viewer.world.getIndexOfItem(u)%this.debugGridColor.length,h=this.context;h.save(),h.lineWidth=2*e.pixelDensityRatio,h.font="small-caps bold "+13*e.pixelDensityRatio+"px arial",h.strokeStyle=this.debugGridColor[a],h.fillStyle=this.debugGridColor[a],this._setRotations(u),l&&this._flip({point:i.position.plus(i.size.divide(2))}),h.strokeRect(i.position.x*e.pixelDensityRatio,i.position.y*e.pixelDensityRatio,i.size.x*e.pixelDensityRatio,i.size.y*e.pixelDensityRatio);var c=(i.position.x+i.size.x/2)*e.pixelDensityRatio,d=(i.position.y+i.size.y/2)*e.pixelDensityRatio;h.translate(c,d);const g=this.viewport.getRotation(!0);h.rotate(Math.PI/180*-g),h.translate(-c,-d),i.x===0&&i.y===0&&(h.fillText("Zoom: "+this.viewport.getZoom(),i.position.x*e.pixelDensityRatio,(i.position.y-30)*e.pixelDensityRatio),h.fillText("Pan: "+this.viewport.getBounds().toString(),i.position.x*e.pixelDensityRatio,(i.position.y-20)*e.pixelDensityRatio)),h.fillText("Level: "+i.level,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+20)*e.pixelDensityRatio),h.fillText("Column: "+i.x,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+30)*e.pixelDensityRatio),h.fillText("Row: "+i.y,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+40)*e.pixelDensityRatio),h.fillText("Order: "+o+" of "+n,(i.position.x+10)*e.pixelDensityRatio,(i.position.y+50)*e.pixelDensityRatio),h.fillText("Size: "+i.size.toString(),(i.position.x+10)*e.pixelDensityRatio,(i.position.y+60)*e.pixelDensityRatio),h.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(),u.getRotation(!0)%360!==0&&this._restoreRotationChanges(),h.restore()}_drawPlaceholder(i){const n=i.getBounds(!0),o=this.viewportToDrawerRectangle(i.getBounds(!0)),u=this._outputContext;let l;typeof i.placeholderFillStyle=="function"?l=i.placeholderFillStyle(i,u):l=i.placeholderFillStyle,this._offsetForRotation({degrees:this.viewer.viewport.getRotation(!0)}),u.fillStyle=l,u.translate(o.x,o.y),u.rotate(Math.PI/180*n.degrees),u.translate(-o.x,-o.y),u.fillRect(o.x,o.y,o.width,o.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,n,o){function u(c,d,g){const m=c.createShader(d);return c.shaderSource(m,g),c.compileShader(m),c.getShaderParameter(m,c.COMPILE_STATUS)?m:(e.console.error(`An error occurred compiling the shaders: ${c.getShaderInfoLog(m)}`),c.deleteShader(m),null)}const l=u(i,i.VERTEX_SHADER,n),a=u(i,i.FRAGMENT_SHADER,o),h=i.createProgram();return i.attachShader(h,l),i.attachShader(h,a),i.linkProgram(h),i.getProgramParameter(h,i.LINK_STATUS)?h:(e.console.error(`Unable to initialize the shader program: ${i.getProgramInfoLog(h)}`),null)}}})(s),(function(e){e.Viewport=function(t){var i=arguments;i.length&&i[0]instanceof e.Point&&(t={containerSize:i[0],contentSize:i[1],config:i[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,i){e.console.error("[Viewport.setHomeBounds] this function is deprecated; The content bounds should not be set manually."),this._setContentBounds(t,i)},_setContentBounds:function(t,i){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(i),this._contentBounds=t.rotate(this.getRotation()).getBoundingBox(),this._contentSize=this._contentBounds.getSize().times(i),this._contentAspectRatio=this._contentSize.x/this._contentSize.y,this.viewer&&this.viewer.raiseEvent("reset-size",{contentSize:this._contentSizeNoRotate.clone(),contentFactor:i,homeBounds:this._contentBoundsNoRotate.clone(),contentBounds:this._contentBounds.clone()})},getHomeZoom:function(){if(this.defaultZoomLevel)return this.defaultZoomLevel;var t=this._contentAspectRatio/this.getAspectRatio(),i;return this.homeFillsViewer?i=t>=1?t:1:i=t>=1?1:t,i/this._contentBounds.width},getHomeBounds:function(){return this.getHomeBoundsNoRotate().rotate(-this.getRotation())},getHomeBoundsNoRotate:function(){var t=this._contentBounds.getCenter(),i=1/this.getHomeZoom(),n=i/this.getAspectRatio();return new e.Rect(t.x-i/2,t.y-n/2,i,n)},goHome:function(t){return this.viewer&&this.viewer.raiseEvent("home",{immediately:t}),this.fitBounds(this.getHomeBounds(),t)},getMinZoom:function(){var t=this.getHomeZoom(),i=this.minZoomLevel?this.minZoomLevel:this.minZoomImageRatio*t;return i},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 i=this.getCenter(t),n=1/this.getZoom(t),o=n/this.getAspectRatio();return new e.Rect(i.x-n/2,i.y-o/2,n,o)},getBoundsWithMargins:function(t){return this.getBoundsNoRotateWithMargins(t).rotate(-this.getRotation(t),this.getCenter(t))},getBoundsNoRotateWithMargins:function(t){var i=this.getBoundsNoRotate(t),n=this._containerInnerSize.x*this.getZoom(t);return i.x-=this._margins.left/n,i.y-=this._margins.top/n,i.width+=(this._margins.left+this._margins.right)/n,i.height+=(this._margins.top+this._margins.bottom)/n,i},getCenter:function(t){var i=new e.Point(this.centerSpringX.current.value,this.centerSpringY.current.value),n=new e.Point(this.centerSpringX.target.value,this.centerSpringY.target.value),o,u,l,a,h,c,d,g;return t?i:this.zoomPoint?(o=this.pixelFromPoint(this.zoomPoint,!0),u=this.getZoom(),l=1/u,a=l/this.getAspectRatio(),h=new e.Rect(i.x-l/2,i.y-a/2,l,a),c=this._pixelFromPoint(this.zoomPoint,h),d=c.minus(o).rotate(-this.getRotation(!0)),g=d.divide(this._containerInnerSize.x*u),n.plus(g)):n},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 i=this.viewportToViewerElementRectangle(t).getBoundingBox(),n=this.viewportToViewerElementRectangle(this._contentBoundsNoRotate).getBoundingBox(),o=!1,u=!1;if(!this.wrapHorizontal){var l=i.x+i.width,a=n.x+n.width,h,c,d;i.width>n.width?h=this.visibilityRatio*n.width:h=this.visibilityRatio*i.width,c=n.x-l+h,d=a-i.x-h,h>n.width?(i.x+=(c+d)/2,o=!0):d<0?(i.x+=d,o=!0):c>0&&(i.x+=c,o=!0)}if(!this.wrapVertical){var g=i.y+i.height,m=n.y+n.height,_,y,E;i.height>n.height?_=this.visibilityRatio*n.height:_=this.visibilityRatio*i.height,y=n.y-g+_,E=m-i.y-_,_>n.height?(i.y+=(y+E)/2,u=!0):E<0?(i.y+=E,u=!0):y>0&&(i.y+=y,u=!0)}var S=o||u,P=S?this.viewerElementToViewportRectangle(i):t.clone();return P.xConstrained=o,P.yConstrained=u,P.constraintApplied=S,P},_raiseConstraintsEvent:function(t){this.viewer&&this.viewer.raiseEvent("constrain",{immediately:t})},applyConstraints:function(t){var i=this.getZoom(),n=this._applyZoomConstraints(i);i!==n&&this.zoomTo(n,this.zoomPoint,t);var o=this.getConstrainedBounds(!1);return o.constraintApplied&&(this.fitBounds(o,t),this._raiseConstraintsEvent(t)),this},ensureVisible:function(t){return this.applyConstraints(t)},_fitBounds:function(t,i){i=i||{};var n=i.immediately||!1,o=i.constraints||!1,u=this.getAspectRatio(),l=t.getCenter(),a=new e.Rect(t.x,t.y,t.width,t.height,t.degrees+this.getRotation()).getBoundingBox();a.getAspectRatio()>=u?a.height=a.width/u:a.width=a.height*u,a.x=l.x-a.width/2,a.y=l.y-a.height/2;var h=1/a.width;if(n)return this.panTo(l,!0),this.zoomTo(h,null,!0),o&&this.applyConstraints(!0),this;var c=this.getCenter(!0),d=this.getZoom(!0);this.panTo(c,!0),this.zoomTo(d,null,!0);var g=this.getBounds(),m=this.getZoom();if(m===0||Math.abs(h/m-1)<1e-8)return this.zoomTo(h,null,!0),this.panTo(l,n),o&&this.applyConstraints(!1),this;if(o){this.panTo(l,!1),h=this._applyZoomConstraints(h),this.zoomTo(h,null,!1);var _=this.getConstrainedBounds();this.panTo(c,!0),this.zoomTo(d,null,!0),this.fitBounds(_)}else{var y=a.rotate(-this.getRotation()),E=y.getTopLeft().times(h).minus(g.getTopLeft().times(m)).divide(h-m);this.zoomTo(h,E,n)}return this},fitBounds:function(t,i){return this._fitBounds(t,{immediately:i,constraints:!1})},fitBoundsWithConstraints:function(t,i){return this._fitBounds(t,{immediately:i,constraints:!0})},fitVertically:function(t){var i=new e.Rect(this._contentBounds.x+this._contentBounds.width/2,this._contentBounds.y,0,this._contentBounds.height);return this.fitBounds(i,t)},fitHorizontally:function(t){var i=new e.Rect(this._contentBounds.x,this._contentBounds.y+this._contentBounds.height/2,this._contentBounds.width,0);return this.fitBounds(i,t)},getConstrainedBounds:function(t){var i,n;return i=this.getBounds(t),n=this._applyBoundaryConstraints(i),n},panBy:function(t,i){var n=new e.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return this.panTo(n.plus(t),i)},panTo:function(t,i){return i?(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:i}),this},zoomBy:function(t,i,n){return this.zoomTo(this.zoomSpring.target.value*t,i,n)},zoomTo:function(t,i,n){var o=this;return this.zoomPoint=i instanceof e.Point&&!isNaN(i.x)&&!isNaN(i.y)?i:null,n?this._adjustCenterSpringsForZoomPoint(function(){o.zoomSpring.resetTo(t)}):this.zoomSpring.springTo(t),this.viewer&&this.viewer.raiseEvent("zoom",{zoom:t,refPoint:i,immediately:n}),this},setRotation:function(t,i){return this.rotateTo(t,null,i)},getRotation:function(t){return t?this.degreesSpring.current.value:this.degreesSpring.target.value},setRotationWithPivot:function(t,i,n){return this.rotateTo(t,i,n)},rotateTo:function(t,i,n){if(!this.viewer||!this.viewer.drawer.canRotate())return this;if(this.degreesSpring.target.value===t&&this.degreesSpring.isAtTargetValue())return this;if(this.rotationPivot=i instanceof e.Point&&!isNaN(i.x)&&!isNaN(i.y)?i:null,n)if(this.rotationPivot){var o=t-this._oldDegrees;if(!o)return this.rotationPivot=null,this;this._rotateAboutPivot(t)}else this.degreesSpring.resetTo(t);else{var u=e.positiveModulo(this.degreesSpring.current.value,360),l=e.positiveModulo(t,360),a=l-u;a>180?l-=360:a<-180&&(l+=360);var h=u-l;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:!!n,pivot:this.rotationPivot||this.getCenter()}),this},rotateBy:function(t,i,n){return this.rotateTo(this.degreesSpring.target.value+t,i,n)},resize:function(t,i){var n=this.getBoundsNoRotate(),o=n,u;this.containerSize.x=t.x,this.containerSize.y=t.y,this._updateContainerInnerSize(),i&&(u=t.x/this.containerSize.x,o.width=n.width*u,o.height=o.width/this.getAspectRatio()),this.viewer&&this.viewer.raiseEvent("resize",{newContainerSize:t,maintain:i});var l=this.fitBounds(o,!0);return this.viewer&&this.viewer.raiseEvent("after-resize",{newContainerSize:t,maintain:i}),l},_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 i=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 n=i||!this.zoomSpring.isAtTargetValue()||!this.centerSpringX.isAtTargetValue()||!this.centerSpringY.isAtTargetValue()||!this.degreesSpring.isAtTargetValue();return n},_rotateAboutPivot:function(t){var i=t===!0,n=this.rotationPivot.minus(this.getCenter());this.centerSpringX.shiftBy(n.x),this.centerSpringY.shiftBy(n.y),i?this.degreesSpring.update():this.degreesSpring.resetTo(t);var o=this.degreesSpring.current.value-this._oldDegrees,u=n.rotate(o*-1).times(-1);this.centerSpringX.shiftBy(u.x),this.centerSpringY.shiftBy(u.y)},_adjustCenterSpringsForZoomPoint:function(t){if(this.zoomPoint){var i=this.pixelFromPoint(this.zoomPoint,!0);t();var n=this.pixelFromPoint(this.zoomPoint,!0),o=n.minus(i),u=this.deltaPointsFromPixels(o,!0);this.centerSpringX.shiftBy(u.x),this.centerSpringY.shiftBy(u.y),this.zoomSpring.isAtTargetValue()&&(this.zoomPoint=null)}else t()},deltaPixelsFromPointsNoRotate:function(t,i){return t.times(this._containerInnerSize.x*this.getZoom(i))},deltaPixelsFromPoints:function(t,i){return this.deltaPixelsFromPointsNoRotate(t.rotate(this.getRotation(i)),i)},deltaPointsFromPixelsNoRotate:function(t,i){return t.divide(this._containerInnerSize.x*this.getZoom(i))},deltaPointsFromPixels:function(t,i){return this.deltaPointsFromPixelsNoRotate(t,i).rotate(-this.getRotation(i))},pixelFromPointNoRotate:function(t,i){return this._pixelFromPointNoRotate(t,this.getBoundsNoRotate(i))},pixelFromPoint:function(t,i){return this._pixelFromPoint(t,this.getBoundsNoRotate(i))},_pixelFromPointNoRotate:function(t,i){return t.minus(i.getTopLeft()).times(this._containerInnerSize.x/i.width).plus(new e.Point(this._margins.left,this._margins.top))},_pixelFromPoint:function(t,i){return this._pixelFromPointNoRotate(t.rotate(this.getRotation(!0),this.getCenter(!0)),i)},pointFromPixelNoRotate:function(t,i){var n=this.getBoundsNoRotate(i);return t.minus(new e.Point(this._margins.left,this._margins.top)).divide(this._containerInnerSize.x/n.width).plus(n.getTopLeft())},pointFromPixel:function(t,i){return this.pointFromPixelNoRotate(t,i).rotate(-this.getRotation(i),this.getCenter(i))},_viewportToImageDelta:function(t,i){var n=this._contentBoundsNoRotate.width;return new e.Point(t*this._contentSizeNoRotate.x/n,i*this._contentSizeNoRotate.x/n)},viewportToImageCoordinates:function(t,i){if(t instanceof e.Point)return this.viewportToImageCoordinates(t.x,t.y);if(this.viewer){var n=this.viewer.world.getItemCount();if(n>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageCoordinates] is not accurate with multi-image; use TiledImage.viewportToImageCoordinates instead.");else if(n===1){var o=this.viewer.world.getItemAt(0);return o.viewportToImageCoordinates(t,i,!0)}}return this._viewportToImageDelta(t-this._contentBoundsNoRotate.x,i-this._contentBoundsNoRotate.y)},_imageToViewportDelta:function(t,i){var n=this._contentBoundsNoRotate.width;return new e.Point(t/this._contentSizeNoRotate.x*n,i/this._contentSizeNoRotate.x*n)},imageToViewportCoordinates:function(t,i){if(t instanceof e.Point)return this.imageToViewportCoordinates(t.x,t.y);if(this.viewer){var n=this.viewer.world.getItemCount();if(n>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.imageToViewportCoordinates] is not accurate with multi-image; use TiledImage.imageToViewportCoordinates instead.");else if(n===1){var o=this.viewer.world.getItemAt(0);return o.imageToViewportCoordinates(t,i,!0)}}var u=this._imageToViewportDelta(t,i);return u.x+=this._contentBoundsNoRotate.x,u.y+=this._contentBoundsNoRotate.y,u},imageToViewportRectangle:function(t,i,n,o){var u=t;if(u instanceof e.Rect||(u=new e.Rect(t,i,n,o)),this.viewer){var l=this.viewer.world.getItemCount();if(l>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.imageToViewportRectangle] is not accurate with multi-image; use TiledImage.imageToViewportRectangle instead.");else if(l===1){var a=this.viewer.world.getItemAt(0);return a.imageToViewportRectangle(t,i,n,o,!0)}}var h=this.imageToViewportCoordinates(u.x,u.y),c=this._imageToViewportDelta(u.width,u.height);return new e.Rect(h.x,h.y,c.x,c.y,u.degrees)},viewportToImageRectangle:function(t,i,n,o){var u=t;if(u instanceof e.Rect||(u=new e.Rect(t,i,n,o)),this.viewer){var l=this.viewer.world.getItemCount();if(l>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageRectangle] is not accurate with multi-image; use TiledImage.viewportToImageRectangle instead.");else if(l===1){var a=this.viewer.world.getItemAt(0);return a.viewportToImageRectangle(t,i,n,o,!0)}}var h=this.viewportToImageCoordinates(u.x,u.y),c=this._viewportToImageDelta(u.width,u.height);return new e.Rect(h.x,h.y,c.x,c.y,u.degrees)},viewerElementToImageCoordinates:function(t){var i=this.pointFromPixel(t,!0);return this.viewportToImageCoordinates(i)},imageToViewerElementCoordinates:function(t){var i=this.imageToViewportCoordinates(t);return this.pixelFromPoint(i,!0)},windowToImageCoordinates:function(t){e.console.assert(this.viewer,"[Viewport.windowToImageCoordinates] the viewport must have a viewer.");var i=t.minus(e.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(i)},imageToWindowCoordinates:function(t){e.console.assert(this.viewer,"[Viewport.imageToWindowCoordinates] the viewport must have a viewer.");var i=this.imageToViewerElementCoordinates(t);return i.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 i=t.minus(e.getElementPosition(this.viewer.element));return this.viewerElementToViewportCoordinates(i)},viewportToWindowCoordinates:function(t){e.console.assert(this.viewer,"[Viewport.viewportToWindowCoordinates] the viewport must have a viewer.");var i=this.viewportToViewerElementCoordinates(t);return i.plus(e.getElementPosition(this.viewer.element))},viewportToImageZoom:function(t){if(this.viewer){var i=this.viewer.world.getItemCount();if(i>1)this.silenceMultiImageWarnings||e.console.error("[Viewport.viewportToImageZoom] is not accurate with multi-image.");else if(i===1){var n=this.viewer.world.getItemAt(0);return n.viewportToImageZoom(t)}}var o=this._contentSizeNoRotate.x,u=this._containerInnerSize.x,l=this._contentBoundsNoRotate.width,a=u/o*l;return t*a},imageToViewportZoom:function(t){if(this.viewer){var i=this.viewer.world.getItemCount();if(i>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(i===1){var n=this.viewer.world.getItemAt(0);return n.imageToViewportZoom(t)}}var o=this._contentSizeNoRotate.x,u=this._containerInnerSize.x,l=this._contentBoundsNoRotate.width,a=o/u/l;return t*a},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,i=!0,n=!1){e.console.assert(!isNaN(t),"[Viewport.setMaxZoomPixelRatio] ratio must be a number"),!isNaN(t)&&(this.maxZoomPixelRatio=t,i&&this.getZoom()>this.getMaxZoom()&&this.applyConstraints(n))}}})(s),(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 i=t.x||0;delete t.x;var n=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 o=1;t.width?(o=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&&(o=t.height/this.normHeight,delete t.height);var u=t.fitBounds;delete t.fitBounds;var l=t.fitBoundsPlacement||s.Placement.CENTER;delete t.fitBoundsPlacement;var a=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:i,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._ySpring=new e.Spring({initial:n,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._scaleSpring=new e.Spring({initial:o,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._degreesSpring=new e.Spring({initial:a,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._updateForScale(),u&&this.fitBounds(u,l,!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 i=this._xSpring.update(),n=this._ySpring.update(),o=this._scaleSpring.update(),u=this._degreesSpring.update(),l=i||n||o||u||this._needsUpdate;if(l||t||!this._fullyLoaded){let a=this._updateLevelsForViewport();this._setFullyLoaded(a)}return this._needsUpdate=!1,l?(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 i=this.getBoundsNoRotate(t);if(this._clip){var n=t?this._worldWidthCurrent:this._worldWidthTarget,o=n/this.source.dimensions.x,u=this._clip.times(o);i=new e.Rect(i.x+u.x,i.y+u.y,u.width,u.height)}return i.rotate(this.getRotation(t),this._getRotationPoint(t))},getTileBounds:function(t,i,n){var o=this.source.getNumTiles(t),u=(o.x+i%o.x)%o.x,l=(o.y+n%o.y)%o.y,a=this.source.getTileBounds(t,u,l);return this.getFlip()&&(a.x=Math.max(0,1-a.x-a.width)),a.x+=(i-u)/o.x,a.y+=this._worldHeightCurrent/this._worldWidthCurrent*((n-l)/o.y),a},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)),i=this.imageToWindowCoordinates(this.getContentSize());return new e.Point(i.x-t.x,i.y-t.y)},_viewportToImageDelta:function(t,i,n){var o=n?this._scaleSpring.current.value:this._scaleSpring.target.value;return new e.Point(t*(this.source.dimensions.x/o),i*(this.source.dimensions.y*this.contentAspectX/o))},viewportToImageCoordinates:function(t,i,n){var o;return t instanceof e.Point?(n=i,o=t):o=new e.Point(t,i),o=o.rotate(-this.getRotation(n),this._getRotationPoint(n)),n?this._viewportToImageDelta(o.x-this._xSpring.current.value,o.y-this._ySpring.current.value):this._viewportToImageDelta(o.x-this._xSpring.target.value,o.y-this._ySpring.target.value)},_imageToViewportDelta:function(t,i,n){var o=n?this._scaleSpring.current.value:this._scaleSpring.target.value;return new e.Point(t/this.source.dimensions.x*o,i/this.source.dimensions.y/this.contentAspectX*o)},imageToViewportCoordinates:function(t,i,n){t instanceof e.Point&&(n=i,i=t.y,t=t.x);var o=this._imageToViewportDelta(t,i,n);return n?(o.x+=this._xSpring.current.value,o.y+=this._ySpring.current.value):(o.x+=this._xSpring.target.value,o.y+=this._ySpring.target.value),o.rotate(this.getRotation(n),this._getRotationPoint(n))},imageToViewportRectangle:function(t,i,n,o,u){var l=t;l instanceof e.Rect?u=i:l=new e.Rect(t,i,n,o);var a=this.imageToViewportCoordinates(l.getTopLeft(),u),h=this._imageToViewportDelta(l.width,l.height,u);return new e.Rect(a.x,a.y,h.x,h.y,l.degrees+this.getRotation(u))},viewportToImageRectangle:function(t,i,n,o,u){var l=t;t instanceof e.Rect?u=i:l=new e.Rect(t,i,n,o);var a=this.viewportToImageCoordinates(l.getTopLeft(),u),h=this._viewportToImageDelta(l.width,l.height,u);return new e.Rect(a.x,a.y,h.x,h.y,l.degrees-this.getRotation(u))},viewerElementToImageCoordinates:function(t){var i=this.viewport.pointFromPixel(t,!0);return this.viewportToImageCoordinates(i)},imageToViewerElementCoordinates:function(t){var i=this.imageToViewportCoordinates(t);return this.viewport.pixelFromPoint(i,!0)},windowToImageCoordinates:function(t){var i=t.minus(s.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(i)},imageToWindowCoordinates:function(t){var i=this.imageToViewerElementCoordinates(t);return i.plus(s.getElementPosition(this.viewer.element))},_viewportToTiledImageRectangle:function(t){var i=this._scaleSpring.current.value;return t=t.rotate(-this.getRotation(!0),this._getRotationPoint(!0)),new e.Rect((t.x-this._xSpring.current.value)/i,(t.y-this._ySpring.current.value)/i,t.width/i,t.height/i,t.degrees)},viewportToImageZoom:function(t){var i=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return i*t},imageToViewportZoom:function(t){var i=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return t/i},setPosition:function(t,i){var n=this._xSpring.target.value===t.x&&this._ySpring.target.value===t.y;if(i){if(n&&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(n)return;this._xSpring.springTo(t.x),this._ySpring.springTo(t.y),this._needsDraw=!0,this._needsUpdate=!0}n||this._raiseBoundsChange()},setWidth:function(t,i){this._setScale(t,i)},setHeight:function(t,i){this._setScale(t/this.normHeight,i)},setCroppingPolygons:function(t){var i=function(o){return o instanceof e.Point||typeof o.x=="number"&&typeof o.y=="number"},n=function(o){return o.map(function(u){try{if(i(u))return{x:u.x,y:u.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(o){return n(o)}),this._needsDraw=!0}catch(o){e.console.error("[TiledImage.setCroppingPolygons] Cropping polygon format not supported"),e.console.error(o),this.resetCroppingPolygons()}},resetCroppingPolygons:function(){this._croppingPolygons=null,this._needsDraw=!0},fitBounds:function(t,i,n){i=i||e.Placement.CENTER;var o=e.Placement.properties[i],u=this.contentAspectX,l=0,a=0,h=1,c=1;if(this._clip&&(u=this._clip.getAspectRatio(),h=this._clip.width/this.source.dimensions.x,c=this._clip.height/this.source.dimensions.y,t.getAspectRatio()>u?(l=this._clip.x/this._clip.height*t.height,a=this._clip.y/this._clip.height*t.height):(l=this._clip.x/this._clip.width*t.width,a=this._clip.y/this._clip.width*t.width)),t.getAspectRatio()>u){var d=t.height/c,g=0;o.isHorizontallyCentered?g=(t.width-t.height*u)/2:o.isRight&&(g=t.width-t.height*u),this.setPosition(new e.Point(t.x-l+g,t.y-a),n),this.setHeight(d,n)}else{var m=t.width/h,_=0;o.isVerticallyCentered?_=(t.height-t.width/u)/2:o.isBottom&&(_=t.height-t.width/u),this.setPosition(new e.Point(t.x-l,t.y-a+_),n),this.setWidth(m,n)}},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 i=this._flipped!==!!t;this._flipped=!!t,i&&(this.update(!0),this._needsDraw=!0,this._raiseBoundsChange())},get wrapHorizontal(){return this._wrapHorizontal},set wrapHorizontal(t){let i=this._wrapHorizontal!==!!t;this._wrapHorizontal=!!t,this._initialized&&i&&(this.update(!0),this._needsDraw=!0)},get wrapVertical(){return this._wrapVertical},set wrapVertical(t){let i=this._wrapVertical!==!!t;this._wrapVertical=!!t,this._initialized&&i&&(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,i){this._degreesSpring.target.value===t&&this._degreesSpring.isAtTargetValue()||(i?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 i=this._viewportToTiledImageRectangle(this.getClippedBounds(!0));t=t.intersection(i)}return t},getTilesToDraw:function(){let t=this._tilesToDraw.flat();return this._updateTilesInViewport(t),t=this._tilesToDraw.flat(),t.forEach(i=>{i.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,i){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(i)},_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 i,n,o,u;for(var l in this.tilesMatrix){i=this.source.getNumTiles(l);for(var a in this.tilesMatrix[l]){n=(i.x+a%i.x)%i.x;for(var h in this.tilesMatrix[l][a])if(o=(i.y+h%i.y)%i.y,u=this.tilesMatrix[l][a][h],u.loadWithAjax=this.loadTilesWithAjax,u.loadWithAjax){var c=this.source.getTileAjaxHeaders(l,n,o);u.ajaxHeaders=e.extend({},this.ajaxHeaders,c)}else u.ajaxHeaders=null}}for(var d=0;d<this._imageLoader.jobQueue.length;d++){var g=this._imageLoader.jobQueue[d];g.loadWithAjax=g.tile.loadWithAjax,g.ajaxHeaders=g.tile.loadWithAjax?g.tile.ajaxHeaders:null}}},_setScale:function(t,i){var n=this._scaleSpring.target.value===t;if(i){if(n&&this._scaleSpring.current.value===t)return;this._scaleSpring.resetTo(t),this._updateForScale(),this._needsDraw=!0,this._needsUpdate=!0}else{if(n)return;this._scaleSpring.springTo(t),this._updateForScale(),this._needsDraw=!0,this._needsUpdate=!0}n||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))),i=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(0),!0).x*this._scaleSpring.current.value,n=Math.min(Math.abs(this.source.maxLevel),Math.abs(Math.floor(Math.log(i/this.minPixelRatio)/Math.log(2))));return n=Math.max(n,this.source.minLevel||0),t=Math.min(t,n),{lowestLevel:t,highestLevel:n}},_updateLevelsForViewport:function(){var t=this._getLevelsInterval(),i=t.lowestLevel,n=t.highestLevel,o=[],u=this.getDrawArea(),l=e.now();if(this._lastDrawn.forEach(k=>{k.tile.beingDrawn=!1}),this._tilesToDraw=[],this._tilesLoading=0,this.loadingCoverage={},!u)return this._needsDraw=!1,this._fullyLoaded;var a=new Array(n-i+1);for(let k=0,M=n;M>=i;M--,k++)a[k]=M;for(let k=n+1;k<=this.source.maxLevel;k++){var h=this.tilesMatrix[k]&&this.tilesMatrix[k][0]&&this.tilesMatrix[k][0][0];if(h&&h.isBottomMost&&h.isRightMost&&h.loaded){a.push(k);break}}let c=!1;for(let k=0;k<a.length;k++){let M=a[k];var d=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(M),!0).x*this._scaleSpring.current.value;if(k===a.length-1||d>=this.minPixelRatio)c=!0;else if(!c)continue;var g=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(M),!1).x*this._scaleSpring.current.value,m=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(Math.max(this.source.getClosestLevel(),0)),!1).x*this._scaleSpring.current.value,_=this.immediateRender?1:m,y=Math.min(1,(d-.5)/.5),E=_/Math.abs(_-g),S=this._updateLevel(M,y,E,u,l,o);o=S.bestTiles;var P=S.updatedTiles.filter(L=>L.loaded),B=(function(L,W,$){return function(Q){return{tile:Q,level:L,levelOpacity:W,currentTime:$}}})(M,y,l);if(this._tilesToDraw[M]=P.map(B),this._providesCoverage(this.coverage,M))break}return o&&o.length>0?(o.forEach(function(k){k&&!k.context2D&&this._loadTile(k,l)},this),this._needsDraw=!0,!1):this._tilesLoading===0},_updateTilesInViewport:function(t){let i=e.now(),n=this;this._tilesLoading=0,this._wasBlending=this._isBlending,this._isBlending=!1,this.loadingCoverage={};let o=t.length?t[0].level:0;if(!this.getDrawArea())return;function u(a){let h=a.tile;if(h&&h.loaded){let c=n._blendTile(h,h.x,h.y,a.level,a.levelOpacity,i,o);n._isBlending=n._isBlending||c,n._needsDraw=n._needsDraw||c||n._wasBlending}}let l=0;for(let a=0;a<t.length;a++){let h=t[a];u(h),this._providesCoverage(this.coverage,h.level)&&(l=Math.max(l,h.level))}if(l>0)for(let a in this._tilesToDraw)a<l&&delete this._tilesToDraw[a]},_blendTile:function(t,i,n,o,u,l,a){let h=1e3*this.blendTime,c,d;return t.blendStart||(t.blendStart=l),c=l-t.blendStart,d=h?Math.min(1,c/h):1,o===a&&(d=1,c=h),this.alwaysBlend&&(d*=u),t.opacity=d,d===1&&(this._setCoverage(this.coverage,o,i,n,!0),this._hasOpaqueTile=!0),c<h},_updateLevel:function(t,i,n,o,u,l){var a=o.getBoundingBox().getTopLeft(),h=o.getBoundingBox().getBottomRight();this.viewer&&this.viewer.raiseEvent("update-level",{tiledImage:this,havedrawn:!0,level:t,opacity:i,visibility:n,drawArea:o,topleft:a,bottomright:h,currenttime:u,best:l}),this._resetCoverage(this.coverage,t),this._resetCoverage(this.loadingCoverage,t);var c=this._getCornerTiles(t,a,h),d=c.topLeft,g=c.bottomRight,m=this.source.getNumTiles(t),_=this.viewport.pixelFromPoint(this.viewport.getCenter());this.getFlip()&&(g.x+=1,this.wrapHorizontal||(g.x=Math.min(g.x,m.x-1)));for(var y=Math.max(0,(g.x-d.x)*(g.y-d.y)),E=new Array(y),S=0,P=d.x;P<=g.x;P++)for(var B=d.y;B<=g.y;B++){var k;if(this.getFlip()){var M=(m.x+P%m.x)%m.x;k=P+m.x-M-M-1}else k=P;if(o.intersection(this.getTileBounds(t,k,B))!==null){var L=this._updateTile(k,B,t,n,_,m,u,l);l=L.bestTiles,E[S]=L.tile,S+=1}}return{bestTiles:l,updatedTiles:E}},_positionTile:function(t,i,n,o,u){var l=t.bounds.getTopLeft();l.x*=this._scaleSpring.current.value,l.y*=this._scaleSpring.current.value,l.x+=this._xSpring.current.value,l.y+=this._ySpring.current.value;var a=t.bounds.getSize();a.x*=this._scaleSpring.current.value,a.y*=this._scaleSpring.current.value,t.positionedBounds.x=l.x,t.positionedBounds.y=l.y,t.positionedBounds.width=a.x,t.positionedBounds.height=a.y;var h=n.pixelFromPointNoRotate(l,!0),c=n.pixelFromPointNoRotate(l,!1),d=n.deltaPixelsFromPointsNoRotate(a,!0),g=n.deltaPixelsFromPointsNoRotate(a,!1),m=c.plus(g.divide(2)),_=o.squaredDistanceTo(m);this.viewer.drawer.minimumOverlapRequired(this)&&(i||(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=_,t.visibility=u},_updateTile:function(t,i,n,o,u,l,a,h){var c=this._getTile(t,i,n,a,l);this.viewer&&this.viewer.raiseEvent("update-tile",{tiledImage:this,tile:c}),this._setCoverage(this.coverage,n,t,i,!1);var d=c.loaded||c.loading||this._isCovered(this.loadingCoverage,n,t,i);if(this._setCoverage(this.loadingCoverage,n,t,i,d),!c.exists)return{bestTiles:h,tile:c};if(c.loaded&&c.opacity===1&&this._setCoverage(this.coverage,n,t,i,!0),this._positionTile(c,this.source.tileOverlap,this.viewport,u,o),!c.loaded)if(c.context2D)this._setTileLoaded(c);else{var g=this._tileCache.getImageRecord(c.cacheKey);g&&this._setTileLoaded(c,g.getData())}return c.loading?this._tilesLoading++:d||(h=this._compareTiles(h,c,this.maxTilesPerFrame)),{bestTiles:h,tile:c}},_getCornerTiles:function(t,i,n){var o,u;this.wrapHorizontal?(o=e.positiveModulo(i.x,1),u=e.positiveModulo(n.x,1)):(o=Math.max(0,i.x),u=Math.min(1,n.x));var l,a,h=1/this.source.aspectRatio;this.wrapVertical?(l=e.positiveModulo(i.y,h),a=e.positiveModulo(n.y,h)):(l=Math.max(0,i.y),a=Math.min(h,n.y));var c=this.source.getTileAtPoint(t,new e.Point(o,l)),d=this.source.getTileAtPoint(t,new e.Point(u,a)),g=this.source.getNumTiles(t);return this.wrapHorizontal&&(c.x+=g.x*Math.floor(i.x),d.x+=g.x*Math.floor(n.x)),this.wrapVertical&&(c.y+=g.y*Math.floor(i.y/h),d.y+=g.y*Math.floor(n.y/h)),{topLeft:c,bottomRight:d}},_getTile:function(t,i,n,o,u){var l,a,h,c,d,g,m,_,y,E,S=this.tilesMatrix,P=this.source;return S[n]||(S[n]={}),S[n][t]||(S[n][t]={}),(!S[n][t][i]||!S[n][t][i].flipped!=!this.flipped)&&(l=(u.x+t%u.x)%u.x,a=(u.y+i%u.y)%u.y,h=this.getTileBounds(n,t,i),c=P.getTileBounds(n,l,a,!0),d=P.tileExists(n,l,a),g=P.getTileUrl(n,l,a),m=P.getTilePostData(n,l,a),this.loadTilesWithAjax?(_=P.getTileAjaxHeaders(n,l,a),e.isPlainObject(this.ajaxHeaders)&&(_=e.extend({},this.ajaxHeaders,_))):_=null,y=P.getContext2D?P.getContext2D(n,l,a):void 0,E=new e.Tile(n,t,i,h,d,g,y,this.loadTilesWithAjax,_,c,m,P.getTileHashKey(n,l,a,g,_,m)),this.getFlip()?l===0&&(E.isRightMost=!0):l===u.x-1&&(E.isRightMost=!0),a===u.y-1&&(E.isBottomMost=!0),E.flipped=this.flipped,S[n][t][i]=E),E=S[n][t][i],E.lastTouchTime=o,E},_loadTile:function(t,i){var n=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(o,u,l){n._onTileLoad(t,i,o,u,l)},abort:function(){t.loading=!1}})},_onTileLoad:function(t,i,n,o,u){if(n)t.exists=!0;else{e.console.error("Tile %s failed to load: %s - error: %s",t,t.getUrl(),o),this.viewer.raiseEvent("tile-load-failed",{tile:t,tiledImage:this,time:i,message:o,tileRequest:u}),t.loading=!1,t.exists=!1;return}if(i<this.lastResetTime){e.console.warn("Ignoring tile %s loaded before reset: %s",t,t.getUrl()),t.loading=!1;return}var l=this,a=function(){var h=l.source,c=h.getClosestLevel();l._setTileLoaded(t,n,c,u)};a()},_setTileLoaded:function(t,i,n,o){var u=0,l=!1,a=this;function h(){return l&&e.console.error("Event 'tile-loaded' argument getCompletionCallback must be called synchronously. Its return value should be called asynchronously."),u++,c}function c(){u--,u===0&&(t.loading=!1,t.loaded=!0,t.hasTransparency=a.source.hasTransparency(t.context2D,t.getUrl(),t.ajaxHeaders,t.postData),t.context2D||a._tileCache.cacheTile({data:i,tile:t,cutoff:n,tiledImage:a}),a.viewer.raiseEvent("tile-ready",{tile:t,tiledImage:a,tileRequest:o}),a._needsDraw=!0)}var d=h();this.viewer.raiseEvent("tile-loaded",{tile:t,tiledImage:this,tileRequest:o,get image(){return e.console.error("[tile-loaded] event 'image' has been deprecated. Use 'data' property instead."),i},data:i,getCompletionCallback:h}),l=!0,d()},_compareTiles:function(t,i,n){return t?(t.push(i),this._sortTiles(t),t.length>n&&t.pop(),t):[i]},_sortTiles:function(t){t.sort(function(i,n){return i===null?1:n===null?-1:i.visibility===n.visibility?i.squaredDistance-n.squaredDistance:n.visibility-i.visibility})},_providesCoverage:function(t,i,n,o){var u,l,a,h;if(!t[i])return!1;if(n===void 0||o===void 0){u=t[i];for(a in u)if(Object.prototype.hasOwnProperty.call(u,a)){l=u[a];for(h in l)if(Object.prototype.hasOwnProperty.call(l,h)&&!l[h])return!1}return!0}return t[i][n]===void 0||t[i][n][o]===void 0||t[i][n][o]===!0},_isCovered:function(t,i,n,o){return n===void 0||o===void 0?this._providesCoverage(t,i+1):this._providesCoverage(t,i+1,2*n,2*o)&&this._providesCoverage(t,i+1,2*n,2*o+1)&&this._providesCoverage(t,i+1,2*n+1,2*o)&&this._providesCoverage(t,i+1,2*n+1,2*o+1)},_setCoverage:function(t,i,n,o,u){if(!t[i]){e.console.warn("Setting coverage for a tile before its level's coverage has been reset: %s",i);return}t[i][n]||(t[i][n]={}),t[i][n][o]=u},_resetCoverage:function(t,i){t[i]={}}})})(s),(function(e){var t=function(n){e.console.assert(n,"[TileCache.cacheTile] options is required"),e.console.assert(n.tile,"[TileCache.cacheTile] options.tile is required"),e.console.assert(n.tiledImage,"[TileCache.cacheTile] options.tiledImage is required"),this.tile=n.tile,this.tiledImage=n.tiledImage},i=function(n){e.console.assert(n,"[ImageRecord] options is required"),e.console.assert(n.data,"[ImageRecord] options.data is required"),this._tiles=[],n.create.apply(null,[this,n.data,n.ownerTile]),this._destroyImplementation=n.destroy.bind(null,this),this.getImage=n.getImage.bind(null,this),this.getData=n.getData.bind(null,this),this.getRenderedContext=n.getRenderedContext.bind(null,this)};i.prototype={destroy:function(){this._destroyImplementation(),this._tiles=null},addTile:function(n){e.console.assert(n,"[ImageRecord.addTile] tile is required"),this._tiles.push(n)},removeTile:function(n){for(var o=0;o<this._tiles.length;o++)if(this._tiles[o]===n){this._tiles.splice(o,1);return}e.console.warn("[ImageRecord.removeTile] trying to remove unknown tile",n)},getTileCount:function(){return this._tiles.length}},e.TileCache=function(n){n=n||{},this._maxImageCacheCount=n.maxImageCacheCount||e.DEFAULT_SETTINGS.maxImageCacheCount,this._tilesLoaded=[],this._imagesLoaded=[],this._imagesLoadedCount=0},e.TileCache.prototype={numTilesLoaded:function(){return this._tilesLoaded.length},cacheTile:function(n){e.console.assert(n,"[TileCache.cacheTile] options is required"),e.console.assert(n.tile,"[TileCache.cacheTile] options.tile is required"),e.console.assert(n.tile.cacheKey,"[TileCache.cacheTile] options.tile.cacheKey is required"),e.console.assert(n.tiledImage,"[TileCache.cacheTile] options.tiledImage is required");var o=n.cutoff||0,u=this._tilesLoaded.length,l=this._imagesLoaded[n.tile.cacheKey];if(l||(n.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."),n.data=n.image),e.console.assert(n.data,"[TileCache.cacheTile] options.data is required to create an ImageRecord"),l=this._imagesLoaded[n.tile.cacheKey]=new i({data:n.data,ownerTile:n.tile,create:n.tiledImage.source.createTileCache,destroy:n.tiledImage.source.destroyTileCache,getImage:n.tiledImage.source.getTileCacheDataAsImage,getData:n.tiledImage.source.getTileCacheData,getRenderedContext:n.tiledImage.source.getTileCacheDataAsContext2D}),this._imagesLoadedCount++),l.addTile(n.tile),n.tile.cacheImageRecord=l,this._imagesLoadedCount>this._maxImageCacheCount){for(var a=null,h=-1,c=null,d,g,m,_,y,E,S=this._tilesLoaded.length-1;S>=0;S--)if(E=this._tilesLoaded[S],d=E.tile,!(d.level<=o||d.beingDrawn)){if(!a){a=d,h=S,c=E;continue}_=d.lastTouchTime,g=a.lastTouchTime,y=d.level,m=a.level,(_<g||_===g&&y>m)&&(a=d,h=S,c=E)}a&&h>=0&&(this._unloadTile(c),u=h)}this._tilesLoaded[u]=new t({tile:n.tile,tiledImage:n.tiledImage})},clearTilesFor:function(n){e.console.assert(n,"[TileCache.clearTilesFor] tiledImage is required");for(var o,u=0;u<this._tilesLoaded.length;++u)o=this._tilesLoaded[u],o.tiledImage===n&&(this._unloadTile(o),this._tilesLoaded.splice(u,1),u--)},getImageRecord:function(n){return e.console.assert(n,"[TileCache.getImageRecord] cacheKey is required"),this._imagesLoaded[n]},_unloadTile:function(n){e.console.assert(n,"[TileCache._unloadTile] tileRecord is required");var o=n.tile,u=n.tiledImage;let l=o.getCanvasContext&&o.getCanvasContext();o.unload(),o.cacheImageRecord=null;var a=this._imagesLoaded[o.cacheKey];a&&(a.removeTile(o),a.getTileCount()||(a.destroy(),delete this._imagesLoaded[o.cacheKey],this._imagesLoadedCount--,l&&(l.canvas.width=0,l.canvas.height=0,u.viewer.raiseEvent("image-unloaded",{context2D:l,tile:o}))),u.viewer.raiseEvent("tile-unloaded",{tile:o,tiledImage:u}))}}})(s),(function(e){e.World=function(t){var i=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(n){i._autoRefigureSizes?i._figureSizes():i._needsSizesFigured=!0},this._figureSizes()},e.extend(e.World.prototype,e.EventSource.prototype,{addItem:function(t,i){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"),i=i||{},i.index!==void 0){var n=Math.max(0,Math.min(this._items.length,i.index));this._items.splice(n,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,i){e.console.assert(t,"[World.setItemIndex] item is required"),e.console.assert(i!==void 0,"[World.setItemIndex] index is required");var n=this.getIndexOfItem(t);if(i>=this._items.length)throw new Error("Index bigger than number of layers.");i===n||n===-1||(this._items.splice(n,1),this._items.splice(i,0,t),this._needsDraw=!0,this.raiseEvent("item-index-change",{item:t,previousIndex:n,newIndex:i}))},removeItem:function(t){e.console.assert(t,"[World.removeItem] item is required");var i=e.indexOf(this._items,t);i!==-1&&(t.removeHandler("bounds-change",this._delegatedFigureSizes),t.removeHandler("clip-change",this._delegatedFigureSizes),t.destroy(),this._items.splice(i,1),this._figureSizes(),this._needsDraw=!0,this._raiseRemoveItem(t))},removeAll:function(){this.viewer._cancelPendingImages();var t,i;for(i=0;i<this._items.length;i++)t=this._items[i],t.removeHandler("bounds-change",this._delegatedFigureSizes),t.removeHandler("clip-change",this._delegatedFigureSizes),t.destroy();var n=this._items;for(this._items=[],this._figureSizes(),this._needsDraw=!0,i=0;i<n.length;i++)t=n[i],this._raiseRemoveItem(t)},resetItems:function(){for(var t=0;t<this._items.length;t++)this._items[t].reset()},update:function(t){for(var i=!1,n=0;n<this._items.length;n++)i=this._items[n].update(t)||i;return i},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 i=t.immediately||!1,n=t.layout||e.DEFAULT_SETTINGS.collectionLayout,o=t.rows||e.DEFAULT_SETTINGS.collectionRows,u=t.columns||e.DEFAULT_SETTINGS.collectionColumns,l=t.tileSize||e.DEFAULT_SETTINGS.collectionTileSize,a=t.tileMargin||e.DEFAULT_SETTINGS.collectionTileMargin,h=l+a,c;!t.rows&&u?c=u:c=Math.ceil(this._items.length/o);var d=0,g=0,m,_,y,E,S;this.setAutoRefigureSizes(!1);for(var P=0;P<this._items.length;P++)P&&P%c===0&&(n==="horizontal"?(g+=h,d=0):(d+=h,g=0)),m=this._items[P],_=m.getBounds(),_.width>_.height?y=l:y=l*(_.width/_.height),E=y*(_.height/_.width),S=new e.Point(d+(l-y)/2,g+(l-E)/2),m.setPosition(S,i),m.setWidth(y,i),n==="horizontal"?d+=h:g+=h;this.setAutoRefigureSizes(!0)},_figureSizes:function(){var t=this._homeBounds?this._homeBounds.clone():null,i=this._contentSize?this._contentSize.clone():null,n=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 o=this._items[0],u=o.getBounds();this._contentFactor=o.getContentSize().x/u.width;for(var l=o.getClippedBounds().getBoundingBox(),a=l.x,h=l.y,c=l.x+l.width,d=l.y+l.height,g=1;g<this._items.length;g++)o=this._items[g],u=o.getBounds(),this._contentFactor=Math.max(this._contentFactor,o.getContentSize().x/u.width),l=o.getClippedBounds().getBoundingBox(),a=Math.min(a,l.x),h=Math.min(h,l.y),c=Math.max(c,l.x+l.width),d=Math.max(d,l.y+l.height);this._homeBounds=new e.Rect(a,h,c-a,d-h),this._contentSize=new e.Point(this._homeBounds.width*this._contentFactor,this._homeBounds.height*this._contentFactor)}(this._contentFactor!==n||!this._homeBounds.equals(t)||!this._contentSize.equals(i))&&this.raiseEvent("metrics-change",{})},_raiseRemoveItem:function(t){this.raiseEvent("remove-item",{item:t})}})})(s)})(en)),en.exports}var Lr=Al();const kl=Object.freeze(Object.defineProperty({__proto__:null,o:Dl({__proto__:null,default:Rl(Lr)},[Lr])},Symbol.toStringTag,{value:"Module"}))})();
|
|
1
|
+
!function(){"use strict";var e=Array.isArray,t=Array.prototype.indexOf,n=Array.prototype.includes,r=Array.from,i=Object.defineProperty,o=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyDescriptors,a=Object.prototype,s=Array.prototype,u=Object.getPrototypeOf,c=Object.isExtensible;const d=()=>{};function f(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const h=1<<24,v=16,p=32,g=512,m=1024,w=2048,y=4096,b=8192,_=16384,x=32768,S=1<<25,k=65536,M=1<<17,I=1<<19,A=1<<25,$=65536,E=1<<21,j=1<<22,C=1<<23,z=Symbol("$state"),L=Symbol("legacy props"),W=Symbol(""),O=Symbol("attributes"),P=Symbol("class"),T=Symbol("style"),N=Symbol("text"),D=Symbol("form reset"),F=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"},R=!!globalThis.document?.contentType&&globalThis.document.contentType.includes("xml"),H="[!",q={},B=Symbol("uninitialized");function U(e){console.warn("https://svelte.dev/e/hydration_mismatch")}let V,K=!1;function Y(e){K=e}function Z(e){if(null===e)throw U(),q;return V=e}function G(){return Z(pt(V))}function X(e){if(K){if(null!==pt(V))throw U(),q;V=e}}function J(e=!0){for(var t=0,n=V;;){if(8===n.nodeType){var r=n.data;if("]"===r){if(0===t)return n;t-=1}else("["===r||r===H||"["===r[0]&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=pt(n);e&&n.remove(),n=i}}function Q(e){if(!e||8!==e.nodeType)throw U(),q;return e.data}function ee(e){return e===this.v}function te(e){return!function(e,t){return e!=e?t==t:e!==t||null!==e&&"object"==typeof e||"function"==typeof e}(e,this.v)}let ne=null;function re(e){ne=e}function ie(e,t=!1,n){ne={p:ne,i:!1,c:null,e:null,s:e,x:null,r:Kt,l:null}}function oe(e){var t=ne,n=t.e;if(null!==n)for(var r of(t.e=null,n))Mt(r);return t.i=!0,ne=t.p,{}}let le=[];function ae(e){if(0===le.length){var t=le;queueMicrotask(()=>{t===le&&function(){var e=le;le=[],function(e){for(var t=0;t<e.length;t++)e[t]()}(e)}()})}le.push(e)}function se(e){var t=Kt;if(null===t)return Bt.f|=C,e;if(0===(t.f&x)&&!(4&t.f))throw e;ue(e,t)}function ue(e,t){if(null===t||0===(t.f&_)){for(;null!==t;){if(128&t.f){if(0===(t.f&x))throw e;try{return void t.b.error(e)}catch(t){e=t}}t=t.parent}throw e}}const ce=-7169;function de(e,t){e.f=e.f&ce|t}function fe(e){0!==(e.f&g)||null===e.deps?de(e,m):de(e,y)}function he(e){if(null!==e)for(const t of e)!(2&t.f)||0===(t.f&$)||(t.f^=$,he(t.deps))}function ve(e,t,n){0!==(e.f&w)?t.add(e):0!==(e.f&y)&&n.add(e),he(e.deps),de(e,m)}let pe=!1;function ge(e,t){if(t){const t=document.body;e.autofocus=!0,ae(()=>{document.activeElement===t&&e.focus()})}}let me=!1;function we(){me||(me=!0,document.addEventListener("reset",e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(const t of e.target.elements)t[D]?.()})},{capture:!0}))}function ye(e){var t=Bt,n=Kt;Vt(null),Yt(null);try{return e()}finally{Vt(t),Yt(n)}}class be{parent;is_pending=!1;transform_error;#e;#t=K?V:null;#n;#r;#i;#o=null;#l=null;#a=null;#s=null;#u=0;#c=0;#d=!1;#f=new Set;#h=new Set;#v=null;#p=function(e){let t,n=0,r=Qe(0);return()=>{xt()&&(fn(r),At(()=>(0===n&&(t=pn(()=>e())),n+=1,()=>{ae(()=>{n-=1,0===n&&(t?.(),t=void 0,it(r))})})))}}(()=>(this.#v=Qe(this.#u),()=>{this.#v=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=Kt;t.b=this,t.f|=128,n(e)},this.parent=Kt.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Et(()=>{if(K){const e=this.#t;G();const t=e.data===H;if(e.data.startsWith("[?")){const t=JSON.parse(e.data.slice(2));this.#g(t)}else t?this.#m():this.#w()}else this.#y()},589824),K&&(this.#e=V)}#w(){try{this.#o=Ct(()=>this.#r(this.#e))}catch(e){this.error(e)}}#g(e){const t=this.#n.failed,{reset:n,invoke_onerror:r}=this.#b(e);ae(r),t&&(this.#a=Ct(()=>{t(this.#e,()=>e,()=>n)}))}#b(e){var t=!1,n=!1;const r=()=>{t?console.warn("https://svelte.dev/e/svelte_boundary_reset_noop"):(t=!0,n&&function(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}(),null!==this.#a&&Pt(this.#a,()=>{this.#a=null}),this.#_(()=>{this.#y()}))};return{reset:r,invoke_onerror:()=>{try{n=!0,this.#n.onerror?.(e,r),n=!1}catch(e){ue(e,this.#i&&this.#i.parent)}}}}#m(){const e=this.#n.pending;e&&(this.is_pending=!0,this.#l=Ct(()=>e(this.#e)),ae(()=>{var e=this.#s=document.createDocumentFragment(),t=ht();e.append(t),this.#o=this.#_(()=>Ct(()=>this.#r(t))),0===this.#c&&(this.#e.before(e),this.#s=null,Pt(this.#l,()=>{this.#l=null}),this.#x(Le))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#c=0,this.#u=0,this.#o=Ct(()=>{this.#r(this.#e)}),this.#c>0){var e=this.#s=document.createDocumentFragment();Ft(this.#o,e);const t=this.#n.pending;this.#l=Ct(()=>t(this.#e))}else this.#x(Le)}catch(e){this.error(e)}}#x(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#h)}defer_effect(e){ve(e,this.#f,this.#h)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#_(e){var t=Kt,n=Bt,r=ne;Yt(this.#i),Vt(this.#i),re(this.#i.ctx);try{return He.ensure(),e()}catch(e){return se(e),null}finally{Yt(t),Vt(n),re(r)}}#S(e,t){this.has_pending_snippet()?(this.#c+=e,0===this.#c&&(this.#x(t),this.#l&&Pt(this.#l,()=>{this.#l=null}),this.#s&&(this.#e.before(this.#s),this.#s=null))):this.parent&&this.parent.#S(e,t)}update_pending_count(e,t){this.#S(e,t),this.#u+=e,this.#v&&!this.#d&&(this.#d=!0,ae(()=>{this.#d=!1,this.#v&&nt(this.#v,this.#u)}))}get_effect_pending(){return this.#p(),fn(this.#v)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;Le?.is_fork?(this.#o&&Le.skip_effect(this.#o),this.#l&&Le.skip_effect(this.#l),this.#a&&Le.skip_effect(this.#a),Le.oncommit(()=>{this.#k(e)})):this.#k(e)}#k(e){this.#o&&(Wt(this.#o),this.#o=null),this.#l&&(Wt(this.#l),this.#l=null),this.#a&&(Wt(this.#a),this.#a=null),K&&(Z(this.#t),function(e=1){if(K){for(var t=e,n=V;t--;)n=pt(n);V=n}}(),Z(J()));let t=this.#n.failed;const n=e=>{const{reset:n,invoke_onerror:r}=this.#b(e);r(),t&&(this.#a=this.#_(()=>{try{return Ct(()=>{var r=Kt;r.b=this,r.f|=128,t(this.#e,()=>e,()=>n)})}catch(e){return ue(e,this.#i.parent),null}}))};ae(()=>{var t;try{t=this.transform_error(e)}catch(e){return void ue(e,this.#i&&this.#i.parent)}null!==t&&"object"==typeof t&&"function"==typeof t.then?t.then(n,e=>ue(e,this.#i&&this.#i.parent)):n(t)})}}function _e(e,t,n,r){const i=ke;var o=e.filter(e=>!e.settled),l=t.map(i);if(0!==n.length||0!==o.length){var a=Kt,s=function(){var e=Kt,t=Bt,n=ne,r=Le;return function(i=!0){Yt(e),Vt(t),re(n),i&&0===(e.f&_)&&(r?.activate(),r?.apply())}}(),u=1===o.length?o[0].promise:o.length>1?Promise.all(o.map(e=>e.promise)):null,c=Se();0!==n.length?u?u.then(()=>{s(),h(),xe()}):h():u.then(()=>d([])).finally(c)}else r(l);function d(e){if(0===(a.f&_)){s();try{r([...l,...e])}catch(e){ue(e,a)}xe()}}function h(){Promise.all(n.map(e=>function(e){let t=Kt;null===t&&function(){throw new Error("https://svelte.dev/e/async_derived_orphan")}();var n=void 0,r=Qe(B),i=!Bt,o=new Set;return function(e){_t(j|I,e)}(()=>{var l=Kt,a=f();n=a.promise;try{Promise.resolve(e()).then(a.resolve,e=>{e!==F&&a.reject(e)}).finally(xe)}catch(e){a.reject(e),xe()}var s=Le;if(i){if(0!==(l.f&x))var u=Se();if(t.b?.is_rendered())s.async_deriveds.get(l)?.reject(Me);else for(const e of o.values())e.reject(Me);o.add(a),s.async_deriveds.set(l,a)}const c=(e,t=void 0)=>{u?.(),o.delete(a),t!==Me&&(s.activate(),t?(r.f|=C,nt(r,t)):(0!==(r.f&C)&&(r.f^=C),nt(r,e)),s.deactivate())};a.promise.then(c,e=>c(null,e||"unknown"))}),St(()=>{for(const e of o)e.reject(Me)}),new Promise(e=>{!function t(i){function o(){i===n?e(r):t(n)}i.then(o,o)}(n)})}(e))).then(d).catch(e=>ue(e,a)).finally(c)}}function xe(e=!0){Yt(null),Vt(null),re(null),e&&Le?.deactivate()}function Se(){var e=Kt,t=e.b,n=Le,r=!!t?.is_rendered();return t?.update_pending_count(1,n),n.increment(r,e),()=>{t?.update_pending_count(-1,n),n.decrement(r,e)}}function ke(e){return null!==Kt&&(Kt.f|=I),{ctx:ne,deps:null,effects:null,equals:ee,f:2050,fn:e,reactions:null,rv:0,v:B,wv:0,parent:Kt,ac:null}}const Me=Symbol("obsolete");function Ie(e){const t=ke(e);return Gt(t),t}function Ae(e){const t=ke(e);return t.equals=te,t}function $e(e){var t,n=Kt,r=e.parent;if(!Ht&&null!==r&&e.v!==B&&24576&r.f)return console.warn("https://svelte.dev/e/derived_inert"),e.v;Yt(r);try{e.f&=~$,function(e){var t=e.effects;if(null!==t){e.effects=null;for(var n=0;n<t.length;n+=1)Wt(t[n])}}(e),t=sn(e)}finally{Yt(n)}return t}function Ee(e){var t=$e(e);e.equals(t)||(e.wv=on(),Le?.is_fork&&null!==e.deps||(null!==Le?(Le.capture(e,t,!0),We?.capture(e,t,!0)):e.v=t,null!==e.deps))?Ht||(null!==Oe?(xt()||Le?.is_fork)&&Oe.set(e,t):fe(e)):de(e,m)}function je(e){if(null!==e.effects)for(const t of e.effects)t.teardown&&null!==t.fn&&dn(t)}let Ce=null,ze=null,Le=null,We=null,Oe=null,Pe=null,Te=!1,Ne=null,De=null;var Fe=0;new Set;let Re=1;class He{id=Re++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;#r=new Set;#i=new Set;#o=0;#l=new Map;#a=null;#s=[];#u=[];#c=new Set;#d=new Set;#f=new Map;#h=new Set;is_fork=!1;#v=!1;constructor(){null===ze?Ce=ze=this:(ze.#n=this,this.#t=ze),ze=this}#p(){if(this.is_fork)return!0;for(const n of this.#l.keys()){for(var e=n,t=!1;null!==e.parent;){if(this.#f.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#h.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){for(var r of(this.#f.delete(e),n.d))de(r,w),t(r);for(r of n.m)de(r,y),t(r)}this.#h.add(e)}#w(){this.#e=!0,Fe++>1e3&&(this.#_(),function(){try{!function(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}()}catch(e){ue(e,Pe)}}());for(const e of this.#c)this.#d.delete(e),de(e,w),this.schedule(e);for(const e of this.#d)de(e,y),this.schedule(e);const e=this.#s;this.#s=[],this.apply();var t=Ne=[],n=[],r=De=[];for(const r of e)try{this.#g(r,t,n)}catch(e){throw Ze(r),this.#p()||this.discard(),e}if(Le=null,r.length>0){var i=He.ensure();for(const e of r)i.schedule(e)}if(Ne=null,De=null,this.#p()){this.#y(n),this.#y(t);for(const[e,t]of this.#f)Ye(e,t);return void(r.length>0&&Le.#w())}const o=this.#b();if(o)return this.#y(n),this.#y(t),void o.#m(this);this.#c.clear(),this.#d.clear();for(const e of this.#r)e(this);this.#r.clear(),We=this,Be(n),Be(t),We=null,this.#a?.resolve();var l=Le;if(0===this.#o&&(0===this.#s.length||null!==l)&&this.#_(),this.#s.length>0)if(null!==l){const e=l;e.#s.push(...this.#s.filter(t=>!e.#s.includes(t)))}else l=this;null!==l&&(Xe.clear(),l.#w())}#g(e,t,n){e.f^=m;for(var r=e.first;null!==r;){var i=r.f,o=!!(96&i);if(!(o&&0!==(i&m)||0!==(i&b)||this.#f.has(r))&&null!==r.fn){o?r.f^=m:4&i?t.push(r):ln(r)&&(0!==(i&v)&&this.#d.add(r),dn(r));var l=r.first;if(null!==l){r=l;continue}}for(;null!==r;){var a=r.next;if(null!==a){r=a;break}r=r.parent}}}#b(){for(var e=this.#t;null!==e;){if(!e.is_fork)for(const[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e;e=e.#t}return null}#m(e){for(const[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(const[t,n]of e.async_deriveds){const e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}e.async_deriveds.clear(),this.transfer_effects(e.#c,e.#d);const t=e=>{var n=e.reactions;if(null!==n&&(!(2&e.f)||6144&e.f))for(const e of n){var r=e.f;if(2&r)t(e);else{var i=e;r&(j|v)&&!this.async_deriveds.has(i)&&(this.#d.delete(i),de(i,w),this.schedule(i))}}};for(const e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#_(),Le=this,this.#w()}#y(e){for(var t=0;t<e.length;t+=1)ve(e[t],this.#c,this.#d)}capture(e,t,n=!1){e.v!==B&&!this.previous.has(e)&&this.previous.set(e,e.v),0===(e.f&C)&&(this.current.set(e,[t,n]),Oe?.set(e,t)),this.is_fork||(e.v=t)}activate(){Le=this}deactivate(){Le=null,Oe=null}flush(){try{Te=!0,Le=this,this.#w()}finally{Fe=0,Pe=null,Ne=null,De=null,Te=!1,Le=null,Oe=null,Xe.clear()}}discard(){for(const e of this.#i)e(this);this.#i.clear();for(const e of this.async_deriveds.values())e.reject(Me);this.#_(),this.#a?.resolve()}register_created_effect(e){this.#u.push(e)}#x(){for(let c=Ce;null!==c;c=c.#n){var e=c.id<this.id,t=[];for(const[r,[i,o]]of this.current){if(c.current.has(r)){var n=c.current.get(r)[0];if(!e||i===n)continue;c.current.set(r,[i,o])}t.push(r)}if(e)for(const[e,t]of this.async_deriveds){const n=c.async_deriveds.get(e);n&&t.promise.then(n.resolve).catch(n.reject)}var r=[...c.current.keys()].filter(e=>!c.current.get(e)[1]);if(c.#e&&0!==r.length){var i=r.filter(e=>!this.current.has(e));if(0===i.length)e&&c.discard();else if(t.length>0){if(e)for(const e of this.#h)c.unskip_effect(e,e=>{0!==(e.f&(v|j))?c.schedule(e):c.#y([e])});c.activate();var o=new Set,l=new Map;for(var a of t)Ue(a,i,o,l);l=new Map;var s=[...c.current].filter(([e,t])=>{const n=this.current.get(e);return!n||n[0]!==t[0]||n[1]!==t[1]}).map(([e])=>e);if(s.length>0)for(const e of this.#u)!(155648&e.f)&&Ve(e,s,l)&&(0!==(e.f&(j|v))?(de(e,w),c.schedule(e)):c.#c.add(e));if(c.#s.length>0&&!c.#v){for(var u of(c.apply(),c.#s))c.#g(u,[],[]);c.#s=[]}c.deactivate()}}}}increment(e,t){if(this.#o+=1,e){let e=this.#l.get(t)??0;this.#l.set(t,e+1)}}decrement(e,t){if(this.#o-=1,e){let e=this.#l.get(t)??0;1===e?this.#l.delete(t):this.#l.set(t,e-1)}this.#v||(this.#v=!0,ae(()=>{this.#v=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(const t of e)this.#c.add(t);for(const e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#a??=f()).promise}static ensure(){if(null===Le){const e=Le=new He;Te||ae(()=>{e.#e||e.flush()})}return Le}apply(){Oe=null}schedule(e){if(Pe=e,e.b?.is_pending&&e.f&(12|h)&&0===(e.f&x))e.b.defer_effect(e);else{for(var t=e;null!==t.parent;){var n=(t=t.parent).f;if(!(null===Ne||t!==Kt||null!==Bt&&2&Bt.f))return;if(96&n){if(0===(n&m))return;t.f^=m}}this.#s.push(t)}}#_(){if(this.linked){var e=this.#t,t=this.#n;null===e?Ce=t:e.#n=t,null===t?ze=e:t.#t=e,this.linked=!1}}}let qe=null;function Be(e){var t=e.length;if(0!==t){for(var n=0;n<t;){var r=e[n++];if(!(24576&r.f)&&ln(r)&&(qe=new Set,dn(r),null===r.deps&&null===r.first&&null===r.nodes&&null===r.teardown&&null===r.ac&&Ot(r),qe?.size>0)){Xe.clear();for(const e of qe){if(24576&e.f)continue;const t=[e];let n=e.parent;for(;null!==n;)qe.has(n)&&(qe.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){const n=t[e];!(24576&n.f)&&dn(n)}}qe.clear()}}qe=null}}function Ue(e,t,n,r){if(!n.has(e)&&(n.add(e),null!==e.reactions))for(const i of e.reactions){const e=i.f;2&e?Ue(i,t,n,r):0!==(e&(j|v))&&0===(e&w)&&Ve(i,t,r)&&(de(i,w),Ke(i))}}function Ve(e,t,r){const i=r.get(e);if(void 0!==i)return i;if(null!==e.deps)for(const i of e.deps){if(n.call(t,i))return!0;if(2&i.f&&Ve(i,t,r))return r.set(i,!0),!0}return r.set(e,!1),!1}function Ke(e){Le.schedule(e)}function Ye(e,t){if(0===(e.f&p)||0===(e.f&m)){0!==(e.f&w)?t.d.push(e):0!==(e.f&y)&&t.m.push(e),de(e,m);for(var n=e.first;null!==n;)Ye(n,t),n=n.next}}function Ze(e){de(e,m);for(var t=e.first;null!==t;)Ze(t),t=t.next}let Ge=new Set;const Xe=new Map;let Je=!1;function Qe(e,t){return{f:0,v:e,reactions:null,equals:ee,rv:0,wv:0}}function et(e,t){const n=Qe(e);return Gt(n),n}function tt(e,t,n=!1){return null!==Bt&&(!Ut||0!==(Bt.f&M))&&4325394&Bt.f&&(null===Zt||!Zt.has(e))&&function(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}(),nt(e,n?lt(t):t,De)}function nt(e,t,n=null){if(!e.equals(t)){Ht?Xe.set(e,t):Xe.has(e)||Xe.set(e,e.v);var r=He.ensure();if(r.capture(e,t),2&e.f){const t=e;0!==(e.f&w)&&$e(t),null===Oe&&fe(t)}e.wv=on(),ot(e,w,n),null!==Kt&&0!==(Kt.f&m)&&!(96&Kt.f)&&(null===Qt?function(e){Qt=e}([e]):Qt.push(e)),!r.is_fork&&Ge.size>0&&!Je&&function(){Je=!1;for(const e of Ge){let t;0!==(e.f&m)&&de(e,y);try{t=ln(e)}catch{t=!0}t&&dn(e)}Ge.clear()}()}return t}function rt(e,t=1){var n=fn(e),r=1===t?n++:n--;return tt(e,n),r}function it(e){tt(e,e.v+1)}function ot(e,t,n){var r=e.reactions;if(null!==r)for(var i=r.length,o=0;o<i;o++){var l=r[o],a=l.f,s=0===(a&w);if(s&&de(l,t),0!==(a&M))Ge.add(l);else if(2&a){var u=l;Oe?.delete(u),0===(a&$)&&(a&g&&(null===Kt||0===(Kt.f&E))&&(l.f|=$),ot(u,y,n))}else if(s){var c=l;0!==(a&v)&&null!==qe&&qe.add(c),null!==n?n.push(c):Ke(c)}}}function lt(t){if("object"!=typeof t||null===t||z in t)return t;const n=u(t);if(n!==a&&n!==s)return t;var r=new Map,i=e(t),l=et(0),c=nn,d=e=>{if(nn===c)return e();var t=Bt,n=nn;Vt(null),rn(c);var r=e();return Vt(t),rn(n),r};return i&&r.set("length",et(t.length)),new Proxy(t,{defineProperty(e,t,n){(!("value"in n)||!1===n.configurable||!1===n.enumerable||!1===n.writable)&&function(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}();var i=r.get(t);return void 0===i?d(()=>{var e=et(n.value);return r.set(t,e),e}):tt(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(void 0===n){if(t in e){const e=d(()=>et(B));r.set(t,e),it(l)}}else tt(n,B),it(l);return!0},get(e,n,i){if(n===z)return t;var l=r.get(n),a=n in e;if(void 0===l&&(!a||o(e,n)?.writable)&&(l=d(()=>et(lt(a?e[n]:B))),r.set(n,l)),void 0!==l){var s=fn(l);return s===B?void 0:s}return Reflect.get(e,n,i)},getOwnPropertyDescriptor(e,t){var n=Reflect.getOwnPropertyDescriptor(e,t);if(n&&"value"in n){var i=r.get(t);i&&(n.value=fn(i))}else if(void 0===n){var o=r.get(t),l=o?.v;if(void 0!==o&&l!==B)return{enumerable:!0,configurable:!0,value:l,writable:!0}}return n},has(e,t){if(t===z)return!0;var n=r.get(t),i=void 0!==n&&n.v!==B||Reflect.has(e,t);return!((void 0!==n||null!==Kt&&(!i||o(e,t)?.writable))&&(void 0===n&&(n=d(()=>et(i?lt(e[t]):B)),r.set(t,n)),fn(n)===B))&&i},set(e,t,n,a){var s=r.get(t),u=t in e;if(i&&"length"===t)for(var c=n;c<s.v;c+=1){var f=r.get(c+"");void 0!==f?tt(f,B):c in e&&(f=d(()=>et(B)),r.set(c+"",f))}void 0===s?(!u||o(e,t)?.writable)&&(tt(s=d(()=>et(void 0)),lt(n)),r.set(t,s)):(u=s.v!==B,tt(s,d(()=>lt(n))));var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(a,n),!u){if(i&&"string"==typeof t){var v=r.get("length"),p=Number(t);Number.isInteger(p)&&p>=v.v&&tt(v,p+1)}it(l)}return!0},ownKeys(e){fn(l);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return void 0===t||t.v!==B});for(var[n,i]of r)i.v!==B&&!(n in e)&&t.push(n);return t},setPrototypeOf(){!function(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}()}})}function at(e){try{if(null!==e&&"object"==typeof e&&z in e)return e[z]}catch{}return e}function st(e,t){return Object.is(at(e),at(t))}var ut,ct,dt,ft;function ht(e=""){return document.createTextNode(e)}function vt(e){return dt.call(e)}function pt(e){return ft.call(e)}function gt(e,t){if(!K)return vt(e);var n=vt(V);if(null===n)n=V.appendChild(ht());else if(t&&3!==n.nodeType){var r=ht();return n?.before(r),Z(r),r}return t&&bt(n),Z(n),n}function mt(e,t=!1){if(!K){var n=vt(e);return n instanceof Comment&&""===n.data?pt(n):n}if(t){if(3!==V?.nodeType){var r=ht();return V?.before(r),Z(r),r}bt(V)}return V}function wt(e,t=1,n=!1){let r=K?V:e;for(var i;t--;)i=r,r=pt(r);if(!K)return r;if(n){if(3!==r?.nodeType){var o=ht();return null===r?i?.after(o):r.before(o),Z(o),o}bt(r)}return Z(r),r}function yt(e,t,n){return n?document.createElement(e,{is:n}):document.createElement(e)}function bt(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;null!==t&&3===t.nodeType;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function _t(e,t){var n=Kt;null!==n&&0!==(n.f&b)&&(e|=b);var r={ctx:ne,deps:null,nodes:null,f:e|w|g,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};Le?.register_created_effect(r);var i=r;if(4&e)null!==Ne?Ne.push(r):He.ensure().schedule(r);else if(null!==t){try{dn(r)}catch(e){throw Wt(r),e}null===i.deps&&null===i.teardown&&null===i.nodes&&i.first===i.last&&0===(i.f&I)&&(i=i.first,0!==(e&v)&&0!==(e&k)&&null!==i&&(i.f|=k))}if(null!==i&&(i.parent=n,null!==n&&function(e,t){var n=t.last;null===n?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}(i,n),null!==Bt&&2&Bt.f&&!(64&e))){var o=Bt;(o.effects??=[]).push(i)}return r}function xt(){return null!==Bt&&!Ut}function St(e){const t=_t(8,null);return de(t,m),t.teardown=e,t}function kt(e){null===Kt&&(null===Bt&&function(){throw new Error("https://svelte.dev/e/effect_orphan")}(),function(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}()),Ht&&function(){throw new Error("https://svelte.dev/e/effect_in_teardown")}();var t=Kt.f;if(Bt||0===(t&p)||null===ne||ne.i)return Mt(e);var n=ne;(n.e??=[]).push(e)}function Mt(e){return _t(1048580,e)}function It(e){return _t(4,e)}function At(e,t=0){return _t(8|t,e)}function $t(e,t=[],n=[],r=[]){_e(r,t,n,t=>{_t(8,()=>{e(...t.map(fn))})})}function Et(e,t=0){return _t(v|t,e)}function jt(e,t=0){return _t(h|t,e)}function Ct(e){return _t(p|I,e)}function zt(e){var t=e.teardown;if(null!==t){const e=Ht,n=Bt;qt(!0),Vt(null);try{t.call(null)}finally{qt(e),Vt(n)}}}function Lt(e,t=!1){var n=e.first;for(e.first=e.last=null;null!==n;){const e=n.ac;null!==e&&ye(()=>{e.abort(F)});var r=n.next;64&n.f?n.parent=null:Wt(n,t),n=r}}function Wt(e,t=!0){var n=!1;(t||!!(262144&e.f))&&null!==e.nodes&&null!==e.nodes.end&&(function(e,t){for(;null!==e;){var n=e===t?null:pt(e);e.remove(),e=n}}(e.nodes.start,e.nodes.end),n=!0),e.f|=S,Lt(e,t&&!n),cn(e,0);var r=e.nodes&&e.nodes.t;if(null!==r)for(const e of r)e.stop();zt(e),e.f^=S,e.f|=_;var i=e.parent;null!==i&&null!==i.first&&Ot(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Ot(e){var t=e.parent,n=e.prev,r=e.next;null!==n&&(n.next=r),null!==r&&(r.prev=n),null!==t&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function Pt(e,t,n=!0){var r=[];Tt(e,r,!0);var i=()=>{n&&Wt(e),t&&t()},o=r.length;if(o>0){var l=()=>--o||i();for(var a of r)a.out(l)}else i()}function Tt(e,t,n){if(0===(e.f&b)){e.f^=b;var r=e.nodes&&e.nodes.t;if(null!==r)for(const e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;null!==i;){var o=i.next;64&i.f||Tt(i,t,!(0===(i.f&k)&&(0===(i.f&p)||0===(e.f&v)))&&n),i=o}}}function Nt(e){Dt(e,!0)}function Dt(e,t){if(0!==(e.f&b)){e.f^=b,0===(e.f&m)&&(de(e,w),He.ensure().schedule(e));for(var n=e.first;null!==n;){var r=n.next;Dt(n,!(0===(n.f&k)&&0===(n.f&p))&&t),n=r}var i=e.nodes&&e.nodes.t;if(null!==i)for(const e of i)(e.is_global||t)&&e.in()}}function Ft(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;null!==n;){var i=n===r?null:pt(n);t.append(n),n=i}}let Rt=!1,Ht=!1;function qt(e){Ht=e}let Bt=null,Ut=!1;function Vt(e){Bt=e}let Kt=null;function Yt(e){Kt=e}let Zt=null;function Gt(e){null!==Bt&&(Zt??=new Set).add(e)}let Xt=null,Jt=0,Qt=null,en=1,tn=0,nn=tn;function rn(e){nn=e}function on(){return++en}function ln(e){var t=e.f;if(0!==(t&w))return!0;if(2&t&&(e.f&=~$),0!==(t&y)){for(var n=e.deps,r=n.length,i=0;i<r;i++){var o=n[i];if(ln(o)&&Ee(o),o.wv>e.wv)return!0}0!==(t&g)&&null===Oe&&de(e,m)}return!1}function an(e,t,n=!0){var r=e.reactions;if(null!==r&&(null===Zt||!Zt.has(e)))for(var i=0;i<r.length;i++){var o=r[i];2&o.f?an(o,t,!1):t===o&&(n?de(o,w):0!==(o.f&m)&&de(o,y),Ke(o))}}function sn(e){var t=Xt,n=Jt,r=Qt,i=Bt,o=Zt,l=ne,a=Ut,s=nn,u=e.f;Xt=null,Jt=0,Qt=null,Bt=96&u?null:e,Zt=null,re(e.ctx),Ut=!1,nn=++tn,null!==e.ac&&(ye(()=>{e.ac.abort(F)}),e.ac=null);try{e.f|=E;var c=(0,e.fn)();e.f|=x;var d=e.deps,f=Le?.is_fork;if(null!==Xt){var h;if(f||cn(e,Jt),null!==d&&Jt>0)for(d.length=Jt+Xt.length,h=0;h<Xt.length;h++)d[Jt+h]=Xt[h];else e.deps=d=Xt;if(xt()&&0!==(e.f&g))for(h=Jt;h<d.length;h++)(d[h].reactions??=[]).push(e)}else!f&&null!==d&&Jt<d.length&&(cn(e,Jt),d.length=Jt);if(!(null===Qt||Ut||null===d||6146&e.f))for(h=0;h<Qt.length;h++)an(Qt[h],e);if(null!==i&&i!==e){if(tn++,null!==i.deps)for(let e=0;e<n;e+=1)i.deps[e].rv=tn;if(null!==t)for(const e of t)e.rv=tn;null!==Qt&&(null===r?r=Qt:r.push(...Qt))}return 0!==(e.f&C)&&(e.f^=C),c}catch(e){return se(e)}finally{e.f^=E,Xt=t,Jt=n,Qt=r,Bt=i,Zt=o,re(l),Ut=a,nn=s}}function un(e,r){let i=r.reactions;if(null!==i){var o=t.call(i,e);if(-1!==o){var l=i.length-1;0===l?i=r.reactions=null:(i[o]=i[l],i.pop())}}if(null===i&&2&r.f&&(null===Xt||!n.call(Xt,r))){var a=r;0!==(a.f&g)&&(a.f^=g,a.f&=~$),a.v!==B&&fe(a),null!==a.ac&&ye(()=>{a.ac.abort(F),a.ac=null,de(a,w)}),function(e){if(null!==e.effects)for(const t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),null!==t.ac&&ye(()=>{t.ac.abort(F),t.ac=null}),null!==t.fn&&(t.teardown=d),cn(t,0),Lt(t))}(a),cn(a,0)}}function cn(e,t){var n=e.deps;if(null!==n)for(var r=t;r<n.length;r++)un(e,n[r])}function dn(e){var t=e.f;if(0===(t&_)){de(e,m);var n=Kt,r=Rt;Kt=e,Rt=!(96&t);try{0!==(t&(v|h))?function(e){for(var t=e.first;null!==t;){var n=t.next;0===(t.f&p)&&Wt(t),t=n}}(e):Lt(e),zt(e);var i=sn(e);e.teardown="function"==typeof i?i:null,e.wv=en}finally{Rt=r,Kt=n}}}function fn(e){var t=!!(2&e.f);if(null!==Bt&&!Ut&&!(null!==Kt&&0!==(Kt.f&_)||null!==Zt&&Zt.has(e))){var r=Bt.deps;if(0!==(Bt.f&E))e.rv<tn&&(e.rv=tn,null===Xt&&null!==r&&r[Jt]===e?Jt++:null===Xt?Xt=[e]:Xt.push(e));else{Bt.deps??=[],n.call(Bt.deps,e)||Bt.deps.push(e);var i=e.reactions;null===i?e.reactions=[Bt]:n.call(i,Bt)||i.push(Bt)}}if(Ht&&Xe.has(e))return Xe.get(e);if(t){var o=e;if(Ht){var l=o.v;return(0===(o.f&m)&&null!==o.reactions||vn(o))&&(l=$e(o)),Xe.set(o,l),l}var a=0===(o.f&g)&&!Ut&&null!==Bt&&(Rt||0!==(Bt.f&g)),s=0===(o.f&x);ln(o)&&(a&&(o.f|=g),Ee(o)),a&&!s&&(je(o),hn(o))}if(Oe?.has(e))return Oe.get(e);if(0!==(e.f&C))throw e.v;return e.v}function hn(e){if(e.f|=g,null!==e.deps)for(const t of e.deps)(t.reactions??=[]).push(e),2&t.f&&0===(t.f&g)&&(je(t),hn(t))}function vn(e){if(e.v===B)return!0;if(null===e.deps)return!1;for(const t of e.deps)if(Xe.has(t)||2&t.f&&vn(t))return!0;return!1}function pn(e){var t=Ut;try{return Ut=!0,e()}finally{Ut=t}}function gn(e){return e.endsWith("capture")&&"gotpointercapture"!==e&&"lostpointercapture"!==e}const mn=["beforeinput","click","change","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"];function wn(e){return mn.includes(e)}const yn={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 bn(e){return e=e.toLowerCase(),yn[e]??e}const _n=["touchstart","touchmove"];function xn(e){return _n.includes(e)}const Sn=Symbol("events"),kn=new Set,Mn=new Set;function In(e,t,n,r={}){function i(e){if(r.capture||Cn.call(t,e),!e.cancelBubble)return ye(()=>n?.call(this,e))}return e.startsWith("pointer")||e.startsWith("touch")||"wheel"===e?ae(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function An(e,t,n){(t[Sn]??={})[e]=n}function $n(e){for(var t=0;t<e.length;t++)kn.add(e[t]);for(var n of Mn)n(e)}let En=null,jn=!1;function Cn(e){var t=this,n=t.ownerDocument,r=e.type,o=e.composedPath?.()||[],l=o[0]||e.target;En=e,jn||(jn=!0,setTimeout(()=>{jn=!1,En=null}));var a=0,s=En===e&&e[Sn];if(s){var u=o.indexOf(s);if(-1!==u&&(t===document||t===window))return void(e[Sn]=t);var c=o.indexOf(t);if(-1===c)return;u<=c&&(a=u)}if((l=o[a]||e.target)!==t){i(e,"currentTarget",{configurable:!0,get:()=>l||n});var d=Bt,f=Kt;Vt(null),Yt(null);try{for(var h,v=[];null!==l&&l!==t;){try{var p=l[Sn]?.[r];null!=p&&(!l.disabled||e.target===l)&&p.call(l,e)}catch(e){h?v.push(e):h=e}if(e.cancelBubble)break;a++,l=a<o.length?o[a]:null}if(h){for(let e of v)queueMicrotask(()=>{throw e});throw h}}finally{e[Sn]=t,delete e.currentTarget,Vt(d),Yt(f)}}}const zn=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:e=>e});function Ln(e){return zn?.createHTML(e)??e}function Wn(e,t){var n=Kt;null===n.nodes&&(n.nodes={start:e,end:t,a:null,t:null})}function On(e,t){var n,r=!!(1&t),i=!!(2&t),o=!e.startsWith("<!>");return()=>{if(K)return Wn(V,null),V;void 0===n&&(n=function(e){var t=yt("template");return t.innerHTML=Ln(e.replaceAll("<!>","\x3c!----\x3e")),t.content}(o?e:"<!>"+e),r||(n=vt(n)));var t=i||ct?document.importNode(n,!0):n.cloneNode(!0);return r?Wn(vt(t),t.lastChild):Wn(t,t),t}}function Pn(){if(K)return Wn(V,null),V;var e=document.createDocumentFragment(),t=document.createComment(""),n=ht();return e.append(t,n),Wn(t,n),e}function Tn(e,t){if(K){var n=Kt;return(0===(n.f&x)||null===n.nodes.end)&&(n.nodes.end=V),void G()}null!==e&&e.before(t)}function Nn(e,t){var n=null==t?"":"object"==typeof t?`${t}`:t;n!==(e[N]??=e.nodeValue)&&(e[N]=n,e.nodeValue=`${n}`)}const Dn=new Map;let Fn=new WeakMap;class Rn{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;constructor(e,t=!0){this.anchor=e,this.#i=t}#o=e=>{if(this.#e.has(e)){var t=this.#e.get(e),n=this.#t.get(t);if(n)Nt(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(Nt(r.effect),this.#t.set(t,r.effect),this.#n.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(const[t,n]of this.#e){if(this.#e.delete(t),t===e)break;const r=this.#n.get(n);r&&(Wt(r.effect),this.#n.delete(n))}for(const[e,r]of this.#t){if(e===t||this.#r.has(e))continue;const i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=document.createDocumentFragment();Ft(r,t),t.append(ht()),this.#n.set(e,{effect:r,fragment:t})}else Wt(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Pt(r,i,!1)):i()}}};#l=e=>{this.#e.delete(e);const t=Array.from(this.#e.values());for(const[e,n]of this.#n)t.includes(e)||(Wt(n.effect),this.#n.delete(e))};ensure(e,t){var n=Le;!t||this.#t.has(e)||this.#n.has(e)||this.#t.set(e,Ct(()=>t(this.anchor))),this.#e.set(n,e),K&&(this.anchor=V),this.#o(n)}}function Hn(e,t,n=!1){var r;K&&(r=V,G());var i=new Rn(e);function o(e,t){if(K){var n=Q(r);if(e!==parseInt(n.substring(1))){var o=J();return Z(o),i.anchor=o,Y(!1),i.ensure(e,t),void Y(!0)}}i.ensure(e,t)}Et(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},n?k:0)}function qn(e,t){return t}function Bn(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(const t of e.pending.values())for(const n of t)r.add(e.items.get(n).e)}for(var i=0;i<t.length;i++){var o=t[i];r?.has(o)?(o.f|=A,Ft(o,document.createDocumentFragment())):Wt(t[i],n)}}var Un;function Vn(t,n,i,o,l,a=null){var s=t,u=new Map;if(4&n){var c=t;s=K?Z(vt(c)):c.appendChild(ht())}K&&G();var d,f=null,h=Ae(()=>{var t=i();return e(t)?t:null==t?[]:r(t)}),v=new Map,p=!0,g={effect:Et(()=>{var e=(d=fn(h)).length;let t=!1;K&&Q(s)===H!=(0===e)&&(Z(s=J()),Y(!1),t=!0);for(var c=new Set,m=Le,w=0;w<e;w+=1){K&&8===V.nodeType&&"]"===V.data&&(s=V,t=!0,Y(!1));var y=d[w],x=o(y,w),S=p?null:u.get(x);S?(S.v&&nt(S.v,y),S.i&&nt(S.i,w)):(S=Yn(u,p?s:Un??=ht(),y,x,w,l,n,i),p||(S.e.f|=A),u.set(x,S)),c.add(x)}0===e&&a&&!f&&(p?f=Ct(()=>a(s)):(f=Ct(()=>a(Un??=ht()))).f|=A),e>c.size&&function(){throw new Error("https://svelte.dev/e/each_key_duplicate")}(),K&&e>0&&Z(J()),p||(v.set(m,c),function(e){0===(g.effect.f&_)&&(g.pending.delete(e),g.fallback=f,function(e,t,n,i,o){var l,a,s,u,c,d=!!(8&i),f=t.length,h=e.items,v=Kn(e.effect.first),p=null,g=[],m=[];if(d)for(c=0;c<f;c+=1)s=o(t[c],c),0===((u=h.get(s).e).f&A)&&(u.nodes?.a?.measure(),(a??=new Set).add(u));for(c=0;c<f;c+=1){if(s=o(t[c],c),u=h.get(s).e,null!==e.outrogroups)for(const t of e.outrogroups)t.pending.delete(u),t.done.delete(u);if(0!==(u.f&b)&&(Nt(u),d&&(u.nodes?.a?.unfix(),(a??=new Set).delete(u))),0!==(u.f&A)){if(u.f^=A,u!==v){var w=p?p.next:v;u===e.effect.last&&(e.effect.last=u.prev),u.prev&&(u.prev.next=u.next),u.next&&(u.next.prev=u.prev),Gn(e,p,u),Gn(e,u,w),Zn(u,w,n),g=[],m=[],v=Kn((p=u).next);continue}Zn(u,null,n)}if(u!==v){if(void 0!==l&&l.has(u)){if(g.length<m.length){var y,_=m[0];p=_.prev;var x=g[0],S=g[g.length-1];for(y=0;y<g.length;y+=1)Zn(g[y],_,n);for(y=0;y<m.length;y+=1)l.delete(m[y]);Gn(e,x.prev,S.next),Gn(e,p,x),Gn(e,S,_),v=_,p=S,c-=1,g=[],m=[]}else l.delete(u),Zn(u,v,n),Gn(e,u.prev,u.next),Gn(e,u,null===p?e.effect.first:p.next),Gn(e,p,u),p=u;continue}for(g=[],m=[];null!==v&&v!==u;)(l??=new Set).add(v),m.push(v),v=Kn(v.next);if(null===v)continue}0===(u.f&A)&&g.push(u),p=u,v=Kn(u.next)}if(null!==e.outrogroups){for(const t of e.outrogroups)0===t.pending.size&&(Bn(e,r(t.done)),e.outrogroups?.delete(t));0===e.outrogroups.size&&(e.outrogroups=null)}if(null!==v||void 0!==l){var k=[];if(void 0!==l)for(u of l)0===(u.f&b)&&k.push(u);for(;null!==v;)0===(v.f&b)&&v!==e.fallback&&k.push(v),v=Kn(v.next);var M=k.length;if(M>0){var I=4&i&&0===f?n:null;if(d){for(c=0;c<M;c+=1)k[c].nodes?.a?.measure();for(c=0;c<M;c+=1)k[c].nodes?.a?.fix()}!function(e,t,n){for(var i,o=t.length,l=t.length,a=0;a<o;a++){let n=t[a];Pt(n,()=>{if(i){if(i.pending.delete(n),i.done.add(n),0===i.pending.size){var t=e.outrogroups;Bn(e,r(i.done)),t.delete(i),0===t.size&&(e.outrogroups=null)}}else l-=1},!1)}if(0===l){var s=null!==n&&0===e.pending.size;if(s){var u=n,c=u.parentNode;(function(e){e.textContent=""})(c),c.append(u),e.items.clear()}Bn(e,t,!s)}else i={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(i)}(e,k,I)}}d&&ae(()=>{if(void 0!==a)for(u of a)u.nodes?.a?.apply()})}(g,d,s,n,o),null!==f&&(0===d.length?0===(f.f&A)?Nt(f):(f.f^=A,Zn(f,null,s)):Pt(f,()=>{f=null})))}(m)),t&&Y(!0),fn(h)}),items:u,pending:v,outrogroups:null,fallback:f};p=!1,K&&(s=V)}function Kn(e){for(;null!==e&&0===(e.f&p);)e=e.next;return e}function Yn(e,t,n,r,i,o,l,a){var s=1&l?16&l?Qe(n):function(e,t=!1){const n=Qe(e);return t||(n.equals=te),n}(n,!1):null,u=2&l?Qe(i):null;return{v:s,i:u,e:Ct(()=>(o(t,s??n,u??i,a),()=>{e.delete(r)}))}}function Zn(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,o=t&&0===(t.f&A)?t.nodes.start:n;null!==r;){var l=pt(r);if(o.before(r),r===i)return;r=l}}function Gn(e,t,n){null===t?e.effect.first=n:t.next=n,null===n?e.effect.last=t:n.prev=t}function Xn(e,t,...n){var r=new Rn(e);Et(()=>{const e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},k)}function Jn(e,t){var n,r=void 0;jt(()=>{r!==(r=t())&&(n&&(Wt(n),n=null),r&&(n=Ct(()=>{It(()=>r(e))})))})}function Qn(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Qn(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}const er=[..." \t\n\r\f \v\ufeff"];function tr(e,t=!1){var n=t?" !important;":";",r="";for(var i of Object.keys(e)){var o=e[i];null!=o&&""!==o&&(r+=" "+i+": "+o+n)}return r}function nr(e){return"-"!==e[0]||"-"!==e[1]?e.toLowerCase():e}function rr(e,t,n,r,i,o){var l=e[P];if(K||l!==n||void 0===l){var a=function(e,t,n){var r=null==e?"":""+e;if(t&&(r=r?r+" "+t:t),n)for(var i of Object.keys(n))if(n[i])r=r?r+" "+i:i;else if(r.length)for(var o=i.length,l=0;(l=r.indexOf(i,l))>=0;){var a=l+o;0!==l&&!er.includes(r[l-1])||a!==r.length&&!er.includes(r[a])?l=a:r=(0===l?"":r.substring(0,l))+r.substring(a+1)}return""===r?null:r}(n,r,o);(!K||a!==e.getAttribute("class"))&&(null==a?e.removeAttribute("class"):t?e.className=a:e.setAttribute("class",a)),e[P]=n}else if(o&&i!==o)for(var s in o){var u=!!o[s];(null==i||u!==!!i[s])&&e.classList.toggle(s,u)}return o}function ir(e,t={},n,r){for(var i in n){var o=n[i];t[i]!==o&&(null==n[i]?e.style.removeProperty(i):e.style.setProperty(i,o,r))}}function or(e,t,n,r){var i=e[T];if(K||i!==t){var o=function(e,t){if(t){var n,r,i="";if(Array.isArray(t)?(n=t[0],r=t[1]):n=t,e){e=String(e).replaceAll(/\/\*.*?\*\//g,"").trim();var o=!1,l=0,a=!1,s=[];n&&s.push(...Object.keys(n).map(nr)),r&&s.push(...Object.keys(r).map(nr));var u=0,c=-1;const t=e.length;for(var d=0;d<t;d++){var f=e[d];if(a?"/"===f&&"*"===e[d-1]&&(a=!1):o?o===f&&(o=!1):"/"===f&&"*"===e[d+1]?a=!0:'"'===f||"'"===f?o=f:"("===f?l++:")"===f&&l--,!a&&!1===o&&0===l)if(":"===f&&-1===c)c=d;else if(";"===f||d===t-1){if(-1!==c){var h=nr(e.substring(u,c).trim());s.includes(h)||(";"!==f&&d++,i+=" "+e.substring(u,d).trim()+";")}u=d+1,c=-1}}}return n&&(i+=tr(n)),r&&(i+=tr(r,!0)),""===(i=i.trim())?null:i}return null==e?null:String(e)}(t,r);(!K||o!==e.getAttribute("style"))&&(null==o?e.removeAttribute("style"):e.style.cssText=o),e[T]=t}else r&&(Array.isArray(r)?(ir(e,n?.[0],r[0]),ir(e,n?.[1],r[1],"important")):ir(e,n,r));return r}function lr(t,n,r=!1){if(t.multiple){if(null==n)return;if(!e(n))return void console.warn("https://svelte.dev/e/select_multiple_invalid_value");for(var i of t.options)i.selected=n.includes(sr(i))}else{for(i of t.options)if(st(sr(i),n))return void(i.selected=!0);(!r||void 0!==n)&&(t.selectedIndex=-1)}}function ar(e){var t=new MutationObserver(()=>{"__value"in e&&lr(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),St(()=>{t.disconnect()})}function sr(e){return"__value"in e?e.__value:e.value}const ur=Symbol("class"),cr=Symbol("style"),dr=Symbol("is custom element"),fr=Symbol("is html"),hr=R?"link":"LINK",vr=R?"input":"INPUT",pr=R?"option":"OPTION",gr=R?"select":"SELECT";function mr(e,t){t?e.hasAttribute("selected")||e.setAttribute("selected",""):e.removeAttribute("selected")}function wr(e,t,n,r){var i=br(e);K&&(i[t]=e.getAttribute(t),"src"===t||"srcset"===t||"href"===t&&e.nodeName===hr)||i[t]!==(i[t]=n)&&("loading"===t&&(e[W]=n),null==n?e.removeAttribute(t):"string"!=typeof n&&xr(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function yr(e,t,n=[],r=[],i=[],o,l=!1,a=!1){_e(i,n,r,n=>{var r=void 0,i={},s=e.nodeName===gr,u=!1;if(jt(()=>{var c=t(...n.map(fn)),d=function(e,t,n,r,i=!1){if(K&&i&&e.nodeName===vr){var o=e;("checkbox"===o.type?"defaultChecked":"defaultValue")in n||function(e){if(K){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute("value")){var n=e.value;wr(e,"value",null),e.value=n}if(e.hasAttribute("checked")){var r=e.checked;wr(e,"checked",null),e.checked=r}}};e[D]=n,ae(n),we()}}(o)}var l=br(e),a=l[dr],s=!l[fr];let u=K&&a;u&&Y(!1);var c=t||{},d=e.nodeName===pr;for(var f in t)!(f in n)&&f[0]+f[1]!=="$$"&&(n[f]=null);n.class?n.class=function(e){return"object"==typeof e?function(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Qn(e))&&(r&&(r+=" "),r+=t);return r}(e):e??""}(n.class):(r||n[ur])&&(n.class=null),n[cr]&&(n.style??=null);var h=xr(e);if(e.nodeName===vr&&"type"in n&&("value"in n||"__value"in n)){var v=n.type;(v!==c.type||void 0===v&&e.hasAttribute("type"))&&(c.type=v,wr(e,"type",v))}for(const i in n){let o=n[i];if(d&&"value"===i&&null==o)e.value=e.__value="",c[i]=o;else if("class"!==i)if("style"!==i){var p=c[i];if(o!==p||void 0===o&&e.hasAttribute(i)){c[i]=o;var g=i[0]+i[1];if("$$"!==g)if("on"===g){const t={},n="$$"+i;let r=i.slice(2);var m=wn(r);if(gn(r)&&(r=r.slice(0,-7),t.capture=!0),!m&&p){if(null!=o)continue;e.removeEventListener(r,c[n],t),c[n]=null}if(m)An(r,e,o),$n([r]);else if(null!=o){let o=function(e){c[i].call(this,e)};c[n]=In(r,e,o,t)}}else if("style"===i)wr(e,i,o);else if("autofocus"===i)ge(e,!!o);else if(a||"__value"!==i&&("value"!==i||null==o))if("selected"===i&&d)mr(e,o);else{var w=i;s||(w=bn(w));var y="defaultValue"===w||"defaultChecked"===w;if(null!=o||a||y)y||h.includes(w)&&(a||"string"!=typeof o)?(e[w]=o,w in l&&(l[w]=B)):"function"!=typeof o&&wr(e,w,o);else if(l[i]=null,"value"===w||"checked"===w){let n=e;const r=void 0===t;if("value"===w){let e=n.defaultValue;n.removeAttribute(w),n.defaultValue=e,n.value=n.__value=r?e:null}else{let e=n.defaultChecked;n.removeAttribute(w),n.defaultChecked=e,n.checked=!!r&&e}}else e.removeAttribute(i)}else e.value=e.__value=o}}else or(e,o,t?.[cr],n[cr]),c[i]=o,c[cr]=n[cr];else rr(e,"http://www.w3.org/1999/xhtml"===e.namespaceURI,o,r,t?.[ur],n[ur]),c[i]=o,c[ur]=n[ur]}return u&&Y(!0),c}(e,r,c,o,l,a);u&&s&&"value"in c&&lr(e,c.value);for(let e of Object.getOwnPropertySymbols(i))c[e]||Wt(i[e]);for(let t of Object.getOwnPropertySymbols(c)){var f=c[t];"@attach"===t.description&&(!r||f!==r[t])&&(i[t]&&Wt(i[t]),i[t]=Ct(()=>Jn(e,()=>f))),d[t]=f}r=d}),s){var c=e;It(()=>{lr(c,r.value,!0),ar(c)})}u=!0})}function br(e){return e[O]??={[dr]:e.nodeName.includes("-"),[fr]:"http://www.w3.org/1999/xhtml"===e.namespaceURI}}var _r=new Map;function xr(e){var t=e.getAttribute("is")||e.nodeName,n=_r.get(t);if(n)return n;_r.set(t,n=[]);for(var r,i=e,o=Element.prototype;o!==i;){for(var a in r=l(i))r[a].set&&"innerHTML"!==a&&"textContent"!==a&&"innerText"!==a&&n.push(a);i=u(i)}return n}let Sr=null;function kr(e,t){return e===t||e?.[z]===t}function Mr(e={},t,n,r){var i=ne.r,o=Kt;return It(()=>{var r,l;return At(()=>{r=l,l=[],pn(()=>{kr(n(...l),e)||(t(e,...l),r&&kr(n(...r),e)&&t(null,...r))})}),()=>{let r=o;for(;r!==i&&null!==r.parent&&r.parent.f&S;)r=r.parent;const a=r.teardown;r.teardown=()=>{l&&kr(n(...l),e)&&t(null,...l),a?.()}}}),e}const Ir={get(e,t){if(!e.exclude.has(t))return e.props[t]},set:(e,t)=>!1,getOwnPropertyDescriptor(e,t){if(!e.exclude.has(t)&&t in e.props)return{enumerable:!0,configurable:!0,value:e.props[t]}},has:(e,t)=>!e.exclude.has(t)&&t in e.props,ownKeys:e=>Reflect.ownKeys(e.props).filter(t=>!e.exclude.has(t))};function Ar(e,t,n){return new Proxy({props:e,exclude:t},Ir)}function $r(e,t,n,r){var i=!!(8&n),l=!!(16&n),a=r,s=!0,u=void 0,c=()=>l?(u??=ke(r),fn(u)):(s&&(s=!1,a=l?pn(r):r),a);let d;if(i){var f=z in e||L in e;d=o(e,t)?.set??(f&&t in e?n=>e[t]=n:void 0)}var h,v,p=!1;if(i?[h,p]=function(e){var t=pe;try{return pe=!1,[e(),pe]}finally{pe=t}}(()=>e[t]):h=e[t],void 0===h&&void 0!==r&&(h=c(),d&&(function(){throw new Error("https://svelte.dev/e/props_invalid_value")}(),d(h))),v=()=>{var n=e[t];return void 0===n?c():(s=!0,n)},!(4&n))return v;if(d){var g=e.$$legacy;return function(e,t){return arguments.length>0?((!t||g||p)&&d(t?v():e),e):v()}}var m=!1,w=(1&n?ke:Ae)(()=>(m=!1,v()));i&&fn(w);var y=Kt;return function(e,t){if(arguments.length>0){const n=t?fn(w):i?lt(e):e;return tt(w,n),m=!0,void 0!==a&&(a=n),e}return Ht&&m||0!==(y.f&_)?w.v:fn(w)}}const Er=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-.]+))?(?:\+[0-9A-Za-z-.]+)?$/;function jr(e){const t=Er.exec(e.trim());if(!t)return null;const[,n,r,i,o]=t,l=o?o.split(".").map(e=>/^\d+$/.test(e)?Number(e):e):[];return{major:Number(n),minor:Number(r),patch:Number(i),prerelease:l}}function Cr(e,t){return e.major-t.major||e.minor-t.minor||e.patch-t.patch||function(e,t){if(0===e.prerelease.length&&0===t.prerelease.length)return 0;if(0===e.prerelease.length)return 1;if(0===t.prerelease.length)return-1;const n=Math.max(e.prerelease.length,t.prerelease.length);for(let r=0;r<n;r++){const n=e.prerelease[r],i=t.prerelease[r];if(void 0===n)return-1;if(void 0===i)return 1;if(n===i)continue;const o="number"==typeof n,l="number"==typeof i;return o&&l?n<i?-1:1:o?-1:l?1:String(n)<String(i)?-1:1}return 0}(e,t)}function zr(e,t){const n="string"==typeof t?t.trim():"",r=n.startsWith("^"),i=n.startsWith(">="),o=jr(r?n.slice(1):i?n.slice(2):n);if(!o)throw new Error(`Unsupported version range "${t}". A plugin declares an exact version ("1.2.3"), a caret range ("^1.2.3"), or a ">=" lower bound (">=1.2.3"); no other range syntax is supported.`);const l=jr(e);if(!l)return!1;const a=Cr(l,o);return i?a>=0:r?a>=0&&Cr(l,function(e){return e.major>0?{major:e.major+1,minor:0,patch:0,prerelease:[]}:e.minor>0?{major:0,minor:e.minor+1,patch:0,prerelease:[]}:{major:0,minor:0,patch:e.patch+1,prerelease:[]}}(o))<0:0===a}class Lr extends Error{code="PLUGIN_INCOMPATIBLE";pluginName;pluginVersion;constructor(e,t,n){super(`Plugin "${e}"@${t} cannot activate — incompatible with this viewer:\n`+n.map(e=>` - ${e}`).join("\n")+"\nUpdate the plugin or the core viewer so their declared ranges and capabilities overlap."),this.name="PluginCompatibilityError",this.pluginName=e,this.pluginVersion=t,Object.setPrototypeOf(this,Lr.prototype)}}function Wr(e){let t=!1;return()=>{t||(t=!0,e())}}const Or={deactivate(){}};class Pr extends Error{name="SvgIconError";constructor(e){super(`svgIcon: ${e}`)}}function Tr(e,t){if(!e)throw new Pr(t)}const Nr=/<svg\b[^>]*>/i,Dr=Symbol("triiiceratops:plugin-image-download"),Fr=function(){Tr(!0,"expected an SVG string.");const e='<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>'.trim();Tr(e.length>0,"received an empty string.");const t=Nr.exec(e);Tr(null!==t,"the markup must contain an <svg> root element."),Tr(!/<script[\s/>]/i.test(e),"<script> elements are not allowed in plugin icons."),Tr(!/<foreignObject[\s/>]/i.test(e),"<foreignObject> is not allowed in plugin icons."),Tr(!/\son[a-z]+\s*=/i.test(e),"on* event-handler attributes (e.g. onload, onclick) are not allowed in plugin icons.");for(const t of e.matchAll(/(?:xlink:)?href\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/gi)){const e=(t[1]??t[2]??t[3]??"").trim();Tr(e.startsWith("#"),`external href/xlink:href URLs are not allowed in plugin icons (found "${e}"); only internal "#id" references are.`)}const n=t[0],r=/\bviewBox\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(n);let i=(r?.[1]??r?.[2])?.trim();if(!i){const e=/\bwidth\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(n),t=/\bheight\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(n),r=parseFloat(e?.[1]??e?.[2]??""),o=parseFloat(t?.[1]??t?.[2]??"");i=Number.isFinite(r)&&Number.isFinite(o)?`0 0 ${r} ${o}`:"0 0 24 24"}let o="";if(!/\/\s*>$/.test(n)){const r=t.index+n.length,i=e.lastIndexOf("</svg>");o=(i>=r?e.slice(r,i):e.slice(r)).trim()}return{kind:"svg",inner:o,viewBox:i}}();typeof window<"u"&&((window.__svelte??={}).v??=new Set).add("5");var Rr=new Set(["$$slots","$$events","$$legacy","variant","size","circle","square","ghost","outline","active","class","style","children","element"]),Hr=On("<button><!></button>");let qr=0;var Br=new Set(["$$slots","$$events","$$legacy","value","size","ghost","class","style","children"]),Ur=On("<!>",1),Vr=On('<div role="option"> </div>'),Kr=On('<div><select><!></select> <button type="button" role="combobox" aria-haspopup="listbox"><span> </span></button> <div role="listbox" class="listbox svelte-1hwvamm" popover="manual" tabindex="-1"></div></div>');function Yr(e,t){ie(t,!0);let n=$r(t,"value",15),r=$r(t,"size",3,"md"),i=$r(t,"ghost",3,!1),o=$r(t,"class",3,""),l=$r(t,"style",3,""),a=Ar(t,Br);const s={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=Ie(()=>`--size:${s[r()]};${l()}`);const c="tri-listbox-"+qr++;let f=et(null),h=et(null),v=et(null),p=et(lt([])),g=et(!1),m=et(-1),w=Ie(()=>!!t.disabled),y=Ie(()=>null==n()?"":String(n())),b=Ie(()=>fn(p).find(e=>e.value===fn(y))??fn(p)[0]);function _(){fn(f)&&tt(p,Array.from(fn(f).querySelectorAll("option")).map(e=>({value:e.value,label:(e.textContent??"").trim(),disabled:e.disabled})),!0)}function x(e){const t=fn(p)[e];!fn(f)||!t||t.disabled||(fn(f).value=t.value,fn(f).dispatchEvent(new Event("input",{bubbles:!0})),fn(f).dispatchEvent(new Event("change",{bubbles:!0})),A())}function S(){if(!fn(h)||!fn(v))return;const e=fn(h).getBoundingClientRect();fn(v).style.minWidth=`${e.width}px`,fn(v).style.left=`${e.left}px`;const t=fn(v).offsetHeight,n=window.innerHeight-e.bottom;n<t&&e.top>n?fn(v).style.top=`${Math.max(4,e.top-t-4)}px`:fn(v).style.top=`${e.bottom+4}px`}function k(){fn(v)?.children[fn(m)]?.scrollIntoView({block:"nearest"})}function M(e){const t=e.composedPath();fn(h)&&t.includes(fn(h))||fn(v)&&t.includes(fn(v))||A()}function I(){fn(w)||fn(g)||!fn(v)||(tt(g,!0),fn(v).showPopover(),S(),tt(m,fn(p).findIndex(e=>e.value===fn(y)),!0),fn(m)<0&&tt(m,fn(p).findIndex(e=>!e.disabled),!0),k(),window.addEventListener("scroll",S,!0),window.addEventListener("resize",S),document.addEventListener("pointerdown",M,!0))}function A(){fn(g)&&(tt(g,!1),fn(v)?.hidePopover(),window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S),document.removeEventListener("pointerdown",M,!0),fn(h)?.focus())}function $(e){if(!fn(p).length)return;let t=fn(m);for(let n=0;n<fn(p).length;n++)if(t=(t+e+fn(p).length)%fn(p).length,!fn(p)[t]?.disabled)return tt(m,t,!0),void k()}function E(e){const t="start"===e?fn(p).map((e,t)=>t):fn(p).map((e,t)=>fn(p).length-1-t);for(const e of t)if(!fn(p)[e]?.disabled)return tt(m,e,!0),void k()}kt(()=>{if(!fn(f))return;_();const e=new MutationObserver(()=>_());return e.observe(fn(f),{childList:!0,subtree:!0,characterData:!0,attributes:!0}),()=>e.disconnect()});let j,C="";var z=Kr(),L=gt(z);yr(L,()=>({class:"native-select",tabindex:"-1","aria-hidden":"true",...a}),void 0,void 0,void 0,"svelte-1hwvamm"),function(e,t){var n=K;(function(){if(null===Sr){var e=yt("select");e.innerHTML=Ln("<option><span>t</span></option>"),Sr=1===e.firstChild?.firstChild?.nodeType}return Sr})()||(Y(!1),e.textContent="",e.append(function(e=""){return document.createComment(e)}("")));try{t()}finally{n&&(K?X(e):(Y(!0),Z(e)))}}(L,()=>{var e=gt(L),n=Ur();Xn(mt(n),()=>t.children??d),Tn(e,n)}),Mr(L,e=>tt(f,e),()=>fn(f));var W=wt(L,2);let O;var P=gt(W);let T;var N=gt(P,!0);X(P),X(W),Mr(W,e=>tt(h,e),()=>fn(h));var F=wt(W,2);Vn(F,23,()=>fn(p),(e,t)=>e.value+"\0"+t,(e,t,n)=>{var r=Vr();let i;var o=gt(r,!0);X(r),$t(()=>{wr(r,"id",`${c}-opt-${fn(n)??""}`),i=rr(r,1,"option svelte-1hwvamm",null,i,{active:fn(n)===fn(m),selected:fn(t).value===fn(y)}),wr(r,"aria-selected",fn(t).value===fn(y)),wr(r,"aria-disabled",fn(t).disabled),Nn(o,fn(t).label)}),An("click",r,()=>x(fn(n))),An("pointermove",r,()=>tt(m,fn(n),!0)),Tn(e,r)}),X(F),Mr(F,e=>tt(v,e),()=>fn(v)),X(z),$t(()=>{rr(z,1,`select-wrapper ${o()??""}`,"svelte-1hwvamm"),or(z,l()),O=rr(W,1,"select svelte-1hwvamm",null,O,{ghost:i(),open:fn(g)}),or(W,fn(u)),W.disabled=fn(w),wr(W,"aria-expanded",fn(g)),wr(W,"aria-controls",c),wr(W,"aria-activedescendant",fn(g)&&fn(m)>=0?`${c}-opt-${fn(m)}`:void 0),wr(W,"aria-label",a["aria-label"]),T=rr(P,1,"select-label svelte-1hwvamm",null,T,{placeholder:fn(b)?.disabled}),Nn(N,fn(b)?.label??""),wr(F,"id",c)}),function(e,t,n=t){var r=new WeakSet,i=!0;(function(e,t,n,r=n){e.addEventListener(t,()=>ye(n));const i=e[D];e[D]=i?()=>{i(),r(!0)}:()=>r(!0),we()})(e,"change",t=>{var i,o=t?"[selected]":":checked";if(e.multiple)i=[].map.call(e.querySelectorAll(o),sr);else{var l=e.querySelector(o)??e.querySelector("option:not([disabled])");i=l&&sr(l)}n(i),e.__value=i,null!==Le&&r.add(Le)}),It(()=>{var o=t();if(e===document.activeElement){var l=Le;if(r.has(l))return}if(lr(e,o,i),i&&void 0===o){var a=e.querySelector(":checked");null!==a&&(o=sr(a),n(o))}e.__value=o,i=!1}),ar(e)}(L,n),An("click",W,function(){fn(g)?A():I()}),An("keydown",W,function(e){if(!fn(w)){if(!fn(g))return void(["ArrowDown","ArrowUp","Enter"," "].includes(e.key)&&(e.preventDefault(),I()));switch(e.key){case"ArrowDown":e.preventDefault(),$(1);break;case"ArrowUp":e.preventDefault(),$(-1);break;case"Home":e.preventDefault(),E("start");break;case"End":e.preventDefault(),E("end");break;case"Enter":case" ":e.preventDefault(),fn(m)>=0&&x(fn(m));break;case"Escape":e.preventDefault(),A();break;case"Tab":A();break;default:1===e.key.length&&!e.metaKey&&!e.ctrlKey&&function(e){C+=e.toLowerCase(),clearTimeout(j),j=setTimeout(()=>C="",600);const t=fn(p).findIndex(e=>!e.disabled&&e.label.toLowerCase().startsWith(C));t>=0&&(tt(m,t,!0),k())}(e.key)}}}),Tn(e,z),oe()}function Zr(e){return e?.id||e?.["@id"]||null}function Gr(e){return Zr(e)||""}function Xr(e){return Array.isArray(e)?e:e?[e]:[]}$n(["click","keydown","pointermove"]);const Jr=new WeakSet;function Qr(e){if(!e)return[];const t=Xr(e.images).filter(e=>!!e);if(t.length>0)return t;const n=Xr(e.items??e.content).flatMap(e=>Xr(e?.items).filter(e=>!!e));return 0===n.length&&function(e){!e||"object"!=typeof e||Jr.has(e)||(Jr.add(e),Zr(e),["images","items","content"].filter(t=>void 0!==e[t]))}(e),n}function ei(e){return Xr(e).map(e=>{const t=String(e).trim().toLowerCase(),n=t.split(/[#/:]/);return n[n.length-1]||t})}function ti(e){const t=function(e){return[ei(e?.behavior),ei(e?.viewingHint)].find(e=>e.length>0)??[]}(e);return t.includes("non-paged")||t.includes("facing-pages")}function ni(e,t){return function(e,t){if(!e)return[];if("string"==typeof e)return[e];if("object"==typeof e&&!Array.isArray(e)){const n=e;if("@value"in n){const e=n["@value"];return Array.isArray(e)?e.map(String):void 0===e?[]:[String(e)]}const r=Object.keys(n),i=e=>{const t=n[e];if(void 0!==t)return Array.isArray(t)?t.map(String):[String(t)]};if(t){const e=i(t);if(e)return e}for(const e of["en","none"]){const t=i(e);if(t)return t}return r.length>0?i(r[0])??[]:[]}if(Array.isArray(e)&&e.length>0){if("string"==typeof e[0])return e;const n=e,r=e=>n.filter(t=>t["@language"]===e).map(e=>e["@value"]??"");if(t){const e=r(t);if(e.length)return e}const i=r("en");if(i.length)return i;const o=n.filter(e=>!e["@language"]).map(e=>e["@value"]??"");return o.length?o:n.map(e=>e["@value"]??"")}return[String(e)]}(e,t).find(Boolean)??""}function ri(e,t,n){const r=void 0===t?"Untitled canvas":`Canvas ${t+1}`,i=e?.label;if(i){const e=ni(i,n);if(e)return e}return r}function ii(e){return e.endsWith("/info.json")?e.slice(0,-10):e}function oi(e,t,n="default",r="jpg",i="full"){return`${ii(e)}/${i}/${t}/0/${n}.${r}`}function li(e){return"string"==typeof e?/^https?:\/\/iiif\.io\/api\/image\//.test(e)||"level0"===e||"level1"===e||"level2"===e:!!Array.isArray(e)&&e.some(e=>li(e))}function ai(e){const t=Xr(e?.service);return t.length&&t.find(e=>{const t=e?.type||e?.["@type"]||"";return"ImageService1"===t||"ImageService2"===t||"ImageService3"===t||li(e?.profile||"")})||null}function si(e){return"SpecificResource"===e?.type&&null!=e&&e.source?e.source:e}function ui(e){const t=si(e);if(!t||"object"!=typeof t)return!1;const n=t,r=n.type??n["@type"];if("Image"===r||"dctypes:Image"===r)return!0;const i=n.format;return!!("string"==typeof i&&i.startsWith("image/")||null!==ai(t))||void 0===r&&void 0===i}function ci(e,t){return Xr(function(e){return e?.body||e?.resource||null}(e)).map(e=>function(e){if(!e||Array.isArray(e))return!1;const t=e.type||e["@type"];return"Choice"===t||"oa:Choice"===t}(e)?function(e,t){const n=function(e){return e?[...Xr(e.default),...Xr(e.items||e.item)].filter(e=>!!e):[]}(e);return(t?n.find(e=>Zr(e)===t):null)||n[0]||null}(e,t):e).filter(e=>null!=e)}function di(e){if(!e)return null;const t=e.match(/xywh=(?:pixel:)?([\d.]+),([\d.]+),([\d.]+),([\d.]+)/);return t?[Number(t[1]),Number(t[2]),Number(t[3]),Number(t[4])]:null}function fi(e){const[t]=e.split("#");return t||null}function hi(e){if(!e)return null;if("string"==typeof e)return e;if(Array.isArray(e)){for(const t of e){const e=hi(t);if(e)return e}return null}if("object"!=typeof e)return null;const t=e,n=Zr(t);return"string"==typeof n?n:t.source?hi(t.source):null}function vi(e){if(!e)return[];if(Array.isArray(e))return e.flatMap(e=>vi(e));if("object"!=typeof e)return[];const t=e;return t.item?vi(t.item):[t]}function pi(e){if(!e)return[];if(Array.isArray(e))return e.flatMap(e=>pi(e));const t=hi(e),n="object"==typeof e&&e&&"selector"in e?vi(e.selector):[],r=function(e){const t=e.find(e=>"FragmentSelector"===e?.type&&"string"==typeof e?.value&&e.value.includes("xywh="));if(t)return di(t.value);const n=e.find(e=>"string"==typeof e?.value&&e.value.includes("xywh="));return n?di(n.value):null}(n)||(t?di(t):null);return[{raw:e,targetId:t,canvasId:t?fi(t):null,selectors:n,xywh:r}]}function gi(e){return"number"==typeof e&&Number.isFinite(e)&&e>0}function mi(e){return gi(e)?e:null}function wi(e){return"string"==typeof e?e||null:Array.isArray(e)&&e.find(e=>"string"==typeof e)||null}function yi(e,t){for(const n of[e,t]){if(!n)continue;const e=n.label;if(e){const t=ni(e);if(t)return t}}return null}function bi(e,t={}){const n=Gr(e);if(!n)return[];const r=function(e){const t=e?.width||null,n=e?.height||null;return"number"!=typeof t||"number"!=typeof n?null:{width:t,height:n}}(e)??t.fallbackCanvasDimensions??null;if(!r)return[];const i=Qr(e);return i.length?i.map(e=>{var i;const o=function(e,t){for(const n of ci(e,t))if(ui(n))return n;return null}(e,null==(i=t.getSelectedChoice)?void 0:i.call(t,n)),l=si(o);if(!l)return null;const a=Zr(l),s=function(e){return{width:mi(e?.width),height:mi(e?.height)}}(l),u=function(e){const t=ai(e),n=Zr(t),r=t?t.profile||"":null;return{serviceId:n?ii(n):null,serviceProfile:wi(r)}}(l),c=u.serviceId||function(e){if(!e||!e.includes("/iiif/"))return null;const t=e.split("/"),n=t.findIndex(e=>"full"===e||/^\d+,\d+,\d+,\d+$/.test(e));return n>0?t.slice(0,n).join("/"):null}(a),d=function(e){var t;return function(e){return e?{x:e[0],y:e[1],width:e[2],height:e[3]}:null}(null==(t=pi(e?.target??e?.on).find(e=>e.xywh))?void 0:t.xywh)}(e),f=function(e,t){var n;return function(e,t){if("string"!=typeof e||!e.trim())return null;const n=e.trim(),r=n.startsWith("pct:"),i=(r?n.slice(4):n).split(",").map(e=>Number(e.trim()));return 4!==i.length||i.some(e=>!Number.isFinite(e)||e<0)?null:r?"number"!=typeof t.width||"number"!=typeof t.height?null:{x:i[0]/100*t.width,y:i[1]/100*t.height,width:i[2]/100*t.width,height:i[3]/100*t.height}:{x:i[0],y:i[1],width:i[2],height:i[3]}}("ImageApiSelector"===(null==(n=e?.selector)?void 0:n.type)?e.selector.region:null,t)}(o,s);return{canvasId:n,annotation:e,resource:l,resourceId:a,label:yi(l,e),canvasWidth:r.width,canvasHeight:r.height,resourceWidth:f?.width||s.width,resourceHeight:f?.height||s.height,serviceId:c,serviceProfile:u.serviceProfile,imageApiRegion:f,x:d?d.x/r.width:0,y:d?d.y/r.width:0,width:d?d.width/r.width:1,height:d?d.height/r.width:r.height/r.width}}).filter(e=>null!==e):[]}function _i(e){if("string"==typeof e)return e.toLowerCase();if(Array.isArray(e)){for(const t of e){const e=_i(t);if(e)return e}return null}if(e&&"object"==typeof e){const t=e;for(const e of["value","id","@id"])if("string"==typeof t[e])return t[e].toLowerCase()}return null}function xi(e){const t=_i(e);if(!t)return null;const n=t.replace(/[?#].*$/,"");for(const e of[0,1,2])if(t===`level${e}`||n.endsWith(`/level${e}.json`)||t.endsWith(`#level${e}`))return e;return null}function Si(e){return 0===xi(e)}function ki(e,t){return Math.max(e,t)}function Mi(e){if("string"==typeof e)return e;if(Array.isArray(e))for(const t of e)if("string"==typeof t)return t;return null}function Ii(e){return gi(e)?Math.floor(e):null}function Ai(e){const t=Mi(e["@context"])??"";return t.includes("/image/3/")?3:t.includes("/image/2/")?2:"ImageService3"===e.type?3:"iiif:Image"===e["@type"]||(Mi(e.profile)??"").includes("/image/2/")?2:3}function $i(e){return"number"!=typeof e||!Number.isFinite(e)||e<1?null:Math.floor(e)}function Ei(e,t,n,r){const i=e.tileSize*t.scaleFactor,o=n*i,l=r*i;return{x:o,y:l,width:Math.min(i,e.width-o),height:Math.min(i,e.height-l)}}function ji(e,t,n,r){return function(e,t,n,r){const i=function(e,t,n,r){const i=Ei(e,t,n,r);return{isWholeImage:0===i.x&&0===i.y&&i.width===e.width&&i.height===e.height,region:`${i.x},${i.y},${i.width},${i.height}`,width:Math.max(1,Math.ceil(i.width/t.scaleFactor)),height:Math.max(1,Math.ceil(i.height/t.scaleFactor))}}(e,t,n,r),o=function(e,t,n){return"widthHeight"===e.sizeForm?`${n.width},${n.height}`:"wholeImage"===e.sizeForm?function(e,t,n){return t?3===n?"max":"full":`${e},`}(t.width,function(e,t){return 2===e.version?t.width===e.width:t.width===e.width&&t.height===e.height}(e,t),e.version):`${n.isWholeImage?function(e,t){const n=e.wholeImageWidths;if(!n||0===n.length)return t;let r=n[0];for(const e of n)Math.abs(e-t)<Math.abs(r-t)&&(r=e);return r}(e,n.width):n.width},`}(e,t,i);return"wholeImage"===e.sizeForm?function(e,t,n,r){const i=oi(e,t,"default",n);return 2!==r?{url:i,fallback:null}:{url:i,fallback:{url:oi(e,t,"native",n),group:e}}}(e.serviceId,o,e.format,e.version):{url:oi(e.serviceId,o,"default",e.format,i.isWholeImage?"full":i.region),fallback:i.isWholeImage&&"widthHeight"===e.sizeForm?{url:oi(e.serviceId,o,"default",e.format,i.region),group:e.serviceId}:null}}(e,t,n,r).url}const Ci=8e3,zi=4e7;async function Li(e,t){const n=await fetch(e,t);if(!n.ok)throw new Error(`Image request failed with ${n.status}.`);return n.blob()}const Wi=/failed to fetch|networkerror|load failed|cross-origin|cors/i;async function Oi(e){const t=URL.createObjectURL(e);try{return await new Promise((e,n)=>{const r=new Image;r.onload=()=>e(r),r.onerror=()=>n(new Error("Unable to decode image for export.")),r.src=t})}finally{URL.revokeObjectURL(t)}}async function Pi(e,t,n,r="image/png"){const i=document.createElement("canvas");i.width=Math.max(1,Math.round(t)),i.height=Math.max(1,Math.round(n));const o=i.getContext("2d");if(!o)throw new Error("Unable to create a canvas for image export.");for(const t of e){const e=await Oi(t.blob);o.drawImage(e,t.x,t.y,t.width,t.height)}return new Promise((e,t)=>{i.toBlob(n=>{n?e(n):t(new Error("Unable to export composed image."))},r)})}function Ti(e,t){let n=1;e>Ci&&(n=Math.min(n,Ci/e)),t>Ci&&(n=Math.min(n,Ci/t));const r=e*t;return r*n*n>zi&&(n=Math.min(n,Math.sqrt(zi/r))),n>=1?{width:Math.round(e),height:Math.round(t),clamped:!1}:{width:Math.max(1,Math.round(e*n)),height:Math.max(1,Math.round(t*n)),clamped:!0}}function Ni(e,t={}){if(Si(e.serviceProfile))return e.resourceId??null;if(e.serviceId){const n=e.imageApiRegion?function(e){return[e.x,e.y,e.width,e.height].map(e=>Math.round(e)).join(",")}(e.imageApiRegion):void 0,r=!(!t.width&&!t.height);return function(e,t={width:1600}){const n="number"==typeof t.width?Math.max(1,Math.round(t.width)):null,r="number"==typeof t.height?Math.max(1,Math.round(t.height)):null;return oi(e,t.size||(n?`${n},`:`,${r||1600}`),t.quality||"default",t.format||"jpg",t.region||"full")}(e.serviceId,{region:n,size:r?void 0:"max",width:t.width,height:t.height})}return e.resourceId??null}async function Di(e){if(!e.serviceId)return null;const t=e.serviceId.endsWith("/info.json")?e.serviceId.slice(0,-10):e.serviceId,n=await async function(e){try{const t=await fetch(`${e}/info.json`);return t.ok?function(e){if(!e||"object"!=typeof e)return null;const t=e,n=Ii(t.width),r=Ii(t.height);if(!n||!r)return null;const i={width:n,height:r,version:Ai(t)},o=Mi(Zr(t));o&&(i.requestBaseUri=o),Si(t.profile)&&(i.level0=!0);const l=Array.isArray(t.tiles)?t.tiles[0]:null;if(l&&"object"==typeof l){const e=l,t=Ii(e.width);t&&(i.tileSize=t);const n=Array.isArray(e.scaleFactors)?e.scaleFactors.filter(e=>gi(e)&&e>=1):[];n.length>0&&(i.scaleFactors=n)}if(Array.isArray(t.sizes)){const e=t.sizes.map(e=>{if(!e||"object"!=typeof e)return null;const t=e,n=Ii(t.width),r=Ii(t.height);return n&&r?{width:n,height:r}:null}).filter(e=>!!e);e.length>0&&(i.sizes=e)}const a=Array.isArray(t.preferredFormats)?Mi(t.preferredFormats):null;return a&&(i.format=a),i}(await t.json()):null}catch{return null}}(t);if(!n)return null;const r=function(e,t){if(t.regionsUntrusted)return null;const n=$i(t.tileSize)??(t.level0?null:$i(void 0));if(!(n&&t.width>0&&t.height>0))return null;const r=function(e,t){const n=(e.scaleFactors??[]).filter(e=>Number.isFinite(e)&&e>=1),r=n.length>0?[...new Set(n)]:[];if(0===r.length){let n=1;for(r.push(n);Math.ceil(e.width/n)>t||Math.ceil(e.height/n)>t;)n*=2,r.push(n)}const i=r.filter(t=>Math.floor(e.width/t)>=1&&Math.floor(e.height/t)>=1);return(i.length>0?i:[1]).sort((e,t)=>t-e)}(t,n).map((e,r)=>({level:r,scaleFactor:e,width:Math.ceil(t.width/e),height:Math.ceil(t.height/e),columns:Math.ceil(t.width/(n*e)),rows:Math.ceil(t.height/(n*e))}));return{serviceId:t.requestBaseUri??e,width:t.width,height:t.height,tileSize:n,levels:r,version:2===t.version?2:3,format:t.format||"jpg",sizeForm:t.level0&&2!==t.version?"widthHeight":"width",wholeImageWidths:t.level0?[...new Set((t.sizes??[]).map(e=>e.width).filter(e=>e>0))].sort((e,t)=>e-t):null}}(t,n),i=r?function(e){return{...e,tileSize:ki(e.width,e.height),levels:e.levels.map(e=>({...e,columns:1,rows:1})),sizeForm:"wholeImage",wholeImageWidths:null}}(r):function(e,t){if(!(t.width>0&&t.height>0))return null;const n=function(e){const t=new Set,n=[];for(const r of e.sizes??[]){if(!(r?.width>0)||!(r?.height>0)||r.width>e.width||r.height>e.height)continue;const i=`${r.width}x${r.height}`;t.has(i)||(t.add(i),n.push({width:r.width,height:r.height}))}return n.sort((e,t)=>e.width-t.width)}(t),r=(n.length>0?n:[{width:t.width,height:t.height}]).map((e,n)=>({level:n,width:e.width,height:e.height,scaleFactor:t.width/e.width,columns:1,rows:1}));return{serviceId:t.requestBaseUri??e,width:t.width,height:t.height,tileSize:ki(t.width,t.height),levels:r,version:2===t.version?2:3,format:t.format||"jpg",sizeForm:"wholeImage",wholeImageWidths:null}}(t,n);return i?{ladder:i,pyramid:r}:null}function Fi({ladder:e,pyramid:t},n){return t?n.width===e.width&&n.height===e.height?ji(e,n,0,0):null:ji(e,n,0,0)}function Ri(e,t){return e<=Ci&&t<=Ci&&e*t<=zi}function Hi(e,t,n){return!!Fi(e,t)||!!n&&Ri(t.width,t.height)}async function qi(e,t={}){const{imageRequest:n}=t;if(t.url)return Li(t.url,n);if(Si(e.serviceProfile)){const r=await Di(e);if(r)return async function(e,t,n,r){const{ladder:i,pyramid:o}=e,l=function(e,t){const n=e.levels,r=n[n.length-1];return t?n.find(e=>e.width>=t)??r:r}(i,t),a=Fi(e,l);if(a)return Li(a,r);const s=o?.levels[l.level];return s&&Ri(l.width,l.height)?async function(e,t,n,r){const i=[];for(let n=0;n<t.rows;n+=1)for(let o=0;o<t.columns;o+=1){const l=Ei(e,t,o,n);i.push({blob:await Li(ji(e,t,o,n),r),x:o*e.tileSize,y:n*e.tileSize,width:Math.max(1,Math.ceil(l.width/t.scaleFactor)),height:Math.max(1,Math.ceil(l.height/t.scaleFactor))})}return Pi(i,t.width,t.height,n)}(o,s,n,r):Li(ji(i,i.levels[i.levels.length-1],0,0),r)}(r,t.width,t.format??("png"===r.ladder.format?"image/png":"image/jpeg"),n)}const r=Ni(e,{width:t.width,height:t.height});if(!r)throw new Error("No exportable image found for this canvas.");return Li(r,n)}const Bi=[{fraction:1,label:"Original"},{fraction:.5,label:"50%"},{fraction:.25,label:"25%"}];function Ui(e,t,n){return Bi.map(({fraction:r,label:i})=>{const o=Math.max(1,Math.round(e*r)),l=Math.max(1,Math.round(t*r)),a=n?.({width:o,height:l,isOriginal:1===r});return{width:o,height:l,label:`${i} (${o} × ${l}px)`,url:a??void 0}}).filter(e=>!n||!!e.url)}function Vi(e){return gi(e)?e:null}function Ki(e){const t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==0?(t[n-1]+t[n])/2:t[n]}const Yi={name:"@triiiceratops/plugin-image-export",version:"1.0.0"},Zi=(Gi=Yi,(e,t,n)=>function(e,t,n,r,i){const o={pluginName:t,pluginVersion:n,phase:"command",error:r,retry:i};e.dispatchEvent(new CustomEvent("pluginerror",{detail:o,bubbles:!0,composed:!0}))}(e,Gi.name,Gi.version,t,n));var Gi;function Xi(e,t){return bi(e,{getSelectedChoice:t})}function Ji(e){return function({canvases:e,currentCanvasId:t,currentCanvasIndex:n,viewingMode:r,pagedOffset:i}){if(!t)return[];if(n<0||n>=e.length)return[];const o=[],l=e[n];if(!l)return o;if("paged"!==r)return o.push({canvasId:t,canvas:l}),o;const a=function(e,t){const n=[];for(let r=0;r<Math.min(t,e.length);r++){const t=e[r],i=Gr(t);n.push({startIndex:r,endIndex:r,entries:i?[{canvasId:i,canvas:t}]:[]})}for(let r=t;r<e.length;){const t=e[r],i=Gr(t),o=e[r+1],l=Gr(o),a=!(!o||!i||!l||ti(t)||ti(o));n.push({startIndex:r,endIndex:a?r+1:r,entries:[...i?[{canvasId:i,canvas:t}]:[],...a?[{canvasId:l,canvas:o}]:[]]}),r+=a?2:1}return n}(e,i).find(({startIndex:e,endIndex:t})=>n>=e&&n<=t);return a?.entries??o}({canvases:e.canvases,currentCanvasId:e.canvasId,currentCanvasIndex:e.currentCanvasIndex,viewingMode:e.viewingMode,pagedOffset:e.pagedOffset}).map(e=>e.canvas).filter(t=>!function(e,t){return function(e,t){let n=!1;for(const r of Qr(e))for(const e of ci(r,t)){if(ui(e))return!1;n=!0}return n}(t,function(e,t){return"function"==typeof e?e(t):e?.getSelectedChoice(t)}(e,Gr(t)??""))}(e,t))}function Qi(e,t){const n=Ji(e);if(!n.length)return null;const r=n.flatMap((e,n)=>{const r=Gr(e)??`canvas-${n}`;return bi(e,{getSelectedChoice:t}).map(e=>({canvasId:r,x:e.x,y:e.y,width:e.width,sourceWidth:e.width,sourceHeight:e.height,tileSource:{resolved:e}}))});if(!r.length)return null;const{layouts:i,sources:o}=function(e,t){const n=function(e){const t=new Map;return e.forEach((e,n)=>{const r=e.canvasId??`canvas-${n}`,i=e.x??0,o=e.y??0,l=e.width??1,a=Vi(e.sourceWidth),s=Vi(e.sourceHeight),u=a&&s?l*s/a:null;let c=t.get(r);c||(c={canvasId:r,sources:[],width:0,height:null,canvasWidth:0,canvasHeight:null},t.set(r,c)),c.sources.push({index:n,localX:i,localY:o,localWidth:l}),c.width=Math.max(c.width,i+l),c.height=null===u?null:Math.max(c.height??0,o+u);const d=Vi(e.canvasBoxWidth)??i+l,f=Vi(e.canvasBoxHeight)??(null===u?null:o+u);c.canvasWidth=Math.max(c.canvasWidth,d),c.canvasHeight=null===f?null:Math.max(c.canvasHeight??0,f)}),[...t.values()]}(e),{layouts:r,scales:i}=function(e,t){if("individuals"===t.mode||e.length<=1)return function(e){return{layouts:e.map(e=>({canvasId:e.canvasId,x:0,y:0,width:e.width,height:e.height??1})),scales:e.map(()=>1)}}(e);const n=!t.preserveCanvasScale&&e.every(e=>null!==e.height),r=n?Ki(e.map(e=>e.height)):1,i=e.map(e=>{const t=n?function(e){return Math.min(4,Math.max(.25,e))}(r/e.height):1;return{group:e,scale:t,width:e.width*t,height:(e.height??1)*t,advanceWidth:e.canvasWidth*t,advanceHeight:(e.canvasHeight??1)*t,x:0,y:0}}),o="continuous"===t.mode&&("top-to-bottom"===t.direction||"bottom-to-top"===t.direction),l=function(e,t){return"number"==typeof e.gap?e.gap:"number"==typeof e.gapFraction&&t.length>0?e.gapFraction*Ki(t):.0125}(t,i.map(e=>o?e.advanceHeight:e.advanceWidth));if("continuous"===t.mode){let e=0;const n="right-to-left"===t.direction||"bottom-to-top"===t.direction;for(const t of i)o?(t.y=n?-e:e,e+=t.advanceHeight+l):(t.x=n?-e:e,e+=t.advanceWidth+l)}else if("paged"===t.mode){const e=Math.max(...i.map(e=>e.height)),n="right-to-left"===t.direction;i.forEach((t,r)=>{const o=n?i.slice(r+1):i.slice(0,r);t.x=o.reduce((e,t)=>e+t.advanceWidth+l,0),t.y=(e-t.height)/2})}return{layouts:i.map(e=>({canvasId:e.group.canvasId,x:e.x,y:e.y,width:e.width,height:e.height})),scales:i.map(e=>e.scale)}}(n,t);return{layouts:r,sources:n.flatMap((t,n)=>{const o=r[n],l=i[n];return t.sources.map(n=>({tileSource:e[n.index].tileSource,x:o.x+n.localX*l,y:o.y+n.localY*l,width:n.localWidth*l,canvasId:t.canvasId}))})}}(r,{mode:e.viewingMode,direction:e.viewingDirection,preserveCanvasScale:e.preserveCanvasScale});if(!i.length)return null;const l=Math.min(...i.map(e=>e.x)),a=Math.min(...i.map(e=>e.y)),s=Math.max(...i.map(e=>e.x+e.width)),u=Math.max(...i.map(e=>e.y+e.height));return{entries:o.map(e=>({resolved:e.tileSource.resolved,x:e.x-l,y:e.y-a,width:e.width})),worldWidth:s-l,worldHeight:u-a}}var eo=On("<option> </option>"),to=On("<!> <option> </option> <!>",1),no=On('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-mode"><span> </span></label> <!></div>'),ro=On('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-canvas"><span> </span></label> <!></div>'),io=On('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-image"><span> </span></label> <!></div>'),oo=On('<option disabled=""> </option> <!>',1),lo=On('<div class="tri-id-alert is-success" data-tri-id-result=""><span> </span></div>'),ao=On('<div class="tri-id-alert is-error" data-tri-id-error=""><span> </span></div>'),so=On('<div class="tri-id-alert"><span> </span></div>'),uo=On('<div class="tri-id-card"><div class="tri-id-card-body"><!> <!> <!></div></div>'),co=On('<span aria-hidden="true"></span> ',1),fo=On('<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 ho(e,t){ie(t,!0);const{context:n}=function(e){return function(e){return null===e&&function(){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}(),e.c??=new Map(function(e){let t=e.p;for(;null!==t&&null===t.c;)t=t.p;return t?.c??null}(e)||void 0)}(ne).get(e)}(Dr),{viewerState:r,selectors:i,locale:o,ui:l}=n;let a=et(0),s=et(0);i.select(e=>[e.canvasId,e.currentCanvasIndex,e.canvases,e.manifestId,e.viewingMode,e.viewingDirection,e.pagedOffset,e.preserveCanvasScale]).subscribe(()=>{rt(a)}),o.subscribe(()=>{rt(s)});const u=(e,t)=>(fn(s),o.t(e,t));let c=et("single"),f=et(0),h=et(0),v=et(lt([])),p=et(null),g=et(!1),m=et(!1),w=et(""),y=et(""),b=et(null);const _=e=>r.getSelectedChoice(e),x=Ie(()=>(fn(a),fn(s),ni(r.manifestEntry?.json?.label,o.current)||null)),S=Ie(()=>(fn(a),r.currentCanvasIndex>=0?r.canvases[r.currentCanvasIndex]??null:null)),k=Ie(()=>(fn(a),fn(S)?Xi(fn(S),_):[])),M=Ie(()=>fn(k).length>1),I=Ie(()=>fn(M)),A=Ie(()=>(fn(a),Ji(r))),$=Ie(()=>fn(A).length>1),E=Ie(()=>fn($)),j=Ie(()=>fn(I)||fn(E)),C=Ie(()=>(fn(a),"single"===fn(c)&&fn($)?fn(A)[fn(f)]??fn(S):fn(S))),z=Ie(()=>(fn(a),fn(C)?Xi(fn(C),_):[])),L=Ie(()=>fn(z).length>1),W=Ie(()=>null!==fn(p)?fn(v)[fn(p)]??null:null),O=Ie(()=>!(fn(m)||fn(g)||!fn(S)||!fn(W))),P=Ie(()=>(fn(s),fn(S)?fn(g)||fn(v).length?null:u("image_download_disabled_no_resolution"):u("image_download_disabled_no_canvas")));function T(e){const t=Number(e);return Number.isInteger(t)?t:0}kt(()=>{("composite"===fn(c)&&!fn(I)||"world"===fn(c)&&!fn(E))&&tt(c,"single")}),kt(()=>{fn(a);const e=r.canvasId,t=fn(A).findIndex(t=>Gr(t)===e);tt(f,t>=0?t:0,!0)}),kt(()=>{fn(C),tt(h,0)}),kt(()=>{const e=fn(S),t=fn(c),n=fn(h);let i=!1;if(tt(v,[],!0),tt(p,null),e){if("single"===t){const e=fn(z)[n];if(!e)return;tt(g,!0),function(e){return async function(e){if(Si(e.serviceProfile)){const t=await async function(e){const t=await Di(e);if(!t)return[];const{ladder:n,pyramid:r}=t,i=new Set,o=[];for(const e of n.levels){const n=`${e.width}x${e.height}`;i.has(n)||(i.add(n),Hi(t,e,r?.levels[e.level])&&o.push({width:e.width,height:e.height,label:`${e.width} × ${e.height}px`,url:Fi(t,e)??void 0}))}return o.sort((e,t)=>t.width-e.width)}(e);return t.length?t:e.resourceId?[{width:e.resourceWidth??0,height:e.resourceHeight??0,label:"Original",url:e.resourceId}]:[]}return function(e){const t=e.resourceWidth,n=e.resourceHeight;if(!e.serviceId||!t||!n){const r=Ni(e);return r?[{width:t??0,height:n??0,label:"Original",url:r}]:[]}return Ui(t,n,({width:t,height:n,isOriginal:r})=>Ni(e,r?{}:{width:t,height:n}))}(e)}(e)}(e).then(e=>{i||(tt(v,e,!0),tt(p,e.length?0:null,!0))}).finally(()=>{i||tt(g,!1)})}else if("composite"===t){const t=function(e,t){const n=bi(e,{getSelectedChoice:t})[0];return n?.canvasWidth&&n?.canvasHeight?Ui(n.canvasWidth,n.canvasHeight):[]}(e,_);tt(v,t,!0),tt(p,t.length?0:null,!0)}else{const e=function(e,t){const n=Qi(e,t);if(!n)return[];const r=n.entries[0],i=r?.resolved.resourceWidth&&r.width>0?r.resolved.resourceWidth/r.width:1600,o=Math.round(n.worldWidth*i),l=Math.round(n.worldHeight*i);return o&&l?Ui(o,l):[]}(r,_);tt(v,e,!0),tt(p,e.length?0:null,!0)}return()=>{i=!0}}});var N=fo(),D=gt(N),F=gt(D),R=gt(F,!0);X(F);var H=wt(F,2),q=gt(H),B=e=>{var t=no(),n=gt(t),r=gt(n),i=gt(r,!0);X(r),X(n);var o=wt(n,2);{let e=Ie(()=>u("image_download_mode"));Yr(o,{id:"tri-id-mode",class:"tri-id-field-select","data-tri-id-mode":!0,get"aria-label"(){return fn(e)},get disabled(){return fn(m)},get value(){return fn(c)},onchange:e=>{tt(c,e.currentTarget.value,!0)},children:(e,t)=>{var n=to(),r=mt(n),i=e=>{var t=eo(),n=gt(t,!0);X(t),t.value=t.__value="composite",$t(e=>Nn(n,e),[()=>u("image_download_mode_composite")]),Tn(e,t)};Hn(r,e=>{fn(I)&&e(i)});var o=wt(r,2),l=gt(o,!0);X(o),o.value=o.__value="single";var a=wt(o,2),s=e=>{var t=eo(),n=gt(t,!0);X(t),t.value=t.__value="world",$t(e=>Nn(n,e),[()=>u("image_download_mode_world")]),Tn(e,t)};Hn(a,e=>{fn(E)&&e(s)}),$t(e=>Nn(l,e),[()=>u("image_download_mode_single")]),Tn(e,n)},$$slots:{default:!0}})}X(t),$t(e=>Nn(i,e),[()=>u("image_download_mode")]),Tn(e,t)};Hn(q,e=>{fn(j)&&e(B)});var U=wt(q,2),V=e=>{var t=ro(),n=gt(t),r=gt(n),i=gt(r,!0);X(r),X(n);var o=wt(n,2);{let e=Ie(()=>u("image_download_canvas"));Yr(o,{id:"tri-id-canvas",class:"tri-id-field-select",get"aria-label"(){return fn(e)},get disabled(){return fn(m)},get value(){return fn(f)},onchange:e=>{tt(f,T(e.currentTarget.value),!0)},children:(e,t)=>{var n=Pn();Vn(mt(n),17,()=>fn(A),qn,(e,t,n)=>{var r=eo(),i=gt(r,!0);X(r),r.value=r.__value=n,$t(e=>Nn(i,e),[()=>ri(fn(t),n)]),Tn(e,r)}),Tn(e,n)},$$slots:{default:!0}})}X(t),$t(e=>Nn(i,e),[()=>u("image_download_canvas")]),Tn(e,t)};Hn(U,e=>{"single"===fn(c)&&fn($)&&e(V)});var K=wt(U,2),Y=e=>{var t=io(),n=gt(t),r=gt(n),i=gt(r,!0);X(r),X(n);var o=wt(n,2);{let e=Ie(()=>u("image_download_image"));Yr(o,{id:"tri-id-image",class:"tri-id-field-select",get"aria-label"(){return fn(e)},get disabled(){return fn(m)},get value(){return fn(h)},onchange:e=>{tt(h,T(e.currentTarget.value),!0)},children:(e,t)=>{var n=Pn();Vn(mt(n),17,()=>fn(z),qn,(e,t,n)=>{var r=eo(),i=gt(r,!0);X(r),r.value=r.__value=n,$t(e=>Nn(i,e),[()=>fn(t).label??`${u("image_download_image")} ${n+1}`]),Tn(e,r)}),Tn(e,n)},$$slots:{default:!0}})}X(t),$t(e=>Nn(i,e),[()=>u("image_download_image")]),Tn(e,t)};Hn(K,e=>{"single"===fn(c)&&fn(L)&&e(Y)});var Z=wt(K,2),G=gt(Z),J=gt(G),Q=gt(J,!0);X(J),X(G);var ee=wt(G,2);{let e=Ie(()=>u("image_download_resolution")),t=Ie(()=>fn(m)||fn(g)||!fn(v).length),n=Ie(()=>fn(p)??"");Yr(ee,{id:"tri-id-resolution",class:"tri-id-field-select","data-tri-id-resolution":!0,get"aria-label"(){return fn(e)},get disabled(){return fn(t)},get value(){return fn(n)},onchange:e=>{tt(p,T(e.currentTarget.value),!0)},children:(e,t)=>{var n=oo(),r=mt(n),i=gt(r,!0);X(r),r.value=r.__value="",Vn(wt(r,2),17,()=>fn(v),qn,(e,t,n)=>{var r=eo(),i=gt(r,!0);X(r),r.value=r.__value=n,$t(()=>Nn(i,fn(t).label)),Tn(e,r)}),$t(e=>Nn(i,e),[()=>u("image_download_resolution_placeholder")]),Tn(e,n)},$$slots:{default:!0}})}X(Z),X(H);var te=wt(H,2),re=e=>{var t=uo(),n=gt(t),r=gt(n),i=e=>{var t=lo(),n=gt(t),r=gt(n,!0);X(n),X(t),$t(()=>Nn(r,fn(y))),Tn(e,t)};Hn(r,e=>{fn(y)&&e(i)});var o=wt(r,2),l=e=>{var t=ao(),n=gt(t),r=gt(n,!0);X(n),X(t),$t(()=>Nn(r,fn(w))),Tn(e,t)};Hn(o,e=>{fn(w)&&e(l)});var a=wt(o,2),s=e=>{var t=so(),n=gt(t),r=gt(n,!0);X(n),X(t),$t(()=>Nn(r,fn(P))),Tn(e,t)};Hn(a,e=>{fn(P)&&e(s)}),X(n),X(t),Tn(e,t)};Hn(te,e=>{(fn(y)||fn(w)||fn(P))&&e(re)}),X(D);var le=wt(D,2),ae=gt(le);{let e=Ie(()=>!fn(O));!function(e,t){ie(t,!0);let n=$r(t,"variant",3,"default"),r=$r(t,"size",3,"md"),i=$r(t,"circle",3,!1),o=$r(t,"square",3,!1),l=$r(t,"ghost",3,!1),a=$r(t,"outline",3,!1),s=$r(t,"active",3,!1),u=$r(t,"class",3,""),c=$r(t,"style",3,""),f=$r(t,"element",15,null),h=Ar(t,Rr);const v={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);"},p={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 g=Ie(()=>`${p[r()]}${v[n()]}${c()}`);var m=Hr();yr(m,()=>({class:`btn ${u()??""}`,style:fn(g),...h,[ur]:{circle:i(),square:o(),ghost:l(),outline:a(),active:s()}}),void 0,void 0,void 0,"svelte-sgoebi"),Xn(gt(m),()=>t.children??d),X(m),Mr(m,e=>f(e),()=>f()),Tn(e,m),oe()}(ae,{variant:"primary",class:"tri-id-download","data-tri-id-download":!0,style:"width:100%",get disabled(){return fn(e)},onclick:async function e(){if(fn(S)&&fn(W)&&fn(O)){tt(m,!0),tt(w,""),tt(y,"");try{let e,t=fn(S);if("single"===fn(c)){t=fn(C);const n=fn(z)[fn(h)];if(!n)return;e=await async function(e,t){return qi(e,t)}(n,fn(W))}else e="composite"===fn(c)?await async function(e,t,n={}){const r=bi(e,{getSelectedChoice:n.getSelectedChoice}),i=r[0];if(!i)throw new Error("No exportable image found for this canvas.");const{canvasWidth:o,canvasHeight:l}=i;if(!o||!l)throw new Error("Unable to determine canvas dimensions for export.");const{width:a,height:s}=Ti(t.width,t.height),u=a/o,c=await Promise.all(r.map(async e=>async function(e,t,n,r){const i=function(e,t,n,r){const i=Math.max(1,Math.round(e.width*t*r)),o=e.resourceWidth&&e.resourceHeight?e.resourceHeight/e.resourceWidth:n/t;return{x:Math.round(e.x*t*r),y:Math.round(e.y*n*r),width:i,height:Math.max(1,Math.round(i*o))}}(e,t,n,r);return{blob:await qi(e,{width:i.width}),...i}}(e,o,l,u)));return Pi(c,a,s,n.format??"image/png")}(fn(S),fn(W),{getSelectedChoice:_}):await async function(e,t,n={}){const r=Qi(e,n.getSelectedChoice);if(!r)throw new Error("Nothing is currently displayed in the viewer.");const{width:i,height:o}=Ti(t.width,t.height),l=i/r.worldWidth;return Pi(await Promise.all(r.entries.map(async({resolved:e,x:t,y:n,width:r})=>{const i=Math.max(1,Math.round(r*l)),o=e.width>0&&e.height>0?e.height/e.width:1,a=Math.max(1,Math.round(i*o));return{blob:await qi(e,{width:i}),x:Math.round(t*l),y:Math.round(n*l),width:i,height:a}})),i,o,n.format??"image/png")}(r,fn(W),{getSelectedChoice:_});const n=function(e,t,n,r){const i="image/jpeg"===n?"jpg":"png",o=[r,e].map(e=>function(e){return e.replace(/[^a-z0-9-_]+/gi,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}(e??"")).filter(Boolean).join("-")||"image";return`${o}${"single"===t?"":`-${t}`}.${i}`}(ri(t,r.currentCanvasIndex,o.current),fn(c),"image/jpeg"===e.type?"image/jpeg":"image/png",fn(x));(function(e,t){const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)})(e,n),tt(y,u("image_download_result_downloaded",{filename:n}),!0)}catch(t){tt(w,function(e){if(!function(e){return typeof DOMException<"u"&&e instanceof DOMException&&"SecurityError"===e.name||e instanceof Error&&"TypeError"===e.name&&Wi.test(e.message)}(e))return u("image_download_error_failed");const t="single"===fn(c)?fn(z)[fn(h)]:fn(k)[0],n=t?function(e){const t=e.serviceId??e.resourceId;if(!t)return null;try{return new URL(t).host||null}catch{return null}}(t):null;return console.warn("[ImageDownload] The image server refused to let this page read the image, so it cannot be downloaded or composited here. That is the image server's cross-origin policy — no 'Access-Control-Allow-Origin' header on the image response — not a viewer error, and not something the viewer can change. The images still display because painting an image needs no such permission; reading its pixels back does.",{host:n,mode:fn(c),resolution:fn(W)?.label,error:e}),n?u("image_download_error_not_allowed",{host:n}):u("image_download_error_not_allowed_unknown_host")}(t),!0),fn(b)&&Zi(fn(b),t,()=>{e()})}finally{tt(m,!1)}}},children:(e,t)=>{var n=co(),r=mt(n);!function(e){It(()=>{var t=pn(()=>{return t=e,function(e){return{destroy:l.renderIcon(Fr,e)}}?.(t)||{};var t});if(t?.destroy)return()=>t.destroy()})}(r);var i=wt(r);$t(e=>Nn(i,` ${e??""}`),[()=>fn(m)?u("image_download_downloading"):u("image_download_download")]),Tn(e,n)},$$slots:{default:!0}})}X(le),X(N),Mr(N,e=>tt(b,e),()=>fn(b)),$t((e,t)=>{Nn(R,e),Nn(Q,t)},[()=>u("image_download_description"),()=>u("image_download_resolution")]),Tn(e,N),oe()}const{STYLES:vo,STYLE_ID:po}={STYLES:".tri-id{display: flex;flex-direction: column;min-height: 0;width: 100%;color: var(--panel-fg, var(--tri-panel-content, currentColor));}.tri-id-body{width: 100%;padding: 1rem;display: flex;flex-direction: column;gap: 1rem;}.tri-id-desc{font-size: 0.875rem;line-height: 1.25rem;margin: 0;color: color-mix(in oklab, var(--panel-fg, currentColor) 70%, transparent);}.tri-id-fields{display: grid;grid-template-columns: repeat(1, minmax(0, 1fr));gap: 0.75rem;}.tri-id-field{width: 100%;}.tri-id-label{display: inline-flex;align-items: center;gap: 0.375rem;margin-bottom: 0.25rem;white-space: nowrap;font-size: 0.75rem;color: color-mix(in oklab, currentColor 60%, transparent);}.tri-id-field-select{width: 100%;}.tri-id-card{display: flex;flex-direction: column;position: relative;border-radius: var(--tri-radius-panels, 0.75rem);border: 1px solid var(--tri-surface-border, rgb(0 0 0 / 0.15));background-color: var(--tri-input-bg, #fff);}.tri-id-card-body{display: flex;flex-direction: column;flex: auto;gap: 0.5rem;padding: 1rem;font-size: 0.875rem;}.tri-id-alert{--alert-color: var(--panel-fg, currentColor);display: grid;grid-auto-flow: column;grid-template-columns: auto;justify-content: start;place-items: center start;gap: 1rem;text-align: start;padding-block: 0.5rem;padding-inline: 1rem;font-size: 0.875rem;line-height: 1.25rem;border: 1px solid color-mix( in oklab, var(--alert-color) 10%, var(--tri-input-bg, transparent) );border-radius: var(--tri-radius-panels, 0.75rem);color: color-mix( in oklab, var(--alert-color) 45%, var(--panel-fg, currentColor) );background: color-mix( in oklab, var(--alert-color) 8%, var(--tri-input-bg, transparent) );box-shadow: none;}.tri-id-alert.is-success{--alert-color: var(--tri-color-success, #16a34a);}.tri-id-alert.is-error{--alert-color: var(--tri-color-error, #dc2626);}.tri-id-footer{width: 100%;padding: 1rem;border-top: 1px solid var(--tri-surface-border, rgb(0 0 0 / 0.15));}.tri-id-download svg{width: 1.125rem;height: 1.125rem;fill: currentColor;}",STYLE_ID:"panel"},go={mount(e,t){const n=t.styles.install(vo,po),i=t.styles.install(".btn.svelte-sgoebi{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-sgoebi:hover{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}}.btn.svelte-sgoebi:focus-visible{isolation:isolate;outline-width:2px;outline-style:solid}.btn.svelte-sgoebi: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-sgoebi{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}.btn.svelte-sgoebi:disabled,.btn[disabled].svelte-sgoebi{pointer-events:none;--btn-border: #0000;--btn-fg: color-mix(in oklch, var(--tri-content) 20%, #0000)}.btn.svelte-sgoebi:disabled:not(.ghost):not(.outline),.btn[disabled].svelte-sgoebi:not(.ghost):not(.outline){background-color:color-mix(in oklab,var(--tri-content) 10%,transparent);box-shadow:none}.circle.svelte-sgoebi{width:var(--size);height:var(--size);border-radius:3.40282e38px;padding-inline:0}.square.svelte-sgoebi{width:var(--size);height:var(--size);padding-inline:0}.ghost.svelte-sgoebi{--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-sgoebi:hover{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent)}}.ghost.svelte-sgoebi:active:not(.active),.ghost.active.svelte-sgoebi{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent);--btn-border: transparent}.outline.svelte-sgoebi: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-1hwvamm{display:inline-flex;width:clamp(3rem,20rem,100%);max-width:100%}.native-select.svelte-1hwvamm{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-1hwvamm{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-1hwvamm{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-label.placeholder.svelte-1hwvamm{color:color-mix(in oklab,var(--tri-content) 55%,transparent)}.select.svelte-1hwvamm:hover:not(:disabled){--input-color: color-mix(in oklab, var(--tri-content) 40%, #0000)}.select.svelte-1hwvamm:focus-visible,.select.open.svelte-1hwvamm{--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-1hwvamm:is(:where(.svelte-1hwvamm):disabled,[disabled]:where(.svelte-1hwvamm)){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-1hwvamm{box-shadow:none;background-color:#0000;border-color:#0000;transition:background-color .2s}.ghost.svelte-1hwvamm:hover:not(:disabled){background-color:color-mix(in oklab,var(--tri-content) 8%,transparent)}.ghost.svelte-1hwvamm:focus-visible,.ghost.open.svelte-1hwvamm{background-color:var(--tri-input-bg);color:var(--tri-content)}.listbox.svelte-1hwvamm{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-1hwvamm:not(:popover-open){display:none}.option.svelte-1hwvamm{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-1hwvamm{background-color:color-mix(in oklab,var(--tri-content) 12%,#0000)}.option.selected.svelte-1hwvamm{background-color:color-mix(in oklab,var(--tri-color-primary) 90%,#0000);color:var(--tri-color-primary-content)}.option.selected.active.svelte-1hwvamm{background-color:var(--tri-color-primary)}.option[aria-disabled=true].svelte-1hwvamm{opacity:.5;cursor:not-allowed;color:color-mix(in oklab,var(--tri-content) 55%,transparent)}\n","bundled"),l=function(e,t){return function(e,{target:t,anchor:n,props:i={},events:l,context:a,intro:s=!0,transformError:u}){!function(){if(void 0===ut){ut=window,ct=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;dt=o(t,"firstChild").get,ft=o(t,"nextSibling").get,c(e)&&(e[P]=void 0,e[O]=null,e[T]=void 0,e.__e=void 0),c(n)&&(n[N]=void 0)}}();var d=void 0,f=function(e){He.ensure();const t=_t(64|I,e);return(e={})=>new Promise(n=>{e.outro?Pt(t,()=>{Wt(t),n(void 0)}):(Wt(t),n(void 0))})}(()=>{var o=n??t.appendChild(ht());!function(e,t,n,r){new be(e,{pending:()=>{}},n,r)}(o,0,t=>{if(ie({}),a&&(ne.c=a),l&&(i.$$events=l),K&&Wn(t,null),d=e(t,i)||{},K&&(Kt.nodes.end=V,null===V||8!==V.nodeType||"]"!==V.data))throw U(),q;oe()},u);var s=new Set,c=e=>{for(var n=0;n<e.length;n++){var r=e[n];if(!s.has(r)){s.add(r);var i=xn(r);for(const e of[t,document]){var o=Dn.get(e);void 0===o&&(o=new Map,Dn.set(e,o));var l=o.get(r);void 0===l?(e.addEventListener(r,Cn,{passive:i}),o.set(r,1)):o.set(r,l+1)}}}};return c(r(kn)),Mn.add(c),()=>{for(var e of s)for(const n of[t,document]){var r=Dn.get(n),i=r.get(e);0==--i?(n.removeEventListener(e,Cn),r.delete(e),0===r.size&&Dn.delete(n)):r.set(e,i)}Mn.delete(c),o!==n&&o.parentNode?.removeChild(o)}});return Fn.set(d,f),d}(e,t)}(ho,{target:e,context:new Map([[Dr,{context:t}]])});return()=>{(function(e){const t=Fn.get(e);t?(Fn.delete(e),t(void 0)):Promise.resolve()})(l),i(),n()}}},mo=function(e){const t={name:e.name,title:e.title,uiId:e.uiId,version:e.version,coreRange:e.coreRange,pluginApiRange:e.pluginApiRange,requiredCapabilities:e.requiredCapabilities??[],icon:e.icon,target:e.target??"panel",fills:e.fills,dismiss:e.dismiss,catalog:e.catalog,view:e.view};return{kind:"triiiceratops-plugin",...t,activate:e=>function(e,t){const n=t.reportError;let r,i,o,l,a;try{(function(e,t){const n=[];zr(t.coreVersion,e.coreRange)||n.push(`requires core ${e.coreRange} but this viewer is core ${t.coreVersion}`),zr(t.pluginApiVersion,e.pluginApiRange)||n.push(`requires plugin API ${e.pluginApiRange} but this viewer provides plugin API ${t.pluginApiVersion}`);const r=new Set(t.capabilities);for(const i of e.requiredCapabilities)r.has(i)||n.push(`requires capability "${i}" which this viewer does not provide (has: ${t.capabilities.join(", ")||"none"})`);if(n.length>0)throw new Lr(e.name,e.version,n)})(e,t),r=function(e,t={}){let n=!1,r=0,i=0;const o=new Set,l=new Set;let a=null;const s=e=>{try{e()}catch(e){t.onListenerError&&t.onListenerError(e)}},u=()=>{i++;for(const e of[...l])s(e)},c=()=>{if((!n&&l.size>0&&!!e.subscribeFrame)!=(null!==a)){if(a)return a(),void(a=null);a=e.subscribeFrame?.(u)??null}},d=e.subscribe(()=>{r++;for(const e of[...o])s(e);for(const e of[...l])s(e)},t.onListenerError);function f(t,a={}){const s=a.equals??Object.is,u=a.cadence??"state",d="frame"===u?l:o;let f,h=-1,v=!1,p=null;const g=()=>"frame"===u?r+i:r,m=()=>{let n;try{n=t(e)}catch(e){return void(p={error:e})}if(v){let e;try{e=s(f,n)}catch(e){return void(p={error:e})}if(e)return void(p=null)}f=n,v=!0,p=null},w=()=>{if(p)throw p.error;return f};return{cadence:u,get version(){return g()},read(){const e=g();return(h!==e||"state"===u&&!1)&&(h=e,m()),w()},recompute:()=>(h=g(),m(),w()),subscribe:e=>n?()=>{}:(d.add(e),c(),Wr(()=>{d.delete(e),c()}))}}return{selectors:{select(e,r=Object.is){const i=f(e,{equals:r});return{get:()=>i.read(),subscribe(e){if(n)return()=>{};let o=i.read();return i.subscribe(()=>{let n;try{n=i.read()}catch(e){return void t.onProjectionError?.(e)}r(o,n)||(o=n,e(n))})}}}},createProjection:f,dispose:Wr(()=>{n=!0,o.clear(),l.clear(),c(),d()})}}(t.viewerState,{onProjectionError:e=>n({phase:"command",error:e}),onListenerError:e=>n({phase:"subscription",error:e})}),i=function(e){const t=new Set;return{service:{install(n,r){const i=e.install(n,r);let o=!1;const l=()=>{o||(o=!0,t.delete(l),i())};return t.add(l),l}},releaseAll(){for(const e of[...t])e();t.clear()}}}(t.styles),o=function(e){const t=new Set;return{service:{get current(){return e.current},t:(t,n)=>e.t(t,n),subscribe(n){const r=e.subscribe(n);let i=!1;const o=()=>{i||(i=!0,t.delete(o),r())};return t.add(o),o}},releaseAll(){for(const e of[...t])e();t.clear()}}}(t.locale),l=function(e,t){let n=null,r=!1;return{publish(i){r||(n?.(),n=e.publishPluginState(t,i))},releaseAll(){r=!0,n?.(),n=null}}}(t.viewerState,t.surface.id);const s=l.publish;a={viewerState:t.viewerState,selectors:r.selectors,surface:t.surface,styles:i.service,locale:o.service,ui:t.ui,publishState:s}}catch(e){return r?.dispose(),i?.releaseAll(),o?.releaseAll(),l?.releaseAll(),n({phase:"setup",error:e}),Or}const s=[],u=i,c=o,d=l,f=r;try{const n=e.view.mount(t.container,a);"function"==typeof n&&s.push(n)}catch(e){n({phase:"mount",error:e}),d.releaseAll()}s.push(()=>u.releaseAll()),s.push(()=>c.releaseAll()),s.push(()=>d.releaseAll()),s.push(()=>f.dispose());let h=!1;return{deactivate(){if(!h){h=!0;for(let e=s.length-1;e>=0;e--)try{s[e]?.()}catch(e){n({phase:"cleanup",error:e})}s.length=0}}}}(t,e)}}({name:Yi.name,title:"image_download_title",uiId:"image-download",version:Yi.version,coreRange:">=1.0.0-rc.0",pluginApiRange:"^1.0.0",requiredCapabilities:[],icon:Fr,target:"panel",catalog:{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.",image_download_error_not_allowed:"This image cannot be downloaded here: {host} does not permit downloads from other websites. Try viewing the image on its own site.",image_download_error_not_allowed_unknown_host:"This image cannot be downloaded here: the image server does not permit downloads from other websites. Try viewing the image on its own site."},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.",image_download_error_not_allowed:"Dieses Bild kann hier nicht heruntergeladen werden: {host} erlaubt keine Downloads von anderen Websites. Rufen Sie das Bild auf der Website des Anbieters auf.",image_download_error_not_allowed_unknown_host:"Dieses Bild kann hier nicht heruntergeladen werden: Der Bildserver erlaubt keine Downloads von anderen Websites. Rufen Sie das Bild auf der Website des Anbieters auf."}},view:go});function wo(){const e=new Map;return{register(t){const n=e.get(t.name);n?n.version!==t.version&&console.warn(`[triiiceratops] Ignoring plugin "${t.name}" version ${t.version}: version ${n.version} is already registered on this page and wins (first registration wins).`):e.set(t.name,t)},get:t=>e.get(t),has:t=>e.has(t),list:()=>[...e.values()]}}!function(e){(window.Triiiceratops??={coreVersion:"",pluginApiVersion:"",capabilities:[],plugins:wo()}).plugins.register(e)}(mo)}();
|