@atlas-viewer/atlas 2.3.2 → 2.3.3

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.js CHANGED
@@ -1,4 +1,4 @@
1
- var un=Object.defineProperty;var mn=(r,e,t)=>e in r?un(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var o=(r,e,t)=>(mn(r,typeof e!="symbol"?e+"":e,t),t);var At=["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"];function Ze(){return At.reduce((r,e)=>(r[e]=[],r),{})}var Y=At.reduce((r,e)=>(r[e.slice(2).toLowerCase()]=e,r[e]=e,r),{});import{dna as Ce,DnaFactory as vt,mutate as pn,translate as yn}from"@atlas-viewer/dna";import{mutate as Ee,scaleAtOrigin as gn,translate as fn}from"@atlas-viewer/dna";var Xe="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Q=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=Xe[t[r]&63];return e};var k=class{constructor(){o(this,"__id");o(this,"__revision",0);o(this,"__host");o(this,"__onCreate");o(this,"__parent");o(this,"__owner",{value:void 0});o(this,"__state",{});o(this,"eventHandlers");o(this,"scale",1);o(this,"layers",[]);o(this,"time",[]);o(this,"_crop");o(this,"cropData");o(this,"id");o(this,"addEventListener",(e,t,i)=>{let n=Y[e];if(!this.eventHandlers[n])throw new Error(`Unknown event ${n}`);this.eventHandlers[n].indexOf(t)===-1&&this.eventHandlers[n].push(t)});o(this,"removeEventListener",(e,t)=>{let i=Y[e];if(!this.eventHandlers[i]){console.warn(`Unknown event ${i}`);return}this.eventHandlers[i].indexOf(t)!==-1&&(this.eventHandlers[i]=this.eventHandlers[i].filter(n=>n!==t))});this.id=this.__id=Q(),this.eventHandlers=Ze()}get crop(){return this._crop}set crop(e){this._crop=e}getObjectsAt(e){return[]}getAllPointsAt(e,t,i){return[]}getScheduledUpdates(e,t){return[]}dispatchEvent(e,t){let i=this.eventHandlers[e],n=i?i.length:0,s=!1;if(n)for(let a=0;a<n;a++)try{i[a](t),s=!0}catch(h){console.error(e,h)}return s}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){Ee(this.points,fn(e,t))}atScale(e){Ee(this.points,gn(e,this.x,this.y)),this.scale*=e}transform(e){Ee(this.points,e)}applyProps(e){this.__revision++}appendChild(e){}removeChild(e){}insertBefore(e,t){}hideInstance(){}};var D=class r extends k{constructor(t){super();o(this,"type","spacial-content");o(this,"id");o(this,"uri");o(this,"display");o(this,"points");o(this,"priority");o(this,"style",{opacity:1});if(!t)this.id="",this.uri="",this.display={x:0,y:0,scale:1,width:0,height:0,points:Ce(5)},this.points=Ce(5);else{let i=t.scale||1;this.id=t.id||t.uri,this.uri=t.uri,this.points=vt.singleBox(t.width,t.height,t.x,t.y),this.display={x:0,y:0,scale:i,width:t.width/i,height:t.height/i,points:vt.singleBox(t.width/i,t.height/i),rotation:t?.rotation}}}applyProps(t){let i=t.display?t.display.width:t.target.width,n=t.target.width/i;if(this.id=t.id||t.uri,this.uri=t.uri,this.points.set(vt.singleBox(t.target.width,t.target.height,t.target.x,t.target.y)),t.style&&typeof t.style.opacity<"u"&&(this.style.opacity=t.style.opacity),t.crop){this.cropData=t.crop;let s=vt.singleBox(t.crop.width,t.crop.height,t.crop.x,t.crop.y);pn(s,yn(-t.crop.x,-t.crop.y)),this.crop?this.crop.set(s):this.crop=Ce(s)}t.display?(this.display.scale=n,this.display.width=t.display.width,this.display.height=t.display.height,this.display.rotation=t.display.rotation,this.display.points=vt.singleBox(t.display.width,t.display.height)):(this.display.scale=n,this.display.width=t.target.width/n,this.display.height=t.target.height/n,this.display.points=vt.singleBox(t.target.width/n,t.target.height/n))}getAllPointsAt(t,i,n){return[[this,this.crop||this.points,i]]}static fromSvg(t,i,n,s){return r.fromImage("data:image/svg+xml;base64,"+btoa(t),i,n,s)}static fromImage(t,i,n,s){let a=new r;return a.applyProps({uri:t,id:s,display:n,target:i}),a}getImageUrl(){return this.uri}};import{dna as Ye,DnaFactory as Ut}from"@atlas-viewer/dna";var dt=class extends k{constructor(t){super();o(this,"type","spacial-content");o(this,"id");o(this,"uri");o(this,"display");o(this,"points");o(this,"getTexture");if(this.getTexture=()=>({source:void 0,hash:-1}),!t)this.id="",this.uri="",this.display={x:0,y:0,scale:1,width:0,height:0,points:Ye(5)},this.points=Ye(5);else{let i=t.scale||1;this.id=t.id||t.uri,this.uri=t.uri,this.points=Ut.singleBox(t.width,t.height),this.display={x:0,y:0,scale:i,width:t.width/i,height:t.height/i,points:i!==1?Ut.singleBox(t.width/i,t.height/i):this.points}}}applyProps(t){let i=t.display?t.display.width:t.target.width,n=t.target.width/i;this.id=t.id,this.points.set(Ut.singleBox(t.target.width,t.target.height)),this.display.scale=n,this.display.width=t.target.width/n,this.display.height=t.target.height/n,this.getTexture=t.getTexture,this.display.points=n!==1?Ut.singleBox(t.target.width/n,t.target.height/n):this.points}getAllPointsAt(t,i,n){return[[this,this.points,i]]}};import{DnaFactory as qe,hidePointsOutsideRegion as bn,mutate as Je,scale as vn,transform as wn,dna as xn,translate as Sn}from"@atlas-viewer/dna";function Qe(r,e,t=1){let i=e.length;if(i===0)throw new Error("No resources passed in.");let n=0,s=1/0;for(let a=0;a<i&&!(!e[a]||!e[a].display);a++){let h=Re(e[a].display.scale,r/(t||1));h<s&&(s=h,n=a)}return n}function Re(r,e){return Math.abs(r-e)}function ct(r,e){let t=Re(r.x,e.x),i=Re(r.y,e.y);return Math.sqrt(Math.pow(t,2)+Math.pow(i,2))}function Ke(r){let e=r.length;return r.indexOf("/info.json")===e-10?r.slice(0,-10):r}function $t(r,e,t){return Math.min(Math.max(r,e),t)}var $=class r extends k{constructor(t){super();o(this,"id");o(this,"type","spacial-content");o(this,"display");o(this,"tileWidth");o(this,"style",{opacity:1});o(this,"points");o(this,"service");o(this,"format","jpg");o(this,"crop2");o(this,"tileUrl");this.tileUrl=Ke(t.url),this.id=t.id||`${this.tileUrl}--${t.scaleFactor}`,this.points=t.displayPoints?t.displayPoints:wn(t.points,vn(t.scaleFactor)),this.tileWidth=t.tileWidth,this.display={x:0,y:0,width:t.width/t.scaleFactor,height:t.height/t.scaleFactor,points:t.points,scale:t.scaleFactor},t.format&&(this.format=t.format)}applyProps(t){if(t.style&&typeof t.style.opacity<"u"&&(this.style.opacity=t.style.opacity),t.service!==this.service&&(this.service=t.service),t.format?this.format=t.format:this.format="jpg",t.crop){this.cropData=t.crop;let i=xn([...this.points]),n=i.length/5,s=t.crop.x||0,a=t.crop.y||0,h=t.crop.x+t.crop.width,d=t.crop.y+t.crop.height;for(let u=0;u<n;u++){let l=u*5;i[l+1]<h&&i[l+3]>s&&i[l+2]<d&&i[l+4]>a?(i[l+1]=$t(i[l+1],s,h),i[l+3]=$t(i[l+3],s,h),i[l+2]=$t(i[l+2],a,d),i[l+4]=$t(i[l+4],a,d)):i[l]=0}Je(i,Sn(-t.crop.x,-t.crop.y)),this.crop?this.crop.set(i):this.crop=i}}static fromTile(t,i,n,s,a,h,d){n.height=n.height?n.height:n.width;let u=d?Math.floor(i.width/s):Math.ceil(i.width/s),l=d?Math.floor(i.height/s):Math.ceil(i.height/s),c=Math.ceil(u/n.width),m=Math.ceil(l/n.height),y=qe.grid(c,m),v=qe.grid(c,m);for(let P=0;P<m;P++)for(let g=0;g<c;g++){let f=g*n.width,C=P*n.height;v.addPoints(f*s,C*s,g===c-1?i.width:(f+n.width)*s,P===m-1?i.height:(C+n.height)*s),y.addPoints(f,C,g===c-1?u:f+n.width,P===m-1?l:C+n.height)}let x=new r({url:t,scaleFactor:s,points:y.build(),displayPoints:v.build(),width:i.width,height:i.height,tileWidth:n.width,format:h});return x.applyProps({service:a}),x}getImageUrl(t){let i=this.points.slice(t*5,t*5+5),n=i[3]-i[1],s=i[4]-i[2],a=Math.ceil(n/this.display.scale);return`${this.tileUrl}/${i[1]},${i[2]},${n},${s}/${a>this.tileWidth?this.tileWidth:a},/0/default.${this.format||"jpg"}`}getAllPointsAt(t,i,n){let s=bn(this.crop||this.points,t);return[[this,s,i]]}transform(t){Je(this.points,t)}getScheduledUpdates(t,i){return[]}};import{compose as Pn,dna as En,DnaFactory as ti,translate as ei}from"@atlas-viewer/dna";var Vt=class extends k{constructor(){super(...arguments);o(this,"type","spacial-content")}getAllPointsAt(t,i,n){return[[this,this.points,i]]}};var Gt=class extends Vt{constructor(t){super();o(this,"id");o(this,"display");o(this,"points");o(this,"images",[]);o(this,"allImages",[]);o(this,"scaleFactors",[]);o(this,"aggregateBuffer",En(9));o(this,"lazyLoader");o(this,"isFullyLoaded",!1);o(this,"maxScaleFactor",0);o(this,"renderOptions");o(this,"_scheduleSortByScales",!1);o(this,"_sortByScales",()=>{this._scheduleSortByScales=!1,this.allImages.sort((i,n)=>n.display.width-i.display.width),this.images=[];let t=.1;for(let i of this.allImages){if(i.display.width<this.renderOptions.minSize&&i.display.height<this.renderOptions.minSize&&!i.priority||i instanceof D&&(i.display.width>this.renderOptions.maxImageSize||i.display.height>this.renderOptions.maxImageSize)&&!i.priority)continue;if(Math.abs(i.display.scale-t)<.25||i.priority){let s=this.images.pop();s&&(s instanceof D||s.priority)?(i.priority&&this.images.push(i),this.images.push(s)):i&&this.images.push(i)}else i&&this.images.push(i);t=i.display.scale}this.images.length===0&&(this.images=[...this.allImages]),this.scaleFactors=this.images.map(i=>i.display.scale),this.maxScaleFactor=Math.max(...this.scaleFactors)});o(this,"loadFullResource",async()=>{if(!this.isFullyLoaded&&this.lazyLoader){this.isFullyLoaded=!0;let t=await this.lazyLoader();this.addImages(t)}});o(this,"fallback",[this.loadFullResource]);this.id=t.id,this.points=ti.singleBox(t.width,t.height),this.lazyLoader=t.loadFullImages,t.loadFullImages||(this.isFullyLoaded=!0),this.display={x:0,y:0,points:ti.singleBox(t.width,t.height),height:t.height,width:t.width,scale:1},this.renderOptions={renderSmallestFallback:!0,renderLayers:3,minSize:255,maxImageSize:2048,quality:1.5,...t.renderOptions||{}},this.addImages(t.images)}applyProps(t){typeof t.renderSmallestFallback<"u"&&t.renderSmallestFallback!==this.renderOptions.renderSmallestFallback&&(this.renderOptions.renderSmallestFallback=t.renderSmallestFallback),typeof t.renderLayers<"u"&&t.renderLayers!==this.renderOptions.renderLayers&&(this.renderOptions.renderLayers=t.renderLayers),typeof t.minSize<"u"&&t.minSize!==this.renderOptions.minSize&&(this.renderOptions.minSize=t.minSize),typeof t.maxImageSize<"u"&&t.maxImageSize!==this.renderOptions.maxImageSize&&(this.renderOptions.maxImageSize=t.maxImageSize),typeof t.quality<"u"&&t.quality!==this.renderOptions.quality&&(this.renderOptions.quality=t.quality)}appendChild(t){this.addImages([t])}removeChild(t){this.images.indexOf(t)!==-1&&(this.images=this.images.filter(i=>i!==t),this.sortByScales())}insertBefore(t,i){this.addImages([t])}hideInstance(){}addImages(t){for(let i of t)i.__parent=this,i.__owner=this.__owner;this.allImages.push(...t.filter(Boolean)),this.sortByScales()}sortByScales(){this._scheduleSortByScales=!0}getScheduledUpdates(t,i){return this._scheduleSortByScales?[this._sortByScales]:this.isFullyLoaded?[]:i>1/this.maxScaleFactor?this.fallback:[]}getAllPointsAt(t,i,n){if(this.images.length===0)return[];let s=Qe(1/(n||1)/(window.devicePixelRatio||1),this.images,this.renderOptions.quality),a=this.images.length,h=i?Pn(i,ei(this.x,this.y)):ei(this.x,this.y);if(s!==this.images.length-1&&this.images[s+1]){let d=[];for(let c=a-1;c>=s;c--)d.push(c);let u=d[0];this.renderOptions.renderLayers&&(d=d.slice(-Math.min(d.length,this.renderOptions.renderLayers))),this.renderOptions.renderSmallestFallback&&d.indexOf(u)===-1&&d.unshift(u);let l=[];for(let c=0;c<d.length;c++)l.push(...this.images[d[c]].getAllPointsAt(t,h,n));return l}return this.images[s].getAllPointsAt(t,h,n)}};import{compose as ri,DnaFactory as Yt,dnaLength as Rn,hidePointsOutsideRegion as si,mutate as oi,scale as Tn,scaleAtOrigin as _n,translate as ai,dna as ut}from"@atlas-viewer/dna";import{dna as z,compose as Te,getIntersection as Cn,scale as ii,transform as _e,translate as Zt,hidePointsOutsideRegion as ni}from"@atlas-viewer/dna";function Xt(r,e,t,i,n){let s=Math.PI/180*n,a=Math.cos(s),h=Math.sin(s),d=a*(t-r)+h*(i-e)+r,u=a*(i-e)-h*(t-r)+e;return[d,u]}var J=class r extends k{constructor(t,i){super();o(this,"id");o(this,"type","world-object");o(this,"scale");o(this,"layers");o(this,"points");o(this,"worldPoints");o(this,"intersectionBuffer",z(5));o(this,"aggregateBuffer",z(9));o(this,"invertedBuffer",z(9));o(this,"rotation",0);o(this,"filteredPointsBuffer");o(this,"_updatedList",[]);o(this,"geometry");let{x:n=0,y:s=0}=i||{};t?(this.id=t.id||"",this.scale=1,this.layers=t.layers,this.points=z([1,n,s,n+t.width,s+t.height]),this.worldPoints=z([1,n,s,n+t.width,s+t.height]),this.filteredPointsBuffer=z(t.layers.length*5)):(this.id="",this.scale=1,this.layers=[],this.points=z(5),this.worldPoints=z(5),this.filteredPointsBuffer=z(5))}static createWithProps(t){let i=new r;return i.applyProps(t),i}applyProps(t){let i=t.x||0,n=t.y||0;this.id=t.id;let s=typeof t.scale<"u"?t.scale:this.scale;this.points[0]=1,this.points[1]=i,this.points[2]=n,this.points[3]=i+t.width,this.points[4]=n+t.height,this.rotation=t.rotation||0,this.worldPoints[3]=this.worldPoints[1]+t.width,this.worldPoints[4]=this.worldPoints[2]+t.height,t.scale&&t.scale!==1&&this.atScale(s),this.scale=s}appendChild(t){t.points[0]===0&&t.points.set(this.points),t.__owner.value=this,this.addLayers([t])}removeChild(t){this.layers=this.layers.filter(i=>i!==t),this.filteredPointsBuffer=z(this.layers.length*5)}insertBefore(t,i){let n=this.layers.indexOf(i);if(n===-1||this.layers.indexOf(t)!==-1)return;let s=this.layers.slice(0,n),a=this.layers.slice(n);this.layers=[...s,t,...a]}hideInstance(){console.warn("hideInstance: not yet implemented")}getObjectsAt(t,i){if(this.rotation&&(t=this.applyRotation(t)),ni(this.points,t,this.filteredPointsBuffer)[0]===0)return[];let s=this.layers.length,a=[];for(let h=0;h<s;h++){let d=this.layers[h];if(i&&d.isShape){let l=_e(d.points,Zt(this.x,this.y));if(!d.intersects([t[1]-l[1],t[2]-l[2]]))continue}if(ni(_e(d.points,Zt(this.x,this.y)),t,this.filteredPointsBuffer)[0]!==0&&a.push(d),i){let l=d;a.push(...l.getObjectsAt(t,i))}}return a}applyRotation(t){if(this.rotation){let i={x:t[1],y:t[2]},n={x:t[1],y:t[4]},s={x:t[3],y:t[2]},a={x:t[3],y:t[4]},h=this.points[1]+(this.points[3]-this.points[1])/2,d=this.points[2]+(this.points[4]-this.points[2])/2,[u,l]=Xt(h,d,i.x,i.y,this.rotation),[c,m]=Xt(h,d,n.x,n.y,this.rotation),[y,v]=Xt(h,d,s.x,s.y,this.rotation),[x,P]=Xt(h,d,a.x,a.y,this.rotation),g=Math.min(u,c,y,x),f=Math.max(u,c,y,x),C=Math.min(l,m,v,P),_=Math.max(l,m,v,P);return z([t[0],g,C,f,_])}return t}getAllPointsAt(t,i,n){let s=Te(Zt(this.x,this.y),ii(this.scale),this.aggregateBuffer);this.rotation&&(t=this.applyRotation(t));let a=Cn(t,this.points,this.intersectionBuffer),h=this.layers.length,d=[],u=_e(a,Te(ii(1/this.scale),Zt(-this.x,-this.y),this.invertedBuffer)),l=i?Te(i,s,this.aggregateBuffer):s,c=n*this.scale;for(let m=0;m<h;m++)d.push(...this.layers[m].getAllPointsAt(u,l,c));return d}addLayers(t){let i=[];for(let n of t)this.layers.indexOf(n)===-1&&(i.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||z([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(i),this.filteredPointsBuffer=z(this.layers.length*5)}getScheduledUpdates(t,i){let n=this.layers.length;this._updatedList=[];let s=i*this.scale;for(let a=0;a<n;a++){let h=this.layers[a].getScheduledUpdates(t,s);h&&this._updatedList.push(...h)}return this._updatedList}};var V=class r extends k{constructor(t=0,i=0,n=100,s="left-to-right"){super();o(this,"id","world");o(this,"_width");o(this,"_height");o(this,"aspectRatio");o(this,"viewingDirection");o(this,"aggregateBuffer",ut(9));o(this,"isDirty",!1);o(this,"zones",[]);o(this,"filteredPointsBuffer");o(this,"selectedZone");o(this,"triggerQueue",[]);o(this,"activatedEvents",[]);o(this,"_updatedList",[]);o(this,"translationBuffer",ut(9));o(this,"needsRecalculate",!0);o(this,"emptyPaintables",[]);o(this,"renderOrder",[]);o(this,"points");o(this,"objects",[]);o(this,"subscriptions",[]);o(this,"_propagateEventTargets",[]);o(this,"_alreadyFlushed",[]);this._width=t,this._height=i,this.aspectRatio=Number.isNaN(t/i)?1:t/i,this.viewingDirection=s,this.points=ut(n*5),this.filteredPointsBuffer=ut(n*5)}get x(){return 0}get y(){return 0}get width(){return this._width}get height(){return this._height}static withProps(t){let i=new r;return i.applyProps(t),i}applyProps(t){typeof t.width<"u"&&typeof t.height<"u"&&(t.width!==this._width||t.height!==this._height)&&this.resize(t.width,t.height),t.viewingDirection!==this.viewingDirection&&(this.viewingDirection=t.viewingDirection,this.triggerRepaint())}propagateTouchEvent(t,i,n){let s=[];for(let a of n)if(a.x&&a.y){let h=Yt.singleBox(1,1,a.x,a.y);s.push(this.getObjectsAt(h,!0).reverse())}return s.map(a=>this.propagateEvent(t,i,a,{bubbles:!0,cancelable:!0}))}propagatePointerEvent(t,i,n,s,a={}){let h=Yt.singleBox(1,1,n,s),d=this.getObjectsAt(h,!0).reverse();return this.propagateEvent(t,i,d,a)}propagateEvent(t,i,n,{bubbles:s=!1,cancelable:a=!1}={}){i.atlasTarget=this,this._propagateEventTargets.length=1,this._propagateEventTargets[0]=this;let h=!1;i.stopPropagation=()=>{h=!0};let d=n.length;for(let c=d-1;c>=0;c--){this._propagateEventTargets.unshift(n[c][0]);let m=n[c][1].length;if(m)for(let y=0;y<m;y++)this._propagateEventTargets.unshift(n[c][1][y])}let u=this._propagateEventTargets.length,l=!1;for(let c=0;c<u&&(i.atlasTarget=this._propagateEventTargets[c],i.atlasWorld=this,l=this._propagateEventTargets[c].dispatchEvent(t,i)||l,!h);c++);return l&&this.triggerRepaint(),this._propagateEventTargets}appendChild(t){let i=this.appendWorldObject(t);this.renderOrder.push(i/5)}removeChild(t){let i=this.objects.indexOf(t);if(i===-1){for(let n of this.objects)if(n&&n.id===t.id){this.removeChild(n);return}return}this.objects[i]=null,this.renderOrder=this.renderOrder.filter(n=>n!==i),this.points[i*5]=0,this.triggerRepaint(),this.needsRecalculate=!0}insertBefore(t,i){let n=this.objects.indexOf(i);if(n===-1)return;let s=this.appendWorldObject(t);this.renderOrder.splice(n-1,0,s/5)}hideInstance(){}asWorldObject(){return null}addZone(t){this.zones.push(t)}selectZone(t){if(typeof t=="string"){let i=this.zones.length;for(let n=0;n<i;n++)if(this.zones[n].id===t){this.selectedZone=n,this.trigger("zone-changed");return}}else this.zones[t]&&(this.selectedZone=t,this.trigger("zone-changed"))}deselectZone(){this.selectedZone=void 0}getActiveZone(){if(this.selectedZone)return this.zones[this.selectedZone]}hasActiveZone(){return typeof this.selectedZone<"u"}checkResizeInternalBuffer(){if(Rn(this.points)===this.objects.length){let t=this.points,i=ut(this.points.length*2);i.set(t,0),this.points=i}}appendWorldObject(t){this.checkResizeInternalBuffer();let i=this.objects.length*5,n=t.points;return t.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),t.points[1]=n[1],t.points[2]=n[2],t.points[3]=n[3],t.points[4]=n[4],this.objects.push(t),this.filteredPointsBuffer=ut(this.objects.length*5),this.needsRecalculate=!0,this.triggerRepaint(),i}recalculateWorldSize(){let t=!1;if(this.needsRecalculate){let i=new Int32Array(this.objects.length),n=new Int32Array(this.objects.length),s=this.renderOrder.length;for(let d=0;d<s;d++){let u=this.renderOrder[d];this.objects[u]&&(i[d]=this.points[u*5+3],n[d]=this.points[u*5+4])}let a=Math.max(...i);a!==this._width&&(this._width=a,t=!0);let h=Math.max(...n);h!==this._height&&(this._height=h,t=!0),t&&this.trigger("recalculate-world-size",{width:a,height:h}),this.needsRecalculate=!1}return t}addObjectAt(t,i){i.width&&!i.height?i.height=i.width/t.width*t.height:i.height&&!i.width&&(i.width=i.height/t.height*t.width),(!i||!i.width||!i.height)&&(i.width=t.width,i.height=t.height);let{width:n,x:s,y:a}=i,h=n/t.width;this.checkResizeInternalBuffer(),this.points.set(Yt.singleBox(t.width,t.height,0,0),this.objects.length*5);let d=new J(t);return d.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),this.objects.push(d),this.scaleWorldObject(this.objects.length-1,h),this.translateWorldObject(this.objects.length-1,s,a),this.filteredPointsBuffer=ut(this.points.length*2),this.triggerRepaint(),this.needsRecalculate=!0,d}scaleWorldObject(t,i){oi(this.points.subarray(t*5,t*5+5),_n(i,this.points[t*5+1],this.points[t*5+2]));let n=this.objects[t];n&&(n.atScale(i),this.triggerRepaint())}translateWorldObject(t,i,n){oi(this.points.subarray(t*5,t*5+5),ai(i,n));let s=this.objects[t];s&&(s.translate(i,n),this.triggerRepaint())}resize(t,i){return this._width=t,this._height=i,this.aspectRatio=t/i,this.triggerRepaint(),this}getObjects(){return this.objects}getPoints(){return this.points}getPointsFromViewer(t,i){let n=Yt.singleBox(t.width,t.height,t.x,t.y);return this.getPointsAt(n,i,t.scale)}addLayoutSubscriber(t){return this.subscriptions.push(t),()=>{this.subscriptions.splice(this.subscriptions.indexOf(t),1)}}getScheduledUpdates(t,i){let n=si(this.points,t,this.filteredPointsBuffer),s=this.objects.length;this._updatedList=[];for(let a=0;a<s;a++)if(n[a*5]!==0){if(!this.objects[a])continue;this._updatedList.push(...this.objects[a].getScheduledUpdates(t,i))}return this._updatedList}getObjectsAt(t,i=!1){let n=this.getActiveZone(),s=si(this.points,t,this.filteredPointsBuffer),a=this.renderOrder.length,h=[];for(let d=0;d<a;d++){let u=this.renderOrder[d];if(s[u*5]!==0){let l=this.objects[u];if(!l||n&&n.objects.indexOf(l)===-1)continue;if(l.type!=="world-object"){h.push([l,[l]]);continue}i?h.push([l,l.getObjectsAt(t,i)]):h.push([l,this.emptyPaintables])}}return h}getPointsAt(t,i,n=1){let s=this.getObjectsAt(t),a=ri(Tn(n),ai(-t[1],-t[2]),this.translationBuffer),h=i?ri(i,a,this.aggregateBuffer):a,d=s.length,u=[];for(let l=0;l<d;l++)s[l]&&u.push(...s[l][0].getAllPointsAt(t,h,n));return u}flushSubscriptions(){if(this.triggerQueue.length){this._alreadyFlushed=[];let t=this.triggerQueue.length;for(let i=0;i<t;i++){if(this._alreadyFlushed.indexOf(this.triggerQueue[i][0])!==-1)continue;typeof this.triggerQueue[i][1]>"u"&&this._alreadyFlushed.push(this.triggerQueue[i][0]);let n=this.subscriptions.length;for(let s=0;s<n;s++)this.subscriptions[s].apply(null,this.triggerQueue[i])}this.triggerQueue=[]}}trigger(t,i){this.triggerQueue.push([t,i])}triggerEventActivation(){this.trigger("event-activation")}triggerRepaint(){this.trigger("repaint")}gotoRegion(t){this.trigger("goto-region",t)}goHome(t=!1){this.trigger("go-home",{immediate:t})}zoomTo(t,i,n){this.trigger("zoom-to",{point:i,factor:t,stream:n})}zoomIn(t){this.trigger("zoom-to",{point:t,factor:.5})}zoomOut(t){this.trigger("zoom-to",{point:t,factor:2})}constraintBounds(t){this.trigger("constrain-bounds",{immediate:t})}};function qs(r){let{src:e,target:t}=r,i=t?t.width:r.width,n=t?t.height:r.height;return new J({id:e,height:n,width:i,layers:[D.fromImage(e,{height:n,width:i},{width:r.width,height:r.height})]})}import{dna as On}from"@atlas-viewer/dna";var An={margin:0},hi=class{constructor(e,t={}){o(this,"id");o(this,"config");o(this,"points");o(this,"objects");this.id=e.map(i=>i.id).join("$$"),this.config={...An,...t},this.points=On(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,i){return[]}};import{dna as li,DnaFactory as di}from"@atlas-viewer/dna";var Qt=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,Kt={},Mn=["backgroundColor","opacity","boxShadow","borderColor","borderWidth","borderStyle","outlineColor","outlineWidth","outlineOffset","outlineStyle"],K=class extends k{constructor(){super();o(this,"id");o(this,"type","spacial-content");o(this,"points");o(this,"hoverEvents",!1);o(this,"activeEvents",!1);o(this,"display",{x:0,y:0,scale:1,width:-1,height:-1,points:li(5)});o(this,"_parsed",{border:{id:null,match:[]},outline:{id:null,match:[]}});o(this,"hovering");o(this,"pressing");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=Q(12),this.points=li(5)}getAllPointsAt(t,i){return[[this,this.points,i]]}applyProps(t={}){let i=!1;if(t.interactive!==this.props.interactive&&(i=!0,this.props.interactive=t.interactive),t.style){let n=t.border||t.style.border;if(n!==this._parsed.border.id)if(!n)this._parsed.border.id=null,this._parsed.border.match=[];else{let s=Kt[n]||Qt.exec(n)||Qt.exec(n);s&&(this._parsed.border.id=n,this._parsed.border.match=Kt[n]=s)}if(this._parsed.border.id&&(t.style.borderWidth=this._parsed.border.match[1],t.style.borderStyle="solid",t.style.borderColor=this._parsed.border.match[4]),t.style.outline!==this._parsed.outline.id)if(!t.style.outline)this._parsed.outline.id=null,this._parsed.outline.match=[];else{let s=Kt[t.style.outline]||Qt.exec(t.style.outline)||Qt.exec(t.style.outline);s&&(this._parsed.outline.id=t.style.outline,this._parsed.outline.match=Kt[t.style.outline]=s)}this._parsed.outline.id&&(t.style.outlineWidth=this._parsed.outline.match[1],t.style.outlineStyle="solid",t.style.outlineColor=this._parsed.outline.match[4]),this.props.style=t.style,t.backgroundColor&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=t.backgroundColor,i=!0),t.style.background&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=t.style.background,i=!0);for(let s of Mn)if(this.props.style[s]!==t.style[s]){i=!0;break}t.style[":hover"]!==this.props.hoverStyles&&(this.props.hoverStyles=t.style[":hover"],this.hoverEvents||(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),i=!0),t.style[":active"]!==this.props.pressStyles&&(this.props.pressStyles=t.style[":active"],this.activeEvents||(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),i=!0)}t.href!==this.props.href&&(this.props.href=t.href,i=!0),t.hrefTarget!==this.props.hrefTarget&&(this.props.hrefTarget=t.hrefTarget,i=!0),t.title!==this.props.title&&(this.props.title=t.title,i=!0),t.className!==this.props.className&&(this.props.className=t.className,t.className&&!this.hoverEvents&&(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),t.className&&!this.activeEvents&&(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),i=!0),t.relativeSize!==this.props.relativeSize&&(this.props.relativeSize=t.relativeSize,i=!0),t.relativeStyle!==this.props.relativeStyle&&(this.props.relativeStyle=t.relativeStyle,i=!0),t.html!==this.props.html&&(this.props.html=t.html,i=!0),t.target&&(t.target.width!==this.display.width||t.target.height!==this.display.height||t.target.x!==this.points[1]||t.target.y!==this.points[2])&&(i=!0,this.points=di.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.points=di.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.width=t.target.width,this.display.height=t.target.height),i&&this.__revision++}};import{dna as ci,DnaFactory as In}from"@atlas-viewer/dna";var ot=class extends k{constructor(){super();o(this,"type","spacial-content");o(this,"id");o(this,"points");o(this,"color","#000");o(this,"backgroundColor");o(this,"hovering");o(this,"pressing");o(this,"text","");o(this,"display",{x:0,y:0,scale:1,width:100,height:100,points:ci(5)});o(this,"className");o(this,"html");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=ci(5)}getAllPointsAt(t,i){return[[this,this.points,i]]}applyProps({id:t,target:i,text:n,color:s,backgroundColor:a,fontSize:h=18,interactive:d,fontFamily:u="Arial, sans-serif",...l}){l.font=`${h}px ${u}`,this.interactive=d||!1,typeof n<"u"&&(this.text=n||""),s&&(this.color=s),a&&(this.backgroundColor=a),t&&(this.id=t),i&&(this.points=In.singleBox(i.width,i.height,i.x,i.y),this.display.points=this.points,this.display.width=i.width,this.display.height=i.height),this.props={...this.props,...l},this.__revision++}};import{DnaFactory as wt,mutate as pi,scale as yi,scaleAtOrigin as bi,transform as Oe,dna as ne,translate as kn,compose as Fn}from"@atlas-viewer/dna";import{dna as Lt,DnaFactory as Ln}from"@atlas-viewer/dna";var L=Math.pow,qt=Math.sqrt,Mt=Math.sin,ui=Math.cos,It=Math.PI,ee=1.70158,Jt=ee*1.525,mi=ee+1,gi=2*It/3,fi=2*It/4.5,te=function(r){return r<1/2.75?7.5625*r*r:r<2/2.75?7.5625*(r-=1.5/2.75)*r+.75:r<2.5/2.75?7.5625*(r-=2.25/2.75)*r+.9375:7.5625*(r-=2.625/2.75)*r+.984375},q={linear:r=>r,easeInQuad:function(r){return r*r},easeOutQuad:function(r){return 1-(1-r)*(1-r)},easeInOutQuad:function(r){return r<.5?2*r*r:1-L(-2*r+2,2)/2},easeInCubic:function(r){return r*r*r},easeOutCubic:function(r){return 1-L(1-r,3)},easeInOutCubic:function(r){return r<.5?4*r*r*r:1-L(-2*r+2,3)/2},easeInQuart:function(r){return r*r*r*r},easeOutQuart:function(r){return 1-L(1-r,4)},easeInOutQuart:function(r){return r<.5?8*r*r*r*r:1-L(-2*r+2,4)/2},easeInQuint:function(r){return r*r*r*r*r},easeOutQuint:function(r){return 1-L(1-r,5)},easeInOutQuint:function(r){return r<.5?16*r*r*r*r*r:1-L(-2*r+2,5)/2},easeInSine:function(r){return 1-ui(r*It/2)},easeOutSine:function(r){return Mt(r*It/2)},easeInOutSine:function(r){return-(ui(It*r)-1)/2},easeInExpo:function(r){return r===0?0:L(2,10*r-10)},easeOutExpo:function(r){return r===1?1:1-L(2,-10*r)},easeInOutExpo:function(r){return r===0?0:r===1?1:r<.5?L(2,20*r-10)/2:(2-L(2,-20*r+10))/2},easeInCirc:function(r){return 1-qt(1-L(r,2))},easeOutCirc:function(r){return qt(1-L(r-1,2))},easeInOutCirc:function(r){return r<.5?(1-qt(1-L(2*r,2)))/2:(qt(1-L(-2*r+2,2))+1)/2},easeInBack:function(r){return mi*r*r*r-ee*r*r},easeOutBack:function(r){return 1+mi*L(r-1,3)+ee*L(r-1,2)},easeInOutBack:function(r){return r<.5?L(2*r,2)*((Jt+1)*2*r-Jt)/2:(L(2*r-2,2)*((Jt+1)*(r*2-2)+Jt)+2)/2},easeInElastic:function(r){return r===0?0:r===1?1:-L(2,10*r-10)*Mt((r*10-10.75)*gi)},easeOutElastic:function(r){return r===0?0:r===1?1:L(2,-10*r)*Mt((r*10-.75)*gi)+1},easeInOutElastic:function(r){return r===0?0:r===1?1:r<.5?-(L(2,20*r-10)*Mt((20*r-11.125)*fi))/2:L(2,-20*r+10)*Mt((20*r-11.125)*fi)/2+1},easeInBounce:function(r){return 1-te(1-r)},easeOutBounce:te,easeInOutBounce:function(r){return r<.5?(1-te(1-2*r))/2:(1+te(2*r-1))/2}};var ie=class{constructor(e){o(this,"runtime");o(this,"pendingTransition");o(this,"lastZoomTo",null);o(this,"isConstraining",!1);o(this,"lastGoToRegion",null);this.runtime=e,this.pendingTransition={from:Lt(5),to:Lt(5),elapsed_time:0,done:!0,total_time:0,timingFunction:q.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=Lt(this.runtime.target),this.pendingTransition.to=Lt(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 i=this.pendingTransition,n=i.total_time===0?0:(i.elapsed_time+t)/i.total_time,s=i.total_time===0?1:n===0?0:i.timingFunction(n);e[1]=i.from[1]+(i.to[1]-i.from[1])*s,e[2]=i.from[2]+(i.to[2]-i.from[2])*s,e[3]=i.from[3]+(i.to[3]-i.from[3])*s,e[4]=i.from[4]+(i.to[4]-i.from[4])*s,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:q.easeOutExpo}}))}}resumeTransition(){console.log("resume",{lastZoom:this.lastZoomTo,isConstraining:this.isConstraining,lastGoToRegion:this.lastGoToRegion}),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:i,stream:n=!1,transition:s}=t;this.lastZoomTo={factor:e,options:t};let a=this.runtime.getZoomedPosition(e,{origin:i}),h=Math.abs(1-e);this.applyTransition(a,s,{duration:2e3*h,easing:q.easeOutExpo,constrain:!0,callback:()=>{this.lastZoomTo=null}},{stream:!1})}constrainBounds({transition:e,panPadding:t=0}={}){this.isConstraining=!0;let[i,n]=this.runtime.constrainBounds(this.runtime.target,{panPadding:t});i&&(this.applyTransition(n,e,{duration:500,easing:q.easeOutQuart,constrain:!1,callback:()=>{this.isConstraining=!1}}),this.runtime.updateNextFrame())}applyTransition(e,t,i,{stream:n}={}){this.pendingTransition.from=Lt(this.runtime.target),this.pendingTransition.to=e,n||(this.pendingTransition.elapsed_time=0),this.pendingTransition.done=!1,this.pendingTransition.total_time=typeof t?.duration<"u"?t.duration:typeof i?.duration<"u"?i.duration:1e3,this.pendingTransition.constrain=typeof t?.constrain<"u"?t.constrain:typeof i?.constrain<"u"?i.constrain:!1,this.pendingTransition.timingFunction=t?.easing||i?.easing||q.easeInOutSine}goToRegion(e,{transition:t}={}){this.lastGoToRegion={target:e,options:{transition:t}};let i=this.runtime.clampRegion(e);this.applyTransition(Ln.singleBox(i.width,i.height,i.x,i.y),t,{duration:1e3,easing:q.easeOutExpo,constrain:!0,callback:()=>{this.lastGoToRegion=null}}),this.runtime.updateNextFrame()}};var To=Number.MIN_VALUE+1,tt=class{constructor(e,t,i,n=[],s){o(this,"id",Q());o(this,"ready",!1);o(this,"renderer");o(this,"world");o(this,"target");o(this,"homePosition");o(this,"manualHomePosition");o(this,"manualFocalPosition");o(this,"focalPosition");o(this,"transitionManager");o(this,"aggregate");o(this,"transformBuffer",ne(500));o(this,"lastTarget",ne(5));o(this,"zoomBuffer",ne(5));o(this,"logNextRender",!1);o(this,"pendingUpdate",!0);o(this,"isCommitting",!1);o(this,"firstRender",!0);o(this,"lastTime");o(this,"stopId");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");o(this,"options");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(typeof e.x>"u"?this.target[1]:e.x),i=Math.round(typeof e.y>"u"?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]=i+e.height:this.target[4]=this.target[4]-this.target[2]+i,Math.abs(this.target[1]-t)>.01&&(this.target[1]=t),Math.abs(this.target[2]-i)>.01&&(this.target[2]=i),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 i=this.pendingUpdate,n=this.renderer.pendingUpdate();if(this.transitionManager.hasPending()&&(this.transitionManager.runTransition(this.target,t),this.pendingUpdate=!0,this.updateControllerPosition()),!this.firstRender&&!i&&!n&&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 s=this.getScaleFactor(),a=this.renderer.getPointsAt(this.world,this.target,this.aggregate,s),h=a.length;for(let l=0;l<h;l++){let c=a[l][0],m=a[l][1],y=a[l][2],v=y?Oe(m,y,this.transformBuffer):m;this.renderer.prepareLayer(c,c.__parent&&y?Oe(c.__parent.crop||c.__parent.points,y):v);let x=v.length/5;for(let P=0;P<x;P++){let g=P*5;v[g]!==0&&(this.renderer.paint(c,P,v[g+1],v[g+2],v[g+3]-v[g+1],v[g+4]-v[g+2]),this.hook("useAfterPaint",c))}this.renderer.finishLayer(c,m)}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 d=this.world.getScheduledUpdates(this.target,s),u=d.length;if(u>0)for(let l=0;l<u;l++){let c=d[u-l-1]();c?c.then(()=>{this.pendingUpdate=!0}):this.pendingUpdate=!0}});this.renderer=e,this.world=t,this.options={maxOverZoom:1,maxUnderZoom:1,visibilityRatio:1.5,...s||{}},this.target=wt.projection(i),this.manualHomePosition=!1,this.pendingUpdate=!0,this.homePosition=wt.projection(this.world),this.manualFocalPosition=!1,this.focalPosition=this.target,this.updateFocalPosition(),this.transitionManager=new ie(this),this.aggregate=yi(1),this.world.addLayoutSubscriber(a=>{a==="repaint"&&(this.pendingUpdate=!0),a==="recalculate-world-size"&&(this.manualHomePosition||(this.setHomePosition(),this.goHome()),this.updateFocalPosition())}),this.lastTime=performance.now(),this.controllers=n,this.render(this.lastTime),this.startControllers()}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}setHomePosition(e){this.homePosition.set(wt.projection(e||this.world)),this.pendingUpdate=!0}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}}goHome(e={}){if(this.world.width<=0||this.world.height<=0)return;let t=this.getScaleFactor(),i=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]},n=this.width*t,s=this.height*t,a=i.width/n,h=i.height/s,d=n/s;if(e.cover?a>h:a<h){let u=d*i.height,l=(u-i.width)/2;this.target[1]=Math.round(-l+i.x),this.target[2]=Math.round(i.y),this.target[3]=Math.round(u-l+i.x),this.target[4]=Math.round(i.height+i.y)}else{let u=i.width/d,l=(u-i.height)/2;this.target[1]=Math.round(i.x),this.target[2]=Math.round(i.y-l),this.target[3]=Math.round(i.x+i.width),this.target[4]=Math.round(i.y+u-l)}this.constrainBounds(this.target),this.updateControllerPosition()}resize(e,t,i,n){this.transitionManager.hasPending()&&this.transitionManager.stopTransition(),this.updateFocalPosition(e-t,i-n);let s=t/e,a=n/i;this.target[3]=this.target[1]+(this.target[3]-this.target[1])*s,this.target[4]=this.target[2]+(this.target[4]-this.target[2])*a,this.goHome({position:this.focalPosition}),this.renderer.resize(t,n),this.pendingUpdate=!0,this.transitionManager.resumeTransition()}updateFocalPosition(e,t){if(!this.manualFocalPosition){let i=this.width,n=this.height,s=Math.min(i,n),a=0,h=0,d=this.x+a,u=this.y+h;if(i<n){let l=this.height-this.width;this.focalPosition=wt.projection({x:d,y:u+l/2,width:s-a*2,height:s-h*2}),this.pendingUpdate=!0}else{let l=this.width-this.height;this.focalPosition=wt.projection({x:d+l/2,y:u,width:s-a*2,height:s-h*2}),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:i=!1}={}){let{minX:n,maxX:s,minY:a,maxY:h}=this.getBounds({target:e,padding:t}),d=!1,u=i?e:ne(e),l=Math.round(e[3]-e[1]),c=Math.round(e[4]-e[2]);return n>e[1]&&(d=!0,u[1]=n,u[3]=n+l),a>e[2]&&(d=!0,u[2]=a,u[4]=a+c),s<e[1]&&(d=!0,u[1]=s,u[3]=s+l),h<e[2]&&(d=!0,u[2]=h,u[4]=h+c),[d,u]}getBounds(e){let t=e.target||this.target,i=e.padding,n=this.options.visibilityRatio,s=Math.abs(1-n);if(this.world.hasActiveZone()){let f=this.world.getActiveZone();if(f){let C=t[3]-t[1]<f.points[3]-f.points[1],_=t[4]-t[2]<f.points[4]-f.points[2];return{minX:C?f.points[1]-i:f.points[1]+(f.points[3]-f.points[1])/2-(t[3]-t[1])/2,maxX:_?f.points[2]-i:f.points[2]+(f.points[4]-f.points[2])/2-(t[4]-t[2])/2,minY:C?f.points[3]+i:f.points[1]+(f.points[3]-f.points[1])/2-(t[3]-t[1])/2,maxY:_?f.points[4]+i:f.points[2]+(f.points[4]-f.points[2])/2-(t[4]-t[2])/2}}}let a=t[3]-t[1],h=this.world.width,d=-a*s,u=h-a-d,l=t[4]-t[2],c=this.world.height,m=-l*s,y=c-l-m,v=Math.round(Math.max(d,u)),x=Math.round(Math.min(d,u)),P=Math.round(Math.max(m,y)),g=Math.round(Math.min(m,y));return{minX:x,maxX:v,minY:g,maxY:P}}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:i}){let n=i?{width:i[3]-i[1],height:i[4]-i[2]}:void 0,s=n?this.renderer.getScale(n.width,n.height):this.getScaleFactor(),a=n?n.width:this.width,h=n?n.height:this.height,d=this.getRendererScreenPosition()?.width,u=this.world.width,l=d?d/u:1,c=this.options.maxUnderZoom,m=Math.max(l||1,this.options.maxOverZoom),y=1/e,v=s*y;if(y<1){let g=a*s,f=h*s,C=this.world.width/g,_=this.world.height/f;if(C>_){let S=this.world.width*v,O=~~(a*s)*c;S<O&&(e=this.world.width*s/(a*s*c))}else{let S=this.world.height*v,O=~~(h*s)*c;S<O&&(e=this.world.height*s/(h*s*c))}}else v>m&&(e=s/m);let P=Oe(this.target,bi(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(P,{ref:!0,panPadding:100}),P}clampRegion({x:e,y:t,width:i,height:n,padding:s=0}){let a=this.width,h=this.height,d=i/a<n/h,u=e-s,l=t-s,c=i+s*2,m=n+s*2;if(d){let v=m/h*a;return{x:u-(v-c)/2,y:l,width:v,height:m}}let y=c/a*h;return{x:u,y:l-(y-m)/2,width:c,height:y}}viewerToWorld(e,t){let i=this.getScaleFactor();return this._viewerToWorld.x=this.target[1]+e/i,this._viewerToWorld.y=this.target[2]+t/i,this._viewerToWorld}worldToViewer(e,t,i,n){let s=wt.singleBox(i,n,e,t);return pi(s,Fn(yi(this.getScaleFactor()),kn(-this.target[1],-this.target[2]))),{x:s[1],y:s[2],width:s[3]-s[1],height:s[4]-s[2],strand:s}}setScale(e,t){pi(this.target,bi(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 typeof this.stopId<"u"&&(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 i=this.hooks[e].length;if(i!==0)for(let n=0;n<i;n++)this.hooks[e][n](t)}registerHook(e,t){return this.hooks[e].push(t),()=>{this.hooks[e]=this.hooks[e].filter(i=>i!==t)}}updateNextFrame(){this.pendingUpdate=!0}};import{dna as vi,DnaFactory as wi}from"@atlas-viewer/dna";var re=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,se={},Dn=["backgroundColor","opacity","boxShadow","borderColor","borderWidth","borderStyle","outlineColor","outlineWidth","outlineOffset","outlineStyle"],xt=class extends k{constructor(){super();o(this,"id");o(this,"type","spacial-content");o(this,"isShape",!0);o(this,"points");o(this,"hoverEvents",!1);o(this,"activeEvents",!1);o(this,"display",{x:0,y:0,scale:1,width:-1,height:-1,points:vi(5)});o(this,"boundingBox",null);o(this,"_parsed",{border:{id:null,match:[]},outline:{id:null,match:[]}});o(this,"hovering");o(this,"pressing");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=Q(12),this.points=vi(5),this.shape={type:"none"}}updateBoundingBox(){if(this.shape.type==="none")return;let t=this.shape.points;if(this.shape.points.length>2){let i=Math.min(...t.map(h=>h[0])),n=Math.min(...t.map(h=>h[1])),s=Math.max(0,...t.map(h=>h[0])),a=Math.max(0,...t.map(h=>h[1]));this.boundingBox={x:i,y:n,width:s-i,height:a-n};return}this.boundingBox=null}intersects(t){if(!t||this.shape.type==="none")return!1;let[i,n]=t,s=this.shape.points,a=this.boundingBox;if(a||(this.updateBoundingBox(),a=this.boundingBox),!a||i<a.x||i>a.x+a.width||n<a.y||n>a.height+a.y)return!1;let h=!1;for(let d=0,u=s.length-1;d<s.length;u=d++)s[d][1]>n!=s[u][1]>n&&i<(s[u][0]-s[d][0])*(n-s[d][1])/(s[u][1]-s[d][1])+s[d][0]&&(h=!h);return h}getAllPointsAt(t,i){return t[3]-t[1]===1&&t[4]-t[2]===1?this.intersects([t[1],t[2]])?[[this,this.points,i]]:[]:[[this,this.points,i]]}applyProps(t={}){let i=!1;if(t.points)if(this.shape.type!=="polygon"||this.shape.points.length!==t.points.length)this.shape={type:"polygon",points:t.points,open:t.open},this.updateBoundingBox();else{let n=!1,s=t.points.length;for(let a=0;a<s;a++)if(t.points[a][0]!==this.shape.points[a][0]||t.points[a][1]!==this.shape.points[a][1]){n=!0;break}n&&(this.shape={type:"polygon",points:t.points,open:t.open},this.updateBoundingBox())}if(t.interactive!==this.props.interactive&&(i=!0,this.props.interactive=t.interactive),(t.open||t.open===!1)&&(i=!0,this.shape.open=t.open),t.style){let n=t.border||t.style.border;if(n!==this._parsed.border.id)if(!n)this._parsed.border.id=null,this._parsed.border.match=[];else{let s=se[n]||re.exec(n)||re.exec(n);s&&(this._parsed.border.id=n,this._parsed.border.match=se[n]=s)}if(this._parsed.border.id&&(t.style.borderWidth=this._parsed.border.match[1],t.style.borderStyle="solid",t.style.borderColor=this._parsed.border.match[4]),t.style.outline!==this._parsed.outline.id)if(!t.style.outline)this._parsed.outline.id=null,this._parsed.outline.match=[];else{let s=se[t.style.outline]||re.exec(t.style.outline)||re.exec(t.style.outline);s&&(this._parsed.outline.id=t.style.outline,this._parsed.outline.match=se[t.style.outline]=s)}this._parsed.outline.id&&(t.style.outlineWidth=this._parsed.outline.match[1],t.style.outlineStyle="solid",t.style.outlineColor=this._parsed.outline.match[4]),this.props.style=t.style,t.backgroundColor&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=t.backgroundColor,i=!0),t.style.background&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=t.style.background,i=!0);for(let s of Dn)if(this.props.style[s]!==t.style[s]){i=!0;break}t.style[":hover"]!==this.props.hoverStyles&&(this.props.hoverStyles=t.style[":hover"],this.hoverEvents||(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),i=!0),t.style[":active"]!==this.props.pressStyles&&(this.props.pressStyles=t.style[":active"],this.activeEvents||(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),i=!0)}t.href!==this.props.href&&(this.props.href=t.href,i=!0),t.hrefTarget!==this.props.hrefTarget&&(this.props.hrefTarget=t.hrefTarget,i=!0),t.title!==this.props.title&&(this.props.title=t.title,i=!0),t.className!==this.props.className&&(this.props.className=t.className,t.className&&!this.hoverEvents&&(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),t.className&&!this.activeEvents&&(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),i=!0),t.relativeSize!==this.props.relativeSize&&(this.props.relativeSize=t.relativeSize,i=!0),t.relativeStyle!==this.props.relativeStyle&&(this.props.relativeStyle=t.relativeStyle,i=!0),t.html!==this.props.html&&(this.props.html=t.html,i=!0),t.target&&(t.target.width!==this.display.width||t.target.height!==this.display.height||t.target.x!==this.points[1]||t.target.y!==this.points[2])&&(i=!0,this.points=wi.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.points=wi.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.width=t.target.width,this.display.height=t.target.height),i&&this.__revision++}};import Bn from"lru-cache";var xi=/(-?[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,Si={},Wn=typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes("firefox"),oe={};var ae=class{constructor(e,t){o(this,"canvas");o(this,"ctx");o(this,"options");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");o(this,"averageJobTime",64);o(this,"lastKnownScale",1);o(this,"visible",[]);o(this,"previousVisible",[]);o(this,"rendererPosition");o(this,"dpi");o(this,"drawCalls",[]);o(this,"lastPaintedObject");o(this,"hostCache");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 Bn({maxSize:1024*512*512,dispose:(i,n,s)=>{this.invalidated.push(n),i.width=0,i.height=0},sizeCalculation:(i,n)=>i.width*i.height}):{store:{},get(i){return this.store[i]},set(i,n){this.store[i]=n}}}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((t,i)=>t.network&&t.scale===i.scale?i.distance-t.distance:t.scale<i.scale?-1:1),this.loadingQueueOrdered=!0),this.previousVisible=this.visible,this.pendingDrawCall=!!this.drawCalls.length,this.pendingDrawCall)for(let t=0;t<this.drawCalls.length;t++){let i=this.drawCalls.shift();i&&i()}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,i){if(Number.isNaN(e)||Number.isNaN(t))return this.lastKnownScale;let n=this.getCanvasDims(),s=n.width/e,a=n.height/t,h=(s<a?a:s)*(i&&this.dpi||1);return Number.isNaN(h)||(this.lastKnownScale=h),this.lastKnownScale}beforeFrame(e,t,i,n){this.options.debug&&this.stats&&this.stats.begin(),this.frameIsRendering=!0,this.visible=[],this.options.beforeFrame&&this.options.beforeFrame(t);let s=this.getCanvasDims();if(this.ctx.globalAlpha=1,this.ctx.fillStyle=this.canvas.dataset.background??"rgb(0, 0, 0)",this.ctx.fillRect(0,0,s.width,s.height),n.enableFilters&&(n.filters.brightness||n.filters.contrast||n.filters.grayscale||n.filters.invert||n.filters.sepia||n.filters.saturate||n.filters.hueRotate||n.filters.blur)){let a="";n.filters.brightness&&(a+=`brightness(${~~(100+n.filters.brightness*100)}%) `),n.filters.contrast&&(a+=`contrast(${~~(100+n.filters.contrast*100)}%) `),n.filters.grayscale&&(a+=`grayscale(${~~(n.filters.grayscale*100)}%) `),n.filters.invert&&(a+=`invert(${~~(n.filters.invert*100)}%) `),n.filters.sepia&&(a+=`sepia(${~~(n.filters.sepia*100)}%) `),n.filters.saturate&&(a+=`saturate(${~~(100+n.filters.saturate*100)}%) `),n.filters.hueRotate&&(a+=`hue-rotate(${n.filters.hueRotate}deg) `),n.filters.blur&&(a+=`blur(${n.filters.blur}px) `),this.ctx.filter=a}else this.ctx.filter="none"}applyTransform(e,t,i,n,s){let a=e.__owner.value;if(a&&a.rotation){this.ctx.save();let h=t+n/2,d=i+s/2;this.ctx.translate(h,d),this.ctx.rotate(a.rotation*Math.PI/180),this.ctx.translate(-h,-d),this.lastPaintedObject=a}}clearTransform(){this.lastPaintedObject&&(this.lastPaintedObject.rotation&&this.ctx.restore(),this.lastPaintedObject=void 0)}paint(e,t,i,n,s,a){let h=this.ctx.globalAlpha;if(e instanceof D||e instanceof $){if(e.display.rotation){this.ctx.save();let l=i+s/2,c=n+a/2;e.crop&&(l-=e.crop[t*5+1],c-=e.crop[t*5+2]),this.ctx.translate(l,c),this.ctx.rotate(e.display.rotation*Math.PI/180),this.ctx.translate(-l,-c)}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 l=e.__host.canvas,c=this.getCanvasDims();if((l.indices.indexOf(t)===-1||this.invalidated.indexOf(l.canvases[t])!==-1)&&this.schedulePaintToCanvas(l,e,t,ct({x:i+s/2,y:n+s/2},{x:c.width/2,y:c.height/2})),!this.firstMeaningfulPaint)return;let m=this.hostCache.get(l.canvases[t]);if(m)if(e.crop&&e.cropData){if(e.crop[t*5]){let y=[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];y[0]+=e.cropData.x/e.display.scale,y[1]+=e.cropData.y/e.display.scale;let v=e.x*this.lastKnownScale,x=e.y*this.lastKnownScale,P=[i+v,n+x,s,a];P[0]+=v,P[1]+=x,this.ctx.drawImage(m,y[0],y[1],y[2],y[3],P[0],P[1],P[2]+1,P[3]+1)}}else Wn?this.ctx.drawImage(m,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],i,n,s+1,a+1):this.ctx.drawImage(m,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],i,n,s+Number.MIN_VALUE+.5,a+Number.MIN_VALUE+.5)}catch{}e.display.rotation&&this.ctx.restore()}let d=e instanceof K&&this.options.box,u=e instanceof xt&&this.options.polygon;if((d||u)&&!e.props.className&&!e.props.html&&!e.props.href){if(this.visible.push(e),e.props.style){let l=Object.assign({},e.props.style||{},e.hovering?e.props.hoverStyles:{},e.pressing?e.props.pressStyles:{}),c=e.props.relativeStyle?1:s/e.width;typeof l.opacity<"u"&&(this.ctx.globalAlpha=l.opacity);let m=0;typeof l.borderWidth<"u"&&(m=parseInt(l.borderWidth,10)*c);let y=0;typeof l.outlineWidth<"u"&&(y=parseInt(l.outlineWidth,10)*c);let v=0;if(typeof l.outlineOffset<"u"&&(v=parseInt(l.outlineOffset,10)*c),l.borderColor&&(this.ctx.strokeStyle=l.borderColor),l.boxShadow){let x=l.boxShadow.split(/,(?![^(]*\))/);for(let P of x){let g=Si[P]||xi.exec(P)||xi.exec(P);Si[P]=g,g&&(this.ctx.save(),this.ctx.shadowOffsetX=parseInt(g[1])*this.dpi*c,this.ctx.shadowOffsetY=parseInt(g[3])*this.dpi*c,this.ctx.shadowBlur=parseInt(g[5])*this.dpi*c,this.ctx.shadowColor=g[9],this.ctx.fillStyle="rgba(0,0,0,1)",this.ctx.fillRect(i+m,n+m,s,a),this.ctx.restore())}}if(this.ctx.fillStyle=l.backgroundColor||"transparent",this.ctx.lineWidth=m,u){let x=e.shape,P=x.points||[],g=P.length;this.ctx.beginPath();for(let f=0;f<g;f++)this.ctx.lineTo(i+P[f][0]*this.lastKnownScale,n+P[f][1]*this.lastKnownScale);x.open||this.ctx.closePath(),m&&this.ctx.stroke(),x.open||this.ctx.fill()}else m&&this.ctx.strokeRect(i+m/2,n+m/2,s+m,a+m),this.ctx.fillRect(i+m,n+m,s,a);y&&(l.outlineColor&&(this.ctx.strokeStyle=l.outlineColor),this.ctx.lineWidth=y,this.ctx.strokeRect(i-y/2-v,n-y/2-v,s+m*2+y+v*2,a+m*2+y+v*2))}this.ctx.globalAlpha=h}}loadImage(e,t,i,n=!1){if(oe[e]&&oe[e].naturalWidth>0){t(oe[e]);return}try{let s=!1;n||setTimeout(()=>{s||this.loadImage(e,t,i,!0)},3e3);let a=document.createElement("img");a.decoding="auto",a.onload=function(){s=!0,t(a),oe[e]=a,a.onload=null},this.options.crossOrigin&&(a.crossOrigin="anonymous"),a.src=e,a.complete&&a.onload({}),a.width}catch(s){console.log("image error",s),i(s)}}schedulePaintToCanvas(e,t,i,n){this.imagesPending++,e.indices.push(i);let s=`${t.id}--${t.display.scale}-${i}`,a=this.invalidated.indexOf(s);a!==-1&&this.invalidated.splice(a,1),e.canvases[i]=s,t.__host.canvas.loading=!0,this.loadingQueueOrdered=!1,this.loadingQueue.push({id:s,scale:t.display.scale,network:!0,distance:n,task:()=>new Promise(h=>{if(this.visible.indexOf(t)===-1){this.imagesPending--,e.indices.splice(e.indices.indexOf(i),1),h();return}let d=t.getImageUrl(i);this.loadImage(d,u=>{this.loadingQueue.push({id:s,scale:t.display.scale,distance:n,task:()=>new Promise(l=>{this.imageIdsLoaded.includes(s)||(this.imagesLoaded++,this.imageIdsLoaded.push(s)),e.loaded.push(i),e.loaded.length===e.indices.length&&(e.loading=!1);let c=t.display.points.slice(i*5,i*5+5),m=document.createElement("canvas"),y=m.getContext("2d");m.width=c[3]-c[1],m.height=c[4]-c[2],this.hostCache.set(e.canvases[i],m),this.drawCalls.push(()=>{y.drawImage(u,0,0,c[3]-c[1],c[4]-c[2]),l()})})}),h()},u=>{this.imagesPending--,e.indices.splice(e.indices.indexOf(i),1),h()})})})}afterPaintLayer(e,t){}prepareLayer(e,t){if(e.__owner.value)if(e.cropData){let i=this.lastKnownScale*(1/e.display.scale);this.applyTransform(e,t[1],t[2],t[3]-t[1],t[4]-t[2])}else this.applyTransform(e,t[1],t[2],t[3]-t[1],t[4]-t[2]);(!e.__host||!e.__host.canvas)&&(e instanceof D||e instanceof $)&&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,i,n){return e.getPointsAt(t,i,n)}getViewportBounds(e,t,i){let n=e.getActiveZone();if(n){let s=t[3]-t[1]<n.points[3]-n.points[1],a=t[4]-t[2]<n.points[4]-n.points[2];return{x1:s?n.points[1]-i:n.points[1]+(n.points[3]-n.points[1])/2-(t[3]-t[1])/2,y1:a?n.points[2]-i:n.points[2]+(n.points[4]-n.points[2])/2-(t[4]-t[2])/2,x2:s?n.points[3]+i:n.points[1]+(n.points[3]-n.points[1])/2-(t[3]-t[1])/2,y2:a?n.points[4]+i:n.points[2]+(n.points[4]-n.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=[]}};var St=class{constructor(e){o(this,"renderers",[]);o(this,"length");for(let t of e)t&&this.renderers.push(t);this.length=this.renderers.length}afterFrame(e,t,i,n){for(let s=0;s<this.length;s++)this.renderers[s].afterFrame(e,t,i,n)}afterPaintLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].afterPaintLayer(e,t)}beforeFrame(e,t,i,n){for(let s=0;s<this.length;s++)this.renderers[s].beforeFrame(e,t,i,n)}triggerResize(){for(let e=0;e<this.length;e++){let t=this.renderers[e];t.triggerResize&&t.triggerResize()}}getPointsAt(e,t,i,n){return this.renderers[0].getPointsAt(e,t,i,n)}getScale(e,t){return this.renderers[0].getScale(e,t)}getViewportBounds(e,t,i){return this.renderers[0].getViewportBounds(e,t,i)}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,i,n,s,a){for(let h=0;h<this.length;h++)this.renderers[h].paint(e,t,i,n,s,a)}pendingUpdate(){for(let e=0;e<this.length;e++)if(this.renderers[e].pendingUpdate())return!0;return!1}prepareLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].prepareLayer(e,t)}finishLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].finishLayer(e,t)}resize(e,t){for(let i=0;i<this.length;i++)this.renderers[i].resize(e,t)}reset(){for(let e=0;e<this.length;e++)this.renderers[e].reset()}};import{DnaFactory as Nn,scale as zn}from"@atlas-viewer/dna";var he=class{constructor(e){o(this,"canvas");o(this,"context");o(this,"heightRatio",1);o(this,"widthRatio",1);o(this,"target",new Float32Array(5));o(this,"initialWidth");o(this,"initialHeight");o(this,"bounds");o(this,"aggregate");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=zn(1)}isReady(){return!0}resize(){this.initialWidth=this.canvas.width,this.initialHeight=this.canvas.height,this.renderNextFrame=!0}afterFrame(e,t,i){if(this.renderNextFrame){this.context.clearRect(0,0,this.canvas.width,this.canvas.height);let n=this.initialWidth/e.width,s=this.initialHeight/e.height,a=this.widthRatio>this.heightRatio?n:s;if(this.target=i,this.bounds){let h=e.getPointsAt(this.bounds,this.aggregate,a);for(let[d,u]of h)if(d instanceof D&&d.__host.canvas){let l=u.length/5;for(let c=0;c<l;c++)if(d.__host.canvas.canvases[c]){let y={x1:u[c+1]*a,y1:u[c+2]*a,width:(u[c+3]-u[c+1])*a,height:(u[c+4]-u[c+2])*a}}}}e.getPoints().forEach((h,d,u)=>{if(d%5===0&&h){let l={x1:u[d+1]*a,y1:u[d+2]*a,x2:u[d+3]*a,y2:u[d+4]*a,width:(u[d+3]-u[d+1])*a,height:(u[d+4]-u[d+2])*a};this.context.strokeStyle="red",this.context.strokeRect(l.x1,l.y1,l.width,l.height)}}),i&&(this.context.strokeStyle="red",this.context.lineWidth=window.devicePixelRatio||1,this.context.strokeRect(i[1]*a,i[2]*a,(i[3]-i[1])*a,(i[4]-i[2])*a))}}getActiveZone(e){return null}getPointsAt(e,t,i,n){return e.getPointsAt(t,i,n)}getScale(e,t){return 1}beforeFrame(e,t){this.bounds=Nn.singleBox(e.width,e.height)}drawImage(){}afterPaintLayer(e,t){}paint(e,t,i,n,s,a){this.renderNextFrame=!0}prepareLayer(e){}pendingUpdate(){return!1}hasActiveZone(){return!1}getViewportBounds(e,t,i){return null}getRendererScreenPosition(){return this.canvas.getBoundingClientRect()}finishLayer(){}reset(){}};var Pi=class{constructor(){o(this,"autoWidth",!1);o(this,"autoHeight",!0);o(this,"width");o(this,"height");o(this,"world");o(this,"content",[]);o(this,"viewingDirection","left-to-right");o(this,"rows");o(this,"columns",4);o(this,"spacing",20);o(this,"reversed",!1);o(this,"padding",20);this.world=V.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(t=>this.world.addObjectAt(t,{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 new Error("Cannot set auto height without setting a width");if(this.autoWidth&&!this.height)throw new 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,t=()=>{if(this.autoWidth&&this.rows){let h=e>this.rows?this.rows:e;return{columns:Math.ceil(e/h),rows:h}}if(this.autoHeight&&this.columns){let h=e>this.columns?this.columns:e;return{columns:h,rows:Math.ceil(e/h)}}throw new Error("Something went wrong.")},{columns:i,rows:n}=t(),s=this.autoWidth?-1:this.width-this.padding*2,a=this.autoWidth?-1:(s-this.spacing*(i-1))/i;if(this.autoHeight&&!this.autoWidth){let h=0,d=this.padding;for(let u=0;u<n&&h!==e;u++){let l=0,c=[];for(let m=0;m<i;m++){let y=this.reversed?e-h:h;if(h===e)break;let v=this.content[y],x=v.width,P=v.width/v.height,g=a/P;c.push([h,a,g,a/x]),g>l&&(l=g),h++}for(let m=0;m<i&&c[m];m++){let y=this.world.getPoints(),v=c[m][0],x=c[m][1],P=c[m][2],g=c[m][3],f=this.padding+m*(this.spacing+x),C=d+(l-P)/2,_=this.reversed?e-v:v,S=y[_*5+1],b=y[_*5+2];this.world.scaleWorldObject(v,g),(S!==f||b!==C)&&this.world.translateWorldObject(_,f-S,C-b)}d+=l+this.spacing}this.height=d+this.padding,this.world.resize(this.width,this.height);return}this.autoWidth&&this.autoHeight,!this.autoWidth&&this.autoHeight}getWorld(){return this.world}};import Hn from"normalize-wheel";import{compose as jn,dna as Ae,scaleAtOrigin as Un,transform as Ci,translate as Ri}from"@atlas-viewer/dna";function Ei(r){return{x:r[1],y:r[2],width:r[3]-r[1],height:r[4]-r[2]}}var Ti="pan",_i="scroll",$n="gesture",Vn={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},le=(r={})=>({start:function(e){let{zoomWheelConstant:t,enableWheel:i,enableClickToZoom:n,ignoreSingleFingerTouch:s,enablePanOnWait:a,panOnWaitDelay:h,parentElement:d,requireMetaKeyForWheelZoom:u}={...Vn,...r},l={pointerStart:{x:0,y:0},isPressing:!1,mousemoveBuffer:Ae(5),multiTouch:{distance:0}};e.world.activatedEvents.push("onMouseUp","onMouseDown","onMouseMove","onTouchStart","onTouchEnd","onTouchMove");function c(){x=0,g="",C(),C(void 0,"notice"),P=0}function m(){e.world.constraintBounds(),c()}function y(w){if(w.which>1){l.isPressing=!1;return}e.mode==="explore"&&(w.preventDefault(),l.pointerStart.x=w.atlas.x,l.pointerStart.y=w.atlas.y,e.transitionManager.stopTransition(),l.isPressing=!0)}function v(){c(),l.isPressing&&(e.mode==="explore"&&e.world.constraintBounds(),l.isPressing=!1)}let x=0,P=0,g="";function f(w){if(e.mode==="explore"){if(w.atlasTouches.length===1&&(P=performance.now(),s==!1&&w.preventDefault(),l.pointerStart.x=w.atlasTouches[0].x,l.pointerStart.y=w.atlasTouches[0].y),w.atlasTouches.length===2){g=$n,w.preventDefault();let R=w.atlasTouches[0].x,A=w.atlasTouches[1].x;l.pointerStart.x=(R+A)/2;let ht=w.atlasTouches[0].y,M=w.atlasTouches[1].y;l.pointerStart.y=(ht+M)/2,x=ct({x:w.touches[0].clientX,y:w.touches[0].clientY},{x:w.touches[1].clientX,y:w.touches[1].clientY})}e.transitionManager.stopTransition(),l.isPressing=!0}}function C(w,R="intent"){d&&(d.dataset[R]=w)}function _(w){let R=null,A=null,ht=!1,M=0;if(l.isPressing&&w.touches.length===2){let X=w.touches[0].clientX,rt=w.touches[1].clientX;R=(X+rt)/2;let yt=w.touches[0].clientY,bt=w.touches[1].clientY;A=(yt+bt)/2,M=ct({x:w.touches[0].clientX,y:w.touches[0].clientY},{x:w.touches[1].clientX,y:w.touches[1].clientY}),ht=!0}if(C(g),l.isPressing&&w.touches.length===1){if(a&&(performance.now()-P<h&&g==""&&(g=_i),g==""&&(g=Ti)),C(g),g==""&&s==!0||g==_i){C("require-two-finger","notice");return}let X=w.touches[0];R=X.clientX,A=X.clientY}if(R!==null&&A!==null){let X=e.getRendererScreenPosition();if(X){let{x:rt,y:yt}=e.viewerToWorld(R-X.x,A-X.y),bt=M&&x?M/x:1;e.transitionManager.customTransition(p=>{p.from=Ae(e.target),p.to=Ci(p.from,jn(Ri(l.pointerStart.x-rt,l.pointerStart.y-yt),Un(1/bt,rt,yt)),l.mousemoveBuffer),p.elapsed_time=0,p.total_time=0,p.timingFunction=q.easeInOutExpo,p.done=!1})}x=M}g==Ti&&w.preventDefault()}function S(w){if(l.isPressing){let R=e.getRendererScreenPosition();if(R){let{x:A,y:ht}=e.viewerToWorld(w.clientX-R.x,w.clientY-R.y);e.transitionManager.customTransition(M=>{M.from=Ae(e.target),M.to=Ci(M.from,Ri(l.pointerStart.x-A,l.pointerStart.y-ht),l.mousemoveBuffer),M.elapsed_time=0,M.total_time=0,M.timingFunction=q.easeInOutExpo,M.done=!1})}}}function b(w){e.mode==="explore"&&e.world.zoomIn(w.atlas)}function O(w){let A=1+Hn(w).spinY/t;e.world.zoomTo(A,w.atlas,!0)}function W(w){return u&&w.metaKey==!1?(C("meta-required","notice"),w.stopPropagation(),!1):!0}e.world.addEventListener("mouseup",m),e.world.addEventListener("touchend",m),e.world.addEventListener("touchstart",f),e.world.addEventListener("mousedown",y),window.addEventListener("touchend",v),window.addEventListener("mouseup",v),window.addEventListener("mousemove",S),d&&d.addEventListener("touchmove",_),n&&(e.world.activatedEvents.push("onClick"),e.world.addEventListener("click",b)),i&&(e.world.activatedEvents.push("onWheel"),u&&d?.addEventListener("wheel",W,{passive:!0,capture:!0}),e.world.addEventListener("wheel",O));let N=e.world.addLayoutSubscriber((w,R)=>{if(w==="zone-changed"&&e.transitionManager.constrainBounds({transition:{duration:0}}),w==="zoom-to"&&R&&e.transitionManager.zoomTo(R.factor,{origin:R.point,stream:R.stream}),w==="go-home"){let A=R.immediate?{duration:0}:void 0;e.transitionManager.goToRegion(Ei(e.homePosition),{transition:A})}if(w==="goto-region"&&R){let A=R.immediate?{duration:0}:{};e.transitionManager.goToRegion(R,{transition:A})}w==="constrain-bounds"&&e.transitionManager.constrainBounds({transition:R?.immediate?{duration:0}:void 0})});return()=>{e.world.removeEventListener("mouseup",m),e.world.removeEventListener("touchend",m),e.world.removeEventListener("touchstart",f),e.world.removeEventListener("mousedown",y),window.removeEventListener("touchend",v),window.removeEventListener("mouseup",v),e.world.removeEventListener("mousemove",S),d&&(d.removeEventListener("touchmove",S),d.removeEventListener("wheel",W,{passive:!0,capture:!0})),n&&e.world.removeEventListener("click",b),i&&e.world.removeEventListener("wheel",O),N()}},updatePosition(){}});import{useCallback as ur,useEffect as G,useMemo as mr,useRef as ji,useState as Me}from"react";import Gn,{useContext as Zn}from"react";import{jsx as Xn}from"react/jsx-runtime";var et=Gn.createContext("explore");et.displayName="Mode";var de=()=>Zn(et);function ca(r){return Xn(et.Provider,{value:r.mode,children:r.children})}import gr from"react-use-measure";import Oi from"react";var it=Oi.createContext(null);it.displayName="Atlas";var mt=Oi.createContext(null);mt.displayName="Bounds";import Di,{useCallback as nr,useEffect as Bi,useRef as rr}from"react";import Qn from"react-reconciler";var kt,Yn=typeof performance=="object"&&typeof performance.now=="function";if(Yn){let r=performance;kt=()=>r.now()}else{let r=Date,e=r.now();kt=()=>r.now()-e}import{version as Kn}from"react";var qn=16;function Ai(r,e){r&&r.appendChild&&e&&r.appendChild(e)}function Ii(r,e){r&&r.removeChild&&e&&r.removeChild(e)}function Jn(r,e){return Ii(r.world,e)}function tr(r,e,t){return Li(r.world,e,t)}function Li(r,e,t){r&&r instanceof tt&&(r=r.world),r&&r.insertBefore&&r.insertBefore(e,t)}function ki(r,e,t){if(t&&(r.applyProps&&r.applyProps(t),r instanceof k))for(let i of At){let n=i.slice(2).toLowerCase();t[i]!==e[i]&&(e[i]&&r.removeEventListener(n,e[i]),r.addEventListener(n,t[i]))}}function Fi(r,e){let t=Object.keys(e),i=!1;for(let n of t)if(At.indexOf(n)!==-1){let s=Y[n];if(s){if(r.activatedEvents.indexOf(s)!==-1)continue;i=!0,r.activatedEvents.push(s)}}i&&r.triggerEventActivation()}var ce=new Map,Mi={};function er(r,{args:e=[],...t},i,n,s){if(!(i instanceof tt)&&s){let d=u=>u.return?d(u.return):u.stateNode&&u.stateNode.containerInfo;i=d(s)}let a,h=i.world;switch(r){case"world":a=V.withProps({width:t.width,height:t.height,viewingDirection:"left-to-right"}),a.activatedEvents=h.activatedEvents,a.eventHandlers=h.eventHandlers,a.subscriptions=h.subscriptions,a.triggerEventActivation(),h=a;break;case"box":a=new K;break;case"shape":a=new xt;break;case"worldObject":case"world-object":a=new J;break;case"worldImage":case"world-image":a=new D;break;case"texture":a=new dt;break;case"compositeImage":case"composite-image":a=new Gt({id:t.id,width:t.width,height:t.height,images:[],renderOptions:t.renderOptions});break;case"tiledImage":case"tiled-image":a=$.fromTile(t.uri,t.display,t.tile,t.scaleFactor,void 0,t.format);break;case"paragraph":a=new ot,a.text=t.children;break;default:return}return Fi(h,t),ki(a,{},t),a}function ir(r,e){if(e instanceof V)r.world=e;else if(e instanceof J)r.world.appendChild(e);else if(e)throw new Error("Invalid root")}var Ft=Qn({unstable_now:kt,now:kt,createInstance:er,removeChild:Ii,appendChild:Ai,appendInitialChild:Ai,insertBefore:Li,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:ir,removeChildFromContainer:Jn,createTextInstance(){},insertInContainerBefore:tr,prepareUpdate(r,e,t,i,n){return Fi(n.world,i),i},commitUpdate(r,e,t,i,n,s){r.applyProps&&e&&ki(r,i,e)},finalizeInitialChildren(r){return r?.__handlers},getChildHostContext(){return Mi},getRootHostContext(){return Mi},prepareForCommit(r){return r.isCommitting=!0,null},preparePortalMount(){},hideInstance(r){r&&r.points&&(r.points[0]=0)},unhideInstance(r,e){r&&r.points&&(r.points[0]=1)},getPublicInstance(r){return r},hideTextInstance(){throw new Error("Text is not allowed in the react-three-fibre tree. You may have extraneous whitespace between components.")},resetAfterCommit(r){r.isCommitting=!1,r.pendingUpdate=!0,r.world&&r.world.needsRecalculate&&(r.world.recalculateWorldSize(),r.world.triggerRepaint())},shouldSetTextContent(){return!1},clearContainer(){return!1},supportsHydration:!1,supportsPersistence:!1,detachDeletedInstance(r){},afterActiveInstanceBlur(){},beforeActiveInstanceBlur(){},getCurrentEventPriority(){return console.log("getCurrentEventPriority"),qn},getInstanceFromNode(r){throw console.log("getInstanceFromNode",r),new Error("Not implemented")},getInstanceFromScope(r){throw console.log("getInstanceFromScope",r),new Error("Not implemented")},prepareScopeUpdate(r,e){throw console.log("prepareScopeUpdate",r,e),new Error("Not implemented")},logRecoverableError(){},requestPostPaintCallback(){}});Ft.injectIntoDevTools({bundleType:0,version:Kn,rendererPackageName:"@atlas-viewer/atlas"});function Dt(r,e){let t=ce.get(r);t&&Ft.updateContainer(null,t,null,()=>{ce.delete(r),e&&e(r)})}var Bt={render(r,e){let t=ce.get(e);if(t)Ft.updateContainer(r,t,null);else{let i=Ft.createContainer(e,0,null,!1,null,"",()=>{},null);Ft.updateContainer(r,i,null),ce.set(e,i)}},unmountComponentAtNode(r,e){Dt(r,e)}};import*as ue from"react";var H=typeof window<"u"&&(window.document?.createElement||window.navigator?.product==="ReactNative")?ue.useLayoutEffect:ue.useEffect;import{jsx as Wt}from"react/jsx-runtime";var Wi=Di.memo(({children:r,setIsReady:e,onCreated:t,bounds:i,preset:n,mode:s="explore"})=>{let a=nr(function(d){let u=rr(!1),l=()=>{e(!0)};return Bi(()=>{if(n&&!u.current){n.runtime.goHome();let c=t&&t(n);return void(c&&c.then?c.then(l):l())}return()=>{}},[]),Bi(()=>{u.current=!0},[]),d.children},[n]);return H(()=>{if(n){let h=n.runtime;s!==h.mode&&(h.mode=s),Bt.render(Wt(Di.StrictMode,{children:Wt(a,{children:Wt(mt.Provider,{value:i,children:Wt(et.Provider,{value:s,children:Wt(it.Provider,{value:n,children:r})})})})}),h)}},[n,s,r]),H(()=>{if(n){let h=n.runtime;return()=>{Bt.unmountComponentAtNode(h)}}return()=>{}},[n]),null});var me=class{constructor(e,t){o(this,"canvas");o(this,"gl");o(this,"program");o(this,"fragmentShader");o(this,"vertexShader");o(this,"rectBuffer");o(this,"fragmentShaderSource",`
1
+ var un=Object.defineProperty;var mn=(r,e,t)=>e in r?un(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var o=(r,e,t)=>(mn(r,typeof e!="symbol"?e+"":e,t),t);var At=["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"];function Ze(){return At.reduce((r,e)=>(r[e]=[],r),{})}var Y=At.reduce((r,e)=>(r[e.slice(2).toLowerCase()]=e,r[e]=e,r),{});import{dna as Ce,DnaFactory as vt,mutate as pn,translate as yn}from"@atlas-viewer/dna";import{mutate as Ee,scaleAtOrigin as gn,translate as fn}from"@atlas-viewer/dna";var Xe="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Q=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=Xe[t[r]&63];return e};var k=class{constructor(){o(this,"__id");o(this,"__revision",0);o(this,"__host");o(this,"__onCreate");o(this,"__parent");o(this,"__owner",{value:void 0});o(this,"__state",{});o(this,"eventHandlers");o(this,"scale",1);o(this,"layers",[]);o(this,"time",[]);o(this,"_crop");o(this,"cropData");o(this,"id");o(this,"addEventListener",(e,t,i)=>{let n=Y[e];if(!this.eventHandlers[n])throw new Error(`Unknown event ${n}`);this.eventHandlers[n].indexOf(t)===-1&&this.eventHandlers[n].push(t)});o(this,"removeEventListener",(e,t)=>{let i=Y[e];if(!this.eventHandlers[i]){console.warn(`Unknown event ${i}`);return}this.eventHandlers[i].indexOf(t)!==-1&&(this.eventHandlers[i]=this.eventHandlers[i].filter(n=>n!==t))});this.id=this.__id=Q(),this.eventHandlers=Ze()}get crop(){return this._crop}set crop(e){this._crop=e}getObjectsAt(e){return[]}getAllPointsAt(e,t,i){return[]}getScheduledUpdates(e,t){return[]}dispatchEvent(e,t){let i=this.eventHandlers[e],n=i?i.length:0,s=!1;if(n)for(let a=0;a<n;a++)try{i[a](t),s=!0}catch(h){console.error(e,h)}return s}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){Ee(this.points,fn(e,t))}atScale(e){Ee(this.points,gn(e,this.x,this.y)),this.scale*=e}transform(e){Ee(this.points,e)}applyProps(e){this.__revision++}appendChild(e){}removeChild(e){}insertBefore(e,t){}hideInstance(){}};var D=class r extends k{constructor(t){super();o(this,"type","spacial-content");o(this,"id");o(this,"uri");o(this,"display");o(this,"points");o(this,"priority");o(this,"style",{opacity:1});if(!t)this.id="",this.uri="",this.display={x:0,y:0,scale:1,width:0,height:0,points:Ce(5)},this.points=Ce(5);else{let i=t.scale||1;this.id=t.id||t.uri,this.uri=t.uri,this.points=vt.singleBox(t.width,t.height,t.x,t.y),this.display={x:0,y:0,scale:i,width:t.width/i,height:t.height/i,points:vt.singleBox(t.width/i,t.height/i),rotation:t?.rotation}}}applyProps(t){let i=t.display?t.display.width:t.target.width,n=t.target.width/i;if(this.id=t.id||t.uri,this.uri=t.uri,this.points.set(vt.singleBox(t.target.width,t.target.height,t.target.x,t.target.y)),t.style&&typeof t.style.opacity<"u"&&(this.style.opacity=t.style.opacity),t.crop){this.cropData=t.crop;let s=vt.singleBox(t.crop.width,t.crop.height,t.crop.x,t.crop.y);pn(s,yn(-t.crop.x,-t.crop.y)),this.crop?this.crop.set(s):this.crop=Ce(s)}t.display?(this.display.scale=n,this.display.width=t.display.width,this.display.height=t.display.height,this.display.rotation=t.display.rotation,this.display.points=vt.singleBox(t.display.width,t.display.height)):(this.display.scale=n,this.display.width=t.target.width/n,this.display.height=t.target.height/n,this.display.points=vt.singleBox(t.target.width/n,t.target.height/n))}getAllPointsAt(t,i,n){return[[this,this.crop||this.points,i]]}static fromSvg(t,i,n,s){return r.fromImage("data:image/svg+xml;base64,"+btoa(t),i,n,s)}static fromImage(t,i,n,s){let a=new r;return a.applyProps({uri:t,id:s,display:n,target:i}),a}getImageUrl(){return this.uri}};import{dna as Ye,DnaFactory as Ut}from"@atlas-viewer/dna";var dt=class extends k{constructor(t){super();o(this,"type","spacial-content");o(this,"id");o(this,"uri");o(this,"display");o(this,"points");o(this,"getTexture");if(this.getTexture=()=>({source:void 0,hash:-1}),!t)this.id="",this.uri="",this.display={x:0,y:0,scale:1,width:0,height:0,points:Ye(5)},this.points=Ye(5);else{let i=t.scale||1;this.id=t.id||t.uri,this.uri=t.uri,this.points=Ut.singleBox(t.width,t.height),this.display={x:0,y:0,scale:i,width:t.width/i,height:t.height/i,points:i!==1?Ut.singleBox(t.width/i,t.height/i):this.points}}}applyProps(t){let i=t.display?t.display.width:t.target.width,n=t.target.width/i;this.id=t.id,this.points.set(Ut.singleBox(t.target.width,t.target.height)),this.display.scale=n,this.display.width=t.target.width/n,this.display.height=t.target.height/n,this.getTexture=t.getTexture,this.display.points=n!==1?Ut.singleBox(t.target.width/n,t.target.height/n):this.points}getAllPointsAt(t,i,n){return[[this,this.points,i]]}};import{DnaFactory as qe,hidePointsOutsideRegion as bn,mutate as Je,scale as vn,transform as wn,dna as xn,translate as Sn}from"@atlas-viewer/dna";function Qe(r,e,t=1){let i=e.length;if(i===0)throw new Error("No resources passed in.");let n=0,s=1/0;for(let a=0;a<i&&!(!e[a]||!e[a].display);a++){let h=Re(e[a].display.scale,r/(t||1));h<s&&(s=h,n=a)}return n}function Re(r,e){return Math.abs(r-e)}function ct(r,e){let t=Re(r.x,e.x),i=Re(r.y,e.y);return Math.sqrt(Math.pow(t,2)+Math.pow(i,2))}function Ke(r){let e=r.length;return r.indexOf("/info.json")===e-10?r.slice(0,-10):r}function $t(r,e,t){return Math.min(Math.max(r,e),t)}var $=class r extends k{constructor(t){super();o(this,"id");o(this,"type","spacial-content");o(this,"display");o(this,"tileWidth");o(this,"style",{opacity:1});o(this,"points");o(this,"service");o(this,"format","jpg");o(this,"crop2");o(this,"tileUrl");this.tileUrl=Ke(t.url),this.id=t.id||`${this.tileUrl}--${t.scaleFactor}`,this.points=t.displayPoints?t.displayPoints:wn(t.points,vn(t.scaleFactor)),this.tileWidth=t.tileWidth,this.display={x:0,y:0,width:t.width/t.scaleFactor,height:t.height/t.scaleFactor,points:t.points,scale:t.scaleFactor},t.format&&(this.format=t.format)}applyProps(t){if(t.style&&typeof t.style.opacity<"u"&&(this.style.opacity=t.style.opacity),t.service!==this.service&&(this.service=t.service),t.format?this.format=t.format:this.format="jpg",t.crop){this.cropData=t.crop;let i=xn([...this.points]),n=i.length/5,s=t.crop.x||0,a=t.crop.y||0,h=t.crop.x+t.crop.width,d=t.crop.y+t.crop.height;for(let u=0;u<n;u++){let l=u*5;i[l+1]<h&&i[l+3]>s&&i[l+2]<d&&i[l+4]>a?(i[l+1]=$t(i[l+1],s,h),i[l+3]=$t(i[l+3],s,h),i[l+2]=$t(i[l+2],a,d),i[l+4]=$t(i[l+4],a,d)):i[l]=0}Je(i,Sn(-t.crop.x,-t.crop.y)),this.crop?this.crop.set(i):this.crop=i}}static fromTile(t,i,n,s,a,h,d){n.height=n.height?n.height:n.width;let u=d?Math.floor(i.width/s):Math.ceil(i.width/s),l=d?Math.floor(i.height/s):Math.ceil(i.height/s),c=Math.ceil(u/n.width),m=Math.ceil(l/n.height),y=qe.grid(c,m),v=qe.grid(c,m);for(let P=0;P<m;P++)for(let g=0;g<c;g++){let f=g*n.width,C=P*n.height;v.addPoints(f*s,C*s,g===c-1?i.width:(f+n.width)*s,P===m-1?i.height:(C+n.height)*s),y.addPoints(f,C,g===c-1?u:f+n.width,P===m-1?l:C+n.height)}let x=new r({url:t,scaleFactor:s,points:y.build(),displayPoints:v.build(),width:i.width,height:i.height,tileWidth:n.width,format:h});return x.applyProps({service:a}),x}getImageUrl(t){let i=this.points.slice(t*5,t*5+5),n=i[3]-i[1],s=i[4]-i[2],a=Math.ceil(n/this.display.scale);return`${this.tileUrl}/${i[1]},${i[2]},${n},${s}/${a>this.tileWidth?this.tileWidth:a},/0/default.${this.format||"jpg"}`}getAllPointsAt(t,i,n){let s=bn(this.crop||this.points,t);return[[this,s,i]]}transform(t){Je(this.points,t)}getScheduledUpdates(t,i){return[]}};import{compose as Pn,dna as En,DnaFactory as ti,translate as ei}from"@atlas-viewer/dna";var Vt=class extends k{constructor(){super(...arguments);o(this,"type","spacial-content")}getAllPointsAt(t,i,n){return[[this,this.points,i]]}};var Gt=class extends Vt{constructor(t){super();o(this,"id");o(this,"display");o(this,"points");o(this,"images",[]);o(this,"allImages",[]);o(this,"scaleFactors",[]);o(this,"aggregateBuffer",En(9));o(this,"lazyLoader");o(this,"isFullyLoaded",!1);o(this,"maxScaleFactor",0);o(this,"renderOptions");o(this,"_scheduleSortByScales",!1);o(this,"_sortByScales",()=>{this._scheduleSortByScales=!1,this.allImages.sort((i,n)=>n.display.width-i.display.width),this.images=[];let t=.1;for(let i of this.allImages){if(i.display.width<this.renderOptions.minSize&&i.display.height<this.renderOptions.minSize&&!i.priority||i instanceof D&&(i.display.width>this.renderOptions.maxImageSize||i.display.height>this.renderOptions.maxImageSize)&&!i.priority)continue;if(Math.abs(i.display.scale-t)<.25||i.priority){let s=this.images.pop();s&&(s instanceof D||s.priority)?(i.priority&&this.images.push(i),this.images.push(s)):i&&this.images.push(i)}else i&&this.images.push(i);t=i.display.scale}this.images.length===0&&(this.images=[...this.allImages]),this.scaleFactors=this.images.map(i=>i.display.scale),this.maxScaleFactor=Math.max(...this.scaleFactors)});o(this,"loadFullResource",async()=>{if(!this.isFullyLoaded&&this.lazyLoader){this.isFullyLoaded=!0;let t=await this.lazyLoader();this.addImages(t)}});o(this,"fallback",[this.loadFullResource]);this.id=t.id,this.points=ti.singleBox(t.width,t.height),this.lazyLoader=t.loadFullImages,t.loadFullImages||(this.isFullyLoaded=!0),this.display={x:0,y:0,points:ti.singleBox(t.width,t.height),height:t.height,width:t.width,scale:1},this.renderOptions={renderSmallestFallback:!0,renderLayers:3,minSize:255,maxImageSize:2048,quality:1.5,...t.renderOptions||{}},this.addImages(t.images)}applyProps(t){typeof t.renderSmallestFallback<"u"&&t.renderSmallestFallback!==this.renderOptions.renderSmallestFallback&&(this.renderOptions.renderSmallestFallback=t.renderSmallestFallback),typeof t.renderLayers<"u"&&t.renderLayers!==this.renderOptions.renderLayers&&(this.renderOptions.renderLayers=t.renderLayers),typeof t.minSize<"u"&&t.minSize!==this.renderOptions.minSize&&(this.renderOptions.minSize=t.minSize),typeof t.maxImageSize<"u"&&t.maxImageSize!==this.renderOptions.maxImageSize&&(this.renderOptions.maxImageSize=t.maxImageSize),typeof t.quality<"u"&&t.quality!==this.renderOptions.quality&&(this.renderOptions.quality=t.quality)}appendChild(t){this.addImages([t])}removeChild(t){this.images.indexOf(t)!==-1&&(this.images=this.images.filter(i=>i!==t),this.sortByScales())}insertBefore(t,i){this.addImages([t])}hideInstance(){}addImages(t){for(let i of t)i.__parent=this,i.__owner=this.__owner;this.allImages.push(...t.filter(Boolean)),this.sortByScales()}sortByScales(){this._scheduleSortByScales=!0}getScheduledUpdates(t,i){return this._scheduleSortByScales?[this._sortByScales]:this.isFullyLoaded?[]:i>1/this.maxScaleFactor?this.fallback:[]}getAllPointsAt(t,i,n){if(this.images.length===0)return[];let s=Qe(1/(n||1)/(window.devicePixelRatio||1),this.images,this.renderOptions.quality),a=this.images.length,h=i?Pn(i,ei(this.x,this.y)):ei(this.x,this.y);if(s!==this.images.length-1&&this.images[s+1]){let d=[];for(let c=a-1;c>=s;c--)d.push(c);let u=d[0];this.renderOptions.renderLayers&&(d=d.slice(-Math.min(d.length,this.renderOptions.renderLayers))),this.renderOptions.renderSmallestFallback&&d.indexOf(u)===-1&&d.unshift(u);let l=[];for(let c=0;c<d.length;c++)l.push(...this.images[d[c]].getAllPointsAt(t,h,n));return l}return this.images[s].getAllPointsAt(t,h,n)}};import{compose as ri,DnaFactory as Yt,dnaLength as Rn,hidePointsOutsideRegion as si,mutate as oi,scale as Tn,scaleAtOrigin as _n,translate as ai,dna as ut}from"@atlas-viewer/dna";import{dna as z,compose as Te,getIntersection as Cn,scale as ii,transform as _e,translate as Zt,hidePointsOutsideRegion as ni}from"@atlas-viewer/dna";function Xt(r,e,t,i,n){let s=Math.PI/180*n,a=Math.cos(s),h=Math.sin(s),d=a*(t-r)+h*(i-e)+r,u=a*(i-e)-h*(t-r)+e;return[d,u]}var J=class r extends k{constructor(t,i){super();o(this,"id");o(this,"type","world-object");o(this,"scale");o(this,"layers");o(this,"points");o(this,"worldPoints");o(this,"intersectionBuffer",z(5));o(this,"aggregateBuffer",z(9));o(this,"invertedBuffer",z(9));o(this,"rotation",0);o(this,"filteredPointsBuffer");o(this,"_updatedList",[]);o(this,"geometry");let{x:n=0,y:s=0}=i||{};t?(this.id=t.id||"",this.scale=1,this.layers=t.layers,this.points=z([1,n,s,n+t.width,s+t.height]),this.worldPoints=z([1,n,s,n+t.width,s+t.height]),this.filteredPointsBuffer=z(t.layers.length*5)):(this.id="",this.scale=1,this.layers=[],this.points=z(5),this.worldPoints=z(5),this.filteredPointsBuffer=z(5))}static createWithProps(t){let i=new r;return i.applyProps(t),i}applyProps(t){let i=t.x||0,n=t.y||0;this.id=t.id;let s=typeof t.scale<"u"?t.scale:this.scale;this.points[0]=1,this.points[1]=i,this.points[2]=n,this.points[3]=i+t.width,this.points[4]=n+t.height,this.rotation=t.rotation||0,this.worldPoints[3]=this.worldPoints[1]+t.width,this.worldPoints[4]=this.worldPoints[2]+t.height,t.scale&&t.scale!==1&&this.atScale(s),this.scale=s}appendChild(t){t.points[0]===0&&t.points.set(this.points),t.__owner.value=this,this.addLayers([t])}removeChild(t){this.layers=this.layers.filter(i=>i!==t),this.filteredPointsBuffer=z(this.layers.length*5)}insertBefore(t,i){let n=this.layers.indexOf(i);if(n===-1||this.layers.indexOf(t)!==-1)return;let s=this.layers.slice(0,n),a=this.layers.slice(n);this.layers=[...s,t,...a]}hideInstance(){console.warn("hideInstance: not yet implemented")}getObjectsAt(t,i){if(this.rotation&&(t=this.applyRotation(t)),ni(this.points,t,this.filteredPointsBuffer)[0]===0)return[];let s=this.layers.length,a=[];for(let h=0;h<s;h++){let d=this.layers[h];if(i&&d.isShape){let l=_e(d.points,Zt(this.x,this.y));if(!d.intersects([t[1]-l[1],t[2]-l[2]]))continue}if(ni(_e(d.points,Zt(this.x,this.y)),t,this.filteredPointsBuffer)[0]!==0&&a.push(d),i){let l=d;a.push(...l.getObjectsAt(t,i))}}return a}applyRotation(t){if(this.rotation){let i={x:t[1],y:t[2]},n={x:t[1],y:t[4]},s={x:t[3],y:t[2]},a={x:t[3],y:t[4]},h=this.points[1]+(this.points[3]-this.points[1])/2,d=this.points[2]+(this.points[4]-this.points[2])/2,[u,l]=Xt(h,d,i.x,i.y,this.rotation),[c,m]=Xt(h,d,n.x,n.y,this.rotation),[y,v]=Xt(h,d,s.x,s.y,this.rotation),[x,P]=Xt(h,d,a.x,a.y,this.rotation),g=Math.min(u,c,y,x),f=Math.max(u,c,y,x),C=Math.min(l,m,v,P),_=Math.max(l,m,v,P);return z([t[0],g,C,f,_])}return t}getAllPointsAt(t,i,n){let s=Te(Zt(this.x,this.y),ii(this.scale),this.aggregateBuffer);this.rotation&&(t=this.applyRotation(t));let a=Cn(t,this.points,this.intersectionBuffer),h=this.layers.length,d=[],u=_e(a,Te(ii(1/this.scale),Zt(-this.x,-this.y),this.invertedBuffer)),l=i?Te(i,s,this.aggregateBuffer):s,c=n*this.scale;for(let m=0;m<h;m++)d.push(...this.layers[m].getAllPointsAt(u,l,c));return d}addLayers(t){let i=[];for(let n of t)this.layers.indexOf(n)===-1&&(i.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||z([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(i),this.filteredPointsBuffer=z(this.layers.length*5)}getScheduledUpdates(t,i){let n=this.layers.length;this._updatedList=[];let s=i*this.scale;for(let a=0;a<n;a++){let h=this.layers[a].getScheduledUpdates(t,s);h&&this._updatedList.push(...h)}return this._updatedList}};var V=class r extends k{constructor(t=0,i=0,n=100,s="left-to-right"){super();o(this,"id","world");o(this,"_width");o(this,"_height");o(this,"aspectRatio");o(this,"viewingDirection");o(this,"aggregateBuffer",ut(9));o(this,"isDirty",!1);o(this,"zones",[]);o(this,"filteredPointsBuffer");o(this,"selectedZone");o(this,"triggerQueue",[]);o(this,"activatedEvents",[]);o(this,"_updatedList",[]);o(this,"translationBuffer",ut(9));o(this,"needsRecalculate",!0);o(this,"emptyPaintables",[]);o(this,"renderOrder",[]);o(this,"points");o(this,"objects",[]);o(this,"subscriptions",[]);o(this,"_propagateEventTargets",[]);o(this,"_alreadyFlushed",[]);this._width=t,this._height=i,this.aspectRatio=Number.isNaN(t/i)?1:t/i,this.viewingDirection=s,this.points=ut(n*5),this.filteredPointsBuffer=ut(n*5)}get x(){return 0}get y(){return 0}get width(){return this._width}get height(){return this._height}static withProps(t){let i=new r;return i.applyProps(t),i}applyProps(t){typeof t.width<"u"&&typeof t.height<"u"&&(t.width!==this._width||t.height!==this._height)&&this.resize(t.width,t.height),t.viewingDirection!==this.viewingDirection&&(this.viewingDirection=t.viewingDirection,this.triggerRepaint())}propagateTouchEvent(t,i,n){let s=[];for(let a of n)if(a.x&&a.y){let h=Yt.singleBox(1,1,a.x,a.y);s.push(this.getObjectsAt(h,!0).reverse())}return s.map(a=>this.propagateEvent(t,i,a,{bubbles:!0,cancelable:!0}))}propagatePointerEvent(t,i,n,s,a={}){let h=Yt.singleBox(1,1,n,s),d=this.getObjectsAt(h,!0).reverse();return this.propagateEvent(t,i,d,a)}propagateEvent(t,i,n,{bubbles:s=!1,cancelable:a=!1}={}){i.atlasTarget=this,this._propagateEventTargets.length=1,this._propagateEventTargets[0]=this;let h=!1;i.stopPropagation=()=>{h=!0};let d=n.length;for(let c=d-1;c>=0;c--){this._propagateEventTargets.unshift(n[c][0]);let m=n[c][1].length;if(m)for(let y=0;y<m;y++)this._propagateEventTargets.unshift(n[c][1][y])}let u=this._propagateEventTargets.length,l=!1;for(let c=0;c<u&&(i.atlasTarget=this._propagateEventTargets[c],i.atlasWorld=this,l=this._propagateEventTargets[c].dispatchEvent(t,i)||l,!h);c++);return l&&this.triggerRepaint(),this._propagateEventTargets}appendChild(t){let i=this.appendWorldObject(t);this.renderOrder.push(i/5)}removeChild(t){let i=this.objects.indexOf(t);if(i===-1){for(let n of this.objects)if(n&&n.id===t.id){this.removeChild(n);return}return}this.objects[i]=null,this.renderOrder=this.renderOrder.filter(n=>n!==i),this.points[i*5]=0,this.triggerRepaint(),this.needsRecalculate=!0}insertBefore(t,i){let n=this.objects.indexOf(i);if(n===-1)return;let s=this.appendWorldObject(t);this.renderOrder.splice(n-1,0,s/5)}hideInstance(){}asWorldObject(){return null}addZone(t){this.zones.push(t)}selectZone(t){if(typeof t=="string"){let i=this.zones.length;for(let n=0;n<i;n++)if(this.zones[n].id===t){this.selectedZone=n,this.trigger("zone-changed");return}}else this.zones[t]&&(this.selectedZone=t,this.trigger("zone-changed"))}deselectZone(){this.selectedZone=void 0}getActiveZone(){if(this.selectedZone)return this.zones[this.selectedZone]}hasActiveZone(){return typeof this.selectedZone<"u"}checkResizeInternalBuffer(){if(Rn(this.points)===this.objects.length){let t=this.points,i=ut(this.points.length*2);i.set(t,0),this.points=i}}appendWorldObject(t){this.checkResizeInternalBuffer();let i=this.objects.length*5,n=t.points;return t.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),t.points[1]=n[1],t.points[2]=n[2],t.points[3]=n[3],t.points[4]=n[4],this.objects.push(t),this.filteredPointsBuffer=ut(this.objects.length*5),this.needsRecalculate=!0,this.triggerRepaint(),i}recalculateWorldSize(){let t=!1;if(this.needsRecalculate){let i=new Int32Array(this.objects.length),n=new Int32Array(this.objects.length),s=this.renderOrder.length;for(let d=0;d<s;d++){let u=this.renderOrder[d];this.objects[u]&&(i[d]=this.points[u*5+3],n[d]=this.points[u*5+4])}let a=Math.max(...i);a!==this._width&&(this._width=a,t=!0);let h=Math.max(...n);h!==this._height&&(this._height=h,t=!0),t&&this.trigger("recalculate-world-size",{width:a,height:h}),this.needsRecalculate=!1}return t}addObjectAt(t,i){i.width&&!i.height?i.height=i.width/t.width*t.height:i.height&&!i.width&&(i.width=i.height/t.height*t.width),(!i||!i.width||!i.height)&&(i.width=t.width,i.height=t.height);let{width:n,x:s,y:a}=i,h=n/t.width;this.checkResizeInternalBuffer(),this.points.set(Yt.singleBox(t.width,t.height,0,0),this.objects.length*5);let d=new J(t);return d.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),this.objects.push(d),this.scaleWorldObject(this.objects.length-1,h),this.translateWorldObject(this.objects.length-1,s,a),this.filteredPointsBuffer=ut(this.points.length*2),this.triggerRepaint(),this.needsRecalculate=!0,d}scaleWorldObject(t,i){oi(this.points.subarray(t*5,t*5+5),_n(i,this.points[t*5+1],this.points[t*5+2]));let n=this.objects[t];n&&(n.atScale(i),this.triggerRepaint())}translateWorldObject(t,i,n){oi(this.points.subarray(t*5,t*5+5),ai(i,n));let s=this.objects[t];s&&(s.translate(i,n),this.triggerRepaint())}resize(t,i){return this._width=t,this._height=i,this.aspectRatio=t/i,this.triggerRepaint(),this}getObjects(){return this.objects}getPoints(){return this.points}getPointsFromViewer(t,i){let n=Yt.singleBox(t.width,t.height,t.x,t.y);return this.getPointsAt(n,i,t.scale)}addLayoutSubscriber(t){return this.subscriptions.push(t),()=>{this.subscriptions.splice(this.subscriptions.indexOf(t),1)}}getScheduledUpdates(t,i){let n=si(this.points,t,this.filteredPointsBuffer),s=this.objects.length;this._updatedList=[];for(let a=0;a<s;a++)if(n[a*5]!==0){if(!this.objects[a])continue;this._updatedList.push(...this.objects[a].getScheduledUpdates(t,i))}return this._updatedList}getObjectsAt(t,i=!1){let n=this.getActiveZone(),s=si(this.points,t,this.filteredPointsBuffer),a=this.renderOrder.length,h=[];for(let d=0;d<a;d++){let u=this.renderOrder[d];if(s[u*5]!==0){let l=this.objects[u];if(!l||n&&n.objects.indexOf(l)===-1)continue;if(l.type!=="world-object"){h.push([l,[l]]);continue}i?h.push([l,l.getObjectsAt(t,i)]):h.push([l,this.emptyPaintables])}}return h}getPointsAt(t,i,n=1){let s=this.getObjectsAt(t),a=ri(Tn(n),ai(-t[1],-t[2]),this.translationBuffer),h=i?ri(i,a,this.aggregateBuffer):a,d=s.length,u=[];for(let l=0;l<d;l++)s[l]&&u.push(...s[l][0].getAllPointsAt(t,h,n));return u}flushSubscriptions(){if(this.triggerQueue.length){this._alreadyFlushed=[];let t=this.triggerQueue.length;for(let i=0;i<t;i++){if(this._alreadyFlushed.indexOf(this.triggerQueue[i][0])!==-1)continue;typeof this.triggerQueue[i][1]>"u"&&this._alreadyFlushed.push(this.triggerQueue[i][0]);let n=this.subscriptions.length;for(let s=0;s<n;s++)this.subscriptions[s].apply(null,this.triggerQueue[i])}this.triggerQueue=[]}}trigger(t,i){this.triggerQueue.push([t,i])}triggerEventActivation(){this.trigger("event-activation")}triggerRepaint(){this.trigger("repaint")}gotoRegion(t){this.trigger("goto-region",t)}goHome(t=!1){this.trigger("go-home",{immediate:t})}zoomTo(t,i,n){this.trigger("zoom-to",{point:i,factor:t,stream:n})}zoomIn(t){this.trigger("zoom-to",{point:t,factor:.5})}zoomOut(t){this.trigger("zoom-to",{point:t,factor:2})}constraintBounds(t){this.trigger("constrain-bounds",{immediate:t})}};function qs(r){let{src:e,target:t}=r,i=t?t.width:r.width,n=t?t.height:r.height;return new J({id:e,height:n,width:i,layers:[D.fromImage(e,{height:n,width:i},{width:r.width,height:r.height})]})}import{dna as On}from"@atlas-viewer/dna";var An={margin:0},hi=class{constructor(e,t={}){o(this,"id");o(this,"config");o(this,"points");o(this,"objects");this.id=e.map(i=>i.id).join("$$"),this.config={...An,...t},this.points=On(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,i){return[]}};import{dna as li,DnaFactory as di}from"@atlas-viewer/dna";var Qt=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,Kt={},Mn=["backgroundColor","opacity","boxShadow","borderColor","borderWidth","borderStyle","outlineColor","outlineWidth","outlineOffset","outlineStyle"],K=class extends k{constructor(){super();o(this,"id");o(this,"type","spacial-content");o(this,"points");o(this,"hoverEvents",!1);o(this,"activeEvents",!1);o(this,"display",{x:0,y:0,scale:1,width:-1,height:-1,points:li(5)});o(this,"_parsed",{border:{id:null,match:[]},outline:{id:null,match:[]}});o(this,"hovering");o(this,"pressing");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=Q(12),this.points=li(5)}getAllPointsAt(t,i){return[[this,this.points,i]]}applyProps(t={}){let i=!1;if(t.interactive!==this.props.interactive&&(i=!0,this.props.interactive=t.interactive),t.style){let n=t.border||t.style.border;if(n!==this._parsed.border.id)if(!n)this._parsed.border.id=null,this._parsed.border.match=[];else{let s=Kt[n]||Qt.exec(n)||Qt.exec(n);s&&(this._parsed.border.id=n,this._parsed.border.match=Kt[n]=s)}if(this._parsed.border.id&&(t.style.borderWidth=this._parsed.border.match[1],t.style.borderStyle="solid",t.style.borderColor=this._parsed.border.match[4]),t.style.outline!==this._parsed.outline.id)if(!t.style.outline)this._parsed.outline.id=null,this._parsed.outline.match=[];else{let s=Kt[t.style.outline]||Qt.exec(t.style.outline)||Qt.exec(t.style.outline);s&&(this._parsed.outline.id=t.style.outline,this._parsed.outline.match=Kt[t.style.outline]=s)}this._parsed.outline.id&&(t.style.outlineWidth=this._parsed.outline.match[1],t.style.outlineStyle="solid",t.style.outlineColor=this._parsed.outline.match[4]),this.props.style=t.style,t.backgroundColor&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=t.backgroundColor,i=!0),t.style.background&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=t.style.background,i=!0);for(let s of Mn)if(this.props.style[s]!==t.style[s]){i=!0;break}t.style[":hover"]!==this.props.hoverStyles&&(this.props.hoverStyles=t.style[":hover"],this.hoverEvents||(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),i=!0),t.style[":active"]!==this.props.pressStyles&&(this.props.pressStyles=t.style[":active"],this.activeEvents||(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),i=!0)}t.href!==this.props.href&&(this.props.href=t.href,i=!0),t.hrefTarget!==this.props.hrefTarget&&(this.props.hrefTarget=t.hrefTarget,i=!0),t.title!==this.props.title&&(this.props.title=t.title,i=!0),t.className!==this.props.className&&(this.props.className=t.className,t.className&&!this.hoverEvents&&(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),t.className&&!this.activeEvents&&(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),i=!0),t.relativeSize!==this.props.relativeSize&&(this.props.relativeSize=t.relativeSize,i=!0),t.relativeStyle!==this.props.relativeStyle&&(this.props.relativeStyle=t.relativeStyle,i=!0),t.html!==this.props.html&&(this.props.html=t.html,i=!0),t.target&&(t.target.width!==this.display.width||t.target.height!==this.display.height||t.target.x!==this.points[1]||t.target.y!==this.points[2])&&(i=!0,this.points=di.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.points=di.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.width=t.target.width,this.display.height=t.target.height),i&&this.__revision++}};import{dna as ci,DnaFactory as In}from"@atlas-viewer/dna";var ot=class extends k{constructor(){super();o(this,"type","spacial-content");o(this,"id");o(this,"points");o(this,"color","#000");o(this,"backgroundColor");o(this,"hovering");o(this,"pressing");o(this,"text","");o(this,"display",{x:0,y:0,scale:1,width:100,height:100,points:ci(5)});o(this,"className");o(this,"html");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=ci(5)}getAllPointsAt(t,i){return[[this,this.points,i]]}applyProps({id:t,target:i,text:n,color:s,backgroundColor:a,fontSize:h=18,interactive:d,fontFamily:u="Arial, sans-serif",...l}){l.font=`${h}px ${u}`,this.interactive=d||!1,typeof n<"u"&&(this.text=n||""),s&&(this.color=s),a&&(this.backgroundColor=a),t&&(this.id=t),i&&(this.points=In.singleBox(i.width,i.height,i.x,i.y),this.display.points=this.points,this.display.width=i.width,this.display.height=i.height),this.props={...this.props,...l},this.__revision++}};import{DnaFactory as wt,mutate as pi,scale as yi,scaleAtOrigin as bi,transform as Oe,dna as ne,translate as kn,compose as Fn}from"@atlas-viewer/dna";import{dna as Lt,DnaFactory as Ln}from"@atlas-viewer/dna";var L=Math.pow,qt=Math.sqrt,Mt=Math.sin,ui=Math.cos,It=Math.PI,ee=1.70158,Jt=ee*1.525,mi=ee+1,gi=2*It/3,fi=2*It/4.5,te=function(r){return r<1/2.75?7.5625*r*r:r<2/2.75?7.5625*(r-=1.5/2.75)*r+.75:r<2.5/2.75?7.5625*(r-=2.25/2.75)*r+.9375:7.5625*(r-=2.625/2.75)*r+.984375},q={linear:r=>r,easeInQuad:function(r){return r*r},easeOutQuad:function(r){return 1-(1-r)*(1-r)},easeInOutQuad:function(r){return r<.5?2*r*r:1-L(-2*r+2,2)/2},easeInCubic:function(r){return r*r*r},easeOutCubic:function(r){return 1-L(1-r,3)},easeInOutCubic:function(r){return r<.5?4*r*r*r:1-L(-2*r+2,3)/2},easeInQuart:function(r){return r*r*r*r},easeOutQuart:function(r){return 1-L(1-r,4)},easeInOutQuart:function(r){return r<.5?8*r*r*r*r:1-L(-2*r+2,4)/2},easeInQuint:function(r){return r*r*r*r*r},easeOutQuint:function(r){return 1-L(1-r,5)},easeInOutQuint:function(r){return r<.5?16*r*r*r*r*r:1-L(-2*r+2,5)/2},easeInSine:function(r){return 1-ui(r*It/2)},easeOutSine:function(r){return Mt(r*It/2)},easeInOutSine:function(r){return-(ui(It*r)-1)/2},easeInExpo:function(r){return r===0?0:L(2,10*r-10)},easeOutExpo:function(r){return r===1?1:1-L(2,-10*r)},easeInOutExpo:function(r){return r===0?0:r===1?1:r<.5?L(2,20*r-10)/2:(2-L(2,-20*r+10))/2},easeInCirc:function(r){return 1-qt(1-L(r,2))},easeOutCirc:function(r){return qt(1-L(r-1,2))},easeInOutCirc:function(r){return r<.5?(1-qt(1-L(2*r,2)))/2:(qt(1-L(-2*r+2,2))+1)/2},easeInBack:function(r){return mi*r*r*r-ee*r*r},easeOutBack:function(r){return 1+mi*L(r-1,3)+ee*L(r-1,2)},easeInOutBack:function(r){return r<.5?L(2*r,2)*((Jt+1)*2*r-Jt)/2:(L(2*r-2,2)*((Jt+1)*(r*2-2)+Jt)+2)/2},easeInElastic:function(r){return r===0?0:r===1?1:-L(2,10*r-10)*Mt((r*10-10.75)*gi)},easeOutElastic:function(r){return r===0?0:r===1?1:L(2,-10*r)*Mt((r*10-.75)*gi)+1},easeInOutElastic:function(r){return r===0?0:r===1?1:r<.5?-(L(2,20*r-10)*Mt((20*r-11.125)*fi))/2:L(2,-20*r+10)*Mt((20*r-11.125)*fi)/2+1},easeInBounce:function(r){return 1-te(1-r)},easeOutBounce:te,easeInOutBounce:function(r){return r<.5?(1-te(1-2*r))/2:(1+te(2*r-1))/2}};var ie=class{constructor(e){o(this,"runtime");o(this,"pendingTransition");o(this,"lastZoomTo",null);o(this,"isConstraining",!1);o(this,"lastGoToRegion",null);this.runtime=e,this.pendingTransition={from:Lt(5),to:Lt(5),elapsed_time:0,done:!0,total_time:0,timingFunction:q.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=Lt(this.runtime.target),this.pendingTransition.to=Lt(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 i=this.pendingTransition,n=i.total_time===0?0:(i.elapsed_time+t)/i.total_time,s=i.total_time===0?1:n===0?0:i.timingFunction(n);e[1]=i.from[1]+(i.to[1]-i.from[1])*s,e[2]=i.from[2]+(i.to[2]-i.from[2])*s,e[3]=i.from[3]+(i.to[3]-i.from[3])*s,e[4]=i.from[4]+(i.to[4]-i.from[4])*s,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:q.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:i,stream:n=!1,transition:s}=t;this.lastZoomTo={factor:e,options:t};let a=this.runtime.getZoomedPosition(e,{origin:i}),h=Math.abs(1-e);this.applyTransition(a,s,{duration:2e3*h,easing:q.easeOutExpo,constrain:!0,callback:()=>{this.lastZoomTo=null}},{stream:!1})}constrainBounds({transition:e,panPadding:t=0}={}){this.isConstraining=!0;let[i,n]=this.runtime.constrainBounds(this.runtime.target,{panPadding:t});i&&(this.applyTransition(n,e,{duration:500,easing:q.easeOutQuart,constrain:!1,callback:()=>{this.isConstraining=!1}}),this.runtime.updateNextFrame())}applyTransition(e,t,i,{stream:n}={}){this.pendingTransition.from=Lt(this.runtime.target),this.pendingTransition.to=e,n||(this.pendingTransition.elapsed_time=0),this.pendingTransition.done=!1,this.pendingTransition.total_time=typeof t?.duration<"u"?t.duration:typeof i?.duration<"u"?i.duration:1e3,this.pendingTransition.constrain=typeof t?.constrain<"u"?t.constrain:typeof i?.constrain<"u"?i.constrain:!1,this.pendingTransition.timingFunction=t?.easing||i?.easing||q.easeInOutSine}goToRegion(e,{transition:t}={}){this.lastGoToRegion={target:e,options:{transition:t}};let i=this.runtime.clampRegion(e);this.applyTransition(Ln.singleBox(i.width,i.height,i.x,i.y),t,{duration:1e3,easing:q.easeOutExpo,constrain:!0,callback:()=>{this.lastGoToRegion=null}}),this.runtime.updateNextFrame()}};var To=Number.MIN_VALUE+1,tt=class{constructor(e,t,i,n=[],s){o(this,"id",Q());o(this,"ready",!1);o(this,"renderer");o(this,"world");o(this,"target");o(this,"homePosition");o(this,"manualHomePosition");o(this,"manualFocalPosition");o(this,"focalPosition");o(this,"transitionManager");o(this,"aggregate");o(this,"transformBuffer",ne(500));o(this,"lastTarget",ne(5));o(this,"zoomBuffer",ne(5));o(this,"logNextRender",!1);o(this,"pendingUpdate",!0);o(this,"isCommitting",!1);o(this,"firstRender",!0);o(this,"lastTime");o(this,"stopId");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");o(this,"options");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(typeof e.x>"u"?this.target[1]:e.x),i=Math.round(typeof e.y>"u"?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]=i+e.height:this.target[4]=this.target[4]-this.target[2]+i,Math.abs(this.target[1]-t)>.01&&(this.target[1]=t),Math.abs(this.target[2]-i)>.01&&(this.target[2]=i),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 i=this.pendingUpdate,n=this.renderer.pendingUpdate();if(this.transitionManager.hasPending()&&(this.transitionManager.runTransition(this.target,t),this.pendingUpdate=!0,this.updateControllerPosition()),!this.firstRender&&!i&&!n&&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 s=this.getScaleFactor(),a=this.renderer.getPointsAt(this.world,this.target,this.aggregate,s),h=a.length;for(let l=0;l<h;l++){let c=a[l][0],m=a[l][1],y=a[l][2],v=y?Oe(m,y,this.transformBuffer):m;this.renderer.prepareLayer(c,c.__parent&&y?Oe(c.__parent.crop||c.__parent.points,y):v);let x=v.length/5;for(let P=0;P<x;P++){let g=P*5;v[g]!==0&&(this.renderer.paint(c,P,v[g+1],v[g+2],v[g+3]-v[g+1],v[g+4]-v[g+2]),this.hook("useAfterPaint",c))}this.renderer.finishLayer(c,m)}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 d=this.world.getScheduledUpdates(this.target,s),u=d.length;if(u>0)for(let l=0;l<u;l++){let c=d[u-l-1]();c?c.then(()=>{this.pendingUpdate=!0}):this.pendingUpdate=!0}});this.renderer=e,this.world=t,this.options={maxOverZoom:1,maxUnderZoom:1,visibilityRatio:1.5,...s||{}},this.target=wt.projection(i),this.manualHomePosition=!1,this.pendingUpdate=!0,this.homePosition=wt.projection(this.world),this.manualFocalPosition=!1,this.focalPosition=this.target,this.updateFocalPosition(),this.transitionManager=new ie(this),this.aggregate=yi(1),this.world.addLayoutSubscriber(a=>{a==="repaint"&&(this.pendingUpdate=!0),a==="recalculate-world-size"&&(this.manualHomePosition||(this.setHomePosition(),this.goHome()),this.updateFocalPosition())}),this.lastTime=performance.now(),this.controllers=n,this.render(this.lastTime),this.startControllers()}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}setHomePosition(e){this.homePosition.set(wt.projection(e||this.world)),this.pendingUpdate=!0}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}}goHome(e={}){if(this.world.width<=0||this.world.height<=0)return;let t=this.getScaleFactor(),i=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]},n=this.width*t,s=this.height*t,a=i.width/n,h=i.height/s,d=n/s;if(e.cover?a>h:a<h){let u=d*i.height,l=(u-i.width)/2;this.target[1]=Math.round(-l+i.x),this.target[2]=Math.round(i.y),this.target[3]=Math.round(u-l+i.x),this.target[4]=Math.round(i.height+i.y)}else{let u=i.width/d,l=(u-i.height)/2;this.target[1]=Math.round(i.x),this.target[2]=Math.round(i.y-l),this.target[3]=Math.round(i.x+i.width),this.target[4]=Math.round(i.y+u-l)}this.constrainBounds(this.target),this.updateControllerPosition()}resize(e,t,i,n){this.transitionManager.hasPending()&&this.transitionManager.stopTransition(),this.updateFocalPosition(e-t,i-n);let s=t/e,a=n/i;this.target[3]=this.target[1]+(this.target[3]-this.target[1])*s,this.target[4]=this.target[2]+(this.target[4]-this.target[2])*a,this.goHome({position:this.focalPosition}),this.renderer.resize(t,n),this.pendingUpdate=!0,this.transitionManager.resumeTransition()}updateFocalPosition(e,t){if(!this.manualFocalPosition){let i=this.width,n=this.height,s=Math.min(i,n),a=0,h=0,d=this.x+a,u=this.y+h;if(i<n){let l=this.height-this.width;this.focalPosition=wt.projection({x:d,y:u+l/2,width:s-a*2,height:s-h*2}),this.pendingUpdate=!0}else{let l=this.width-this.height;this.focalPosition=wt.projection({x:d+l/2,y:u,width:s-a*2,height:s-h*2}),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:i=!1}={}){let{minX:n,maxX:s,minY:a,maxY:h}=this.getBounds({target:e,padding:t}),d=!1,u=i?e:ne(e),l=Math.round(e[3]-e[1]),c=Math.round(e[4]-e[2]);return n>e[1]&&(d=!0,u[1]=n,u[3]=n+l),a>e[2]&&(d=!0,u[2]=a,u[4]=a+c),s<e[1]&&(d=!0,u[1]=s,u[3]=s+l),h<e[2]&&(d=!0,u[2]=h,u[4]=h+c),[d,u]}getBounds(e){let t=e.target||this.target,i=e.padding,n=this.options.visibilityRatio,s=Math.abs(1-n);if(this.world.hasActiveZone()){let f=this.world.getActiveZone();if(f){let C=t[3]-t[1]<f.points[3]-f.points[1],_=t[4]-t[2]<f.points[4]-f.points[2];return{minX:C?f.points[1]-i:f.points[1]+(f.points[3]-f.points[1])/2-(t[3]-t[1])/2,maxX:_?f.points[2]-i:f.points[2]+(f.points[4]-f.points[2])/2-(t[4]-t[2])/2,minY:C?f.points[3]+i:f.points[1]+(f.points[3]-f.points[1])/2-(t[3]-t[1])/2,maxY:_?f.points[4]+i:f.points[2]+(f.points[4]-f.points[2])/2-(t[4]-t[2])/2}}}let a=t[3]-t[1],h=this.world.width,d=-a*s,u=h-a-d,l=t[4]-t[2],c=this.world.height,m=-l*s,y=c-l-m,v=Math.round(Math.max(d,u)),x=Math.round(Math.min(d,u)),P=Math.round(Math.max(m,y)),g=Math.round(Math.min(m,y));return{minX:x,maxX:v,minY:g,maxY:P}}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:i}){let n=i?{width:i[3]-i[1],height:i[4]-i[2]}:void 0,s=n?this.renderer.getScale(n.width,n.height):this.getScaleFactor(),a=n?n.width:this.width,h=n?n.height:this.height,d=this.getRendererScreenPosition()?.width,u=this.world.width,l=d?d/u:1,c=this.options.maxUnderZoom,m=Math.max(l||1,this.options.maxOverZoom),y=1/e,v=s*y;if(y<1){let g=a*s,f=h*s,C=this.world.width/g,_=this.world.height/f;if(C>_){let S=this.world.width*v,O=~~(a*s)*c;S<O&&(e=this.world.width*s/(a*s*c))}else{let S=this.world.height*v,O=~~(h*s)*c;S<O&&(e=this.world.height*s/(h*s*c))}}else v>m&&(e=s/m);let P=Oe(this.target,bi(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(P,{ref:!0,panPadding:100}),P}clampRegion({x:e,y:t,width:i,height:n,padding:s=0}){let a=this.width,h=this.height,d=i/a<n/h,u=e-s,l=t-s,c=i+s*2,m=n+s*2;if(d){let v=m/h*a;return{x:u-(v-c)/2,y:l,width:v,height:m}}let y=c/a*h;return{x:u,y:l-(y-m)/2,width:c,height:y}}viewerToWorld(e,t){let i=this.getScaleFactor();return this._viewerToWorld.x=this.target[1]+e/i,this._viewerToWorld.y=this.target[2]+t/i,this._viewerToWorld}worldToViewer(e,t,i,n){let s=wt.singleBox(i,n,e,t);return pi(s,Fn(yi(this.getScaleFactor()),kn(-this.target[1],-this.target[2]))),{x:s[1],y:s[2],width:s[3]-s[1],height:s[4]-s[2],strand:s}}setScale(e,t){pi(this.target,bi(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 typeof this.stopId<"u"&&(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 i=this.hooks[e].length;if(i!==0)for(let n=0;n<i;n++)this.hooks[e][n](t)}registerHook(e,t){return this.hooks[e].push(t),()=>{this.hooks[e]=this.hooks[e].filter(i=>i!==t)}}updateNextFrame(){this.pendingUpdate=!0}};import{dna as vi,DnaFactory as wi}from"@atlas-viewer/dna";var re=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,se={},Dn=["backgroundColor","opacity","boxShadow","borderColor","borderWidth","borderStyle","outlineColor","outlineWidth","outlineOffset","outlineStyle"],xt=class extends k{constructor(){super();o(this,"id");o(this,"type","spacial-content");o(this,"isShape",!0);o(this,"points");o(this,"hoverEvents",!1);o(this,"activeEvents",!1);o(this,"display",{x:0,y:0,scale:1,width:-1,height:-1,points:vi(5)});o(this,"boundingBox",null);o(this,"_parsed",{border:{id:null,match:[]},outline:{id:null,match:[]}});o(this,"hovering");o(this,"pressing");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=Q(12),this.points=vi(5),this.shape={type:"none"}}updateBoundingBox(){if(this.shape.type==="none")return;let t=this.shape.points;if(this.shape.points.length>2){let i=Math.min(...t.map(h=>h[0])),n=Math.min(...t.map(h=>h[1])),s=Math.max(0,...t.map(h=>h[0])),a=Math.max(0,...t.map(h=>h[1]));this.boundingBox={x:i,y:n,width:s-i,height:a-n};return}this.boundingBox=null}intersects(t){if(!t||this.shape.type==="none")return!1;let[i,n]=t,s=this.shape.points,a=this.boundingBox;if(a||(this.updateBoundingBox(),a=this.boundingBox),!a||i<a.x||i>a.x+a.width||n<a.y||n>a.height+a.y)return!1;let h=!1;for(let d=0,u=s.length-1;d<s.length;u=d++)s[d][1]>n!=s[u][1]>n&&i<(s[u][0]-s[d][0])*(n-s[d][1])/(s[u][1]-s[d][1])+s[d][0]&&(h=!h);return h}getAllPointsAt(t,i){return t[3]-t[1]===1&&t[4]-t[2]===1?this.intersects([t[1],t[2]])?[[this,this.points,i]]:[]:[[this,this.points,i]]}applyProps(t={}){let i=!1;if(t.points)if(this.shape.type!=="polygon"||this.shape.points.length!==t.points.length)this.shape={type:"polygon",points:t.points,open:t.open},this.updateBoundingBox();else{let n=!1,s=t.points.length;for(let a=0;a<s;a++)if(t.points[a][0]!==this.shape.points[a][0]||t.points[a][1]!==this.shape.points[a][1]){n=!0;break}n&&(this.shape={type:"polygon",points:t.points,open:t.open},this.updateBoundingBox())}if(t.interactive!==this.props.interactive&&(i=!0,this.props.interactive=t.interactive),(t.open||t.open===!1)&&(i=!0,this.shape.open=t.open),t.style){let n=t.border||t.style.border;if(n!==this._parsed.border.id)if(!n)this._parsed.border.id=null,this._parsed.border.match=[];else{let s=se[n]||re.exec(n)||re.exec(n);s&&(this._parsed.border.id=n,this._parsed.border.match=se[n]=s)}if(this._parsed.border.id&&(t.style.borderWidth=this._parsed.border.match[1],t.style.borderStyle="solid",t.style.borderColor=this._parsed.border.match[4]),t.style.outline!==this._parsed.outline.id)if(!t.style.outline)this._parsed.outline.id=null,this._parsed.outline.match=[];else{let s=se[t.style.outline]||re.exec(t.style.outline)||re.exec(t.style.outline);s&&(this._parsed.outline.id=t.style.outline,this._parsed.outline.match=se[t.style.outline]=s)}this._parsed.outline.id&&(t.style.outlineWidth=this._parsed.outline.match[1],t.style.outlineStyle="solid",t.style.outlineColor=this._parsed.outline.match[4]),this.props.style=t.style,t.backgroundColor&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=t.backgroundColor,i=!0),t.style.background&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=t.style.background,i=!0);for(let s of Dn)if(this.props.style[s]!==t.style[s]){i=!0;break}t.style[":hover"]!==this.props.hoverStyles&&(this.props.hoverStyles=t.style[":hover"],this.hoverEvents||(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),i=!0),t.style[":active"]!==this.props.pressStyles&&(this.props.pressStyles=t.style[":active"],this.activeEvents||(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),i=!0)}t.href!==this.props.href&&(this.props.href=t.href,i=!0),t.hrefTarget!==this.props.hrefTarget&&(this.props.hrefTarget=t.hrefTarget,i=!0),t.title!==this.props.title&&(this.props.title=t.title,i=!0),t.className!==this.props.className&&(this.props.className=t.className,t.className&&!this.hoverEvents&&(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),t.className&&!this.activeEvents&&(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),i=!0),t.relativeSize!==this.props.relativeSize&&(this.props.relativeSize=t.relativeSize,i=!0),t.relativeStyle!==this.props.relativeStyle&&(this.props.relativeStyle=t.relativeStyle,i=!0),t.html!==this.props.html&&(this.props.html=t.html,i=!0),t.target&&(t.target.width!==this.display.width||t.target.height!==this.display.height||t.target.x!==this.points[1]||t.target.y!==this.points[2])&&(i=!0,this.points=wi.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.points=wi.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.width=t.target.width,this.display.height=t.target.height),i&&this.__revision++}};import Bn from"lru-cache";var xi=/(-?[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,Si={},Wn=typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes("firefox"),oe={};var ae=class{constructor(e,t){o(this,"canvas");o(this,"ctx");o(this,"options");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");o(this,"averageJobTime",64);o(this,"lastKnownScale",1);o(this,"visible",[]);o(this,"previousVisible",[]);o(this,"rendererPosition");o(this,"dpi");o(this,"drawCalls",[]);o(this,"lastPaintedObject");o(this,"hostCache");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 Bn({maxSize:1024*512*512,dispose:(i,n,s)=>{this.invalidated.push(n),i.width=0,i.height=0},sizeCalculation:(i,n)=>i.width*i.height}):{store:{},get(i){return this.store[i]},set(i,n){this.store[i]=n}}}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((t,i)=>t.network&&t.scale===i.scale?i.distance-t.distance:t.scale<i.scale?-1:1),this.loadingQueueOrdered=!0),this.previousVisible=this.visible,this.pendingDrawCall=!!this.drawCalls.length,this.pendingDrawCall)for(let t=0;t<this.drawCalls.length;t++){let i=this.drawCalls.shift();i&&i()}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,i){if(Number.isNaN(e)||Number.isNaN(t))return this.lastKnownScale;let n=this.getCanvasDims(),s=n.width/e,a=n.height/t,h=(s<a?a:s)*(i&&this.dpi||1);return Number.isNaN(h)||(this.lastKnownScale=h),this.lastKnownScale}beforeFrame(e,t,i,n){this.options.debug&&this.stats&&this.stats.begin(),this.frameIsRendering=!0,this.visible=[],this.options.beforeFrame&&this.options.beforeFrame(t);let s=this.getCanvasDims();if(this.ctx.globalAlpha=1,this.ctx.fillStyle=this.canvas.dataset.background??"rgb(0, 0, 0)",this.ctx.fillRect(0,0,s.width,s.height),n.enableFilters&&(n.filters.brightness||n.filters.contrast||n.filters.grayscale||n.filters.invert||n.filters.sepia||n.filters.saturate||n.filters.hueRotate||n.filters.blur)){let a="";n.filters.brightness&&(a+=`brightness(${~~(100+n.filters.brightness*100)}%) `),n.filters.contrast&&(a+=`contrast(${~~(100+n.filters.contrast*100)}%) `),n.filters.grayscale&&(a+=`grayscale(${~~(n.filters.grayscale*100)}%) `),n.filters.invert&&(a+=`invert(${~~(n.filters.invert*100)}%) `),n.filters.sepia&&(a+=`sepia(${~~(n.filters.sepia*100)}%) `),n.filters.saturate&&(a+=`saturate(${~~(100+n.filters.saturate*100)}%) `),n.filters.hueRotate&&(a+=`hue-rotate(${n.filters.hueRotate}deg) `),n.filters.blur&&(a+=`blur(${n.filters.blur}px) `),this.ctx.filter=a}else this.ctx.filter="none"}applyTransform(e,t,i,n,s){let a=e.__owner.value;if(a&&a.rotation){this.ctx.save();let h=t+n/2,d=i+s/2;this.ctx.translate(h,d),this.ctx.rotate(a.rotation*Math.PI/180),this.ctx.translate(-h,-d),this.lastPaintedObject=a}}clearTransform(){this.lastPaintedObject&&(this.lastPaintedObject.rotation&&this.ctx.restore(),this.lastPaintedObject=void 0)}paint(e,t,i,n,s,a){let h=this.ctx.globalAlpha;if(e instanceof D||e instanceof $){if(e.display.rotation){this.ctx.save();let l=i+s/2,c=n+a/2;e.crop&&(l-=e.crop[t*5+1],c-=e.crop[t*5+2]),this.ctx.translate(l,c),this.ctx.rotate(e.display.rotation*Math.PI/180),this.ctx.translate(-l,-c)}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 l=e.__host.canvas,c=this.getCanvasDims();if((l.indices.indexOf(t)===-1||this.invalidated.indexOf(l.canvases[t])!==-1)&&this.schedulePaintToCanvas(l,e,t,ct({x:i+s/2,y:n+s/2},{x:c.width/2,y:c.height/2})),!this.firstMeaningfulPaint)return;let m=this.hostCache.get(l.canvases[t]);if(m)if(e.crop&&e.cropData){if(e.crop[t*5]){let y=[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];y[0]+=e.cropData.x/e.display.scale,y[1]+=e.cropData.y/e.display.scale;let v=e.x*this.lastKnownScale,x=e.y*this.lastKnownScale,P=[i+v,n+x,s,a];P[0]+=v,P[1]+=x,this.ctx.drawImage(m,y[0],y[1],y[2],y[3],P[0],P[1],P[2]+1,P[3]+1)}}else Wn?this.ctx.drawImage(m,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],i,n,s+1,a+1):this.ctx.drawImage(m,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],i,n,s+Number.MIN_VALUE+.5,a+Number.MIN_VALUE+.5)}catch{}e.display.rotation&&this.ctx.restore()}let d=e instanceof K&&this.options.box,u=e instanceof xt&&this.options.polygon;if((d||u)&&!e.props.className&&!e.props.html&&!e.props.href){if(this.visible.push(e),e.props.style){let l=Object.assign({},e.props.style||{},e.hovering?e.props.hoverStyles:{},e.pressing?e.props.pressStyles:{}),c=e.props.relativeStyle?1:s/e.width;typeof l.opacity<"u"&&(this.ctx.globalAlpha=l.opacity);let m=0;typeof l.borderWidth<"u"&&(m=parseInt(l.borderWidth,10)*c);let y=0;typeof l.outlineWidth<"u"&&(y=parseInt(l.outlineWidth,10)*c);let v=0;if(typeof l.outlineOffset<"u"&&(v=parseInt(l.outlineOffset,10)*c),l.borderColor&&(this.ctx.strokeStyle=l.borderColor),l.boxShadow){let x=l.boxShadow.split(/,(?![^(]*\))/);for(let P of x){let g=Si[P]||xi.exec(P)||xi.exec(P);Si[P]=g,g&&(this.ctx.save(),this.ctx.shadowOffsetX=parseInt(g[1])*this.dpi*c,this.ctx.shadowOffsetY=parseInt(g[3])*this.dpi*c,this.ctx.shadowBlur=parseInt(g[5])*this.dpi*c,this.ctx.shadowColor=g[9],this.ctx.fillStyle="rgba(0,0,0,1)",this.ctx.fillRect(i+m,n+m,s,a),this.ctx.restore())}}if(this.ctx.fillStyle=l.backgroundColor||"transparent",this.ctx.lineWidth=m,u){let x=e.shape,P=x.points||[],g=P.length;this.ctx.beginPath();for(let f=0;f<g;f++)this.ctx.lineTo(i+P[f][0]*this.lastKnownScale,n+P[f][1]*this.lastKnownScale);x.open||this.ctx.closePath(),m&&this.ctx.stroke(),x.open||this.ctx.fill()}else m&&this.ctx.strokeRect(i+m/2,n+m/2,s+m,a+m),this.ctx.fillRect(i+m,n+m,s,a);y&&(l.outlineColor&&(this.ctx.strokeStyle=l.outlineColor),this.ctx.lineWidth=y,this.ctx.strokeRect(i-y/2-v,n-y/2-v,s+m*2+y+v*2,a+m*2+y+v*2))}this.ctx.globalAlpha=h}}loadImage(e,t,i,n=!1){if(oe[e]&&oe[e].naturalWidth>0){t(oe[e]);return}try{let s=!1;n||setTimeout(()=>{s||this.loadImage(e,t,i,!0)},3e3);let a=document.createElement("img");a.decoding="auto",a.onload=function(){s=!0,t(a),oe[e]=a,a.onload=null},this.options.crossOrigin&&(a.crossOrigin="anonymous"),a.src=e,a.complete&&a.onload({}),a.width}catch(s){console.log("image error",s),i(s)}}schedulePaintToCanvas(e,t,i,n){this.imagesPending++,e.indices.push(i);let s=`${t.id}--${t.display.scale}-${i}`,a=this.invalidated.indexOf(s);a!==-1&&this.invalidated.splice(a,1),e.canvases[i]=s,t.__host.canvas.loading=!0,this.loadingQueueOrdered=!1,this.loadingQueue.push({id:s,scale:t.display.scale,network:!0,distance:n,task:()=>new Promise(h=>{if(this.visible.indexOf(t)===-1){this.imagesPending--,e.indices.splice(e.indices.indexOf(i),1),h();return}let d=t.getImageUrl(i);this.loadImage(d,u=>{this.loadingQueue.push({id:s,scale:t.display.scale,distance:n,task:()=>new Promise(l=>{this.imageIdsLoaded.includes(s)||(this.imagesLoaded++,this.imageIdsLoaded.push(s)),e.loaded.push(i),e.loaded.length===e.indices.length&&(e.loading=!1);let c=t.display.points.slice(i*5,i*5+5),m=document.createElement("canvas"),y=m.getContext("2d");m.width=c[3]-c[1],m.height=c[4]-c[2],this.hostCache.set(e.canvases[i],m),this.drawCalls.push(()=>{y.drawImage(u,0,0,c[3]-c[1],c[4]-c[2]),l()})})}),h()},u=>{this.imagesPending--,e.indices.splice(e.indices.indexOf(i),1),h()})})})}afterPaintLayer(e,t){}prepareLayer(e,t){if(e.__owner.value)if(e.cropData){let i=this.lastKnownScale*(1/e.display.scale);this.applyTransform(e,t[1],t[2],t[3]-t[1],t[4]-t[2])}else this.applyTransform(e,t[1],t[2],t[3]-t[1],t[4]-t[2]);(!e.__host||!e.__host.canvas)&&(e instanceof D||e instanceof $)&&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,i,n){return e.getPointsAt(t,i,n)}getViewportBounds(e,t,i){let n=e.getActiveZone();if(n){let s=t[3]-t[1]<n.points[3]-n.points[1],a=t[4]-t[2]<n.points[4]-n.points[2];return{x1:s?n.points[1]-i:n.points[1]+(n.points[3]-n.points[1])/2-(t[3]-t[1])/2,y1:a?n.points[2]-i:n.points[2]+(n.points[4]-n.points[2])/2-(t[4]-t[2])/2,x2:s?n.points[3]+i:n.points[1]+(n.points[3]-n.points[1])/2-(t[3]-t[1])/2,y2:a?n.points[4]+i:n.points[2]+(n.points[4]-n.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=[]}};var St=class{constructor(e){o(this,"renderers",[]);o(this,"length");for(let t of e)t&&this.renderers.push(t);this.length=this.renderers.length}afterFrame(e,t,i,n){for(let s=0;s<this.length;s++)this.renderers[s].afterFrame(e,t,i,n)}afterPaintLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].afterPaintLayer(e,t)}beforeFrame(e,t,i,n){for(let s=0;s<this.length;s++)this.renderers[s].beforeFrame(e,t,i,n)}triggerResize(){for(let e=0;e<this.length;e++){let t=this.renderers[e];t.triggerResize&&t.triggerResize()}}getPointsAt(e,t,i,n){return this.renderers[0].getPointsAt(e,t,i,n)}getScale(e,t){return this.renderers[0].getScale(e,t)}getViewportBounds(e,t,i){return this.renderers[0].getViewportBounds(e,t,i)}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,i,n,s,a){for(let h=0;h<this.length;h++)this.renderers[h].paint(e,t,i,n,s,a)}pendingUpdate(){for(let e=0;e<this.length;e++)if(this.renderers[e].pendingUpdate())return!0;return!1}prepareLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].prepareLayer(e,t)}finishLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].finishLayer(e,t)}resize(e,t){for(let i=0;i<this.length;i++)this.renderers[i].resize(e,t)}reset(){for(let e=0;e<this.length;e++)this.renderers[e].reset()}};import{DnaFactory as Nn,scale as zn}from"@atlas-viewer/dna";var he=class{constructor(e){o(this,"canvas");o(this,"context");o(this,"heightRatio",1);o(this,"widthRatio",1);o(this,"target",new Float32Array(5));o(this,"initialWidth");o(this,"initialHeight");o(this,"bounds");o(this,"aggregate");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=zn(1)}isReady(){return!0}resize(){this.initialWidth=this.canvas.width,this.initialHeight=this.canvas.height,this.renderNextFrame=!0}afterFrame(e,t,i){if(this.renderNextFrame){this.context.clearRect(0,0,this.canvas.width,this.canvas.height);let n=this.initialWidth/e.width,s=this.initialHeight/e.height,a=this.widthRatio>this.heightRatio?n:s;if(this.target=i,this.bounds){let h=e.getPointsAt(this.bounds,this.aggregate,a);for(let[d,u]of h)if(d instanceof D&&d.__host.canvas){let l=u.length/5;for(let c=0;c<l;c++)if(d.__host.canvas.canvases[c]){let y={x1:u[c+1]*a,y1:u[c+2]*a,width:(u[c+3]-u[c+1])*a,height:(u[c+4]-u[c+2])*a}}}}e.getPoints().forEach((h,d,u)=>{if(d%5===0&&h){let l={x1:u[d+1]*a,y1:u[d+2]*a,x2:u[d+3]*a,y2:u[d+4]*a,width:(u[d+3]-u[d+1])*a,height:(u[d+4]-u[d+2])*a};this.context.strokeStyle="red",this.context.strokeRect(l.x1,l.y1,l.width,l.height)}}),i&&(this.context.strokeStyle="red",this.context.lineWidth=window.devicePixelRatio||1,this.context.strokeRect(i[1]*a,i[2]*a,(i[3]-i[1])*a,(i[4]-i[2])*a))}}getActiveZone(e){return null}getPointsAt(e,t,i,n){return e.getPointsAt(t,i,n)}getScale(e,t){return 1}beforeFrame(e,t){this.bounds=Nn.singleBox(e.width,e.height)}drawImage(){}afterPaintLayer(e,t){}paint(e,t,i,n,s,a){this.renderNextFrame=!0}prepareLayer(e){}pendingUpdate(){return!1}hasActiveZone(){return!1}getViewportBounds(e,t,i){return null}getRendererScreenPosition(){return this.canvas.getBoundingClientRect()}finishLayer(){}reset(){}};var Pi=class{constructor(){o(this,"autoWidth",!1);o(this,"autoHeight",!0);o(this,"width");o(this,"height");o(this,"world");o(this,"content",[]);o(this,"viewingDirection","left-to-right");o(this,"rows");o(this,"columns",4);o(this,"spacing",20);o(this,"reversed",!1);o(this,"padding",20);this.world=V.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(t=>this.world.addObjectAt(t,{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 new Error("Cannot set auto height without setting a width");if(this.autoWidth&&!this.height)throw new 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,t=()=>{if(this.autoWidth&&this.rows){let h=e>this.rows?this.rows:e;return{columns:Math.ceil(e/h),rows:h}}if(this.autoHeight&&this.columns){let h=e>this.columns?this.columns:e;return{columns:h,rows:Math.ceil(e/h)}}throw new Error("Something went wrong.")},{columns:i,rows:n}=t(),s=this.autoWidth?-1:this.width-this.padding*2,a=this.autoWidth?-1:(s-this.spacing*(i-1))/i;if(this.autoHeight&&!this.autoWidth){let h=0,d=this.padding;for(let u=0;u<n&&h!==e;u++){let l=0,c=[];for(let m=0;m<i;m++){let y=this.reversed?e-h:h;if(h===e)break;let v=this.content[y],x=v.width,P=v.width/v.height,g=a/P;c.push([h,a,g,a/x]),g>l&&(l=g),h++}for(let m=0;m<i&&c[m];m++){let y=this.world.getPoints(),v=c[m][0],x=c[m][1],P=c[m][2],g=c[m][3],f=this.padding+m*(this.spacing+x),C=d+(l-P)/2,_=this.reversed?e-v:v,S=y[_*5+1],b=y[_*5+2];this.world.scaleWorldObject(v,g),(S!==f||b!==C)&&this.world.translateWorldObject(_,f-S,C-b)}d+=l+this.spacing}this.height=d+this.padding,this.world.resize(this.width,this.height);return}this.autoWidth&&this.autoHeight,!this.autoWidth&&this.autoHeight}getWorld(){return this.world}};import Hn from"normalize-wheel";import{compose as jn,dna as Ae,scaleAtOrigin as Un,transform as Ci,translate as Ri}from"@atlas-viewer/dna";function Ei(r){return{x:r[1],y:r[2],width:r[3]-r[1],height:r[4]-r[2]}}var Ti="pan",_i="scroll",$n="gesture",Vn={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},le=(r={})=>({start:function(e){let{zoomWheelConstant:t,enableWheel:i,enableClickToZoom:n,ignoreSingleFingerTouch:s,enablePanOnWait:a,panOnWaitDelay:h,parentElement:d,requireMetaKeyForWheelZoom:u}={...Vn,...r},l={pointerStart:{x:0,y:0},isPressing:!1,mousemoveBuffer:Ae(5),multiTouch:{distance:0}};e.world.activatedEvents.push("onMouseUp","onMouseDown","onMouseMove","onTouchStart","onTouchEnd","onTouchMove");function c(){x=0,g="",C(),C(void 0,"notice"),P=0}function m(){e.world.constraintBounds(),c()}function y(w){if(w.which>1){l.isPressing=!1;return}e.mode==="explore"&&(w.preventDefault(),l.pointerStart.x=w.atlas.x,l.pointerStart.y=w.atlas.y,e.transitionManager.stopTransition(),l.isPressing=!0)}function v(){c(),l.isPressing&&(e.mode==="explore"&&e.world.constraintBounds(),l.isPressing=!1)}let x=0,P=0,g="";function f(w){if(e.mode==="explore"){if(w.atlasTouches.length===1&&(P=performance.now(),s==!1&&w.preventDefault(),l.pointerStart.x=w.atlasTouches[0].x,l.pointerStart.y=w.atlasTouches[0].y),w.atlasTouches.length===2){g=$n,w.preventDefault();let R=w.atlasTouches[0].x,A=w.atlasTouches[1].x;l.pointerStart.x=(R+A)/2;let ht=w.atlasTouches[0].y,M=w.atlasTouches[1].y;l.pointerStart.y=(ht+M)/2,x=ct({x:w.touches[0].clientX,y:w.touches[0].clientY},{x:w.touches[1].clientX,y:w.touches[1].clientY})}e.transitionManager.stopTransition(),l.isPressing=!0}}function C(w,R="intent"){d&&(d.dataset[R]=w)}function _(w){let R=null,A=null,ht=!1,M=0;if(l.isPressing&&w.touches.length===2){let X=w.touches[0].clientX,rt=w.touches[1].clientX;R=(X+rt)/2;let yt=w.touches[0].clientY,bt=w.touches[1].clientY;A=(yt+bt)/2,M=ct({x:w.touches[0].clientX,y:w.touches[0].clientY},{x:w.touches[1].clientX,y:w.touches[1].clientY}),ht=!0}if(C(g),l.isPressing&&w.touches.length===1){if(a&&(performance.now()-P<h&&g==""&&(g=_i),g==""&&(g=Ti)),C(g),g==""&&s==!0||g==_i){C("require-two-finger","notice");return}let X=w.touches[0];R=X.clientX,A=X.clientY}if(R!==null&&A!==null){let X=e.getRendererScreenPosition();if(X){let{x:rt,y:yt}=e.viewerToWorld(R-X.x,A-X.y),bt=M&&x?M/x:1;e.transitionManager.customTransition(p=>{p.from=Ae(e.target),p.to=Ci(p.from,jn(Ri(l.pointerStart.x-rt,l.pointerStart.y-yt),Un(1/bt,rt,yt)),l.mousemoveBuffer),p.elapsed_time=0,p.total_time=0,p.timingFunction=q.easeInOutExpo,p.done=!1})}x=M}g==Ti&&w.preventDefault()}function S(w){if(l.isPressing){let R=e.getRendererScreenPosition();if(R){let{x:A,y:ht}=e.viewerToWorld(w.clientX-R.x,w.clientY-R.y);e.transitionManager.customTransition(M=>{M.from=Ae(e.target),M.to=Ci(M.from,Ri(l.pointerStart.x-A,l.pointerStart.y-ht),l.mousemoveBuffer),M.elapsed_time=0,M.total_time=0,M.timingFunction=q.easeInOutExpo,M.done=!1})}}}function b(w){e.mode==="explore"&&e.world.zoomIn(w.atlas)}function O(w){let A=1+Hn(w).spinY/t;e.world.zoomTo(A,w.atlas,!0)}function W(w){return u&&w.metaKey==!1?(C("meta-required","notice"),w.stopPropagation(),!1):!0}e.world.addEventListener("mouseup",m),e.world.addEventListener("touchend",m),e.world.addEventListener("touchstart",f),e.world.addEventListener("mousedown",y),window.addEventListener("touchend",v),window.addEventListener("mouseup",v),window.addEventListener("mousemove",S),d&&d.addEventListener("touchmove",_),n&&(e.world.activatedEvents.push("onClick"),e.world.addEventListener("click",b)),i&&(e.world.activatedEvents.push("onWheel"),u&&d?.addEventListener("wheel",W,{passive:!0,capture:!0}),e.world.addEventListener("wheel",O));let N=e.world.addLayoutSubscriber((w,R)=>{if(w==="zone-changed"&&e.transitionManager.constrainBounds({transition:{duration:0}}),w==="zoom-to"&&R&&e.transitionManager.zoomTo(R.factor,{origin:R.point,stream:R.stream}),w==="go-home"){let A=R.immediate?{duration:0}:void 0;e.transitionManager.goToRegion(Ei(e.homePosition),{transition:A})}if(w==="goto-region"&&R){let A=R.immediate?{duration:0}:{};e.transitionManager.goToRegion(R,{transition:A})}w==="constrain-bounds"&&e.transitionManager.constrainBounds({transition:R?.immediate?{duration:0}:void 0})});return()=>{e.world.removeEventListener("mouseup",m),e.world.removeEventListener("touchend",m),e.world.removeEventListener("touchstart",f),e.world.removeEventListener("mousedown",y),window.removeEventListener("touchend",v),window.removeEventListener("mouseup",v),e.world.removeEventListener("mousemove",S),d&&(d.removeEventListener("touchmove",S),d.removeEventListener("wheel",W,{passive:!0,capture:!0})),n&&e.world.removeEventListener("click",b),i&&e.world.removeEventListener("wheel",O),N()}},updatePosition(){}});import{useCallback as ur,useEffect as G,useMemo as mr,useRef as ji,useState as Me}from"react";import Gn,{useContext as Zn}from"react";import{jsx as Xn}from"react/jsx-runtime";var et=Gn.createContext("explore");et.displayName="Mode";var de=()=>Zn(et);function ca(r){return Xn(et.Provider,{value:r.mode,children:r.children})}import gr from"react-use-measure";import Oi from"react";var it=Oi.createContext(null);it.displayName="Atlas";var mt=Oi.createContext(null);mt.displayName="Bounds";import Di,{useCallback as nr,useEffect as Bi,useRef as rr}from"react";import Qn from"react-reconciler";var kt,Yn=typeof performance=="object"&&typeof performance.now=="function";if(Yn){let r=performance;kt=()=>r.now()}else{let r=Date,e=r.now();kt=()=>r.now()-e}import{version as Kn}from"react";var qn=16;function Ai(r,e){r&&r.appendChild&&e&&r.appendChild(e)}function Ii(r,e){r&&r.removeChild&&e&&r.removeChild(e)}function Jn(r,e){return Ii(r.world,e)}function tr(r,e,t){return Li(r.world,e,t)}function Li(r,e,t){r&&r instanceof tt&&(r=r.world),r&&r.insertBefore&&r.insertBefore(e,t)}function ki(r,e,t){if(t&&(r.applyProps&&r.applyProps(t),r instanceof k))for(let i of At){let n=i.slice(2).toLowerCase();t[i]!==e[i]&&(e[i]&&r.removeEventListener(n,e[i]),r.addEventListener(n,t[i]))}}function Fi(r,e){let t=Object.keys(e),i=!1;for(let n of t)if(At.indexOf(n)!==-1){let s=Y[n];if(s){if(r.activatedEvents.indexOf(s)!==-1)continue;i=!0,r.activatedEvents.push(s)}}i&&r.triggerEventActivation()}var ce=new Map,Mi={};function er(r,{args:e=[],...t},i,n,s){if(!(i instanceof tt)&&s){let d=u=>u.return?d(u.return):u.stateNode&&u.stateNode.containerInfo;i=d(s)}let a,h=i.world;switch(r){case"world":a=V.withProps({width:t.width,height:t.height,viewingDirection:"left-to-right"}),a.activatedEvents=h.activatedEvents,a.eventHandlers=h.eventHandlers,a.subscriptions=h.subscriptions,a.triggerEventActivation(),h=a;break;case"box":a=new K;break;case"shape":a=new xt;break;case"worldObject":case"world-object":a=new J;break;case"worldImage":case"world-image":a=new D;break;case"texture":a=new dt;break;case"compositeImage":case"composite-image":a=new Gt({id:t.id,width:t.width,height:t.height,images:[],renderOptions:t.renderOptions});break;case"tiledImage":case"tiled-image":a=$.fromTile(t.uri,t.display,t.tile,t.scaleFactor,void 0,t.format);break;case"paragraph":a=new ot,a.text=t.children;break;default:return}return Fi(h,t),ki(a,{},t),a}function ir(r,e){if(e instanceof V)r.world=e;else if(e instanceof J)r.world.appendChild(e);else if(e)throw new Error("Invalid root")}var Ft=Qn({unstable_now:kt,now:kt,createInstance:er,removeChild:Ii,appendChild:Ai,appendInitialChild:Ai,insertBefore:Li,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:ir,removeChildFromContainer:Jn,createTextInstance(){},insertInContainerBefore:tr,prepareUpdate(r,e,t,i,n){return Fi(n.world,i),i},commitUpdate(r,e,t,i,n,s){r.applyProps&&e&&ki(r,i,e)},finalizeInitialChildren(r){return r?.__handlers},getChildHostContext(){return Mi},getRootHostContext(){return Mi},prepareForCommit(r){return r.isCommitting=!0,null},preparePortalMount(){},hideInstance(r){r&&r.points&&(r.points[0]=0)},unhideInstance(r,e){r&&r.points&&(r.points[0]=1)},getPublicInstance(r){return r},hideTextInstance(){throw new Error("Text is not allowed in the react-three-fibre tree. You may have extraneous whitespace between components.")},resetAfterCommit(r){r.isCommitting=!1,r.pendingUpdate=!0,r.world&&r.world.needsRecalculate&&(r.world.recalculateWorldSize(),r.world.triggerRepaint())},shouldSetTextContent(){return!1},clearContainer(){return!1},supportsHydration:!1,supportsPersistence:!1,detachDeletedInstance(r){},afterActiveInstanceBlur(){},beforeActiveInstanceBlur(){},getCurrentEventPriority(){return console.log("getCurrentEventPriority"),qn},getInstanceFromNode(r){throw console.log("getInstanceFromNode",r),new Error("Not implemented")},getInstanceFromScope(r){throw console.log("getInstanceFromScope",r),new Error("Not implemented")},prepareScopeUpdate(r,e){throw console.log("prepareScopeUpdate",r,e),new Error("Not implemented")},logRecoverableError(){},requestPostPaintCallback(){}});Ft.injectIntoDevTools({bundleType:0,version:Kn,rendererPackageName:"@atlas-viewer/atlas"});function Dt(r,e){let t=ce.get(r);t&&Ft.updateContainer(null,t,null,()=>{ce.delete(r),e&&e(r)})}var Bt={render(r,e){let t=ce.get(e);if(t)Ft.updateContainer(r,t,null);else{let i=Ft.createContainer(e,0,null,!1,null,"",()=>{},null);Ft.updateContainer(r,i,null),ce.set(e,i)}},unmountComponentAtNode(r,e){Dt(r,e)}};import*as ue from"react";var H=typeof window<"u"&&(window.document?.createElement||window.navigator?.product==="ReactNative")?ue.useLayoutEffect:ue.useEffect;import{jsx as Wt}from"react/jsx-runtime";var Wi=Di.memo(({children:r,setIsReady:e,onCreated:t,bounds:i,preset:n,mode:s="explore"})=>{let a=nr(function(d){let u=rr(!1),l=()=>{e(!0)};return Bi(()=>{if(n&&!u.current){n.runtime.goHome();let c=t&&t(n);return void(c&&c.then?c.then(l):l())}return()=>{}},[]),Bi(()=>{u.current=!0},[]),d.children},[n]);return H(()=>{if(n){let h=n.runtime;s!==h.mode&&(h.mode=s),Bt.render(Wt(Di.StrictMode,{children:Wt(a,{children:Wt(mt.Provider,{value:i,children:Wt(et.Provider,{value:s,children:Wt(it.Provider,{value:n,children:r})})})})}),h)}},[n,s,r]),H(()=>{if(n){let h=n.runtime;return()=>{Bt.unmountComponentAtNode(h)}}return()=>{}},[n]),null});var me=class{constructor(e,t){o(this,"canvas");o(this,"gl");o(this,"program");o(this,"fragmentShader");o(this,"vertexShader");o(this,"rectBuffer");o(this,"fragmentShaderSource",`
2
2
  precision mediump float;
3
3
 
4
4
  uniform sampler2D u_image;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlas-viewer/atlas",
3
- "version": "2.3.2",
3
+ "version": "2.3.3",
4
4
  "bugs": "https://github.com/atlas-viewer/atlas/issues",
5
5
  "repository": {
6
6
  "type": "git",