@atlas-viewer/atlas 3.1.0 → 3.1.1

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/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`@atlas-viewer/dna`),u=require(`node:crypto`),d=require(`react`);d=c(d);let f=require(`react/jsx-runtime`),p=require(`react-use-measure`);p=c(p);let m=require(`react-reconciler`);m=c(m);let h=require(`@atlas-viewer/iiif-image-api`),g=require(`@iiif/helpers/thumbnail`);const _=`onMouseDown.onMouseEnter.onMouseLeave.onMouseMove.onMouseOut.onMouseOver.onMouseUp.onTouchCancel.onTouchEnd.onTouchMove.onTouchStart.onPointerDown.onPointerMove.onPointerUp.onPointerCancel.onPointerEnter.onPointerLeave.onPointerOver.onPointerOut.onScroll.onWheel.onClick.onDragStart.onDragEnd.onDragEnter.onDragExit.onDrag.onDragOver.onContextMenu`.split(`.`);function v(){return _.reduce((e,t)=>(e[t]=[],e),{})}const y=_.reduce((e,t)=>(e[t.slice(2).toLowerCase()]=t,e[t]=t,e),{}),b=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,x=128;let S,C;function w(e){!S||S.length<e?(S=Buffer.allocUnsafe(e*128),u.webcrypto.getRandomValues(S),C=0):C+e>S.length&&(u.webcrypto.getRandomValues(S),C=0),C+=e}function T(e=21){w(e-=0);let t=``;for(let n=C-e;n<C;n++)t+=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`[S[n]&63];return t}function E(e){"@babel/helpers - typeof";return E=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},E(e)}function D(e,t){if(E(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(E(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ee(e){var t=D(e,`string`);return E(t)==`symbol`?t:t+``}function O(e,t,n){return(t=ee(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var k=class{get crop(){return this._crop}set crop(e){this._crop=e}getObjectsAt(e){return[]}getAllPointsAt(e,t,n){return[]}getScheduledUpdates(e,t){return[]}constructor(){O(this,`__id`,void 0),O(this,`__revision`,0),O(this,`__host`,void 0),O(this,`__onCreate`,void 0),O(this,`__parent`,void 0),O(this,`__owner`,{value:void 0}),O(this,`__state`,{}),O(this,`eventHandlers`,void 0),O(this,`scale`,1),O(this,`layers`,[]),O(this,`time`,[]),O(this,`_crop`,void 0),O(this,`cropData`,void 0),O(this,`id`,void 0),O(this,`addEventListener`,(e,t,n)=>{let r=y[e];if(!this.eventHandlers[r])throw Error(`Unknown event ${r}`);this.eventHandlers[r].indexOf(t)===-1&&this.eventHandlers[r].push(t)}),O(this,`removeEventListener`,(e,t)=>{let n=y[e];if(!this.eventHandlers[n]){console.warn(`Unknown event ${n}`);return}this.eventHandlers[n].indexOf(t)!==-1&&(this.eventHandlers[n]=this.eventHandlers[n].filter(e=>e!==t))}),this.id=this.__id=T(),this.eventHandlers=v()}dispatchEvent(e,t){let n=this.eventHandlers[e],r=n?n.length:0,i=!1;if(r)for(let a=0;a<r;a++)try{n[a]?.(t),i=!0}catch(t){console.error(e,t)}return i}get x(){return this.points[1]}get y(){return this.points[2]}get width(){return this.points[3]-this.points[1]}get height(){return this.points[4]-this.points[2]}translate(e,t){(0,l.mutate)(this.points,(0,l.translate)(e,t))}atScale(e){(0,l.mutate)(this.points,(0,l.scaleAtOrigin)(e,this.x,this.y)),this.scale*=e}transform(e){(0,l.mutate)(this.points,e)}applyProps(e){this.__revision++}appendChild(e){}removeChild(e){}insertBefore(e,t){}hideInstance(){}},A=class e extends k{constructor(e){if(super(),O(this,`type`,`spacial-content`),O(this,`id`,void 0),O(this,`uri`,void 0),O(this,`display`,void 0),O(this,`points`,void 0),O(this,`priority`,void 0),O(this,`style`,{opacity:1}),!e)this.id=``,this.uri=``,this.display={x:0,y:0,scale:1,width:0,height:0,points:(0,l.dna)(5)},this.points=(0,l.dna)(5);else{let t=e.scale||1;this.id=e.id||e.uri,this.uri=e.uri,this.points=l.DnaFactory.singleBox(e.width,e.height,e.x,e.y),this.display={x:0,y:0,scale:t,width:e.width/t,height:e.height/t,points:l.DnaFactory.singleBox(e.width/t,e.height/t),rotation:e?.rotation}}}applyProps(e){let t=e.display?e.display.width:e.target.width,n=e.target.width/t;if(this.id=e.id||e.uri,this.uri=e.uri,this.points.set(l.DnaFactory.singleBox(e.target.width,e.target.height,e.target.x,e.target.y)),e.style&&e.style.opacity!==void 0&&(this.style.opacity=e.style.opacity),e.crop){this.cropData=e.crop;let t=l.DnaFactory.singleBox(e.crop.width,e.crop.height,e.crop.x,e.crop.y);(0,l.mutate)(t,(0,l.translate)(-e.crop.x,-e.crop.y)),this.crop?this.crop.set(t):this.crop=(0,l.dna)(t)}e.display?(this.display.scale=n,this.display.width=e.display.width,this.display.height=e.display.height,this.display.rotation=e.display.rotation,this.display.points=l.DnaFactory.singleBox(e.display.width,e.display.height)):(this.display.scale=n,this.display.width=e.target.width/n,this.display.height=e.target.height/n,this.display.points=l.DnaFactory.singleBox(e.target.width/n,e.target.height/n))}getAllPointsAt(e,t,n){return[[this,this.crop||this.points,t]]}static fromSvg(t,n,r,i){return e.fromImage(`data:image/svg+xml;base64,`+btoa(t),n,r,i)}static fromImage(t,n,r,i){let a=new e;return a.applyProps({uri:t,id:i,display:r,target:n}),a}getImageUrl(){return this.uri}},te=class extends k{constructor(e){if(super(),O(this,`type`,`spacial-content`),O(this,`id`,void 0),O(this,`uri`,void 0),O(this,`display`,void 0),O(this,`points`,void 0),O(this,`getTexture`,void 0),this.getTexture=()=>({source:void 0,hash:-1}),!e)this.id=``,this.uri=``,this.display={x:0,y:0,scale:1,width:0,height:0,points:(0,l.dna)(5)},this.points=(0,l.dna)(5);else{let t=e.scale||1;this.id=e.id||e.uri,this.uri=e.uri,this.points=l.DnaFactory.singleBox(e.width,e.height),this.display={x:0,y:0,scale:t,width:e.width/t,height:e.height/t,points:t===1?this.points:l.DnaFactory.singleBox(e.width/t,e.height/t)}}}applyProps(e){let t=e.display?e.display.width:e.target.width,n=e.target.width/t;this.id=e.id,this.points.set(l.DnaFactory.singleBox(e.target.width,e.target.height)),this.display.scale=n,this.display.width=e.target.width/n,this.display.height=e.target.height/n,this.getTexture=e.getTexture,this.display.points=n===1?this.points:l.DnaFactory.singleBox(e.target.width/n,e.target.height/n)}getAllPointsAt(e,t,n){return[[this,this.points,t]]}};function j(e,t,n=1){let r=t.length;if(r===0)throw Error(`No resources passed in.`);let i=0,a=1/0;for(let o=0;o<r&&!(!t[o]||!t[o].display);o++){let r=ne(t[o].display.scale,e/(n||1));r<a&&(a=r,i=o)}return i}function ne(e,t){return Math.abs(e-t)}function M(e,t){let n=ne(e.x,t.x),r=ne(e.y,t.y);return Math.sqrt(n**2+r**2)}function re(e){let t=e.length;return e.indexOf(`/info.json`)===t-10?e.slice(0,-10):e}function N(e,t,n){return Math.min(Math.max(e,t),n)}var P=class e extends k{constructor(e){super(),O(this,`id`,void 0),O(this,`type`,`spacial-content`),O(this,`display`,void 0),O(this,`tileWidth`,void 0),O(this,`style`,{opacity:1}),O(this,`points`,void 0),O(this,`service`,void 0),O(this,`format`,`jpg`),O(this,`crop2`,void 0),O(this,`version3`,void 0),O(this,`tileUrl`,void 0),this.tileUrl=re(e.url),this.id=e.id||`${this.tileUrl}--${e.scaleFactor}`,this.points=e.displayPoints?e.displayPoints:(0,l.transform)(e.points,(0,l.scale)(e.scaleFactor)),this.tileWidth=e.tileWidth,this.version3=e.version3,this.display={x:0,y:0,width:e.width/e.scaleFactor,height:e.height/e.scaleFactor,points:e.points,scale:e.scaleFactor},e.format&&(this.format=e.format)}applyProps(e){if(e.style&&e.style.opacity!==void 0&&(this.style.opacity=e.style.opacity),e.service!==this.service&&(this.service=e.service),e.format?this.format=e.format:this.format=`jpg`,e.version3!==void 0&&(this.version3=e.version3),e.crop){this.cropData=e.crop;let t=(0,l.dna)([...this.points]),n=t.length/5,r=e.crop.x||0,i=e.crop.y||0,a=e.crop.x+e.crop.width,o=e.crop.y+e.crop.height;for(let e=0;e<n;e++){let n=e*5;t[n+1]<a&&t[n+3]>r&&t[n+2]<o&&t[n+4]>i?(t[n+1]=N(t[n+1],r,a),t[n+3]=N(t[n+3],r,a),t[n+2]=N(t[n+2],i,o),t[n+4]=N(t[n+4],i,o)):t[n]=0}(0,l.mutate)(t,(0,l.translate)(-e.crop.x,-e.crop.y)),this.crop?this.crop.set(t):this.crop=t}}static fromTile(t,n,r,i,a,o,s,c){r.height=r.height?r.height:r.width;let u=s?Math.floor(n.width/i):Math.ceil(n.width/i),d=s?Math.floor(n.height/i):Math.ceil(n.height/i),f=Math.ceil(u/r.width),p=Math.ceil(d/r.height),m=l.DnaFactory.grid(f,p),h=l.DnaFactory.grid(f,p),g=a&&a[`@context`]?Array.isArray(a[`@context`])?a[`@context`]:[a[`@context`]]:[],_=c===void 0?g.indexOf(`http://iiif.io/api/image/3/context.json`)!==-1:c;for(let e=0;e<p;e++)for(let t=0;t<f;t++){let a=t*r.width,o=e*r.height;h.addPoints(a*i,o*i,t===f-1?n.width:(a+r.width)*i,e===p-1?n.height:(o+r.height)*i),m.addPoints(a,o,t===f-1?u:a+r.width,e===p-1?d:o+r.height)}let v=new e({url:t,scaleFactor:i,points:m.build(),displayPoints:h.build(),width:n.width,height:n.height,tileWidth:r.width,format:o,version3:_});return v.applyProps({service:a}),v}getImageUrl(e){let t=this.points.slice(e*5,e*5+5),n=t[3]-t[1],r=t[4]-t[2],i=Math.ceil(n/this.display.scale),a=Math.ceil(r/this.display.scale),o=`${i>this.tileWidth?this.tileWidth:i},`;return this.version3&&(o+=`${a>this.tileWidth?this.tileWidth:a}`),`${this.tileUrl}/${t[1]},${t[2]},${n},${r}/${o}/0/default.${this.format||`jpg`}`}getAllPointsAt(e,t,n){let r=(0,l.hidePointsOutsideRegion)(this.crop||this.points,e);return[[this,r,t]]}transform(e){(0,l.mutate)(this.points,e)}getScheduledUpdates(e,t){return[]}},ie=class extends k{constructor(...e){super(...e),O(this,`type`,`spacial-content`)}getAllPointsAt(e,t,n){return[[this,this.points,t]]}},F=class extends ie{constructor(e){super(),O(this,`id`,void 0),O(this,`display`,void 0),O(this,`points`,void 0),O(this,`images`,[]),O(this,`allImages`,[]),O(this,`scaleFactors`,[]),O(this,`aggregateBuffer`,(0,l.dna)(9)),O(this,`lazyLoader`,void 0),O(this,`isFullyLoaded`,!1),O(this,`maxScaleFactor`,0),O(this,`renderOptions`,void 0),O(this,`_scheduleSortByScales`,!1),O(this,`_sortByScales`,()=>{this._scheduleSortByScales=!1,this.allImages.sort((e,t)=>t.display.width-e.display.width),this.images=[];let e=.1;for(let t of this.allImages)if(!(t.display.width<this.renderOptions.minSize&&t.display.height<this.renderOptions.minSize&&!t.priority)&&!(t instanceof A&&(t.display.width>this.renderOptions.maxImageSize||t.display.height>this.renderOptions.maxImageSize)&&!t.priority)){if(Math.abs(t.display.scale-e)<.25||t.priority){let e=this.images.pop();e&&(e instanceof A||e.priority)?(t.priority&&this.images.push(t),this.images.push(e)):t&&this.images.push(t)}else t&&this.images.push(t);e=t.display.scale}this.images.length===0&&(this.images=[...this.allImages]),this.scaleFactors=this.images.map(e=>e.display.scale),this.maxScaleFactor=Math.max(...this.scaleFactors)}),O(this,`loadFullResource`,async()=>{if(!this.isFullyLoaded&&this.lazyLoader){this.isFullyLoaded=!0;let e=await this.lazyLoader();this.addImages(e)}}),O(this,`fallback`,[this.loadFullResource]),this.id=e.id,this.points=l.DnaFactory.singleBox(e.width,e.height),this.lazyLoader=e.loadFullImages,e.loadFullImages||(this.isFullyLoaded=!0),this.display={x:0,y:0,points:l.DnaFactory.singleBox(e.width,e.height),height:e.height,width:e.width,scale:1},this.renderOptions={renderSmallestFallback:!0,renderLayers:3,minSize:255,maxImageSize:2048,quality:1.5,...e.renderOptions||{}},this.addImages(e.images)}applyProps(e){e.renderSmallestFallback!==void 0&&e.renderSmallestFallback!==this.renderOptions.renderSmallestFallback&&(this.renderOptions.renderSmallestFallback=e.renderSmallestFallback),e.renderLayers!==void 0&&e.renderLayers!==this.renderOptions.renderLayers&&(this.renderOptions.renderLayers=e.renderLayers),e.minSize!==void 0&&e.minSize!==this.renderOptions.minSize&&(this.renderOptions.minSize=e.minSize),e.maxImageSize!==void 0&&e.maxImageSize!==this.renderOptions.maxImageSize&&(this.renderOptions.maxImageSize=e.maxImageSize),e.quality!==void 0&&e.quality!==this.renderOptions.quality&&(this.renderOptions.quality=e.quality)}appendChild(e){this.addImages([e])}removeChild(e){this.images.indexOf(e)!==-1&&(this.images=this.images.filter(t=>t!==e),this.sortByScales())}insertBefore(e,t){this.addImages([e])}hideInstance(){}addImages(e){for(let t of e)t.__parent=this,t.__owner=this.__owner;this.allImages.push(...e.filter(Boolean)),this.sortByScales()}sortByScales(){this._scheduleSortByScales=!0}getScheduledUpdates(e,t){return this._scheduleSortByScales?[this._sortByScales]:this.isFullyLoaded?[]:t>1/this.maxScaleFactor?this.fallback:[]}getAllPointsAt(e,t,n){if(this.images.length===0)return[];let r=j(1/(n||1)/(window.devicePixelRatio||1),this.images,this.renderOptions.quality),i=this.images.length,a=t?(0,l.compose)(t,(0,l.translate)(this.x,this.y)):(0,l.translate)(this.x,this.y);if(r!==this.images.length-1&&this.images[r+1]){let t=[];for(let e=i-1;e>=r;e--)t.push(e);let o=t[0];this.renderOptions.renderLayers&&(t=t.slice(-Math.min(t.length,this.renderOptions.renderLayers))),this.renderOptions.renderSmallestFallback&&t.indexOf(o)===-1&&t.unshift(o);let s=[];for(let r=0;r<t.length;r++)s.push(...this.images[t[r]].getAllPointsAt(e,a,n));return s}return this.images[r].getAllPointsAt(e,a,n)}};function I(e,t,n,r,i){let a=Math.PI/180*i,o=Math.cos(a),s=Math.sin(a);return[o*(n-e)+s*(r-t)+e,o*(r-t)-s*(n-e)+t]}var L=class e extends k{constructor(e,t){super(),O(this,`id`,void 0),O(this,`type`,`world-object`),O(this,`scale`,void 0),O(this,`layers`,void 0),O(this,`points`,void 0),O(this,`worldPoints`,void 0),O(this,`intersectionBuffer`,(0,l.dna)(5)),O(this,`aggregateBuffer`,(0,l.dna)(9)),O(this,`invertedBuffer`,(0,l.dna)(9)),O(this,`rotation`,0),O(this,`filteredPointsBuffer`,void 0),O(this,`_updatedList`,[]),O(this,`geometry`,void 0);let{x:n=0,y:r=0}=t||{};e?(this.id=e.id||``,this.scale=1,this.layers=e.layers,this.points=(0,l.dna)([1,n,r,n+e.width,r+e.height]),this.worldPoints=(0,l.dna)([1,n,r,n+e.width,r+e.height]),this.filteredPointsBuffer=(0,l.dna)(e.layers.length*5)):(this.id=``,this.scale=1,this.layers=[],this.points=(0,l.dna)(5),this.worldPoints=(0,l.dna)(5),this.filteredPointsBuffer=(0,l.dna)(5))}static createWithProps(t){let n=new e;return n.applyProps(t),n}applyProps(e){let t=e.x||0,n=e.y||0;this.id=e.id;let r=e.scale===void 0?this.scale:e.scale;this.points[0]=1,this.points[1]=t,this.points[2]=n,this.points[3]=t+e.width,this.points[4]=n+e.height,this.rotation=e.rotation||0,this.worldPoints[3]=this.worldPoints[1]+e.width,this.worldPoints[4]=this.worldPoints[2]+e.height,e.scale&&e.scale!==1&&this.atScale(r),this.scale=r}appendChild(e){e.points[0]===0&&e.points.set(this.points),e.__owner.value=this,this.addLayers([e])}removeChild(e){this.layers=this.layers.filter(t=>t!==e),this.filteredPointsBuffer=(0,l.dna)(this.layers.length*5)}insertBefore(e,t){let n=this.layers.indexOf(t);if(n===-1||this.layers.indexOf(e)!==-1)return;let r=this.layers.slice(0,n),i=this.layers.slice(n);this.layers=[...r,e,...i]}hideInstance(){console.warn(`hideInstance: not yet implemented`)}getObjectsAt(e,t){if(this.rotation&&(e=this.applyRotation(e)),(0,l.hidePointsOutsideRegion)(this.points,e,this.filteredPointsBuffer)[0]===0)return[];let n=this.layers.length,r=[];for(let i=0;i<n;i++){let n=this.layers[i];if(t&&n.isShape){let t=(0,l.transform)(n.points,(0,l.translate)(this.x,this.y));if(!n.intersects([e[1]-t[1],e[2]-t[2]]))continue}if((0,l.hidePointsOutsideRegion)((0,l.transform)(n.points,(0,l.translate)(this.x,this.y)),e,this.filteredPointsBuffer)[0]!==0&&r.push(n),t){let i=n;r.push(...i.getObjectsAt(e,t))}}return r}applyRotation(e){if(this.rotation){let t={x:e[1],y:e[2]},n={x:e[1],y:e[4]},r={x:e[3],y:e[2]},i={x:e[3],y:e[4]},a=this.points[1]+(this.points[3]-this.points[1])/2,o=this.points[2]+(this.points[4]-this.points[2])/2,[s,c]=I(a,o,t.x,t.y,this.rotation),[u,d]=I(a,o,n.x,n.y,this.rotation),[f,p]=I(a,o,r.x,r.y,this.rotation),[m,h]=I(a,o,i.x,i.y,this.rotation),g=Math.min(s,u,f,m),_=Math.max(s,u,f,m),v=Math.min(c,d,p,h),y=Math.max(c,d,p,h);return(0,l.dna)([e[0],g,v,_,y])}return e}getAllPointsAt(e,t,n){let r=(0,l.compose)((0,l.translate)(this.x,this.y),(0,l.scale)(this.scale),this.aggregateBuffer);this.rotation&&(e=this.applyRotation(e));let i=(0,l.getIntersection)(e,this.points,this.intersectionBuffer),a=this.layers.length,o=[],s=(0,l.transform)(i,(0,l.compose)((0,l.scale)(1/this.scale),(0,l.translate)(-this.x,-this.y),this.invertedBuffer)),c=t?(0,l.compose)(t,r,this.aggregateBuffer):r,u=n*this.scale;for(let e=0;e<a;e++)o.push(...this.layers[e].getAllPointsAt(s,c,u));return o}addLayers(e){let t=[];for(let n of e)this.layers.indexOf(n)===-1&&(t.push(n),n.points.length===5&&(n.points[1]<this.worldPoints[1]/this.scale||n.points[2]<this.worldPoints[2]/this.scale||n.points[3]>this.worldPoints[3]/this.scale||n.points[4]>this.worldPoints[4]/this.scale)&&(n.crop=n.crop||(0,l.dna)([1,Math.max(this.worldPoints[1]/this.scale,n.points[1]),Math.max(this.worldPoints[2]/this.scale,n.points[2]),Math.min(this.worldPoints[3]/this.scale,n.points[3]),Math.min(this.worldPoints[4]/this.scale,n.points[4])])));this.layers=this.layers.concat(t),this.filteredPointsBuffer=(0,l.dna)(this.layers.length*5)}getScheduledUpdates(e,t){let n=this.layers.length;this._updatedList=[];let r=t*this.scale;for(let t=0;t<n;t++){let n=this.layers[t].getScheduledUpdates(e,r);n&&this._updatedList.push(...n)}return this._updatedList}},R=class e extends k{get x(){return 0}get y(){return 0}get width(){return this._width}get height(){return this._height}constructor(e=0,t=0,n=100,r=`left-to-right`){super(),O(this,`id`,`world`),O(this,`_width`,void 0),O(this,`_height`,void 0),O(this,`aspectRatio`,void 0),O(this,`viewingDirection`,void 0),O(this,`aggregateBuffer`,(0,l.dna)(9)),O(this,`isDirty`,!1),O(this,`zones`,[]),O(this,`filteredPointsBuffer`,void 0),O(this,`selectedZone`,void 0),O(this,`triggerQueue`,[]),O(this,`activatedEvents`,[]),O(this,`_updatedList`,[]),O(this,`translationBuffer`,(0,l.dna)(9)),O(this,`needsRecalculate`,!0),O(this,`emptyPaintables`,[]),O(this,`renderOrder`,[]),O(this,`points`,void 0),O(this,`objects`,[]),O(this,`subscriptions`,[]),O(this,`_propagateEventTargets`,[]),O(this,`_alreadyFlushed`,[]),this._width=e,this._height=t,this.aspectRatio=Number.isNaN(e/t)?1:e/t,this.viewingDirection=r,this.points=(0,l.dna)(n*5),this.filteredPointsBuffer=(0,l.dna)(n*5)}static withProps(t){let n=new e;return n.applyProps(t),n}applyProps(e){e.width!==void 0&&e.height!==void 0&&(e.width!==this._width||e.height!==this._height)&&this.resize(e.width,e.height),e.viewingDirection!==this.viewingDirection&&(this.viewingDirection=e.viewingDirection,this.triggerRepaint())}propagateTouchEvent(e,t,n){let r=[];for(let e of n)if(e.x&&e.y){let t=l.DnaFactory.singleBox(1,1,e.x,e.y);r.push(this.getObjectsAt(t,!0).reverse())}return r.map(n=>this.propagateEvent(e,t,n,{bubbles:!0,cancelable:!0}))}propagatePointerEvent(e,t,n,r,i={}){let a=l.DnaFactory.singleBox(1,1,n,r),o=this.getObjectsAt(a,!0).reverse();return this.propagateEvent(e,t,o,i)}propagateEvent(e,t,n,{bubbles:r=!1,cancelable:i=!1}={}){t.atlasTarget=this,this._propagateEventTargets.length=1,this._propagateEventTargets[0]=this;let a=!1;t.stopPropagation=()=>{a=!0};let o=n.length;for(let e=o-1;e>=0;e--){this._propagateEventTargets.unshift(n[e][0]);let t=n[e][1].length;if(t)for(let r=0;r<t;r++)this._propagateEventTargets.unshift(n[e][1][r])}let s=this._propagateEventTargets.length,c=!1;for(let n=0;n<s&&(t.atlasTarget=this._propagateEventTargets[n],t.atlasWorld=this,c=this._propagateEventTargets[n].dispatchEvent(e,t)||c,!a);n++);return c&&this.triggerRepaint(),this._propagateEventTargets}appendChild(e){let t=this.appendWorldObject(e);this.renderOrder.push(t/5)}removeChild(e){let t=this.objects.indexOf(e);if(t===-1){for(let t of this.objects)if(t&&t.id===e.id){this.removeChild(t);return}return}this.objects[t]=null,this.renderOrder=this.renderOrder.filter(e=>e!==t),this.points[t*5]=0,this.triggerRepaint(),this.needsRecalculate=!0}insertBefore(e,t){let n=this.objects.indexOf(t);if(n===-1)return;let r=this.appendWorldObject(e);this.renderOrder.splice(n-1,0,r/5)}hideInstance(){}asWorldObject(){return null}addZone(e){this.zones.push(e)}selectZone(e){if(typeof e==`string`){let t=this.zones.length;for(let n=0;n<t;n++)if(this.zones[n].id===e){this.selectedZone=n,this.trigger(`zone-changed`);return}}else this.zones[e]&&(this.selectedZone=e,this.trigger(`zone-changed`))}deselectZone(){this.selectedZone=void 0}getActiveZone(){if(this.selectedZone)return this.zones[this.selectedZone]}hasActiveZone(){return this.selectedZone!==void 0}checkResizeInternalBuffer(){if((0,l.dnaLength)(this.points)===this.objects.length){let e=this.points,t=(0,l.dna)(this.points.length*2);t.set(e,0),this.points=t}}appendWorldObject(e){this.checkResizeInternalBuffer();let t=this.objects.length*5,n=e.points;return e.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),e.points[1]=n[1],e.points[2]=n[2],e.points[3]=n[3],e.points[4]=n[4],this.objects.push(e),this.filteredPointsBuffer=(0,l.dna)(this.objects.length*5),this.needsRecalculate=!0,this.triggerRepaint(),t}recalculateWorldSize(){let e=!1;if(this.needsRecalculate){let t=new Int32Array(this.objects.length),n=new Int32Array(this.objects.length),r=this.renderOrder.length;for(let e=0;e<r;e++){let r=this.renderOrder[e];this.objects[r]&&(t[e]=this.points[r*5+3],n[e]=this.points[r*5+4])}let i=Math.max(...t);i!==this._width&&(this._width=i,e=!0);let a=Math.max(...n);a!==this._height&&(this._height=a,e=!0),e&&this.trigger(`recalculate-world-size`,{width:i,height:a}),this.needsRecalculate=!1}return e}addObjectAt(e,t){t.width&&!t.height?t.height=t.width/e.width*e.height:t.height&&!t.width&&(t.width=t.height/e.height*e.width),(!t||!t.width||!t.height)&&(t.width=e.width,t.height=e.height);let{width:n,x:r,y:i}=t,a=n/e.width;this.checkResizeInternalBuffer(),this.points.set(l.DnaFactory.singleBox(e.width,e.height,0,0),this.objects.length*5);let o=new L(e);return o.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),this.objects.push(o),this.scaleWorldObject(this.objects.length-1,a),this.translateWorldObject(this.objects.length-1,r,i),this.filteredPointsBuffer=(0,l.dna)(this.points.length*2),this.triggerRepaint(),this.needsRecalculate=!0,o}scaleWorldObject(e,t){(0,l.mutate)(this.points.subarray(e*5,e*5+5),(0,l.scaleAtOrigin)(t,this.points[e*5+1],this.points[e*5+2]));let n=this.objects[e];n&&(n.atScale(t),this.triggerRepaint())}translateWorldObject(e,t,n){(0,l.mutate)(this.points.subarray(e*5,e*5+5),(0,l.translate)(t,n));let r=this.objects[e];r&&(r.translate(t,n),this.triggerRepaint())}resize(e,t){return this._width=e,this._height=t,this.aspectRatio=e/t,this.triggerRepaint(),this}getObjects(){return this.objects}getPoints(){return this.points}getPointsFromViewer(e,t){let n=l.DnaFactory.singleBox(e.width,e.height,e.x,e.y);return this.getPointsAt(n,t,e.scale)}addLayoutSubscriber(e){return this.subscriptions.push(e),()=>{this.subscriptions.splice(this.subscriptions.indexOf(e),1)}}getScheduledUpdates(e,t){let n=(0,l.hidePointsOutsideRegion)(this.points,e,this.filteredPointsBuffer),r=this.objects.length;this._updatedList=[];for(let i=0;i<r;i++)if(n[i*5]!==0){if(!this.objects[i])continue;this._updatedList.push(...this.objects[i].getScheduledUpdates(e,t))}return this._updatedList}getObjectsAt(e,t=!1){let n=this.getActiveZone(),r=(0,l.hidePointsOutsideRegion)(this.points,e,this.filteredPointsBuffer),i=this.renderOrder.length,a=[];for(let o=0;o<i;o++){let i=this.renderOrder[o];if(r[i*5]!==0){let r=this.objects[i];if(!r||n&&n.objects.indexOf(r)===-1)continue;if(r.type!==`world-object`){a.push([r,[r]]);continue}t?a.push([r,r.getObjectsAt(e,t)]):a.push([r,this.emptyPaintables])}}return a}getPointsAt(e,t,n=1){let r=this.getObjectsAt(e),i=(0,l.compose)((0,l.scale)(n),(0,l.translate)(-e[1],-e[2]),this.translationBuffer),a=t?(0,l.compose)(t,i,this.aggregateBuffer):i,o=r.length,s=[];for(let t=0;t<o;t++)r[t]&&s.push(...r[t][0].getAllPointsAt(e,a,n));return s}flushSubscriptions(){if(this.triggerQueue.length){this._alreadyFlushed=[];let e=this.triggerQueue.length;for(let t=0;t<e;t++){if(this._alreadyFlushed.indexOf(this.triggerQueue[t][0])!==-1)continue;this.triggerQueue[t][1]===void 0&&this._alreadyFlushed.push(this.triggerQueue[t][0]);let e=this.subscriptions.length;for(let n=0;n<e;n++)this.subscriptions[n].apply(null,this.triggerQueue[t])}this.triggerQueue=[]}}trigger(e,t){this.triggerQueue.push([e,t])}triggerEventActivation(){this.trigger(`event-activation`)}triggerRepaint(){this.trigger(`repaint`)}gotoRegion(e){this.trigger(`goto-region`,e)}goHome(e=!1,t){this.trigger(`go-home`,{immediate:e,paddingPx:t})}zoomTo(e,t,n){this.trigger(`zoom-to`,{point:t,factor:e,stream:n})}zoomIn(e){this.trigger(`zoom-to`,{point:e,factor:.5})}zoomOut(e){this.trigger(`zoom-to`,{point:e,factor:2})}constraintBounds(e){this.trigger(`constrain-bounds`,{immediate:e})}};function ae(e){let{src:t,target:n}=e,r=n?n.width:e.width,i=n?n.height:e.height;return new L({id:t,height:i,width:r,layers:[A.fromImage(t,{height:i,width:r},{width:e.width,height:e.height})]})}const oe={margin:0};var se=class{constructor(e,t={}){O(this,`id`,void 0),O(this,`config`,void 0),O(this,`points`,void 0),O(this,`objects`,void 0),this.id=e.map(e=>e.id).join(`$$`),this.config={...oe,...t},this.points=(0,l.dna)(5),this.objects=e,this.recalculateBounds()}recalculateBounds(){this.points.set([1,Math.min(...this.objects.map(e=>e.points[1]))-this.config.margin,Math.min(...this.objects.map(e=>e.points[2]))-this.config.margin,Math.max(...this.objects.map(e=>e.points[3]))+this.config.margin,Math.max(...this.objects.map(e=>e.points[4]))+this.config.margin])}getPointsAt(e,t,n){return[]}};const z=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,ce={},le=[`backgroundColor`,`opacity`,`boxShadow`,`borderColor`,`borderWidth`,`borderStyle`,`outlineColor`,`outlineWidth`,`outlineOffset`,`outlineStyle`];var B=class extends k{constructor(){super(),O(this,`id`,void 0),O(this,`type`,`spacial-content`),O(this,`points`,void 0),O(this,`hoverEvents`,!1),O(this,`activeEvents`,!1),O(this,`display`,{x:0,y:0,scale:1,width:-1,height:-1,points:(0,l.dna)(5)}),O(this,`_parsed`,{border:{id:null,match:[]},outline:{id:null,match:[]}}),O(this,`hovering`,void 0),O(this,`pressing`,void 0),O(this,`props`,{}),O(this,`addHover`,()=>{this.hovering=!0,this.__revision++}),O(this,`removeHover`,()=>{this.hovering=!1,this.pressing=!1,this.__revision++}),O(this,`addPress`,()=>{this.pressing=!0,this.__revision++}),O(this,`removePress`,()=>{this.pressing=!1,this.__revision++}),this.id=T(12),this.points=(0,l.dna)(5)}getAllPointsAt(e,t){return[[this,this.points,t]]}applyProps(e={}){let t=!1;if(e.interactive!==this.props.interactive&&(t=!0,this.props.interactive=e.interactive),e.style){let n=e.border||e.style.border;if(n!==this._parsed.border.id)if(!n)this._parsed.border.id=null,this._parsed.border.match=[];else{let e=ce[n]||z.exec(n)||z.exec(n);e&&(this._parsed.border.id=n,this._parsed.border.match=ce[n]=e)}if(this._parsed.border.id&&(e.style.borderWidth=this._parsed.border.match[1],e.style.borderStyle=`solid`,e.style.borderColor=this._parsed.border.match[4]),e.style.outline!==this._parsed.outline.id)if(!e.style.outline)this._parsed.outline.id=null,this._parsed.outline.match=[];else{let t=ce[e.style.outline]||z.exec(e.style.outline)||z.exec(e.style.outline);t&&(this._parsed.outline.id=e.style.outline,this._parsed.outline.match=ce[e.style.outline]=t)}this._parsed.outline.id&&(e.style.outlineWidth=this._parsed.outline.match[1],e.style.outlineStyle=`solid`,e.style.outlineColor=this._parsed.outline.match[4]),this.props.style=e.style,e.backgroundColor&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=e.backgroundColor,t=!0),e.style.background&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=e.style.background,t=!0);for(let n of le)if(this.props.style[n]!==e.style[n]){t=!0;break}e.style[`:hover`]!==this.props.hoverStyles&&(this.props.hoverStyles=e.style[`:hover`],this.hoverEvents||(this.hoverEvents=!0,this.addEventListener(`pointerenter`,this.addHover),this.addEventListener(`pointerleave`,this.removeHover)),t=!0),e.style[`:active`]!==this.props.pressStyles&&(this.props.pressStyles=e.style[`:active`],this.activeEvents||(this.activeEvents=!0,this.addEventListener(`mousedown`,this.addPress),this.addEventListener(`mouseup`,this.removePress)),t=!0)}e.href!==this.props.href&&(this.props.href=e.href,t=!0),e.hrefTarget!==this.props.hrefTarget&&(this.props.hrefTarget=e.hrefTarget,t=!0),e.title!==this.props.title&&(this.props.title=e.title,t=!0),e.className!==this.props.className&&(this.props.className=e.className,e.className&&!this.hoverEvents&&(this.hoverEvents=!0,this.addEventListener(`pointerenter`,this.addHover),this.addEventListener(`pointerleave`,this.removeHover)),e.className&&!this.activeEvents&&(this.activeEvents=!0,this.addEventListener(`mousedown`,this.addPress),this.addEventListener(`mouseup`,this.removePress)),t=!0),e.relativeSize!==this.props.relativeSize&&(this.props.relativeSize=e.relativeSize,t=!0),e.relativeStyle!==this.props.relativeStyle&&(this.props.relativeStyle=e.relativeStyle,t=!0),e.html!==this.props.html&&(this.props.html=e.html,t=!0),e.target&&(e.target.width!==this.display.width||e.target.height!==this.display.height||e.target.x!==this.points[1]||e.target.y!==this.points[2])&&(t=!0,this.points=l.DnaFactory.singleBox(e.target.width,e.target.height,e.target.x,e.target.y),this.display.points=l.DnaFactory.singleBox(e.target.width,e.target.height,e.target.x,e.target.y),this.display.width=e.target.width,this.display.height=e.target.height),t&&this.__revision++}},V=class extends k{constructor(){super(),O(this,`type`,`spacial-content`),O(this,`id`,void 0),O(this,`points`,void 0),O(this,`color`,`#000`),O(this,`backgroundColor`,void 0),O(this,`hovering`,void 0),O(this,`pressing`,void 0),O(this,`text`,``),O(this,`display`,{x:0,y:0,scale:1,width:100,height:100,points:(0,l.dna)(5)}),O(this,`className`,void 0),O(this,`html`,void 0),O(this,`interactive`,!1),O(this,`props`,{font:`18px Arial, sans-serif`,lineHeight:1,textAlign:`left`,verticalAlign:`top`,paddingX:0,paddingY:0,fitParent:!1,lineBreak:`auto`,strokeText:!1,sizeToFill:!1,maxFontSizeToFill:void 0,allowNewLine:!0,justifyLines:!1,renderHDPI:!1,textDecoration:`none`,interactive:!1,relativeSize:!1}),this.id=``,this.points=(0,l.dna)(5)}getAllPointsAt(e,t){return[[this,this.points,t]]}applyProps({id:e,target:t,text:n,color:r,backgroundColor:i,fontSize:a=18,interactive:o,fontFamily:s=`Arial, sans-serif`,...c}){c.font=`${a}px ${s}`,this.interactive=o||!1,n!==void 0&&(this.text=n||``),r&&(this.color=r),i&&(this.backgroundColor=i),e&&(this.id=e),t&&(this.points=l.DnaFactory.singleBox(t.width,t.height,t.x,t.y),this.display.points=this.points,this.display.width=t.width,this.display.height=t.height),this.props={...this.props,...c},this.__revision++}};const H=Math.pow,U=Math.sqrt,ue=Math.sin,de=Math.cos,fe=Math.PI,pe=1.70158,me=pe*1.525,he=pe+1,ge=2*fe/3,_e=2*fe/4.5,W=function(e){let t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375},G={linear:e=>e,easeInQuad:function(e){return e*e},easeOutQuad:function(e){return 1-(1-e)*(1-e)},easeInOutQuad:function(e){return e<.5?2*e*e:1-H(-2*e+2,2)/2},easeInCubic:function(e){return e*e*e},easeOutCubic:function(e){return 1-H(1-e,3)},easeInOutCubic:function(e){return e<.5?4*e*e*e:1-H(-2*e+2,3)/2},easeInQuart:function(e){return e*e*e*e},easeOutQuart:function(e){return 1-H(1-e,4)},easeInOutQuart:function(e){return e<.5?8*e*e*e*e:1-H(-2*e+2,4)/2},easeInQuint:function(e){return e*e*e*e*e},easeOutQuint:function(e){return 1-H(1-e,5)},easeInOutQuint:function(e){return e<.5?16*e*e*e*e*e:1-H(-2*e+2,5)/2},easeInSine:function(e){return 1-de(e*fe/2)},easeOutSine:function(e){return ue(e*fe/2)},easeInOutSine:function(e){return-(de(fe*e)-1)/2},easeInExpo:function(e){return e===0?0:H(2,10*e-10)},easeOutExpo:function(e){return e===1?1:1-H(2,-10*e)},easeInOutExpo:function(e){return e===0?0:e===1?1:e<.5?H(2,20*e-10)/2:(2-H(2,-20*e+10))/2},easeInCirc:function(e){return 1-U(1-H(e,2))},easeOutCirc:function(e){return U(1-H(e-1,2))},easeInOutCirc:function(e){return e<.5?(1-U(1-H(2*e,2)))/2:(U(1-H(-2*e+2,2))+1)/2},easeInBack:function(e){return he*e*e*e-pe*e*e},easeOutBack:function(e){return 1+he*H(e-1,3)+pe*H(e-1,2)},easeInOutBack:function(e){return e<.5?H(2*e,2)*((me+1)*2*e-me)/2:(H(2*e-2,2)*((me+1)*(e*2-2)+me)+2)/2},easeInElastic:function(e){return e===0?0:e===1?1:-H(2,10*e-10)*ue((e*10-10.75)*ge)},easeOutElastic:function(e){return e===0?0:e===1?1:H(2,-10*e)*ue((e*10-.75)*ge)+1},easeInOutElastic:function(e){return e===0?0:e===1?1:e<.5?-(H(2,20*e-10)*ue((20*e-11.125)*_e))/2:H(2,-20*e+10)*ue((20*e-11.125)*_e)/2+1},easeInBounce:function(e){return 1-W(1-e)},easeOutBounce:W,easeInOutBounce:function(e){return e<.5?(1-W(1-2*e))/2:(1+W(2*e-1))/2}};var ve=class{constructor(e){O(this,`runtime`,void 0),O(this,`pendingTransition`,void 0),O(this,`lastZoomTo`,null),O(this,`isConstraining`,!1),O(this,`lastGoToRegion`,null),this.runtime=e,this.pendingTransition={from:(0,l.dna)(5),to:(0,l.dna)(5),elapsed_time:0,done:!0,total_time:0,timingFunction:G.easeInOutQuad,constrain:!1}}hasPending(){return!this.pendingTransition.done}getPendingTransition(){return this.pendingTransition}getPendingFrom(){return this.pendingTransition.from}customTransition(e){e(this.pendingTransition)}stopTransition(){this.pendingTransition.from=(0,l.dna)(this.runtime.target),this.pendingTransition.to=(0,l.dna)(this.runtime.target),this.pendingTransition.done=!0,this.pendingTransition.elapsed_time=0,this.pendingTransition.total_time=0}runTransition(e,t){if(!this.pendingTransition.done){let n=this.pendingTransition,r=n.total_time===0?0:(n.elapsed_time+t)/n.total_time,i=n.total_time===0?1:r===0?0:n.timingFunction(r);e[1]=n.from[1]+(n.to[1]-n.from[1])*i,e[2]=n.from[2]+(n.to[2]-n.from[2])*i,e[3]=n.from[3]+(n.to[3]-n.from[3])*i,e[4]=n.from[4]+(n.to[4]-n.from[4])*i,this.pendingTransition.elapsed_time+=t,this.pendingTransition.elapsed_time>=this.pendingTransition.total_time&&(this.pendingTransition.done=!0,this.pendingTransition.callback?.(),this.pendingTransition.constrain&&this.constrainBounds({transition:{duration:this.pendingTransition.total_time===0?0:500,easing:G.easeOutExpo}}))}}resumeTransition(){this.lastZoomTo&&this.zoomTo(this.lastZoomTo.factor,this.lastZoomTo.options),this.isConstraining&&this.constrainBounds(),this.lastGoToRegion&&this.goToRegion(this.lastGoToRegion.target,this.lastGoToRegion.options)}zoomTo(e,t={}){let{origin:n,stream:r=!1,transition:i}=t;this.lastZoomTo={factor:e,options:t};let a=this.runtime.getZoomedPosition(e,{origin:n}),o=Math.abs(1-e);this.applyTransition(a,i,{duration:2e3*o,easing:G.easeOutExpo,constrain:!0,callback:()=>{this.lastZoomTo=null}},{stream:!1})}constrainBounds({transition:e,panPadding:t=0}={}){this.isConstraining=!0;let[n,r]=this.runtime.constrainBounds(this.runtime.target,{panPadding:t});n&&(this.applyTransition(r,e,{duration:500,easing:G.easeOutQuart,constrain:!1,callback:()=>{this.isConstraining=!1}}),this.runtime.updateNextFrame())}applyTransition(e,t,n,{stream:r}={}){this.pendingTransition.from=(0,l.dna)(this.runtime.target),this.pendingTransition.to=e,r||(this.pendingTransition.elapsed_time=0),this.pendingTransition.done=!1,this.pendingTransition.total_time=t?.duration===void 0?n?.duration===void 0?1e3:n.duration:t.duration,this.pendingTransition.constrain=t?.constrain===void 0?n?.constrain===void 0?!1:n.constrain:t.constrain,this.pendingTransition.timingFunction=t?.easing||n?.easing||G.easeInOutSine}goToRegion(e,{transition:t}={}){this.lastGoToRegion={target:e,options:{transition:t}};let n=this.runtime.clampRegion(e);this.applyTransition(l.DnaFactory.singleBox(n.width,n.height,n.x,n.y),t,{duration:1e3,easing:G.easeOutExpo,constrain:!0,callback:()=>{this.lastGoToRegion=null}}),this.runtime.updateNextFrame()}};Number.MIN_VALUE+1;var ye=class{get x(){return this.target[1]}set x(e){this.target[1]=e}get y(){return this.target[2]}set y(e){this.target[2]=e}get x2(){return this.target[3]}set x2(e){this.target[3]=e}get y2(){return this.target[4]}set y2(e){this.target[4]=e}get width(){return this.target[3]-this.target[1]}set width(e){this.target[3]=this.target[1]+e}get height(){return this.target[4]-this.target[2]}set height(e){this.target[4]=this.target[2]=e}constructor(e,t,n,r=[],i){O(this,`id`,T()),O(this,`ready`,!1),O(this,`renderer`,void 0),O(this,`world`,void 0),O(this,`target`,void 0),O(this,`homePosition`,void 0),O(this,`manualHomePosition`,void 0),O(this,`manualFocalPosition`,void 0),O(this,`focalPosition`,void 0),O(this,`homePaddingPx`,void 0),O(this,`transitionManager`,void 0),O(this,`aggregate`,void 0),O(this,`transformBuffer`,(0,l.dna)(500)),O(this,`lastTarget`,(0,l.dna)(5)),O(this,`zoomBuffer`,(0,l.dna)(5)),O(this,`logNextRender`,!1),O(this,`pendingUpdate`,!0),O(this,`isCommitting`,!1),O(this,`firstRender`,!0),O(this,`lastTime`,void 0),O(this,`stopId`,void 0),O(this,`mode`,`explore`),O(this,`controllers`,[]),O(this,`controllersRunning`,!1),O(this,`controllerStopFunctions`,[]),O(this,`maxScaleFactor`,1),O(this,`_viewerToWorld`,{x:0,y:0}),O(this,`_lastGoodScale`,1),O(this,`_canvasWidth`,0),O(this,`_canvasHeight`,0),O(this,`hooks`,{useFrame:[],useBeforeFrame:[],useAfterPaint:[],useAfterFrame:[]}),O(this,`fpsLimit`,void 0),O(this,`options`,void 0),O(this,`hookOptions`,{filters:{grayscale:0,contrast:0,brightness:0,saturate:0,sepia:0,invert:0,hueRotate:0,blur:0}}),O(this,`_viewport`,{x:0,y:0,width:0,height:0}),O(this,`setViewport`,e=>{let t=Math.round(e.x===void 0?this.target[1]:e.x),n=Math.round(e.y===void 0?this.target[2]:e.y);e.width?this.target[3]=t+e.width:this.target[3]=this.target[3]-this.target[1]+t,e.height?this.target[4]=n+e.height:this.target[4]=this.target[4]-this.target[2]+n,Math.abs(this.target[1]-t)>.01&&(this.target[1]=t),Math.abs(this.target[2]-n)>.01&&(this.target[2]=n),this.pendingUpdate=!0}),O(this,`render`,e=>{let t=e-this.lastTime;if(this.isCommitting||this.fpsLimit&&t<1e3/this.fpsLimit){this.stopId=window.requestAnimationFrame(this.render);return}this.lastTime=e,this.world.flushSubscriptions(),this.stopId=window.requestAnimationFrame(this.render),this.hook(`useFrame`,t);let n=this.pendingUpdate,r=this.renderer.pendingUpdate();if(this.transitionManager.hasPending()&&(this.transitionManager.runTransition(this.target,t),this.pendingUpdate=!0,this.updateControllerPosition()),!this.firstRender&&!n&&!r&&this.target[0]===this.lastTarget[0]&&this.target[1]===this.lastTarget[1]&&this.target[2]===this.lastTarget[2]&&this.target[3]===this.lastTarget[3]&&this.target[4]===this.lastTarget[4])return;this.hook(`useBeforeFrame`,t),this.renderer.beforeFrame(this.world,t,this.target,this.hookOptions);let i=this.getScaleFactor(),a=this.renderer.getPointsAt(this.world,this.target,this.aggregate,i),o=a.length;for(let e=0;e<o;e++){let t=a[e][0],n=a[e][1],r=a[e][2],i=r?(0,l.transform)(n,r,this.transformBuffer):n;this.renderer.prepareLayer(t,t.__parent&&r?(0,l.transform)(t.__parent.crop||t.__parent.points,r):i);let o=i.length/5;for(let e=0;e<o;e++){let n=e*5;i[n]!==0&&(this.renderer.paint(t,e,i[n+1],i[n+2],i[n+3]-i[n+1],i[n+4]-i[n+2]),this.hook(`useAfterPaint`,t))}this.renderer.finishLayer(t,n)}this.renderer.afterFrame(this.world,t,this.target,this.hookOptions),this.hook(`useAfterFrame`,t),this.lastTarget[0]=this.target[0],this.lastTarget[1]=this.target[1],this.lastTarget[2]=this.target[2],this.lastTarget[3]=this.target[3],this.lastTarget[4]=this.target[4],this.firstRender=!1,this.pendingUpdate=!1,this.logNextRender=!1,this.renderer.isReady()&&(this.ready=!0,this.world.trigger(`ready`)),this.world.flushSubscriptions();let s=this.world.getScheduledUpdates(this.target,i),c=s.length;if(c>0)for(let e=0;e<c;e++){let t=s[c-e-1]();t?t.then(()=>{this.pendingUpdate=!0}):this.pendingUpdate=!0}}),this.renderer=e,this.world=t,this.options={maxOverZoom:1,maxUnderZoom:1,visibilityRatio:1.5,...i||{}},this.target=l.DnaFactory.projection(n),this.manualHomePosition=!1,this.pendingUpdate=!0,this.homePosition=l.DnaFactory.projection(this.world),this.manualFocalPosition=!1,this.focalPosition=this.target,this.updateFocalPosition(),this.transitionManager=new ve(this),this.aggregate=(0,l.scale)(1),this.world.addLayoutSubscriber(e=>{e===`repaint`&&(this.pendingUpdate=!0),e===`recalculate-world-size`&&(this.manualHomePosition||(this.setHomePosition(),this.goHome()),this.updateFocalPosition())}),this.lastTime=performance.now(),this.controllers=r,this.render(this.lastTime),this.startControllers(),this.homePaddingPx=void 0;let a=this.getRendererScreenPosition();this._canvasWidth=a?.width||0,this._canvasHeight=a?.height||0}setHomePosition(e){this.homePosition.set(l.DnaFactory.projection(e||this.world)),this.pendingUpdate=!0}setHomePaddingPx(e){e==null?this.homePaddingPx=void 0:this.homePaddingPx=e,this.pendingUpdate=!0}getHomePaddingPx(){return this.homePaddingPx}startControllers(){if(!this.controllersRunning){for(let e of this.controllers)this.controllerStopFunctions.push(e.start(this));this.controllersRunning=!0}}stopControllers(){if(this.controllersRunning){for(let e of this.controllerStopFunctions)e();this.controllersRunning=!1,this.controllerStopFunctions=[]}}updateControllerPosition(){for(let e of this.controllers)e.updatePosition(this.x,this.y,this.width,this.height)}triggerResize(){this.renderer.triggerResize&&this.renderer.triggerResize();let e=this.getRendererScreenPosition();e&&(this._canvasWidth=e.width,this._canvasHeight=e.height),this.pendingUpdate=!0}addController(e){this.controllers.push(e),this.controllersRunning&&e.start(this),this.pendingUpdate=!0}cover(){return this.goHome({cover:!0})}getRendererScreenPosition(){return this.renderer.getRendererScreenPosition()}updateRendererScreenPosition(){this.pendingUpdate=!0,this.renderer.resize()}setOptions(e){this.options={...this.options,...e}}getHomeTarget(e={}){let t=this.getRendererScreenPosition(),n=t?.width||this._canvasWidth||this.width,r=t?.height||this._canvasHeight||this.height;t&&(this._canvasWidth=t.width,this._canvasHeight=t.height);let i=e.paddingPx===void 0?this.homePaddingPx:e.paddingPx,a={left:0,right:0,top:0,bottom:0};typeof i==`number`?a.left=a.right=a.top=a.bottom=i:i&&(a.left=i.left||0,a.right=i.right||0,a.top=i.top||0,a.bottom=i.bottom||0);let o=Math.max(1,n-a.left-a.right),s=o/Math.max(1,r-a.top-a.bottom),c=e.position?{x:e.position[1],y:e.position[2],width:e.position[3]-e.position[1],height:e.position[4]-e.position[2]}:{x:this.homePosition[1],y:this.homePosition[2],width:this.homePosition[3]-this.homePosition[1],height:this.homePosition[4]-this.homePosition[2]},l=c.width/c.height,u=e.cover?l<s:l>s,d=c.width,f=c.height,p=c.x,m=c.y;u?(d=c.width,f=c.width/s,p=c.x,m=c.y-(f-c.height)/2):(f=c.height,d=c.height*s,p=c.x-(d-c.width)/2,m=c.y);let h=d/o,g=a.left*h,_=a.right*h,v=a.top*h,y=a.bottom*h;return{x:p-g,y:m-v,width:d+g+_,height:f+v+y}}getHomeTargetStrand(e={}){let t=this.getHomeTarget(e);return l.DnaFactory.singleBox(t.width,t.height,t.x,t.y)}goHome(e={}){if(this.world.width<=0||this.world.height<=0)return;let t=this.getHomeTarget(e);this.target[1]=Math.round(t.x),this.target[2]=Math.round(t.y),this.target[3]=Math.round(t.x+t.width),this.target[4]=Math.round(t.y+t.height);let n=e.paddingPx===void 0?this.homePaddingPx:e.paddingPx,r=n?{ref:!0,homePaddingPx:n}:{ref:!0};this.constrainBounds(this.target,r),this.updateControllerPosition()}resize(e,t,n,r){this.transitionManager.hasPending()&&this.transitionManager.stopTransition(),this.updateFocalPosition(e-t,n-r);let i=t/e,a=r/n;this.target[3]=this.target[1]+(this.target[3]-this.target[1])*i,this.target[4]=this.target[2]+(this.target[4]-this.target[2])*a,this.goHome({position:this.focalPosition}),this.renderer.resize(t,r),this.pendingUpdate=!0,this.transitionManager.resumeTransition()}updateFocalPosition(e,t){if(!this.manualFocalPosition){let e=this.width,t=this.height,n=Math.min(e,t),r=this.x+0,i=this.y+0;if(e<t){let e=this.height-this.width;this.focalPosition=l.DnaFactory.projection({x:r,y:i+e/2,width:n-0,height:n-0}),this.pendingUpdate=!0}else{let e=this.width-this.height;this.focalPosition=l.DnaFactory.projection({x:r+e/2,y:i,width:n-0,height:n-0}),this.pendingUpdate=!0}}}getViewport(){return this._viewport.x=this.target[1],this._viewport.y=this.target[2],this._viewport.width=this.target[3]-this.target[1],this._viewport.height=this.target[4]-this.target[2],this._viewport}constrainBounds(e,{panPadding:t=0,ref:n=!1,homePaddingPx:r}={}){let{minX:i,maxX:a,minY:o,maxY:s}=this.getBounds({target:e,padding:t,homePaddingPx:r}),c=!1,u=n?e:(0,l.dna)(e),d=Math.round(e[3]-e[1]),f=Math.round(e[4]-e[2]);return i>e[1]&&(c=!0,u[1]=i,u[3]=i+d),o>e[2]&&(c=!0,u[2]=o,u[4]=o+f),a<e[1]&&(c=!0,u[1]=a,u[3]=a+d),s<e[2]&&(c=!0,u[2]=s,u[4]=s+f),[c,u]}getBounds(e){let t=e.target||this.target,n=e.padding,r=this.options.visibilityRatio,i=Math.abs(1-r),a=0,o=0,s=0,c=0;if(e.homePaddingPx){let t=this.getScaleFactor(!1);typeof e.homePaddingPx==`number`?a=o=s=c=e.homePaddingPx/t:(a=e.homePaddingPx.left?e.homePaddingPx.left/t:0,o=e.homePaddingPx.right?e.homePaddingPx.right/t:0,s=e.homePaddingPx.top?e.homePaddingPx.top/t:0,c=e.homePaddingPx.bottom?e.homePaddingPx.bottom/t:0)}if(this.world.hasActiveZone()){let e=this.world.getActiveZone();if(e){let r=t[3]-t[1]<e.points[3]-e.points[1],i=t[4]-t[2]<e.points[4]-e.points[2];return{minX:r?e.points[1]-n:e.points[1]+(e.points[3]-e.points[1])/2-(t[3]-t[1])/2,maxX:i?e.points[2]-n:e.points[2]+(e.points[4]-e.points[2])/2-(t[4]-t[2])/2,minY:r?e.points[3]+n:e.points[1]+(e.points[3]-e.points[1])/2-(t[3]-t[1])/2,maxY:i?e.points[4]+n:e.points[2]+(e.points[4]-e.points[2])/2-(t[4]-t[2])/2}}}let l=t[3]-t[1],u=this.world.width+a+o,d=-l*i-a,f=u-l-d,p=t[4]-t[2],m=this.world.height+s+c,h=-p*i-s,g=m-p-h,_=Math.round(Math.max(d,f)),v=Math.round(Math.min(d,f)),y=Math.round(Math.max(h,g));return{minX:v,maxX:_,minY:Math.round(Math.min(h,g)),maxY:y}}getScaleFactor(e=!1){let t=this.renderer.getScale(this.target[3]-this.target[1],this.target[4]-this.target[2],e);return t===0?this._lastGoodScale:(this._lastGoodScale=t,t)}getZoomedPosition(e,{origin:t,fromPos:n}){let r=n?{width:n[3]-n[1],height:n[4]-n[2]}:void 0,i=r?this.renderer.getScale(r.width,r.height):this.getScaleFactor(),a=r?r.width:this.width,o=r?r.height:this.height,s=this.getRendererScreenPosition()?.width,c=this.world.width,u=s?s/c:1,d=this.options.maxUnderZoom,f=Math.max(u||1,this.options.maxOverZoom),p=1/e,m=i*p;if(p<1){let t=a*i,n=o*i;this.world.width/t>this.world.height/n?this.world.width*m<~~(a*i)*d&&(e=this.world.width*i/(a*i*d)):this.world.height*m<~~(o*i)*d&&(e=this.world.height*i/(o*i*d))}else m>f&&(e=i/f);let h=(0,l.transform)(this.target,(0,l.scaleAtOrigin)(e,t?t.x:this.target[1]+(this.target[3]-this.target[1])/2,t?t.y:this.target[2]+(this.target[4]-this.target[2])/2),this.zoomBuffer);return this.constrainBounds(h,{ref:!0,panPadding:100}),h}clampRegion({x:e,y:t,width:n,height:r,padding:i=0}){let a=this.width,o=this.height,s=n/a<r/o,c=e-i,l=t-i,u=n+i*2,d=r+i*2;if(s){let e=d/o*a;return{x:c-(e-u)/2,y:l,width:e,height:d}}let f=u/a*o;return{x:c,y:l-(f-d)/2,width:u,height:f}}viewerToWorld(e,t){let n=this.getScaleFactor();return this._viewerToWorld.x=this.target[1]+e/n,this._viewerToWorld.y=this.target[2]+t/n,this._viewerToWorld}worldToViewer(e,t,n,r){let i=l.DnaFactory.singleBox(n,r,e,t);return(0,l.mutate)(i,(0,l.compose)((0,l.scale)(this.getScaleFactor()),(0,l.translate)(-this.target[1],-this.target[2]))),{x:i[1],y:i[2],width:i[3]-i[1],height:i[4]-i[2],strand:i}}setScale(e,t){(0,l.mutate)(this.target,(0,l.scaleAtOrigin)(e,t?t.x:this.target[1]+(this.target[3]-this.target[1])/2,t?t.y:this.target[2]+(this.target[4]-this.target[2])/2)),this.pendingUpdate=!0}syncTo(e){let t=this.target;return this.target=e.target,this.pendingUpdate=!0,()=>{this.target=t}}stop(){return this.stopId!==void 0&&(window.cancelAnimationFrame(this.stopId),this.stopId=void 0),()=>{this.render(performance.now())}}reset(){this.renderer.reset()}selectZone(e){this.world.selectZone(e),this.pendingUpdate=!0}deselectZone(){this.world.deselectZone(),this.pendingUpdate=!0}hook(e,t){let n=this.hooks[e].length;if(n!==0)for(let r=0;r<n;r++)this.hooks[e][r](t)}registerHook(e,t){return this.hooks[e].push(t),()=>{this.hooks[e]=this.hooks[e].filter(e=>e!==t)}}updateNextFrame(){this.pendingUpdate=!0}};const be=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,xe={},Se=[`backgroundColor`,`opacity`,`boxShadow`,`borderColor`,`borderWidth`,`borderStyle`,`outlineColor`,`outlineWidth`,`outlineOffset`,`outlineStyle`];var Ce=class extends k{constructor(){super(),O(this,`id`,void 0),O(this,`type`,`spacial-content`),O(this,`isShape`,!0),O(this,`points`,void 0),O(this,`hoverEvents`,!1),O(this,`activeEvents`,!1),O(this,`display`,{x:0,y:0,scale:1,width:-1,height:-1,points:(0,l.dna)(5)}),O(this,`boundingBox`,null),O(this,`_parsed`,{border:{id:null,match:[]},outline:{id:null,match:[]}}),O(this,`hovering`,void 0),O(this,`pressing`,void 0),O(this,`props`,{}),O(this,`shape`,{type:`none`}),O(this,`addHover`,()=>{this.hovering=!0,this.__revision++}),O(this,`removeHover`,()=>{this.hovering=!1,this.pressing=!1,this.__revision++}),O(this,`addPress`,()=>{this.pressing=!0,this.__revision++}),O(this,`removePress`,()=>{this.pressing=!1,this.__revision++}),this.id=T(12),this.points=(0,l.dna)(5),this.shape={type:`none`}}updateBoundingBox(){if(this.shape.type===`none`)return;let e=this.shape.points;if(this.shape.points.length>2){let t=Math.min(...e.map(e=>e[0])),n=Math.min(...e.map(e=>e[1])),r=Math.max(0,...e.map(e=>e[0])),i=Math.max(0,...e.map(e=>e[1]));this.boundingBox={x:t,y:n,width:r-t,height:i-n};return}this.boundingBox=null}intersects(e){if(!e||this.shape.type===`none`)return!1;let[t,n]=e,r=this.shape.points,i=this.boundingBox;if(i||(this.updateBoundingBox(),i=this.boundingBox),!i||t<i.x||t>i.x+i.width||n<i.y||n>i.height+i.y)return!1;let a=!1;for(let e=0,i=r.length-1;e<r.length;i=e++)r[e][1]>n!=r[i][1]>n&&t<(r[i][0]-r[e][0])*(n-r[e][1])/(r[i][1]-r[e][1])+r[e][0]&&(a=!a);return a}getAllPointsAt(e,t){return e[3]-e[1]===1&&e[4]-e[2]===1?this.intersects([e[1],e[2]])?[[this,this.points,t]]:[]:[[this,this.points,t]]}applyProps(e={}){let t=!1;if(e.points)if(this.shape.type!==`polygon`||this.shape.points.length!==e.points.length)this.shape={type:`polygon`,points:e.points,open:e.open},this.updateBoundingBox();else{let t=!1,n=e.points.length;for(let r=0;r<n;r++)if(e.points[r][0]!==this.shape.points[r][0]||e.points[r][1]!==this.shape.points[r][1]){t=!0;break}t&&(this.shape={type:`polygon`,points:e.points,open:e.open},this.updateBoundingBox())}if(e.interactive!==this.props.interactive&&(t=!0,this.props.interactive=e.interactive),(e.open||e.open===!1)&&(t=!0,this.shape.open=e.open),e.style){let n=e.border||e.style.border;if(n!==this._parsed.border.id)if(!n)this._parsed.border.id=null,this._parsed.border.match=[];else{let e=xe[n]||be.exec(n)||be.exec(n);e&&(this._parsed.border.id=n,this._parsed.border.match=xe[n]=e)}if(this._parsed.border.id&&(e.style.borderWidth=this._parsed.border.match[1],e.style.borderStyle=`solid`,e.style.borderColor=this._parsed.border.match[4]),e.style.outline!==this._parsed.outline.id)if(!e.style.outline)this._parsed.outline.id=null,this._parsed.outline.match=[];else{let t=xe[e.style.outline]||be.exec(e.style.outline)||be.exec(e.style.outline);t&&(this._parsed.outline.id=e.style.outline,this._parsed.outline.match=xe[e.style.outline]=t)}this._parsed.outline.id&&(e.style.outlineWidth=this._parsed.outline.match[1],e.style.outlineStyle=`solid`,e.style.outlineColor=this._parsed.outline.match[4]),this.props.style=e.style,e.backgroundColor&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=e.backgroundColor,t=!0),e.style.background&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=e.style.background,t=!0);for(let n of Se)if(this.props.style[n]!==e.style[n]){t=!0;break}e.style[`:hover`]!==this.props.hoverStyles&&(this.props.hoverStyles=e.style[`:hover`],this.hoverEvents||(this.hoverEvents=!0,this.addEventListener(`pointerenter`,this.addHover),this.addEventListener(`pointerleave`,this.removeHover)),t=!0),e.style[`:active`]!==this.props.pressStyles&&(this.props.pressStyles=e.style[`:active`],this.activeEvents||(this.activeEvents=!0,this.addEventListener(`mousedown`,this.addPress),this.addEventListener(`mouseup`,this.removePress)),t=!0)}e.href!==this.props.href&&(this.props.href=e.href,t=!0),e.hrefTarget!==this.props.hrefTarget&&(this.props.hrefTarget=e.hrefTarget,t=!0),e.title!==this.props.title&&(this.props.title=e.title,t=!0),e.className!==this.props.className&&(this.props.className=e.className,e.className&&!this.hoverEvents&&(this.hoverEvents=!0,this.addEventListener(`pointerenter`,this.addHover),this.addEventListener(`pointerleave`,this.removeHover)),e.className&&!this.activeEvents&&(this.activeEvents=!0,this.addEventListener(`mousedown`,this.addPress),this.addEventListener(`mouseup`,this.removePress)),t=!0),e.relativeSize!==this.props.relativeSize&&(this.props.relativeSize=e.relativeSize,t=!0),e.relativeStyle!==this.props.relativeStyle&&(this.props.relativeStyle=e.relativeStyle,t=!0),e.html!==this.props.html&&(this.props.html=e.html,t=!0),e.target&&(e.target.width!==this.display.width||e.target.height!==this.display.height||e.target.x!==this.points[1]||e.target.y!==this.points[2])&&(t=!0,this.points=l.DnaFactory.singleBox(e.target.width,e.target.height,e.target.x,e.target.y),this.display.points=l.DnaFactory.singleBox(e.target.width,e.target.height,e.target.x,e.target.y),this.display.width=e.target.width,this.display.height=e.target.height),t&&this.__revision++}};const we=typeof performance==`object`&&performance&&typeof performance.now==`function`?performance:Date,Te=typeof AbortController==`function`?AbortController:class{constructor(){this.signal=new Oe}abort(e=Error(`This operation was aborted`)){this.signal.reason=this.signal.reason||e,this.signal.aborted=!0,this.signal.dispatchEvent({type:`abort`,target:this.signal})}},Ee=typeof AbortSignal==`function`,De=typeof Te.AbortSignal==`function`,Oe=Ee?AbortSignal:De?Te.AbortController:class{constructor(){this.reason=void 0,this.aborted=!1,this._listeners=[]}dispatchEvent(e){e.type===`abort`&&(this.aborted=!0,this.onabort(e),this._listeners.forEach(t=>t(e),this))}onabort(){}addEventListener(e,t){e===`abort`&&this._listeners.push(t)}removeEventListener(e,t){e===`abort`&&(this._listeners=this._listeners.filter(e=>e!==t))}},ke=new Set,Ae=(e,t)=>{let n=`LRU_CACHE_OPTION_${e}`;Pe(n)&&Fe(n,`${e} option`,`options.${t}`,ze)},je=(e,t)=>{let n=`LRU_CACHE_METHOD_${e}`;if(Pe(n)){let{prototype:r}=ze,{get:i}=Object.getOwnPropertyDescriptor(r,e);Fe(n,`${e} method`,`cache.${t}()`,i)}},Me=(e,t)=>{let n=`LRU_CACHE_PROPERTY_${e}`;if(Pe(n)){let{prototype:r}=ze,{get:i}=Object.getOwnPropertyDescriptor(r,e);Fe(n,`${e} property`,`cache.${t}`,i)}},Ne=(...e)=>{typeof process==`object`&&process&&typeof process.emitWarning==`function`?process.emitWarning(...e):console.error(...e)},Pe=e=>!ke.has(e),Fe=(e,t,n,r)=>{ke.add(e),Ne(`The ${t} is deprecated. Please use ${n} instead.`,`DeprecationWarning`,e,r)},K=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Ie=e=>K(e)?e<=2**8?Uint8Array:e<=2**16?Uint16Array:e<=2**32?Uint32Array:e<=2**53-1?Le:null:null;var Le=class extends Array{constructor(e){super(e),this.fill(0)}},Re=class{constructor(e){if(e===0)return[];this.heap=new(Ie(e))(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},ze=class e{constructor(t={}){let{max:n=0,ttl:r,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:s,allowStale:c,dispose:l,disposeAfter:u,noDisposeOnSet:d,noUpdateTTL:f,maxSize:p=0,maxEntrySize:m=0,sizeCalculation:h,fetchMethod:g,fetchContext:_,noDeleteOnFetchRejection:v,noDeleteOnStaleGet:y,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:x,ignoreFetchAbort:S}=t,{length:C,maxAge:w,stale:T}=t instanceof e?{}:t;if(n!==0&&!K(n))throw TypeError(`max option must be a nonnegative integer`);let E=n?Ie(n):Array;if(!E)throw Error(`invalid max value: `+n);if(this.max=n,this.maxSize=p,this.maxEntrySize=m||this.maxSize,this.sizeCalculation=h||C,this.sizeCalculation){if(!this.maxSize&&!this.maxEntrySize)throw TypeError(`cannot set sizeCalculation without setting maxSize or maxEntrySize`);if(typeof this.sizeCalculation!=`function`)throw TypeError(`sizeCalculation set to non-function`)}if(this.fetchMethod=g||null,this.fetchMethod&&typeof this.fetchMethod!=`function`)throw TypeError(`fetchMethod must be a function if specified`);if(this.fetchContext=_,!this.fetchMethod&&_!==void 0)throw TypeError(`cannot set fetchContext without fetchMethod`);if(this.keyMap=new Map,this.keyList=Array(n).fill(null),this.valList=Array(n).fill(null),this.next=new E(n),this.prev=new E(n),this.head=0,this.tail=0,this.free=new Re(n),this.initialFill=1,this.size=0,typeof l==`function`&&(this.dispose=l),typeof u==`function`?(this.disposeAfter=u,this.disposed=[]):(this.disposeAfter=null,this.disposed=null),this.noDisposeOnSet=!!d,this.noUpdateTTL=!!f,this.noDeleteOnFetchRejection=!!v,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!x,this.ignoreFetchAbort=!!S,this.maxEntrySize!==0){if(this.maxSize!==0&&!K(this.maxSize))throw TypeError(`maxSize must be a positive integer if specified`);if(!K(this.maxEntrySize))throw TypeError(`maxEntrySize must be a positive integer if specified`);this.initializeSizeTracking()}if(this.allowStale=!!c||!!T,this.noDeleteOnStaleGet=!!y,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!s,this.ttlResolution=K(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=r||w||0,this.ttl){if(!K(this.ttl))throw TypeError(`ttl must be a positive integer if specified`);this.initializeTTLTracking()}if(this.max===0&&this.ttl===0&&this.maxSize===0)throw TypeError(`At least one of max, maxSize, or ttl is required`);if(!this.ttlAutopurge&&!this.max&&!this.maxSize){let t=`LRU_CACHE_UNBOUNDED`;Pe(t)&&(ke.add(t),Ne(`TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.`,`UnboundedCacheWarning`,t,e))}T&&Ae(`stale`,`allowStale`),w&&Ae(`maxAge`,`ttl`),C&&Ae(`length`,`sizeCalculation`)}getRemainingTTL(e){return this.has(e,{updateAgeOnHas:!1})?1/0:0}initializeTTLTracking(){this.ttls=new Le(this.max),this.starts=new Le(this.max),this.setItemTTL=(e,t,n=we.now())=>{if(this.starts[e]=t===0?0:n,this.ttls[e]=t,t!==0&&this.ttlAutopurge){let n=setTimeout(()=>{this.isStale(e)&&this.delete(this.keyList[e])},t+1);n.unref&&n.unref()}},this.updateItemAge=e=>{this.starts[e]=this.ttls[e]===0?0:we.now()},this.statusTTL=(n,r)=>{n&&(n.ttl=this.ttls[r],n.start=this.starts[r],n.now=e||t(),n.remainingTTL=n.now+n.ttl-n.start)};let e=0,t=()=>{let t=we.now();if(this.ttlResolution>0){e=t;let n=setTimeout(()=>e=0,this.ttlResolution);n.unref&&n.unref()}return t};this.getRemainingTTL=n=>{let r=this.keyMap.get(n);return r===void 0?0:this.ttls[r]===0||this.starts[r]===0?1/0:this.starts[r]+this.ttls[r]-(e||t())},this.isStale=n=>this.ttls[n]!==0&&this.starts[n]!==0&&(e||t())-this.starts[n]>this.ttls[n]}updateItemAge(e){}statusTTL(e,t){}setItemTTL(e,t,n){}isStale(e){return!1}initializeSizeTracking(){this.calculatedSize=0,this.sizes=new Le(this.max),this.removeItemSize=e=>{this.calculatedSize-=this.sizes[e],this.sizes[e]=0},this.requireSize=(e,t,n,r)=>{if(this.isBackgroundFetch(t))return 0;if(!K(n))if(r){if(typeof r!=`function`)throw TypeError(`sizeCalculation must be a function`);if(n=r(t,e),!K(n))throw TypeError(`sizeCalculation return invalid (expect positive integer)`)}else throw TypeError(`invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.`);return n},this.addItemSize=(e,t,n)=>{if(this.sizes[e]=t,this.maxSize){let t=this.maxSize-this.sizes[e];for(;this.calculatedSize>t;)this.evict(!0)}this.calculatedSize+=this.sizes[e],n&&(n.entrySize=t,n.totalCalculatedSize=this.calculatedSize)}}removeItemSize(e){}addItemSize(e,t){}requireSize(e,t,n,r){if(n||r)throw TypeError(`cannot set size without setting maxSize or maxEntrySize on cache`)}*indexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.tail;!(!this.isValidIndex(t)||((e||!this.isStale(t))&&(yield t),t===this.head));)t=this.prev[t]}*rindexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.head;!(!this.isValidIndex(t)||((e||!this.isStale(t))&&(yield t),t===this.tail));)t=this.next[t]}isValidIndex(e){return e!==void 0&&this.keyMap.get(this.keyList[e])===e}*entries(){for(let e of this.indexes())this.valList[e]!==void 0&&this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield[this.keyList[e],this.valList[e]])}*rentries(){for(let e of this.rindexes())this.valList[e]!==void 0&&this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield[this.keyList[e],this.valList[e]])}*keys(){for(let e of this.indexes())this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.keyList[e])}*rkeys(){for(let e of this.rindexes())this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.keyList[e])}*values(){for(let e of this.indexes())this.valList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.valList[e])}*rvalues(){for(let e of this.rindexes())this.valList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.valList[e])}[Symbol.iterator](){return this.entries()}find(e,t){for(let n of this.indexes()){let r=this.valList[n],i=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;if(i!==void 0&&e(i,this.keyList[n],this))return this.get(this.keyList[n],t)}}forEach(e,t=this){for(let n of this.indexes()){let r=this.valList[n],i=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.keyList[n],this)}}rforEach(e,t=this){for(let n of this.rindexes()){let r=this.valList[n],i=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.keyList[n],this)}}get prune(){return je(`prune`,`purgeStale`),this.purgeStale}purgeStale(){let e=!1;for(let t of this.rindexes({allowStale:!0}))this.isStale(t)&&(this.delete(this.keyList[t]),e=!0);return e}dump(){let e=[];for(let t of this.indexes({allowStale:!0})){let n=this.keyList[t],r=this.valList[t],i=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;if(i===void 0)continue;let a={value:i};if(this.ttls){a.ttl=this.ttls[t];let e=we.now()-this.starts[t];a.start=Math.floor(Date.now()-e)}this.sizes&&(a.size=this.sizes[t]),e.unshift([n,a])}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let e=Date.now()-n.start;n.start=we.now()-e}this.set(t,n.value,n)}}dispose(e,t,n){}set(e,t,{ttl:n=this.ttl,start:r,noDisposeOnSet:i=this.noDisposeOnSet,size:a=0,sizeCalculation:o=this.sizeCalculation,noUpdateTTL:s=this.noUpdateTTL,status:c}={}){if(a=this.requireSize(e,t,a,o),this.maxEntrySize&&a>this.maxEntrySize)return c&&(c.set=`miss`,c.maxEntrySizeExceeded=!0),this.delete(e),this;let l=this.size===0?void 0:this.keyMap.get(e);if(l===void 0)l=this.newIndex(),this.keyList[l]=e,this.valList[l]=t,this.keyMap.set(e,l),this.next[this.tail]=l,this.prev[l]=this.tail,this.tail=l,this.size++,this.addItemSize(l,a,c),c&&(c.set=`add`),s=!1;else{this.moveToTail(l);let n=this.valList[l];if(t!==n){if(this.isBackgroundFetch(n)?n.__abortController.abort(Error(`replaced`)):i||(this.dispose(n,e,`set`),this.disposeAfter&&this.disposed.push([n,e,`set`])),this.removeItemSize(l),this.valList[l]=t,this.addItemSize(l,a,c),c){c.set=`replace`;let e=n&&this.isBackgroundFetch(n)?n.__staleWhileFetching:n;e!==void 0&&(c.oldValue=e)}}else c&&(c.set=`update`)}if(n!==0&&this.ttl===0&&!this.ttls&&this.initializeTTLTracking(),s||this.setItemTTL(l,n,r),this.statusTTL(c,l),this.disposeAfter)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return this}newIndex(){return this.size===0?this.tail:this.size===this.max&&this.max!==0?this.evict(!1):this.free.length===0?this.initialFill++:this.free.pop()}pop(){if(this.size){let e=this.valList[this.head];return this.evict(!0),e}}evict(e){let t=this.head,n=this.keyList[t],r=this.valList[t];return this.isBackgroundFetch(r)?r.__abortController.abort(Error(`evicted`)):(this.dispose(r,n,`evict`),this.disposeAfter&&this.disposed.push([r,n,`evict`])),this.removeItemSize(t),e&&(this.keyList[t]=null,this.valList[t]=null,this.free.push(t)),this.head=this.next[t],this.keyMap.delete(n),this.size--,t}has(e,{updateAgeOnHas:t=this.updateAgeOnHas,status:n}={}){let r=this.keyMap.get(e);if(r!==void 0)if(this.isStale(r))n&&(n.has=`stale`,this.statusTTL(n,r));else return t&&this.updateItemAge(r),n&&(n.has=`hit`),this.statusTTL(n,r),!0;else n&&(n.has=`miss`);return!1}peek(e,{allowStale:t=this.allowStale}={}){let n=this.keyMap.get(e);if(n!==void 0&&(t||!this.isStale(n))){let e=this.valList[n];return this.isBackgroundFetch(e)?e.__staleWhileFetching:e}}backgroundFetch(e,t,n,r){let i=t===void 0?void 0:this.valList[t];if(this.isBackgroundFetch(i))return i;let a=new Te;n.signal&&n.signal.addEventListener(`abort`,()=>a.abort(n.signal.reason));let o={signal:a.signal,options:n,context:r},s=(r,i=!1)=>{let{aborted:s}=a.signal,c=n.ignoreFetchAbort&&r!==void 0;return n.status&&(s&&!i?(n.status.fetchAborted=!0,n.status.fetchError=a.signal.reason,c&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),s&&!c&&!i?l(a.signal.reason):(this.valList[t]===d&&(r===void 0?d.__staleWhileFetching?this.valList[t]=d.__staleWhileFetching:this.delete(e):(n.status&&(n.status.fetchUpdated=!0),this.set(e,r,o.options))),r)},c=e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),l(e)),l=r=>{let{aborted:i}=a.signal,o=i&&n.allowStaleOnFetchAbort,s=o||n.allowStaleOnFetchRejection,c=s||n.noDeleteOnFetchRejection;if(this.valList[t]===d&&(!c||d.__staleWhileFetching===void 0?this.delete(e):o||(this.valList[t]=d.__staleWhileFetching)),s)return n.status&&d.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),d.__staleWhileFetching;if(d.__returned===d)throw r},u=(t,r)=>{this.fetchMethod(e,i,o).then(e=>t(e),r),a.signal.addEventListener(`abort`,()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(t(),n.allowStaleOnFetchAbort&&(t=e=>s(e,!0)))})};n.status&&(n.status.fetchDispatched=!0);let d=new Promise(u).then(s,c);return d.__abortController=a,d.__staleWhileFetching=i,d.__returned=null,t===void 0?(this.set(e,d,{...o.options,status:void 0}),t=this.keyMap.get(e)):this.valList[t]=d,d}isBackgroundFetch(e){return e&&typeof e==`object`&&typeof e.then==`function`&&Object.prototype.hasOwnProperty.call(e,`__staleWhileFetching`)&&Object.prototype.hasOwnProperty.call(e,`__returned`)&&(e.__returned===e||e.__returned===null)}async fetch(e,{allowStale:t=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:i=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:o=0,sizeCalculation:s=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:f=this.allowStaleOnFetchAbort,fetchContext:p=this.fetchContext,forceRefresh:m=!1,status:h,signal:g}={}){if(!this.fetchMethod)return h&&(h.fetch=`get`),this.get(e,{allowStale:t,updateAgeOnGet:n,noDeleteOnStaleGet:r,status:h});let _={allowStale:t,updateAgeOnGet:n,noDeleteOnStaleGet:r,ttl:i,noDisposeOnSet:a,size:o,sizeCalculation:s,noUpdateTTL:c,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:f,ignoreFetchAbort:d,status:h,signal:g},v=this.keyMap.get(e);if(v===void 0){h&&(h.fetch=`miss`);let t=this.backgroundFetch(e,v,_,p);return t.__returned=t}else{let r=this.valList[v];if(this.isBackgroundFetch(r)){let e=t&&r.__staleWhileFetching!==void 0;return h&&(h.fetch=`inflight`,e&&(h.returnedStale=!0)),e?r.__staleWhileFetching:r.__returned=r}let i=this.isStale(v);if(!m&&!i)return h&&(h.fetch=`hit`),this.moveToTail(v),n&&this.updateItemAge(v),this.statusTTL(h,v),r;let a=this.backgroundFetch(e,v,_,p),o=a.__staleWhileFetching!==void 0,s=o&&t;return h&&(h.fetch=o&&i?`stale`:`refresh`,s&&i&&(h.returnedStale=!0)),s?a.__staleWhileFetching:a.__returned=a}}get(e,{allowStale:t=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:i}={}){let a=this.keyMap.get(e);if(a!==void 0){let o=this.valList[a],s=this.isBackgroundFetch(o);return this.statusTTL(i,a),this.isStale(a)?(i&&(i.get=`stale`),s?(i&&(i.returnedStale=t&&o.__staleWhileFetching!==void 0),t?o.__staleWhileFetching:void 0):(r||this.delete(e),i&&(i.returnedStale=t),t?o:void 0)):(i&&(i.get=`hit`),s?o.__staleWhileFetching:(this.moveToTail(a),n&&this.updateItemAge(a),o))}else i&&(i.get=`miss`)}connect(e,t){this.prev[t]=e,this.next[e]=t}moveToTail(e){e!==this.tail&&(e===this.head?this.head=this.next[e]:this.connect(this.prev[e],this.next[e]),this.connect(this.tail,e),this.tail=e)}get del(){return je(`del`,`delete`),this.delete}delete(e){let t=!1;if(this.size!==0){let n=this.keyMap.get(e);if(n!==void 0)if(t=!0,this.size===1)this.clear();else{this.removeItemSize(n);let t=this.valList[n];this.isBackgroundFetch(t)?t.__abortController.abort(Error(`deleted`)):(this.dispose(t,e,`delete`),this.disposeAfter&&this.disposed.push([t,e,`delete`])),this.keyMap.delete(e),this.keyList[n]=null,this.valList[n]=null,n===this.tail?this.tail=this.prev[n]:n===this.head?this.head=this.next[n]:(this.next[this.prev[n]]=this.next[n],this.prev[this.next[n]]=this.prev[n]),this.size--,this.free.push(n)}}if(this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return t}clear(){for(let e of this.rindexes({allowStale:!0})){let t=this.valList[e];if(this.isBackgroundFetch(t))t.__abortController.abort(Error(`deleted`));else{let n=this.keyList[e];this.dispose(t,n,`delete`),this.disposeAfter&&this.disposed.push([t,n,`delete`])}}if(this.keyMap.clear(),this.valList.fill(null),this.keyList.fill(null),this.ttls&&(this.ttls.fill(0),this.starts.fill(0)),this.sizes&&this.sizes.fill(0),this.head=0,this.tail=0,this.initialFill=1,this.free.length=0,this.calculatedSize=0,this.size=0,this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift())}get reset(){return je(`reset`,`clear`),this.clear}get length(){return Me(`length`,`size`),this.size}static get AbortController(){return Te}static get AbortSignal(){return Oe}},Be=ze;const Ve=/(-?[0-9]+(px|em)\s+|0\s+)(-?[0-9]+(px|em)\s+|0\s+)(-?[0-9]+(px|em)\s+|0\s+)?(-?[0-9]+(px|em)\s+|0\s+)?(.*)/g,He={},Ue=typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(`firefox`),We={};var Ge=class{constructor(e,t){O(this,`canvas`,void 0),O(this,`ctx`,void 0),O(this,`options`,void 0),O(this,`imagesPending`,0),O(this,`imagesLoaded`,0),O(this,`imageIdsLoaded`,[]),O(this,`frameIsRendering`,!1),O(this,`pendingDrawCall`,!1),O(this,`firstMeaningfulPaint`,!1),O(this,`parallelTasks`,8),O(this,`frameTasks`,0),O(this,`loadingQueueOrdered`,!0),O(this,`loadingQueue`,[]),O(this,`currentTask`,Promise.resolve()),O(this,`tasksRunning`,0),O(this,`stats`,void 0),O(this,`averageJobTime`,64),O(this,`lastKnownScale`,1),O(this,`visible`,[]),O(this,`previousVisible`,[]),O(this,`rendererPosition`,void 0),O(this,`dpi`,void 0),O(this,`drawCalls`,[]),O(this,`lastPaintedObject`,void 0),O(this,`hostCache`,void 0),O(this,`invalidated`,[]),O(this,`_worker`,()=>{if(this.loadingQueue.length){let e=this.loadingQueue.pop();e&&(this.tasksRunning++,this.frameTasks++,this.currentTask=e.task().then(()=>{this.tasksRunning--}).catch(()=>{this.tasksRunning--}))}}),O(this,`_scheduled`,0),O(this,`_doWork`,()=>{this.loadingQueue.length===0&&this.tasksRunning===0&&this._scheduled&&(clearInterval(this._scheduled),this._scheduled=0);let e=this.parallelTasks||1;!this.firstMeaningfulPaint&&this.loadingQueue.length&&(e=this.loadingQueue.length);for(let t=0;t<=e;t++)this._worker()}),this.canvas=e,this.rendererPosition=e.getBoundingClientRect(),this.ctx=e.getContext(`2d`,{alpha:!0}),this.ctx.imageSmoothingEnabled=!0,this.options=t||{},this.canvas.style.transition=`opacity .3s`,this.dpi=t?.dpi||1,this.hostCache=t?.lruCache?new Be({maxSize:1024*512*512,dispose:(e,t,n)=>{this.invalidated.push(t),e.width=0,e.height=0},sizeCalculation:(e,t)=>e.width*e.height}):{store:{},get(e){return this.store[e]},set(e,t){this.store[e]=t}}}getCanvasDims(){return{width:this.canvas.width/this.dpi,height:this.canvas.height/this.dpi}}resize(){this.rendererPosition=this.canvas.getBoundingClientRect()}isReady(){return this.firstMeaningfulPaint}afterFrame(e){if(this.clearTransform(),this.lastPaintedObject=void 0,this.frameIsRendering=!1,this.imagesPending=Math.max(0,this.imagesPending-this.imagesLoaded),this.imagesLoaded=0,this.loadingQueueOrdered||(this.loadingQueue=this.loadingQueue.sort((e,t)=>e.network&&e.scale===t.scale?t.distance-e.distance:e.scale<t.scale?-1:1),this.loadingQueueOrdered=!0),this.previousVisible=this.visible,this.pendingDrawCall=!!this.drawCalls.length,this.pendingDrawCall)for(let e=0;e<this.drawCalls.length;e++){let e=this.drawCalls.shift();e&&e()}this.doOffscreenWork(),this.options.debug&&this.stats&&this.stats.end()}doOffscreenWork(){this.frameTasks=0,this.loadingQueue.length&&(this._worker(),this.loadingQueue.length&&(this._scheduled||(this._scheduled=setInterval(this._doWork,0))))}getScale(e,t,n){if(Number.isNaN(e)||Number.isNaN(t))return this.lastKnownScale;let r=this.getCanvasDims(),i=r.width/e,a=r.height/t,o=(i<a?a:i)*(n&&this.dpi||1);return Number.isNaN(o)||(this.lastKnownScale=o),this.lastKnownScale}beforeFrame(e,t,n,r){this.options.debug&&this.stats&&this.stats.begin(),this.frameIsRendering=!0,this.visible=[],this.options.beforeFrame&&this.options.beforeFrame(t);let i=this.getCanvasDims();if(this.ctx.globalAlpha=1,this.canvas.dataset.background===`transparent`?this.ctx.clearRect(0,0,i.width,i.height):(this.ctx.fillStyle=this.canvas.dataset.background??`rgb(0, 0, 0)`,this.ctx.fillRect(0,0,i.width,i.height)),r.enableFilters&&(r.filters.brightness||r.filters.contrast||r.filters.grayscale||r.filters.invert||r.filters.sepia||r.filters.saturate||r.filters.hueRotate||r.filters.blur)){let e=``;r.filters.brightness&&(e+=`brightness(${~~(100+r.filters.brightness*100)}%) `),r.filters.contrast&&(e+=`contrast(${~~(100+r.filters.contrast*100)}%) `),r.filters.grayscale&&(e+=`grayscale(${~~(r.filters.grayscale*100)}%) `),r.filters.invert&&(e+=`invert(${~~(r.filters.invert*100)}%) `),r.filters.sepia&&(e+=`sepia(${~~(r.filters.sepia*100)}%) `),r.filters.saturate&&(e+=`saturate(${~~(100+r.filters.saturate*100)}%) `),r.filters.hueRotate&&(e+=`hue-rotate(${r.filters.hueRotate}deg) `),r.filters.blur&&(e+=`blur(${r.filters.blur}px) `),this.ctx.filter!==e&&(this.ctx.filter=e)}else this.ctx.filter=`none`}applyTransform(e,t,n,r,i){let a=e.__owner.value;if(a&&a.rotation){this.ctx.save();let e=t+r/2,o=n+i/2;this.ctx.translate(e,o),this.ctx.rotate(a.rotation*Math.PI/180),this.ctx.translate(-e,-o),this.lastPaintedObject=a}}clearTransform(){this.lastPaintedObject&&(this.lastPaintedObject.rotation&&this.ctx.restore(),this.lastPaintedObject=void 0)}paint(e,t,n,r,i,a){let o=this.ctx.globalAlpha;if(e instanceof A||e instanceof P){if(e.display.rotation){this.ctx.save();let o=n+i/2,s=r+a/2;e.crop&&(o-=e.crop[t*5+1],s-=e.crop[t*5+2]),this.ctx.translate(o,s),this.ctx.rotate(e.display.rotation*Math.PI/180),this.ctx.translate(-o,-s)}if(this.visible.push(e),typeof e.style&&e.style.opacity!==`undefined`){if(!e.style.opacity)return;this.ctx.globalAlpha=e.style.opacity}try{let o=e.__host.canvas,s=this.getCanvasDims();if((o.indices.indexOf(t)===-1||this.invalidated.indexOf(o.canvases[t])!==-1)&&this.schedulePaintToCanvas(o,e,t,M({x:n+i/2,y:r+i/2},{x:s.width/2,y:s.height/2})),!this.firstMeaningfulPaint)return;let c=this.hostCache.get(o.canvases[t]);if(c)if(e.crop&&e.cropData){if(e.crop[t*5]){let o=[e.crop[t*5+1]/e.display.scale-e.display.points[t*5+1],e.crop[t*5+2]/e.display.scale-e.display.points[t*5+2],1+(e.crop[t*5+3]-e.crop[t*5+1])/e.display.scale,1+(e.crop[t*5+4]-e.crop[t*5+2])/e.display.scale];o[0]+=e.cropData.x/e.display.scale,o[1]+=e.cropData.y/e.display.scale;let s=e.x*this.lastKnownScale,l=e.y*this.lastKnownScale,u=[n+s,r+l,i,a];u[0]+=s,u[1]+=l,this.ctx.drawImage(c,o[0],o[1],o[2],o[3],u[0],u[1],u[2]+1,u[3]+1)}}else Ue?this.ctx.drawImage(c,0,0,e.display.points[t*5+3]-e.display.points[t*5+1],e.display.points[t*5+4]-e.display.points[t*5+2],n,r,i+1,a+1):this.ctx.drawImage(c,0,0,e.display.points[t*5+3]-e.display.points[t*5+1],e.display.points[t*5+4]-e.display.points[t*5+2],n,r,i+Number.MIN_VALUE+.5,a+Number.MIN_VALUE+.5)}catch{}e.display.rotation&&this.ctx.restore()}let s=e instanceof B&&this.options.box,c=e instanceof Ce&&this.options.polygon;if((s||c)&&!e.props.className&&!e.props.html&&!e.props.href){if(this.visible.push(e),e.props.style){let t=Object.assign({},e.props.style||{},e.hovering?e.props.hoverStyles:{},e.pressing?e.props.pressStyles:{}),o=e.props.relativeStyle?1:i/e.width;t.opacity!==void 0&&(this.ctx.globalAlpha=t.opacity);let s=0;t.borderWidth!==void 0&&(s=parseInt(t.borderWidth,10)*o);let l=0;t.outlineWidth!==void 0&&(l=parseInt(t.outlineWidth,10)*o);let u=0;if(t.outlineOffset!==void 0&&(u=parseInt(t.outlineOffset,10)*o),t.borderColor&&(this.ctx.strokeStyle=t.borderColor),t.boxShadow){let e=t.boxShadow.split(/,(?![^(]*\))/);for(let t of e){let e=He[t]||Ve.exec(t)||Ve.exec(t);He[t]=e,e&&(this.ctx.save(),this.ctx.shadowOffsetX=parseInt(e[1])*this.dpi*o,this.ctx.shadowOffsetY=parseInt(e[3])*this.dpi*o,this.ctx.shadowBlur=parseInt(e[5])*this.dpi*o,this.ctx.shadowColor=e[9],this.ctx.fillStyle=`rgba(0,0,0,1)`,this.ctx.fillRect(n+s,r+s,i,a),this.ctx.restore())}}if(this.ctx.fillStyle=t.backgroundColor||`transparent`,this.ctx.lineWidth=s,c){let t=e.shape,i=t.points||[],a=i.length;this.ctx.beginPath();for(let e=0;e<a;e++)this.ctx.lineTo(n+i[e][0]*this.lastKnownScale,r+i[e][1]*this.lastKnownScale);t.open||this.ctx.closePath(),s&&this.ctx.stroke(),t.open||this.ctx.fill()}else s&&this.ctx.strokeRect(n+s/2,r+s/2,i+s,a+s),this.ctx.fillRect(n+s,r+s,i,a);l&&(t.outlineColor&&(this.ctx.strokeStyle=t.outlineColor),this.ctx.lineWidth=l,this.ctx.strokeRect(n-l/2-u,r-l/2-u,i+s*2+l+u*2,a+s*2+l+u*2))}this.ctx.globalAlpha=o}}loadImage(e,t,n,r=!1){if(We[e]&&We[e].naturalWidth>0){t(We[e]);return}try{let i=!1;r||setTimeout(()=>{i||this.loadImage(e,t,n,!0)},3e3);let a=document.createElement(`img`);a.decoding=`auto`,a.onload=function(){i=!0,t(a),We[e]=a,a.onload=null},this.options.crossOrigin&&(a.crossOrigin=`anonymous`),a.src=e,a.complete&&a.onload({}),a.width}catch(e){console.log(`image error`,e),n(e)}}schedulePaintToCanvas(e,t,n,r){this.imagesPending++,e.indices.push(n);let i=`${t.id}--${t.display.scale}-${n}`,a=this.invalidated.indexOf(i);a!==-1&&this.invalidated.splice(a,1),e.canvases[n]=i,t.__host.canvas.loading=!0,this.loadingQueueOrdered=!1,this.loadingQueue.push({id:i,scale:t.display.scale,network:!0,distance:r,task:()=>new Promise(a=>{if(this.visible.indexOf(t)===-1){this.imagesPending--,e.indices.splice(e.indices.indexOf(n),1),a();return}let o=t.getImageUrl(n);this.loadImage(o,o=>{this.loadingQueue.push({id:i,scale:t.display.scale,distance:r,task:()=>new Promise(r=>{this.imageIdsLoaded.includes(i)||(this.imagesLoaded++,this.imageIdsLoaded.push(i)),e.loaded.push(n),e.loaded.length===e.indices.length&&(e.loading=!1);let a=t.display.points.slice(n*5,n*5+5),s=document.createElement(`canvas`),c=s.getContext(`2d`);s.width=a[3]-a[1],s.height=a[4]-a[2],this.hostCache.set(e.canvases[n],s),this.drawCalls.push(()=>{c.drawImage(o,0,0,a[3]-a[1],a[4]-a[2]),r()})})}),a()},t=>{this.imagesPending--,e.indices.splice(e.indices.indexOf(n),1),a()})})})}afterPaintLayer(e,t){}prepareLayer(e,t){e.__owner.value&&(e.cropData&&this.lastKnownScale*(1/e.display.scale),this.applyTransform(e,t[1],t[2],t[3]-t[1],t[4]-t[2])),(!e.__host||!e.__host.canvas)&&(e instanceof A||e instanceof P)&&this.createImageHost(e)}finishLayer(){this.lastPaintedObject&&this.clearTransform()}createImageHost(e){e.__host=e.__host?e.__host:{},e.__host.canvas={canvas:void 0,canvases:[],indices:[],loaded:[],loading:!1}}getPointsAt(e,t,n,r){return e.getPointsAt(t,n,r)}getViewportBounds(e,t,n){let r=e.getActiveZone();if(r){let e=t[3]-t[1]<r.points[3]-r.points[1],i=t[4]-t[2]<r.points[4]-r.points[2];return{x1:e?r.points[1]-n:r.points[1]+(r.points[3]-r.points[1])/2-(t[3]-t[1])/2,y1:i?r.points[2]-n:r.points[2]+(r.points[4]-r.points[2])/2-(t[4]-t[2])/2,x2:e?r.points[3]+n:r.points[1]+(r.points[3]-r.points[1])/2-(t[3]-t[1])/2,y2:i?r.points[4]+n:r.points[2]+(r.points[4]-r.points[2])/2-(t[4]-t[2])/2}}return null}pendingUpdate(){let e=!this.pendingDrawCall&&this.drawCalls.length===0&&this.imagesPending===0&&this.loadingQueue.length===0&&this.tasksRunning===0;return!e&&this.visible.length===0&&setTimeout(()=>{this.canvas.style.opacity=`1`,this.firstMeaningfulPaint=!0},500),!this.firstMeaningfulPaint&&e&&this.visible.length?(this.canvas.style.opacity=`1`,this.firstMeaningfulPaint=e,!0):this.options.debug?!0:!e}getRendererScreenPosition(){return this.rendererPosition}reset(){this.loadingQueue=[],this.drawCalls=[]}},Ke=class{constructor(e){O(this,`renderers`,[]),O(this,`length`,void 0);for(let t of e)t&&this.renderers.push(t);this.length=this.renderers.length}afterFrame(e,t,n,r){for(let i=0;i<this.length;i++)this.renderers[i].afterFrame(e,t,n,r)}afterPaintLayer(e,t){for(let n=0;n<this.length;n++)this.renderers[n].afterPaintLayer(e,t)}beforeFrame(e,t,n,r){for(let i=0;i<this.length;i++)this.renderers[i].beforeFrame(e,t,n,r)}triggerResize(){for(let e=0;e<this.length;e++){let t=this.renderers[e];t.triggerResize&&t.triggerResize()}}getPointsAt(e,t,n,r){return this.renderers[0].getPointsAt(e,t,n,r)}getScale(e,t){return this.renderers[0].getScale(e,t)}getViewportBounds(e,t,n){return this.renderers[0].getViewportBounds(e,t,n)}getRendererScreenPosition(){return this.renderers[0].getRendererScreenPosition()}isReady(){for(let e=0;e<this.length;e++)if(!this.renderers[e].isReady())return!1;return!0}paint(e,t,n,r,i,a){for(let o=0;o<this.length;o++)this.renderers[o].paint(e,t,n,r,i,a)}pendingUpdate(){for(let e=0;e<this.length;e++)if(this.renderers[e].pendingUpdate())return!0;return!1}prepareLayer(e,t){for(let n=0;n<this.length;n++)this.renderers[n].prepareLayer(e,t)}finishLayer(e,t){for(let n=0;n<this.length;n++)this.renderers[n].finishLayer(e,t)}resize(e,t){for(let n=0;n<this.length;n++)this.renderers[n].resize(e,t)}reset(){for(let e=0;e<this.length;e++)this.renderers[e].reset()}},qe=class{constructor(e){O(this,`canvas`,void 0),O(this,`context`,void 0),O(this,`heightRatio`,1),O(this,`widthRatio`,1),O(this,`target`,new Float32Array(5)),O(this,`initialWidth`,void 0),O(this,`initialHeight`,void 0),O(this,`bounds`,void 0),O(this,`aggregate`,void 0),O(this,`delta`,0),O(this,`renderNextFrame`,!0),this.canvas=e,this.initialWidth=e.width,this.initialHeight=e.height,this.context=e.getContext(`2d`),this.context.globalAlpha=.5,this.aggregate=(0,l.scale)(1)}isReady(){return!0}resize(){this.initialWidth=this.canvas.width,this.initialHeight=this.canvas.height,this.renderNextFrame=!0}afterFrame(e,t,n){if(this.renderNextFrame){this.context.clearRect(0,0,this.canvas.width,this.canvas.height);let t=this.initialWidth/e.width,r=this.initialHeight/e.height,i=this.widthRatio>this.heightRatio?t:r;if(this.target=n,this.bounds){let t=e.getPointsAt(this.bounds,this.aggregate,i);for(let[e,n]of t)if(e instanceof A&&e.__host.canvas){let t=n.length/5;for(let r=0;r<t;r++)e.__host.canvas.canvases[r]&&(n[r+1]*i,n[r+2]*i,(n[r+3]-n[r+1])*i,(n[r+4]-n[r+2])*i)}}e.getPoints().forEach((e,t,n)=>{if(t%5==0&&e){let e={x1:n[t+1]*i,y1:n[t+2]*i,x2:n[t+3]*i,y2:n[t+4]*i,width:(n[t+3]-n[t+1])*i,height:(n[t+4]-n[t+2])*i};this.context.strokeStyle=`red`,this.context.strokeRect(e.x1,e.y1,e.width,e.height)}}),n&&(this.context.strokeStyle=`red`,this.context.lineWidth=window.devicePixelRatio||1,this.context.strokeRect(n[1]*i,n[2]*i,(n[3]-n[1])*i,(n[4]-n[2])*i))}}getActiveZone(e){return null}getPointsAt(e,t,n,r){return e.getPointsAt(t,n,r)}getScale(e,t){return 1}beforeFrame(e,t){this.bounds=l.DnaFactory.singleBox(e.width,e.height)}drawImage(){}afterPaintLayer(e,t){}paint(e,t,n,r,i,a){this.renderNextFrame=!0}prepareLayer(e){}pendingUpdate(){return!1}hasActiveZone(){return!1}getViewportBounds(e,t,n){return null}getRendererScreenPosition(){return this.canvas.getBoundingClientRect()}finishLayer(){}reset(){}},Je=class{constructor(){O(this,`autoWidth`,!1),O(this,`autoHeight`,!0),O(this,`width`,void 0),O(this,`height`,void 0),O(this,`world`,void 0),O(this,`content`,[]),O(this,`viewingDirection`,`left-to-right`),O(this,`rows`,void 0),O(this,`columns`,4),O(this,`spacing`,20),O(this,`reversed`,!1),O(this,`padding`,20),this.world=R.withProps({width:0,height:0,viewingDirection:`left-to-right`}),this.width=0,this.height=0}setViewingDirection(e){this.viewingDirection=e}addContent(e){this.content.push(...e.map(e=>this.world.addObjectAt(e,{width:0,height:0,x:0,y:0})))}setWidth(e){this.width=e}setHeight(e){this.height=e}setSpacing(e){this.spacing=e}setPadding(e){this.padding=e}setRows(e){this.autoWidth=!0,this.rows=e}setColumns(e){this.autoHeight=!0,this.columns=e}recalculate(){if(this.height===0&&this.width===0||this.rows===0||this.columns===0)return;if(this.autoHeight&&!this.width)throw Error(`Cannot set auto height without setting a width`);if(this.autoWidth&&!this.height)throw Error(`Cannot set auto width without setting a height`);(this.viewingDirection===`left-to-right`||this.viewingDirection===`top-to-bottom`)&&this.reversed&&(this.reversed=!1,this.content.reverse()),(this.viewingDirection===`right-to-left`||this.viewingDirection===`bottom-to-top`)&&!this.reversed&&(this.reversed=!0,this.content.reverse());let e=this.content.length,{columns:t,rows:n}=(()=>{if(this.autoWidth&&this.rows){let t=e>this.rows?this.rows:e;return{columns:Math.ceil(e/t),rows:t}}if(this.autoHeight&&this.columns){let t=e>this.columns?this.columns:e;return{columns:t,rows:Math.ceil(e/t)}}throw Error(`Something went wrong.`)})(),r=this.autoWidth?-1:this.width-this.padding*2,i=this.autoWidth?-1:(r-this.spacing*(t-1))/t;if(this.autoHeight&&!this.autoWidth){let r=0,a=this.padding;for(let o=0;o<n&&r!==e;o++){let n=0,o=[];for(let a=0;a<t;a++){let t=this.reversed?e-r:r;if(r===e)break;let a=this.content[t],s=a.width,c=i/(a.width/a.height);o.push([r,i,c,i/s]),c>n&&(n=c),r++}for(let r=0;r<t&&o[r];r++){let t=this.world.getPoints(),i=o[r][0],s=o[r][1],c=o[r][2],l=o[r][3],u=this.padding+r*(this.spacing+s),d=a+(n-c)/2,f=this.reversed?e-i:i,p=t[f*5+1],m=t[f*5+2];this.world.scaleWorldObject(i,l),(p!==u||m!==d)&&this.world.translateWorldObject(f,u-p,d-m)}a+=n+this.spacing}this.height=a+this.padding,this.world.resize(this.width,this.height);return}this.autoWidth&&this.autoHeight,!this.autoWidth&&this.autoHeight}getWorld(){return this.world}},Ye=o(((e,t)=>{var n=!1,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_;function v(){if(!n){n=!0;var e=navigator.userAgent,t=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(e),v=/(Mac OS X)|(Windows)|(Linux)/.exec(e);if(m=/\b(iPhone|iP[ao]d)/.exec(e),h=/\b(iP[ao]d)/.exec(e),f=/Android/i.exec(e),g=/FBAN\/\w+;/i.exec(e),_=/Mobile/i.exec(e),p=!!/Win64/.exec(e),t){r=t[1]?parseFloat(t[1]):t[5]?parseFloat(t[5]):NaN,r&&document&&document.documentMode&&(r=document.documentMode);var y=/(?:Trident\/(\d+.\d+))/.exec(e);c=y?parseFloat(y[1])+4:r,i=t[2]?parseFloat(t[2]):NaN,a=t[3]?parseFloat(t[3]):NaN,o=t[4]?parseFloat(t[4]):NaN,o?(t=/(?:Chrome\/(\d+\.\d+))/.exec(e),s=t&&t[1]?parseFloat(t[1]):NaN):s=NaN}else r=i=a=s=o=NaN;if(v){if(v[1]){var b=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(e);l=b?parseFloat(b[1].replace(`_`,`.`)):!0}else l=!1;u=!!v[2],d=!!v[3]}else l=u=d=!1}}var y={ie:function(){return v()||r},ieCompatibilityMode:function(){return v()||c>r},ie64:function(){return y.ie()&&p},firefox:function(){return v()||i},opera:function(){return v()||a},webkit:function(){return v()||o},safari:function(){return y.webkit()},chrome:function(){return v()||s},windows:function(){return v()||u},osx:function(){return v()||l},linux:function(){return v()||d},iphone:function(){return v()||m},mobile:function(){return v()||m||h||f||_},nativeApp:function(){return v()||g},android:function(){return v()||f},ipad:function(){return v()||h}};t.exports=y})),Xe=o(((e,t)=>{var n=!!(typeof window<`u`&&window.document&&window.document.createElement);t.exports={canUseDOM:n,canUseWorkers:typeof Worker<`u`,canUseEventListeners:n&&!!(window.addEventListener||window.attachEvent),canUseViewport:n&&!!window.screen,isInWorker:!n}})),Ze=o(((e,t)=>{var n=Xe(),r;n.canUseDOM&&(r=document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature(``,``)!==!0);
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`@atlas-viewer/dna`),u=require(`node:crypto`),d=require(`react`);d=c(d);let f=require(`react/jsx-runtime`),p=require(`react-use-measure`);p=c(p);let m=require(`react-reconciler`);m=c(m);let h=require(`@atlas-viewer/iiif-image-api`),g=require(`@iiif/helpers/thumbnail`);const _=`onMouseDown.onMouseEnter.onMouseLeave.onMouseMove.onMouseOut.onMouseOver.onMouseUp.onTouchCancel.onTouchEnd.onTouchMove.onTouchStart.onPointerDown.onPointerMove.onPointerUp.onPointerCancel.onPointerEnter.onPointerLeave.onPointerOver.onPointerOut.onScroll.onWheel.onClick.onDragStart.onDragEnd.onDragEnter.onDragExit.onDrag.onDragOver.onContextMenu`.split(`.`);function v(){return _.reduce((e,t)=>(e[t]=[],e),{})}const y=_.reduce((e,t)=>(e[t.slice(2).toLowerCase()]=t,e[t]=t,e),{}),b=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,x=128;let S,C;function w(e){!S||S.length<e?(S=Buffer.allocUnsafe(e*128),u.webcrypto.getRandomValues(S),C=0):C+e>S.length&&(u.webcrypto.getRandomValues(S),C=0),C+=e}function T(e=21){w(e-=0);let t=``;for(let n=C-e;n<C;n++)t+=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`[S[n]&63];return t}function E(e){"@babel/helpers - typeof";return E=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},E(e)}function D(e,t){if(E(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(E(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ee(e){var t=D(e,`string`);return E(t)==`symbol`?t:t+``}function O(e,t,n){return(t=ee(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var k=class{get crop(){return this._crop}set crop(e){this._crop=e}getObjectsAt(e){return[]}getAllPointsAt(e,t,n){return[]}getScheduledUpdates(e,t){return[]}constructor(){O(this,`__id`,void 0),O(this,`__revision`,0),O(this,`__host`,void 0),O(this,`__onCreate`,void 0),O(this,`__parent`,void 0),O(this,`__owner`,{value:void 0}),O(this,`__state`,{}),O(this,`eventHandlers`,void 0),O(this,`scale`,1),O(this,`layers`,[]),O(this,`time`,[]),O(this,`_crop`,void 0),O(this,`cropData`,void 0),O(this,`id`,void 0),O(this,`addEventListener`,(e,t,n)=>{let r=y[e];if(!this.eventHandlers[r])throw Error(`Unknown event ${r}`);this.eventHandlers[r].indexOf(t)===-1&&this.eventHandlers[r].push(t)}),O(this,`removeEventListener`,(e,t)=>{let n=y[e];if(!this.eventHandlers[n]){console.warn(`Unknown event ${n}`);return}this.eventHandlers[n].indexOf(t)!==-1&&(this.eventHandlers[n]=this.eventHandlers[n].filter(e=>e!==t))}),this.id=this.__id=T(),this.eventHandlers=v()}dispatchEvent(e,t){let n=this.eventHandlers[e],r=n?n.length:0,i=!1;if(r)for(let a=0;a<r;a++)try{n[a]?.(t),i=!0}catch(t){console.error(e,t)}return i}get x(){return this.points[1]}get y(){return this.points[2]}get width(){return this.points[3]-this.points[1]}get height(){return this.points[4]-this.points[2]}translate(e,t){(0,l.mutate)(this.points,(0,l.translate)(e,t))}atScale(e){(0,l.mutate)(this.points,(0,l.scaleAtOrigin)(e,this.x,this.y)),this.scale*=e}transform(e){(0,l.mutate)(this.points,e)}applyProps(e){this.__revision++}appendChild(e){}removeChild(e){}insertBefore(e,t){}hideInstance(){}},A=class e extends k{constructor(e){if(super(),O(this,`type`,`spacial-content`),O(this,`id`,void 0),O(this,`uri`,void 0),O(this,`display`,void 0),O(this,`points`,void 0),O(this,`priority`,void 0),O(this,`style`,{opacity:1}),!e)this.id=``,this.uri=``,this.display={x:0,y:0,scale:1,width:0,height:0,points:(0,l.dna)(5)},this.points=(0,l.dna)(5);else{let t=e.scale||1;this.id=e.id||e.uri,this.uri=e.uri,this.points=l.DnaFactory.singleBox(e.width,e.height,e.x,e.y),this.display={x:0,y:0,scale:t,width:e.width/t,height:e.height/t,points:l.DnaFactory.singleBox(e.width/t,e.height/t),rotation:e?.rotation}}}applyProps(e){let t=e.display?e.display.width:e.target.width,n=e.target.width/t;if(this.id=e.id||e.uri,this.uri=e.uri,this.points.set(l.DnaFactory.singleBox(e.target.width,e.target.height,e.target.x,e.target.y)),e.style&&e.style.opacity!==void 0&&(this.style.opacity=e.style.opacity),e.crop){this.cropData=e.crop;let t=l.DnaFactory.singleBox(e.crop.width,e.crop.height,e.crop.x,e.crop.y);(0,l.mutate)(t,(0,l.translate)(-e.crop.x,-e.crop.y)),this.crop?this.crop.set(t):this.crop=(0,l.dna)(t)}e.display?(this.display.scale=n,this.display.width=e.display.width,this.display.height=e.display.height,this.display.rotation=e.display.rotation,this.display.points=l.DnaFactory.singleBox(e.display.width,e.display.height)):(this.display.scale=n,this.display.width=e.target.width/n,this.display.height=e.target.height/n,this.display.points=l.DnaFactory.singleBox(e.target.width/n,e.target.height/n))}getAllPointsAt(e,t,n){return[[this,this.crop||this.points,t]]}static fromSvg(t,n,r,i){return e.fromImage(`data:image/svg+xml;base64,`+btoa(t),n,r,i)}static fromImage(t,n,r,i){let a=new e;return a.applyProps({uri:t,id:i,display:r,target:n}),a}getImageUrl(){return this.uri}},te=class extends k{constructor(e){if(super(),O(this,`type`,`spacial-content`),O(this,`id`,void 0),O(this,`uri`,void 0),O(this,`display`,void 0),O(this,`points`,void 0),O(this,`getTexture`,void 0),this.getTexture=()=>({source:void 0,hash:-1}),!e)this.id=``,this.uri=``,this.display={x:0,y:0,scale:1,width:0,height:0,points:(0,l.dna)(5)},this.points=(0,l.dna)(5);else{let t=e.scale||1;this.id=e.id||e.uri,this.uri=e.uri,this.points=l.DnaFactory.singleBox(e.width,e.height),this.display={x:0,y:0,scale:t,width:e.width/t,height:e.height/t,points:t===1?this.points:l.DnaFactory.singleBox(e.width/t,e.height/t)}}}applyProps(e){let t=e.display?e.display.width:e.target.width,n=e.target.width/t;this.id=e.id,this.points.set(l.DnaFactory.singleBox(e.target.width,e.target.height)),this.display.scale=n,this.display.width=e.target.width/n,this.display.height=e.target.height/n,this.getTexture=e.getTexture,this.display.points=n===1?this.points:l.DnaFactory.singleBox(e.target.width/n,e.target.height/n)}getAllPointsAt(e,t,n){return[[this,this.points,t]]}};function j(e,t,n=1){let r=t.length;if(r===0)throw Error(`No resources passed in.`);let i=0,a=1/0;for(let o=0;o<r&&!(!t[o]||!t[o].display);o++){let r=ne(t[o].display.scale,e/(n||1));r<a&&(a=r,i=o)}return i}function ne(e,t){return Math.abs(e-t)}function M(e,t){let n=ne(e.x,t.x),r=ne(e.y,t.y);return Math.sqrt(n**2+r**2)}function re(e){let t=e.length;return e.indexOf(`/info.json`)===t-10?e.slice(0,-10):e}function N(e,t,n){return Math.min(Math.max(e,t),n)}var P=class e extends k{constructor(e){super(),O(this,`id`,void 0),O(this,`type`,`spacial-content`),O(this,`display`,void 0),O(this,`tileWidth`,void 0),O(this,`style`,{opacity:1}),O(this,`points`,void 0),O(this,`service`,void 0),O(this,`format`,`jpg`),O(this,`crop2`,void 0),O(this,`version3`,void 0),O(this,`tileUrl`,void 0),this.tileUrl=re(e.url),this.id=e.id||`${this.tileUrl}--${e.scaleFactor}`,this.points=e.displayPoints?e.displayPoints:(0,l.transform)(e.points,(0,l.scale)(e.scaleFactor)),this.tileWidth=e.tileWidth,this.version3=e.version3,this.display={x:0,y:0,width:e.width/e.scaleFactor,height:e.height/e.scaleFactor,points:e.points,scale:e.scaleFactor},e.format&&(this.format=e.format)}applyProps(e){if(e.style&&e.style.opacity!==void 0&&(this.style.opacity=e.style.opacity),e.service!==this.service&&(this.service=e.service),e.format?this.format=e.format:this.format=`jpg`,e.version3!==void 0&&(this.version3=e.version3),e.crop){this.cropData=e.crop;let t=(0,l.dna)([...this.points]),n=t.length/5,r=e.crop.x||0,i=e.crop.y||0,a=e.crop.x+e.crop.width,o=e.crop.y+e.crop.height;for(let e=0;e<n;e++){let n=e*5;t[n+1]<a&&t[n+3]>r&&t[n+2]<o&&t[n+4]>i?(t[n+1]=N(t[n+1],r,a),t[n+3]=N(t[n+3],r,a),t[n+2]=N(t[n+2],i,o),t[n+4]=N(t[n+4],i,o)):t[n]=0}(0,l.mutate)(t,(0,l.translate)(-e.crop.x,-e.crop.y)),this.crop?this.crop.set(t):this.crop=t}}static fromTile(t,n,r,i,a,o,s,c){r.height=r.height?r.height:r.width;let u=s?Math.floor(n.width/i):Math.ceil(n.width/i),d=s?Math.floor(n.height/i):Math.ceil(n.height/i),f=Math.ceil(u/r.width),p=Math.ceil(d/r.height),m=l.DnaFactory.grid(f,p),h=l.DnaFactory.grid(f,p),g=a&&a[`@context`]?Array.isArray(a[`@context`])?a[`@context`]:[a[`@context`]]:[],_=c===void 0?g.indexOf(`http://iiif.io/api/image/3/context.json`)!==-1:c;for(let e=0;e<p;e++)for(let t=0;t<f;t++){let a=t*r.width,o=e*r.height;h.addPoints(a*i,o*i,t===f-1?n.width:(a+r.width)*i,e===p-1?n.height:(o+r.height)*i),m.addPoints(a,o,t===f-1?u:a+r.width,e===p-1?d:o+r.height)}let v=new e({url:t,scaleFactor:i,points:m.build(),displayPoints:h.build(),width:n.width,height:n.height,tileWidth:r.width,format:o,version3:_});return v.applyProps({service:a}),v}getImageUrl(e){let t=this.points.slice(e*5,e*5+5),n=t[3]-t[1],r=t[4]-t[2],i=Math.ceil(n/this.display.scale),a=Math.ceil(r/this.display.scale),o=`${i>this.tileWidth?this.tileWidth:i},`;return this.version3&&(o+=`${a>this.tileWidth?this.tileWidth:a}`),`${this.tileUrl}/${t[1]},${t[2]},${n},${r}/${o}/0/default.${this.format||`jpg`}`}getAllPointsAt(e,t,n){let r=(0,l.hidePointsOutsideRegion)(this.crop||this.points,e);return[[this,r,t]]}transform(e){(0,l.mutate)(this.points,e)}getScheduledUpdates(e,t){return[]}},ie=class extends k{constructor(...e){super(...e),O(this,`type`,`spacial-content`)}getAllPointsAt(e,t,n){return[[this,this.points,t]]}},F=class extends ie{constructor(e){super(),O(this,`id`,void 0),O(this,`display`,void 0),O(this,`points`,void 0),O(this,`images`,[]),O(this,`allImages`,[]),O(this,`scaleFactors`,[]),O(this,`aggregateBuffer`,(0,l.dna)(9)),O(this,`lazyLoader`,void 0),O(this,`isFullyLoaded`,!1),O(this,`maxScaleFactor`,0),O(this,`renderOptions`,void 0),O(this,`_scheduleSortByScales`,!1),O(this,`_sortByScales`,()=>{this._scheduleSortByScales=!1,this.allImages.sort((e,t)=>t.display.width-e.display.width),this.images=[];let e=.1;for(let t of this.allImages)if(!(t.display.width<this.renderOptions.minSize&&t.display.height<this.renderOptions.minSize&&!t.priority)&&!(t instanceof A&&(t.display.width>this.renderOptions.maxImageSize||t.display.height>this.renderOptions.maxImageSize)&&!t.priority)){if(Math.abs(t.display.scale-e)<.25||t.priority){let e=this.images.pop();e&&(e instanceof A||e.priority)?(t.priority&&this.images.push(t),this.images.push(e)):t&&this.images.push(t)}else t&&this.images.push(t);e=t.display.scale}this.images.length===0&&(this.images=[...this.allImages]),this.scaleFactors=this.images.map(e=>e.display.scale),this.maxScaleFactor=Math.max(...this.scaleFactors)}),O(this,`loadFullResource`,async()=>{if(!this.isFullyLoaded&&this.lazyLoader){this.isFullyLoaded=!0;let e=await this.lazyLoader();this.addImages(e)}}),O(this,`fallback`,[this.loadFullResource]),this.id=e.id,this.points=l.DnaFactory.singleBox(e.width,e.height),this.lazyLoader=e.loadFullImages,e.loadFullImages||(this.isFullyLoaded=!0),this.display={x:0,y:0,points:l.DnaFactory.singleBox(e.width,e.height),height:e.height,width:e.width,scale:1},this.renderOptions={renderSmallestFallback:!0,renderLayers:3,minSize:255,maxImageSize:2048,quality:1.5,...e.renderOptions||{}},this.addImages(e.images)}applyProps(e){e.renderSmallestFallback!==void 0&&e.renderSmallestFallback!==this.renderOptions.renderSmallestFallback&&(this.renderOptions.renderSmallestFallback=e.renderSmallestFallback),e.renderLayers!==void 0&&e.renderLayers!==this.renderOptions.renderLayers&&(this.renderOptions.renderLayers=e.renderLayers),e.minSize!==void 0&&e.minSize!==this.renderOptions.minSize&&(this.renderOptions.minSize=e.minSize),e.maxImageSize!==void 0&&e.maxImageSize!==this.renderOptions.maxImageSize&&(this.renderOptions.maxImageSize=e.maxImageSize),e.quality!==void 0&&e.quality!==this.renderOptions.quality&&(this.renderOptions.quality=e.quality)}appendChild(e){this.addImages([e])}removeChild(e){this.images.indexOf(e)!==-1&&(this.images=this.images.filter(t=>t!==e),this.sortByScales())}insertBefore(e,t){this.addImages([e])}hideInstance(){}addImages(e){for(let t of e)t.__parent=this,t.__owner=this.__owner;this.allImages.push(...e.filter(Boolean)),this.sortByScales()}sortByScales(){this._scheduleSortByScales=!0}getScheduledUpdates(e,t){return this._scheduleSortByScales?[this._sortByScales]:this.isFullyLoaded?[]:t>1/this.maxScaleFactor?this.fallback:[]}getAllPointsAt(e,t,n){if(this.images.length===0)return[];let r=j(1/(n||1)/(window.devicePixelRatio||1),this.images,this.renderOptions.quality),i=this.images.length,a=t?(0,l.compose)(t,(0,l.translate)(this.x,this.y)):(0,l.translate)(this.x,this.y);if(r!==this.images.length-1&&this.images[r+1]){let t=[];for(let e=i-1;e>=r;e--)t.push(e);let o=t[0];this.renderOptions.renderLayers&&(t=t.slice(-Math.min(t.length,this.renderOptions.renderLayers))),this.renderOptions.renderSmallestFallback&&t.indexOf(o)===-1&&t.unshift(o);let s=[];for(let r=0;r<t.length;r++)s.push(...this.images[t[r]].getAllPointsAt(e,a,n));return s}return this.images[r].getAllPointsAt(e,a,n)}};function I(e,t,n,r,i){let a=Math.PI/180*i,o=Math.cos(a),s=Math.sin(a);return[o*(n-e)+s*(r-t)+e,o*(r-t)-s*(n-e)+t]}var L=class e extends k{constructor(e,t){super(),O(this,`id`,void 0),O(this,`type`,`world-object`),O(this,`scale`,void 0),O(this,`layers`,void 0),O(this,`points`,void 0),O(this,`worldPoints`,void 0),O(this,`intersectionBuffer`,(0,l.dna)(5)),O(this,`aggregateBuffer`,(0,l.dna)(9)),O(this,`invertedBuffer`,(0,l.dna)(9)),O(this,`rotation`,0),O(this,`filteredPointsBuffer`,void 0),O(this,`_updatedList`,[]),O(this,`geometry`,void 0);let{x:n=0,y:r=0}=t||{};e?(this.id=e.id||``,this.scale=1,this.layers=e.layers,this.points=(0,l.dna)([1,n,r,n+e.width,r+e.height]),this.worldPoints=(0,l.dna)([1,n,r,n+e.width,r+e.height]),this.filteredPointsBuffer=(0,l.dna)(e.layers.length*5)):(this.id=``,this.scale=1,this.layers=[],this.points=(0,l.dna)(5),this.worldPoints=(0,l.dna)(5),this.filteredPointsBuffer=(0,l.dna)(5))}static createWithProps(t){let n=new e;return n.applyProps(t),n}applyProps(e){let t=e.x||0,n=e.y||0;this.id=e.id;let r=e.scale===void 0?this.scale:e.scale;this.points[0]=1,this.points[1]=t,this.points[2]=n,this.points[3]=t+e.width,this.points[4]=n+e.height,this.rotation=e.rotation||0,this.worldPoints[3]=this.worldPoints[1]+e.width,this.worldPoints[4]=this.worldPoints[2]+e.height,e.scale&&e.scale!==1&&this.atScale(r),this.scale=r}appendChild(e){e.points[0]===0&&e.points.set(this.points),e.__owner.value=this,this.addLayers([e])}removeChild(e){this.layers=this.layers.filter(t=>t!==e),this.filteredPointsBuffer=(0,l.dna)(this.layers.length*5)}insertBefore(e,t){let n=this.layers.indexOf(t);if(n===-1||this.layers.indexOf(e)!==-1)return;let r=this.layers.slice(0,n),i=this.layers.slice(n);this.layers=[...r,e,...i]}hideInstance(){console.warn(`hideInstance: not yet implemented`)}getObjectsAt(e,t){if(this.rotation&&(e=this.applyRotation(e)),(0,l.hidePointsOutsideRegion)(this.points,e,this.filteredPointsBuffer)[0]===0)return[];let n=this.layers.length,r=[];for(let i=0;i<n;i++){let n=this.layers[i];if(t&&n.isShape){let t=(0,l.transform)(n.points,(0,l.translate)(this.x,this.y));if(!n.intersects([e[1]-t[1],e[2]-t[2]]))continue}if((0,l.hidePointsOutsideRegion)((0,l.transform)(n.points,(0,l.translate)(this.x,this.y)),e,this.filteredPointsBuffer)[0]!==0&&r.push(n),t){let i=n;r.push(...i.getObjectsAt(e,t))}}return r}applyRotation(e){if(this.rotation){let t={x:e[1],y:e[2]},n={x:e[1],y:e[4]},r={x:e[3],y:e[2]},i={x:e[3],y:e[4]},a=this.points[1]+(this.points[3]-this.points[1])/2,o=this.points[2]+(this.points[4]-this.points[2])/2,[s,c]=I(a,o,t.x,t.y,this.rotation),[u,d]=I(a,o,n.x,n.y,this.rotation),[f,p]=I(a,o,r.x,r.y,this.rotation),[m,h]=I(a,o,i.x,i.y,this.rotation),g=Math.min(s,u,f,m),_=Math.max(s,u,f,m),v=Math.min(c,d,p,h),y=Math.max(c,d,p,h);return(0,l.dna)([e[0],g,v,_,y])}return e}getAllPointsAt(e,t,n){let r=(0,l.compose)((0,l.translate)(this.x,this.y),(0,l.scale)(this.scale),this.aggregateBuffer);this.rotation&&(e=this.applyRotation(e));let i=(0,l.getIntersection)(e,this.points,this.intersectionBuffer),a=this.layers.length,o=[],s=(0,l.transform)(i,(0,l.compose)((0,l.scale)(1/this.scale),(0,l.translate)(-this.x,-this.y),this.invertedBuffer)),c=t?(0,l.compose)(t,r,this.aggregateBuffer):r,u=n*this.scale;for(let e=0;e<a;e++)o.push(...this.layers[e].getAllPointsAt(s,c,u));return o}addLayers(e){let t=[];for(let n of e)this.layers.indexOf(n)===-1&&(t.push(n),n.points.length===5&&(n.points[1]<this.worldPoints[1]/this.scale||n.points[2]<this.worldPoints[2]/this.scale||n.points[3]>this.worldPoints[3]/this.scale||n.points[4]>this.worldPoints[4]/this.scale)&&(n.crop=n.crop||(0,l.dna)([1,Math.max(this.worldPoints[1]/this.scale,n.points[1]),Math.max(this.worldPoints[2]/this.scale,n.points[2]),Math.min(this.worldPoints[3]/this.scale,n.points[3]),Math.min(this.worldPoints[4]/this.scale,n.points[4])])));this.layers=this.layers.concat(t),this.filteredPointsBuffer=(0,l.dna)(this.layers.length*5)}getScheduledUpdates(e,t){let n=this.layers.length;this._updatedList=[];let r=t*this.scale;for(let t=0;t<n;t++){let n=this.layers[t].getScheduledUpdates(e,r);n&&this._updatedList.push(...n)}return this._updatedList}},R=class e extends k{get x(){return 0}get y(){return 0}get width(){return this._width}get height(){return this._height}constructor(e=0,t=0,n=100,r=`left-to-right`){super(),O(this,`id`,`world`),O(this,`_width`,void 0),O(this,`_height`,void 0),O(this,`aspectRatio`,void 0),O(this,`viewingDirection`,void 0),O(this,`aggregateBuffer`,(0,l.dna)(9)),O(this,`isDirty`,!1),O(this,`zones`,[]),O(this,`filteredPointsBuffer`,void 0),O(this,`selectedZone`,void 0),O(this,`triggerQueue`,[]),O(this,`activatedEvents`,[]),O(this,`_updatedList`,[]),O(this,`translationBuffer`,(0,l.dna)(9)),O(this,`needsRecalculate`,!0),O(this,`emptyPaintables`,[]),O(this,`renderOrder`,[]),O(this,`points`,void 0),O(this,`objects`,[]),O(this,`subscriptions`,[]),O(this,`_propagateEventTargets`,[]),O(this,`_alreadyFlushed`,[]),this._width=e,this._height=t,this.aspectRatio=Number.isNaN(e/t)?1:e/t,this.viewingDirection=r,this.points=(0,l.dna)(n*5),this.filteredPointsBuffer=(0,l.dna)(n*5)}static withProps(t){let n=new e;return n.applyProps(t),n}applyProps(e){e.width!==void 0&&e.height!==void 0&&(e.width!==this._width||e.height!==this._height)&&this.resize(e.width,e.height),e.viewingDirection!==this.viewingDirection&&(this.viewingDirection=e.viewingDirection,this.triggerRepaint())}propagateTouchEvent(e,t,n){let r=[];for(let e of n)if(e.x&&e.y){let t=l.DnaFactory.singleBox(1,1,e.x,e.y);r.push(this.getObjectsAt(t,!0).reverse())}return r.map(n=>this.propagateEvent(e,t,n,{bubbles:!0,cancelable:!0}))}propagatePointerEvent(e,t,n,r,i={}){let a=l.DnaFactory.singleBox(1,1,n,r),o=this.getObjectsAt(a,!0).reverse();return this.propagateEvent(e,t,o,i)}propagateEvent(e,t,n,{bubbles:r=!1,cancelable:i=!1}={}){t.atlasTarget=this,this._propagateEventTargets.length=1,this._propagateEventTargets[0]=this;let a=!1;t.stopPropagation=()=>{a=!0};let o=n.length;for(let e=o-1;e>=0;e--){this._propagateEventTargets.unshift(n[e][0]);let t=n[e][1].length;if(t)for(let r=0;r<t;r++)this._propagateEventTargets.unshift(n[e][1][r])}let s=this._propagateEventTargets.length,c=!1;for(let n=0;n<s&&(t.atlasTarget=this._propagateEventTargets[n],t.atlasWorld=this,c=this._propagateEventTargets[n].dispatchEvent(e,t)||c,!a);n++);return c&&this.triggerRepaint(),this._propagateEventTargets}appendChild(e){let t=this.appendWorldObject(e);this.renderOrder.push(t/5)}removeChild(e){let t=this.objects.indexOf(e);if(t===-1){for(let t of this.objects)if(t&&t.id===e.id){this.removeChild(t);return}return}this.objects[t]=null,this.renderOrder=this.renderOrder.filter(e=>e!==t),this.points[t*5]=0,this.triggerRepaint(),this.needsRecalculate=!0}insertBefore(e,t){let n=this.objects.indexOf(t);if(n===-1)return;let r=this.appendWorldObject(e);this.renderOrder.splice(n-1,0,r/5)}hideInstance(){}asWorldObject(){return null}addZone(e){this.zones.push(e)}selectZone(e){if(typeof e==`string`){let t=this.zones.length;for(let n=0;n<t;n++)if(this.zones[n].id===e){this.selectedZone=n,this.trigger(`zone-changed`);return}}else this.zones[e]&&(this.selectedZone=e,this.trigger(`zone-changed`))}deselectZone(){this.selectedZone=void 0}getActiveZone(){if(this.selectedZone)return this.zones[this.selectedZone]}hasActiveZone(){return this.selectedZone!==void 0}checkResizeInternalBuffer(){if((0,l.dnaLength)(this.points)===this.objects.length){let e=this.points,t=(0,l.dna)(this.points.length*2);t.set(e,0),this.points=t}}appendWorldObject(e){this.checkResizeInternalBuffer();let t=this.objects.length*5,n=e.points;return e.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),e.points[1]=n[1],e.points[2]=n[2],e.points[3]=n[3],e.points[4]=n[4],this.objects.push(e),this.filteredPointsBuffer=(0,l.dna)(this.objects.length*5),this.needsRecalculate=!0,this.triggerRepaint(),t}recalculateWorldSize(){let e=!1;if(this.needsRecalculate){let t=new Int32Array(this.objects.length),n=new Int32Array(this.objects.length),r=this.renderOrder.length;for(let e=0;e<r;e++){let r=this.renderOrder[e];this.objects[r]&&(t[e]=this.points[r*5+3],n[e]=this.points[r*5+4])}let i=Math.max(...t);i!==this._width&&(this._width=i,e=!0);let a=Math.max(...n);a!==this._height&&(this._height=a,e=!0),e&&this.trigger(`recalculate-world-size`,{width:i,height:a}),this.needsRecalculate=!1}return e}addObjectAt(e,t){t.width&&!t.height?t.height=t.width/e.width*e.height:t.height&&!t.width&&(t.width=t.height/e.height*e.width),(!t||!t.width||!t.height)&&(t.width=e.width,t.height=e.height);let{width:n,x:r,y:i}=t,a=n/e.width;this.checkResizeInternalBuffer(),this.points.set(l.DnaFactory.singleBox(e.width,e.height,0,0),this.objects.length*5);let o=new L(e);return o.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),this.objects.push(o),this.scaleWorldObject(this.objects.length-1,a),this.translateWorldObject(this.objects.length-1,r,i),this.filteredPointsBuffer=(0,l.dna)(this.points.length*2),this.triggerRepaint(),this.needsRecalculate=!0,o}scaleWorldObject(e,t){(0,l.mutate)(this.points.subarray(e*5,e*5+5),(0,l.scaleAtOrigin)(t,this.points[e*5+1],this.points[e*5+2]));let n=this.objects[e];n&&(n.atScale(t),this.triggerRepaint())}translateWorldObject(e,t,n){(0,l.mutate)(this.points.subarray(e*5,e*5+5),(0,l.translate)(t,n));let r=this.objects[e];r&&(r.translate(t,n),this.triggerRepaint())}resize(e,t){return this._width=e,this._height=t,this.aspectRatio=e/t,this.triggerRepaint(),this}getObjects(){return this.objects}getPoints(){return this.points}getPointsFromViewer(e,t){let n=l.DnaFactory.singleBox(e.width,e.height,e.x,e.y);return this.getPointsAt(n,t,e.scale)}addLayoutSubscriber(e){return this.subscriptions.push(e),()=>{this.subscriptions.splice(this.subscriptions.indexOf(e),1)}}getScheduledUpdates(e,t){let n=(0,l.hidePointsOutsideRegion)(this.points,e,this.filteredPointsBuffer),r=this.objects.length;this._updatedList=[];for(let i=0;i<r;i++)if(n[i*5]!==0){if(!this.objects[i])continue;this._updatedList.push(...this.objects[i].getScheduledUpdates(e,t))}return this._updatedList}getObjectsAt(e,t=!1){let n=this.getActiveZone(),r=(0,l.hidePointsOutsideRegion)(this.points,e,this.filteredPointsBuffer),i=this.renderOrder.length,a=[];for(let o=0;o<i;o++){let i=this.renderOrder[o];if(r[i*5]!==0){let r=this.objects[i];if(!r||n&&n.objects.indexOf(r)===-1)continue;if(r.type!==`world-object`){a.push([r,[r]]);continue}t?a.push([r,r.getObjectsAt(e,t)]):a.push([r,this.emptyPaintables])}}return a}getPointsAt(e,t,n=1){let r=this.getObjectsAt(e),i=(0,l.compose)((0,l.scale)(n),(0,l.translate)(-e[1],-e[2]),this.translationBuffer),a=t?(0,l.compose)(t,i,this.aggregateBuffer):i,o=r.length,s=[];for(let t=0;t<o;t++)r[t]&&s.push(...r[t][0].getAllPointsAt(e,a,n));return s}flushSubscriptions(){if(this.triggerQueue.length){this._alreadyFlushed=[];let e=this.triggerQueue.length;for(let t=0;t<e;t++){if(this._alreadyFlushed.indexOf(this.triggerQueue[t][0])!==-1)continue;this.triggerQueue[t][1]===void 0&&this._alreadyFlushed.push(this.triggerQueue[t][0]);let e=this.subscriptions.length;for(let n=0;n<e;n++)this.subscriptions[n].apply(null,this.triggerQueue[t])}this.triggerQueue=[]}}trigger(e,t){this.triggerQueue.push([e,t])}triggerEventActivation(){this.trigger(`event-activation`)}triggerRepaint(){this.trigger(`repaint`)}gotoRegion(e){this.trigger(`goto-region`,e)}goHome(e=!1,t){this.trigger(`go-home`,{immediate:e,paddingPx:t})}zoomTo(e,t,n){this.trigger(`zoom-to`,{point:t,factor:e,stream:n})}zoomIn(e){this.trigger(`zoom-to`,{point:e,factor:.5})}zoomOut(e){this.trigger(`zoom-to`,{point:e,factor:2})}constraintBounds(e){this.trigger(`constrain-bounds`,{immediate:e})}};function ae(e){let{src:t,target:n}=e,r=n?n.width:e.width,i=n?n.height:e.height;return new L({id:t,height:i,width:r,layers:[A.fromImage(t,{height:i,width:r},{width:e.width,height:e.height})]})}const oe={margin:0};var se=class{constructor(e,t={}){O(this,`id`,void 0),O(this,`config`,void 0),O(this,`points`,void 0),O(this,`objects`,void 0),this.id=e.map(e=>e.id).join(`$$`),this.config={...oe,...t},this.points=(0,l.dna)(5),this.objects=e,this.recalculateBounds()}recalculateBounds(){this.points.set([1,Math.min(...this.objects.map(e=>e.points[1]))-this.config.margin,Math.min(...this.objects.map(e=>e.points[2]))-this.config.margin,Math.max(...this.objects.map(e=>e.points[3]))+this.config.margin,Math.max(...this.objects.map(e=>e.points[4]))+this.config.margin])}getPointsAt(e,t,n){return[]}};const z=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,ce={},le=[`backgroundColor`,`opacity`,`boxShadow`,`borderColor`,`borderWidth`,`borderStyle`,`outlineColor`,`outlineWidth`,`outlineOffset`,`outlineStyle`];var B=class extends k{constructor(){super(),O(this,`id`,void 0),O(this,`type`,`spacial-content`),O(this,`points`,void 0),O(this,`hoverEvents`,!1),O(this,`activeEvents`,!1),O(this,`display`,{x:0,y:0,scale:1,width:-1,height:-1,points:(0,l.dna)(5)}),O(this,`_parsed`,{border:{id:null,match:[]},outline:{id:null,match:[]}}),O(this,`hovering`,void 0),O(this,`pressing`,void 0),O(this,`props`,{}),O(this,`addHover`,()=>{this.hovering=!0,this.__revision++}),O(this,`removeHover`,()=>{this.hovering=!1,this.pressing=!1,this.__revision++}),O(this,`addPress`,()=>{this.pressing=!0,this.__revision++}),O(this,`removePress`,()=>{this.pressing=!1,this.__revision++}),this.id=T(12),this.points=(0,l.dna)(5)}getAllPointsAt(e,t){return[[this,this.points,t]]}applyProps(e={}){let t=!1;if(e.interactive!==this.props.interactive&&(t=!0,this.props.interactive=e.interactive),e.style){let n=e.border||e.style.border;if(n!==this._parsed.border.id)if(!n)this._parsed.border.id=null,this._parsed.border.match=[];else{let e=ce[n]||z.exec(n)||z.exec(n);e&&(this._parsed.border.id=n,this._parsed.border.match=ce[n]=e)}if(this._parsed.border.id&&(e.style.borderWidth=this._parsed.border.match[1],e.style.borderStyle=`solid`,e.style.borderColor=this._parsed.border.match[4]),e.style.outline!==this._parsed.outline.id)if(!e.style.outline)this._parsed.outline.id=null,this._parsed.outline.match=[];else{let t=ce[e.style.outline]||z.exec(e.style.outline)||z.exec(e.style.outline);t&&(this._parsed.outline.id=e.style.outline,this._parsed.outline.match=ce[e.style.outline]=t)}this._parsed.outline.id&&(e.style.outlineWidth=this._parsed.outline.match[1],e.style.outlineStyle=`solid`,e.style.outlineColor=this._parsed.outline.match[4]),this.props.style=e.style,e.backgroundColor&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=e.backgroundColor,t=!0),e.style.background&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=e.style.background,t=!0);for(let n of le)if(this.props.style[n]!==e.style[n]){t=!0;break}e.style[`:hover`]!==this.props.hoverStyles&&(this.props.hoverStyles=e.style[`:hover`],this.hoverEvents||(this.hoverEvents=!0,this.addEventListener(`pointerenter`,this.addHover),this.addEventListener(`pointerleave`,this.removeHover)),t=!0),e.style[`:active`]!==this.props.pressStyles&&(this.props.pressStyles=e.style[`:active`],this.activeEvents||(this.activeEvents=!0,this.addEventListener(`mousedown`,this.addPress),this.addEventListener(`mouseup`,this.removePress)),t=!0)}e.href!==this.props.href&&(this.props.href=e.href,t=!0),e.hrefTarget!==this.props.hrefTarget&&(this.props.hrefTarget=e.hrefTarget,t=!0),e.title!==this.props.title&&(this.props.title=e.title,t=!0),e.className!==this.props.className&&(this.props.className=e.className,e.className&&!this.hoverEvents&&(this.hoverEvents=!0,this.addEventListener(`pointerenter`,this.addHover),this.addEventListener(`pointerleave`,this.removeHover)),e.className&&!this.activeEvents&&(this.activeEvents=!0,this.addEventListener(`mousedown`,this.addPress),this.addEventListener(`mouseup`,this.removePress)),t=!0),e.relativeSize!==this.props.relativeSize&&(this.props.relativeSize=e.relativeSize,t=!0),e.relativeStyle!==this.props.relativeStyle&&(this.props.relativeStyle=e.relativeStyle,t=!0),e.html!==this.props.html&&(this.props.html=e.html,t=!0),e.target&&(e.target.width!==this.display.width||e.target.height!==this.display.height||e.target.x!==this.points[1]||e.target.y!==this.points[2])&&(t=!0,this.points=l.DnaFactory.singleBox(e.target.width,e.target.height,e.target.x,e.target.y),this.display.points=l.DnaFactory.singleBox(e.target.width,e.target.height,e.target.x,e.target.y),this.display.width=e.target.width,this.display.height=e.target.height),t&&this.__revision++}},V=class extends k{constructor(){super(),O(this,`type`,`spacial-content`),O(this,`id`,void 0),O(this,`points`,void 0),O(this,`color`,`#000`),O(this,`backgroundColor`,void 0),O(this,`hovering`,void 0),O(this,`pressing`,void 0),O(this,`text`,``),O(this,`display`,{x:0,y:0,scale:1,width:100,height:100,points:(0,l.dna)(5)}),O(this,`className`,void 0),O(this,`html`,void 0),O(this,`interactive`,!1),O(this,`props`,{font:`18px Arial, sans-serif`,lineHeight:1,textAlign:`left`,verticalAlign:`top`,paddingX:0,paddingY:0,fitParent:!1,lineBreak:`auto`,strokeText:!1,sizeToFill:!1,maxFontSizeToFill:void 0,allowNewLine:!0,justifyLines:!1,renderHDPI:!1,textDecoration:`none`,interactive:!1,relativeSize:!1}),this.id=``,this.points=(0,l.dna)(5)}getAllPointsAt(e,t){return[[this,this.points,t]]}applyProps({id:e,target:t,text:n,color:r,backgroundColor:i,fontSize:a=18,interactive:o,fontFamily:s=`Arial, sans-serif`,...c}){c.font=`${a}px ${s}`,this.interactive=o||!1,n!==void 0&&(this.text=n||``),r&&(this.color=r),i&&(this.backgroundColor=i),e&&(this.id=e),t&&(this.points=l.DnaFactory.singleBox(t.width,t.height,t.x,t.y),this.display.points=this.points,this.display.width=t.width,this.display.height=t.height),this.props={...this.props,...c},this.__revision++}};const H=Math.pow,U=Math.sqrt,ue=Math.sin,de=Math.cos,fe=Math.PI,pe=1.70158,me=pe*1.525,he=pe+1,ge=2*fe/3,_e=2*fe/4.5,W=function(e){let t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375},G={linear:e=>e,easeInQuad:function(e){return e*e},easeOutQuad:function(e){return 1-(1-e)*(1-e)},easeInOutQuad:function(e){return e<.5?2*e*e:1-H(-2*e+2,2)/2},easeInCubic:function(e){return e*e*e},easeOutCubic:function(e){return 1-H(1-e,3)},easeInOutCubic:function(e){return e<.5?4*e*e*e:1-H(-2*e+2,3)/2},easeInQuart:function(e){return e*e*e*e},easeOutQuart:function(e){return 1-H(1-e,4)},easeInOutQuart:function(e){return e<.5?8*e*e*e*e:1-H(-2*e+2,4)/2},easeInQuint:function(e){return e*e*e*e*e},easeOutQuint:function(e){return 1-H(1-e,5)},easeInOutQuint:function(e){return e<.5?16*e*e*e*e*e:1-H(-2*e+2,5)/2},easeInSine:function(e){return 1-de(e*fe/2)},easeOutSine:function(e){return ue(e*fe/2)},easeInOutSine:function(e){return-(de(fe*e)-1)/2},easeInExpo:function(e){return e===0?0:H(2,10*e-10)},easeOutExpo:function(e){return e===1?1:1-H(2,-10*e)},easeInOutExpo:function(e){return e===0?0:e===1?1:e<.5?H(2,20*e-10)/2:(2-H(2,-20*e+10))/2},easeInCirc:function(e){return 1-U(1-H(e,2))},easeOutCirc:function(e){return U(1-H(e-1,2))},easeInOutCirc:function(e){return e<.5?(1-U(1-H(2*e,2)))/2:(U(1-H(-2*e+2,2))+1)/2},easeInBack:function(e){return he*e*e*e-pe*e*e},easeOutBack:function(e){return 1+he*H(e-1,3)+pe*H(e-1,2)},easeInOutBack:function(e){return e<.5?H(2*e,2)*((me+1)*2*e-me)/2:(H(2*e-2,2)*((me+1)*(e*2-2)+me)+2)/2},easeInElastic:function(e){return e===0?0:e===1?1:-H(2,10*e-10)*ue((e*10-10.75)*ge)},easeOutElastic:function(e){return e===0?0:e===1?1:H(2,-10*e)*ue((e*10-.75)*ge)+1},easeInOutElastic:function(e){return e===0?0:e===1?1:e<.5?-(H(2,20*e-10)*ue((20*e-11.125)*_e))/2:H(2,-20*e+10)*ue((20*e-11.125)*_e)/2+1},easeInBounce:function(e){return 1-W(1-e)},easeOutBounce:W,easeInOutBounce:function(e){return e<.5?(1-W(1-2*e))/2:(1+W(2*e-1))/2}};var ve=class{constructor(e){O(this,`runtime`,void 0),O(this,`pendingTransition`,void 0),O(this,`lastZoomTo`,null),O(this,`isConstraining`,!1),O(this,`lastGoToRegion`,null),this.runtime=e,this.pendingTransition={from:(0,l.dna)(5),to:(0,l.dna)(5),elapsed_time:0,done:!0,total_time:0,timingFunction:G.easeInOutQuad,constrain:!1}}hasPending(){return!this.pendingTransition.done}getPendingTransition(){return this.pendingTransition}getPendingFrom(){return this.pendingTransition.from}customTransition(e){e(this.pendingTransition)}stopTransition(){this.pendingTransition.from=(0,l.dna)(this.runtime.target),this.pendingTransition.to=(0,l.dna)(this.runtime.target),this.pendingTransition.done=!0,this.pendingTransition.elapsed_time=0,this.pendingTransition.total_time=0}runTransition(e,t){if(!this.pendingTransition.done){let n=this.pendingTransition,r=n.total_time===0?0:(n.elapsed_time+t)/n.total_time,i=n.total_time===0?1:r===0?0:n.timingFunction(r);e[1]=n.from[1]+(n.to[1]-n.from[1])*i,e[2]=n.from[2]+(n.to[2]-n.from[2])*i,e[3]=n.from[3]+(n.to[3]-n.from[3])*i,e[4]=n.from[4]+(n.to[4]-n.from[4])*i,this.pendingTransition.elapsed_time+=t,this.pendingTransition.elapsed_time>=this.pendingTransition.total_time&&(this.pendingTransition.done=!0,this.pendingTransition.callback?.(),this.pendingTransition.constrain&&this.constrainBounds({transition:{duration:this.pendingTransition.total_time===0?0:500,easing:G.easeOutExpo}}))}}resumeTransition(){this.lastZoomTo&&this.zoomTo(this.lastZoomTo.factor,this.lastZoomTo.options),this.isConstraining&&this.constrainBounds(),this.lastGoToRegion&&this.goToRegion(this.lastGoToRegion.target,this.lastGoToRegion.options)}zoomTo(e,t={}){let{origin:n,stream:r=!1,transition:i}=t;this.lastZoomTo={factor:e,options:t};let a=this.runtime.getZoomedPosition(e,{origin:n}),o=Math.abs(1-e);this.applyTransition(a,i,{duration:2e3*o,easing:G.easeOutExpo,constrain:!0,callback:()=>{this.lastZoomTo=null}},{stream:!1})}constrainBounds({transition:e,panPadding:t=0}={}){this.isConstraining=!0;let[n,r]=this.runtime.constrainBounds(this.runtime.target,{panPadding:t});n&&(this.applyTransition(r,e,{duration:500,easing:G.easeOutQuart,constrain:!1,callback:()=>{this.isConstraining=!1}}),this.runtime.updateNextFrame())}applyTransition(e,t,n,{stream:r}={}){this.pendingTransition.from=(0,l.dna)(this.runtime.target),this.pendingTransition.to=e,r||(this.pendingTransition.elapsed_time=0),this.pendingTransition.done=!1,this.pendingTransition.total_time=t?.duration===void 0?n?.duration===void 0?1e3:n.duration:t.duration,this.pendingTransition.constrain=t?.constrain===void 0?n?.constrain===void 0?!1:n.constrain:t.constrain,this.pendingTransition.timingFunction=t?.easing||n?.easing||G.easeInOutSine}goToRegion(e,{transition:t}={}){this.lastGoToRegion={target:e,options:{transition:t}};let n=this.runtime.clampRegion(e);this.applyTransition(l.DnaFactory.singleBox(n.width,n.height,n.x,n.y),t,{duration:1e3,easing:G.easeOutExpo,constrain:!0,callback:()=>{this.lastGoToRegion=null}}),this.runtime.updateNextFrame()}};Number.MIN_VALUE+1;var ye=class{get x(){return this.target[1]}set x(e){this.target[1]=e}get y(){return this.target[2]}set y(e){this.target[2]=e}get x2(){return this.target[3]}set x2(e){this.target[3]=e}get y2(){return this.target[4]}set y2(e){this.target[4]=e}get width(){return this.target[3]-this.target[1]}set width(e){this.target[3]=this.target[1]+e}get height(){return this.target[4]-this.target[2]}set height(e){this.target[4]=this.target[2]=e}constructor(e,t,n,r=[],i){O(this,`id`,T()),O(this,`ready`,!1),O(this,`renderer`,void 0),O(this,`world`,void 0),O(this,`target`,void 0),O(this,`homePosition`,void 0),O(this,`manualHomePosition`,void 0),O(this,`manualFocalPosition`,void 0),O(this,`focalPosition`,void 0),O(this,`homePaddingPx`,void 0),O(this,`transitionManager`,void 0),O(this,`aggregate`,void 0),O(this,`transformBuffer`,(0,l.dna)(500)),O(this,`lastTarget`,(0,l.dna)(5)),O(this,`zoomBuffer`,(0,l.dna)(5)),O(this,`logNextRender`,!1),O(this,`pendingUpdate`,!0),O(this,`isCommitting`,!1),O(this,`firstRender`,!0),O(this,`lastTime`,void 0),O(this,`stopId`,void 0),O(this,`mode`,`explore`),O(this,`controllers`,[]),O(this,`controllersRunning`,!1),O(this,`controllerStopFunctions`,[]),O(this,`maxScaleFactor`,1),O(this,`_viewerToWorld`,{x:0,y:0}),O(this,`_lastGoodScale`,1),O(this,`hooks`,{useFrame:[],useBeforeFrame:[],useAfterPaint:[],useAfterFrame:[]}),O(this,`fpsLimit`,void 0),O(this,`options`,void 0),O(this,`hookOptions`,{filters:{grayscale:0,contrast:0,brightness:0,saturate:0,sepia:0,invert:0,hueRotate:0,blur:0}}),O(this,`_viewport`,{x:0,y:0,width:0,height:0}),O(this,`setViewport`,e=>{let t=Math.round(e.x===void 0?this.target[1]:e.x),n=Math.round(e.y===void 0?this.target[2]:e.y);e.width?this.target[3]=t+e.width:this.target[3]=this.target[3]-this.target[1]+t,e.height?this.target[4]=n+e.height:this.target[4]=this.target[4]-this.target[2]+n,Math.abs(this.target[1]-t)>.01&&(this.target[1]=t),Math.abs(this.target[2]-n)>.01&&(this.target[2]=n),this.pendingUpdate=!0}),O(this,`render`,e=>{let t=e-this.lastTime;if(this.isCommitting||this.fpsLimit&&t<1e3/this.fpsLimit){this.stopId=window.requestAnimationFrame(this.render);return}this.lastTime=e,this.world.flushSubscriptions(),this.stopId=window.requestAnimationFrame(this.render),this.hook(`useFrame`,t);let n=this.pendingUpdate,r=this.renderer.pendingUpdate();if(this.transitionManager.hasPending()&&(this.transitionManager.runTransition(this.target,t),this.pendingUpdate=!0,this.updateControllerPosition()),!this.firstRender&&!n&&!r&&this.target[0]===this.lastTarget[0]&&this.target[1]===this.lastTarget[1]&&this.target[2]===this.lastTarget[2]&&this.target[3]===this.lastTarget[3]&&this.target[4]===this.lastTarget[4])return;this.hook(`useBeforeFrame`,t),this.renderer.beforeFrame(this.world,t,this.target,this.hookOptions);let i=this.getScaleFactor(),a=this.renderer.getPointsAt(this.world,this.target,this.aggregate,i),o=a.length;for(let e=0;e<o;e++){let t=a[e][0],n=a[e][1],r=a[e][2],i=r?(0,l.transform)(n,r,this.transformBuffer):n;this.renderer.prepareLayer(t,t.__parent&&r?(0,l.transform)(t.__parent.crop||t.__parent.points,r):i);let o=i.length/5;for(let e=0;e<o;e++){let n=e*5;i[n]!==0&&(this.renderer.paint(t,e,i[n+1],i[n+2],i[n+3]-i[n+1],i[n+4]-i[n+2]),this.hook(`useAfterPaint`,t))}this.renderer.finishLayer(t,n)}this.renderer.afterFrame(this.world,t,this.target,this.hookOptions),this.hook(`useAfterFrame`,t),this.lastTarget[0]=this.target[0],this.lastTarget[1]=this.target[1],this.lastTarget[2]=this.target[2],this.lastTarget[3]=this.target[3],this.lastTarget[4]=this.target[4],this.firstRender=!1,this.pendingUpdate=!1,this.logNextRender=!1,this.renderer.isReady()&&(this.ready=!0,this.world.trigger(`ready`)),this.world.flushSubscriptions();let s=this.world.getScheduledUpdates(this.target,i),c=s.length;if(c>0)for(let e=0;e<c;e++){let t=s[c-e-1]();t?t.then(()=>{this.pendingUpdate=!0}):this.pendingUpdate=!0}}),this.renderer=e,this.world=t,this.options={maxOverZoom:1,maxUnderZoom:1,visibilityRatio:1.5,...i||{}},this.target=l.DnaFactory.projection(n),this.manualHomePosition=!1,this.pendingUpdate=!0,this.homePosition=l.DnaFactory.projection(this.world),this.manualFocalPosition=!1,this.focalPosition=this.target,this.updateFocalPosition(),this.transitionManager=new ve(this),this.aggregate=(0,l.scale)(1),this.world.addLayoutSubscriber(e=>{e===`repaint`&&(this.pendingUpdate=!0),e===`recalculate-world-size`&&(this.manualHomePosition||(this.setHomePosition(),this.goHome()),this.updateFocalPosition())}),this.lastTime=performance.now(),this.controllers=r,this.render(this.lastTime),this.startControllers(),this.homePaddingPx=void 0}setHomePosition(e){this.homePosition.set(l.DnaFactory.projection(e||this.world)),this.pendingUpdate=!0}setHomePaddingPx(e){this.homePaddingPx=e,this.pendingUpdate=!0}getHomePaddingPx(){return this.homePaddingPx}startControllers(){if(!this.controllersRunning){for(let e of this.controllers)this.controllerStopFunctions.push(e.start(this));this.controllersRunning=!0}}stopControllers(){if(this.controllersRunning){for(let e of this.controllerStopFunctions)e();this.controllersRunning=!1,this.controllerStopFunctions=[]}}updateControllerPosition(){for(let e of this.controllers)e.updatePosition(this.x,this.y,this.width,this.height)}triggerResize(){this.renderer.triggerResize&&this.renderer.triggerResize(),this.pendingUpdate=!0}addController(e){this.controllers.push(e),this.controllersRunning&&e.start(this),this.pendingUpdate=!0}cover(){return this.goHome({cover:!0})}getRendererScreenPosition(){return this.renderer.getRendererScreenPosition()}updateRendererScreenPosition(){this.pendingUpdate=!0,this.renderer.resize()}setOptions(e){this.options={...this.options,...e}}normalizePadding(e){return typeof e==`number`?{left:e,right:e,top:e,bottom:e}:e?{left:e.left||0,right:e.right||0,top:e.top||0,bottom:e.bottom||0}:{left:0,right:0,top:0,bottom:0}}getHomeTarget(e={}){let t=this.getRendererScreenPosition(),n=t?.width||this.width,r=t?.height||this.height,i=e.paddingPx===void 0?this.homePaddingPx:e.paddingPx,a=this.normalizePadding(i),o=Math.max(1,n-a.left-a.right),s=Math.max(1,r-a.top-a.bottom),c=e.position?{x:e.position[1],y:e.position[2],width:e.position[3]-e.position[1],height:e.position[4]-e.position[2]}:{x:this.homePosition[1],y:this.homePosition[2],width:this.homePosition[3]-this.homePosition[1],height:this.homePosition[4]-this.homePosition[2]},l=o/s,u=c.width/c.height,d,f,p,m;(e.cover?u<l:u>l)?(d=c.width,f=c.width/l,p=c.x,m=c.y-(f-c.height)/2):(f=c.height,d=c.height*l,p=c.x-(d-c.width)/2,m=c.y);let h=d/o,g=a.left*h,_=a.right*h,v=a.top*h,y=a.bottom*h;return{x:p-g,y:m-v,width:d+g+_,height:f+v+y}}goHome(e={}){if(this.world.width<=0||this.world.height<=0)return;let t=e.paddingPx===void 0?this.homePaddingPx:e.paddingPx,n=this.normalizePadding(t);if(n.left>0||n.right>0||n.top>0||n.bottom>0){let t=this.getHomeTarget(e);this.target[1]=Math.round(t.x),this.target[2]=Math.round(t.y),this.target[3]=Math.round(t.x+t.width),this.target[4]=Math.round(t.y+t.height)}else{let t=this.getScaleFactor(),n=e.position?{x:e.position[1],y:e.position[2],width:e.position[3]-e.position[1],height:e.position[4]-e.position[2]}:{x:this.homePosition[1],y:this.homePosition[2],width:this.homePosition[3]-this.homePosition[1],height:this.homePosition[4]-this.homePosition[2]},r=this.width*t,i=this.height*t,a=n.width/r,o=n.height/i,s=r/i;if(e.cover?a>o:a<o){let e=s*n.height,t=(e-n.width)/2;this.target[1]=Math.round(-t+n.x),this.target[2]=Math.round(n.y),this.target[3]=Math.round(e-t+n.x),this.target[4]=Math.round(n.height+n.y)}else{let e=n.width/s,t=(e-n.height)/2;this.target[1]=Math.round(n.x),this.target[2]=Math.round(n.y-t),this.target[3]=Math.round(n.x+n.width),this.target[4]=Math.round(n.y+e-t)}}this.constrainBounds(this.target),this.updateControllerPosition()}resize(e,t,n,r){this.transitionManager.hasPending()&&this.transitionManager.stopTransition(),this.updateFocalPosition(e-t,n-r);let i=t/e,a=r/n;this.target[3]=this.target[1]+(this.target[3]-this.target[1])*i,this.target[4]=this.target[2]+(this.target[4]-this.target[2])*a,this.goHome({position:this.focalPosition}),this.renderer.resize(t,r),this.pendingUpdate=!0,this.transitionManager.resumeTransition()}updateFocalPosition(e,t){if(!this.manualFocalPosition){let e=this.width,t=this.height,n=Math.min(e,t),r=this.x+0,i=this.y+0;if(e<t){let e=this.height-this.width;this.focalPosition=l.DnaFactory.projection({x:r,y:i+e/2,width:n-0,height:n-0}),this.pendingUpdate=!0}else{let e=this.width-this.height;this.focalPosition=l.DnaFactory.projection({x:r+e/2,y:i,width:n-0,height:n-0}),this.pendingUpdate=!0}}}getViewport(){return this._viewport.x=this.target[1],this._viewport.y=this.target[2],this._viewport.width=this.target[3]-this.target[1],this._viewport.height=this.target[4]-this.target[2],this._viewport}constrainBounds(e,{panPadding:t=0,ref:n=!1}={}){let{minX:r,maxX:i,minY:a,maxY:o}=this.getBounds({target:e,padding:t}),s=!1,c=n?e:(0,l.dna)(e),u=Math.round(e[3]-e[1]),d=Math.round(e[4]-e[2]);return r>e[1]&&(s=!0,c[1]=r,c[3]=r+u),a>e[2]&&(s=!0,c[2]=a,c[4]=a+d),i<e[1]&&(s=!0,c[1]=i,c[3]=i+u),o<e[2]&&(s=!0,c[2]=o,c[4]=o+d),[s,c]}getBounds(e){let t=e.target||this.target,n=e.padding,r=this.options.visibilityRatio,i=Math.abs(1-r);if(this.world.hasActiveZone()){let e=this.world.getActiveZone();if(e){let r=t[3]-t[1]<e.points[3]-e.points[1],i=t[4]-t[2]<e.points[4]-e.points[2];return{minX:r?e.points[1]-n:e.points[1]+(e.points[3]-e.points[1])/2-(t[3]-t[1])/2,maxX:i?e.points[2]-n:e.points[2]+(e.points[4]-e.points[2])/2-(t[4]-t[2])/2,minY:r?e.points[3]+n:e.points[1]+(e.points[3]-e.points[1])/2-(t[3]-t[1])/2,maxY:i?e.points[4]+n:e.points[2]+(e.points[4]-e.points[2])/2-(t[4]-t[2])/2}}}let a=t[3]-t[1],o=this.world.width,s=-a*i,c=o-a-s,l=t[4]-t[2],u=this.world.height,d=-l*i,f=u-l-d,p=Math.round(Math.max(s,c)),m=Math.round(Math.min(s,c)),h=Math.round(Math.max(d,f));return{minX:m,maxX:p,minY:Math.round(Math.min(d,f)),maxY:h}}getScaleFactor(e=!1){let t=this.renderer.getScale(this.target[3]-this.target[1],this.target[4]-this.target[2],e);return t===0?this._lastGoodScale:(this._lastGoodScale=t,t)}getZoomedPosition(e,{origin:t,fromPos:n}){let r=n?{width:n[3]-n[1],height:n[4]-n[2]}:void 0,i=r?this.renderer.getScale(r.width,r.height):this.getScaleFactor(),a=r?r.width:this.width,o=r?r.height:this.height,s=this.getRendererScreenPosition()?.width,c=this.world.width,u=s?s/c:1,d=this.options.maxUnderZoom,f=Math.max(u||1,this.options.maxOverZoom),p=1/e,m=i*p;if(p<1){let t=a*i,n=o*i;this.world.width/t>this.world.height/n?this.world.width*m<~~(a*i)*d&&(e=this.world.width*i/(a*i*d)):this.world.height*m<~~(o*i)*d&&(e=this.world.height*i/(o*i*d))}else m>f&&(e=i/f);let h=(0,l.transform)(this.target,(0,l.scaleAtOrigin)(e,t?t.x:this.target[1]+(this.target[3]-this.target[1])/2,t?t.y:this.target[2]+(this.target[4]-this.target[2])/2),this.zoomBuffer);return this.constrainBounds(h,{ref:!0,panPadding:100}),h}clampRegion({x:e,y:t,width:n,height:r,padding:i=0}){let a=this.width,o=this.height,s=n/a<r/o,c=e-i,l=t-i,u=n+i*2,d=r+i*2;if(s){let e=d/o*a;return{x:c-(e-u)/2,y:l,width:e,height:d}}let f=u/a*o;return{x:c,y:l-(f-d)/2,width:u,height:f}}viewerToWorld(e,t){let n=this.getScaleFactor();return this._viewerToWorld.x=this.target[1]+e/n,this._viewerToWorld.y=this.target[2]+t/n,this._viewerToWorld}worldToViewer(e,t,n,r){let i=l.DnaFactory.singleBox(n,r,e,t);return(0,l.mutate)(i,(0,l.compose)((0,l.scale)(this.getScaleFactor()),(0,l.translate)(-this.target[1],-this.target[2]))),{x:i[1],y:i[2],width:i[3]-i[1],height:i[4]-i[2],strand:i}}setScale(e,t){(0,l.mutate)(this.target,(0,l.scaleAtOrigin)(e,t?t.x:this.target[1]+(this.target[3]-this.target[1])/2,t?t.y:this.target[2]+(this.target[4]-this.target[2])/2)),this.pendingUpdate=!0}syncTo(e){let t=this.target;return this.target=e.target,this.pendingUpdate=!0,()=>{this.target=t}}stop(){return this.stopId!==void 0&&(window.cancelAnimationFrame(this.stopId),this.stopId=void 0),()=>{this.render(performance.now())}}reset(){this.renderer.reset()}selectZone(e){this.world.selectZone(e),this.pendingUpdate=!0}deselectZone(){this.world.deselectZone(),this.pendingUpdate=!0}hook(e,t){let n=this.hooks[e].length;if(n!==0)for(let r=0;r<n;r++)this.hooks[e][r](t)}registerHook(e,t){return this.hooks[e].push(t),()=>{this.hooks[e]=this.hooks[e].filter(e=>e!==t)}}updateNextFrame(){this.pendingUpdate=!0}};const be=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,xe={},Se=[`backgroundColor`,`opacity`,`boxShadow`,`borderColor`,`borderWidth`,`borderStyle`,`outlineColor`,`outlineWidth`,`outlineOffset`,`outlineStyle`];var Ce=class extends k{constructor(){super(),O(this,`id`,void 0),O(this,`type`,`spacial-content`),O(this,`isShape`,!0),O(this,`points`,void 0),O(this,`hoverEvents`,!1),O(this,`activeEvents`,!1),O(this,`display`,{x:0,y:0,scale:1,width:-1,height:-1,points:(0,l.dna)(5)}),O(this,`boundingBox`,null),O(this,`_parsed`,{border:{id:null,match:[]},outline:{id:null,match:[]}}),O(this,`hovering`,void 0),O(this,`pressing`,void 0),O(this,`props`,{}),O(this,`shape`,{type:`none`}),O(this,`addHover`,()=>{this.hovering=!0,this.__revision++}),O(this,`removeHover`,()=>{this.hovering=!1,this.pressing=!1,this.__revision++}),O(this,`addPress`,()=>{this.pressing=!0,this.__revision++}),O(this,`removePress`,()=>{this.pressing=!1,this.__revision++}),this.id=T(12),this.points=(0,l.dna)(5),this.shape={type:`none`}}updateBoundingBox(){if(this.shape.type===`none`)return;let e=this.shape.points;if(this.shape.points.length>2){let t=Math.min(...e.map(e=>e[0])),n=Math.min(...e.map(e=>e[1])),r=Math.max(0,...e.map(e=>e[0])),i=Math.max(0,...e.map(e=>e[1]));this.boundingBox={x:t,y:n,width:r-t,height:i-n};return}this.boundingBox=null}intersects(e){if(!e||this.shape.type===`none`)return!1;let[t,n]=e,r=this.shape.points,i=this.boundingBox;if(i||(this.updateBoundingBox(),i=this.boundingBox),!i||t<i.x||t>i.x+i.width||n<i.y||n>i.height+i.y)return!1;let a=!1;for(let e=0,i=r.length-1;e<r.length;i=e++)r[e][1]>n!=r[i][1]>n&&t<(r[i][0]-r[e][0])*(n-r[e][1])/(r[i][1]-r[e][1])+r[e][0]&&(a=!a);return a}getAllPointsAt(e,t){return e[3]-e[1]===1&&e[4]-e[2]===1?this.intersects([e[1],e[2]])?[[this,this.points,t]]:[]:[[this,this.points,t]]}applyProps(e={}){let t=!1;if(e.points)if(this.shape.type!==`polygon`||this.shape.points.length!==e.points.length)this.shape={type:`polygon`,points:e.points,open:e.open},this.updateBoundingBox();else{let t=!1,n=e.points.length;for(let r=0;r<n;r++)if(e.points[r][0]!==this.shape.points[r][0]||e.points[r][1]!==this.shape.points[r][1]){t=!0;break}t&&(this.shape={type:`polygon`,points:e.points,open:e.open},this.updateBoundingBox())}if(e.interactive!==this.props.interactive&&(t=!0,this.props.interactive=e.interactive),(e.open||e.open===!1)&&(t=!0,this.shape.open=e.open),e.style){let n=e.border||e.style.border;if(n!==this._parsed.border.id)if(!n)this._parsed.border.id=null,this._parsed.border.match=[];else{let e=xe[n]||be.exec(n)||be.exec(n);e&&(this._parsed.border.id=n,this._parsed.border.match=xe[n]=e)}if(this._parsed.border.id&&(e.style.borderWidth=this._parsed.border.match[1],e.style.borderStyle=`solid`,e.style.borderColor=this._parsed.border.match[4]),e.style.outline!==this._parsed.outline.id)if(!e.style.outline)this._parsed.outline.id=null,this._parsed.outline.match=[];else{let t=xe[e.style.outline]||be.exec(e.style.outline)||be.exec(e.style.outline);t&&(this._parsed.outline.id=e.style.outline,this._parsed.outline.match=xe[e.style.outline]=t)}this._parsed.outline.id&&(e.style.outlineWidth=this._parsed.outline.match[1],e.style.outlineStyle=`solid`,e.style.outlineColor=this._parsed.outline.match[4]),this.props.style=e.style,e.backgroundColor&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=e.backgroundColor,t=!0),e.style.background&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=e.style.background,t=!0);for(let n of Se)if(this.props.style[n]!==e.style[n]){t=!0;break}e.style[`:hover`]!==this.props.hoverStyles&&(this.props.hoverStyles=e.style[`:hover`],this.hoverEvents||(this.hoverEvents=!0,this.addEventListener(`pointerenter`,this.addHover),this.addEventListener(`pointerleave`,this.removeHover)),t=!0),e.style[`:active`]!==this.props.pressStyles&&(this.props.pressStyles=e.style[`:active`],this.activeEvents||(this.activeEvents=!0,this.addEventListener(`mousedown`,this.addPress),this.addEventListener(`mouseup`,this.removePress)),t=!0)}e.href!==this.props.href&&(this.props.href=e.href,t=!0),e.hrefTarget!==this.props.hrefTarget&&(this.props.hrefTarget=e.hrefTarget,t=!0),e.title!==this.props.title&&(this.props.title=e.title,t=!0),e.className!==this.props.className&&(this.props.className=e.className,e.className&&!this.hoverEvents&&(this.hoverEvents=!0,this.addEventListener(`pointerenter`,this.addHover),this.addEventListener(`pointerleave`,this.removeHover)),e.className&&!this.activeEvents&&(this.activeEvents=!0,this.addEventListener(`mousedown`,this.addPress),this.addEventListener(`mouseup`,this.removePress)),t=!0),e.relativeSize!==this.props.relativeSize&&(this.props.relativeSize=e.relativeSize,t=!0),e.relativeStyle!==this.props.relativeStyle&&(this.props.relativeStyle=e.relativeStyle,t=!0),e.html!==this.props.html&&(this.props.html=e.html,t=!0),e.target&&(e.target.width!==this.display.width||e.target.height!==this.display.height||e.target.x!==this.points[1]||e.target.y!==this.points[2])&&(t=!0,this.points=l.DnaFactory.singleBox(e.target.width,e.target.height,e.target.x,e.target.y),this.display.points=l.DnaFactory.singleBox(e.target.width,e.target.height,e.target.x,e.target.y),this.display.width=e.target.width,this.display.height=e.target.height),t&&this.__revision++}};const we=typeof performance==`object`&&performance&&typeof performance.now==`function`?performance:Date,Te=typeof AbortController==`function`?AbortController:class{constructor(){this.signal=new Oe}abort(e=Error(`This operation was aborted`)){this.signal.reason=this.signal.reason||e,this.signal.aborted=!0,this.signal.dispatchEvent({type:`abort`,target:this.signal})}},Ee=typeof AbortSignal==`function`,De=typeof Te.AbortSignal==`function`,Oe=Ee?AbortSignal:De?Te.AbortController:class{constructor(){this.reason=void 0,this.aborted=!1,this._listeners=[]}dispatchEvent(e){e.type===`abort`&&(this.aborted=!0,this.onabort(e),this._listeners.forEach(t=>t(e),this))}onabort(){}addEventListener(e,t){e===`abort`&&this._listeners.push(t)}removeEventListener(e,t){e===`abort`&&(this._listeners=this._listeners.filter(e=>e!==t))}},ke=new Set,Ae=(e,t)=>{let n=`LRU_CACHE_OPTION_${e}`;Pe(n)&&Fe(n,`${e} option`,`options.${t}`,ze)},je=(e,t)=>{let n=`LRU_CACHE_METHOD_${e}`;if(Pe(n)){let{prototype:r}=ze,{get:i}=Object.getOwnPropertyDescriptor(r,e);Fe(n,`${e} method`,`cache.${t}()`,i)}},Me=(e,t)=>{let n=`LRU_CACHE_PROPERTY_${e}`;if(Pe(n)){let{prototype:r}=ze,{get:i}=Object.getOwnPropertyDescriptor(r,e);Fe(n,`${e} property`,`cache.${t}`,i)}},Ne=(...e)=>{typeof process==`object`&&process&&typeof process.emitWarning==`function`?process.emitWarning(...e):console.error(...e)},Pe=e=>!ke.has(e),Fe=(e,t,n,r)=>{ke.add(e),Ne(`The ${t} is deprecated. Please use ${n} instead.`,`DeprecationWarning`,e,r)},K=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Ie=e=>K(e)?e<=2**8?Uint8Array:e<=2**16?Uint16Array:e<=2**32?Uint32Array:e<=2**53-1?Le:null:null;var Le=class extends Array{constructor(e){super(e),this.fill(0)}},Re=class{constructor(e){if(e===0)return[];this.heap=new(Ie(e))(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},ze=class e{constructor(t={}){let{max:n=0,ttl:r,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:s,allowStale:c,dispose:l,disposeAfter:u,noDisposeOnSet:d,noUpdateTTL:f,maxSize:p=0,maxEntrySize:m=0,sizeCalculation:h,fetchMethod:g,fetchContext:_,noDeleteOnFetchRejection:v,noDeleteOnStaleGet:y,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:x,ignoreFetchAbort:S}=t,{length:C,maxAge:w,stale:T}=t instanceof e?{}:t;if(n!==0&&!K(n))throw TypeError(`max option must be a nonnegative integer`);let E=n?Ie(n):Array;if(!E)throw Error(`invalid max value: `+n);if(this.max=n,this.maxSize=p,this.maxEntrySize=m||this.maxSize,this.sizeCalculation=h||C,this.sizeCalculation){if(!this.maxSize&&!this.maxEntrySize)throw TypeError(`cannot set sizeCalculation without setting maxSize or maxEntrySize`);if(typeof this.sizeCalculation!=`function`)throw TypeError(`sizeCalculation set to non-function`)}if(this.fetchMethod=g||null,this.fetchMethod&&typeof this.fetchMethod!=`function`)throw TypeError(`fetchMethod must be a function if specified`);if(this.fetchContext=_,!this.fetchMethod&&_!==void 0)throw TypeError(`cannot set fetchContext without fetchMethod`);if(this.keyMap=new Map,this.keyList=Array(n).fill(null),this.valList=Array(n).fill(null),this.next=new E(n),this.prev=new E(n),this.head=0,this.tail=0,this.free=new Re(n),this.initialFill=1,this.size=0,typeof l==`function`&&(this.dispose=l),typeof u==`function`?(this.disposeAfter=u,this.disposed=[]):(this.disposeAfter=null,this.disposed=null),this.noDisposeOnSet=!!d,this.noUpdateTTL=!!f,this.noDeleteOnFetchRejection=!!v,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!x,this.ignoreFetchAbort=!!S,this.maxEntrySize!==0){if(this.maxSize!==0&&!K(this.maxSize))throw TypeError(`maxSize must be a positive integer if specified`);if(!K(this.maxEntrySize))throw TypeError(`maxEntrySize must be a positive integer if specified`);this.initializeSizeTracking()}if(this.allowStale=!!c||!!T,this.noDeleteOnStaleGet=!!y,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!s,this.ttlResolution=K(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=r||w||0,this.ttl){if(!K(this.ttl))throw TypeError(`ttl must be a positive integer if specified`);this.initializeTTLTracking()}if(this.max===0&&this.ttl===0&&this.maxSize===0)throw TypeError(`At least one of max, maxSize, or ttl is required`);if(!this.ttlAutopurge&&!this.max&&!this.maxSize){let t=`LRU_CACHE_UNBOUNDED`;Pe(t)&&(ke.add(t),Ne(`TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.`,`UnboundedCacheWarning`,t,e))}T&&Ae(`stale`,`allowStale`),w&&Ae(`maxAge`,`ttl`),C&&Ae(`length`,`sizeCalculation`)}getRemainingTTL(e){return this.has(e,{updateAgeOnHas:!1})?1/0:0}initializeTTLTracking(){this.ttls=new Le(this.max),this.starts=new Le(this.max),this.setItemTTL=(e,t,n=we.now())=>{if(this.starts[e]=t===0?0:n,this.ttls[e]=t,t!==0&&this.ttlAutopurge){let n=setTimeout(()=>{this.isStale(e)&&this.delete(this.keyList[e])},t+1);n.unref&&n.unref()}},this.updateItemAge=e=>{this.starts[e]=this.ttls[e]===0?0:we.now()},this.statusTTL=(n,r)=>{n&&(n.ttl=this.ttls[r],n.start=this.starts[r],n.now=e||t(),n.remainingTTL=n.now+n.ttl-n.start)};let e=0,t=()=>{let t=we.now();if(this.ttlResolution>0){e=t;let n=setTimeout(()=>e=0,this.ttlResolution);n.unref&&n.unref()}return t};this.getRemainingTTL=n=>{let r=this.keyMap.get(n);return r===void 0?0:this.ttls[r]===0||this.starts[r]===0?1/0:this.starts[r]+this.ttls[r]-(e||t())},this.isStale=n=>this.ttls[n]!==0&&this.starts[n]!==0&&(e||t())-this.starts[n]>this.ttls[n]}updateItemAge(e){}statusTTL(e,t){}setItemTTL(e,t,n){}isStale(e){return!1}initializeSizeTracking(){this.calculatedSize=0,this.sizes=new Le(this.max),this.removeItemSize=e=>{this.calculatedSize-=this.sizes[e],this.sizes[e]=0},this.requireSize=(e,t,n,r)=>{if(this.isBackgroundFetch(t))return 0;if(!K(n))if(r){if(typeof r!=`function`)throw TypeError(`sizeCalculation must be a function`);if(n=r(t,e),!K(n))throw TypeError(`sizeCalculation return invalid (expect positive integer)`)}else throw TypeError(`invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.`);return n},this.addItemSize=(e,t,n)=>{if(this.sizes[e]=t,this.maxSize){let t=this.maxSize-this.sizes[e];for(;this.calculatedSize>t;)this.evict(!0)}this.calculatedSize+=this.sizes[e],n&&(n.entrySize=t,n.totalCalculatedSize=this.calculatedSize)}}removeItemSize(e){}addItemSize(e,t){}requireSize(e,t,n,r){if(n||r)throw TypeError(`cannot set size without setting maxSize or maxEntrySize on cache`)}*indexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.tail;!(!this.isValidIndex(t)||((e||!this.isStale(t))&&(yield t),t===this.head));)t=this.prev[t]}*rindexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.head;!(!this.isValidIndex(t)||((e||!this.isStale(t))&&(yield t),t===this.tail));)t=this.next[t]}isValidIndex(e){return e!==void 0&&this.keyMap.get(this.keyList[e])===e}*entries(){for(let e of this.indexes())this.valList[e]!==void 0&&this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield[this.keyList[e],this.valList[e]])}*rentries(){for(let e of this.rindexes())this.valList[e]!==void 0&&this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield[this.keyList[e],this.valList[e]])}*keys(){for(let e of this.indexes())this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.keyList[e])}*rkeys(){for(let e of this.rindexes())this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.keyList[e])}*values(){for(let e of this.indexes())this.valList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.valList[e])}*rvalues(){for(let e of this.rindexes())this.valList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.valList[e])}[Symbol.iterator](){return this.entries()}find(e,t){for(let n of this.indexes()){let r=this.valList[n],i=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;if(i!==void 0&&e(i,this.keyList[n],this))return this.get(this.keyList[n],t)}}forEach(e,t=this){for(let n of this.indexes()){let r=this.valList[n],i=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.keyList[n],this)}}rforEach(e,t=this){for(let n of this.rindexes()){let r=this.valList[n],i=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.keyList[n],this)}}get prune(){return je(`prune`,`purgeStale`),this.purgeStale}purgeStale(){let e=!1;for(let t of this.rindexes({allowStale:!0}))this.isStale(t)&&(this.delete(this.keyList[t]),e=!0);return e}dump(){let e=[];for(let t of this.indexes({allowStale:!0})){let n=this.keyList[t],r=this.valList[t],i=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;if(i===void 0)continue;let a={value:i};if(this.ttls){a.ttl=this.ttls[t];let e=we.now()-this.starts[t];a.start=Math.floor(Date.now()-e)}this.sizes&&(a.size=this.sizes[t]),e.unshift([n,a])}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let e=Date.now()-n.start;n.start=we.now()-e}this.set(t,n.value,n)}}dispose(e,t,n){}set(e,t,{ttl:n=this.ttl,start:r,noDisposeOnSet:i=this.noDisposeOnSet,size:a=0,sizeCalculation:o=this.sizeCalculation,noUpdateTTL:s=this.noUpdateTTL,status:c}={}){if(a=this.requireSize(e,t,a,o),this.maxEntrySize&&a>this.maxEntrySize)return c&&(c.set=`miss`,c.maxEntrySizeExceeded=!0),this.delete(e),this;let l=this.size===0?void 0:this.keyMap.get(e);if(l===void 0)l=this.newIndex(),this.keyList[l]=e,this.valList[l]=t,this.keyMap.set(e,l),this.next[this.tail]=l,this.prev[l]=this.tail,this.tail=l,this.size++,this.addItemSize(l,a,c),c&&(c.set=`add`),s=!1;else{this.moveToTail(l);let n=this.valList[l];if(t!==n){if(this.isBackgroundFetch(n)?n.__abortController.abort(Error(`replaced`)):i||(this.dispose(n,e,`set`),this.disposeAfter&&this.disposed.push([n,e,`set`])),this.removeItemSize(l),this.valList[l]=t,this.addItemSize(l,a,c),c){c.set=`replace`;let e=n&&this.isBackgroundFetch(n)?n.__staleWhileFetching:n;e!==void 0&&(c.oldValue=e)}}else c&&(c.set=`update`)}if(n!==0&&this.ttl===0&&!this.ttls&&this.initializeTTLTracking(),s||this.setItemTTL(l,n,r),this.statusTTL(c,l),this.disposeAfter)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return this}newIndex(){return this.size===0?this.tail:this.size===this.max&&this.max!==0?this.evict(!1):this.free.length===0?this.initialFill++:this.free.pop()}pop(){if(this.size){let e=this.valList[this.head];return this.evict(!0),e}}evict(e){let t=this.head,n=this.keyList[t],r=this.valList[t];return this.isBackgroundFetch(r)?r.__abortController.abort(Error(`evicted`)):(this.dispose(r,n,`evict`),this.disposeAfter&&this.disposed.push([r,n,`evict`])),this.removeItemSize(t),e&&(this.keyList[t]=null,this.valList[t]=null,this.free.push(t)),this.head=this.next[t],this.keyMap.delete(n),this.size--,t}has(e,{updateAgeOnHas:t=this.updateAgeOnHas,status:n}={}){let r=this.keyMap.get(e);if(r!==void 0)if(this.isStale(r))n&&(n.has=`stale`,this.statusTTL(n,r));else return t&&this.updateItemAge(r),n&&(n.has=`hit`),this.statusTTL(n,r),!0;else n&&(n.has=`miss`);return!1}peek(e,{allowStale:t=this.allowStale}={}){let n=this.keyMap.get(e);if(n!==void 0&&(t||!this.isStale(n))){let e=this.valList[n];return this.isBackgroundFetch(e)?e.__staleWhileFetching:e}}backgroundFetch(e,t,n,r){let i=t===void 0?void 0:this.valList[t];if(this.isBackgroundFetch(i))return i;let a=new Te;n.signal&&n.signal.addEventListener(`abort`,()=>a.abort(n.signal.reason));let o={signal:a.signal,options:n,context:r},s=(r,i=!1)=>{let{aborted:s}=a.signal,c=n.ignoreFetchAbort&&r!==void 0;return n.status&&(s&&!i?(n.status.fetchAborted=!0,n.status.fetchError=a.signal.reason,c&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),s&&!c&&!i?l(a.signal.reason):(this.valList[t]===d&&(r===void 0?d.__staleWhileFetching?this.valList[t]=d.__staleWhileFetching:this.delete(e):(n.status&&(n.status.fetchUpdated=!0),this.set(e,r,o.options))),r)},c=e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),l(e)),l=r=>{let{aborted:i}=a.signal,o=i&&n.allowStaleOnFetchAbort,s=o||n.allowStaleOnFetchRejection,c=s||n.noDeleteOnFetchRejection;if(this.valList[t]===d&&(!c||d.__staleWhileFetching===void 0?this.delete(e):o||(this.valList[t]=d.__staleWhileFetching)),s)return n.status&&d.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),d.__staleWhileFetching;if(d.__returned===d)throw r},u=(t,r)=>{this.fetchMethod(e,i,o).then(e=>t(e),r),a.signal.addEventListener(`abort`,()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(t(),n.allowStaleOnFetchAbort&&(t=e=>s(e,!0)))})};n.status&&(n.status.fetchDispatched=!0);let d=new Promise(u).then(s,c);return d.__abortController=a,d.__staleWhileFetching=i,d.__returned=null,t===void 0?(this.set(e,d,{...o.options,status:void 0}),t=this.keyMap.get(e)):this.valList[t]=d,d}isBackgroundFetch(e){return e&&typeof e==`object`&&typeof e.then==`function`&&Object.prototype.hasOwnProperty.call(e,`__staleWhileFetching`)&&Object.prototype.hasOwnProperty.call(e,`__returned`)&&(e.__returned===e||e.__returned===null)}async fetch(e,{allowStale:t=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:i=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:o=0,sizeCalculation:s=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:f=this.allowStaleOnFetchAbort,fetchContext:p=this.fetchContext,forceRefresh:m=!1,status:h,signal:g}={}){if(!this.fetchMethod)return h&&(h.fetch=`get`),this.get(e,{allowStale:t,updateAgeOnGet:n,noDeleteOnStaleGet:r,status:h});let _={allowStale:t,updateAgeOnGet:n,noDeleteOnStaleGet:r,ttl:i,noDisposeOnSet:a,size:o,sizeCalculation:s,noUpdateTTL:c,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:f,ignoreFetchAbort:d,status:h,signal:g},v=this.keyMap.get(e);if(v===void 0){h&&(h.fetch=`miss`);let t=this.backgroundFetch(e,v,_,p);return t.__returned=t}else{let r=this.valList[v];if(this.isBackgroundFetch(r)){let e=t&&r.__staleWhileFetching!==void 0;return h&&(h.fetch=`inflight`,e&&(h.returnedStale=!0)),e?r.__staleWhileFetching:r.__returned=r}let i=this.isStale(v);if(!m&&!i)return h&&(h.fetch=`hit`),this.moveToTail(v),n&&this.updateItemAge(v),this.statusTTL(h,v),r;let a=this.backgroundFetch(e,v,_,p),o=a.__staleWhileFetching!==void 0,s=o&&t;return h&&(h.fetch=o&&i?`stale`:`refresh`,s&&i&&(h.returnedStale=!0)),s?a.__staleWhileFetching:a.__returned=a}}get(e,{allowStale:t=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:i}={}){let a=this.keyMap.get(e);if(a!==void 0){let o=this.valList[a],s=this.isBackgroundFetch(o);return this.statusTTL(i,a),this.isStale(a)?(i&&(i.get=`stale`),s?(i&&(i.returnedStale=t&&o.__staleWhileFetching!==void 0),t?o.__staleWhileFetching:void 0):(r||this.delete(e),i&&(i.returnedStale=t),t?o:void 0)):(i&&(i.get=`hit`),s?o.__staleWhileFetching:(this.moveToTail(a),n&&this.updateItemAge(a),o))}else i&&(i.get=`miss`)}connect(e,t){this.prev[t]=e,this.next[e]=t}moveToTail(e){e!==this.tail&&(e===this.head?this.head=this.next[e]:this.connect(this.prev[e],this.next[e]),this.connect(this.tail,e),this.tail=e)}get del(){return je(`del`,`delete`),this.delete}delete(e){let t=!1;if(this.size!==0){let n=this.keyMap.get(e);if(n!==void 0)if(t=!0,this.size===1)this.clear();else{this.removeItemSize(n);let t=this.valList[n];this.isBackgroundFetch(t)?t.__abortController.abort(Error(`deleted`)):(this.dispose(t,e,`delete`),this.disposeAfter&&this.disposed.push([t,e,`delete`])),this.keyMap.delete(e),this.keyList[n]=null,this.valList[n]=null,n===this.tail?this.tail=this.prev[n]:n===this.head?this.head=this.next[n]:(this.next[this.prev[n]]=this.next[n],this.prev[this.next[n]]=this.prev[n]),this.size--,this.free.push(n)}}if(this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return t}clear(){for(let e of this.rindexes({allowStale:!0})){let t=this.valList[e];if(this.isBackgroundFetch(t))t.__abortController.abort(Error(`deleted`));else{let n=this.keyList[e];this.dispose(t,n,`delete`),this.disposeAfter&&this.disposed.push([t,n,`delete`])}}if(this.keyMap.clear(),this.valList.fill(null),this.keyList.fill(null),this.ttls&&(this.ttls.fill(0),this.starts.fill(0)),this.sizes&&this.sizes.fill(0),this.head=0,this.tail=0,this.initialFill=1,this.free.length=0,this.calculatedSize=0,this.size=0,this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift())}get reset(){return je(`reset`,`clear`),this.clear}get length(){return Me(`length`,`size`),this.size}static get AbortController(){return Te}static get AbortSignal(){return Oe}},Be=ze;const Ve=/(-?[0-9]+(px|em)\s+|0\s+)(-?[0-9]+(px|em)\s+|0\s+)(-?[0-9]+(px|em)\s+|0\s+)?(-?[0-9]+(px|em)\s+|0\s+)?(.*)/g,He={},Ue=typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(`firefox`),We={};var Ge=class{constructor(e,t){O(this,`canvas`,void 0),O(this,`ctx`,void 0),O(this,`options`,void 0),O(this,`imagesPending`,0),O(this,`imagesLoaded`,0),O(this,`imageIdsLoaded`,[]),O(this,`frameIsRendering`,!1),O(this,`pendingDrawCall`,!1),O(this,`firstMeaningfulPaint`,!1),O(this,`parallelTasks`,8),O(this,`frameTasks`,0),O(this,`loadingQueueOrdered`,!0),O(this,`loadingQueue`,[]),O(this,`currentTask`,Promise.resolve()),O(this,`tasksRunning`,0),O(this,`stats`,void 0),O(this,`averageJobTime`,64),O(this,`lastKnownScale`,1),O(this,`visible`,[]),O(this,`previousVisible`,[]),O(this,`rendererPosition`,void 0),O(this,`dpi`,void 0),O(this,`drawCalls`,[]),O(this,`lastPaintedObject`,void 0),O(this,`hostCache`,void 0),O(this,`invalidated`,[]),O(this,`_worker`,()=>{if(this.loadingQueue.length){let e=this.loadingQueue.pop();e&&(this.tasksRunning++,this.frameTasks++,this.currentTask=e.task().then(()=>{this.tasksRunning--}).catch(()=>{this.tasksRunning--}))}}),O(this,`_scheduled`,0),O(this,`_doWork`,()=>{this.loadingQueue.length===0&&this.tasksRunning===0&&this._scheduled&&(clearInterval(this._scheduled),this._scheduled=0);let e=this.parallelTasks||1;!this.firstMeaningfulPaint&&this.loadingQueue.length&&(e=this.loadingQueue.length);for(let t=0;t<=e;t++)this._worker()}),this.canvas=e,this.rendererPosition=e.getBoundingClientRect(),this.ctx=e.getContext(`2d`,{alpha:!0}),this.ctx.imageSmoothingEnabled=!0,this.options=t||{},this.canvas.style.transition=`opacity .3s`,this.dpi=t?.dpi||1,this.hostCache=t?.lruCache?new Be({maxSize:1024*512*512,dispose:(e,t,n)=>{this.invalidated.push(t),e.width=0,e.height=0},sizeCalculation:(e,t)=>e.width*e.height}):{store:{},get(e){return this.store[e]},set(e,t){this.store[e]=t}}}getCanvasDims(){return{width:this.canvas.width/this.dpi,height:this.canvas.height/this.dpi}}resize(){this.rendererPosition=this.canvas.getBoundingClientRect()}isReady(){return this.firstMeaningfulPaint}afterFrame(e){if(this.clearTransform(),this.lastPaintedObject=void 0,this.frameIsRendering=!1,this.imagesPending=Math.max(0,this.imagesPending-this.imagesLoaded),this.imagesLoaded=0,this.loadingQueueOrdered||(this.loadingQueue=this.loadingQueue.sort((e,t)=>e.network&&e.scale===t.scale?t.distance-e.distance:e.scale<t.scale?-1:1),this.loadingQueueOrdered=!0),this.previousVisible=this.visible,this.pendingDrawCall=!!this.drawCalls.length,this.pendingDrawCall)for(let e=0;e<this.drawCalls.length;e++){let e=this.drawCalls.shift();e&&e()}this.doOffscreenWork(),this.options.debug&&this.stats&&this.stats.end()}doOffscreenWork(){this.frameTasks=0,this.loadingQueue.length&&(this._worker(),this.loadingQueue.length&&(this._scheduled||(this._scheduled=setInterval(this._doWork,0))))}getScale(e,t,n){if(Number.isNaN(e)||Number.isNaN(t))return this.lastKnownScale;let r=this.getCanvasDims(),i=r.width/e,a=r.height/t,o=(i<a?a:i)*(n&&this.dpi||1);return Number.isNaN(o)||(this.lastKnownScale=o),this.lastKnownScale}beforeFrame(e,t,n,r){this.options.debug&&this.stats&&this.stats.begin(),this.frameIsRendering=!0,this.visible=[],this.options.beforeFrame&&this.options.beforeFrame(t);let i=this.getCanvasDims();if(this.ctx.globalAlpha=1,this.canvas.dataset.background===`transparent`?this.ctx.clearRect(0,0,i.width,i.height):(this.ctx.fillStyle=this.canvas.dataset.background??`rgb(0, 0, 0)`,this.ctx.fillRect(0,0,i.width,i.height)),r.enableFilters&&(r.filters.brightness||r.filters.contrast||r.filters.grayscale||r.filters.invert||r.filters.sepia||r.filters.saturate||r.filters.hueRotate||r.filters.blur)){let e=``;r.filters.brightness&&(e+=`brightness(${~~(100+r.filters.brightness*100)}%) `),r.filters.contrast&&(e+=`contrast(${~~(100+r.filters.contrast*100)}%) `),r.filters.grayscale&&(e+=`grayscale(${~~(r.filters.grayscale*100)}%) `),r.filters.invert&&(e+=`invert(${~~(r.filters.invert*100)}%) `),r.filters.sepia&&(e+=`sepia(${~~(r.filters.sepia*100)}%) `),r.filters.saturate&&(e+=`saturate(${~~(100+r.filters.saturate*100)}%) `),r.filters.hueRotate&&(e+=`hue-rotate(${r.filters.hueRotate}deg) `),r.filters.blur&&(e+=`blur(${r.filters.blur}px) `),this.ctx.filter!==e&&(this.ctx.filter=e)}else this.ctx.filter=`none`}applyTransform(e,t,n,r,i){let a=e.__owner.value;if(a&&a.rotation){this.ctx.save();let e=t+r/2,o=n+i/2;this.ctx.translate(e,o),this.ctx.rotate(a.rotation*Math.PI/180),this.ctx.translate(-e,-o),this.lastPaintedObject=a}}clearTransform(){this.lastPaintedObject&&(this.lastPaintedObject.rotation&&this.ctx.restore(),this.lastPaintedObject=void 0)}paint(e,t,n,r,i,a){let o=this.ctx.globalAlpha;if(e instanceof A||e instanceof P){if(e.display.rotation){this.ctx.save();let o=n+i/2,s=r+a/2;e.crop&&(o-=e.crop[t*5+1],s-=e.crop[t*5+2]),this.ctx.translate(o,s),this.ctx.rotate(e.display.rotation*Math.PI/180),this.ctx.translate(-o,-s)}if(this.visible.push(e),typeof e.style&&e.style.opacity!==`undefined`){if(!e.style.opacity)return;this.ctx.globalAlpha=e.style.opacity}try{let o=e.__host.canvas,s=this.getCanvasDims();if((o.indices.indexOf(t)===-1||this.invalidated.indexOf(o.canvases[t])!==-1)&&this.schedulePaintToCanvas(o,e,t,M({x:n+i/2,y:r+i/2},{x:s.width/2,y:s.height/2})),!this.firstMeaningfulPaint)return;let c=this.hostCache.get(o.canvases[t]);if(c)if(e.crop&&e.cropData){if(e.crop[t*5]){let o=[e.crop[t*5+1]/e.display.scale-e.display.points[t*5+1],e.crop[t*5+2]/e.display.scale-e.display.points[t*5+2],1+(e.crop[t*5+3]-e.crop[t*5+1])/e.display.scale,1+(e.crop[t*5+4]-e.crop[t*5+2])/e.display.scale];o[0]+=e.cropData.x/e.display.scale,o[1]+=e.cropData.y/e.display.scale;let s=e.x*this.lastKnownScale,l=e.y*this.lastKnownScale,u=[n+s,r+l,i,a];u[0]+=s,u[1]+=l,this.ctx.drawImage(c,o[0],o[1],o[2],o[3],u[0],u[1],u[2]+1,u[3]+1)}}else Ue?this.ctx.drawImage(c,0,0,e.display.points[t*5+3]-e.display.points[t*5+1],e.display.points[t*5+4]-e.display.points[t*5+2],n,r,i+1,a+1):this.ctx.drawImage(c,0,0,e.display.points[t*5+3]-e.display.points[t*5+1],e.display.points[t*5+4]-e.display.points[t*5+2],n,r,i+Number.MIN_VALUE+.5,a+Number.MIN_VALUE+.5)}catch{}e.display.rotation&&this.ctx.restore()}let s=e instanceof B&&this.options.box,c=e instanceof Ce&&this.options.polygon;if((s||c)&&!e.props.className&&!e.props.html&&!e.props.href){if(this.visible.push(e),e.props.style){let t=Object.assign({},e.props.style||{},e.hovering?e.props.hoverStyles:{},e.pressing?e.props.pressStyles:{}),o=e.props.relativeStyle?1:i/e.width;t.opacity!==void 0&&(this.ctx.globalAlpha=t.opacity);let s=0;t.borderWidth!==void 0&&(s=parseInt(t.borderWidth,10)*o);let l=0;t.outlineWidth!==void 0&&(l=parseInt(t.outlineWidth,10)*o);let u=0;if(t.outlineOffset!==void 0&&(u=parseInt(t.outlineOffset,10)*o),t.borderColor&&(this.ctx.strokeStyle=t.borderColor),t.boxShadow){let e=t.boxShadow.split(/,(?![^(]*\))/);for(let t of e){let e=He[t]||Ve.exec(t)||Ve.exec(t);He[t]=e,e&&(this.ctx.save(),this.ctx.shadowOffsetX=parseInt(e[1])*this.dpi*o,this.ctx.shadowOffsetY=parseInt(e[3])*this.dpi*o,this.ctx.shadowBlur=parseInt(e[5])*this.dpi*o,this.ctx.shadowColor=e[9],this.ctx.fillStyle=`rgba(0,0,0,1)`,this.ctx.fillRect(n+s,r+s,i,a),this.ctx.restore())}}if(this.ctx.fillStyle=t.backgroundColor||`transparent`,this.ctx.lineWidth=s,c){let t=e.shape,i=t.points||[],a=i.length;this.ctx.beginPath();for(let e=0;e<a;e++)this.ctx.lineTo(n+i[e][0]*this.lastKnownScale,r+i[e][1]*this.lastKnownScale);t.open||this.ctx.closePath(),s&&this.ctx.stroke(),t.open||this.ctx.fill()}else s&&this.ctx.strokeRect(n+s/2,r+s/2,i+s,a+s),this.ctx.fillRect(n+s,r+s,i,a);l&&(t.outlineColor&&(this.ctx.strokeStyle=t.outlineColor),this.ctx.lineWidth=l,this.ctx.strokeRect(n-l/2-u,r-l/2-u,i+s*2+l+u*2,a+s*2+l+u*2))}this.ctx.globalAlpha=o}}loadImage(e,t,n,r=!1){if(We[e]&&We[e].naturalWidth>0){t(We[e]);return}try{let i=!1;r||setTimeout(()=>{i||this.loadImage(e,t,n,!0)},3e3);let a=document.createElement(`img`);a.decoding=`auto`,a.onload=function(){i=!0,t(a),We[e]=a,a.onload=null},this.options.crossOrigin&&(a.crossOrigin=`anonymous`),a.src=e,a.complete&&a.onload({}),a.width}catch(e){console.log(`image error`,e),n(e)}}schedulePaintToCanvas(e,t,n,r){this.imagesPending++,e.indices.push(n);let i=`${t.id}--${t.display.scale}-${n}`,a=this.invalidated.indexOf(i);a!==-1&&this.invalidated.splice(a,1),e.canvases[n]=i,t.__host.canvas.loading=!0,this.loadingQueueOrdered=!1,this.loadingQueue.push({id:i,scale:t.display.scale,network:!0,distance:r,task:()=>new Promise(a=>{if(this.visible.indexOf(t)===-1){this.imagesPending--,e.indices.splice(e.indices.indexOf(n),1),a();return}let o=t.getImageUrl(n);this.loadImage(o,o=>{this.loadingQueue.push({id:i,scale:t.display.scale,distance:r,task:()=>new Promise(r=>{this.imageIdsLoaded.includes(i)||(this.imagesLoaded++,this.imageIdsLoaded.push(i)),e.loaded.push(n),e.loaded.length===e.indices.length&&(e.loading=!1);let a=t.display.points.slice(n*5,n*5+5),s=document.createElement(`canvas`),c=s.getContext(`2d`);s.width=a[3]-a[1],s.height=a[4]-a[2],this.hostCache.set(e.canvases[n],s),this.drawCalls.push(()=>{c.drawImage(o,0,0,a[3]-a[1],a[4]-a[2]),r()})})}),a()},t=>{this.imagesPending--,e.indices.splice(e.indices.indexOf(n),1),a()})})})}afterPaintLayer(e,t){}prepareLayer(e,t){e.__owner.value&&(e.cropData&&this.lastKnownScale*(1/e.display.scale),this.applyTransform(e,t[1],t[2],t[3]-t[1],t[4]-t[2])),(!e.__host||!e.__host.canvas)&&(e instanceof A||e instanceof P)&&this.createImageHost(e)}finishLayer(){this.lastPaintedObject&&this.clearTransform()}createImageHost(e){e.__host=e.__host?e.__host:{},e.__host.canvas={canvas:void 0,canvases:[],indices:[],loaded:[],loading:!1}}getPointsAt(e,t,n,r){return e.getPointsAt(t,n,r)}getViewportBounds(e,t,n){let r=e.getActiveZone();if(r){let e=t[3]-t[1]<r.points[3]-r.points[1],i=t[4]-t[2]<r.points[4]-r.points[2];return{x1:e?r.points[1]-n:r.points[1]+(r.points[3]-r.points[1])/2-(t[3]-t[1])/2,y1:i?r.points[2]-n:r.points[2]+(r.points[4]-r.points[2])/2-(t[4]-t[2])/2,x2:e?r.points[3]+n:r.points[1]+(r.points[3]-r.points[1])/2-(t[3]-t[1])/2,y2:i?r.points[4]+n:r.points[2]+(r.points[4]-r.points[2])/2-(t[4]-t[2])/2}}return null}pendingUpdate(){let e=!this.pendingDrawCall&&this.drawCalls.length===0&&this.imagesPending===0&&this.loadingQueue.length===0&&this.tasksRunning===0;return!e&&this.visible.length===0&&setTimeout(()=>{this.canvas.style.opacity=`1`,this.firstMeaningfulPaint=!0},500),!this.firstMeaningfulPaint&&e&&this.visible.length?(this.canvas.style.opacity=`1`,this.firstMeaningfulPaint=e,!0):this.options.debug?!0:!e}getRendererScreenPosition(){return this.rendererPosition}reset(){this.loadingQueue=[],this.drawCalls=[]}},Ke=class{constructor(e){O(this,`renderers`,[]),O(this,`length`,void 0);for(let t of e)t&&this.renderers.push(t);this.length=this.renderers.length}afterFrame(e,t,n,r){for(let i=0;i<this.length;i++)this.renderers[i].afterFrame(e,t,n,r)}afterPaintLayer(e,t){for(let n=0;n<this.length;n++)this.renderers[n].afterPaintLayer(e,t)}beforeFrame(e,t,n,r){for(let i=0;i<this.length;i++)this.renderers[i].beforeFrame(e,t,n,r)}triggerResize(){for(let e=0;e<this.length;e++){let t=this.renderers[e];t.triggerResize&&t.triggerResize()}}getPointsAt(e,t,n,r){return this.renderers[0].getPointsAt(e,t,n,r)}getScale(e,t){return this.renderers[0].getScale(e,t)}getViewportBounds(e,t,n){return this.renderers[0].getViewportBounds(e,t,n)}getRendererScreenPosition(){return this.renderers[0].getRendererScreenPosition()}isReady(){for(let e=0;e<this.length;e++)if(!this.renderers[e].isReady())return!1;return!0}paint(e,t,n,r,i,a){for(let o=0;o<this.length;o++)this.renderers[o].paint(e,t,n,r,i,a)}pendingUpdate(){for(let e=0;e<this.length;e++)if(this.renderers[e].pendingUpdate())return!0;return!1}prepareLayer(e,t){for(let n=0;n<this.length;n++)this.renderers[n].prepareLayer(e,t)}finishLayer(e,t){for(let n=0;n<this.length;n++)this.renderers[n].finishLayer(e,t)}resize(e,t){for(let n=0;n<this.length;n++)this.renderers[n].resize(e,t)}reset(){for(let e=0;e<this.length;e++)this.renderers[e].reset()}},qe=class{constructor(e){O(this,`canvas`,void 0),O(this,`context`,void 0),O(this,`heightRatio`,1),O(this,`widthRatio`,1),O(this,`target`,new Float32Array(5)),O(this,`initialWidth`,void 0),O(this,`initialHeight`,void 0),O(this,`bounds`,void 0),O(this,`aggregate`,void 0),O(this,`delta`,0),O(this,`renderNextFrame`,!0),this.canvas=e,this.initialWidth=e.width,this.initialHeight=e.height,this.context=e.getContext(`2d`),this.context.globalAlpha=.5,this.aggregate=(0,l.scale)(1)}isReady(){return!0}resize(){this.initialWidth=this.canvas.width,this.initialHeight=this.canvas.height,this.renderNextFrame=!0}afterFrame(e,t,n){if(this.renderNextFrame){this.context.clearRect(0,0,this.canvas.width,this.canvas.height);let t=this.initialWidth/e.width,r=this.initialHeight/e.height,i=this.widthRatio>this.heightRatio?t:r;if(this.target=n,this.bounds){let t=e.getPointsAt(this.bounds,this.aggregate,i);for(let[e,n]of t)if(e instanceof A&&e.__host.canvas){let t=n.length/5;for(let r=0;r<t;r++)e.__host.canvas.canvases[r]&&(n[r+1]*i,n[r+2]*i,(n[r+3]-n[r+1])*i,(n[r+4]-n[r+2])*i)}}e.getPoints().forEach((e,t,n)=>{if(t%5==0&&e){let e={x1:n[t+1]*i,y1:n[t+2]*i,x2:n[t+3]*i,y2:n[t+4]*i,width:(n[t+3]-n[t+1])*i,height:(n[t+4]-n[t+2])*i};this.context.strokeStyle=`red`,this.context.strokeRect(e.x1,e.y1,e.width,e.height)}}),n&&(this.context.strokeStyle=`red`,this.context.lineWidth=window.devicePixelRatio||1,this.context.strokeRect(n[1]*i,n[2]*i,(n[3]-n[1])*i,(n[4]-n[2])*i))}}getActiveZone(e){return null}getPointsAt(e,t,n,r){return e.getPointsAt(t,n,r)}getScale(e,t){return 1}beforeFrame(e,t){this.bounds=l.DnaFactory.singleBox(e.width,e.height)}drawImage(){}afterPaintLayer(e,t){}paint(e,t,n,r,i,a){this.renderNextFrame=!0}prepareLayer(e){}pendingUpdate(){return!1}hasActiveZone(){return!1}getViewportBounds(e,t,n){return null}getRendererScreenPosition(){return this.canvas.getBoundingClientRect()}finishLayer(){}reset(){}},Je=class{constructor(){O(this,`autoWidth`,!1),O(this,`autoHeight`,!0),O(this,`width`,void 0),O(this,`height`,void 0),O(this,`world`,void 0),O(this,`content`,[]),O(this,`viewingDirection`,`left-to-right`),O(this,`rows`,void 0),O(this,`columns`,4),O(this,`spacing`,20),O(this,`reversed`,!1),O(this,`padding`,20),this.world=R.withProps({width:0,height:0,viewingDirection:`left-to-right`}),this.width=0,this.height=0}setViewingDirection(e){this.viewingDirection=e}addContent(e){this.content.push(...e.map(e=>this.world.addObjectAt(e,{width:0,height:0,x:0,y:0})))}setWidth(e){this.width=e}setHeight(e){this.height=e}setSpacing(e){this.spacing=e}setPadding(e){this.padding=e}setRows(e){this.autoWidth=!0,this.rows=e}setColumns(e){this.autoHeight=!0,this.columns=e}recalculate(){if(this.height===0&&this.width===0||this.rows===0||this.columns===0)return;if(this.autoHeight&&!this.width)throw Error(`Cannot set auto height without setting a width`);if(this.autoWidth&&!this.height)throw Error(`Cannot set auto width without setting a height`);(this.viewingDirection===`left-to-right`||this.viewingDirection===`top-to-bottom`)&&this.reversed&&(this.reversed=!1,this.content.reverse()),(this.viewingDirection===`right-to-left`||this.viewingDirection===`bottom-to-top`)&&!this.reversed&&(this.reversed=!0,this.content.reverse());let e=this.content.length,{columns:t,rows:n}=(()=>{if(this.autoWidth&&this.rows){let t=e>this.rows?this.rows:e;return{columns:Math.ceil(e/t),rows:t}}if(this.autoHeight&&this.columns){let t=e>this.columns?this.columns:e;return{columns:t,rows:Math.ceil(e/t)}}throw Error(`Something went wrong.`)})(),r=this.autoWidth?-1:this.width-this.padding*2,i=this.autoWidth?-1:(r-this.spacing*(t-1))/t;if(this.autoHeight&&!this.autoWidth){let r=0,a=this.padding;for(let o=0;o<n&&r!==e;o++){let n=0,o=[];for(let a=0;a<t;a++){let t=this.reversed?e-r:r;if(r===e)break;let a=this.content[t],s=a.width,c=i/(a.width/a.height);o.push([r,i,c,i/s]),c>n&&(n=c),r++}for(let r=0;r<t&&o[r];r++){let t=this.world.getPoints(),i=o[r][0],s=o[r][1],c=o[r][2],l=o[r][3],u=this.padding+r*(this.spacing+s),d=a+(n-c)/2,f=this.reversed?e-i:i,p=t[f*5+1],m=t[f*5+2];this.world.scaleWorldObject(i,l),(p!==u||m!==d)&&this.world.translateWorldObject(f,u-p,d-m)}a+=n+this.spacing}this.height=a+this.padding,this.world.resize(this.width,this.height);return}this.autoWidth&&this.autoHeight,!this.autoWidth&&this.autoHeight}getWorld(){return this.world}},Ye=o(((e,t)=>{var n=!1,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_;function v(){if(!n){n=!0;var e=navigator.userAgent,t=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(e),v=/(Mac OS X)|(Windows)|(Linux)/.exec(e);if(m=/\b(iPhone|iP[ao]d)/.exec(e),h=/\b(iP[ao]d)/.exec(e),f=/Android/i.exec(e),g=/FBAN\/\w+;/i.exec(e),_=/Mobile/i.exec(e),p=!!/Win64/.exec(e),t){r=t[1]?parseFloat(t[1]):t[5]?parseFloat(t[5]):NaN,r&&document&&document.documentMode&&(r=document.documentMode);var y=/(?:Trident\/(\d+.\d+))/.exec(e);c=y?parseFloat(y[1])+4:r,i=t[2]?parseFloat(t[2]):NaN,a=t[3]?parseFloat(t[3]):NaN,o=t[4]?parseFloat(t[4]):NaN,o?(t=/(?:Chrome\/(\d+\.\d+))/.exec(e),s=t&&t[1]?parseFloat(t[1]):NaN):s=NaN}else r=i=a=s=o=NaN;if(v){if(v[1]){var b=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(e);l=b?parseFloat(b[1].replace(`_`,`.`)):!0}else l=!1;u=!!v[2],d=!!v[3]}else l=u=d=!1}}var y={ie:function(){return v()||r},ieCompatibilityMode:function(){return v()||c>r},ie64:function(){return y.ie()&&p},firefox:function(){return v()||i},opera:function(){return v()||a},webkit:function(){return v()||o},safari:function(){return y.webkit()},chrome:function(){return v()||s},windows:function(){return v()||u},osx:function(){return v()||l},linux:function(){return v()||d},iphone:function(){return v()||m},mobile:function(){return v()||m||h||f||_},nativeApp:function(){return v()||g},android:function(){return v()||f},ipad:function(){return v()||h}};t.exports=y})),Xe=o(((e,t)=>{var n=!!(typeof window<`u`&&window.document&&window.document.createElement);t.exports={canUseDOM:n,canUseWorkers:typeof Worker<`u`,canUseEventListeners:n&&!!(window.addEventListener||window.attachEvent),canUseViewport:n&&!!window.screen,isInWorker:!n}})),Ze=o(((e,t)=>{var n=Xe(),r;n.canUseDOM&&(r=document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature(``,``)!==!0);
2
2
  /**
3
3
  * Checks if an event is supported in the current execution environment.
4
4
  *
@@ -13,7 +13,7 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
13
13
  * @internal
14
14
  * @license Modernizr 3.0.0pre (Custom Build) | MIT
15
15
  */
16
- function i(e,t){if(!n.canUseDOM||t&&!(`addEventListener`in document))return!1;var i=`on`+e,a=i in document;if(!a){var o=document.createElement(`div`);o.setAttribute(i,`return;`),a=typeof o[i]==`function`}return!a&&r&&e===`wheel`&&(a=document.implementation.hasFeature(`Events.wheel`,`3.0`)),a}t.exports=i})),Qe=o(((e,t)=>{var n=Ye(),r=Ze(),i=10,a=40,o=800;function s(e){var t=0,n=0,r=0,s=0;return`detail`in e&&(n=e.detail),`wheelDelta`in e&&(n=-e.wheelDelta/120),`wheelDeltaY`in e&&(n=-e.wheelDeltaY/120),`wheelDeltaX`in e&&(t=-e.wheelDeltaX/120),`axis`in e&&e.axis===e.HORIZONTAL_AXIS&&(t=n,n=0),r=t*i,s=n*i,`deltaY`in e&&(s=e.deltaY),`deltaX`in e&&(r=e.deltaX),(r||s)&&e.deltaMode&&(e.deltaMode==1?(r*=a,s*=a):(r*=o,s*=o)),r&&!t&&(t=r<1?-1:1),s&&!n&&(n=s<1?-1:1),{spinX:t,spinY:n,pixelX:r,pixelY:s}}s.getEventType=function(){return n.firefox()?`DOMMouseScroll`:r(`wheel`)?`wheel`:`mousewheel`},t.exports=s})),$e=o(((e,t)=>{t.exports=Qe()})),et=c($e(),1);const tt=`pan`,nt=`scroll`,rt=`gesture`,it={zoomOutFactor:.8,zoomInFactor:1.25,maxZoomFactor:1,minZoomFactor:.05,zoomDuration:300,zoomWheelConstant:20,zoomClamp:.6,panBounceStiffness:120,panBounceDamping:15,panTimeConstant:240,panPower:.1,nudgeDistance:100,panPadding:0,devicePixelRatio:1,enableWheel:!0,enableClickToZoom:!0,ignoreSingleFingerTouch:!1,enablePanOnWait:!1,requireMetaKeyForWheelZoom:!1,panOnWaitDelay:40,onPanInSketchMode:()=>{},parentElement:null},at=(e={})=>({start:function(t){let{zoomWheelConstant:n,enableWheel:r,enableClickToZoom:i,ignoreSingleFingerTouch:a,enablePanOnWait:o,panOnWaitDelay:s,parentElement:c,requireMetaKeyForWheelZoom:u}={...it,...e},d={pointerStart:{x:0,y:0},isPressing:!1,mousemoveBuffer:(0,l.dna)(5),multiTouch:{distance:0}};t.world.activatedEvents.push(`onMouseUp`,`onMouseDown`,`onMouseMove`,`onTouchStart`,`onTouchEnd`,`onTouchMove`,`onContextMenu`);function f(){g=0,v=``,b(),b(void 0,`notice`),_=0}function p(){t.world.constraintBounds(),f()}function m(e){if(e.which>1){d.isPressing=!1;return}t.mode===`explore`&&(e.preventDefault(),d.pointerStart.x=e.atlas.x,d.pointerStart.y=e.atlas.y,t.transitionManager.stopTransition(),d.isPressing=!0)}function h(){f(),d.isPressing&&(t.mode===`explore`&&t.world.constraintBounds(),d.isPressing=!1)}let g=0,_=0,v=``;function y(e){if(t.mode===`explore`){if(e.atlasTouches.length===1&&(_=performance.now(),a==0&&e.preventDefault(),d.pointerStart.x=e.atlasTouches[0].x,d.pointerStart.y=e.atlasTouches[0].y),e.atlasTouches.length===2){v=`gesture`,e.preventDefault();let t=e.atlasTouches[0].x,n=e.atlasTouches[1].x;d.pointerStart.x=(t+n)/2;let r=e.atlasTouches[0].y,i=e.atlasTouches[1].y;d.pointerStart.y=(r+i)/2,g=M({x:e.touches[0].clientX,y:e.touches[0].clientY},{x:e.touches[1].clientX,y:e.touches[1].clientY})}t.transitionManager.stopTransition(),d.isPressing=!0}}function b(e,t=`intent`){c&&(c.dataset[t]=e)}function x(e){let n=null,r=null,i=0;if(d.isPressing&&e.touches.length===2&&(n=(e.touches[0].clientX+e.touches[1].clientX)/2,r=(e.touches[0].clientY+e.touches[1].clientY)/2,i=M({x:e.touches[0].clientX,y:e.touches[0].clientY},{x:e.touches[1].clientX,y:e.touches[1].clientY})),b(v),d.isPressing&&e.touches.length===1){if(o&&(performance.now()-_<s&&v==``&&(v=nt),v==``&&(v=`pan`)),b(v),v==``&&a==1||v==nt){b(`require-two-finger`,`notice`);return}let t=e.touches[0];n=t.clientX,r=t.clientY}if(n!==null&&r!==null){let e=t.getRendererScreenPosition();if(e){let{x:a,y:o}=t.viewerToWorld(n-e.x,r-e.y),s=i&&g?i/g:1;t.transitionManager.customTransition(e=>{e.from=(0,l.dna)(t.target),e.to=(0,l.transform)(e.from,(0,l.compose)((0,l.translate)(d.pointerStart.x-a,d.pointerStart.y-o),(0,l.scaleAtOrigin)(1/s,a,o)),d.mousemoveBuffer),e.elapsed_time=0,e.total_time=0,e.timingFunction=G.easeInOutExpo,e.done=!1})}g=i}v==`pan`&&e.preventDefault()}function S(e){if(d.isPressing){let n=t.getRendererScreenPosition();if(n){let{x:r,y:i}=t.viewerToWorld(e.clientX-n.x,e.clientY-n.y);t.transitionManager.customTransition(e=>{e.from=(0,l.dna)(t.target),e.to=(0,l.transform)(e.from,(0,l.translate)(d.pointerStart.x-r,d.pointerStart.y-i),d.mousemoveBuffer),e.elapsed_time=0,e.total_time=0,e.timingFunction=G.easeInOutExpo,e.done=!1})}}}function C(e){t.mode===`explore`&&t.world.zoomIn(e.atlas)}function w(e){let r=1+(0,et.default)(e).spinY/n;t.world.zoomTo(r,e.atlas,!0)}function T(e){return u&&e.metaKey==0?(b(`meta-required`,`notice`),e.stopPropagation(),!1):!0}t.world.addEventListener(`mouseup`,p),t.world.addEventListener(`touchend`,p),t.world.addEventListener(`touchstart`,y),t.world.addEventListener(`mousedown`,m),window.addEventListener(`touchend`,h),window.addEventListener(`mouseup`,h),window.addEventListener(`mousemove`,S),c&&c.addEventListener(`touchmove`,x),i&&(t.world.activatedEvents.push(`onClick`),t.world.addEventListener(`click`,C)),r&&(t.world.activatedEvents.push(`onWheel`),u&&c?.addEventListener(`wheel`,T,{passive:!0,capture:!0}),t.world.addEventListener(`wheel`,w));let E=t.world.addLayoutSubscriber((e,n)=>{if(e===`zone-changed`&&t.transitionManager.constrainBounds({transition:{duration:0}}),e===`zoom-to`&&n&&t.transitionManager.zoomTo(n.factor,{origin:n.point,stream:n.stream}),e===`go-home`){let e=n.immediate?{duration:0}:void 0,r=n?.paddingPx===void 0?t.homePaddingPx:n.paddingPx,i=t.getHomeTargetStrand({paddingPx:r});t.transitionManager.applyTransition(i,e,{duration:1e3,easing:G.easeOutExpo,constrain:!0},{stream:!1}),t.updateNextFrame()}if(e===`goto-region`&&n){let e=n.immediate?{duration:0}:{};if(n.paddingPx!==void 0){let r=t.getScaleFactor(!1);if(typeof n.paddingPx==`number`){let i=n.paddingPx/r,a={x:n.x,y:n.y,width:n.width,height:n.height,padding:i};t.transitionManager.goToRegion(a,{transition:e})}else{let i=n.paddingPx.left?n.paddingPx.left/r:0,a=n.paddingPx.right?n.paddingPx.right/r:0,o=n.paddingPx.top?n.paddingPx.top/r:0,s=n.paddingPx.bottom?n.paddingPx.bottom/r:0,c={x:n.x-i,y:n.y-o,width:n.width+i+a,height:n.height+o+s};t.transitionManager.goToRegion(c,{transition:e})}}else t.transitionManager.goToRegion(n,{transition:e})}e===`constrain-bounds`&&t.transitionManager.constrainBounds({transition:n?.immediate?{duration:0}:void 0})});return()=>{t.world.removeEventListener(`mouseup`,p),t.world.removeEventListener(`touchend`,p),t.world.removeEventListener(`touchstart`,y),t.world.removeEventListener(`mousedown`,m),window.removeEventListener(`touchend`,h),window.removeEventListener(`mouseup`,h),t.world.removeEventListener(`mousemove`,S),c&&(c.removeEventListener(`touchmove`,S),c.removeEventListener(`wheel`,T,{passive:!0,capture:!0})),i&&t.world.removeEventListener(`click`,C),r&&t.world.removeEventListener(`wheel`,w),E()}},updatePosition(){}}),q=d.default.createContext(`explore`);q.displayName=`Mode`;const ot=()=>(0,d.useContext)(q);function st(e){return(0,f.jsx)(q.Provider,{value:e.mode,children:e.children})}const J=d.default.createContext(null);J.displayName=`Atlas`;const ct=d.default.createContext(null);ct.displayName=`Bounds`;let lt;if(typeof performance==`object`&&typeof performance.now==`function`){let e=performance;lt=()=>e.now()}else{let e=Date,t=e.now();lt=()=>e.now()-t}const ut=typeof m.default==`function`?m.default:null,dt=8,ft=32,pt=2,mt=0;function ht(e,t){e&&e.appendChild&&t&&e.appendChild(t)}function gt(e,t){e&&e.removeChild&&t&&e.removeChild(t)}function _t(e,t){return gt(e.world,t)}function vt(e,t,n){return yt(e.world,t,n)}function yt(e,t,n){e&&e instanceof ye&&(e=e.world),e&&e.insertBefore&&e.insertBefore(t,n)}function bt(e,t,n){if(n&&(e.applyProps&&e.applyProps(n),e instanceof k))for(let r of _){let i=r.slice(2).toLowerCase();n[r]!==t[r]&&(t[r]&&e.removeEventListener(i,t[r]),e.addEventListener(i,n[r]))}}function xt(e,t){let n=Object.keys(t),r=!1;for(let t of n)if(_.indexOf(t)!==-1){let n=y[t];if(n){if(e.activatedEvents.indexOf(n)!==-1)continue;r=!0,e.activatedEvents.push(n)}}r&&e.triggerEventActivation()}const St=new Map,Ct={};function wt(e,{args:t=[],...n},r,i,a){if(!(r instanceof ye)&&a){let e=t=>t.return?e(t.return):t.stateNode&&t.stateNode.containerInfo;r=e(a)}let o,s=r.world;switch(e){case`world`:o=R.withProps({width:n.width,height:n.height,viewingDirection:`left-to-right`}),o.activatedEvents=s.activatedEvents,o.eventHandlers=s.eventHandlers,o.subscriptions=s.subscriptions,o.triggerEventActivation(),s=o;break;case`box`:o=new B;break;case`shape`:o=new Ce;break;case`worldObject`:case`world-object`:o=new L;break;case`worldImage`:case`world-image`:o=new A;break;case`texture`:o=new te;break;case`compositeImage`:case`composite-image`:o=new F({id:n.id,width:n.width,height:n.height,images:[],renderOptions:n.renderOptions});break;case`tiledImage`:case`tiled-image`:o=P.fromTile(n.uri,n.display,n.tile,n.scaleFactor,void 0,n.format,n.useFloorCalc,n.version3);break;case`paragraph`:o=new V,o.text=n.children;break;default:return}return xt(s,n),bt(o,{},n),o}function Tt(e,t){if(t instanceof R)e.world=t;else if(t instanceof L)e.world.appendChild(t);else if(t)throw Error(`Invalid root`)}let Et=0;const Y=ut?ut({unstable_now:lt,now:lt,createInstance:wt,removeChild:gt,appendChild:ht,appendInitialChild:ht,insertBefore:yt,warnsIfNotActing:!0,supportsMutation:!0,isPrimaryRenderer:!1,scheduleTimeout:typeof setTimeout<`u`?setTimeout:void 0,cancelTimeout:typeof clearTimeout<`u`?clearTimeout:void 0,setTimeout:typeof setTimeout<`u`?setTimeout:void 0,clearTimeout:typeof clearTimeout<`u`?clearTimeout:void 0,noTimeout:-1,appendChildToContainer:Tt,removeChildFromContainer:_t,createTextInstance(){},insertInContainerBefore:vt,prepareUpdate(e,t,n,r,i){return xt(i.world,r),r},commitUpdate(e,t,n,r,i){let a=r,o=n;typeof a==`string`&&(a=n),e.applyProps&&a&&bt(e,o,a)},finalizeInitialChildren(e){return e?.__handlers},getChildHostContext(){return Ct},getRootHostContext(){return Ct},prepareForCommit(e){return e.isCommitting=!0,null},preparePortalMount(){},hideInstance(e){e&&e.points&&(e.points[0]=0)},unhideInstance(e,t){e&&e.points&&(e.points[0]=1)},getPublicInstance(e){return e},hideTextInstance(){throw Error(`Text is not allowed in the react-three-fibre tree. You may have extraneous whitespace between components.`)},resetAfterCommit(e){e.isCommitting=!1,e.pendingUpdate=!0,e.world&&e.world.needsRecalculate&&(e.world.recalculateWorldSize(),e.world.triggerRepaint())},shouldSetTextContent(){return!1},clearContainer(){return!1},supportsHydration:!1,supportsPersistence:!1,detachDeletedInstance(e){},afterActiveInstanceBlur(){},beforeActiveInstanceBlur(){},getCurrentEventPriority(){return 32},getInstanceFromNode(e){throw Error(`Not implemented`)},getInstanceFromScope(e){throw Error(`Not implemented`)},prepareScopeUpdate(e,t){throw Error(`Not implemented`)},logRecoverableError(){},requestPostPaintCallback(){},rendererPackageName:`@atlas-viewer/atlas`,rendererVersion:d.version,shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent:()=>{},resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,maySuspendCommit:()=>!1,preloadInstance:()=>!0,startSuspendingCommit(){},suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,setCurrentUpdatePriority(e){Et=e},getCurrentUpdatePriority(){return Et},resolveUpdatePriority(){if(Et!==0)return Et;switch(typeof window<`u`&&window.event?.type){case`click`:case`contextmenu`:case`dblclick`:case`pointercancel`:case`pointerdown`:case`pointerup`:return 2;case`pointermove`:case`pointerout`:case`pointerover`:case`pointerenter`:case`pointerleave`:case`wheel`:return 8;default:return 32}},resetFormInstance(){}}):null;Y&&Y.injectIntoDevTools();function Dt(e,t){let n=St.get(e);if(n){if(!Y)return;Y.updateContainer(null,n,null,()=>{St.delete(e),t&&t(e)})}}const Ot={render(e,t){let n=St.get(t);if(Y)if(n)Y.updateContainer(e,n,null);else{let n=Y.createContainer(t,0,null,!1,null,``,()=>{},null);Y.updateContainer(e,n,null),St.set(t,n)}},unmountComponentAtNode(e,t){Dt(e,t)}},X=typeof window<`u`&&(window.document?.createElement||window.navigator?.product===`ReactNative`)?d.useLayoutEffect:d.useEffect,kt=d.default.memo(({children:e,setIsReady:t,onCreated:n,bounds:r,preset:i,mode:a=`explore`})=>{let o=(0,d.useCallback)(function(e){let r=(0,d.useRef)(!1),a=()=>{t(!0)};return(0,d.useEffect)(()=>{if(i&&!r.current){i.runtime.goHome();let e=n&&n(i);e&&e.then?e.then(a):a();return}return()=>{}},[]),(0,d.useEffect)(()=>{r.current=!0},[]),e.children},[i]);return X(()=>{if(i){let t=i.runtime;a!==t.mode&&(t.mode=a),Ot.render((0,f.jsx)(d.default.StrictMode,{children:(0,f.jsx)(o,{children:(0,f.jsx)(ct.Provider,{value:r,children:(0,f.jsx)(q.Provider,{value:a,children:(0,f.jsx)(J.Provider,{value:i,children:e})})})})}),t)}},[i,a,e]),X(()=>{if(i){let e=i.runtime;return()=>{Ot.unmountComponentAtNode(e)}}return()=>{}},[i]),null});var At=class{constructor(e,t){O(this,`canvas`,void 0),O(this,`gl`,void 0),O(this,`program`,void 0),O(this,`fragmentShader`,void 0),O(this,`vertexShader`,void 0),O(this,`rectBuffer`,void 0),O(this,`fragmentShaderSource`,`
16
+ function i(e,t){if(!n.canUseDOM||t&&!(`addEventListener`in document))return!1;var i=`on`+e,a=i in document;if(!a){var o=document.createElement(`div`);o.setAttribute(i,`return;`),a=typeof o[i]==`function`}return!a&&r&&e===`wheel`&&(a=document.implementation.hasFeature(`Events.wheel`,`3.0`)),a}t.exports=i})),Qe=o(((e,t)=>{var n=Ye(),r=Ze(),i=10,a=40,o=800;function s(e){var t=0,n=0,r=0,s=0;return`detail`in e&&(n=e.detail),`wheelDelta`in e&&(n=-e.wheelDelta/120),`wheelDeltaY`in e&&(n=-e.wheelDeltaY/120),`wheelDeltaX`in e&&(t=-e.wheelDeltaX/120),`axis`in e&&e.axis===e.HORIZONTAL_AXIS&&(t=n,n=0),r=t*i,s=n*i,`deltaY`in e&&(s=e.deltaY),`deltaX`in e&&(r=e.deltaX),(r||s)&&e.deltaMode&&(e.deltaMode==1?(r*=a,s*=a):(r*=o,s*=o)),r&&!t&&(t=r<1?-1:1),s&&!n&&(n=s<1?-1:1),{spinX:t,spinY:n,pixelX:r,pixelY:s}}s.getEventType=function(){return n.firefox()?`DOMMouseScroll`:r(`wheel`)?`wheel`:`mousewheel`},t.exports=s})),$e=o(((e,t)=>{t.exports=Qe()})),et=c($e(),1);const tt=`pan`,nt=`scroll`,rt=`gesture`,it={zoomOutFactor:.8,zoomInFactor:1.25,maxZoomFactor:1,minZoomFactor:.05,zoomDuration:300,zoomWheelConstant:20,zoomClamp:.6,panBounceStiffness:120,panBounceDamping:15,panTimeConstant:240,panPower:.1,nudgeDistance:100,panPadding:0,devicePixelRatio:1,enableWheel:!0,enableClickToZoom:!0,ignoreSingleFingerTouch:!1,enablePanOnWait:!1,requireMetaKeyForWheelZoom:!1,panOnWaitDelay:40,onPanInSketchMode:()=>{},parentElement:null},at=(e={})=>({start:function(t){let{zoomWheelConstant:n,enableWheel:r,enableClickToZoom:i,ignoreSingleFingerTouch:a,enablePanOnWait:o,panOnWaitDelay:s,parentElement:c,requireMetaKeyForWheelZoom:u}={...it,...e},d={pointerStart:{x:0,y:0},isPressing:!1,mousemoveBuffer:(0,l.dna)(5),multiTouch:{distance:0}};t.world.activatedEvents.push(`onMouseUp`,`onMouseDown`,`onMouseMove`,`onTouchStart`,`onTouchEnd`,`onTouchMove`,`onContextMenu`);function f(){g=0,v=``,b(),b(void 0,`notice`),_=0}function p(){t.world.constraintBounds(),f()}function m(e){if(e.which>1){d.isPressing=!1;return}t.mode===`explore`&&(e.preventDefault(),d.pointerStart.x=e.atlas.x,d.pointerStart.y=e.atlas.y,t.transitionManager.stopTransition(),d.isPressing=!0)}function h(){f(),d.isPressing&&(t.mode===`explore`&&t.world.constraintBounds(),d.isPressing=!1)}let g=0,_=0,v=``;function y(e){if(t.mode===`explore`){if(e.atlasTouches.length===1&&(_=performance.now(),a==0&&e.preventDefault(),d.pointerStart.x=e.atlasTouches[0].x,d.pointerStart.y=e.atlasTouches[0].y),e.atlasTouches.length===2){v=`gesture`,e.preventDefault();let t=e.atlasTouches[0].x,n=e.atlasTouches[1].x;d.pointerStart.x=(t+n)/2;let r=e.atlasTouches[0].y,i=e.atlasTouches[1].y;d.pointerStart.y=(r+i)/2,g=M({x:e.touches[0].clientX,y:e.touches[0].clientY},{x:e.touches[1].clientX,y:e.touches[1].clientY})}t.transitionManager.stopTransition(),d.isPressing=!0}}function b(e,t=`intent`){c&&(c.dataset[t]=e)}function x(e){let n=null,r=null,i=0;if(d.isPressing&&e.touches.length===2&&(n=(e.touches[0].clientX+e.touches[1].clientX)/2,r=(e.touches[0].clientY+e.touches[1].clientY)/2,i=M({x:e.touches[0].clientX,y:e.touches[0].clientY},{x:e.touches[1].clientX,y:e.touches[1].clientY})),b(v),d.isPressing&&e.touches.length===1){if(o&&(performance.now()-_<s&&v==``&&(v=nt),v==``&&(v=`pan`)),b(v),v==``&&a==1||v==nt){b(`require-two-finger`,`notice`);return}let t=e.touches[0];n=t.clientX,r=t.clientY}if(n!==null&&r!==null){let e=t.getRendererScreenPosition();if(e){let{x:a,y:o}=t.viewerToWorld(n-e.x,r-e.y),s=i&&g?i/g:1;t.transitionManager.customTransition(e=>{e.from=(0,l.dna)(t.target),e.to=(0,l.transform)(e.from,(0,l.compose)((0,l.translate)(d.pointerStart.x-a,d.pointerStart.y-o),(0,l.scaleAtOrigin)(1/s,a,o)),d.mousemoveBuffer),e.elapsed_time=0,e.total_time=0,e.timingFunction=G.easeInOutExpo,e.done=!1})}g=i}v==`pan`&&e.preventDefault()}function S(e){if(d.isPressing){let n=t.getRendererScreenPosition();if(n){let{x:r,y:i}=t.viewerToWorld(e.clientX-n.x,e.clientY-n.y);t.transitionManager.customTransition(e=>{e.from=(0,l.dna)(t.target),e.to=(0,l.transform)(e.from,(0,l.translate)(d.pointerStart.x-r,d.pointerStart.y-i),d.mousemoveBuffer),e.elapsed_time=0,e.total_time=0,e.timingFunction=G.easeInOutExpo,e.done=!1})}}}function C(e){t.mode===`explore`&&t.world.zoomIn(e.atlas)}function w(e){let r=1+(0,et.default)(e).spinY/n;t.world.zoomTo(r,e.atlas,!0)}function T(e){return u&&e.metaKey==0?(b(`meta-required`,`notice`),e.stopPropagation(),!1):!0}t.world.addEventListener(`mouseup`,p),t.world.addEventListener(`touchend`,p),t.world.addEventListener(`touchstart`,y),t.world.addEventListener(`mousedown`,m),window.addEventListener(`touchend`,h),window.addEventListener(`mouseup`,h),window.addEventListener(`mousemove`,S),c&&c.addEventListener(`touchmove`,x),i&&(t.world.activatedEvents.push(`onClick`),t.world.addEventListener(`click`,C)),r&&(t.world.activatedEvents.push(`onWheel`),u&&c?.addEventListener(`wheel`,T,{passive:!0,capture:!0}),t.world.addEventListener(`wheel`,w));let E=t.world.addLayoutSubscriber((e,n)=>{if(e===`zone-changed`&&t.transitionManager.constrainBounds({transition:{duration:0}}),e===`zoom-to`&&n&&t.transitionManager.zoomTo(n.factor,{origin:n.point,stream:n.stream}),e===`go-home`){let e=n.immediate?{duration:0}:void 0,r=n?.paddingPx,i=t.getHomeTarget({paddingPx:r});t.transitionManager.goToRegion(i,{transition:e})}if(e===`goto-region`&&n){let e=n.immediate?{duration:0}:{};if(n.paddingPx!==void 0){let r=t.getHomeTarget({position:l.DnaFactory.singleBox(n.width,n.height,n.x,n.y),paddingPx:n.paddingPx});t.transitionManager.goToRegion(r,{transition:e})}else t.transitionManager.goToRegion(n,{transition:e})}e===`constrain-bounds`&&t.transitionManager.constrainBounds({transition:n?.immediate?{duration:0}:void 0})});return()=>{t.world.removeEventListener(`mouseup`,p),t.world.removeEventListener(`touchend`,p),t.world.removeEventListener(`touchstart`,y),t.world.removeEventListener(`mousedown`,m),window.removeEventListener(`touchend`,h),window.removeEventListener(`mouseup`,h),t.world.removeEventListener(`mousemove`,S),c&&(c.removeEventListener(`touchmove`,S),c.removeEventListener(`wheel`,T,{passive:!0,capture:!0})),i&&t.world.removeEventListener(`click`,C),r&&t.world.removeEventListener(`wheel`,w),E()}},updatePosition(){}}),q=d.default.createContext(`explore`);q.displayName=`Mode`;const ot=()=>(0,d.useContext)(q);function st(e){return(0,f.jsx)(q.Provider,{value:e.mode,children:e.children})}const J=d.default.createContext(null);J.displayName=`Atlas`;const ct=d.default.createContext(null);ct.displayName=`Bounds`;let lt;if(typeof performance==`object`&&typeof performance.now==`function`){let e=performance;lt=()=>e.now()}else{let e=Date,t=e.now();lt=()=>e.now()-t}const ut=typeof m.default==`function`?m.default:null,dt=8,ft=32,pt=2,mt=0;function ht(e,t){e&&e.appendChild&&t&&e.appendChild(t)}function gt(e,t){e&&e.removeChild&&t&&e.removeChild(t)}function _t(e,t){return gt(e.world,t)}function vt(e,t,n){return yt(e.world,t,n)}function yt(e,t,n){e&&e instanceof ye&&(e=e.world),e&&e.insertBefore&&e.insertBefore(t,n)}function bt(e,t,n){if(n&&(e.applyProps&&e.applyProps(n),e instanceof k))for(let r of _){let i=r.slice(2).toLowerCase();n[r]!==t[r]&&(t[r]&&e.removeEventListener(i,t[r]),e.addEventListener(i,n[r]))}}function xt(e,t){let n=Object.keys(t),r=!1;for(let t of n)if(_.indexOf(t)!==-1){let n=y[t];if(n){if(e.activatedEvents.indexOf(n)!==-1)continue;r=!0,e.activatedEvents.push(n)}}r&&e.triggerEventActivation()}const St=new Map,Ct={};function wt(e,{args:t=[],...n},r,i,a){if(!(r instanceof ye)&&a){let e=t=>t.return?e(t.return):t.stateNode&&t.stateNode.containerInfo;r=e(a)}let o,s=r.world;switch(e){case`world`:o=R.withProps({width:n.width,height:n.height,viewingDirection:`left-to-right`}),o.activatedEvents=s.activatedEvents,o.eventHandlers=s.eventHandlers,o.subscriptions=s.subscriptions,o.triggerEventActivation(),s=o;break;case`box`:o=new B;break;case`shape`:o=new Ce;break;case`worldObject`:case`world-object`:o=new L;break;case`worldImage`:case`world-image`:o=new A;break;case`texture`:o=new te;break;case`compositeImage`:case`composite-image`:o=new F({id:n.id,width:n.width,height:n.height,images:[],renderOptions:n.renderOptions});break;case`tiledImage`:case`tiled-image`:o=P.fromTile(n.uri,n.display,n.tile,n.scaleFactor,void 0,n.format,n.useFloorCalc,n.version3);break;case`paragraph`:o=new V,o.text=n.children;break;default:return}return xt(s,n),bt(o,{},n),o}function Tt(e,t){if(t instanceof R)e.world=t;else if(t instanceof L)e.world.appendChild(t);else if(t)throw Error(`Invalid root`)}let Et=0;const Y=ut?ut({unstable_now:lt,now:lt,createInstance:wt,removeChild:gt,appendChild:ht,appendInitialChild:ht,insertBefore:yt,warnsIfNotActing:!0,supportsMutation:!0,isPrimaryRenderer:!1,scheduleTimeout:typeof setTimeout<`u`?setTimeout:void 0,cancelTimeout:typeof clearTimeout<`u`?clearTimeout:void 0,setTimeout:typeof setTimeout<`u`?setTimeout:void 0,clearTimeout:typeof clearTimeout<`u`?clearTimeout:void 0,noTimeout:-1,appendChildToContainer:Tt,removeChildFromContainer:_t,createTextInstance(){},insertInContainerBefore:vt,prepareUpdate(e,t,n,r,i){return xt(i.world,r),r},commitUpdate(e,t,n,r,i){let a=r,o=n;typeof a==`string`&&(a=n),e.applyProps&&a&&bt(e,o,a)},finalizeInitialChildren(e){return e?.__handlers},getChildHostContext(){return Ct},getRootHostContext(){return Ct},prepareForCommit(e){return e.isCommitting=!0,null},preparePortalMount(){},hideInstance(e){e&&e.points&&(e.points[0]=0)},unhideInstance(e,t){e&&e.points&&(e.points[0]=1)},getPublicInstance(e){return e},hideTextInstance(){throw Error(`Text is not allowed in the react-three-fibre tree. You may have extraneous whitespace between components.`)},resetAfterCommit(e){e.isCommitting=!1,e.pendingUpdate=!0,e.world&&e.world.needsRecalculate&&(e.world.recalculateWorldSize(),e.world.triggerRepaint())},shouldSetTextContent(){return!1},clearContainer(){return!1},supportsHydration:!1,supportsPersistence:!1,detachDeletedInstance(e){},afterActiveInstanceBlur(){},beforeActiveInstanceBlur(){},getCurrentEventPriority(){return 32},getInstanceFromNode(e){throw Error(`Not implemented`)},getInstanceFromScope(e){throw Error(`Not implemented`)},prepareScopeUpdate(e,t){throw Error(`Not implemented`)},logRecoverableError(){},requestPostPaintCallback(){},rendererPackageName:`@atlas-viewer/atlas`,rendererVersion:d.version,shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent:()=>{},resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,maySuspendCommit:()=>!1,preloadInstance:()=>!0,startSuspendingCommit(){},suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,setCurrentUpdatePriority(e){Et=e},getCurrentUpdatePriority(){return Et},resolveUpdatePriority(){if(Et!==0)return Et;switch(typeof window<`u`&&window.event?.type){case`click`:case`contextmenu`:case`dblclick`:case`pointercancel`:case`pointerdown`:case`pointerup`:return 2;case`pointermove`:case`pointerout`:case`pointerover`:case`pointerenter`:case`pointerleave`:case`wheel`:return 8;default:return 32}},resetFormInstance(){}}):null;Y&&Y.injectIntoDevTools();function Dt(e,t){let n=St.get(e);if(n){if(!Y)return;Y.updateContainer(null,n,null,()=>{St.delete(e),t&&t(e)})}}const Ot={render(e,t){let n=St.get(t);if(Y)if(n)Y.updateContainer(e,n,null);else{let n=Y.createContainer(t,0,null,!1,null,``,()=>{},null);Y.updateContainer(e,n,null),St.set(t,n)}},unmountComponentAtNode(e,t){Dt(e,t)}},X=typeof window<`u`&&(window.document?.createElement||window.navigator?.product===`ReactNative`)?d.useLayoutEffect:d.useEffect,kt=d.default.memo(({children:e,setIsReady:t,onCreated:n,bounds:r,preset:i,mode:a=`explore`})=>{let o=(0,d.useCallback)(function(e){let r=(0,d.useRef)(!1),a=()=>{t(!0)};return(0,d.useEffect)(()=>{if(i&&!r.current){i.runtime.goHome();let e=n&&n(i);e&&e.then?e.then(a):a();return}return()=>{}},[]),(0,d.useEffect)(()=>{r.current=!0},[]),e.children},[i]);return X(()=>{if(i){let t=i.runtime;a!==t.mode&&(t.mode=a),Ot.render((0,f.jsx)(d.default.StrictMode,{children:(0,f.jsx)(o,{children:(0,f.jsx)(ct.Provider,{value:r,children:(0,f.jsx)(q.Provider,{value:a,children:(0,f.jsx)(J.Provider,{value:i,children:e})})})})}),t)}},[i,a,e]),X(()=>{if(i){let e=i.runtime;return()=>{Ot.unmountComponentAtNode(e)}}return()=>{}},[i]),null});var At=class{constructor(e,t){O(this,`canvas`,void 0),O(this,`gl`,void 0),O(this,`program`,void 0),O(this,`fragmentShader`,void 0),O(this,`vertexShader`,void 0),O(this,`rectBuffer`,void 0),O(this,`fragmentShaderSource`,`
17
17
  precision mediump float;
18
18
 
19
19
  uniform sampler2D u_image;
package/dist/index.d.cts CHANGED
@@ -624,27 +624,18 @@ declare class Runtime {
624
624
  y: number;
625
625
  };
626
626
  _lastGoodScale: number;
627
- _canvasWidth: number;
628
- _canvasHeight: number;
629
627
  hooks: RuntimeHooks;
630
628
  fpsLimit: number | undefined;
631
629
  options: RuntimeOptions;
632
630
  hookOptions: HookOptions;
633
631
  constructor(renderer: Renderer, world: World, target: Viewer, controllers?: RuntimeController[], options?: Partial<RuntimeOptions>);
634
632
  setHomePosition(position?: Projection): void;
635
- /**
636
- * Set the default home padding in CSS pixels. When `goHome()` is invoked without a paddingPx
637
- * this value will be used and converted to world units internally.
638
- */
639
633
  setHomePaddingPx(px?: number | {
640
634
  left?: number;
641
635
  right?: number;
642
636
  top?: number;
643
637
  bottom?: number;
644
638
  }): void;
645
- /**
646
- * Get the current default home padding in CSS pixels (as set via `setHomePaddingPx`).
647
- */
648
639
  getHomePaddingPx(): number | {
649
640
  left?: number;
650
641
  right?: number;
@@ -667,6 +658,14 @@ declare class Runtime {
667
658
  } | undefined;
668
659
  updateRendererScreenPosition(): void;
669
660
  setOptions(options: Partial<RuntimeOptions>): void;
661
+ /**
662
+ * Normalize padding input to a consistent per-side format.
663
+ */
664
+ private normalizePadding;
665
+ /**
666
+ * Calculate the viewport region that fits the target content within the available
667
+ * canvas area (accounting for CSS pixel padding).
668
+ */
670
669
  getHomeTarget(options?: {
671
670
  cover?: boolean;
672
671
  position?: Strand;
@@ -682,16 +681,6 @@ declare class Runtime {
682
681
  width: number;
683
682
  height: number;
684
683
  };
685
- getHomeTargetStrand(options?: {
686
- cover?: boolean;
687
- position?: Strand;
688
- paddingPx?: number | {
689
- left?: number;
690
- right?: number;
691
- top?: number;
692
- bottom?: number;
693
- };
694
- }): Strand;
695
684
  goHome(options?: {
696
685
  cover?: boolean;
697
686
  position?: Strand;
@@ -746,17 +735,10 @@ declare class Runtime {
746
735
  }) => void;
747
736
  constrainBounds(target: Strand, {
748
737
  panPadding,
749
- ref,
750
- homePaddingPx
738
+ ref
751
739
  }?: {
752
740
  ref?: boolean;
753
741
  panPadding?: number;
754
- homePaddingPx?: number | {
755
- left?: number;
756
- right?: number;
757
- top?: number;
758
- bottom?: number;
759
- };
760
742
  }): readonly [boolean, Strand];
761
743
  /**
762
744
  * Get bounds
@@ -768,12 +750,6 @@ declare class Runtime {
768
750
  getBounds(options: {
769
751
  padding: number;
770
752
  target?: Strand;
771
- homePaddingPx?: number | {
772
- left?: number;
773
- right?: number;
774
- top?: number;
775
- bottom?: number;
776
- };
777
753
  }): {
778
754
  readonly minX: number;
779
755
  readonly maxX: number;