@atlas-viewer/atlas 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +7 -7
- package/dist/index.global.js +16 -27
- package/dist/index.js +7 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ws=Object.create;var Ne=Object.defineProperty;var xs=Object.getOwnPropertyDescriptor;var Ss=Object.getOwnPropertyNames;var Ps=Object.getPrototypeOf,Es=Object.prototype.hasOwnProperty;var Cs=(s,e,t)=>e in s?Ne(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var Dt=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var Ts=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ss(e))!Es.call(s,n)&&n!==t&&Ne(s,n,{get:()=>e[n],enumerable:!(i=xs(e,n))||i.enumerable});return s};var Rs=(s,e,t)=>(t=s!=null?ws(Ps(s)):{},Ts(e||!s||!s.__esModule?Ne(t,"default",{value:s,enumerable:!0}):t,s));var a=(s,e,t)=>(Cs(s,typeof e!="symbol"?e+"":e,t),t);var fn=Dt((Ah,mn)=>{"use strict";var hn=!1,yt,Ke,Je,ve,we,ln,xe,ti,ei,ii,cn,ni,si,dn,un;function j(){if(!hn){hn=!0;var s=navigator.userAgent,e=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(s),t=/(Mac OS X)|(Windows)|(Linux)/.exec(s);if(ni=/\b(iPhone|iP[ao]d)/.exec(s),si=/\b(iP[ao]d)/.exec(s),ii=/Android/i.exec(s),dn=/FBAN\/\w+;/i.exec(s),un=/Mobile/i.exec(s),cn=!!/Win64/.exec(s),e){yt=e[1]?parseFloat(e[1]):e[5]?parseFloat(e[5]):NaN,yt&&document&&document.documentMode&&(yt=document.documentMode);var i=/(?:Trident\/(\d+.\d+))/.exec(s);ln=i?parseFloat(i[1])+4:yt,Ke=e[2]?parseFloat(e[2]):NaN,Je=e[3]?parseFloat(e[3]):NaN,ve=e[4]?parseFloat(e[4]):NaN,ve?(e=/(?:Chrome\/(\d+\.\d+))/.exec(s),we=e&&e[1]?parseFloat(e[1]):NaN):we=NaN}else yt=Ke=Je=we=ve=NaN;if(t){if(t[1]){var n=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(s);xe=n?parseFloat(n[1].replace("_",".")):!0}else xe=!1;ti=!!t[2],ei=!!t[3]}else xe=ti=ei=!1}}var ri={ie:function(){return j()||yt},ieCompatibilityMode:function(){return j()||ln>yt},ie64:function(){return ri.ie()&&cn},firefox:function(){return j()||Ke},opera:function(){return j()||Je},webkit:function(){return j()||ve},safari:function(){return ri.webkit()},chrome:function(){return j()||we},windows:function(){return j()||ti},osx:function(){return j()||xe},linux:function(){return j()||ei},iphone:function(){return j()||ni},mobile:function(){return j()||ni||si||ii||un},nativeApp:function(){return j()||dn},android:function(){return j()||ii},ipad:function(){return j()||si}};mn.exports=ri});var pn=Dt((Oh,gn)=>{"use strict";var Se=!!(typeof window<"u"&&window.document&&window.document.createElement),sr={canUseDOM:Se,canUseWorkers:typeof Worker<"u",canUseEventListeners:Se&&!!(window.addEventListener||window.attachEvent),canUseViewport:Se&&!!window.screen,isInWorker:!Se};gn.exports=sr});var wn=Dt((Mh,vn)=>{"use strict";var yn=pn(),bn;yn.canUseDOM&&(bn=document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature("","")!==!0);function rr(s,e){if(!yn.canUseDOM||e&&!("addEventListener"in document))return!1;var t="on"+s,i=t in document;if(!i){var n=document.createElement("div");n.setAttribute(t,"return;"),i=typeof n[t]=="function"}return!i&&bn&&s==="wheel"&&(i=document.implementation.hasFeature("Events.wheel","3.0")),i}vn.exports=rr});var Tn=Dt((Lh,Cn)=>{"use strict";var or=fn(),ar=wn(),xn=10,Sn=40,Pn=800;function En(s){var e=0,t=0,i=0,n=0;return"detail"in s&&(t=s.detail),"wheelDelta"in s&&(t=-s.wheelDelta/120),"wheelDeltaY"in s&&(t=-s.wheelDeltaY/120),"wheelDeltaX"in s&&(e=-s.wheelDeltaX/120),"axis"in s&&s.axis===s.HORIZONTAL_AXIS&&(e=t,t=0),i=e*xn,n=t*xn,"deltaY"in s&&(n=s.deltaY),"deltaX"in s&&(i=s.deltaX),(i||n)&&s.deltaMode&&(s.deltaMode==1?(i*=Sn,n*=Sn):(i*=Pn,n*=Pn)),i&&!e&&(e=i<1?-1:1),n&&!t&&(t=n<1?-1:1),{spinX:e,spinY:t,pixelX:i,pixelY:n}}En.getEventType=function(){return or.firefox()?"DOMMouseScroll":ar("wheel")?"wheel":"mousewheel"};Cn.exports=En});var _n=Dt((Ih,Rn)=>{"use strict";Rn.exports=Tn()});var Wt=["onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onTouchCancel","onTouchEnd","onTouchMove","onTouchStart","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut","onScroll","onWheel","onClick","onDragStart","onDragEnd","onDragEnter","onDragExit","onDrag","onDragOver","onContextMenu"];function Ti(){return Wt.reduce((s,e)=>(s[e]=[],s),{})}var q=Wt.reduce((s,e)=>(s[e.slice(2).toLowerCase()]=e,s[e]=e,s),{});import{dna as je,DnaFactory as Pt,mutate as Os,translate as Ms}from"@atlas-viewer/dna";import{mutate as He,scaleAtOrigin as _s,translate as As}from"@atlas-viewer/dna";var Ri="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var K=(s=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(s));for(;s--;)e+=Ri[t[s]&63];return e};var k=class{constructor(){a(this,"__id");a(this,"__revision",0);a(this,"__host");a(this,"__onCreate");a(this,"__parent");a(this,"__owner",{value:void 0});a(this,"__state",{});a(this,"eventHandlers");a(this,"scale",1);a(this,"layers",[]);a(this,"time",[]);a(this,"_crop");a(this,"cropData");a(this,"id");a(this,"addEventListener",(e,t,i)=>{let n=q[e];if(!this.eventHandlers[n])throw new Error(`Unknown event ${n}`);this.eventHandlers[n].indexOf(t)===-1&&this.eventHandlers[n].push(t)});a(this,"removeEventListener",(e,t)=>{let i=q[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=K(),this.eventHandlers=Ti()}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,r=!1;if(n)for(let o=0;o<n;o++)try{i[o](t),r=!0}catch(h){console.error(e,h)}return r}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){He(this.points,As(e,t))}atScale(e){He(this.points,_s(e,this.x,this.y)),this.scale*=e}transform(e){He(this.points,e)}applyProps(e){this.__revision++}appendChild(e){}removeChild(e){}insertBefore(e,t){}hideInstance(){}};var z=class s extends k{constructor(t){super();a(this,"type","spacial-content");a(this,"id");a(this,"uri");a(this,"display");a(this,"points");a(this,"priority");a(this,"style",{opacity:1});if(!t)this.id="",this.uri="",this.display={x:0,y:0,scale:1,width:0,height:0,points:je(5)},this.points=je(5);else{let i=t.scale||1;this.id=t.id||t.uri,this.uri=t.uri,this.points=Pt.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:Pt.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(Pt.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 r=Pt.singleBox(t.crop.width,t.crop.height,t.crop.x,t.crop.y);Os(r,Ms(-t.crop.x,-t.crop.y)),this.crop?this.crop.set(r):this.crop=je(r)}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=Pt.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=Pt.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,r){return s.fromImage("data:image/svg+xml;base64,"+btoa(t),i,n,r)}static fromImage(t,i,n,r){let o=new s;return o.applyProps({uri:t,id:r,display:n,target:i}),o}getImageUrl(){return this.uri}};import{dna as _i,DnaFactory as qt}from"@atlas-viewer/dna";var ft=class extends k{constructor(t){super();a(this,"type","spacial-content");a(this,"id");a(this,"uri");a(this,"display");a(this,"points");a(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:_i(5)},this.points=_i(5);else{let i=t.scale||1;this.id=t.id||t.uri,this.uri=t.uri,this.points=qt.singleBox(t.width,t.height),this.display={x:0,y:0,scale:i,width:t.width/i,height:t.height/i,points:i!==1?qt.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(qt.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?qt.singleBox(t.target.width/n,t.target.height/n):this.points}getAllPointsAt(t,i,n){return[[this,this.points,i]]}};import{DnaFactory as Mi,hidePointsOutsideRegion as Ls,mutate as Li,scale as Is,transform as ks,dna as Fs,translate as Ds}from"@atlas-viewer/dna";function Ai(s,e,t=1){let i=e.length;if(i===0)throw new Error("No resources passed in.");let n=0,r=1/0;for(let o=0;o<i&&!(!e[o]||!e[o].display);o++){let h=Ue(e[o].display.scale,s/(t||1));h<r&&(r=h,n=o)}return n}function Ue(s,e){return Math.abs(s-e)}function gt(s,e){let t=Ue(s.x,e.x),i=Ue(s.y,e.y);return Math.sqrt(Math.pow(t,2)+Math.pow(i,2))}function Oi(s){let e=s.length;return s.indexOf("/info.json")===e-10?s.slice(0,-10):s}function Kt(s,e,t){return Math.min(Math.max(s,e),t)}var G=class s extends k{constructor(t){super();a(this,"id");a(this,"type","spacial-content");a(this,"display");a(this,"tileWidth");a(this,"style",{opacity:1});a(this,"points");a(this,"service");a(this,"format","jpg");a(this,"crop2");a(this,"version3");a(this,"tileUrl");this.tileUrl=Oi(t.url),this.id=t.id||`${this.tileUrl}--${t.scaleFactor}`,this.points=t.displayPoints?t.displayPoints:ks(t.points,Is(t.scaleFactor)),this.tileWidth=t.tileWidth,this.version3=t.version3,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",typeof t.version3<"u"&&(this.version3=t.version3),t.crop){this.cropData=t.crop;let i=Fs([...this.points]),n=i.length/5,r=t.crop.x||0,o=t.crop.y||0,h=t.crop.x+t.crop.width,l=t.crop.y+t.crop.height;for(let d=0;d<n;d++){let c=d*5;i[c+1]<h&&i[c+3]>r&&i[c+2]<l&&i[c+4]>o?(i[c+1]=Kt(i[c+1],r,h),i[c+3]=Kt(i[c+3],r,h),i[c+2]=Kt(i[c+2],o,l),i[c+4]=Kt(i[c+4],o,l)):i[c]=0}Li(i,Ds(-t.crop.x,-t.crop.y)),this.crop?this.crop.set(i):this.crop=i}}static fromTile(t,i,n,r,o,h,l,d){n.height=n.height?n.height:n.width;let c=l?Math.floor(i.width/r):Math.ceil(i.width/r),u=l?Math.floor(i.height/r):Math.ceil(i.height/r),m=Math.ceil(c/n.width),f=Math.ceil(u/n.height),y=Mi.grid(m,f),w=Mi.grid(m,f),v=o?o["@context"]?Array.isArray(o["@context"])?o["@context"]:[o["@context"]]:[]:[],g=typeof d<"u"?d:v.indexOf("http://iiif.io/api/image/3/context.json")!==-1;for(let E=0;E<f;E++)for(let C=0;C<m;C++){let S=C*n.width,P=E*n.height;w.addPoints(S*r,P*r,C===m-1?i.width:(S+n.width)*r,E===f-1?i.height:(P+n.height)*r),y.addPoints(S,P,C===m-1?c:S+n.width,E===f-1?u:P+n.height)}let p=new s({url:t,scaleFactor:r,points:y.build(),displayPoints:w.build(),width:i.width,height:i.height,tileWidth:n.width,format:h,version3:g});return p.applyProps({service:o}),p}getImageUrl(t){let i=this.points.slice(t*5,t*5+5),n=i[3]-i[1],r=i[4]-i[2],o=Math.ceil(n/this.display.scale),h=Math.ceil(r/this.display.scale),l=`${o>this.tileWidth?this.tileWidth:o},`;return this.version3&&(l+=`${h>this.tileWidth?this.tileWidth:h}`),`${this.tileUrl}/${i[1]},${i[2]},${n},${r}/${l}/0/default.${this.format||"jpg"}`}getAllPointsAt(t,i,n){let r=Ls(this.crop||this.points,t);return[[this,r,i]]}transform(t){Li(this.points,t)}getScheduledUpdates(t,i){return[]}};import{compose as Ws,dna as zs,DnaFactory as Ii,translate as ki}from"@atlas-viewer/dna";var Jt=class extends k{constructor(){super(...arguments);a(this,"type","spacial-content")}getAllPointsAt(t,i,n){return[[this,this.points,i]]}};var te=class extends Jt{constructor(t){super();a(this,"id");a(this,"display");a(this,"points");a(this,"images",[]);a(this,"allImages",[]);a(this,"scaleFactors",[]);a(this,"aggregateBuffer",zs(9));a(this,"lazyLoader");a(this,"isFullyLoaded",!1);a(this,"maxScaleFactor",0);a(this,"renderOptions");a(this,"_scheduleSortByScales",!1);a(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 z&&(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 r=this.images.pop();r&&(r instanceof z||r.priority)?(i.priority&&this.images.push(i),this.images.push(r)):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)});a(this,"loadFullResource",async()=>{if(!this.isFullyLoaded&&this.lazyLoader){this.isFullyLoaded=!0;let t=await this.lazyLoader();this.addImages(t)}});a(this,"fallback",[this.loadFullResource]);this.id=t.id,this.points=Ii.singleBox(t.width,t.height),this.lazyLoader=t.loadFullImages,t.loadFullImages||(this.isFullyLoaded=!0),this.display={x:0,y:0,points:Ii.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 r=Ai(1/(n||1)/(window.devicePixelRatio||1),this.images,this.renderOptions.quality),o=this.images.length,h=i?Ws(i,ki(this.x,this.y)):ki(this.x,this.y);if(r!==this.images.length-1&&this.images[r+1]){let l=[];for(let u=o-1;u>=r;u--)l.push(u);let d=l[0];this.renderOptions.renderLayers&&(l=l.slice(-Math.min(l.length,this.renderOptions.renderLayers))),this.renderOptions.renderSmallestFallback&&l.indexOf(d)===-1&&l.unshift(d);let c=[];for(let u=0;u<l.length;u++)c.push(...this.images[l[u]].getAllPointsAt(t,h,n));return c}return this.images[r].getAllPointsAt(t,h,n)}};import{compose as Wi,DnaFactory as ne,dnaLength as Ns,hidePointsOutsideRegion as zi,mutate as Bi,scale as Hs,scaleAtOrigin as js,translate as Ni,dna as pt}from"@atlas-viewer/dna";import{dna as U,compose as $e,getIntersection as Bs,scale as Fi,transform as Ve,translate as ee,hidePointsOutsideRegion as Di}from"@atlas-viewer/dna";function ie(s,e,t,i,n){let r=Math.PI/180*n,o=Math.cos(r),h=Math.sin(r),l=o*(t-s)+h*(i-e)+s,d=o*(i-e)-h*(t-s)+e;return[l,d]}var it=class s extends k{constructor(t,i){super();a(this,"id");a(this,"type","world-object");a(this,"scale");a(this,"layers");a(this,"points");a(this,"worldPoints");a(this,"intersectionBuffer",U(5));a(this,"aggregateBuffer",U(9));a(this,"invertedBuffer",U(9));a(this,"rotation",0);a(this,"filteredPointsBuffer");a(this,"_updatedList",[]);a(this,"geometry");let{x:n=0,y:r=0}=i||{};t?(this.id=t.id||"",this.scale=1,this.layers=t.layers,this.points=U([1,n,r,n+t.width,r+t.height]),this.worldPoints=U([1,n,r,n+t.width,r+t.height]),this.filteredPointsBuffer=U(t.layers.length*5)):(this.id="",this.scale=1,this.layers=[],this.points=U(5),this.worldPoints=U(5),this.filteredPointsBuffer=U(5))}static createWithProps(t){let i=new s;return i.applyProps(t),i}applyProps(t){let i=t.x||0,n=t.y||0;this.id=t.id;let r=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(r),this.scale=r}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=U(this.layers.length*5)}insertBefore(t,i){let n=this.layers.indexOf(i);if(n===-1||this.layers.indexOf(t)!==-1)return;let r=this.layers.slice(0,n),o=this.layers.slice(n);this.layers=[...r,t,...o]}hideInstance(){console.warn("hideInstance: not yet implemented")}getObjectsAt(t,i){if(this.rotation&&(t=this.applyRotation(t)),Di(this.points,t,this.filteredPointsBuffer)[0]===0)return[];let r=this.layers.length,o=[];for(let h=0;h<r;h++){let l=this.layers[h];if(i&&l.isShape){let c=Ve(l.points,ee(this.x,this.y));if(!l.intersects([t[1]-c[1],t[2]-c[2]]))continue}if(Di(Ve(l.points,ee(this.x,this.y)),t,this.filteredPointsBuffer)[0]!==0&&o.push(l),i){let c=l;o.push(...c.getObjectsAt(t,i))}}return o}applyRotation(t){if(this.rotation){let i={x:t[1],y:t[2]},n={x:t[1],y:t[4]},r={x:t[3],y:t[2]},o={x:t[3],y:t[4]},h=this.points[1]+(this.points[3]-this.points[1])/2,l=this.points[2]+(this.points[4]-this.points[2])/2,[d,c]=ie(h,l,i.x,i.y,this.rotation),[u,m]=ie(h,l,n.x,n.y,this.rotation),[f,y]=ie(h,l,r.x,r.y,this.rotation),[w,v]=ie(h,l,o.x,o.y,this.rotation),g=Math.min(d,u,f,w),p=Math.max(d,u,f,w),E=Math.min(c,m,y,v),C=Math.max(c,m,y,v);return U([t[0],g,E,p,C])}return t}getAllPointsAt(t,i,n){let r=$e(ee(this.x,this.y),Fi(this.scale),this.aggregateBuffer);this.rotation&&(t=this.applyRotation(t));let o=Bs(t,this.points,this.intersectionBuffer),h=this.layers.length,l=[],d=Ve(o,$e(Fi(1/this.scale),ee(-this.x,-this.y),this.invertedBuffer)),c=i?$e(i,r,this.aggregateBuffer):r,u=n*this.scale;for(let m=0;m<h;m++)l.push(...this.layers[m].getAllPointsAt(d,c,u));return l}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||U([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=U(this.layers.length*5)}getScheduledUpdates(t,i){let n=this.layers.length;this._updatedList=[];let r=i*this.scale;for(let o=0;o<n;o++){let h=this.layers[o].getScheduledUpdates(t,r);h&&this._updatedList.push(...h)}return this._updatedList}};var X=class s extends k{constructor(t=0,i=0,n=100,r="left-to-right"){super();a(this,"id","world");a(this,"_width");a(this,"_height");a(this,"aspectRatio");a(this,"viewingDirection");a(this,"aggregateBuffer",pt(9));a(this,"isDirty",!1);a(this,"zones",[]);a(this,"filteredPointsBuffer");a(this,"selectedZone");a(this,"triggerQueue",[]);a(this,"activatedEvents",[]);a(this,"_updatedList",[]);a(this,"translationBuffer",pt(9));a(this,"needsRecalculate",!0);a(this,"emptyPaintables",[]);a(this,"renderOrder",[]);a(this,"points");a(this,"objects",[]);a(this,"subscriptions",[]);a(this,"_propagateEventTargets",[]);a(this,"_alreadyFlushed",[]);this._width=t,this._height=i,this.aspectRatio=Number.isNaN(t/i)?1:t/i,this.viewingDirection=r,this.points=pt(n*5),this.filteredPointsBuffer=pt(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 s;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 r=[];for(let o of n)if(o.x&&o.y){let h=ne.singleBox(1,1,o.x,o.y);r.push(this.getObjectsAt(h,!0).reverse())}return r.map(o=>this.propagateEvent(t,i,o,{bubbles:!0,cancelable:!0}))}propagatePointerEvent(t,i,n,r,o={}){let h=ne.singleBox(1,1,n,r),l=this.getObjectsAt(h,!0).reverse();return this.propagateEvent(t,i,l,o)}propagateEvent(t,i,n,{bubbles:r=!1,cancelable:o=!1}={}){i.atlasTarget=this,this._propagateEventTargets.length=1,this._propagateEventTargets[0]=this;let h=!1;i.stopPropagation=()=>{h=!0};let l=n.length;for(let u=l-1;u>=0;u--){this._propagateEventTargets.unshift(n[u][0]);let m=n[u][1].length;if(m)for(let f=0;f<m;f++)this._propagateEventTargets.unshift(n[u][1][f])}let d=this._propagateEventTargets.length,c=!1;for(let u=0;u<d&&(i.atlasTarget=this._propagateEventTargets[u],i.atlasWorld=this,c=this._propagateEventTargets[u].dispatchEvent(t,i)||c,!h);u++);return c&&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 r=this.appendWorldObject(t);this.renderOrder.splice(n-1,0,r/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(Ns(this.points)===this.objects.length){let t=this.points,i=pt(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=pt(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),r=this.renderOrder.length;for(let l=0;l<r;l++){let d=this.renderOrder[l];this.objects[d]&&(i[l]=this.points[d*5+3],n[l]=this.points[d*5+4])}let o=Math.max(...i);o!==this._width&&(this._width=o,t=!0);let h=Math.max(...n);h!==this._height&&(this._height=h,t=!0),t&&this.trigger("recalculate-world-size",{width:o,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:r,y:o}=i,h=n/t.width;this.checkResizeInternalBuffer(),this.points.set(ne.singleBox(t.width,t.height,0,0),this.objects.length*5);let l=new it(t);return l.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),this.objects.push(l),this.scaleWorldObject(this.objects.length-1,h),this.translateWorldObject(this.objects.length-1,r,o),this.filteredPointsBuffer=pt(this.points.length*2),this.triggerRepaint(),this.needsRecalculate=!0,l}scaleWorldObject(t,i){Bi(this.points.subarray(t*5,t*5+5),js(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){Bi(this.points.subarray(t*5,t*5+5),Ni(i,n));let r=this.objects[t];r&&(r.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=ne.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=zi(this.points,t,this.filteredPointsBuffer),r=this.objects.length;this._updatedList=[];for(let o=0;o<r;o++)if(n[o*5]!==0){if(!this.objects[o])continue;this._updatedList.push(...this.objects[o].getScheduledUpdates(t,i))}return this._updatedList}getObjectsAt(t,i=!1){let n=this.getActiveZone(),r=zi(this.points,t,this.filteredPointsBuffer),o=this.renderOrder.length,h=[];for(let l=0;l<o;l++){let d=this.renderOrder[l];if(r[d*5]!==0){let c=this.objects[d];if(!c||n&&n.objects.indexOf(c)===-1)continue;if(c.type!=="world-object"){h.push([c,[c]]);continue}i?h.push([c,c.getObjectsAt(t,i)]):h.push([c,this.emptyPaintables])}}return h}getPointsAt(t,i,n=1){let r=this.getObjectsAt(t),o=Wi(Hs(n),Ni(-t[1],-t[2]),this.translationBuffer),h=i?Wi(i,o,this.aggregateBuffer):o,l=r.length,d=[];for(let c=0;c<l;c++)r[c]&&d.push(...r[c][0].getAllPointsAt(t,h,n));return d}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 r=0;r<n;r++)this.subscriptions[r].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 Pa(s){let{src:e,target:t}=s,i=t?t.width:s.width,n=t?t.height:s.height;return new it({id:e,height:n,width:i,layers:[z.fromImage(e,{height:n,width:i},{width:s.width,height:s.height})]})}import{dna as Us}from"@atlas-viewer/dna";var $s={margin:0},Hi=class{constructor(e,t={}){a(this,"id");a(this,"config");a(this,"points");a(this,"objects");this.id=e.map(i=>i.id).join("$$"),this.config={...$s,...t},this.points=Us(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 ji,DnaFactory as Ui}from"@atlas-viewer/dna";var se=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,re={},Vs=["backgroundColor","opacity","boxShadow","borderColor","borderWidth","borderStyle","outlineColor","outlineWidth","outlineOffset","outlineStyle"],J=class extends k{constructor(){super();a(this,"id");a(this,"type","spacial-content");a(this,"points");a(this,"hoverEvents",!1);a(this,"activeEvents",!1);a(this,"display",{x:0,y:0,scale:1,width:-1,height:-1,points:ji(5)});a(this,"_parsed",{border:{id:null,match:[]},outline:{id:null,match:[]}});a(this,"hovering");a(this,"pressing");a(this,"props",{});a(this,"addHover",()=>{this.hovering=!0,this.__revision++});a(this,"removeHover",()=>{this.hovering=!1,this.pressing=!1,this.__revision++});a(this,"addPress",()=>{this.pressing=!0,this.__revision++});a(this,"removePress",()=>{this.pressing=!1,this.__revision++});this.id=K(12),this.points=ji(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 r=re[n]||se.exec(n)||se.exec(n);r&&(this._parsed.border.id=n,this._parsed.border.match=re[n]=r)}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 r=re[t.style.outline]||se.exec(t.style.outline)||se.exec(t.style.outline);r&&(this._parsed.outline.id=t.style.outline,this._parsed.outline.match=re[t.style.outline]=r)}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 r of Vs)if(this.props.style[r]!==t.style[r]){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=Ui.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.points=Ui.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 $i,DnaFactory as Gs}from"@atlas-viewer/dna";var ht=class extends k{constructor(){super();a(this,"type","spacial-content");a(this,"id");a(this,"points");a(this,"color","#000");a(this,"backgroundColor");a(this,"hovering");a(this,"pressing");a(this,"text","");a(this,"display",{x:0,y:0,scale:1,width:100,height:100,points:$i(5)});a(this,"className");a(this,"html");a(this,"interactive",!1);a(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=$i(5)}getAllPointsAt(t,i){return[[this,this.points,i]]}applyProps({id:t,target:i,text:n,color:r,backgroundColor:o,fontSize:h=18,interactive:l,fontFamily:d="Arial, sans-serif",...c}){c.font=`${h}px ${d}`,this.interactive=l||!1,typeof n<"u"&&(this.text=n||""),r&&(this.color=r),o&&(this.backgroundColor=o),t&&(this.id=t),i&&(this.points=Gs.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,...c},this.__revision++}};import{DnaFactory as Et,mutate as Yi,scale as Qi,scaleAtOrigin as qi,transform as Ge,dna as de,translate as Zs,compose as Ys}from"@atlas-viewer/dna";import{dna as Nt,DnaFactory as Xs}from"@atlas-viewer/dna";var I=Math.pow,oe=Math.sqrt,zt=Math.sin,Vi=Math.cos,Bt=Math.PI,le=1.70158,ae=le*1.525,Gi=le+1,Xi=2*Bt/3,Zi=2*Bt/4.5,he=function(s){return s<1/2.75?7.5625*s*s:s<2/2.75?7.5625*(s-=1.5/2.75)*s+.75:s<2.5/2.75?7.5625*(s-=2.25/2.75)*s+.9375:7.5625*(s-=2.625/2.75)*s+.984375},tt={linear:s=>s,easeInQuad:function(s){return s*s},easeOutQuad:function(s){return 1-(1-s)*(1-s)},easeInOutQuad:function(s){return s<.5?2*s*s:1-I(-2*s+2,2)/2},easeInCubic:function(s){return s*s*s},easeOutCubic:function(s){return 1-I(1-s,3)},easeInOutCubic:function(s){return s<.5?4*s*s*s:1-I(-2*s+2,3)/2},easeInQuart:function(s){return s*s*s*s},easeOutQuart:function(s){return 1-I(1-s,4)},easeInOutQuart:function(s){return s<.5?8*s*s*s*s:1-I(-2*s+2,4)/2},easeInQuint:function(s){return s*s*s*s*s},easeOutQuint:function(s){return 1-I(1-s,5)},easeInOutQuint:function(s){return s<.5?16*s*s*s*s*s:1-I(-2*s+2,5)/2},easeInSine:function(s){return 1-Vi(s*Bt/2)},easeOutSine:function(s){return zt(s*Bt/2)},easeInOutSine:function(s){return-(Vi(Bt*s)-1)/2},easeInExpo:function(s){return s===0?0:I(2,10*s-10)},easeOutExpo:function(s){return s===1?1:1-I(2,-10*s)},easeInOutExpo:function(s){return s===0?0:s===1?1:s<.5?I(2,20*s-10)/2:(2-I(2,-20*s+10))/2},easeInCirc:function(s){return 1-oe(1-I(s,2))},easeOutCirc:function(s){return oe(1-I(s-1,2))},easeInOutCirc:function(s){return s<.5?(1-oe(1-I(2*s,2)))/2:(oe(1-I(-2*s+2,2))+1)/2},easeInBack:function(s){return Gi*s*s*s-le*s*s},easeOutBack:function(s){return 1+Gi*I(s-1,3)+le*I(s-1,2)},easeInOutBack:function(s){return s<.5?I(2*s,2)*((ae+1)*2*s-ae)/2:(I(2*s-2,2)*((ae+1)*(s*2-2)+ae)+2)/2},easeInElastic:function(s){return s===0?0:s===1?1:-I(2,10*s-10)*zt((s*10-10.75)*Xi)},easeOutElastic:function(s){return s===0?0:s===1?1:I(2,-10*s)*zt((s*10-.75)*Xi)+1},easeInOutElastic:function(s){return s===0?0:s===1?1:s<.5?-(I(2,20*s-10)*zt((20*s-11.125)*Zi))/2:I(2,-20*s+10)*zt((20*s-11.125)*Zi)/2+1},easeInBounce:function(s){return 1-he(1-s)},easeOutBounce:he,easeInOutBounce:function(s){return s<.5?(1-he(1-2*s))/2:(1+he(2*s-1))/2}};var ce=class{constructor(e){a(this,"runtime");a(this,"pendingTransition");a(this,"lastZoomTo",null);a(this,"isConstraining",!1);a(this,"lastGoToRegion",null);this.runtime=e,this.pendingTransition={from:Nt(5),to:Nt(5),elapsed_time:0,done:!0,total_time:0,timingFunction:tt.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=Nt(this.runtime.target),this.pendingTransition.to=Nt(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,r=i.total_time===0?1:n===0?0:i.timingFunction(n);e[1]=i.from[1]+(i.to[1]-i.from[1])*r,e[2]=i.from[2]+(i.to[2]-i.from[2])*r,e[3]=i.from[3]+(i.to[3]-i.from[3])*r,e[4]=i.from[4]+(i.to[4]-i.from[4])*r,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:tt.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:r}=t;this.lastZoomTo={factor:e,options:t};let o=this.runtime.getZoomedPosition(e,{origin:i}),h=Math.abs(1-e);this.applyTransition(o,r,{duration:2e3*h,easing:tt.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:tt.easeOutQuart,constrain:!1,callback:()=>{this.isConstraining=!1}}),this.runtime.updateNextFrame())}applyTransition(e,t,i,{stream:n}={}){this.pendingTransition.from=Nt(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||tt.easeInOutSine}goToRegion(e,{transition:t}={}){this.lastGoToRegion={target:e,options:{transition:t}};let i=this.runtime.clampRegion(e);this.applyTransition(Xs.singleBox(i.width,i.height,i.x,i.y),t,{duration:1e3,easing:tt.easeOutExpo,constrain:!0,callback:()=>{this.lastGoToRegion=null}}),this.runtime.updateNextFrame()}};var qa=Number.MIN_VALUE+1,nt=class{constructor(e,t,i,n=[],r){a(this,"id",K());a(this,"ready",!1);a(this,"renderer");a(this,"world");a(this,"target");a(this,"homePosition");a(this,"manualHomePosition");a(this,"manualFocalPosition");a(this,"focalPosition");a(this,"transitionManager");a(this,"aggregate");a(this,"transformBuffer",de(500));a(this,"lastTarget",de(5));a(this,"zoomBuffer",de(5));a(this,"logNextRender",!1);a(this,"pendingUpdate",!0);a(this,"isCommitting",!1);a(this,"firstRender",!0);a(this,"lastTime");a(this,"stopId");a(this,"mode","explore");a(this,"controllers",[]);a(this,"controllersRunning",!1);a(this,"controllerStopFunctions",[]);a(this,"maxScaleFactor",1);a(this,"_viewerToWorld",{x:0,y:0});a(this,"_lastGoodScale",1);a(this,"hooks",{useFrame:[],useBeforeFrame:[],useAfterPaint:[],useAfterFrame:[]});a(this,"fpsLimit");a(this,"options");a(this,"hookOptions",{filters:{grayscale:0,contrast:0,brightness:0,saturate:0,sepia:0,invert:0,hueRotate:0,blur:0}});a(this,"_viewport",{x:0,y:0,width:0,height:0});a(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});a(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 r=this.getScaleFactor(),o=this.renderer.getPointsAt(this.world,this.target,this.aggregate,r),h=o.length;for(let c=0;c<h;c++){let u=o[c][0],m=o[c][1],f=o[c][2],y=f?Ge(m,f,this.transformBuffer):m;this.renderer.prepareLayer(u,u.__parent&&f?Ge(u.__parent.crop||u.__parent.points,f):y);let w=y.length/5;for(let v=0;v<w;v++){let g=v*5;y[g]!==0&&(this.renderer.paint(u,v,y[g+1],y[g+2],y[g+3]-y[g+1],y[g+4]-y[g+2]),this.hook("useAfterPaint",u))}this.renderer.finishLayer(u,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 l=this.world.getScheduledUpdates(this.target,r),d=l.length;if(d>0)for(let c=0;c<d;c++){let u=l[d-c-1]();u?u.then(()=>{this.pendingUpdate=!0}):this.pendingUpdate=!0}});this.renderer=e,this.world=t,this.options={maxOverZoom:1,maxUnderZoom:1,visibilityRatio:1.5,...r||{}},this.target=Et.projection(i),this.manualHomePosition=!1,this.pendingUpdate=!0,this.homePosition=Et.projection(this.world),this.manualFocalPosition=!1,this.focalPosition=this.target,this.updateFocalPosition(),this.transitionManager=new ce(this),this.aggregate=Qi(1),this.world.addLayoutSubscriber(o=>{o==="repaint"&&(this.pendingUpdate=!0),o==="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(Et.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,r=this.height*t,o=i.width/n,h=i.height/r,l=n/r;if(e.cover?o>h:o<h){let d=l*i.height,c=(d-i.width)/2;this.target[1]=Math.round(-c+i.x),this.target[2]=Math.round(i.y),this.target[3]=Math.round(d-c+i.x),this.target[4]=Math.round(i.height+i.y)}else{let d=i.width/l,c=(d-i.height)/2;this.target[1]=Math.round(i.x),this.target[2]=Math.round(i.y-c),this.target[3]=Math.round(i.x+i.width),this.target[4]=Math.round(i.y+d-c)}this.constrainBounds(this.target),this.updateControllerPosition()}resize(e,t,i,n){this.transitionManager.hasPending()&&this.transitionManager.stopTransition(),this.updateFocalPosition(e-t,i-n);let r=t/e,o=n/i;this.target[3]=this.target[1]+(this.target[3]-this.target[1])*r,this.target[4]=this.target[2]+(this.target[4]-this.target[2])*o,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,r=Math.min(i,n),o=0,h=0,l=this.x+o,d=this.y+h;if(i<n){let c=this.height-this.width;this.focalPosition=Et.projection({x:l,y:d+c/2,width:r-o*2,height:r-h*2}),this.pendingUpdate=!0}else{let c=this.width-this.height;this.focalPosition=Et.projection({x:l+c/2,y:d,width:r-o*2,height:r-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:r,minY:o,maxY:h}=this.getBounds({target:e,padding:t}),l=!1,d=i?e:de(e),c=Math.round(e[3]-e[1]),u=Math.round(e[4]-e[2]);return n>e[1]&&(l=!0,d[1]=n,d[3]=n+c),o>e[2]&&(l=!0,d[2]=o,d[4]=o+u),r<e[1]&&(l=!0,d[1]=r,d[3]=r+c),h<e[2]&&(l=!0,d[2]=h,d[4]=h+u),[l,d]}getBounds(e){let t=e.target||this.target,i=e.padding,n=this.options.visibilityRatio,r=Math.abs(1-n);if(this.world.hasActiveZone()){let p=this.world.getActiveZone();if(p){let E=t[3]-t[1]<p.points[3]-p.points[1],C=t[4]-t[2]<p.points[4]-p.points[2];return{minX:E?p.points[1]-i:p.points[1]+(p.points[3]-p.points[1])/2-(t[3]-t[1])/2,maxX:C?p.points[2]-i:p.points[2]+(p.points[4]-p.points[2])/2-(t[4]-t[2])/2,minY:E?p.points[3]+i:p.points[1]+(p.points[3]-p.points[1])/2-(t[3]-t[1])/2,maxY:C?p.points[4]+i:p.points[2]+(p.points[4]-p.points[2])/2-(t[4]-t[2])/2}}}let o=t[3]-t[1],h=this.world.width,l=-o*r,d=h-o-l,c=t[4]-t[2],u=this.world.height,m=-c*r,f=u-c-m,y=Math.round(Math.max(l,d)),w=Math.round(Math.min(l,d)),v=Math.round(Math.max(m,f)),g=Math.round(Math.min(m,f));return{minX:w,maxX:y,minY:g,maxY:v}}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,r=n?this.renderer.getScale(n.width,n.height):this.getScaleFactor(),o=n?n.width:this.width,h=n?n.height:this.height,l=this.getRendererScreenPosition()?.width,d=this.world.width,c=l?l/d:1,u=this.options.maxUnderZoom,m=Math.max(c||1,this.options.maxOverZoom),f=1/e,y=r*f;if(f<1){let g=o*r,p=h*r,E=this.world.width/g,C=this.world.height/p;if(E>C){let S=this.world.width*y,A=~~(o*r)*u;S<A&&(e=this.world.width*r/(o*r*u))}else{let S=this.world.height*y,A=~~(h*r)*u;S<A&&(e=this.world.height*r/(h*r*u))}}else y>m&&(e=r/m);let v=Ge(this.target,qi(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(v,{ref:!0,panPadding:100}),v}clampRegion({x:e,y:t,width:i,height:n,padding:r=0}){let o=this.width,h=this.height,l=i/o<n/h,d=e-r,c=t-r,u=i+r*2,m=n+r*2;if(l){let y=m/h*o;return{x:d-(y-u)/2,y:c,width:y,height:m}}let f=u/o*h;return{x:d,y:c-(f-m)/2,width:u,height:f}}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 r=Et.singleBox(i,n,e,t);return Yi(r,Ys(Qi(this.getScaleFactor()),Zs(-this.target[1],-this.target[2]))),{x:r[1],y:r[2],width:r[3]-r[1],height:r[4]-r[2],strand:r}}setScale(e,t){Yi(this.target,qi(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 Ki,DnaFactory as Ji}from"@atlas-viewer/dna";var ue=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,me={},Qs=["backgroundColor","opacity","boxShadow","borderColor","borderWidth","borderStyle","outlineColor","outlineWidth","outlineOffset","outlineStyle"],Ct=class extends k{constructor(){super();a(this,"id");a(this,"type","spacial-content");a(this,"isShape",!0);a(this,"points");a(this,"hoverEvents",!1);a(this,"activeEvents",!1);a(this,"display",{x:0,y:0,scale:1,width:-1,height:-1,points:Ki(5)});a(this,"boundingBox",null);a(this,"_parsed",{border:{id:null,match:[]},outline:{id:null,match:[]}});a(this,"hovering");a(this,"pressing");a(this,"props",{});a(this,"shape",{type:"none"});a(this,"addHover",()=>{this.hovering=!0,this.__revision++});a(this,"removeHover",()=>{this.hovering=!1,this.pressing=!1,this.__revision++});a(this,"addPress",()=>{this.pressing=!0,this.__revision++});a(this,"removePress",()=>{this.pressing=!1,this.__revision++});this.id=K(12),this.points=Ki(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])),r=Math.max(0,...t.map(h=>h[0])),o=Math.max(0,...t.map(h=>h[1]));this.boundingBox={x:i,y:n,width:r-i,height:o-n};return}this.boundingBox=null}intersects(t){if(!t||this.shape.type==="none")return!1;let[i,n]=t,r=this.shape.points,o=this.boundingBox;if(o||(this.updateBoundingBox(),o=this.boundingBox),!o||i<o.x||i>o.x+o.width||n<o.y||n>o.height+o.y)return!1;let h=!1;for(let l=0,d=r.length-1;l<r.length;d=l++)r[l][1]>n!=r[d][1]>n&&i<(r[d][0]-r[l][0])*(n-r[l][1])/(r[d][1]-r[l][1])+r[l][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,r=t.points.length;for(let o=0;o<r;o++)if(t.points[o][0]!==this.shape.points[o][0]||t.points[o][1]!==this.shape.points[o][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 r=me[n]||ue.exec(n)||ue.exec(n);r&&(this._parsed.border.id=n,this._parsed.border.match=me[n]=r)}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 r=me[t.style.outline]||ue.exec(t.style.outline)||ue.exec(t.style.outline);r&&(this._parsed.outline.id=t.style.outline,this._parsed.outline.match=me[t.style.outline]=r)}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 r of Qs)if(this.props.style[r]!==t.style[r]){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=Ji.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.points=Ji.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++}};var Ht=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,qs=typeof AbortController=="function",fe=qs?AbortController:class{constructor(){this.signal=new tn}abort(e=new Error("This operation was aborted")){this.signal.reason=this.signal.reason||e,this.signal.aborted=!0,this.signal.dispatchEvent({type:"abort",target:this.signal})}},Ks=typeof AbortSignal=="function",Js=typeof fe.AbortSignal=="function",tn=Ks?AbortSignal:Js?fe.AbortController:class{constructor(){this.reason=void 0,this.aborted=!1,this._listeners=[]}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,this.onabort(e),this._listeners.forEach(t=>t(e),this))}onabort(){}addEventListener(e,t){e==="abort"&&this._listeners.push(t)}removeEventListener(e,t){e==="abort"&&(this._listeners=this._listeners.filter(i=>i!==t))}},Qe=new Set,Xe=(s,e)=>{let t=`LRU_CACHE_OPTION_${s}`;ge(t)&&qe(t,`${s} option`,`options.${e}`,Rt)},Ze=(s,e)=>{let t=`LRU_CACHE_METHOD_${s}`;if(ge(t)){let{prototype:i}=Rt,{get:n}=Object.getOwnPropertyDescriptor(i,s);qe(t,`${s} method`,`cache.${e}()`,n)}},tr=(s,e)=>{let t=`LRU_CACHE_PROPERTY_${s}`;if(ge(t)){let{prototype:i}=Rt,{get:n}=Object.getOwnPropertyDescriptor(i,s);qe(t,`${s} property`,`cache.${e}`,n)}},en=(...s)=>{typeof process=="object"&&process&&typeof process.emitWarning=="function"?process.emitWarning(...s):console.error(...s)},ge=s=>!Qe.has(s),qe=(s,e,t,i)=>{Qe.add(s);let n=`The ${e} is deprecated. Please use ${t} instead.`;en(n,"DeprecationWarning",s,i)},lt=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),nn=s=>lt(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?Tt:null:null,Tt=class extends Array{constructor(e){super(e),this.fill(0)}},Ye=class{constructor(e){if(e===0)return[];let t=nn(e);this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},Rt=class s{constructor(e={}){let{max:t=0,ttl:i,ttlResolution:n=1,ttlAutopurge:r,updateAgeOnGet:o,updateAgeOnHas:h,allowStale:l,dispose:d,disposeAfter:c,noDisposeOnSet:u,noUpdateTTL:m,maxSize:f=0,maxEntrySize:y=0,sizeCalculation:w,fetchMethod:v,fetchContext:g,noDeleteOnFetchRejection:p,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:C,allowStaleOnFetchAbort:S,ignoreFetchAbort:P}=e,{length:A,maxAge:T,stale:F}=e instanceof s?{}:e;if(t!==0&&!lt(t))throw new TypeError("max option must be a nonnegative integer");let x=t?nn(t):Array;if(!x)throw new Error("invalid max value: "+t);if(this.max=t,this.maxSize=f,this.maxEntrySize=y||this.maxSize,this.sizeCalculation=w||A,this.sizeCalculation){if(!this.maxSize&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(this.fetchMethod=v||null,this.fetchMethod&&typeof this.fetchMethod!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.fetchContext=g,!this.fetchMethod&&g!==void 0)throw new TypeError("cannot set fetchContext without fetchMethod");if(this.keyMap=new Map,this.keyList=new Array(t).fill(null),this.valList=new Array(t).fill(null),this.next=new x(t),this.prev=new x(t),this.head=0,this.tail=0,this.free=new Ye(t),this.initialFill=1,this.size=0,typeof d=="function"&&(this.dispose=d),typeof c=="function"?(this.disposeAfter=c,this.disposed=[]):(this.disposeAfter=null,this.disposed=null),this.noDisposeOnSet=!!u,this.noUpdateTTL=!!m,this.noDeleteOnFetchRejection=!!p,this.allowStaleOnFetchRejection=!!C,this.allowStaleOnFetchAbort=!!S,this.ignoreFetchAbort=!!P,this.maxEntrySize!==0){if(this.maxSize!==0&&!lt(this.maxSize))throw new TypeError("maxSize must be a positive integer if specified");if(!lt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.initializeSizeTracking()}if(this.allowStale=!!l||!!F,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!h,this.ttlResolution=lt(n)||n===0?n:1,this.ttlAutopurge=!!r,this.ttl=i||T||0,this.ttl){if(!lt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.initializeTTLTracking()}if(this.max===0&&this.ttl===0&&this.maxSize===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.max&&!this.maxSize){let _="LRU_CACHE_UNBOUNDED";ge(_)&&(Qe.add(_),en("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",_,s))}F&&Xe("stale","allowStale"),T&&Xe("maxAge","ttl"),A&&Xe("length","sizeCalculation")}getRemainingTTL(e){return this.has(e,{updateAgeOnHas:!1})?1/0:0}initializeTTLTracking(){this.ttls=new Tt(this.max),this.starts=new Tt(this.max),this.setItemTTL=(i,n,r=Ht.now())=>{if(this.starts[i]=n!==0?r:0,this.ttls[i]=n,n!==0&&this.ttlAutopurge){let o=setTimeout(()=>{this.isStale(i)&&this.delete(this.keyList[i])},n+1);o.unref&&o.unref()}},this.updateItemAge=i=>{this.starts[i]=this.ttls[i]!==0?Ht.now():0},this.statusTTL=(i,n)=>{i&&(i.ttl=this.ttls[n],i.start=this.starts[n],i.now=e||t(),i.remainingTTL=i.now+i.ttl-i.start)};let e=0,t=()=>{let i=Ht.now();if(this.ttlResolution>0){e=i;let n=setTimeout(()=>e=0,this.ttlResolution);n.unref&&n.unref()}return i};this.getRemainingTTL=i=>{let n=this.keyMap.get(i);return n===void 0?0:this.ttls[n]===0||this.starts[n]===0?1/0:this.starts[n]+this.ttls[n]-(e||t())},this.isStale=i=>this.ttls[i]!==0&&this.starts[i]!==0&&(e||t())-this.starts[i]>this.ttls[i]}updateItemAge(e){}statusTTL(e,t){}setItemTTL(e,t,i){}isStale(e){return!1}initializeSizeTracking(){this.calculatedSize=0,this.sizes=new Tt(this.max),this.removeItemSize=e=>{this.calculatedSize-=this.sizes[e],this.sizes[e]=0},this.requireSize=(e,t,i,n)=>{if(this.isBackgroundFetch(t))return 0;if(!lt(i))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(i=n(t,e),!lt(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.addItemSize=(e,t,i)=>{if(this.sizes[e]=t,this.maxSize){let n=this.maxSize-this.sizes[e];for(;this.calculatedSize>n;)this.evict(!0)}this.calculatedSize+=this.sizes[e],i&&(i.entrySize=t,i.totalCalculatedSize=this.calculatedSize)}}removeItemSize(e){}addItemSize(e,t){}requireSize(e,t,i,n){if(i||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache")}*indexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.tail;!(!this.isValidIndex(t)||((e||!this.isStale(t))&&(yield t),t===this.head));)t=this.prev[t]}*rindexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.head;!(!this.isValidIndex(t)||((e||!this.isStale(t))&&(yield t),t===this.tail));)t=this.next[t]}isValidIndex(e){return e!==void 0&&this.keyMap.get(this.keyList[e])===e}*entries(){for(let e of this.indexes())this.valList[e]!==void 0&&this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield[this.keyList[e],this.valList[e]])}*rentries(){for(let e of this.rindexes())this.valList[e]!==void 0&&this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield[this.keyList[e],this.valList[e]])}*keys(){for(let e of this.indexes())this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.keyList[e])}*rkeys(){for(let e of this.rindexes())this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.keyList[e])}*values(){for(let e of this.indexes())this.valList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.valList[e])}*rvalues(){for(let e of this.rindexes())this.valList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.valList[e])}[Symbol.iterator](){return this.entries()}find(e,t){for(let i of this.indexes()){let n=this.valList[i],r=this.isBackgroundFetch(n)?n.__staleWhileFetching:n;if(r!==void 0&&e(r,this.keyList[i],this))return this.get(this.keyList[i],t)}}forEach(e,t=this){for(let i of this.indexes()){let n=this.valList[i],r=this.isBackgroundFetch(n)?n.__staleWhileFetching:n;r!==void 0&&e.call(t,r,this.keyList[i],this)}}rforEach(e,t=this){for(let i of this.rindexes()){let n=this.valList[i],r=this.isBackgroundFetch(n)?n.__staleWhileFetching:n;r!==void 0&&e.call(t,r,this.keyList[i],this)}}get prune(){return Ze("prune","purgeStale"),this.purgeStale}purgeStale(){let e=!1;for(let t of this.rindexes({allowStale:!0}))this.isStale(t)&&(this.delete(this.keyList[t]),e=!0);return e}dump(){let e=[];for(let t of this.indexes({allowStale:!0})){let i=this.keyList[t],n=this.valList[t],r=this.isBackgroundFetch(n)?n.__staleWhileFetching:n;if(r===void 0)continue;let o={value:r};if(this.ttls){o.ttl=this.ttls[t];let h=Ht.now()-this.starts[t];o.start=Math.floor(Date.now()-h)}this.sizes&&(o.size=this.sizes[t]),e.unshift([i,o])}return e}load(e){this.clear();for(let[t,i]of e){if(i.start){let n=Date.now()-i.start;i.start=Ht.now()-n}this.set(t,i.value,i)}}dispose(e,t,i){}set(e,t,{ttl:i=this.ttl,start:n,noDisposeOnSet:r=this.noDisposeOnSet,size:o=0,sizeCalculation:h=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,status:d}={}){if(o=this.requireSize(e,t,o,h),this.maxEntrySize&&o>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=!0),this.delete(e),this;let c=this.size===0?void 0:this.keyMap.get(e);if(c===void 0)c=this.newIndex(),this.keyList[c]=e,this.valList[c]=t,this.keyMap.set(e,c),this.next[this.tail]=c,this.prev[c]=this.tail,this.tail=c,this.size++,this.addItemSize(c,o,d),d&&(d.set="add"),l=!1;else{this.moveToTail(c);let u=this.valList[c];if(t!==u){if(this.isBackgroundFetch(u)?u.__abortController.abort(new Error("replaced")):r||(this.dispose(u,e,"set"),this.disposeAfter&&this.disposed.push([u,e,"set"])),this.removeItemSize(c),this.valList[c]=t,this.addItemSize(c,o,d),d){d.set="replace";let m=u&&this.isBackgroundFetch(u)?u.__staleWhileFetching:u;m!==void 0&&(d.oldValue=m)}}else d&&(d.set="update")}if(i!==0&&this.ttl===0&&!this.ttls&&this.initializeTTLTracking(),l||this.setItemTTL(c,i,n),this.statusTTL(d,c),this.disposeAfter)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return this}newIndex(){return this.size===0?this.tail:this.size===this.max&&this.max!==0?this.evict(!1):this.free.length!==0?this.free.pop():this.initialFill++}pop(){if(this.size){let e=this.valList[this.head];return this.evict(!0),e}}evict(e){let t=this.head,i=this.keyList[t],n=this.valList[t];return this.isBackgroundFetch(n)?n.__abortController.abort(new Error("evicted")):(this.dispose(n,i,"evict"),this.disposeAfter&&this.disposed.push([n,i,"evict"])),this.removeItemSize(t),e&&(this.keyList[t]=null,this.valList[t]=null,this.free.push(t)),this.head=this.next[t],this.keyMap.delete(i),this.size--,t}has(e,{updateAgeOnHas:t=this.updateAgeOnHas,status:i}={}){let n=this.keyMap.get(e);if(n!==void 0)if(this.isStale(n))i&&(i.has="stale",this.statusTTL(i,n));else return t&&this.updateItemAge(n),i&&(i.has="hit"),this.statusTTL(i,n),!0;else i&&(i.has="miss");return!1}peek(e,{allowStale:t=this.allowStale}={}){let i=this.keyMap.get(e);if(i!==void 0&&(t||!this.isStale(i))){let n=this.valList[i];return this.isBackgroundFetch(n)?n.__staleWhileFetching:n}}backgroundFetch(e,t,i,n){let r=t===void 0?void 0:this.valList[t];if(this.isBackgroundFetch(r))return r;let o=new fe;i.signal&&i.signal.addEventListener("abort",()=>o.abort(i.signal.reason));let h={signal:o.signal,options:i,context:n},l=(f,y=!1)=>{let{aborted:w}=o.signal,v=i.ignoreFetchAbort&&f!==void 0;return i.status&&(w&&!y?(i.status.fetchAborted=!0,i.status.fetchError=o.signal.reason,v&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),w&&!v&&!y?c(o.signal.reason):(this.valList[t]===m&&(f===void 0?m.__staleWhileFetching?this.valList[t]=m.__staleWhileFetching:this.delete(e):(i.status&&(i.status.fetchUpdated=!0),this.set(e,f,h.options))),f)},d=f=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=f),c(f)),c=f=>{let{aborted:y}=o.signal,w=y&&i.allowStaleOnFetchAbort,v=w||i.allowStaleOnFetchRejection,g=v||i.noDeleteOnFetchRejection;if(this.valList[t]===m&&(!g||m.__staleWhileFetching===void 0?this.delete(e):w||(this.valList[t]=m.__staleWhileFetching)),v)return i.status&&m.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),m.__staleWhileFetching;if(m.__returned===m)throw f},u=(f,y)=>{this.fetchMethod(e,r,h).then(w=>f(w),y),o.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(f(),i.allowStaleOnFetchAbort&&(f=w=>l(w,!0)))})};i.status&&(i.status.fetchDispatched=!0);let m=new Promise(u).then(l,d);return m.__abortController=o,m.__staleWhileFetching=r,m.__returned=null,t===void 0?(this.set(e,m,{...h.options,status:void 0}),t=this.keyMap.get(e)):this.valList[t]=m,m}isBackgroundFetch(e){return e&&typeof e=="object"&&typeof e.then=="function"&&Object.prototype.hasOwnProperty.call(e,"__staleWhileFetching")&&Object.prototype.hasOwnProperty.call(e,"__returned")&&(e.__returned===e||e.__returned===null)}async fetch(e,{allowStale:t=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:h=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:d=this.noUpdateTTL,noDeleteOnFetchRejection:c=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:m=this.ignoreFetchAbort,allowStaleOnFetchAbort:f=this.allowStaleOnFetchAbort,fetchContext:y=this.fetchContext,forceRefresh:w=!1,status:v,signal:g}={}){if(!this.fetchMethod)return v&&(v.fetch="get"),this.get(e,{allowStale:t,updateAgeOnGet:i,noDeleteOnStaleGet:n,status:v});let p={allowStale:t,updateAgeOnGet:i,noDeleteOnStaleGet:n,ttl:r,noDisposeOnSet:o,size:h,sizeCalculation:l,noUpdateTTL:d,noDeleteOnFetchRejection:c,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:f,ignoreFetchAbort:m,status:v,signal:g},E=this.keyMap.get(e);if(E===void 0){v&&(v.fetch="miss");let C=this.backgroundFetch(e,E,p,y);return C.__returned=C}else{let C=this.valList[E];if(this.isBackgroundFetch(C)){let F=t&&C.__staleWhileFetching!==void 0;return v&&(v.fetch="inflight",F&&(v.returnedStale=!0)),F?C.__staleWhileFetching:C.__returned=C}let S=this.isStale(E);if(!w&&!S)return v&&(v.fetch="hit"),this.moveToTail(E),i&&this.updateItemAge(E),this.statusTTL(v,E),C;let P=this.backgroundFetch(e,E,p,y),A=P.__staleWhileFetching!==void 0,T=A&&t;return v&&(v.fetch=A&&S?"stale":"refresh",T&&S&&(v.returnedStale=!0)),T?P.__staleWhileFetching:P.__returned=P}}get(e,{allowStale:t=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:r}={}){let o=this.keyMap.get(e);if(o!==void 0){let h=this.valList[o],l=this.isBackgroundFetch(h);return this.statusTTL(r,o),this.isStale(o)?(r&&(r.get="stale"),l?(r&&(r.returnedStale=t&&h.__staleWhileFetching!==void 0),t?h.__staleWhileFetching:void 0):(n||this.delete(e),r&&(r.returnedStale=t),t?h:void 0)):(r&&(r.get="hit"),l?h.__staleWhileFetching:(this.moveToTail(o),i&&this.updateItemAge(o),h))}else r&&(r.get="miss")}connect(e,t){this.prev[t]=e,this.next[e]=t}moveToTail(e){e!==this.tail&&(e===this.head?this.head=this.next[e]:this.connect(this.prev[e],this.next[e]),this.connect(this.tail,e),this.tail=e)}get del(){return Ze("del","delete"),this.delete}delete(e){let t=!1;if(this.size!==0){let i=this.keyMap.get(e);if(i!==void 0)if(t=!0,this.size===1)this.clear();else{this.removeItemSize(i);let n=this.valList[i];this.isBackgroundFetch(n)?n.__abortController.abort(new Error("deleted")):(this.dispose(n,e,"delete"),this.disposeAfter&&this.disposed.push([n,e,"delete"])),this.keyMap.delete(e),this.keyList[i]=null,this.valList[i]=null,i===this.tail?this.tail=this.prev[i]:i===this.head?this.head=this.next[i]:(this.next[this.prev[i]]=this.next[i],this.prev[this.next[i]]=this.prev[i]),this.size--,this.free.push(i)}}if(this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return t}clear(){for(let e of this.rindexes({allowStale:!0})){let t=this.valList[e];if(this.isBackgroundFetch(t))t.__abortController.abort(new Error("deleted"));else{let i=this.keyList[e];this.dispose(t,i,"delete"),this.disposeAfter&&this.disposed.push([t,i,"delete"])}}if(this.keyMap.clear(),this.valList.fill(null),this.keyList.fill(null),this.ttls&&(this.ttls.fill(0),this.starts.fill(0)),this.sizes&&this.sizes.fill(0),this.head=0,this.tail=0,this.initialFill=1,this.free.length=0,this.calculatedSize=0,this.size=0,this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift())}get reset(){return Ze("reset","clear"),this.clear}get length(){return tr("length","size"),this.size}static get AbortController(){return fe}static get AbortSignal(){return tn}},sn=Rt;var rn=/(-?[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,on={},er=typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes("firefox"),pe={};var ye=class{constructor(e,t){a(this,"canvas");a(this,"ctx");a(this,"options");a(this,"imagesPending",0);a(this,"imagesLoaded",0);a(this,"imageIdsLoaded",[]);a(this,"frameIsRendering",!1);a(this,"pendingDrawCall",!1);a(this,"firstMeaningfulPaint",!1);a(this,"parallelTasks",8);a(this,"frameTasks",0);a(this,"loadingQueueOrdered",!0);a(this,"loadingQueue",[]);a(this,"currentTask",Promise.resolve());a(this,"tasksRunning",0);a(this,"stats");a(this,"averageJobTime",64);a(this,"lastKnownScale",1);a(this,"visible",[]);a(this,"previousVisible",[]);a(this,"rendererPosition");a(this,"dpi");a(this,"drawCalls",[]);a(this,"lastPaintedObject");a(this,"hostCache");a(this,"invalidated",[]);a(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--}))}});a(this,"_scheduled",0);a(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 sn({maxSize:1024*512*512,dispose:(i,n,r)=>{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(),r=n.width/e,o=n.height/t,h=(r<o?o:r)*(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 r=this.getCanvasDims();if(this.ctx.globalAlpha=1,this.ctx.fillStyle=this.canvas.dataset.background??"rgb(0, 0, 0)",this.ctx.fillRect(0,0,r.width,r.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 o="";n.filters.brightness&&(o+=`brightness(${~~(100+n.filters.brightness*100)}%) `),n.filters.contrast&&(o+=`contrast(${~~(100+n.filters.contrast*100)}%) `),n.filters.grayscale&&(o+=`grayscale(${~~(n.filters.grayscale*100)}%) `),n.filters.invert&&(o+=`invert(${~~(n.filters.invert*100)}%) `),n.filters.sepia&&(o+=`sepia(${~~(n.filters.sepia*100)}%) `),n.filters.saturate&&(o+=`saturate(${~~(100+n.filters.saturate*100)}%) `),n.filters.hueRotate&&(o+=`hue-rotate(${n.filters.hueRotate}deg) `),n.filters.blur&&(o+=`blur(${n.filters.blur}px) `),this.ctx.filter!==o&&(this.ctx.filter=o)}else this.ctx.filter="none"}applyTransform(e,t,i,n,r){let o=e.__owner.value;if(o&&o.rotation){this.ctx.save();let h=t+n/2,l=i+r/2;this.ctx.translate(h,l),this.ctx.rotate(o.rotation*Math.PI/180),this.ctx.translate(-h,-l),this.lastPaintedObject=o}}clearTransform(){this.lastPaintedObject&&(this.lastPaintedObject.rotation&&this.ctx.restore(),this.lastPaintedObject=void 0)}paint(e,t,i,n,r,o){let h=this.ctx.globalAlpha;if(e instanceof z||e instanceof G){if(e.display.rotation){this.ctx.save();let c=i+r/2,u=n+o/2;e.crop&&(c-=e.crop[t*5+1],u-=e.crop[t*5+2]),this.ctx.translate(c,u),this.ctx.rotate(e.display.rotation*Math.PI/180),this.ctx.translate(-c,-u)}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 c=e.__host.canvas,u=this.getCanvasDims();if((c.indices.indexOf(t)===-1||this.invalidated.indexOf(c.canvases[t])!==-1)&&this.schedulePaintToCanvas(c,e,t,gt({x:i+r/2,y:n+r/2},{x:u.width/2,y:u.height/2})),!this.firstMeaningfulPaint)return;let m=this.hostCache.get(c.canvases[t]);if(m)if(e.crop&&e.cropData){if(e.crop[t*5]){let f=[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];f[0]+=e.cropData.x/e.display.scale,f[1]+=e.cropData.y/e.display.scale;let y=e.x*this.lastKnownScale,w=e.y*this.lastKnownScale,v=[i+y,n+w,r,o];v[0]+=y,v[1]+=w,this.ctx.drawImage(m,f[0],f[1],f[2],f[3],v[0],v[1],v[2]+1,v[3]+1)}}else er?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,r+1,o+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,r+Number.MIN_VALUE+.5,o+Number.MIN_VALUE+.5)}catch{}e.display.rotation&&this.ctx.restore()}let l=e instanceof J&&this.options.box,d=e instanceof Ct&&this.options.polygon;if((l||d)&&!e.props.className&&!e.props.html&&!e.props.href){if(this.visible.push(e),e.props.style){let c=Object.assign({},e.props.style||{},e.hovering?e.props.hoverStyles:{},e.pressing?e.props.pressStyles:{}),u=e.props.relativeStyle?1:r/e.width;typeof c.opacity<"u"&&(this.ctx.globalAlpha=c.opacity);let m=0;typeof c.borderWidth<"u"&&(m=parseInt(c.borderWidth,10)*u);let f=0;typeof c.outlineWidth<"u"&&(f=parseInt(c.outlineWidth,10)*u);let y=0;if(typeof c.outlineOffset<"u"&&(y=parseInt(c.outlineOffset,10)*u),c.borderColor&&(this.ctx.strokeStyle=c.borderColor),c.boxShadow){let w=c.boxShadow.split(/,(?![^(]*\))/);for(let v of w){let g=on[v]||rn.exec(v)||rn.exec(v);on[v]=g,g&&(this.ctx.save(),this.ctx.shadowOffsetX=parseInt(g[1])*this.dpi*u,this.ctx.shadowOffsetY=parseInt(g[3])*this.dpi*u,this.ctx.shadowBlur=parseInt(g[5])*this.dpi*u,this.ctx.shadowColor=g[9],this.ctx.fillStyle="rgba(0,0,0,1)",this.ctx.fillRect(i+m,n+m,r,o),this.ctx.restore())}}if(this.ctx.fillStyle=c.backgroundColor||"transparent",this.ctx.lineWidth=m,d){let w=e.shape,v=w.points||[],g=v.length;this.ctx.beginPath();for(let p=0;p<g;p++)this.ctx.lineTo(i+v[p][0]*this.lastKnownScale,n+v[p][1]*this.lastKnownScale);w.open||this.ctx.closePath(),m&&this.ctx.stroke(),w.open||this.ctx.fill()}else m&&this.ctx.strokeRect(i+m/2,n+m/2,r+m,o+m),this.ctx.fillRect(i+m,n+m,r,o);f&&(c.outlineColor&&(this.ctx.strokeStyle=c.outlineColor),this.ctx.lineWidth=f,this.ctx.strokeRect(i-f/2-y,n-f/2-y,r+m*2+f+y*2,o+m*2+f+y*2))}this.ctx.globalAlpha=h}}loadImage(e,t,i,n=!1){if(pe[e]&&pe[e].naturalWidth>0){t(pe[e]);return}try{let r=!1;n||setTimeout(()=>{r||this.loadImage(e,t,i,!0)},3e3);let o=document.createElement("img");o.decoding="auto",o.onload=function(){r=!0,t(o),pe[e]=o,o.onload=null},this.options.crossOrigin&&(o.crossOrigin="anonymous"),o.src=e,o.complete&&o.onload({}),o.width}catch(r){console.log("image error",r),i(r)}}schedulePaintToCanvas(e,t,i,n){this.imagesPending++,e.indices.push(i);let r=`${t.id}--${t.display.scale}-${i}`,o=this.invalidated.indexOf(r);o!==-1&&this.invalidated.splice(o,1),e.canvases[i]=r,t.__host.canvas.loading=!0,this.loadingQueueOrdered=!1,this.loadingQueue.push({id:r,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 l=t.getImageUrl(i);this.loadImage(l,d=>{this.loadingQueue.push({id:r,scale:t.display.scale,distance:n,task:()=>new Promise(c=>{this.imageIdsLoaded.includes(r)||(this.imagesLoaded++,this.imageIdsLoaded.push(r)),e.loaded.push(i),e.loaded.length===e.indices.length&&(e.loading=!1);let u=t.display.points.slice(i*5,i*5+5),m=document.createElement("canvas"),f=m.getContext("2d");m.width=u[3]-u[1],m.height=u[4]-u[2],this.hostCache.set(e.canvases[i],m),this.drawCalls.push(()=>{f.drawImage(d,0,0,u[3]-u[1],u[4]-u[2]),c()})})}),h()},d=>{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 z||e instanceof G)&&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 r=t[3]-t[1]<n.points[3]-n.points[1],o=t[4]-t[2]<n.points[4]-n.points[2];return{x1:r?n.points[1]-i:n.points[1]+(n.points[3]-n.points[1])/2-(t[3]-t[1])/2,y1:o?n.points[2]-i:n.points[2]+(n.points[4]-n.points[2])/2-(t[4]-t[2])/2,x2:r?n.points[3]+i:n.points[1]+(n.points[3]-n.points[1])/2-(t[3]-t[1])/2,y2:o?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 _t=class{constructor(e){a(this,"renderers",[]);a(this,"length");for(let t of e)t&&this.renderers.push(t);this.length=this.renderers.length}afterFrame(e,t,i,n){for(let r=0;r<this.length;r++)this.renderers[r].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 r=0;r<this.length;r++)this.renderers[r].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,r,o){for(let h=0;h<this.length;h++)this.renderers[h].paint(e,t,i,n,r,o)}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 ir,scale as nr}from"@atlas-viewer/dna";var be=class{constructor(e){a(this,"canvas");a(this,"context");a(this,"heightRatio",1);a(this,"widthRatio",1);a(this,"target",new Float32Array(5));a(this,"initialWidth");a(this,"initialHeight");a(this,"bounds");a(this,"aggregate");a(this,"delta",0);a(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=nr(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,r=this.initialHeight/e.height,o=this.widthRatio>this.heightRatio?n:r;if(this.target=i,this.bounds){let h=e.getPointsAt(this.bounds,this.aggregate,o);for(let[l,d]of h)if(l instanceof z&&l.__host.canvas){let c=d.length/5;for(let u=0;u<c;u++)if(l.__host.canvas.canvases[u]){let f={x1:d[u+1]*o,y1:d[u+2]*o,width:(d[u+3]-d[u+1])*o,height:(d[u+4]-d[u+2])*o}}}}e.getPoints().forEach((h,l,d)=>{if(l%5===0&&h){let c={x1:d[l+1]*o,y1:d[l+2]*o,x2:d[l+3]*o,y2:d[l+4]*o,width:(d[l+3]-d[l+1])*o,height:(d[l+4]-d[l+2])*o};this.context.strokeStyle="red",this.context.strokeRect(c.x1,c.y1,c.width,c.height)}}),i&&(this.context.strokeStyle="red",this.context.lineWidth=window.devicePixelRatio||1,this.context.strokeRect(i[1]*o,i[2]*o,(i[3]-i[1])*o,(i[4]-i[2])*o))}}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=ir.singleBox(e.width,e.height)}drawImage(){}afterPaintLayer(e,t){}paint(e,t,i,n,r,o){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 an=class{constructor(){a(this,"autoWidth",!1);a(this,"autoHeight",!0);a(this,"width");a(this,"height");a(this,"world");a(this,"content",[]);a(this,"viewingDirection","left-to-right");a(this,"rows");a(this,"columns",4);a(this,"spacing",20);a(this,"reversed",!1);a(this,"padding",20);this.world=X.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(),r=this.autoWidth?-1:this.width-this.padding*2,o=this.autoWidth?-1:(r-this.spacing*(i-1))/i;if(this.autoHeight&&!this.autoWidth){let h=0,l=this.padding;for(let d=0;d<n&&h!==e;d++){let c=0,u=[];for(let m=0;m<i;m++){let f=this.reversed?e-h:h;if(h===e)break;let y=this.content[f],w=y.width,v=y.width/y.height,g=o/v;u.push([h,o,g,o/w]),g>c&&(c=g),h++}for(let m=0;m<i&&u[m];m++){let f=this.world.getPoints(),y=u[m][0],w=u[m][1],v=u[m][2],g=u[m][3],p=this.padding+m*(this.spacing+w),E=l+(c-v)/2,C=this.reversed?e-y:y,S=f[C*5+1],P=f[C*5+2];this.world.scaleWorldObject(y,g),(S!==p||P!==E)&&this.world.translateWorldObject(C,p-S,E-P)}l+=c+this.spacing}this.height=l+this.padding,this.world.resize(this.width,this.height);return}this.autoWidth&&this.autoHeight,!this.autoWidth&&this.autoHeight}getWorld(){return this.world}};var kn=Rs(_n(),1);import{compose as hr,dna as oi,scaleAtOrigin as lr,transform as On,translate as Mn}from"@atlas-viewer/dna";function An(s){return{x:s[1],y:s[2],width:s[3]-s[1],height:s[4]-s[2]}}var Ln="pan",In="scroll",cr="gesture",dr={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},Pe=(s={})=>({start:function(e){let{zoomWheelConstant:t,enableWheel:i,enableClickToZoom:n,ignoreSingleFingerTouch:r,enablePanOnWait:o,panOnWaitDelay:h,parentElement:l,requireMetaKeyForWheelZoom:d}={...dr,...s},c={pointerStart:{x:0,y:0},isPressing:!1,mousemoveBuffer:oi(5),multiTouch:{distance:0}};e.world.activatedEvents.push("onMouseUp","onMouseDown","onMouseMove","onTouchStart","onTouchEnd","onTouchMove","onContextMenu");function u(){w=0,g="",E(),E(void 0,"notice"),v=0}function m(){e.world.constraintBounds(),u()}function f(x){if(x.which>1){c.isPressing=!1;return}e.mode==="explore"&&(x.preventDefault(),c.pointerStart.x=x.atlas.x,c.pointerStart.y=x.atlas.y,e.transitionManager.stopTransition(),c.isPressing=!0)}function y(){u(),c.isPressing&&(e.mode==="explore"&&e.world.constraintBounds(),c.isPressing=!1)}let w=0,v=0,g="";function p(x){if(e.mode==="explore"){if(x.atlasTouches.length===1&&(v=performance.now(),r==!1&&x.preventDefault(),c.pointerStart.x=x.atlasTouches[0].x,c.pointerStart.y=x.atlasTouches[0].y),x.atlasTouches.length===2){g=cr,x.preventDefault();let _=x.atlasTouches[0].x,M=x.atlasTouches[1].x;c.pointerStart.x=(_+M)/2;let dt=x.atlasTouches[0].y,W=x.atlasTouches[1].y;c.pointerStart.y=(dt+W)/2,w=gt({x:x.touches[0].clientX,y:x.touches[0].clientY},{x:x.touches[1].clientX,y:x.touches[1].clientY})}e.transitionManager.stopTransition(),c.isPressing=!0}}function E(x,_="intent"){l&&(l.dataset[_]=x)}function C(x){let _=null,M=null,dt=!1,W=0;if(c.isPressing&&x.touches.length===2){let Q=x.touches[0].clientX,H=x.touches[1].clientX;_=(Q+H)/2;let St=x.touches[0].clientY,ut=x.touches[1].clientY;M=(St+ut)/2,W=gt({x:x.touches[0].clientX,y:x.touches[0].clientY},{x:x.touches[1].clientX,y:x.touches[1].clientY}),dt=!0}if(E(g),c.isPressing&&x.touches.length===1){if(o&&(performance.now()-v<h&&g==""&&(g=In),g==""&&(g=Ln)),E(g),g==""&&r==!0||g==In){E("require-two-finger","notice");return}let Q=x.touches[0];_=Q.clientX,M=Q.clientY}if(_!==null&&M!==null){let Q=e.getRendererScreenPosition();if(Q){let{x:H,y:St}=e.viewerToWorld(_-Q.x,M-Q.y),ut=W&&w?W/w:1;e.transitionManager.customTransition(et=>{et.from=oi(e.target),et.to=On(et.from,hr(Mn(c.pointerStart.x-H,c.pointerStart.y-St),lr(1/ut,H,St)),c.mousemoveBuffer),et.elapsed_time=0,et.total_time=0,et.timingFunction=tt.easeInOutExpo,et.done=!1})}w=W}g==Ln&&x.preventDefault()}function S(x){if(c.isPressing){let _=e.getRendererScreenPosition();if(_){let{x:M,y:dt}=e.viewerToWorld(x.clientX-_.x,x.clientY-_.y);e.transitionManager.customTransition(W=>{W.from=oi(e.target),W.to=On(W.from,Mn(c.pointerStart.x-M,c.pointerStart.y-dt),c.mousemoveBuffer),W.elapsed_time=0,W.total_time=0,W.timingFunction=tt.easeInOutExpo,W.done=!1})}}}function P(x){e.mode==="explore"&&e.world.zoomIn(x.atlas)}function A(x){let M=1+(0,kn.default)(x).spinY/t;e.world.zoomTo(M,x.atlas,!0)}function T(x){return d&&x.metaKey==!1?(E("meta-required","notice"),x.stopPropagation(),!1):!0}e.world.addEventListener("mouseup",m),e.world.addEventListener("touchend",m),e.world.addEventListener("touchstart",p),e.world.addEventListener("mousedown",f),window.addEventListener("touchend",y),window.addEventListener("mouseup",y),window.addEventListener("mousemove",S),l&&l.addEventListener("touchmove",C),n&&(e.world.activatedEvents.push("onClick"),e.world.addEventListener("click",P)),i&&(e.world.activatedEvents.push("onWheel"),d&&l?.addEventListener("wheel",T,{passive:!0,capture:!0}),e.world.addEventListener("wheel",A));let F=e.world.addLayoutSubscriber((x,_)=>{if(x==="zone-changed"&&e.transitionManager.constrainBounds({transition:{duration:0}}),x==="zoom-to"&&_&&e.transitionManager.zoomTo(_.factor,{origin:_.point,stream:_.stream}),x==="go-home"){let M=_.immediate?{duration:0}:void 0;e.transitionManager.goToRegion(An(e.homePosition),{transition:M})}if(x==="goto-region"&&_){let M=_.immediate?{duration:0}:{};e.transitionManager.goToRegion(_,{transition:M})}x==="constrain-bounds"&&e.transitionManager.constrainBounds({transition:_?.immediate?{duration:0}:void 0})});return()=>{e.world.removeEventListener("mouseup",m),e.world.removeEventListener("touchend",m),e.world.removeEventListener("touchstart",p),e.world.removeEventListener("mousedown",f),window.removeEventListener("touchend",y),window.removeEventListener("mouseup",y),e.world.removeEventListener("mousemove",S),l&&(l.removeEventListener("touchmove",S),l.removeEventListener("wheel",T,{passive:!0,capture:!0})),n&&e.world.removeEventListener("click",P),i&&e.world.removeEventListener("wheel",A),F()}},updatePosition(){}});import{memo as Fr,useCallback as Dr,useEffect as Z,useMemo as Wr,useRef as qn,useState as ai}from"react";import ur,{useContext as mr}from"react";import{jsx as fr}from"react/jsx-runtime";var st=ur.createContext("explore");st.displayName="Mode";var Ee=()=>mr(st);function jh(s){return fr(st.Provider,{value:s.mode,children:s.children})}import zr from"react-use-measure";import Fn from"react";var rt=Fn.createContext(null);rt.displayName="Atlas";var bt=Fn.createContext(null);bt.displayName="Bounds";import $n,{useCallback as Er,useEffect as Vn,useRef as Cr}from"react";import pr from"react-reconciler";import{ContinuousEventPriority as yr,DiscreteEventPriority as br,DefaultEventPriority as Dn}from"react-reconciler/constants";var jt,gr=typeof performance=="object"&&typeof performance.now=="function";if(gr){let s=performance;jt=()=>s.now()}else{let s=Date,e=s.now();jt=()=>s.now()-e}import{version as vr}from"react";function Wn(s,e){s&&s.appendChild&&e&&s.appendChild(e)}function Bn(s,e){s&&s.removeChild&&e&&s.removeChild(e)}function wr(s,e){return Bn(s.world,e)}function xr(s,e,t){return Nn(s.world,e,t)}function Nn(s,e,t){s&&s instanceof nt&&(s=s.world),s&&s.insertBefore&&s.insertBefore(e,t)}function Hn(s,e,t){if(t&&(s.applyProps&&s.applyProps(t),s instanceof k))for(let i of Wt){let n=i.slice(2).toLowerCase();t[i]!==e[i]&&(e[i]&&s.removeEventListener(n,e[i]),s.addEventListener(n,t[i]))}}function jn(s,e){let t=Object.keys(e),i=!1;for(let n of t)if(Wt.indexOf(n)!==-1){let r=q[n];if(r){if(s.activatedEvents.indexOf(r)!==-1)continue;i=!0,s.activatedEvents.push(r)}}i&&s.triggerEventActivation()}var Te=new Map,zn={};function Sr(s,{args:e=[],...t},i,n,r){if(!(i instanceof nt)&&r){let l=d=>d.return?l(d.return):d.stateNode&&d.stateNode.containerInfo;i=l(r)}let o,h=i.world;switch(s){case"world":o=X.withProps({width:t.width,height:t.height,viewingDirection:"left-to-right"}),o.activatedEvents=h.activatedEvents,o.eventHandlers=h.eventHandlers,o.subscriptions=h.subscriptions,o.triggerEventActivation(),h=o;break;case"box":o=new J;break;case"shape":o=new Ct;break;case"worldObject":case"world-object":o=new it;break;case"worldImage":case"world-image":o=new z;break;case"texture":o=new ft;break;case"compositeImage":case"composite-image":o=new te({id:t.id,width:t.width,height:t.height,images:[],renderOptions:t.renderOptions});break;case"tiledImage":case"tiled-image":o=G.fromTile(t.uri,t.display,t.tile,t.scaleFactor,void 0,t.format,t.useFloorCalc,t.version3);break;case"paragraph":o=new ht,o.text=t.children;break;default:return}return jn(h,t),Hn(o,{},t),o}function Pr(s,e){if(e instanceof X)s.world=e;else if(e instanceof it)s.world.appendChild(e);else if(e)throw new Error("Invalid root")}var Un=0,Ce=Un,Ut=pr({unstable_now:jt,now:jt,createInstance:Sr,removeChild:Bn,appendChild:Wn,appendInitialChild:Wn,insertBefore:Nn,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:Pr,removeChildFromContainer:wr,createTextInstance(){},insertInContainerBefore:xr,prepareUpdate(s,e,t,i,n){return jn(n.world,i),i},commitUpdate(s,e,t,i,n,r){s.applyProps&&t&&Hn(s,i,t)},finalizeInitialChildren(s){return s?.__handlers},getChildHostContext(){return zn},getRootHostContext(){return zn},prepareForCommit(s){return s.isCommitting=!0,null},preparePortalMount(){},hideInstance(s){s&&s.points&&(s.points[0]=0)},unhideInstance(s,e){s&&s.points&&(s.points[0]=1)},getPublicInstance(s){return s},hideTextInstance(){throw new Error("Text is not allowed in the react-three-fibre tree. You may have extraneous whitespace between components.")},resetAfterCommit(s){s.isCommitting=!1,s.pendingUpdate=!0,s.world&&s.world.needsRecalculate&&(s.world.recalculateWorldSize(),s.world.triggerRepaint())},shouldSetTextContent(){return!1},clearContainer(){return!1},supportsHydration:!1,supportsPersistence:!1,detachDeletedInstance(s){},afterActiveInstanceBlur(){},beforeActiveInstanceBlur(){},getCurrentEventPriority(){return Dn},getInstanceFromNode(s){throw new Error("Not implemented")},getInstanceFromScope(s){throw new Error("Not implemented")},prepareScopeUpdate(s,e){throw new Error("Not implemented")},logRecoverableError(){},requestPostPaintCallback(){},rendererPackageName:"@atlas-viewer/atlas",rendererVersion:vr,shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent:()=>{},resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,maySuspendCommit:()=>!1,preloadInstance:()=>!0,startSuspendingCommit(){},suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,setCurrentUpdatePriority(s){Ce=s},getCurrentUpdatePriority(){return Ce},resolveUpdatePriority(){if(Ce!==Un)return Ce;switch(typeof window<"u"&&window.event?.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return br;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return yr;default:return Dn}},resetFormInstance(){}});Ut.injectIntoDevTools();function $t(s,e){let t=Te.get(s);t&&Ut.updateContainer(null,t,null,()=>{Te.delete(s),e&&e(s)})}var Vt={render(s,e){let t=Te.get(e);if(t)Ut.updateContainer(s,t,null);else{let i=Ut.createContainer(e,0,null,!1,null,"",()=>{},null);Ut.updateContainer(s,i,null),Te.set(e,i)}},unmountComponentAtNode(s,e){$t(s,e)}};import*as Re from"react";var $=typeof window<"u"&&(window.document?.createElement||window.navigator?.product==="ReactNative")?Re.useLayoutEffect:Re.useEffect;import{jsx as Gt}from"react/jsx-runtime";var Gn=$n.memo(({children:s,setIsReady:e,onCreated:t,bounds:i,preset:n,mode:r="explore"})=>{let o=Er(function(l){let d=Cr(!1),c=()=>{e(!0)};return Vn(()=>{if(n&&!d.current){n.runtime.goHome();let u=t&&t(n);return void(u&&u.then?u.then(c):c())}return()=>{}},[]),Vn(()=>{d.current=!0},[]),l.children},[n]);return $(()=>{if(n){let h=n.runtime;r!==h.mode&&(h.mode=r),Vt.render(Gt($n.StrictMode,{children:Gt(o,{children:Gt(bt.Provider,{value:i,children:Gt(st.Provider,{value:r,children:Gt(rt.Provider,{value:n,children:s})})})})}),h)}},[n,r,s]),$(()=>{if(n){let h=n.runtime;return()=>{Vt.unmountComponentAtNode(h)}}return()=>{}},[n]),null});var _e=class{constructor(e,t){a(this,"canvas");a(this,"gl");a(this,"program");a(this,"fragmentShader");a(this,"vertexShader");a(this,"rectBuffer");a(this,"fragmentShaderSource",`
|
|
1
|
+
var wr=Object.create;var Ne=Object.defineProperty;var xr=Object.getOwnPropertyDescriptor;var Sr=Object.getOwnPropertyNames;var Pr=Object.getPrototypeOf,Er=Object.prototype.hasOwnProperty;var Cr=(r,e,t)=>e in r?Ne(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var Dt=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Tr=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Sr(e))!Er.call(r,n)&&n!==t&&Ne(r,n,{get:()=>e[n],enumerable:!(i=xr(e,n))||i.enumerable});return r};var Rr=(r,e,t)=>(t=r!=null?wr(Pr(r)):{},Tr(e||!r||!r.__esModule?Ne(t,"default",{value:r,enumerable:!0}):t,r));var a=(r,e,t)=>(Cr(r,typeof e!="symbol"?e+"":e,t),t);var fn=Dt((Ah,mn)=>{"use strict";var hn=!1,yt,Ke,Je,ve,we,ln,xe,ti,ei,ii,cn,ni,ri,dn,un;function j(){if(!hn){hn=!0;var r=navigator.userAgent,e=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(r),t=/(Mac OS X)|(Windows)|(Linux)/.exec(r);if(ni=/\b(iPhone|iP[ao]d)/.exec(r),ri=/\b(iP[ao]d)/.exec(r),ii=/Android/i.exec(r),dn=/FBAN\/\w+;/i.exec(r),un=/Mobile/i.exec(r),cn=!!/Win64/.exec(r),e){yt=e[1]?parseFloat(e[1]):e[5]?parseFloat(e[5]):NaN,yt&&document&&document.documentMode&&(yt=document.documentMode);var i=/(?:Trident\/(\d+.\d+))/.exec(r);ln=i?parseFloat(i[1])+4:yt,Ke=e[2]?parseFloat(e[2]):NaN,Je=e[3]?parseFloat(e[3]):NaN,ve=e[4]?parseFloat(e[4]):NaN,ve?(e=/(?:Chrome\/(\d+\.\d+))/.exec(r),we=e&&e[1]?parseFloat(e[1]):NaN):we=NaN}else yt=Ke=Je=we=ve=NaN;if(t){if(t[1]){var n=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(r);xe=n?parseFloat(n[1].replace("_",".")):!0}else xe=!1;ti=!!t[2],ei=!!t[3]}else xe=ti=ei=!1}}var si={ie:function(){return j()||yt},ieCompatibilityMode:function(){return j()||ln>yt},ie64:function(){return si.ie()&&cn},firefox:function(){return j()||Ke},opera:function(){return j()||Je},webkit:function(){return j()||ve},safari:function(){return si.webkit()},chrome:function(){return j()||we},windows:function(){return j()||ti},osx:function(){return j()||xe},linux:function(){return j()||ei},iphone:function(){return j()||ni},mobile:function(){return j()||ni||ri||ii||un},nativeApp:function(){return j()||dn},android:function(){return j()||ii},ipad:function(){return j()||ri}};mn.exports=si});var pn=Dt((Oh,gn)=>{"use strict";var Se=!!(typeof window<"u"&&window.document&&window.document.createElement),rs={canUseDOM:Se,canUseWorkers:typeof Worker<"u",canUseEventListeners:Se&&!!(window.addEventListener||window.attachEvent),canUseViewport:Se&&!!window.screen,isInWorker:!Se};gn.exports=rs});var wn=Dt((Lh,vn)=>{"use strict";var yn=pn(),bn;yn.canUseDOM&&(bn=document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature("","")!==!0);function ss(r,e){if(!yn.canUseDOM||e&&!("addEventListener"in document))return!1;var t="on"+r,i=t in document;if(!i){var n=document.createElement("div");n.setAttribute(t,"return;"),i=typeof n[t]=="function"}return!i&&bn&&r==="wheel"&&(i=document.implementation.hasFeature("Events.wheel","3.0")),i}vn.exports=ss});var Tn=Dt((Mh,Cn)=>{"use strict";var os=fn(),as=wn(),xn=10,Sn=40,Pn=800;function En(r){var e=0,t=0,i=0,n=0;return"detail"in r&&(t=r.detail),"wheelDelta"in r&&(t=-r.wheelDelta/120),"wheelDeltaY"in r&&(t=-r.wheelDeltaY/120),"wheelDeltaX"in r&&(e=-r.wheelDeltaX/120),"axis"in r&&r.axis===r.HORIZONTAL_AXIS&&(e=t,t=0),i=e*xn,n=t*xn,"deltaY"in r&&(n=r.deltaY),"deltaX"in r&&(i=r.deltaX),(i||n)&&r.deltaMode&&(r.deltaMode==1?(i*=Sn,n*=Sn):(i*=Pn,n*=Pn)),i&&!e&&(e=i<1?-1:1),n&&!t&&(t=n<1?-1:1),{spinX:e,spinY:t,pixelX:i,pixelY:n}}En.getEventType=function(){return os.firefox()?"DOMMouseScroll":as("wheel")?"wheel":"mousewheel"};Cn.exports=En});var _n=Dt((Ih,Rn)=>{"use strict";Rn.exports=Tn()});var Wt=["onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onTouchCancel","onTouchEnd","onTouchMove","onTouchStart","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut","onScroll","onWheel","onClick","onDragStart","onDragEnd","onDragEnter","onDragExit","onDrag","onDragOver","onContextMenu"];function Ti(){return Wt.reduce((r,e)=>(r[e]=[],r),{})}var q=Wt.reduce((r,e)=>(r[e.slice(2).toLowerCase()]=e,r[e]=e,r),{});import{dna as je,DnaFactory as Pt,mutate as Or,translate as Lr}from"@atlas-viewer/dna";import{mutate as He,scaleAtOrigin as _r,translate as Ar}from"@atlas-viewer/dna";var Ri="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var K=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=Ri[t[r]&63];return e};var k=class{constructor(){a(this,"__id");a(this,"__revision",0);a(this,"__host");a(this,"__onCreate");a(this,"__parent");a(this,"__owner",{value:void 0});a(this,"__state",{});a(this,"eventHandlers");a(this,"scale",1);a(this,"layers",[]);a(this,"time",[]);a(this,"_crop");a(this,"cropData");a(this,"id");a(this,"addEventListener",(e,t,i)=>{let n=q[e];if(!this.eventHandlers[n])throw new Error(`Unknown event ${n}`);this.eventHandlers[n].indexOf(t)===-1&&this.eventHandlers[n].push(t)});a(this,"removeEventListener",(e,t)=>{let i=q[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=K(),this.eventHandlers=Ti()}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 o=0;o<n;o++)try{i[o](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){He(this.points,Ar(e,t))}atScale(e){He(this.points,_r(e,this.x,this.y)),this.scale*=e}transform(e){He(this.points,e)}applyProps(e){this.__revision++}appendChild(e){}removeChild(e){}insertBefore(e,t){}hideInstance(){}};var z=class r extends k{constructor(t){super();a(this,"type","spacial-content");a(this,"id");a(this,"uri");a(this,"display");a(this,"points");a(this,"priority");a(this,"style",{opacity:1});if(!t)this.id="",this.uri="",this.display={x:0,y:0,scale:1,width:0,height:0,points:je(5)},this.points=je(5);else{let i=t.scale||1;this.id=t.id||t.uri,this.uri=t.uri,this.points=Pt.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:Pt.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(Pt.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=Pt.singleBox(t.crop.width,t.crop.height,t.crop.x,t.crop.y);Or(s,Lr(-t.crop.x,-t.crop.y)),this.crop?this.crop.set(s):this.crop=je(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=Pt.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=Pt.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 o=new r;return o.applyProps({uri:t,id:s,display:n,target:i}),o}getImageUrl(){return this.uri}};import{dna as _i,DnaFactory as qt}from"@atlas-viewer/dna";var ft=class extends k{constructor(t){super();a(this,"type","spacial-content");a(this,"id");a(this,"uri");a(this,"display");a(this,"points");a(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:_i(5)},this.points=_i(5);else{let i=t.scale||1;this.id=t.id||t.uri,this.uri=t.uri,this.points=qt.singleBox(t.width,t.height),this.display={x:0,y:0,scale:i,width:t.width/i,height:t.height/i,points:i!==1?qt.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(qt.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?qt.singleBox(t.target.width/n,t.target.height/n):this.points}getAllPointsAt(t,i,n){return[[this,this.points,i]]}};import{DnaFactory as Li,hidePointsOutsideRegion as Mr,mutate as Mi,scale as Ir,transform as kr,dna as Fr,translate as Dr}from"@atlas-viewer/dna";function Ai(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 o=0;o<i&&!(!e[o]||!e[o].display);o++){let h=Ue(e[o].display.scale,r/(t||1));h<s&&(s=h,n=o)}return n}function Ue(r,e){return Math.abs(r-e)}function gt(r,e){let t=Ue(r.x,e.x),i=Ue(r.y,e.y);return Math.sqrt(Math.pow(t,2)+Math.pow(i,2))}function Oi(r){let e=r.length;return r.indexOf("/info.json")===e-10?r.slice(0,-10):r}function Kt(r,e,t){return Math.min(Math.max(r,e),t)}var G=class r extends k{constructor(t){super();a(this,"id");a(this,"type","spacial-content");a(this,"display");a(this,"tileWidth");a(this,"style",{opacity:1});a(this,"points");a(this,"service");a(this,"format","jpg");a(this,"crop2");a(this,"version3");a(this,"tileUrl");this.tileUrl=Oi(t.url),this.id=t.id||`${this.tileUrl}--${t.scaleFactor}`,this.points=t.displayPoints?t.displayPoints:kr(t.points,Ir(t.scaleFactor)),this.tileWidth=t.tileWidth,this.version3=t.version3,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",typeof t.version3<"u"&&(this.version3=t.version3),t.crop){this.cropData=t.crop;let i=Fr([...this.points]),n=i.length/5,s=t.crop.x||0,o=t.crop.y||0,h=t.crop.x+t.crop.width,l=t.crop.y+t.crop.height;for(let d=0;d<n;d++){let c=d*5;i[c+1]<h&&i[c+3]>s&&i[c+2]<l&&i[c+4]>o?(i[c+1]=Kt(i[c+1],s,h),i[c+3]=Kt(i[c+3],s,h),i[c+2]=Kt(i[c+2],o,l),i[c+4]=Kt(i[c+4],o,l)):i[c]=0}Mi(i,Dr(-t.crop.x,-t.crop.y)),this.crop?this.crop.set(i):this.crop=i}}static fromTile(t,i,n,s,o,h,l,d){n.height=n.height?n.height:n.width;let c=l?Math.floor(i.width/s):Math.ceil(i.width/s),u=l?Math.floor(i.height/s):Math.ceil(i.height/s),m=Math.ceil(c/n.width),f=Math.ceil(u/n.height),y=Li.grid(m,f),w=Li.grid(m,f),v=o?o["@context"]?Array.isArray(o["@context"])?o["@context"]:[o["@context"]]:[]:[],g=typeof d<"u"?d:v.indexOf("http://iiif.io/api/image/3/context.json")!==-1;for(let E=0;E<f;E++)for(let C=0;C<m;C++){let S=C*n.width,P=E*n.height;w.addPoints(S*s,P*s,C===m-1?i.width:(S+n.width)*s,E===f-1?i.height:(P+n.height)*s),y.addPoints(S,P,C===m-1?c:S+n.width,E===f-1?u:P+n.height)}let p=new r({url:t,scaleFactor:s,points:y.build(),displayPoints:w.build(),width:i.width,height:i.height,tileWidth:n.width,format:h,version3:g});return p.applyProps({service:o}),p}getImageUrl(t){let i=this.points.slice(t*5,t*5+5),n=i[3]-i[1],s=i[4]-i[2],o=Math.ceil(n/this.display.scale),h=Math.ceil(s/this.display.scale),l=`${o>this.tileWidth?this.tileWidth:o},`;return this.version3&&(l+=`${h>this.tileWidth?this.tileWidth:h}`),`${this.tileUrl}/${i[1]},${i[2]},${n},${s}/${l}/0/default.${this.format||"jpg"}`}getAllPointsAt(t,i,n){let s=Mr(this.crop||this.points,t);return[[this,s,i]]}transform(t){Mi(this.points,t)}getScheduledUpdates(t,i){return[]}};import{compose as Wr,dna as zr,DnaFactory as Ii,translate as ki}from"@atlas-viewer/dna";var Jt=class extends k{constructor(){super(...arguments);a(this,"type","spacial-content")}getAllPointsAt(t,i,n){return[[this,this.points,i]]}};var te=class extends Jt{constructor(t){super();a(this,"id");a(this,"display");a(this,"points");a(this,"images",[]);a(this,"allImages",[]);a(this,"scaleFactors",[]);a(this,"aggregateBuffer",zr(9));a(this,"lazyLoader");a(this,"isFullyLoaded",!1);a(this,"maxScaleFactor",0);a(this,"renderOptions");a(this,"_scheduleSortByScales",!1);a(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 z&&(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 z||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)});a(this,"loadFullResource",async()=>{if(!this.isFullyLoaded&&this.lazyLoader){this.isFullyLoaded=!0;let t=await this.lazyLoader();this.addImages(t)}});a(this,"fallback",[this.loadFullResource]);this.id=t.id,this.points=Ii.singleBox(t.width,t.height),this.lazyLoader=t.loadFullImages,t.loadFullImages||(this.isFullyLoaded=!0),this.display={x:0,y:0,points:Ii.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=Ai(1/(n||1)/(window.devicePixelRatio||1),this.images,this.renderOptions.quality),o=this.images.length,h=i?Wr(i,ki(this.x,this.y)):ki(this.x,this.y);if(s!==this.images.length-1&&this.images[s+1]){let l=[];for(let u=o-1;u>=s;u--)l.push(u);let d=l[0];this.renderOptions.renderLayers&&(l=l.slice(-Math.min(l.length,this.renderOptions.renderLayers))),this.renderOptions.renderSmallestFallback&&l.indexOf(d)===-1&&l.unshift(d);let c=[];for(let u=0;u<l.length;u++)c.push(...this.images[l[u]].getAllPointsAt(t,h,n));return c}return this.images[s].getAllPointsAt(t,h,n)}};import{compose as Wi,DnaFactory as ne,dnaLength as Nr,hidePointsOutsideRegion as zi,mutate as Bi,scale as Hr,scaleAtOrigin as jr,translate as Ni,dna as pt}from"@atlas-viewer/dna";import{dna as U,compose as $e,getIntersection as Br,scale as Fi,transform as Ve,translate as ee,hidePointsOutsideRegion as Di}from"@atlas-viewer/dna";function ie(r,e,t,i,n){let s=Math.PI/180*n,o=Math.cos(s),h=Math.sin(s),l=o*(t-r)+h*(i-e)+r,d=o*(i-e)-h*(t-r)+e;return[l,d]}var it=class r extends k{constructor(t,i){super();a(this,"id");a(this,"type","world-object");a(this,"scale");a(this,"layers");a(this,"points");a(this,"worldPoints");a(this,"intersectionBuffer",U(5));a(this,"aggregateBuffer",U(9));a(this,"invertedBuffer",U(9));a(this,"rotation",0);a(this,"filteredPointsBuffer");a(this,"_updatedList",[]);a(this,"geometry");let{x:n=0,y:s=0}=i||{};t?(this.id=t.id||"",this.scale=1,this.layers=t.layers,this.points=U([1,n,s,n+t.width,s+t.height]),this.worldPoints=U([1,n,s,n+t.width,s+t.height]),this.filteredPointsBuffer=U(t.layers.length*5)):(this.id="",this.scale=1,this.layers=[],this.points=U(5),this.worldPoints=U(5),this.filteredPointsBuffer=U(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=U(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),o=this.layers.slice(n);this.layers=[...s,t,...o]}hideInstance(){console.warn("hideInstance: not yet implemented")}getObjectsAt(t,i){if(this.rotation&&(t=this.applyRotation(t)),Di(this.points,t,this.filteredPointsBuffer)[0]===0)return[];let s=this.layers.length,o=[];for(let h=0;h<s;h++){let l=this.layers[h];if(i&&l.isShape){let c=Ve(l.points,ee(this.x,this.y));if(!l.intersects([t[1]-c[1],t[2]-c[2]]))continue}if(Di(Ve(l.points,ee(this.x,this.y)),t,this.filteredPointsBuffer)[0]!==0&&o.push(l),i){let c=l;o.push(...c.getObjectsAt(t,i))}}return o}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]},o={x:t[3],y:t[4]},h=this.points[1]+(this.points[3]-this.points[1])/2,l=this.points[2]+(this.points[4]-this.points[2])/2,[d,c]=ie(h,l,i.x,i.y,this.rotation),[u,m]=ie(h,l,n.x,n.y,this.rotation),[f,y]=ie(h,l,s.x,s.y,this.rotation),[w,v]=ie(h,l,o.x,o.y,this.rotation),g=Math.min(d,u,f,w),p=Math.max(d,u,f,w),E=Math.min(c,m,y,v),C=Math.max(c,m,y,v);return U([t[0],g,E,p,C])}return t}getAllPointsAt(t,i,n){let s=$e(ee(this.x,this.y),Fi(this.scale),this.aggregateBuffer);this.rotation&&(t=this.applyRotation(t));let o=Br(t,this.points,this.intersectionBuffer),h=this.layers.length,l=[],d=Ve(o,$e(Fi(1/this.scale),ee(-this.x,-this.y),this.invertedBuffer)),c=i?$e(i,s,this.aggregateBuffer):s,u=n*this.scale;for(let m=0;m<h;m++)l.push(...this.layers[m].getAllPointsAt(d,c,u));return l}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||U([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=U(this.layers.length*5)}getScheduledUpdates(t,i){let n=this.layers.length;this._updatedList=[];let s=i*this.scale;for(let o=0;o<n;o++){let h=this.layers[o].getScheduledUpdates(t,s);h&&this._updatedList.push(...h)}return this._updatedList}};var X=class r extends k{constructor(t=0,i=0,n=100,s="left-to-right"){super();a(this,"id","world");a(this,"_width");a(this,"_height");a(this,"aspectRatio");a(this,"viewingDirection");a(this,"aggregateBuffer",pt(9));a(this,"isDirty",!1);a(this,"zones",[]);a(this,"filteredPointsBuffer");a(this,"selectedZone");a(this,"triggerQueue",[]);a(this,"activatedEvents",[]);a(this,"_updatedList",[]);a(this,"translationBuffer",pt(9));a(this,"needsRecalculate",!0);a(this,"emptyPaintables",[]);a(this,"renderOrder",[]);a(this,"points");a(this,"objects",[]);a(this,"subscriptions",[]);a(this,"_propagateEventTargets",[]);a(this,"_alreadyFlushed",[]);this._width=t,this._height=i,this.aspectRatio=Number.isNaN(t/i)?1:t/i,this.viewingDirection=s,this.points=pt(n*5),this.filteredPointsBuffer=pt(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 o of n)if(o.x&&o.y){let h=ne.singleBox(1,1,o.x,o.y);s.push(this.getObjectsAt(h,!0).reverse())}return s.map(o=>this.propagateEvent(t,i,o,{bubbles:!0,cancelable:!0}))}propagatePointerEvent(t,i,n,s,o={}){let h=ne.singleBox(1,1,n,s),l=this.getObjectsAt(h,!0).reverse();return this.propagateEvent(t,i,l,o)}propagateEvent(t,i,n,{bubbles:s=!1,cancelable:o=!1}={}){i.atlasTarget=this,this._propagateEventTargets.length=1,this._propagateEventTargets[0]=this;let h=!1;i.stopPropagation=()=>{h=!0};let l=n.length;for(let u=l-1;u>=0;u--){this._propagateEventTargets.unshift(n[u][0]);let m=n[u][1].length;if(m)for(let f=0;f<m;f++)this._propagateEventTargets.unshift(n[u][1][f])}let d=this._propagateEventTargets.length,c=!1;for(let u=0;u<d&&(i.atlasTarget=this._propagateEventTargets[u],i.atlasWorld=this,c=this._propagateEventTargets[u].dispatchEvent(t,i)||c,!h);u++);return c&&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(Nr(this.points)===this.objects.length){let t=this.points,i=pt(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=pt(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 l=0;l<s;l++){let d=this.renderOrder[l];this.objects[d]&&(i[l]=this.points[d*5+3],n[l]=this.points[d*5+4])}let o=Math.max(...i);o!==this._width&&(this._width=o,t=!0);let h=Math.max(...n);h!==this._height&&(this._height=h,t=!0),t&&this.trigger("recalculate-world-size",{width:o,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:o}=i,h=n/t.width;this.checkResizeInternalBuffer(),this.points.set(ne.singleBox(t.width,t.height,0,0),this.objects.length*5);let l=new it(t);return l.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),this.objects.push(l),this.scaleWorldObject(this.objects.length-1,h),this.translateWorldObject(this.objects.length-1,s,o),this.filteredPointsBuffer=pt(this.points.length*2),this.triggerRepaint(),this.needsRecalculate=!0,l}scaleWorldObject(t,i){Bi(this.points.subarray(t*5,t*5+5),jr(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){Bi(this.points.subarray(t*5,t*5+5),Ni(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=ne.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=zi(this.points,t,this.filteredPointsBuffer),s=this.objects.length;this._updatedList=[];for(let o=0;o<s;o++)if(n[o*5]!==0){if(!this.objects[o])continue;this._updatedList.push(...this.objects[o].getScheduledUpdates(t,i))}return this._updatedList}getObjectsAt(t,i=!1){let n=this.getActiveZone(),s=zi(this.points,t,this.filteredPointsBuffer),o=this.renderOrder.length,h=[];for(let l=0;l<o;l++){let d=this.renderOrder[l];if(s[d*5]!==0){let c=this.objects[d];if(!c||n&&n.objects.indexOf(c)===-1)continue;if(c.type!=="world-object"){h.push([c,[c]]);continue}i?h.push([c,c.getObjectsAt(t,i)]):h.push([c,this.emptyPaintables])}}return h}getPointsAt(t,i,n=1){let s=this.getObjectsAt(t),o=Wi(Hr(n),Ni(-t[1],-t[2]),this.translationBuffer),h=i?Wi(i,o,this.aggregateBuffer):o,l=s.length,d=[];for(let c=0;c<l;c++)s[c]&&d.push(...s[c][0].getAllPointsAt(t,h,n));return d}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 Pa(r){let{src:e,target:t}=r,i=t?t.width:r.width,n=t?t.height:r.height;return new it({id:e,height:n,width:i,layers:[z.fromImage(e,{height:n,width:i},{width:r.width,height:r.height})]})}import{dna as Ur}from"@atlas-viewer/dna";var $r={margin:0},Hi=class{constructor(e,t={}){a(this,"id");a(this,"config");a(this,"points");a(this,"objects");this.id=e.map(i=>i.id).join("$$"),this.config={...$r,...t},this.points=Ur(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 ji,DnaFactory as Ui}from"@atlas-viewer/dna";var re=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,se={},Vr=["backgroundColor","opacity","boxShadow","borderColor","borderWidth","borderStyle","outlineColor","outlineWidth","outlineOffset","outlineStyle"],J=class extends k{constructor(){super();a(this,"id");a(this,"type","spacial-content");a(this,"points");a(this,"hoverEvents",!1);a(this,"activeEvents",!1);a(this,"display",{x:0,y:0,scale:1,width:-1,height:-1,points:ji(5)});a(this,"_parsed",{border:{id:null,match:[]},outline:{id:null,match:[]}});a(this,"hovering");a(this,"pressing");a(this,"props",{});a(this,"addHover",()=>{this.hovering=!0,this.__revision++});a(this,"removeHover",()=>{this.hovering=!1,this.pressing=!1,this.__revision++});a(this,"addPress",()=>{this.pressing=!0,this.__revision++});a(this,"removePress",()=>{this.pressing=!1,this.__revision++});this.id=K(12),this.points=ji(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=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 Vr)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=Ui.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.points=Ui.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 $i,DnaFactory as Gr}from"@atlas-viewer/dna";var ht=class extends k{constructor(){super();a(this,"type","spacial-content");a(this,"id");a(this,"points");a(this,"color","#000");a(this,"backgroundColor");a(this,"hovering");a(this,"pressing");a(this,"text","");a(this,"display",{x:0,y:0,scale:1,width:100,height:100,points:$i(5)});a(this,"className");a(this,"html");a(this,"interactive",!1);a(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=$i(5)}getAllPointsAt(t,i){return[[this,this.points,i]]}applyProps({id:t,target:i,text:n,color:s,backgroundColor:o,fontSize:h=18,interactive:l,fontFamily:d="Arial, sans-serif",...c}){c.font=`${h}px ${d}`,this.interactive=l||!1,typeof n<"u"&&(this.text=n||""),s&&(this.color=s),o&&(this.backgroundColor=o),t&&(this.id=t),i&&(this.points=Gr.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,...c},this.__revision++}};import{DnaFactory as Et,mutate as Yi,scale as Qi,scaleAtOrigin as qi,transform as Ge,dna as de,translate as Zr,compose as Yr}from"@atlas-viewer/dna";import{dna as Nt,DnaFactory as Xr}from"@atlas-viewer/dna";var I=Math.pow,oe=Math.sqrt,zt=Math.sin,Vi=Math.cos,Bt=Math.PI,le=1.70158,ae=le*1.525,Gi=le+1,Xi=2*Bt/3,Zi=2*Bt/4.5,he=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},tt={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-I(-2*r+2,2)/2},easeInCubic:function(r){return r*r*r},easeOutCubic:function(r){return 1-I(1-r,3)},easeInOutCubic:function(r){return r<.5?4*r*r*r:1-I(-2*r+2,3)/2},easeInQuart:function(r){return r*r*r*r},easeOutQuart:function(r){return 1-I(1-r,4)},easeInOutQuart:function(r){return r<.5?8*r*r*r*r:1-I(-2*r+2,4)/2},easeInQuint:function(r){return r*r*r*r*r},easeOutQuint:function(r){return 1-I(1-r,5)},easeInOutQuint:function(r){return r<.5?16*r*r*r*r*r:1-I(-2*r+2,5)/2},easeInSine:function(r){return 1-Vi(r*Bt/2)},easeOutSine:function(r){return zt(r*Bt/2)},easeInOutSine:function(r){return-(Vi(Bt*r)-1)/2},easeInExpo:function(r){return r===0?0:I(2,10*r-10)},easeOutExpo:function(r){return r===1?1:1-I(2,-10*r)},easeInOutExpo:function(r){return r===0?0:r===1?1:r<.5?I(2,20*r-10)/2:(2-I(2,-20*r+10))/2},easeInCirc:function(r){return 1-oe(1-I(r,2))},easeOutCirc:function(r){return oe(1-I(r-1,2))},easeInOutCirc:function(r){return r<.5?(1-oe(1-I(2*r,2)))/2:(oe(1-I(-2*r+2,2))+1)/2},easeInBack:function(r){return Gi*r*r*r-le*r*r},easeOutBack:function(r){return 1+Gi*I(r-1,3)+le*I(r-1,2)},easeInOutBack:function(r){return r<.5?I(2*r,2)*((ae+1)*2*r-ae)/2:(I(2*r-2,2)*((ae+1)*(r*2-2)+ae)+2)/2},easeInElastic:function(r){return r===0?0:r===1?1:-I(2,10*r-10)*zt((r*10-10.75)*Xi)},easeOutElastic:function(r){return r===0?0:r===1?1:I(2,-10*r)*zt((r*10-.75)*Xi)+1},easeInOutElastic:function(r){return r===0?0:r===1?1:r<.5?-(I(2,20*r-10)*zt((20*r-11.125)*Zi))/2:I(2,-20*r+10)*zt((20*r-11.125)*Zi)/2+1},easeInBounce:function(r){return 1-he(1-r)},easeOutBounce:he,easeInOutBounce:function(r){return r<.5?(1-he(1-2*r))/2:(1+he(2*r-1))/2}};var ce=class{constructor(e){a(this,"runtime");a(this,"pendingTransition");a(this,"lastZoomTo",null);a(this,"isConstraining",!1);a(this,"lastGoToRegion",null);this.runtime=e,this.pendingTransition={from:Nt(5),to:Nt(5),elapsed_time:0,done:!0,total_time:0,timingFunction:tt.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=Nt(this.runtime.target),this.pendingTransition.to=Nt(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:tt.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 o=this.runtime.getZoomedPosition(e,{origin:i}),h=Math.abs(1-e);this.applyTransition(o,s,{duration:2e3*h,easing:tt.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:tt.easeOutQuart,constrain:!1,callback:()=>{this.isConstraining=!1}}),this.runtime.updateNextFrame())}applyTransition(e,t,i,{stream:n}={}){this.pendingTransition.from=Nt(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||tt.easeInOutSine}goToRegion(e,{transition:t}={}){this.lastGoToRegion={target:e,options:{transition:t}};let i=this.runtime.clampRegion(e);this.applyTransition(Xr.singleBox(i.width,i.height,i.x,i.y),t,{duration:1e3,easing:tt.easeOutExpo,constrain:!0,callback:()=>{this.lastGoToRegion=null}}),this.runtime.updateNextFrame()}};var qa=Number.MIN_VALUE+1,nt=class{constructor(e,t,i,n=[],s){a(this,"id",K());a(this,"ready",!1);a(this,"renderer");a(this,"world");a(this,"target");a(this,"homePosition");a(this,"manualHomePosition");a(this,"manualFocalPosition");a(this,"focalPosition");a(this,"transitionManager");a(this,"aggregate");a(this,"transformBuffer",de(500));a(this,"lastTarget",de(5));a(this,"zoomBuffer",de(5));a(this,"logNextRender",!1);a(this,"pendingUpdate",!0);a(this,"isCommitting",!1);a(this,"firstRender",!0);a(this,"lastTime");a(this,"stopId");a(this,"mode","explore");a(this,"controllers",[]);a(this,"controllersRunning",!1);a(this,"controllerStopFunctions",[]);a(this,"maxScaleFactor",1);a(this,"_viewerToWorld",{x:0,y:0});a(this,"_lastGoodScale",1);a(this,"hooks",{useFrame:[],useBeforeFrame:[],useAfterPaint:[],useAfterFrame:[]});a(this,"fpsLimit");a(this,"options");a(this,"hookOptions",{filters:{grayscale:0,contrast:0,brightness:0,saturate:0,sepia:0,invert:0,hueRotate:0,blur:0}});a(this,"_viewport",{x:0,y:0,width:0,height:0});a(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});a(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(),o=this.renderer.getPointsAt(this.world,this.target,this.aggregate,s),h=o.length;for(let c=0;c<h;c++){let u=o[c][0],m=o[c][1],f=o[c][2],y=f?Ge(m,f,this.transformBuffer):m;this.renderer.prepareLayer(u,u.__parent&&f?Ge(u.__parent.crop||u.__parent.points,f):y);let w=y.length/5;for(let v=0;v<w;v++){let g=v*5;y[g]!==0&&(this.renderer.paint(u,v,y[g+1],y[g+2],y[g+3]-y[g+1],y[g+4]-y[g+2]),this.hook("useAfterPaint",u))}this.renderer.finishLayer(u,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 l=this.world.getScheduledUpdates(this.target,s),d=l.length;if(d>0)for(let c=0;c<d;c++){let u=l[d-c-1]();u?u.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=Et.projection(i),this.manualHomePosition=!1,this.pendingUpdate=!0,this.homePosition=Et.projection(this.world),this.manualFocalPosition=!1,this.focalPosition=this.target,this.updateFocalPosition(),this.transitionManager=new ce(this),this.aggregate=Qi(1),this.world.addLayoutSubscriber(o=>{o==="repaint"&&(this.pendingUpdate=!0),o==="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(Et.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,o=i.width/n,h=i.height/s,l=n/s;if(e.cover?o>h:o<h){let d=l*i.height,c=(d-i.width)/2;this.target[1]=Math.round(-c+i.x),this.target[2]=Math.round(i.y),this.target[3]=Math.round(d-c+i.x),this.target[4]=Math.round(i.height+i.y)}else{let d=i.width/l,c=(d-i.height)/2;this.target[1]=Math.round(i.x),this.target[2]=Math.round(i.y-c),this.target[3]=Math.round(i.x+i.width),this.target[4]=Math.round(i.y+d-c)}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,o=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])*o,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),o=0,h=0,l=this.x+o,d=this.y+h;if(i<n){let c=this.height-this.width;this.focalPosition=Et.projection({x:l,y:d+c/2,width:s-o*2,height:s-h*2}),this.pendingUpdate=!0}else{let c=this.width-this.height;this.focalPosition=Et.projection({x:l+c/2,y:d,width:s-o*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:o,maxY:h}=this.getBounds({target:e,padding:t}),l=!1,d=i?e:de(e),c=Math.round(e[3]-e[1]),u=Math.round(e[4]-e[2]);return n>e[1]&&(l=!0,d[1]=n,d[3]=n+c),o>e[2]&&(l=!0,d[2]=o,d[4]=o+u),s<e[1]&&(l=!0,d[1]=s,d[3]=s+c),h<e[2]&&(l=!0,d[2]=h,d[4]=h+u),[l,d]}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 p=this.world.getActiveZone();if(p){let E=t[3]-t[1]<p.points[3]-p.points[1],C=t[4]-t[2]<p.points[4]-p.points[2];return{minX:E?p.points[1]-i:p.points[1]+(p.points[3]-p.points[1])/2-(t[3]-t[1])/2,maxX:C?p.points[2]-i:p.points[2]+(p.points[4]-p.points[2])/2-(t[4]-t[2])/2,minY:E?p.points[3]+i:p.points[1]+(p.points[3]-p.points[1])/2-(t[3]-t[1])/2,maxY:C?p.points[4]+i:p.points[2]+(p.points[4]-p.points[2])/2-(t[4]-t[2])/2}}}let o=t[3]-t[1],h=this.world.width,l=-o*s,d=h-o-l,c=t[4]-t[2],u=this.world.height,m=-c*s,f=u-c-m,y=Math.round(Math.max(l,d)),w=Math.round(Math.min(l,d)),v=Math.round(Math.max(m,f)),g=Math.round(Math.min(m,f));return{minX:w,maxX:y,minY:g,maxY:v}}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(),o=n?n.width:this.width,h=n?n.height:this.height,l=this.getRendererScreenPosition()?.width,d=this.world.width,c=l?l/d:1,u=this.options.maxUnderZoom,m=Math.max(c||1,this.options.maxOverZoom),f=1/e,y=s*f;if(f<1){let g=o*s,p=h*s,E=this.world.width/g,C=this.world.height/p;if(E>C){let S=this.world.width*y,A=~~(o*s)*u;S<A&&(e=this.world.width*s/(o*s*u))}else{let S=this.world.height*y,A=~~(h*s)*u;S<A&&(e=this.world.height*s/(h*s*u))}}else y>m&&(e=s/m);let v=Ge(this.target,qi(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(v,{ref:!0,panPadding:100}),v}clampRegion({x:e,y:t,width:i,height:n,padding:s=0}){let o=this.width,h=this.height,l=i/o<n/h,d=e-s,c=t-s,u=i+s*2,m=n+s*2;if(l){let y=m/h*o;return{x:d-(y-u)/2,y:c,width:y,height:m}}let f=u/o*h;return{x:d,y:c-(f-m)/2,width:u,height:f}}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=Et.singleBox(i,n,e,t);return Yi(s,Yr(Qi(this.getScaleFactor()),Zr(-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){Yi(this.target,qi(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 Ki,DnaFactory as Ji}from"@atlas-viewer/dna";var ue=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,me={},Qr=["backgroundColor","opacity","boxShadow","borderColor","borderWidth","borderStyle","outlineColor","outlineWidth","outlineOffset","outlineStyle"],Ct=class extends k{constructor(){super();a(this,"id");a(this,"type","spacial-content");a(this,"isShape",!0);a(this,"points");a(this,"hoverEvents",!1);a(this,"activeEvents",!1);a(this,"display",{x:0,y:0,scale:1,width:-1,height:-1,points:Ki(5)});a(this,"boundingBox",null);a(this,"_parsed",{border:{id:null,match:[]},outline:{id:null,match:[]}});a(this,"hovering");a(this,"pressing");a(this,"props",{});a(this,"shape",{type:"none"});a(this,"addHover",()=>{this.hovering=!0,this.__revision++});a(this,"removeHover",()=>{this.hovering=!1,this.pressing=!1,this.__revision++});a(this,"addPress",()=>{this.pressing=!0,this.__revision++});a(this,"removePress",()=>{this.pressing=!1,this.__revision++});this.id=K(12),this.points=Ki(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])),o=Math.max(0,...t.map(h=>h[1]));this.boundingBox={x:i,y:n,width:s-i,height:o-n};return}this.boundingBox=null}intersects(t){if(!t||this.shape.type==="none")return!1;let[i,n]=t,s=this.shape.points,o=this.boundingBox;if(o||(this.updateBoundingBox(),o=this.boundingBox),!o||i<o.x||i>o.x+o.width||n<o.y||n>o.height+o.y)return!1;let h=!1;for(let l=0,d=s.length-1;l<s.length;d=l++)s[l][1]>n!=s[d][1]>n&&i<(s[d][0]-s[l][0])*(n-s[l][1])/(s[d][1]-s[l][1])+s[l][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 o=0;o<s;o++)if(t.points[o][0]!==this.shape.points[o][0]||t.points[o][1]!==this.shape.points[o][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=me[n]||ue.exec(n)||ue.exec(n);s&&(this._parsed.border.id=n,this._parsed.border.match=me[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=me[t.style.outline]||ue.exec(t.style.outline)||ue.exec(t.style.outline);s&&(this._parsed.outline.id=t.style.outline,this._parsed.outline.match=me[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 Qr)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=Ji.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.points=Ji.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++}};var Ht=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,qr=typeof AbortController=="function",fe=qr?AbortController:class{constructor(){this.signal=new tn}abort(e=new Error("This operation was aborted")){this.signal.reason=this.signal.reason||e,this.signal.aborted=!0,this.signal.dispatchEvent({type:"abort",target:this.signal})}},Kr=typeof AbortSignal=="function",Jr=typeof fe.AbortSignal=="function",tn=Kr?AbortSignal:Jr?fe.AbortController:class{constructor(){this.reason=void 0,this.aborted=!1,this._listeners=[]}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,this.onabort(e),this._listeners.forEach(t=>t(e),this))}onabort(){}addEventListener(e,t){e==="abort"&&this._listeners.push(t)}removeEventListener(e,t){e==="abort"&&(this._listeners=this._listeners.filter(i=>i!==t))}},Qe=new Set,Xe=(r,e)=>{let t=`LRU_CACHE_OPTION_${r}`;ge(t)&&qe(t,`${r} option`,`options.${e}`,Rt)},Ze=(r,e)=>{let t=`LRU_CACHE_METHOD_${r}`;if(ge(t)){let{prototype:i}=Rt,{get:n}=Object.getOwnPropertyDescriptor(i,r);qe(t,`${r} method`,`cache.${e}()`,n)}},ts=(r,e)=>{let t=`LRU_CACHE_PROPERTY_${r}`;if(ge(t)){let{prototype:i}=Rt,{get:n}=Object.getOwnPropertyDescriptor(i,r);qe(t,`${r} property`,`cache.${e}`,n)}},en=(...r)=>{typeof process=="object"&&process&&typeof process.emitWarning=="function"?process.emitWarning(...r):console.error(...r)},ge=r=>!Qe.has(r),qe=(r,e,t,i)=>{Qe.add(r);let n=`The ${e} is deprecated. Please use ${t} instead.`;en(n,"DeprecationWarning",r,i)},lt=r=>r&&r===Math.floor(r)&&r>0&&isFinite(r),nn=r=>lt(r)?r<=Math.pow(2,8)?Uint8Array:r<=Math.pow(2,16)?Uint16Array:r<=Math.pow(2,32)?Uint32Array:r<=Number.MAX_SAFE_INTEGER?Tt:null:null,Tt=class extends Array{constructor(e){super(e),this.fill(0)}},Ye=class{constructor(e){if(e===0)return[];let t=nn(e);this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},Rt=class r{constructor(e={}){let{max:t=0,ttl:i,ttlResolution:n=1,ttlAutopurge:s,updateAgeOnGet:o,updateAgeOnHas:h,allowStale:l,dispose:d,disposeAfter:c,noDisposeOnSet:u,noUpdateTTL:m,maxSize:f=0,maxEntrySize:y=0,sizeCalculation:w,fetchMethod:v,fetchContext:g,noDeleteOnFetchRejection:p,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:C,allowStaleOnFetchAbort:S,ignoreFetchAbort:P}=e,{length:A,maxAge:T,stale:F}=e instanceof r?{}:e;if(t!==0&&!lt(t))throw new TypeError("max option must be a nonnegative integer");let x=t?nn(t):Array;if(!x)throw new Error("invalid max value: "+t);if(this.max=t,this.maxSize=f,this.maxEntrySize=y||this.maxSize,this.sizeCalculation=w||A,this.sizeCalculation){if(!this.maxSize&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(this.fetchMethod=v||null,this.fetchMethod&&typeof this.fetchMethod!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.fetchContext=g,!this.fetchMethod&&g!==void 0)throw new TypeError("cannot set fetchContext without fetchMethod");if(this.keyMap=new Map,this.keyList=new Array(t).fill(null),this.valList=new Array(t).fill(null),this.next=new x(t),this.prev=new x(t),this.head=0,this.tail=0,this.free=new Ye(t),this.initialFill=1,this.size=0,typeof d=="function"&&(this.dispose=d),typeof c=="function"?(this.disposeAfter=c,this.disposed=[]):(this.disposeAfter=null,this.disposed=null),this.noDisposeOnSet=!!u,this.noUpdateTTL=!!m,this.noDeleteOnFetchRejection=!!p,this.allowStaleOnFetchRejection=!!C,this.allowStaleOnFetchAbort=!!S,this.ignoreFetchAbort=!!P,this.maxEntrySize!==0){if(this.maxSize!==0&&!lt(this.maxSize))throw new TypeError("maxSize must be a positive integer if specified");if(!lt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.initializeSizeTracking()}if(this.allowStale=!!l||!!F,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!h,this.ttlResolution=lt(n)||n===0?n:1,this.ttlAutopurge=!!s,this.ttl=i||T||0,this.ttl){if(!lt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.initializeTTLTracking()}if(this.max===0&&this.ttl===0&&this.maxSize===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.max&&!this.maxSize){let _="LRU_CACHE_UNBOUNDED";ge(_)&&(Qe.add(_),en("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",_,r))}F&&Xe("stale","allowStale"),T&&Xe("maxAge","ttl"),A&&Xe("length","sizeCalculation")}getRemainingTTL(e){return this.has(e,{updateAgeOnHas:!1})?1/0:0}initializeTTLTracking(){this.ttls=new Tt(this.max),this.starts=new Tt(this.max),this.setItemTTL=(i,n,s=Ht.now())=>{if(this.starts[i]=n!==0?s:0,this.ttls[i]=n,n!==0&&this.ttlAutopurge){let o=setTimeout(()=>{this.isStale(i)&&this.delete(this.keyList[i])},n+1);o.unref&&o.unref()}},this.updateItemAge=i=>{this.starts[i]=this.ttls[i]!==0?Ht.now():0},this.statusTTL=(i,n)=>{i&&(i.ttl=this.ttls[n],i.start=this.starts[n],i.now=e||t(),i.remainingTTL=i.now+i.ttl-i.start)};let e=0,t=()=>{let i=Ht.now();if(this.ttlResolution>0){e=i;let n=setTimeout(()=>e=0,this.ttlResolution);n.unref&&n.unref()}return i};this.getRemainingTTL=i=>{let n=this.keyMap.get(i);return n===void 0?0:this.ttls[n]===0||this.starts[n]===0?1/0:this.starts[n]+this.ttls[n]-(e||t())},this.isStale=i=>this.ttls[i]!==0&&this.starts[i]!==0&&(e||t())-this.starts[i]>this.ttls[i]}updateItemAge(e){}statusTTL(e,t){}setItemTTL(e,t,i){}isStale(e){return!1}initializeSizeTracking(){this.calculatedSize=0,this.sizes=new Tt(this.max),this.removeItemSize=e=>{this.calculatedSize-=this.sizes[e],this.sizes[e]=0},this.requireSize=(e,t,i,n)=>{if(this.isBackgroundFetch(t))return 0;if(!lt(i))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(i=n(t,e),!lt(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.addItemSize=(e,t,i)=>{if(this.sizes[e]=t,this.maxSize){let n=this.maxSize-this.sizes[e];for(;this.calculatedSize>n;)this.evict(!0)}this.calculatedSize+=this.sizes[e],i&&(i.entrySize=t,i.totalCalculatedSize=this.calculatedSize)}}removeItemSize(e){}addItemSize(e,t){}requireSize(e,t,i,n){if(i||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache")}*indexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.tail;!(!this.isValidIndex(t)||((e||!this.isStale(t))&&(yield t),t===this.head));)t=this.prev[t]}*rindexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.head;!(!this.isValidIndex(t)||((e||!this.isStale(t))&&(yield t),t===this.tail));)t=this.next[t]}isValidIndex(e){return e!==void 0&&this.keyMap.get(this.keyList[e])===e}*entries(){for(let e of this.indexes())this.valList[e]!==void 0&&this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield[this.keyList[e],this.valList[e]])}*rentries(){for(let e of this.rindexes())this.valList[e]!==void 0&&this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield[this.keyList[e],this.valList[e]])}*keys(){for(let e of this.indexes())this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.keyList[e])}*rkeys(){for(let e of this.rindexes())this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.keyList[e])}*values(){for(let e of this.indexes())this.valList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.valList[e])}*rvalues(){for(let e of this.rindexes())this.valList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.valList[e])}[Symbol.iterator](){return this.entries()}find(e,t){for(let i of this.indexes()){let n=this.valList[i],s=this.isBackgroundFetch(n)?n.__staleWhileFetching:n;if(s!==void 0&&e(s,this.keyList[i],this))return this.get(this.keyList[i],t)}}forEach(e,t=this){for(let i of this.indexes()){let n=this.valList[i],s=this.isBackgroundFetch(n)?n.__staleWhileFetching:n;s!==void 0&&e.call(t,s,this.keyList[i],this)}}rforEach(e,t=this){for(let i of this.rindexes()){let n=this.valList[i],s=this.isBackgroundFetch(n)?n.__staleWhileFetching:n;s!==void 0&&e.call(t,s,this.keyList[i],this)}}get prune(){return Ze("prune","purgeStale"),this.purgeStale}purgeStale(){let e=!1;for(let t of this.rindexes({allowStale:!0}))this.isStale(t)&&(this.delete(this.keyList[t]),e=!0);return e}dump(){let e=[];for(let t of this.indexes({allowStale:!0})){let i=this.keyList[t],n=this.valList[t],s=this.isBackgroundFetch(n)?n.__staleWhileFetching:n;if(s===void 0)continue;let o={value:s};if(this.ttls){o.ttl=this.ttls[t];let h=Ht.now()-this.starts[t];o.start=Math.floor(Date.now()-h)}this.sizes&&(o.size=this.sizes[t]),e.unshift([i,o])}return e}load(e){this.clear();for(let[t,i]of e){if(i.start){let n=Date.now()-i.start;i.start=Ht.now()-n}this.set(t,i.value,i)}}dispose(e,t,i){}set(e,t,{ttl:i=this.ttl,start:n,noDisposeOnSet:s=this.noDisposeOnSet,size:o=0,sizeCalculation:h=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,status:d}={}){if(o=this.requireSize(e,t,o,h),this.maxEntrySize&&o>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=!0),this.delete(e),this;let c=this.size===0?void 0:this.keyMap.get(e);if(c===void 0)c=this.newIndex(),this.keyList[c]=e,this.valList[c]=t,this.keyMap.set(e,c),this.next[this.tail]=c,this.prev[c]=this.tail,this.tail=c,this.size++,this.addItemSize(c,o,d),d&&(d.set="add"),l=!1;else{this.moveToTail(c);let u=this.valList[c];if(t!==u){if(this.isBackgroundFetch(u)?u.__abortController.abort(new Error("replaced")):s||(this.dispose(u,e,"set"),this.disposeAfter&&this.disposed.push([u,e,"set"])),this.removeItemSize(c),this.valList[c]=t,this.addItemSize(c,o,d),d){d.set="replace";let m=u&&this.isBackgroundFetch(u)?u.__staleWhileFetching:u;m!==void 0&&(d.oldValue=m)}}else d&&(d.set="update")}if(i!==0&&this.ttl===0&&!this.ttls&&this.initializeTTLTracking(),l||this.setItemTTL(c,i,n),this.statusTTL(d,c),this.disposeAfter)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return this}newIndex(){return this.size===0?this.tail:this.size===this.max&&this.max!==0?this.evict(!1):this.free.length!==0?this.free.pop():this.initialFill++}pop(){if(this.size){let e=this.valList[this.head];return this.evict(!0),e}}evict(e){let t=this.head,i=this.keyList[t],n=this.valList[t];return this.isBackgroundFetch(n)?n.__abortController.abort(new Error("evicted")):(this.dispose(n,i,"evict"),this.disposeAfter&&this.disposed.push([n,i,"evict"])),this.removeItemSize(t),e&&(this.keyList[t]=null,this.valList[t]=null,this.free.push(t)),this.head=this.next[t],this.keyMap.delete(i),this.size--,t}has(e,{updateAgeOnHas:t=this.updateAgeOnHas,status:i}={}){let n=this.keyMap.get(e);if(n!==void 0)if(this.isStale(n))i&&(i.has="stale",this.statusTTL(i,n));else return t&&this.updateItemAge(n),i&&(i.has="hit"),this.statusTTL(i,n),!0;else i&&(i.has="miss");return!1}peek(e,{allowStale:t=this.allowStale}={}){let i=this.keyMap.get(e);if(i!==void 0&&(t||!this.isStale(i))){let n=this.valList[i];return this.isBackgroundFetch(n)?n.__staleWhileFetching:n}}backgroundFetch(e,t,i,n){let s=t===void 0?void 0:this.valList[t];if(this.isBackgroundFetch(s))return s;let o=new fe;i.signal&&i.signal.addEventListener("abort",()=>o.abort(i.signal.reason));let h={signal:o.signal,options:i,context:n},l=(f,y=!1)=>{let{aborted:w}=o.signal,v=i.ignoreFetchAbort&&f!==void 0;return i.status&&(w&&!y?(i.status.fetchAborted=!0,i.status.fetchError=o.signal.reason,v&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),w&&!v&&!y?c(o.signal.reason):(this.valList[t]===m&&(f===void 0?m.__staleWhileFetching?this.valList[t]=m.__staleWhileFetching:this.delete(e):(i.status&&(i.status.fetchUpdated=!0),this.set(e,f,h.options))),f)},d=f=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=f),c(f)),c=f=>{let{aborted:y}=o.signal,w=y&&i.allowStaleOnFetchAbort,v=w||i.allowStaleOnFetchRejection,g=v||i.noDeleteOnFetchRejection;if(this.valList[t]===m&&(!g||m.__staleWhileFetching===void 0?this.delete(e):w||(this.valList[t]=m.__staleWhileFetching)),v)return i.status&&m.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),m.__staleWhileFetching;if(m.__returned===m)throw f},u=(f,y)=>{this.fetchMethod(e,s,h).then(w=>f(w),y),o.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(f(),i.allowStaleOnFetchAbort&&(f=w=>l(w,!0)))})};i.status&&(i.status.fetchDispatched=!0);let m=new Promise(u).then(l,d);return m.__abortController=o,m.__staleWhileFetching=s,m.__returned=null,t===void 0?(this.set(e,m,{...h.options,status:void 0}),t=this.keyMap.get(e)):this.valList[t]=m,m}isBackgroundFetch(e){return e&&typeof e=="object"&&typeof e.then=="function"&&Object.prototype.hasOwnProperty.call(e,"__staleWhileFetching")&&Object.prototype.hasOwnProperty.call(e,"__returned")&&(e.__returned===e||e.__returned===null)}async fetch(e,{allowStale:t=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:h=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:d=this.noUpdateTTL,noDeleteOnFetchRejection:c=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:m=this.ignoreFetchAbort,allowStaleOnFetchAbort:f=this.allowStaleOnFetchAbort,fetchContext:y=this.fetchContext,forceRefresh:w=!1,status:v,signal:g}={}){if(!this.fetchMethod)return v&&(v.fetch="get"),this.get(e,{allowStale:t,updateAgeOnGet:i,noDeleteOnStaleGet:n,status:v});let p={allowStale:t,updateAgeOnGet:i,noDeleteOnStaleGet:n,ttl:s,noDisposeOnSet:o,size:h,sizeCalculation:l,noUpdateTTL:d,noDeleteOnFetchRejection:c,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:f,ignoreFetchAbort:m,status:v,signal:g},E=this.keyMap.get(e);if(E===void 0){v&&(v.fetch="miss");let C=this.backgroundFetch(e,E,p,y);return C.__returned=C}else{let C=this.valList[E];if(this.isBackgroundFetch(C)){let F=t&&C.__staleWhileFetching!==void 0;return v&&(v.fetch="inflight",F&&(v.returnedStale=!0)),F?C.__staleWhileFetching:C.__returned=C}let S=this.isStale(E);if(!w&&!S)return v&&(v.fetch="hit"),this.moveToTail(E),i&&this.updateItemAge(E),this.statusTTL(v,E),C;let P=this.backgroundFetch(e,E,p,y),A=P.__staleWhileFetching!==void 0,T=A&&t;return v&&(v.fetch=A&&S?"stale":"refresh",T&&S&&(v.returnedStale=!0)),T?P.__staleWhileFetching:P.__returned=P}}get(e,{allowStale:t=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:s}={}){let o=this.keyMap.get(e);if(o!==void 0){let h=this.valList[o],l=this.isBackgroundFetch(h);return this.statusTTL(s,o),this.isStale(o)?(s&&(s.get="stale"),l?(s&&(s.returnedStale=t&&h.__staleWhileFetching!==void 0),t?h.__staleWhileFetching:void 0):(n||this.delete(e),s&&(s.returnedStale=t),t?h:void 0)):(s&&(s.get="hit"),l?h.__staleWhileFetching:(this.moveToTail(o),i&&this.updateItemAge(o),h))}else s&&(s.get="miss")}connect(e,t){this.prev[t]=e,this.next[e]=t}moveToTail(e){e!==this.tail&&(e===this.head?this.head=this.next[e]:this.connect(this.prev[e],this.next[e]),this.connect(this.tail,e),this.tail=e)}get del(){return Ze("del","delete"),this.delete}delete(e){let t=!1;if(this.size!==0){let i=this.keyMap.get(e);if(i!==void 0)if(t=!0,this.size===1)this.clear();else{this.removeItemSize(i);let n=this.valList[i];this.isBackgroundFetch(n)?n.__abortController.abort(new Error("deleted")):(this.dispose(n,e,"delete"),this.disposeAfter&&this.disposed.push([n,e,"delete"])),this.keyMap.delete(e),this.keyList[i]=null,this.valList[i]=null,i===this.tail?this.tail=this.prev[i]:i===this.head?this.head=this.next[i]:(this.next[this.prev[i]]=this.next[i],this.prev[this.next[i]]=this.prev[i]),this.size--,this.free.push(i)}}if(this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return t}clear(){for(let e of this.rindexes({allowStale:!0})){let t=this.valList[e];if(this.isBackgroundFetch(t))t.__abortController.abort(new Error("deleted"));else{let i=this.keyList[e];this.dispose(t,i,"delete"),this.disposeAfter&&this.disposed.push([t,i,"delete"])}}if(this.keyMap.clear(),this.valList.fill(null),this.keyList.fill(null),this.ttls&&(this.ttls.fill(0),this.starts.fill(0)),this.sizes&&this.sizes.fill(0),this.head=0,this.tail=0,this.initialFill=1,this.free.length=0,this.calculatedSize=0,this.size=0,this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift())}get reset(){return Ze("reset","clear"),this.clear}get length(){return ts("length","size"),this.size}static get AbortController(){return fe}static get AbortSignal(){return tn}},rn=Rt;var sn=/(-?[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,on={},es=typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes("firefox"),pe={};var ye=class{constructor(e,t){a(this,"canvas");a(this,"ctx");a(this,"options");a(this,"imagesPending",0);a(this,"imagesLoaded",0);a(this,"imageIdsLoaded",[]);a(this,"frameIsRendering",!1);a(this,"pendingDrawCall",!1);a(this,"firstMeaningfulPaint",!1);a(this,"parallelTasks",8);a(this,"frameTasks",0);a(this,"loadingQueueOrdered",!0);a(this,"loadingQueue",[]);a(this,"currentTask",Promise.resolve());a(this,"tasksRunning",0);a(this,"stats");a(this,"averageJobTime",64);a(this,"lastKnownScale",1);a(this,"visible",[]);a(this,"previousVisible",[]);a(this,"rendererPosition");a(this,"dpi");a(this,"drawCalls",[]);a(this,"lastPaintedObject");a(this,"hostCache");a(this,"invalidated",[]);a(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--}))}});a(this,"_scheduled",0);a(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 rn({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,o=n.height/t,h=(s<o?o: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 o="";n.filters.brightness&&(o+=`brightness(${~~(100+n.filters.brightness*100)}%) `),n.filters.contrast&&(o+=`contrast(${~~(100+n.filters.contrast*100)}%) `),n.filters.grayscale&&(o+=`grayscale(${~~(n.filters.grayscale*100)}%) `),n.filters.invert&&(o+=`invert(${~~(n.filters.invert*100)}%) `),n.filters.sepia&&(o+=`sepia(${~~(n.filters.sepia*100)}%) `),n.filters.saturate&&(o+=`saturate(${~~(100+n.filters.saturate*100)}%) `),n.filters.hueRotate&&(o+=`hue-rotate(${n.filters.hueRotate}deg) `),n.filters.blur&&(o+=`blur(${n.filters.blur}px) `),this.ctx.filter!==o&&(this.ctx.filter=o)}else this.ctx.filter="none"}applyTransform(e,t,i,n,s){let o=e.__owner.value;if(o&&o.rotation){this.ctx.save();let h=t+n/2,l=i+s/2;this.ctx.translate(h,l),this.ctx.rotate(o.rotation*Math.PI/180),this.ctx.translate(-h,-l),this.lastPaintedObject=o}}clearTransform(){this.lastPaintedObject&&(this.lastPaintedObject.rotation&&this.ctx.restore(),this.lastPaintedObject=void 0)}paint(e,t,i,n,s,o){let h=this.ctx.globalAlpha;if(e instanceof z||e instanceof G){if(e.display.rotation){this.ctx.save();let c=i+s/2,u=n+o/2;e.crop&&(c-=e.crop[t*5+1],u-=e.crop[t*5+2]),this.ctx.translate(c,u),this.ctx.rotate(e.display.rotation*Math.PI/180),this.ctx.translate(-c,-u)}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 c=e.__host.canvas,u=this.getCanvasDims();if((c.indices.indexOf(t)===-1||this.invalidated.indexOf(c.canvases[t])!==-1)&&this.schedulePaintToCanvas(c,e,t,gt({x:i+s/2,y:n+s/2},{x:u.width/2,y:u.height/2})),!this.firstMeaningfulPaint)return;let m=this.hostCache.get(c.canvases[t]);if(m)if(e.crop&&e.cropData){if(e.crop[t*5]){let f=[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];f[0]+=e.cropData.x/e.display.scale,f[1]+=e.cropData.y/e.display.scale;let y=e.x*this.lastKnownScale,w=e.y*this.lastKnownScale,v=[i+y,n+w,s,o];v[0]+=y,v[1]+=w,this.ctx.drawImage(m,f[0],f[1],f[2],f[3],v[0],v[1],v[2]+1,v[3]+1)}}else es?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,o+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,o+Number.MIN_VALUE+.5)}catch{}e.display.rotation&&this.ctx.restore()}let l=e instanceof J&&this.options.box,d=e instanceof Ct&&this.options.polygon;if((l||d)&&!e.props.className&&!e.props.html&&!e.props.href){if(this.visible.push(e),e.props.style){let c=Object.assign({},e.props.style||{},e.hovering?e.props.hoverStyles:{},e.pressing?e.props.pressStyles:{}),u=e.props.relativeStyle?1:s/e.width;typeof c.opacity<"u"&&(this.ctx.globalAlpha=c.opacity);let m=0;typeof c.borderWidth<"u"&&(m=parseInt(c.borderWidth,10)*u);let f=0;typeof c.outlineWidth<"u"&&(f=parseInt(c.outlineWidth,10)*u);let y=0;if(typeof c.outlineOffset<"u"&&(y=parseInt(c.outlineOffset,10)*u),c.borderColor&&(this.ctx.strokeStyle=c.borderColor),c.boxShadow){let w=c.boxShadow.split(/,(?![^(]*\))/);for(let v of w){let g=on[v]||sn.exec(v)||sn.exec(v);on[v]=g,g&&(this.ctx.save(),this.ctx.shadowOffsetX=parseInt(g[1])*this.dpi*u,this.ctx.shadowOffsetY=parseInt(g[3])*this.dpi*u,this.ctx.shadowBlur=parseInt(g[5])*this.dpi*u,this.ctx.shadowColor=g[9],this.ctx.fillStyle="rgba(0,0,0,1)",this.ctx.fillRect(i+m,n+m,s,o),this.ctx.restore())}}if(this.ctx.fillStyle=c.backgroundColor||"transparent",this.ctx.lineWidth=m,d){let w=e.shape,v=w.points||[],g=v.length;this.ctx.beginPath();for(let p=0;p<g;p++)this.ctx.lineTo(i+v[p][0]*this.lastKnownScale,n+v[p][1]*this.lastKnownScale);w.open||this.ctx.closePath(),m&&this.ctx.stroke(),w.open||this.ctx.fill()}else m&&this.ctx.strokeRect(i+m/2,n+m/2,s+m,o+m),this.ctx.fillRect(i+m,n+m,s,o);f&&(c.outlineColor&&(this.ctx.strokeStyle=c.outlineColor),this.ctx.lineWidth=f,this.ctx.strokeRect(i-f/2-y,n-f/2-y,s+m*2+f+y*2,o+m*2+f+y*2))}this.ctx.globalAlpha=h}}loadImage(e,t,i,n=!1){if(pe[e]&&pe[e].naturalWidth>0){t(pe[e]);return}try{let s=!1;n||setTimeout(()=>{s||this.loadImage(e,t,i,!0)},3e3);let o=document.createElement("img");o.decoding="auto",o.onload=function(){s=!0,t(o),pe[e]=o,o.onload=null},this.options.crossOrigin&&(o.crossOrigin="anonymous"),o.src=e,o.complete&&o.onload({}),o.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}`,o=this.invalidated.indexOf(s);o!==-1&&this.invalidated.splice(o,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 l=t.getImageUrl(i);this.loadImage(l,d=>{this.loadingQueue.push({id:s,scale:t.display.scale,distance:n,task:()=>new Promise(c=>{this.imageIdsLoaded.includes(s)||(this.imagesLoaded++,this.imageIdsLoaded.push(s)),e.loaded.push(i),e.loaded.length===e.indices.length&&(e.loading=!1);let u=t.display.points.slice(i*5,i*5+5),m=document.createElement("canvas"),f=m.getContext("2d");m.width=u[3]-u[1],m.height=u[4]-u[2],this.hostCache.set(e.canvases[i],m),this.drawCalls.push(()=>{f.drawImage(d,0,0,u[3]-u[1],u[4]-u[2]),c()})})}),h()},d=>{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 z||e instanceof G)&&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],o=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:o?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:o?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 _t=class{constructor(e){a(this,"renderers",[]);a(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,o){for(let h=0;h<this.length;h++)this.renderers[h].paint(e,t,i,n,s,o)}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 is,scale as ns}from"@atlas-viewer/dna";var be=class{constructor(e){a(this,"canvas");a(this,"context");a(this,"heightRatio",1);a(this,"widthRatio",1);a(this,"target",new Float32Array(5));a(this,"initialWidth");a(this,"initialHeight");a(this,"bounds");a(this,"aggregate");a(this,"delta",0);a(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=ns(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,o=this.widthRatio>this.heightRatio?n:s;if(this.target=i,this.bounds){let h=e.getPointsAt(this.bounds,this.aggregate,o);for(let[l,d]of h)if(l instanceof z&&l.__host.canvas){let c=d.length/5;for(let u=0;u<c;u++)if(l.__host.canvas.canvases[u]){let f={x1:d[u+1]*o,y1:d[u+2]*o,width:(d[u+3]-d[u+1])*o,height:(d[u+4]-d[u+2])*o}}}}e.getPoints().forEach((h,l,d)=>{if(l%5===0&&h){let c={x1:d[l+1]*o,y1:d[l+2]*o,x2:d[l+3]*o,y2:d[l+4]*o,width:(d[l+3]-d[l+1])*o,height:(d[l+4]-d[l+2])*o};this.context.strokeStyle="red",this.context.strokeRect(c.x1,c.y1,c.width,c.height)}}),i&&(this.context.strokeStyle="red",this.context.lineWidth=window.devicePixelRatio||1,this.context.strokeRect(i[1]*o,i[2]*o,(i[3]-i[1])*o,(i[4]-i[2])*o))}}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=is.singleBox(e.width,e.height)}drawImage(){}afterPaintLayer(e,t){}paint(e,t,i,n,s,o){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 an=class{constructor(){a(this,"autoWidth",!1);a(this,"autoHeight",!0);a(this,"width");a(this,"height");a(this,"world");a(this,"content",[]);a(this,"viewingDirection","left-to-right");a(this,"rows");a(this,"columns",4);a(this,"spacing",20);a(this,"reversed",!1);a(this,"padding",20);this.world=X.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,o=this.autoWidth?-1:(s-this.spacing*(i-1))/i;if(this.autoHeight&&!this.autoWidth){let h=0,l=this.padding;for(let d=0;d<n&&h!==e;d++){let c=0,u=[];for(let m=0;m<i;m++){let f=this.reversed?e-h:h;if(h===e)break;let y=this.content[f],w=y.width,v=y.width/y.height,g=o/v;u.push([h,o,g,o/w]),g>c&&(c=g),h++}for(let m=0;m<i&&u[m];m++){let f=this.world.getPoints(),y=u[m][0],w=u[m][1],v=u[m][2],g=u[m][3],p=this.padding+m*(this.spacing+w),E=l+(c-v)/2,C=this.reversed?e-y:y,S=f[C*5+1],P=f[C*5+2];this.world.scaleWorldObject(y,g),(S!==p||P!==E)&&this.world.translateWorldObject(C,p-S,E-P)}l+=c+this.spacing}this.height=l+this.padding,this.world.resize(this.width,this.height);return}this.autoWidth&&this.autoHeight,!this.autoWidth&&this.autoHeight}getWorld(){return this.world}};var kn=Rr(_n(),1);import{compose as hs,dna as oi,scaleAtOrigin as ls,transform as On,translate as Ln}from"@atlas-viewer/dna";function An(r){return{x:r[1],y:r[2],width:r[3]-r[1],height:r[4]-r[2]}}var Mn="pan",In="scroll",cs="gesture",ds={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},Pe=(r={})=>({start:function(e){let{zoomWheelConstant:t,enableWheel:i,enableClickToZoom:n,ignoreSingleFingerTouch:s,enablePanOnWait:o,panOnWaitDelay:h,parentElement:l,requireMetaKeyForWheelZoom:d}={...ds,...r},c={pointerStart:{x:0,y:0},isPressing:!1,mousemoveBuffer:oi(5),multiTouch:{distance:0}};e.world.activatedEvents.push("onMouseUp","onMouseDown","onMouseMove","onTouchStart","onTouchEnd","onTouchMove","onContextMenu");function u(){w=0,g="",E(),E(void 0,"notice"),v=0}function m(){e.world.constraintBounds(),u()}function f(x){if(x.which>1){c.isPressing=!1;return}e.mode==="explore"&&(x.preventDefault(),c.pointerStart.x=x.atlas.x,c.pointerStart.y=x.atlas.y,e.transitionManager.stopTransition(),c.isPressing=!0)}function y(){u(),c.isPressing&&(e.mode==="explore"&&e.world.constraintBounds(),c.isPressing=!1)}let w=0,v=0,g="";function p(x){if(e.mode==="explore"){if(x.atlasTouches.length===1&&(v=performance.now(),s==!1&&x.preventDefault(),c.pointerStart.x=x.atlasTouches[0].x,c.pointerStart.y=x.atlasTouches[0].y),x.atlasTouches.length===2){g=cs,x.preventDefault();let _=x.atlasTouches[0].x,L=x.atlasTouches[1].x;c.pointerStart.x=(_+L)/2;let dt=x.atlasTouches[0].y,W=x.atlasTouches[1].y;c.pointerStart.y=(dt+W)/2,w=gt({x:x.touches[0].clientX,y:x.touches[0].clientY},{x:x.touches[1].clientX,y:x.touches[1].clientY})}e.transitionManager.stopTransition(),c.isPressing=!0}}function E(x,_="intent"){l&&(l.dataset[_]=x)}function C(x){let _=null,L=null,dt=!1,W=0;if(c.isPressing&&x.touches.length===2){let Q=x.touches[0].clientX,H=x.touches[1].clientX;_=(Q+H)/2;let St=x.touches[0].clientY,ut=x.touches[1].clientY;L=(St+ut)/2,W=gt({x:x.touches[0].clientX,y:x.touches[0].clientY},{x:x.touches[1].clientX,y:x.touches[1].clientY}),dt=!0}if(E(g),c.isPressing&&x.touches.length===1){if(o&&(performance.now()-v<h&&g==""&&(g=In),g==""&&(g=Mn)),E(g),g==""&&s==!0||g==In){E("require-two-finger","notice");return}let Q=x.touches[0];_=Q.clientX,L=Q.clientY}if(_!==null&&L!==null){let Q=e.getRendererScreenPosition();if(Q){let{x:H,y:St}=e.viewerToWorld(_-Q.x,L-Q.y),ut=W&&w?W/w:1;e.transitionManager.customTransition(et=>{et.from=oi(e.target),et.to=On(et.from,hs(Ln(c.pointerStart.x-H,c.pointerStart.y-St),ls(1/ut,H,St)),c.mousemoveBuffer),et.elapsed_time=0,et.total_time=0,et.timingFunction=tt.easeInOutExpo,et.done=!1})}w=W}g==Mn&&x.preventDefault()}function S(x){if(c.isPressing){let _=e.getRendererScreenPosition();if(_){let{x:L,y:dt}=e.viewerToWorld(x.clientX-_.x,x.clientY-_.y);e.transitionManager.customTransition(W=>{W.from=oi(e.target),W.to=On(W.from,Ln(c.pointerStart.x-L,c.pointerStart.y-dt),c.mousemoveBuffer),W.elapsed_time=0,W.total_time=0,W.timingFunction=tt.easeInOutExpo,W.done=!1})}}}function P(x){e.mode==="explore"&&e.world.zoomIn(x.atlas)}function A(x){let L=1+(0,kn.default)(x).spinY/t;e.world.zoomTo(L,x.atlas,!0)}function T(x){return d&&x.metaKey==!1?(E("meta-required","notice"),x.stopPropagation(),!1):!0}e.world.addEventListener("mouseup",m),e.world.addEventListener("touchend",m),e.world.addEventListener("touchstart",p),e.world.addEventListener("mousedown",f),window.addEventListener("touchend",y),window.addEventListener("mouseup",y),window.addEventListener("mousemove",S),l&&l.addEventListener("touchmove",C),n&&(e.world.activatedEvents.push("onClick"),e.world.addEventListener("click",P)),i&&(e.world.activatedEvents.push("onWheel"),d&&l?.addEventListener("wheel",T,{passive:!0,capture:!0}),e.world.addEventListener("wheel",A));let F=e.world.addLayoutSubscriber((x,_)=>{if(x==="zone-changed"&&e.transitionManager.constrainBounds({transition:{duration:0}}),x==="zoom-to"&&_&&e.transitionManager.zoomTo(_.factor,{origin:_.point,stream:_.stream}),x==="go-home"){let L=_.immediate?{duration:0}:void 0;e.transitionManager.goToRegion(An(e.homePosition),{transition:L})}if(x==="goto-region"&&_){let L=_.immediate?{duration:0}:{};e.transitionManager.goToRegion(_,{transition:L})}x==="constrain-bounds"&&e.transitionManager.constrainBounds({transition:_?.immediate?{duration:0}:void 0})});return()=>{e.world.removeEventListener("mouseup",m),e.world.removeEventListener("touchend",m),e.world.removeEventListener("touchstart",p),e.world.removeEventListener("mousedown",f),window.removeEventListener("touchend",y),window.removeEventListener("mouseup",y),e.world.removeEventListener("mousemove",S),l&&(l.removeEventListener("touchmove",S),l.removeEventListener("wheel",T,{passive:!0,capture:!0})),n&&e.world.removeEventListener("click",P),i&&e.world.removeEventListener("wheel",A),F()}},updatePosition(){}});import{memo as Fs,useCallback as Ds,useEffect as Z,useMemo as Ws,useRef as qn,useState as ai}from"react";import us,{useContext as ms}from"react";import{jsx as fs}from"react/jsx-runtime";var rt=us.createContext("explore");rt.displayName="Mode";var Ee=()=>ms(rt);function jh(r){return fs(rt.Provider,{value:r.mode,children:r.children})}import zs from"react-use-measure";import Fn from"react";var st=Fn.createContext(null);st.displayName="Atlas";var bt=Fn.createContext(null);bt.displayName="Bounds";import $n,{useCallback as Es,useEffect as Vn,useRef as Cs}from"react";import ps from"react-reconciler";var jt,gs=typeof performance=="object"&&typeof performance.now=="function";if(gs){let r=performance;jt=()=>r.now()}else{let r=Date,e=r.now();jt=()=>r.now()-e}import{version as ys}from"react";var bs=8,Dn=32,vs=2;var Bn=0;function Wn(r,e){r&&r.appendChild&&e&&r.appendChild(e)}function Nn(r,e){r&&r.removeChild&&e&&r.removeChild(e)}function ws(r,e){return Nn(r.world,e)}function xs(r,e,t){return Hn(r.world,e,t)}function Hn(r,e,t){r&&r instanceof nt&&(r=r.world),r&&r.insertBefore&&r.insertBefore(e,t)}function jn(r,e,t){if(t&&(r.applyProps&&r.applyProps(t),r instanceof k))for(let i of Wt){let n=i.slice(2).toLowerCase();t[i]!==e[i]&&(e[i]&&r.removeEventListener(n,e[i]),r.addEventListener(n,t[i]))}}function Un(r,e){let t=Object.keys(e),i=!1;for(let n of t)if(Wt.indexOf(n)!==-1){let s=q[n];if(s){if(r.activatedEvents.indexOf(s)!==-1)continue;i=!0,r.activatedEvents.push(s)}}i&&r.triggerEventActivation()}var Te=new Map,zn={};function Ss(r,{args:e=[],...t},i,n,s){if(!(i instanceof nt)&&s){let l=d=>d.return?l(d.return):d.stateNode&&d.stateNode.containerInfo;i=l(s)}let o,h=i.world;switch(r){case"world":o=X.withProps({width:t.width,height:t.height,viewingDirection:"left-to-right"}),o.activatedEvents=h.activatedEvents,o.eventHandlers=h.eventHandlers,o.subscriptions=h.subscriptions,o.triggerEventActivation(),h=o;break;case"box":o=new J;break;case"shape":o=new Ct;break;case"worldObject":case"world-object":o=new it;break;case"worldImage":case"world-image":o=new z;break;case"texture":o=new ft;break;case"compositeImage":case"composite-image":o=new te({id:t.id,width:t.width,height:t.height,images:[],renderOptions:t.renderOptions});break;case"tiledImage":case"tiled-image":o=G.fromTile(t.uri,t.display,t.tile,t.scaleFactor,void 0,t.format,t.useFloorCalc,t.version3);break;case"paragraph":o=new ht,o.text=t.children;break;default:return}return Un(h,t),jn(o,{},t),o}function Ps(r,e){if(e instanceof X)r.world=e;else if(e instanceof it)r.world.appendChild(e);else if(e)throw new Error("Invalid root")}var Ce=Bn,Ut=ps({unstable_now:jt,now:jt,createInstance:Ss,removeChild:Nn,appendChild:Wn,appendInitialChild:Wn,insertBefore:Hn,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:Ps,removeChildFromContainer:ws,createTextInstance(){},insertInContainerBefore:xs,prepareUpdate(r,e,t,i,n){return Un(n.world,i),i},commitUpdate(r,e,t,i,n,s){let o=e,h=t;typeof h=="string"&&(o=t,h=t),r.applyProps&&h&&jn(r,i,h)},finalizeInitialChildren(r){return r?.__handlers},getChildHostContext(){return zn},getRootHostContext(){return zn},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 Dn},getInstanceFromNode(r){throw new Error("Not implemented")},getInstanceFromScope(r){throw new Error("Not implemented")},prepareScopeUpdate(r,e){throw new Error("Not implemented")},logRecoverableError(){},requestPostPaintCallback(){},rendererPackageName:"@atlas-viewer/atlas",rendererVersion:ys,shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent:()=>{},resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,maySuspendCommit:()=>!1,preloadInstance:()=>!0,startSuspendingCommit(){},suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,setCurrentUpdatePriority(r){Ce=r},getCurrentUpdatePriority(){return Ce},resolveUpdatePriority(){if(Ce!==Bn)return Ce;switch(typeof window<"u"&&window.event?.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return vs;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return bs;default:return Dn}},resetFormInstance(){}});Ut.injectIntoDevTools();function $t(r,e){let t=Te.get(r);t&&Ut.updateContainer(null,t,null,()=>{Te.delete(r),e&&e(r)})}var Vt={render(r,e){let t=Te.get(e);if(t)Ut.updateContainer(r,t,null);else{let i=Ut.createContainer(e,0,null,!1,null,"",()=>{},null);Ut.updateContainer(r,i,null),Te.set(e,i)}},unmountComponentAtNode(r,e){$t(r,e)}};import*as Re from"react";var $=typeof window<"u"&&(window.document?.createElement||window.navigator?.product==="ReactNative")?Re.useLayoutEffect:Re.useEffect;import{jsx as Gt}from"react/jsx-runtime";var Gn=$n.memo(({children:r,setIsReady:e,onCreated:t,bounds:i,preset:n,mode:s="explore"})=>{let o=Es(function(l){let d=Cs(!1),c=()=>{e(!0)};return Vn(()=>{if(n&&!d.current){n.runtime.goHome();let u=t&&t(n);return void(u&&u.then?u.then(c):c())}return()=>{}},[]),Vn(()=>{d.current=!0},[]),l.children},[n]);return $(()=>{if(n){let h=n.runtime;s!==h.mode&&(h.mode=s),Vt.render(Gt($n.StrictMode,{children:Gt(o,{children:Gt(bt.Provider,{value:i,children:Gt(rt.Provider,{value:s,children:Gt(st.Provider,{value:n,children:r})})})})}),h)}},[n,s,r]),$(()=>{if(n){let h=n.runtime;return()=>{Vt.unmountComponentAtNode(h)}}return()=>{}},[n]),null});var _e=class{constructor(e,t){a(this,"canvas");a(this,"gl");a(this,"program");a(this,"fragmentShader");a(this,"vertexShader");a(this,"rectBuffer");a(this,"fragmentShaderSource",`
|
|
2
2
|
precision mediump float;
|
|
3
3
|
|
|
4
4
|
uniform sampler2D u_image;
|
|
@@ -31,14 +31,14 @@ var ws=Object.create;var Ne=Object.defineProperty;var xs=Object.getOwnPropertyDe
|
|
|
31
31
|
|
|
32
32
|
v_texCoord = a_texCoord;
|
|
33
33
|
}
|
|
34
|
-
`);a(this,"attributes");a(this,"uniforms");a(this,"buffers");a(this,"rendererPosition");a(this,"dpi");a(this,"lastResize",0);a(this,"lastKnownScale",1);this.canvas=e,this.rendererPosition=e.getBoundingClientRect(),this.gl=e.getContext("webgl2"),this.fragmentShader=this.createShader(this.gl.FRAGMENT_SHADER,this.fragmentShaderSource),this.vertexShader=this.createShader(this.gl.VERTEX_SHADER,this.vertexShaderSource),this.program=this.createProgram(this.vertexShader,this.fragmentShader),this.dpi=t?.dpi||1,this.attributes={position:this.gl.getAttribLocation(this.program,"a_position"),texCoord:this.gl.getAttribLocation(this.program,"a_texCoord")},this.uniforms={resolution:this.gl.getUniformLocation(this.program,"u_resolution"),texture:this.gl.getUniformLocation(this.program,"u_texture")},this.buffers={position:this.createArrayBuffer(),texCoord:this.createArrayBuffer(new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]))},this.rectBuffer=new Float32Array(12),this.resize(),this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.gl.clearColor(0,0,0,0),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.useProgram(this.program),this.gl.enableVertexAttribArray(this.attributes.position)}resize(){this.resizeCanvasToDisplaySize(),this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.rendererPosition=this.canvas.getBoundingClientRect()}isReady(){return!0}beforeFrame(e,t,i){this.gl.clearColor(0,0,0,0),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.vertexAttribPointer(this.attributes.position,2,this.gl.FLOAT,!1,0,0),this.gl.uniform2f(this.uniforms.resolution,this.gl.canvas.width,this.gl.canvas.height),this.lastResize>1e3&&(this.lastResize=0,this.resizeCanvasToDisplaySize()),this.lastResize+=t}prepareLayer(e){(!e.__host||!e.__host.webgl)&&((e instanceof z||e instanceof G)&&this.createImageHost(e),e instanceof ft&&this.createTextureHost(e))}createTextureHost(e){e.__host=e.__host?e.__host:{};let t=this.gl,i=this.gl.createTexture();t.bindTexture(t.TEXTURE_2D,i),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1);let n;if(e instanceof ft){let
|
|
34
|
+
`);a(this,"attributes");a(this,"uniforms");a(this,"buffers");a(this,"rendererPosition");a(this,"dpi");a(this,"lastResize",0);a(this,"lastKnownScale",1);this.canvas=e,this.rendererPosition=e.getBoundingClientRect(),this.gl=e.getContext("webgl2"),this.fragmentShader=this.createShader(this.gl.FRAGMENT_SHADER,this.fragmentShaderSource),this.vertexShader=this.createShader(this.gl.VERTEX_SHADER,this.vertexShaderSource),this.program=this.createProgram(this.vertexShader,this.fragmentShader),this.dpi=t?.dpi||1,this.attributes={position:this.gl.getAttribLocation(this.program,"a_position"),texCoord:this.gl.getAttribLocation(this.program,"a_texCoord")},this.uniforms={resolution:this.gl.getUniformLocation(this.program,"u_resolution"),texture:this.gl.getUniformLocation(this.program,"u_texture")},this.buffers={position:this.createArrayBuffer(),texCoord:this.createArrayBuffer(new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]))},this.rectBuffer=new Float32Array(12),this.resize(),this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.gl.clearColor(0,0,0,0),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.useProgram(this.program),this.gl.enableVertexAttribArray(this.attributes.position)}resize(){this.resizeCanvasToDisplaySize(),this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.rendererPosition=this.canvas.getBoundingClientRect()}isReady(){return!0}beforeFrame(e,t,i){this.gl.clearColor(0,0,0,0),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.vertexAttribPointer(this.attributes.position,2,this.gl.FLOAT,!1,0,0),this.gl.uniform2f(this.uniforms.resolution,this.gl.canvas.width,this.gl.canvas.height),this.lastResize>1e3&&(this.lastResize=0,this.resizeCanvasToDisplaySize()),this.lastResize+=t}prepareLayer(e){(!e.__host||!e.__host.webgl)&&((e instanceof z||e instanceof G)&&this.createImageHost(e),e instanceof ft&&this.createTextureHost(e))}createTextureHost(e){e.__host=e.__host?e.__host:{};let t=this.gl,i=this.gl.createTexture();t.bindTexture(t.TEXTURE_2D,i),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1);let n;if(e instanceof ft){let s=e.getTexture();s.source&&t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,s.source),n=s}t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),e.__host.webgl={height:e.height,width:e.width,texture:i,lastImage:n}}createImageHost(e){let t=[...new Array(e.points.length/5)];e.__host=e.__host?e.__host:{},e.__host.webgl={height:e.height,width:e.width,textures:t,loading:[],loaded:[],lastLevelRendered:-1,onLoad:(i,n)=>{let s=this.gl,o=this.gl.createTexture();s.bindTexture(s.TEXTURE_2D,o),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,n),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.bindTexture(s.TEXTURE_2D,null),e.__host.webgl.textures[i]=o,e.__host.webgl.loaded.push(i)}}}paint(e,t,i,n,s,o){if(e.type==="spacial-content"&&e.__host&&e.__host.webgl){if(e.getTexture){let l=e?.getTexture();if(l&&e.__host.webgl.lastImage!==l.hash&&l.source&&!e.__host.webgl.error)try{let c=this.gl.RGBA,u=this.gl.RGBA,m=this.gl.UNSIGNED_BYTE;this.gl.bindTexture(this.gl.TEXTURE_2D,e.__host.webgl.texture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,c,u,m,l.source),e.__host.webgl.lastImage=l.hash}catch(d){e.__host.webgl.error=d}}if(e.__host.webgl.loading&&e.__host.webgl.loading.indexOf(t)===-1&&e.getImageUrl){e.__host.webgl.loading.push(t);let l=document.createElement("img");l.decoding="async",l.crossOrigin="anonymous",l.src=e.getImageUrl(t),l.onload=()=>(l.onload=null,e.__host.webgl.onLoad(t,l))}let h=e.__host.webgl.texture?e.__host.webgl.texture:e.__host.webgl.textures[t];h&&(this.gl.enableVertexAttribArray(this.attributes.texCoord),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.buffers.texCoord),this.gl.enableVertexAttribArray(this.attributes.texCoord),this.gl.vertexAttribPointer(this.attributes.texCoord,2,this.gl.FLOAT,!1,0,0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.buffers.position),this.gl.enableVertexAttribArray(this.attributes.position),this.gl.vertexAttribPointer(this.attributes.position,2,this.gl.FLOAT,!1,0,0),this.gl.bindTexture(this.gl.TEXTURE_2D,h),this.gl.uniform1i(this.uniforms.texture,0),this.setRectangle(i,n,s,o),this.gl.drawArrays(this.gl.TRIANGLES,0,6))}}afterPaintLayer(e,t){}pendingUpdate(){return!0}getPointsAt(e,t,i,n){return e.getPointsAt(t,i,n)}afterFrame(){}getScale(e,t,i){if(Number.isNaN(e)||Number.isNaN(t))return this.lastKnownScale;let n=this.getCanvasDims(),s=n.width/e,o=n.height/t,h=(s<o?o:s)*(i&&this.dpi||1);return Number.isNaN(h)||(this.lastKnownScale=h),this.lastKnownScale}getCanvasDims(){return{width:this.canvas.width/this.dpi,height:this.canvas.height/this.dpi}}getViewportBounds(e,t,i){return null}createShader(e,t){let i=this.gl.createShader(e);if(i){if(this.gl.shaderSource(i,t),this.gl.compileShader(i),this.gl.getShaderParameter(i,this.gl.COMPILE_STATUS))return i;let s=this.gl.getShaderInfoLog(i);if(this.gl.deleteShader(i),s)throw new Error(s)}throw new Error("Invalid shader")}createProgram(e,t){let i=this.gl.createProgram();if(i){if(this.gl.attachShader(i,e),this.gl.attachShader(i,t),this.gl.linkProgram(i),this.gl.getProgramParameter(i,this.gl.LINK_STATUS))return i;let s=this.gl.getProgramInfoLog(i);if(this.gl.deleteProgram(i),s)throw new Error(s)}throw new Error("Invalid program")}resizeCanvasToDisplaySize(){let e=this.gl.canvas,t=e.clientWidth,i=e.clientHeight,n=e.width!==t||e.height!==i;return n&&(e.width=t,e.height=i),n}createArrayBuffer(e){let t=this.gl.createBuffer();if(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t),e&&this.gl.bufferData(this.gl.ARRAY_BUFFER,e,this.gl.STATIC_DRAW),!t)throw new Error("Cannot create buffer");return t}setRectangle(e,t,i,n){this.gl.bufferData(this.gl.ARRAY_BUFFER,this.getRectangle(e,t,i,n),this.gl.STATIC_DRAW)}getRectangle(e,t,i,n){let s=e,o=e+i,h=t,l=t+n;return this.rectBuffer.set([s,h,o,h,s,l,s,l,o,h,o,l]),this.rectBuffer}getRendererScreenPosition(){return this.rendererPosition}finishLayer(){}reset(){}};function Xt(r,e){let t=e?r:JSON.stringify(r),i=5381,n=t.length;for(;n;)i=i*33^t.charCodeAt(--n);let o=(i>>>0).toString(16);return o.length%2?"0"+o:o}var At=class{constructor(e){a(this,"$element");a(this,"stylesheetClasses");a(this,"activeStylesheetClasses");a(this,"sheetsDidUpdate");a(this,"sheetPrefix");a(this,"stylesheetEntries");this.sheetPrefix=e?.sheetPrefix||"a-",this.$element=document.createElement("style"),this.stylesheetClasses=[],this.activeStylesheetClasses=[],this.sheetsDidUpdate=!1,this.stylesheetEntries={}}getElement(){return this.$element}addStylesheet(e){let t=e.replace(/\s\s+/g," ").replace(/: /g,":").replace(/; /g,";").trim(),i=this.sheetPrefix+Xt(t,!0);return this.stylesheetClasses.indexOf(i)!==-1||(this.stylesheetClasses.push(i),this.activeStylesheetClasses.push(i),this.stylesheetEntries[i]=t,this.sheetsDidUpdate=!0),i}removeStylesheet(e){let t=this.sheetPrefix+Xt(e,!0);this.stylesheetClasses.indexOf(t)&&(this.stylesheetClasses=this.stylesheetClasses.filter(i=>i!==t)),this.sheetsDidUpdate=!0}clearClasses(){this.activeStylesheetClasses=[]}didUpdateActive(){if(this.activeStylesheetClasses.length){for(let e of this.activeStylesheetClasses)if(this.stylesheetClasses.indexOf(e)===-1)return!0;for(let e of this.stylesheetClasses)if(this.activeStylesheetClasses.indexOf(e)===-1)return!0}return!1}updateSheet(){(this.sheetsDidUpdate||this.didUpdateActive())&&(this.$element.innerText=this.activeStylesheetClasses.map(e=>`.${e}{${this.stylesheetEntries[e]}}`).join(""),this.sheetsDidUpdate=!1,this.stylesheetClasses=[...this.activeStylesheetClasses])}};var Ot=class{constructor(e,t){a(this,"htmlContainer");a(this,"visible",[]);a(this,"previousVisible",[]);a(this,"htmlIds",[]);a(this,"firstMeaningfulPaint",!1);a(this,"rendererPosition");a(this,"stylesheet");a(this,"options");a(this,"paintTx",1);a(this,"zIndex",0);a(this,"classes");this.htmlContainer=e,this.htmlContainer.innerHTML="",this.rendererPosition=this.htmlContainer.getBoundingClientRect(),this.options={triggerResize:()=>{},box:!1,text:!1,sheetPrefix:"",inlineStyles:!1,background:"",...t||{}},this.stylesheet=new At({sheetPrefix:this.options.sheetPrefix}),this.options.inlineStyles||this.htmlContainer.appendChild(this.stylesheet.getElement()),this.options.background&&this.htmlContainer.classList.add(this.stylesheet.addStylesheet(`
|
|
35
35
|
background: ${this.options.background};
|
|
36
36
|
`)),this.classes={hostClassName:this.stylesheet.addStylesheet(`
|
|
37
37
|
position: absolute;
|
|
38
38
|
transform-origin: 0px 0px;
|
|
39
|
-
`),interactive:this.stylesheet.addStylesheet("pointer-events: all"),nonInteractive:this.stylesheet.addStylesheet("pointer-events: none")},this.stylesheet.updateSheet()}createHtmlHost(e){if(this.htmlContainer&&(this.options.box||e.props.className||e.props.html||e.props.href)){let t=document.createElement(e.props.href?"a":"div");if(e.props.href){t.style.display="block",t.href=e.props.href;let i=e.props.hrefTarget||"_blank";t.target=i,i!=="_self"&&(t.rel="noopener noreferrer")}t.title=e.props.title||"",this.options.inlineStyles?(t.style.display="block",t.style.position="absolute",t.style.overflow="hidden",t.style.transformOrigin="0px 0px"):t.classList.add(this.classes.hostClassName),e.__host={element:t,revision:null,relative:!1},this.updateHtmlHost(e,e.width,e.height),e.__onCreate&&e.__onCreate()}}triggerResize(){this.options.triggerResize()}updateHtmlHost(e,t,i){if(e.__revision!==e.__host.revision){let n=e.__host.element,r=[this.classes.hostClassName];if(e.props.interactive?this.options.inlineStyles?n.style.pointerEvents="all":r.push(this.classes.interactive):this.options.inlineStyles?n.style.pointerEvents="none":r.push(this.classes.nonInteractive),e.props.href){n.style.display="block",n.href=e.props.href;let l=e.props.hrefTarget||"_blank";n.target=l,l!=="_self"?n.rel="noopener noreferrer":n.rel=""}else n.href&&n.removeAttribute("href");if(e.props.title&&(n.title=e.props.title||""),e.props.className&&(r.push(e.props.className),e.hovering&&r.push(`${e.props.className}--hover`),e.pressing&&r.push(`${e.props.className}--active`)),e.props.relativeStyle?(n.style.width=`${t||e.width}px`,n.style.height=`${i||e.height}px`):(n.style.width=`${e.width}px`,n.style.height=`${e.height}px`),e.props.style){Object.assign(n.style,e.props.style||{},e.hovering?e.props.hoverStyles||{}:{},e.pressing?e.props.pressStyles||{}:{});return}if(this.options.text&&e instanceof ht){e.text&&(n.innerText=e.text),e.backgroundColor&&(n.style.backgroundColor=e.backgroundColor),e.color&&(n.style.color=e.color),e.props.font&&(n.style.font=e.props.font),e.props.textAlign&&(n.style.textAlign=e.props.textAlign),e.__host.revision=e.__revision;let l=r.join(" ");n.className=l,n.part=l}e instanceof J&&(this.options.box||e.props.className||e.props.html)&&(e.props.backgroundColor&&(n.style.backgroundColor=e.props.backgroundColor),e.props.border!==n.style.border&&(n.style.border=e.props.border));let h=r.join(" ");n.className=h,n.part=h}}afterFrame(e,t,i){this.stylesheet.updateSheet();for(let n of this.previousVisible)this.visible.indexOf(n)===-1&&this.htmlContainer&&n.__id&&this.htmlIds.indexOf(n.__id)!==-1&&this.htmlContainer.removeChild(n.__host.element);this.previousVisible=this.visible}afterPaintLayer(e,t){}beforeFrame(e,t,i){this.stylesheet.clearClasses(),this.paintTx++,this.zIndex=0,this.visible=[]}getPointsAt(e,t,i,n){return e.getPointsAt(t,i,n)}getScale(e,t){let i=this.rendererPosition.width/e,n=this.rendererPosition.height/t;return i<n?n:i}getViewportBounds(e,t,i){return null}isReady(){return!1}paint(e,t,i,n,r,o){if(this.zIndex++,(this.options.text&&e instanceof ht||e instanceof J&&(this.options.box||e.props.className||e.props.html))&&e.__host.tx!==this.paintTx&&(this.visible.push(e),e.__host.tx=this.paintTx,this.htmlContainer)){this.updateHtmlHost(e,r,o);let h=r/e.width,l=e.__host.element;l.style.zIndex=`${this.zIndex}`,e.props.relativeStyle?l.style.transform=`translate(${Math.round(i)}px, ${Math.round(n)}px)`:l.style.transform=`translate(${Math.round(i)}px, ${Math.round(n)}px) scale(${h})`,this.previousVisible.indexOf(e)===-1&&this.htmlContainer.appendChild(l),this.htmlIds.indexOf(e.__id)===-1&&this.htmlIds.push(e.__id)}}pendingUpdate(){return!1}prepareLayer(e){e.__host||(e instanceof ht||e instanceof J)&&this.createHtmlHost(e)}resize(e,t){typeof e<"u"&&typeof t<"u"&&(this.htmlContainer.style.width=`${e}px`,this.htmlContainer.style.height=`${t}px`),this.rendererPosition=this.htmlContainer.getBoundingClientRect()}getRendererScreenPosition(){return this.rendererPosition}finishLayer(){}reset(){}};var Mt=class Mt{constructor(e,t,i){a(this,"element");a(this,"runtime");a(this,"unsubscribe");a(this,"activatedEvents",[]);a(this,"eventHandlers",[]);a(this,"bounds");a(this,"listening");a(this,"pointerMoveEvent");a(this,"pointerEventState",{isClicking:!1,isDragging:!1,isPressed:!1,mousedOver:[],itemsBeingDragged:[],mouseDownStart:{x:0,y:0},lastTouches:[]});a(this,"options");a(this,"_realPointerMove",e=>{this.pointerMoveEvent=e});a(this,"onWheelEvent",e=>{e.preventDefault(),this.onPointerEvent(e)});a(this,"onContextMenu",e=>{e.preventDefault();let t="onContextMenu";if(this.runtime.world.activatedEvents.indexOf(t)!==-1){let{x:i,y:n}=this.runtime.viewerToWorld(e.clientX-this.bounds.left,e.clientY-this.bounds.top);this.assignToEvent(e,i,n),this.runtime.world.propagatePointerEvent(t,e,i,n)}});a(this,"onTouchEvent",e=>{let t=q[e.type],i=[],n=e.touches.length;for(let r=0;r<n;r++){let o=e.touches.item(r);if(!o)continue;let{x:h,y:l}=this.runtime.viewerToWorld(o.clientX-this.bounds.left,o.clientY-this.bounds.top),d={id:o.identifier,x:h,y:l};i.push(d)}i.length&&this.assignToEvent(e,i[0].x,i[0].y),t!=="onTouchEnd"?(this.pointerEventState.lastTouches=i,e.atlasTouches=i,this.runtime.world.propagateTouchEvent(t,e,i)):(e.atlasTouches=[],this.runtime.world.propagateTouchEvent(t,e,this.pointerEventState.lastTouches),this.pointerEventState.lastTouches=[])});a(this,"onPointerEvent",e=>{if(e.button===2)return;let t=q[e.type];if(t&&this.runtime.world.activatedEvents.indexOf(t)!==-1){let{x:i,y:n}=this.runtime.viewerToWorld(e.clientX-this.bounds.left,e.clientY-this.bounds.top);this.assignToEvent(e,i,n),this.runtime.world.propagatePointerEvent(t,e,i,n)}});a(this,"onPointerDown",e=>{e.button!==2&&(this.pointerEventState.isPressed=!0,this.pointerEventState.isClicking=!0,this.pointerEventState.mouseDownStart.x=e.clientX,this.pointerEventState.mouseDownStart.y=e.clientY,setTimeout(()=>{this.runtime&&(this.pointerEventState.isClicking=!1)},250),setTimeout(()=>{if(this.runtime&&this.pointerEventState.isPressed&&!this.pointerEventState.isDragging){let t=this.runtime.viewerToWorld(this.pointerEventState.mouseDownStart.x-this.bounds.left,this.pointerEventState.mouseDownStart.y-this.bounds.top);this.pointerEventState.isDragging=!0,this.pointerEventState.itemsBeingDragged=this.runtime.world.propagatePointerEvent("onDragStart",e,t.x,t.y)}},800),this.onPointerEvent(e))});a(this,"onPointerUp",e=>{if(e.button!==2){if(this.pointerEventState.isClicking){let{x:t,y:i}=this.runtime.viewerToWorld(e.clientX-this.bounds.left,e.clientY-this.bounds.top);this.assignToEvent(e,t,i),this.runtime.world.propagatePointerEvent("onClick",e,t,i)}if(this.pointerEventState.isDragging){for(let t of this.pointerEventState.itemsBeingDragged)t.dispatchEvent("onDragEnd",e);this.pointerEventState.isDragging=!1}this.pointerEventState.isClicking=!1,this.pointerEventState.isPressed=!1,this.pointerEventState.itemsBeingDragged=[],this.onPointerEvent(e)}});a(this,"onPointerMove",e=>{this.pointerMoveEvent=void 0;let{x:t,y:i}=this.runtime.viewerToWorld(e.clientX-this.bounds.left,e.clientY-this.bounds.top);if(Number.isNaN(t)||Number.isNaN(i))return;this.assignToEvent(e,t,i),this.runtime.world.propagatePointerEvent("onPointerMove",e,t,i);let n=this.runtime.world.propagatePointerEvent("onMouseMove",e,t,i),r=[],o=[];for(let h of n)r.push(h.id),o.push(h),this.pointerEventState.mousedOver.indexOf(h)===-1&&(h.dispatchEvent("onMouseEnter",e),h.dispatchEvent("onPointerEnter",e),h.dispatchEvent("onMouseOver",e),h.dispatchEvent("onPointerOver",e));for(let h of this.pointerEventState.mousedOver)r.indexOf(h.id)===-1&&(h.dispatchEvent("onMouseLeave",e),h.dispatchEvent("onPointerLeave",e),h.dispatchEvent("onMouseOut",e),h.dispatchEvent("onPointerOut",e));if(this.pointerEventState.isDragging)for(let h of this.pointerEventState.itemsBeingDragged)h.dispatchEvent("onDrag",e);if(this.pointerEventState.isPressed&&!this.pointerEventState.isDragging&>(this.pointerEventState.mouseDownStart,{x:e.clientX,y:e.clientY})>50){let h=this.runtime.viewerToWorld(this.pointerEventState.mouseDownStart.x-this.bounds.left,this.pointerEventState.mouseDownStart.y-this.bounds.top);this.pointerEventState.isDragging=!0,this.pointerEventState.itemsBeingDragged=this.runtime.world.propagatePointerEvent("onDragStart",{...e,atlas:{x:h.x,y:h.y}},h.x,h.y)}this.pointerEventState.mousedOver=o});this.element=e,this.runtime=t,this.unsubscribe=t.world.addLayoutSubscriber(this.layoutSubscriber.bind(this)),this.bounds=e.getBoundingClientRect(),this.listening=!1,this.options={simulationRate:0,...i||{}};let n=0;t.registerHook("useFrame",r=>{n+=r,n>this.options.simulationRate&&this.pointerMoveEvent&&(n=0,t.updateNextFrame())}),t.registerHook("useBeforeFrame",()=>{this.pointerMoveEvent&&this.onPointerMove(this.pointerMoveEvent)}),this.activateEvents()}updateBounds(){this.bounds=this.element.getBoundingClientRect(),this.runtime.updateRendererScreenPosition()}layoutSubscriber(e){e==="event-activation"&&this.listening==!1&&this.activateEvents()}assignToEvent(e,t,i){Mt.eventPool.atlas.x=t,Mt.eventPool.atlas.y=i,e.atlas=Mt.eventPool.atlas}activateEvents(){this.listening=!0,this.element.addEventListener("pointermove",this._realPointerMove),this.element.addEventListener("pointerup",this.onPointerUp),this.element.addEventListener("pointerdown",this.onPointerDown),this.element.addEventListener("mousedown",this.onPointerEvent),this.element.addEventListener("mouseup",this.onPointerEvent),this.element.addEventListener("pointercancel",this.onPointerEvent),this.element.addEventListener("wheel",this.onWheelEvent),this.element.addEventListener("contextmenu",this.onContextMenu),this.element.addEventListener("touchstart",this.onTouchEvent),this.element.addEventListener("touchcancel",this.onTouchEvent),this.element.addEventListener("touchend",this.onTouchEvent),this.element.addEventListener("touchmove",this.onTouchEvent)}normalizeEventName(e){return e.startsWith("on")?e.slice(2).toLowerCase():e.toLowerCase()}stop(){this.listening=!1,this.element.removeEventListener("pointermove",this._realPointerMove),this.element.removeEventListener("pointerup",this.onPointerUp),this.element.removeEventListener("pointerdown",this.onPointerDown),this.element.removeEventListener("mousedown",this.onPointerEvent),this.element.removeEventListener("mouseup",this.onPointerEvent),this.element.removeEventListener("pointercancel",this.onPointerEvent),this.element.removeEventListener("wheel",this.onWheelEvent),this.element.removeEventListener("touchstart",this.onTouchEvent),this.element.removeEventListener("touchcancel",this.onTouchEvent),this.element.removeEventListener("touchend",this.onTouchEvent),this.element.removeEventListener("touchmove",this.onTouchEvent),this.unsubscribe();for(let[e,t]of this.eventHandlers)this.element.removeEventListener(this.normalizeEventName(e),t)}};a(Mt,"eventPool",{atlas:{x:0,y:0}});var Lt=Mt;function Ae({interactive:s=!0,viewport:e,forceRefresh:t,canvasElement:i,overlayElement:n,controllerConfig:r,unstable_webglRenderer:o,dpi:h,debug:l,canvasBox:d=!0,polygon:c=!0,navigatorElement:u,runtimeOptions:m}){if(!i)throw new Error("Invalid container");i.style.userSelect="none";let f=s?Pe({minZoomFactor:.5,maxZoomFactor:3,enableClickToZoom:!1,parentElement:i,...r||{}}):void 0,y=new _t([o?new _e(i,{dpi:h}):new ye(i,{dpi:h,debug:l,box:d,polygon:c}),n?new Ot(n,{box:o||!d,text:!0,triggerResize:t}):void 0,u?new be(u):void 0]),w=new nt(y,new X(1024,1024),e,f?[f]:[],m),v=new Lt(i,w);return{name:"default-preset",em:v,runtime:w,renderer:y,controller:f,canvas:i,navigator:u,unmount(){$t(w),w.stopControllers(),w.stop(),w.reset(),v&&v.stop()}}}var ct=1+Number.MIN_VALUE,Oe=class{constructor(e,t){a(this,"container");a(this,"width");a(this,"height");a(this,"pending",!0);a(this,"options");a(this,"stylesheet");a(this,"zIndex",0);a(this,"lastKnownScale",1);a(this,"rendererPosition");a(this,"currentlyVisible",[]);a(this,"previouslyVisible",[]);this.container=e,this.rendererPosition=e.getBoundingClientRect();let{width:i,height:n}=this.rendererPosition;this.width=i,this.height=n,this.options={addPart:!1,setDraggableFalse:!1,imageClass:"",widthStylesheet:!1,sheetPrefix:"position-",background:"#000",...t||{}},this.stylesheet=new At({sheetPrefix:this.options.sheetPrefix}),this.container.classList.add(this.stylesheet.addStylesheet(`
|
|
39
|
+
`),interactive:this.stylesheet.addStylesheet("pointer-events: all"),nonInteractive:this.stylesheet.addStylesheet("pointer-events: none")},this.stylesheet.updateSheet()}createHtmlHost(e){if(this.htmlContainer&&(this.options.box||e.props.className||e.props.html||e.props.href)){let t=document.createElement(e.props.href?"a":"div");if(e.props.href){t.style.display="block",t.href=e.props.href;let i=e.props.hrefTarget||"_blank";t.target=i,i!=="_self"&&(t.rel="noopener noreferrer")}t.title=e.props.title||"",this.options.inlineStyles?(t.style.display="block",t.style.position="absolute",t.style.overflow="hidden",t.style.transformOrigin="0px 0px"):t.classList.add(this.classes.hostClassName),e.__host={element:t,revision:null,relative:!1},this.updateHtmlHost(e,e.width,e.height),e.__onCreate&&e.__onCreate()}}triggerResize(){this.options.triggerResize()}updateHtmlHost(e,t,i){if(e.__revision!==e.__host.revision){let n=e.__host.element,s=[this.classes.hostClassName];if(e.props.interactive?this.options.inlineStyles?n.style.pointerEvents="all":s.push(this.classes.interactive):this.options.inlineStyles?n.style.pointerEvents="none":s.push(this.classes.nonInteractive),e.props.href){n.style.display="block",n.href=e.props.href;let l=e.props.hrefTarget||"_blank";n.target=l,l!=="_self"?n.rel="noopener noreferrer":n.rel=""}else n.href&&n.removeAttribute("href");if(e.props.title&&(n.title=e.props.title||""),e.props.className&&(s.push(e.props.className),e.hovering&&s.push(`${e.props.className}--hover`),e.pressing&&s.push(`${e.props.className}--active`)),e.props.relativeStyle?(n.style.width=`${t||e.width}px`,n.style.height=`${i||e.height}px`):(n.style.width=`${e.width}px`,n.style.height=`${e.height}px`),e.props.style){Object.assign(n.style,e.props.style||{},e.hovering?e.props.hoverStyles||{}:{},e.pressing?e.props.pressStyles||{}:{});return}if(this.options.text&&e instanceof ht){e.text&&(n.innerText=e.text),e.backgroundColor&&(n.style.backgroundColor=e.backgroundColor),e.color&&(n.style.color=e.color),e.props.font&&(n.style.font=e.props.font),e.props.textAlign&&(n.style.textAlign=e.props.textAlign),e.__host.revision=e.__revision;let l=s.join(" ");n.className=l,n.part=l}e instanceof J&&(this.options.box||e.props.className||e.props.html)&&(e.props.backgroundColor&&(n.style.backgroundColor=e.props.backgroundColor),e.props.border!==n.style.border&&(n.style.border=e.props.border));let h=s.join(" ");n.className=h,n.part=h}}afterFrame(e,t,i){this.stylesheet.updateSheet();for(let n of this.previousVisible)this.visible.indexOf(n)===-1&&this.htmlContainer&&n.__id&&this.htmlIds.indexOf(n.__id)!==-1&&this.htmlContainer.removeChild(n.__host.element);this.previousVisible=this.visible}afterPaintLayer(e,t){}beforeFrame(e,t,i){this.stylesheet.clearClasses(),this.paintTx++,this.zIndex=0,this.visible=[]}getPointsAt(e,t,i,n){return e.getPointsAt(t,i,n)}getScale(e,t){let i=this.rendererPosition.width/e,n=this.rendererPosition.height/t;return i<n?n:i}getViewportBounds(e,t,i){return null}isReady(){return!1}paint(e,t,i,n,s,o){if(this.zIndex++,(this.options.text&&e instanceof ht||e instanceof J&&(this.options.box||e.props.className||e.props.html))&&e.__host.tx!==this.paintTx&&(this.visible.push(e),e.__host.tx=this.paintTx,this.htmlContainer)){this.updateHtmlHost(e,s,o);let h=s/e.width,l=e.__host.element;l.style.zIndex=`${this.zIndex}`,e.props.relativeStyle?l.style.transform=`translate(${Math.round(i)}px, ${Math.round(n)}px)`:l.style.transform=`translate(${Math.round(i)}px, ${Math.round(n)}px) scale(${h})`,this.previousVisible.indexOf(e)===-1&&this.htmlContainer.appendChild(l),this.htmlIds.indexOf(e.__id)===-1&&this.htmlIds.push(e.__id)}}pendingUpdate(){return!1}prepareLayer(e){e.__host||(e instanceof ht||e instanceof J)&&this.createHtmlHost(e)}resize(e,t){typeof e<"u"&&typeof t<"u"&&(this.htmlContainer.style.width=`${e}px`,this.htmlContainer.style.height=`${t}px`),this.rendererPosition=this.htmlContainer.getBoundingClientRect()}getRendererScreenPosition(){return this.rendererPosition}finishLayer(){}reset(){}};var Lt=class Lt{constructor(e,t,i){a(this,"element");a(this,"runtime");a(this,"unsubscribe");a(this,"activatedEvents",[]);a(this,"eventHandlers",[]);a(this,"bounds");a(this,"listening");a(this,"pointerMoveEvent");a(this,"pointerEventState",{isClicking:!1,isDragging:!1,isPressed:!1,mousedOver:[],itemsBeingDragged:[],mouseDownStart:{x:0,y:0},lastTouches:[]});a(this,"options");a(this,"_realPointerMove",e=>{this.pointerMoveEvent=e});a(this,"onWheelEvent",e=>{e.preventDefault(),this.onPointerEvent(e)});a(this,"onContextMenu",e=>{e.preventDefault();let t="onContextMenu";if(this.runtime.world.activatedEvents.indexOf(t)!==-1){let{x:i,y:n}=this.runtime.viewerToWorld(e.clientX-this.bounds.left,e.clientY-this.bounds.top);this.assignToEvent(e,i,n),this.runtime.world.propagatePointerEvent(t,e,i,n)}});a(this,"onTouchEvent",e=>{let t=q[e.type],i=[],n=e.touches.length;for(let s=0;s<n;s++){let o=e.touches.item(s);if(!o)continue;let{x:h,y:l}=this.runtime.viewerToWorld(o.clientX-this.bounds.left,o.clientY-this.bounds.top),d={id:o.identifier,x:h,y:l};i.push(d)}i.length&&this.assignToEvent(e,i[0].x,i[0].y),t!=="onTouchEnd"?(this.pointerEventState.lastTouches=i,e.atlasTouches=i,this.runtime.world.propagateTouchEvent(t,e,i)):(e.atlasTouches=[],this.runtime.world.propagateTouchEvent(t,e,this.pointerEventState.lastTouches),this.pointerEventState.lastTouches=[])});a(this,"onPointerEvent",e=>{if(e.button===2)return;let t=q[e.type];if(t&&this.runtime.world.activatedEvents.indexOf(t)!==-1){let{x:i,y:n}=this.runtime.viewerToWorld(e.clientX-this.bounds.left,e.clientY-this.bounds.top);this.assignToEvent(e,i,n),this.runtime.world.propagatePointerEvent(t,e,i,n)}});a(this,"onPointerDown",e=>{e.button!==2&&(this.pointerEventState.isPressed=!0,this.pointerEventState.isClicking=!0,this.pointerEventState.mouseDownStart.x=e.clientX,this.pointerEventState.mouseDownStart.y=e.clientY,setTimeout(()=>{this.runtime&&(this.pointerEventState.isClicking=!1)},250),setTimeout(()=>{if(this.runtime&&this.pointerEventState.isPressed&&!this.pointerEventState.isDragging){let t=this.runtime.viewerToWorld(this.pointerEventState.mouseDownStart.x-this.bounds.left,this.pointerEventState.mouseDownStart.y-this.bounds.top);this.pointerEventState.isDragging=!0,this.pointerEventState.itemsBeingDragged=this.runtime.world.propagatePointerEvent("onDragStart",e,t.x,t.y)}},800),this.onPointerEvent(e))});a(this,"onPointerUp",e=>{if(e.button!==2){if(this.pointerEventState.isClicking){let{x:t,y:i}=this.runtime.viewerToWorld(e.clientX-this.bounds.left,e.clientY-this.bounds.top);this.assignToEvent(e,t,i),this.runtime.world.propagatePointerEvent("onClick",e,t,i)}if(this.pointerEventState.isDragging){for(let t of this.pointerEventState.itemsBeingDragged)t.dispatchEvent("onDragEnd",e);this.pointerEventState.isDragging=!1}this.pointerEventState.isClicking=!1,this.pointerEventState.isPressed=!1,this.pointerEventState.itemsBeingDragged=[],this.onPointerEvent(e)}});a(this,"onPointerMove",e=>{this.pointerMoveEvent=void 0;let{x:t,y:i}=this.runtime.viewerToWorld(e.clientX-this.bounds.left,e.clientY-this.bounds.top);if(Number.isNaN(t)||Number.isNaN(i))return;this.assignToEvent(e,t,i),this.runtime.world.propagatePointerEvent("onPointerMove",e,t,i);let n=this.runtime.world.propagatePointerEvent("onMouseMove",e,t,i),s=[],o=[];for(let h of n)s.push(h.id),o.push(h),this.pointerEventState.mousedOver.indexOf(h)===-1&&(h.dispatchEvent("onMouseEnter",e),h.dispatchEvent("onPointerEnter",e),h.dispatchEvent("onMouseOver",e),h.dispatchEvent("onPointerOver",e));for(let h of this.pointerEventState.mousedOver)s.indexOf(h.id)===-1&&(h.dispatchEvent("onMouseLeave",e),h.dispatchEvent("onPointerLeave",e),h.dispatchEvent("onMouseOut",e),h.dispatchEvent("onPointerOut",e));if(this.pointerEventState.isDragging)for(let h of this.pointerEventState.itemsBeingDragged)h.dispatchEvent("onDrag",e);if(this.pointerEventState.isPressed&&!this.pointerEventState.isDragging&>(this.pointerEventState.mouseDownStart,{x:e.clientX,y:e.clientY})>50){let h=this.runtime.viewerToWorld(this.pointerEventState.mouseDownStart.x-this.bounds.left,this.pointerEventState.mouseDownStart.y-this.bounds.top);this.pointerEventState.isDragging=!0,this.pointerEventState.itemsBeingDragged=this.runtime.world.propagatePointerEvent("onDragStart",{...e,atlas:{x:h.x,y:h.y}},h.x,h.y)}this.pointerEventState.mousedOver=o});this.element=e,this.runtime=t,this.unsubscribe=t.world.addLayoutSubscriber(this.layoutSubscriber.bind(this)),this.bounds=e.getBoundingClientRect(),this.listening=!1,this.options={simulationRate:0,...i||{}};let n=0;t.registerHook("useFrame",s=>{n+=s,n>this.options.simulationRate&&this.pointerMoveEvent&&(n=0,t.updateNextFrame())}),t.registerHook("useBeforeFrame",()=>{this.pointerMoveEvent&&this.onPointerMove(this.pointerMoveEvent)}),this.activateEvents()}updateBounds(){this.bounds=this.element.getBoundingClientRect(),this.runtime.updateRendererScreenPosition()}layoutSubscriber(e){e==="event-activation"&&this.listening==!1&&this.activateEvents()}assignToEvent(e,t,i){Lt.eventPool.atlas.x=t,Lt.eventPool.atlas.y=i,e.atlas=Lt.eventPool.atlas}activateEvents(){this.listening=!0,this.element.addEventListener("pointermove",this._realPointerMove),this.element.addEventListener("pointerup",this.onPointerUp),this.element.addEventListener("pointerdown",this.onPointerDown),this.element.addEventListener("mousedown",this.onPointerEvent),this.element.addEventListener("mouseup",this.onPointerEvent),this.element.addEventListener("pointercancel",this.onPointerEvent),this.element.addEventListener("wheel",this.onWheelEvent),this.element.addEventListener("contextmenu",this.onContextMenu),this.element.addEventListener("touchstart",this.onTouchEvent),this.element.addEventListener("touchcancel",this.onTouchEvent),this.element.addEventListener("touchend",this.onTouchEvent),this.element.addEventListener("touchmove",this.onTouchEvent)}normalizeEventName(e){return e.startsWith("on")?e.slice(2).toLowerCase():e.toLowerCase()}stop(){this.listening=!1,this.element.removeEventListener("pointermove",this._realPointerMove),this.element.removeEventListener("pointerup",this.onPointerUp),this.element.removeEventListener("pointerdown",this.onPointerDown),this.element.removeEventListener("mousedown",this.onPointerEvent),this.element.removeEventListener("mouseup",this.onPointerEvent),this.element.removeEventListener("pointercancel",this.onPointerEvent),this.element.removeEventListener("wheel",this.onWheelEvent),this.element.removeEventListener("touchstart",this.onTouchEvent),this.element.removeEventListener("touchcancel",this.onTouchEvent),this.element.removeEventListener("touchend",this.onTouchEvent),this.element.removeEventListener("touchmove",this.onTouchEvent),this.unsubscribe();for(let[e,t]of this.eventHandlers)this.element.removeEventListener(this.normalizeEventName(e),t)}};a(Lt,"eventPool",{atlas:{x:0,y:0}});var Mt=Lt;function Ae({interactive:r=!0,viewport:e,forceRefresh:t,canvasElement:i,overlayElement:n,controllerConfig:s,unstable_webglRenderer:o,dpi:h,debug:l,canvasBox:d=!0,polygon:c=!0,navigatorElement:u,runtimeOptions:m}){if(!i)throw new Error("Invalid container");i.style.userSelect="none";let f=r?Pe({minZoomFactor:.5,maxZoomFactor:3,enableClickToZoom:!1,parentElement:i,...s||{}}):void 0,y=new _t([o?new _e(i,{dpi:h}):new ye(i,{dpi:h,debug:l,box:d,polygon:c}),n?new Ot(n,{box:o||!d,text:!0,triggerResize:t}):void 0,u?new be(u):void 0]),w=new nt(y,new X(1024,1024),e,f?[f]:[],m),v=new Mt(i,w);return{name:"default-preset",em:v,runtime:w,renderer:y,controller:f,canvas:i,navigator:u,unmount(){$t(w),w.stopControllers(),w.stop(),w.reset(),v&&v.stop()}}}var ct=1+Number.MIN_VALUE,Oe=class{constructor(e,t){a(this,"container");a(this,"width");a(this,"height");a(this,"pending",!0);a(this,"options");a(this,"stylesheet");a(this,"zIndex",0);a(this,"lastKnownScale",1);a(this,"rendererPosition");a(this,"currentlyVisible",[]);a(this,"previouslyVisible",[]);this.container=e,this.rendererPosition=e.getBoundingClientRect();let{width:i,height:n}=this.rendererPosition;this.width=i,this.height=n,this.options={addPart:!1,setDraggableFalse:!1,imageClass:"",widthStylesheet:!1,sheetPrefix:"position-",background:"#000",...t||{}},this.stylesheet=new At({sheetPrefix:this.options.sheetPrefix}),this.container.classList.add(this.stylesheet.addStylesheet(`
|
|
40
40
|
background: ${this.options.background};
|
|
41
|
-
`)),this.options.widthStylesheet&&this.container.appendChild(this.stylesheet.getElement())}isReady(){return!0}resize(){this.rendererPosition=this.container.getBoundingClientRect(),this.width=this.rendererPosition.width,this.height=this.rendererPosition.height}getRendererScreenPosition(){return this.rendererPosition}afterFrame(e,t,i){this.stylesheet.updateSheet();for(let n of this.previouslyVisible)this.currentlyVisible.indexOf(n)===-1&&this.container.removeChild(n);for(let n of this.currentlyVisible)this.previouslyVisible.indexOf(n)===-1&&this.container.appendChild(n);this.previouslyVisible=this.currentlyVisible,this.currentlyVisible=[]}afterPaintLayer(e,t){}beforeFrame(e,t,i){this.stylesheet.clearClasses(),this.zIndex=0}getPointsAt(e,t,i,n){return e.getPointsAt(t,i,n)}getScale(e,t){if(Number.isNaN(e)||Number.isNaN(t))return this.lastKnownScale;let i=this.width/e,n=this.height/t,r=i<n?n:i;return Number.isNaN(r)||(this.lastKnownScale=r),this.lastKnownScale}getViewportBounds(e,t,i){return null}createImage(){let e=document.createElement("img");return this.options.imageClass?(e.className=this.options.imageClass,this.options.addPart&&e.setAttribute("part",this.options.imageClass)):(e.style.position="absolute",e.style.pointerEvents="none",e.style.userSelect="none"),this.options.setDraggableFalse&&e.setAttribute("draggable","false"),e}paint(e,t,i,n,r,o){if(this.pending=!1,this.zIndex++,e instanceof z){if(!e.__host){let l=this.createImage();l.src=e.uri,e.__host=l,this.container.appendChild(e.__host)}let h=e.__host;this.currentlyVisible.push(h),h.style.zIndex=`${this.zIndex}`,h.style.opacity=`${e.style.opacity}`,this.options.widthStylesheet?h.className=this.options.imageClass+" "+this.stylesheet.addStylesheet(`width:${(r+ct).toFixed(2)}px;height:${(o+ct).toFixed(2)}px;`):(h.style.width=`${r+ct}px`,h.style.height=`${o+ct}px`),h.style.transform=`translate(${i}px, ${n}px)`}if(e instanceof G){if(e.__host||(e.__host={images:[]}),!e.__host.images[t]){let l=e.getImageUrl(t),d=this.createImage();d.src=l,e.__host.images[t]=d,this.container.appendChild(d)}let h=e.__host.images[t];h.style.zIndex=`${this.zIndex}`,h.style.opacity=`${e.style.opacity}`,this.currentlyVisible.push(h),this.options.widthStylesheet?h.className=this.options.imageClass+" "+this.stylesheet.addStylesheet(`width:${(r+ct).toFixed(2)}px;height:${(o+ct).toFixed(2)}px;`):(h.style.width=`${r+ct}px`,h.style.height=`${o+ct}px`),h.style.transform=`translate(${i}px, ${n}px)`}}pendingUpdate(){return this.pending}prepareLayer(e){}finishLayer(e){}reset(){}};function Xn({interactive:s,viewport:e,forceRefresh:t,containerElement:i,overlayElement:n,controllerConfig:r}){if(!i)throw new Error("Invalid container");i.style.userSelect="none";let o=s?Pe({minZoomFactor:.5,maxZoomFactor:3,enableClickToZoom:!1,parentElement:i,...r||{}}):void 0,h=new Oe(i,{addPart:!1,setDraggableFalse:!1,imageClass:"atlas-static-image"}),l=n?new _t([h,new Ot(n,{box:!0,text:!0,triggerResize:t})]):h,d=new nt(l,new X(1024,1024),e,o?[o]:[]),c=new Lt(i,d);return{name:"static-preset",em:c,runtime:d,renderer:l,controller:o,container:i,overlay:n,unmount(){$t(d),d.stopControllers(),d.stop(),c&&c.stop()}}}var Zn={"default-preset":Ae,"static-preset":Xn};import{useLayoutEffect as Tr,useMemo as Rr,useRef as Zt,useState as _r}from"react";var Ar={};function Me(s,e){let t=Zt(),i=Zt(),n=Zt(),r=Zt(),o=Zt({width:e.width,height:e.height,didUpdate:!0}),[h="default-preset",l=Ar]=Array.isArray(s)?s||[]:[s],[d,c]=_r(null);Tr(()=>{let m=i.current,f=r.current,y=t.current,w=n.current,g=(Zn[h]||Ae)({containerElement:f,canvasElement:m,overlayElement:y,navigatorElement:w,viewport:o.current,dpi:window.devicePixelRatio||1,forceRefresh:e.forceRefresh,unstable_webglRenderer:e.unstable_webglRenderer,...l||{}});return c(g),()=>{g&&(g.unmount(),m&&(m.height=0,m.width=0),y&&(y.innerHTML=""),w&&(w.height=0,w.width=0))}},[h,l]);let u=Rr(()=>({canvas:i,overlay:t,container:r,navigator:n}),[]);return[h,d,o,u]}import{useMemo as Or}from"react";function Yn(s){return Or(()=>Xt(s),s)}import Mr from"react";import{jsx as Lr}from"react/jsx-runtime";var vt=Mr.forwardRef((s,e)=>Lr("div",{...s,ref:e,part:s.className}));import{useRef as Ir}from"react";function kr(s,e){let t={},i=new Set([...Object.keys(s),...Object.keys(e)]);for(let n of i){let r=s[n],o=e[n];r!==o&&(t[n]={before:r,after:o})}return Object.keys(t).length>0?t:null}function Qn(s,e="",t=!1){let i=Ir(s);i.current&&t&&(console.log("Diff:",e,kr(i.current,s)),i.current=s)}import{jsx as V,jsxs as Br}from"react/jsx-runtime";var Kn=["brightness","contrast","grayscale","hueRotate","invert","saturate","sepia","blur"],Jn=Fr(function(e){let{htmlChildren:t,renderPreset:i,onCreated:n,mode:r="explore",resetWorldOnChange:o=!0,unstable_webglRenderer:h=!1,unstable_noReconciler:l=!1,hideInlineStyle:d=!1,controllerConfig:c,children:u,overlayStyle:m,containerStyle:f,enableNavigator:y,className:w,containerProps:v={},homePosition:g,homeOnResize:p,homeCover:E,background:C,runtimeOptions:S,debug:P,filters:A,...T}=e;Qn(e,"Atlas.tsx",e.debug);let[F,x]=ai(r),[_,M]=ai(!1),dt=qn(!1),W=Wr(()=>(typeof i=="string"&&(i=[i,{}]),P?i?[i[0],{debug:P,...i[1]||{}}]:["default-preset",{debug:P}]:i||"default-preset"),[i,P]),[Q,H,St]=zr({scroll:!0}),ut=qn(),et=R=>{ut.current=R,Q(R)},[wi,b,D,Qt]=Me(W,{width:T.width,height:T.height,forceRefresh:St,unstable_webglRenderer:h}),[ys,xi]=ai("");Z(()=>{x(r)},[r]),Z(()=>{b&&b.em&&b.em.updateBounds()},[b,H]),Z(()=>{b?.runtime.setOptions(S||{})},[S]),Z(()=>{b&&b.runtime&&(b.runtime.mode=F),_&&b&&(b.ready=!0)},[b,_,F]),Z(()=>{b&&(E||(b.runtime.manualHomePosition=!!g,b.runtime.setHomePosition(g)))},[b,E,g]),Z(()=>{if(b){let R=b.runtime;R.resize(D.current.width,T.width,D.current.height,T.height),D.current.width=T.width,D.current.height=T.height,R.updateNextFrame(),D.current.didUpdate=!0}},[b,T.width,T.height,D]),Z(()=>{if(A&&b){let R=b.runtime,O=!1;R.hookOptions.enableFilters=!0;for(let L of Kn)A[L]?A[L]!==b.runtime.hookOptions.filters[L]&&(R.hookOptions.filters[L]=A[L],O=!0):R.hookOptions.filters[L]&&(R.hookOptions.filters[L]=0,O=!0);O&&R.updateNextFrame()}else if(b){let R=b.runtime;for(let O of Kn)R.hookOptions.filters[O]=0;R.hookOptions.enableFilters=!1,R.updateNextFrame()}},[b,A]);function Si(){if(b&&(b.overlay&&(b.overlay.style.width=`${H.width}px`,b.overlay.style.height=`${H.height}px`),b.container&&(b.container.style.width=`${H.width}px`,b.container.style.height=`${H.height}px`),E)){let R=b.runtime.world.width,O=b.runtime.world.height,L=R/O,N=D.current.width,Ft=D.current.height,at=N/Ft;if(L>at){at=Ft/N,b.runtime.manualHomePosition=!0;let mt=(R-O/at)/2;E==="start"&&(mt=0),E==="end"&&(mt=R-O/at);let Be={x:mt,y:0,width:O/at,height:O};b.runtime.setHomePosition(Be)}else{let mt=(O-R/at)/2;E==="start"&&(mt=0),E==="end"&&(mt=O-R/at),b.runtime.manualHomePosition=!0;let Be={x:0,y:mt,width:R,height:R/at};b.runtime.setHomePosition(Be)}p&&b.runtime.goHome({})}}$(()=>{Si()},[b,e.runtimeOptions?.maxOverZoom,H.height,H.width,E]),$(()=>{let R=()=>{if(b){let O=b.runtime;D.current.width!==T.width&&D.current.height!==T.height&&(O.resize(D.current.width,T.width,D.current.height,T.height),D.current.width=T.width,D.current.height=T.height,O.updateNextFrame(),D.current.didUpdate=!0)}};return window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)},[b,T.height,T.width]);let Pi={width:120},Ei=()=>{if(b&&b.navigator){let R=b.runtime.world.height,O=b.runtime.world.width,L=window.devicePixelRatio||1,N=Pi.width,Ft=Pi.width/O*R;b.navigator.width=N*L,b.navigator.height=Ft*L,b.navigator.style.width=N+"px",b.navigator.style.height=Ft+"px"}};$(()=>{if(b){Ei();let R=b.runtime;return R.world.addLayoutSubscriber(O=>{O==="recalculate-world-size"&&(Ei(),Si(),R.resize(D.current.width,T.width,D.current.height,T.height))})}return()=>{}},[b,T.width,T.height]);let bs=Dr(function(O){let L=()=>{M(!0)};return Z(()=>{if(b){b.runtime.goHome();let N=n&&n(b);return void(N&&N.then?N.then(L):L())}else throw new Error("Invalid configuration - no runtime found")},[]),O.children},[b]);Z(()=>{if(b){let R=b.runtime;if(o)return R.world.addLayoutSubscriber(O=>{O==="recalculate-world-size"&&R.goHome()})}return()=>{}},[b,o]),Z(()=>b?b.runtime.registerHook("useBeforeFrame",()=>{if(D.current.didUpdate&&b.canvas){let O=window.devicePixelRatio||1,L=D.current.width,N=D.current.height;b.canvas.width=L*O,b.canvas.height=N*O,b.canvas.style.width=L+"px",b.canvas.style.height=N+"px",b.canvas.getContext("2d")?.scale(O,O),b&&b.em&&b.em.updateBounds(),D.current.didUpdate=!1}}):()=>{},[b,o]),Z(()=>{let R=()=>{b&&(x("sketch"),xi("mode-sketch")),window.removeEventListener("keyup",R)},O=L=>{if(L.code==="Space"&&b&&b.runtime.mode==="sketch"){let N=L.target?.tagName?.toLowerCase();if(N==="input"||N==="textarea"||L.target?.isContentEditable)return;L.preventDefault(),x("explore"),xi("mode-explore"),window.addEventListener("keyup",R)}};return window.addEventListener("keydown",O),()=>{window.removeEventListener("keydown",O),window.removeEventListener("keyup",R)}},[b]),dt.current=!0;let{height:yo,width:bo,...vs}=T,ze=Yn([T.width,T.height]),Ci=!0;return W&&Array.isArray(W)&&W.length>1&&W[1].interactive===!1&&(Ci=!1),C=C??"#000",ut.current&&(C=getComputedStyle(ut.current).getPropertyValue("--atlas-background")||C),Br(vt,{ref:et,className:["atlas",d?"":`atlas-width-${ze}`,ys,w,`atlas-${wi}`].filter(Boolean).join(" ").trim(),style:{...f,...d?{}:{width:T.width,height:T.height}},children:[wi==="static-preset"?V(vt,{className:"atlas-static-container",ref:Qt.container,tabIndex:0,...v}):V("canvas",{className:"atlas-canvas",part:"atlas-canvas",tabIndex:0,...vs,...v,ref:Qt.canvas,"data-background":C}),V(vt,{className:["atlas-overlay",Ci?"atlas-overlay--interactive":""].filter(Boolean).join(" ").trim(),style:{...m||{}},ref:Qt.overlay,children:l?V(bs,{children:V(bt.Provider,{value:H,children:V(st.Provider,{value:F,children:V(rt.Provider,{value:b,children:u})})})}):V(Gn,{bounds:H,preset:b,mode:F,setIsReady:M,onCreated:n,children:u})}),y?V(vt,{className:"atlas-navigator",children:V("canvas",{className:"atlas-navigator-canvas",part:"atlas-navigator-canvas",ref:Qt.navigator})}):null,d?V("style",{children:`.atlas-width-${ze} { width: ${T.width}px; height: ${T.height}px; }`}):V("style",{children:`
|
|
41
|
+
`)),this.options.widthStylesheet&&this.container.appendChild(this.stylesheet.getElement())}isReady(){return!0}resize(){this.rendererPosition=this.container.getBoundingClientRect(),this.width=this.rendererPosition.width,this.height=this.rendererPosition.height}getRendererScreenPosition(){return this.rendererPosition}afterFrame(e,t,i){this.stylesheet.updateSheet();for(let n of this.previouslyVisible)this.currentlyVisible.indexOf(n)===-1&&this.container.removeChild(n);for(let n of this.currentlyVisible)this.previouslyVisible.indexOf(n)===-1&&this.container.appendChild(n);this.previouslyVisible=this.currentlyVisible,this.currentlyVisible=[]}afterPaintLayer(e,t){}beforeFrame(e,t,i){this.stylesheet.clearClasses(),this.zIndex=0}getPointsAt(e,t,i,n){return e.getPointsAt(t,i,n)}getScale(e,t){if(Number.isNaN(e)||Number.isNaN(t))return this.lastKnownScale;let i=this.width/e,n=this.height/t,s=i<n?n:i;return Number.isNaN(s)||(this.lastKnownScale=s),this.lastKnownScale}getViewportBounds(e,t,i){return null}createImage(){let e=document.createElement("img");return this.options.imageClass?(e.className=this.options.imageClass,this.options.addPart&&e.setAttribute("part",this.options.imageClass)):(e.style.position="absolute",e.style.pointerEvents="none",e.style.userSelect="none"),this.options.setDraggableFalse&&e.setAttribute("draggable","false"),e}paint(e,t,i,n,s,o){if(this.pending=!1,this.zIndex++,e instanceof z){if(!e.__host){let l=this.createImage();l.src=e.uri,e.__host=l,this.container.appendChild(e.__host)}let h=e.__host;this.currentlyVisible.push(h),h.style.zIndex=`${this.zIndex}`,h.style.opacity=`${e.style.opacity}`,this.options.widthStylesheet?h.className=this.options.imageClass+" "+this.stylesheet.addStylesheet(`width:${(s+ct).toFixed(2)}px;height:${(o+ct).toFixed(2)}px;`):(h.style.width=`${s+ct}px`,h.style.height=`${o+ct}px`),h.style.transform=`translate(${i}px, ${n}px)`}if(e instanceof G){if(e.__host||(e.__host={images:[]}),!e.__host.images[t]){let l=e.getImageUrl(t),d=this.createImage();d.src=l,e.__host.images[t]=d,this.container.appendChild(d)}let h=e.__host.images[t];h.style.zIndex=`${this.zIndex}`,h.style.opacity=`${e.style.opacity}`,this.currentlyVisible.push(h),this.options.widthStylesheet?h.className=this.options.imageClass+" "+this.stylesheet.addStylesheet(`width:${(s+ct).toFixed(2)}px;height:${(o+ct).toFixed(2)}px;`):(h.style.width=`${s+ct}px`,h.style.height=`${o+ct}px`),h.style.transform=`translate(${i}px, ${n}px)`}}pendingUpdate(){return this.pending}prepareLayer(e){}finishLayer(e){}reset(){}};function Xn({interactive:r,viewport:e,forceRefresh:t,containerElement:i,overlayElement:n,controllerConfig:s}){if(!i)throw new Error("Invalid container");i.style.userSelect="none";let o=r?Pe({minZoomFactor:.5,maxZoomFactor:3,enableClickToZoom:!1,parentElement:i,...s||{}}):void 0,h=new Oe(i,{addPart:!1,setDraggableFalse:!1,imageClass:"atlas-static-image"}),l=n?new _t([h,new Ot(n,{box:!0,text:!0,triggerResize:t})]):h,d=new nt(l,new X(1024,1024),e,o?[o]:[]),c=new Mt(i,d);return{name:"static-preset",em:c,runtime:d,renderer:l,controller:o,container:i,overlay:n,unmount(){$t(d),d.stopControllers(),d.stop(),c&&c.stop()}}}var Zn={"default-preset":Ae,"static-preset":Xn};import{useLayoutEffect as Ts,useMemo as Rs,useRef as Zt,useState as _s}from"react";var As={};function Le(r,e){let t=Zt(),i=Zt(),n=Zt(),s=Zt(),o=Zt({width:e.width,height:e.height,didUpdate:!0}),[h="default-preset",l=As]=Array.isArray(r)?r||[]:[r],[d,c]=_s(null);Ts(()=>{let m=i.current,f=s.current,y=t.current,w=n.current,g=(Zn[h]||Ae)({containerElement:f,canvasElement:m,overlayElement:y,navigatorElement:w,viewport:o.current,dpi:window.devicePixelRatio||1,forceRefresh:e.forceRefresh,unstable_webglRenderer:e.unstable_webglRenderer,...l||{}});return c(g),()=>{g&&(g.unmount(),m&&(m.height=0,m.width=0),y&&(y.innerHTML=""),w&&(w.height=0,w.width=0))}},[h,l]);let u=Rs(()=>({canvas:i,overlay:t,container:s,navigator:n}),[]);return[h,d,o,u]}import{useMemo as Os}from"react";function Yn(r){return Os(()=>Xt(r),r)}import Ls from"react";import{jsx as Ms}from"react/jsx-runtime";var vt=Ls.forwardRef((r,e)=>Ms("div",{...r,ref:e,part:r.className}));import{useRef as Is}from"react";function ks(r,e){let t={},i=new Set([...Object.keys(r),...Object.keys(e)]);for(let n of i){let s=r[n],o=e[n];s!==o&&(t[n]={before:s,after:o})}return Object.keys(t).length>0?t:null}function Qn(r,e="",t=!1){let i=Is(r);i.current&&t&&(console.log("Diff:",e,ks(i.current,r)),i.current=r)}import{jsx as V,jsxs as Bs}from"react/jsx-runtime";var Kn=["brightness","contrast","grayscale","hueRotate","invert","saturate","sepia","blur"],Jn=Fs(function(e){let{htmlChildren:t,renderPreset:i,onCreated:n,mode:s="explore",resetWorldOnChange:o=!0,unstable_webglRenderer:h=!1,unstable_noReconciler:l=!1,hideInlineStyle:d=!1,controllerConfig:c,children:u,overlayStyle:m,containerStyle:f,enableNavigator:y,className:w,containerProps:v={},homePosition:g,homeOnResize:p,homeCover:E,background:C,runtimeOptions:S,debug:P,filters:A,...T}=e;Qn(e,"Atlas.tsx",e.debug);let[F,x]=ai(s),[_,L]=ai(!1),dt=qn(!1),W=Ws(()=>(typeof i=="string"&&(i=[i,{}]),P?i?[i[0],{debug:P,...i[1]||{}}]:["default-preset",{debug:P}]:i||"default-preset"),[i,P]),[Q,H,St]=zs({scroll:!0}),ut=qn(),et=R=>{ut.current=R,Q(R)},[wi,b,D,Qt]=Le(W,{width:T.width,height:T.height,forceRefresh:St,unstable_webglRenderer:h}),[yr,xi]=ai("");Z(()=>{x(s)},[s]),Z(()=>{b&&b.em&&b.em.updateBounds()},[b,H]),Z(()=>{b?.runtime.setOptions(S||{})},[S]),Z(()=>{b&&b.runtime&&(b.runtime.mode=F),_&&b&&(b.ready=!0)},[b,_,F]),Z(()=>{b&&(E||(b.runtime.manualHomePosition=!!g,b.runtime.setHomePosition(g)))},[b,E,g]),Z(()=>{if(b){let R=b.runtime;R.resize(D.current.width,T.width,D.current.height,T.height),D.current.width=T.width,D.current.height=T.height,R.updateNextFrame(),D.current.didUpdate=!0}},[b,T.width,T.height,D]),Z(()=>{if(A&&b){let R=b.runtime,O=!1;R.hookOptions.enableFilters=!0;for(let M of Kn)A[M]?A[M]!==b.runtime.hookOptions.filters[M]&&(R.hookOptions.filters[M]=A[M],O=!0):R.hookOptions.filters[M]&&(R.hookOptions.filters[M]=0,O=!0);O&&R.updateNextFrame()}else if(b){let R=b.runtime;for(let O of Kn)R.hookOptions.filters[O]=0;R.hookOptions.enableFilters=!1,R.updateNextFrame()}},[b,A]);function Si(){if(b&&(b.overlay&&(b.overlay.style.width=`${H.width}px`,b.overlay.style.height=`${H.height}px`),b.container&&(b.container.style.width=`${H.width}px`,b.container.style.height=`${H.height}px`),E)){let R=b.runtime.world.width,O=b.runtime.world.height,M=R/O,N=D.current.width,Ft=D.current.height,at=N/Ft;if(M>at){at=Ft/N,b.runtime.manualHomePosition=!0;let mt=(R-O/at)/2;E==="start"&&(mt=0),E==="end"&&(mt=R-O/at);let Be={x:mt,y:0,width:O/at,height:O};b.runtime.setHomePosition(Be)}else{let mt=(O-R/at)/2;E==="start"&&(mt=0),E==="end"&&(mt=O-R/at),b.runtime.manualHomePosition=!0;let Be={x:0,y:mt,width:R,height:R/at};b.runtime.setHomePosition(Be)}p&&b.runtime.goHome({})}}$(()=>{Si()},[b,e.runtimeOptions?.maxOverZoom,H.height,H.width,E]),$(()=>{let R=()=>{if(b){let O=b.runtime;D.current.width!==T.width&&D.current.height!==T.height&&(O.resize(D.current.width,T.width,D.current.height,T.height),D.current.width=T.width,D.current.height=T.height,O.updateNextFrame(),D.current.didUpdate=!0)}};return window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)},[b,T.height,T.width]);let Pi={width:120},Ei=()=>{if(b&&b.navigator){let R=b.runtime.world.height,O=b.runtime.world.width,M=window.devicePixelRatio||1,N=Pi.width,Ft=Pi.width/O*R;b.navigator.width=N*M,b.navigator.height=Ft*M,b.navigator.style.width=N+"px",b.navigator.style.height=Ft+"px"}};$(()=>{if(b){Ei();let R=b.runtime;return R.world.addLayoutSubscriber(O=>{O==="recalculate-world-size"&&(Ei(),Si(),R.resize(D.current.width,T.width,D.current.height,T.height))})}return()=>{}},[b,T.width,T.height]);let br=Ds(function(O){let M=()=>{L(!0)};return Z(()=>{if(b){b.runtime.goHome();let N=n&&n(b);return void(N&&N.then?N.then(M):M())}else throw new Error("Invalid configuration - no runtime found")},[]),O.children},[b]);Z(()=>{if(b){let R=b.runtime;if(o)return R.world.addLayoutSubscriber(O=>{O==="recalculate-world-size"&&R.goHome()})}return()=>{}},[b,o]),Z(()=>b?b.runtime.registerHook("useBeforeFrame",()=>{if(D.current.didUpdate&&b.canvas){let O=window.devicePixelRatio||1,M=D.current.width,N=D.current.height;b.canvas.width=M*O,b.canvas.height=N*O,b.canvas.style.width=M+"px",b.canvas.style.height=N+"px",b.canvas.getContext("2d")?.scale(O,O),b&&b.em&&b.em.updateBounds(),D.current.didUpdate=!1}}):()=>{},[b,o]),Z(()=>{let R=()=>{b&&(x("sketch"),xi("mode-sketch")),window.removeEventListener("keyup",R)},O=M=>{if(M.code==="Space"&&b&&b.runtime.mode==="sketch"){let N=M.target?.tagName?.toLowerCase();if(N==="input"||N==="textarea"||M.target?.isContentEditable)return;M.preventDefault(),x("explore"),xi("mode-explore"),window.addEventListener("keyup",R)}};return window.addEventListener("keydown",O),()=>{window.removeEventListener("keydown",O),window.removeEventListener("keyup",R)}},[b]),dt.current=!0;let{height:yo,width:bo,...vr}=T,ze=Yn([T.width,T.height]),Ci=!0;return W&&Array.isArray(W)&&W.length>1&&W[1].interactive===!1&&(Ci=!1),C=C??"#000",ut.current&&(C=getComputedStyle(ut.current).getPropertyValue("--atlas-background")||C),Bs(vt,{ref:et,className:["atlas",d?"":`atlas-width-${ze}`,yr,w,`atlas-${wi}`].filter(Boolean).join(" ").trim(),style:{...f,...d?{}:{width:T.width,height:T.height}},children:[wi==="static-preset"?V(vt,{className:"atlas-static-container",ref:Qt.container,tabIndex:0,...v}):V("canvas",{className:"atlas-canvas",part:"atlas-canvas",tabIndex:0,...vr,...v,ref:Qt.canvas,"data-background":C}),V(vt,{className:["atlas-overlay",Ci?"atlas-overlay--interactive":""].filter(Boolean).join(" ").trim(),style:{...m||{}},ref:Qt.overlay,children:l?V(br,{children:V(bt.Provider,{value:H,children:V(rt.Provider,{value:F,children:V(st.Provider,{value:b,children:u})})})}):V(Gn,{bounds:H,preset:b,mode:F,setIsReady:L,onCreated:n,children:u})}),y?V(vt,{className:"atlas-navigator",children:V("canvas",{className:"atlas-navigator-canvas",part:"atlas-navigator-canvas",ref:Qt.navigator})}):null,d?V("style",{children:`.atlas-width-${ze} { width: ${T.width}px; height: ${T.height}px; }`}):V("style",{children:`
|
|
42
42
|
.atlas { position: relative; display: flex; background: ${C}; z-index: var(--atlas-z-index, 10); -webkit-touch-callout: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
|
|
43
43
|
.atlas-width-${ze} { width: ${T.width}px; height: ${T.height}px; }
|
|
44
44
|
.atlas-canvas { flex: 1 1 0px; }
|
|
@@ -52,14 +52,14 @@ var ws=Object.create;var Ne=Object.defineProperty;var xs=Object.getOwnPropertyDe
|
|
|
52
52
|
.atlas-static-image { position: absolute; user-select: none; transform-origin: 0px 0px; }
|
|
53
53
|
.atlas-navigator { position: absolute; top: var(--atlas-navigator-top, 10px); right: var(--atlas-navigator-bottom, 10px); left: var(--atlas-navigator-left); bottom: var(--atlas-navigator-bottom); opacity: .8 }
|
|
54
54
|
.atlas-navigator-canvas { width: 100%; }
|
|
55
|
-
`}),t]})});import{memo as
|
|
55
|
+
`}),t]})});import{memo as Ns,useEffect as Hs,useMemo as js}from"react";import Us from"react-use-measure";function tr(r){return Number(r)==r?`${r}px`:r}import{jsx as er,jsxs as $s}from"react/jsx-runtime";var Jc=Ns(function({resizeHash:e,aspectRatio:t,containerProps:i={},htmlChildren:n,...s}){let[o,h,l]=Us(),{height:d,width:c,...u}=s;Hs(()=>{l()},[c,d,e,l]);let m=js(()=>t?{width:h.width,height:h.width*(1/t)}:h,[h,t]);return $s(vt,{ref:o,className:"atlas-container",...i,children:[m.width?er(Jn,{width:m.width||100,height:m.height||100,...u,children:s.children}):null,s.hideInlineStyle?null:er("style",{children:`
|
|
56
56
|
.atlas-container {
|
|
57
57
|
display: var(--atlas-container-display, block);
|
|
58
58
|
flex: var(--atlas-container-flex, none);
|
|
59
59
|
width: var(--atlas-container-width, ${c?`${c}px`:"100%"});
|
|
60
|
-
height: var(--atlas-container-height, ${
|
|
60
|
+
height: var(--atlas-container-height, ${tr(d||(t?m.height:512))})
|
|
61
61
|
}
|
|
62
|
-
`}),n]})});import{useEffect as ke,useRef as Yr,useState as ss}from"react";import{useContext as Vr}from"react";var Le=()=>Vr(rt);var B=()=>{let s=Le();return s?s.runtime:void 0};import{useEffect as Gr}from"react";var is=(s,e=[])=>{let t=B();Gr(()=>t?t.registerHook("useAfterFrame",s):()=>{},e)};import{useEffect as Xr}from"react";var It=(s,e=[])=>{let t=B();Xr(()=>t?t.registerHook("useFrame",s):()=>{},e)};var ns=()=>{let s=Le();return s&&s.canvas?s.canvas:void 0};import{useContext as Zr}from"react";function Ie(){return Zr(bt)}var _d=({onCreate:s})=>{let e=Yr({x:0,y:0}),t=ns(),i=Ie(),n=B(),[r,o]=ss(),[h,l]=ss(),d=Ee();return It(()=>{n&&r&&!h&&(n.pendingUpdate=!0)},[r,h]),is(()=>{if(r&&t&&n){let c=t.getContext("2d");if(c){let{x:u,y:m,width:f,height:y}=n.worldToViewer(r.x,r.y,(h?h.x:e.current.x)-r.x,(h?h.y:e.current.y)-r.y);c.lineWidth=h?3:1,c.strokeStyle="#fff",c.strokeRect(u,m,f,y),c.lineWidth=h?3:1,c.strokeStyle="#000",c.strokeRect(u+1,m+1,f-2,y-2)}}},[r,h]),ke(()=>{let c=u=>{if(i&&n){let{x:m,y:f}=n.viewerToWorld(u.clientX-i.left,u.clientY-i.top);e.current.x=~~m,e.current.y=~~f}};return t?(t.addEventListener("mousemove",c),()=>t.removeEventListener("mousemove",c)):()=>{}},[i,t,n]),ke(()=>{let c=u=>{d==="sketch"&&(o({x:Math.round(e.current.x),y:Math.round(e.current.y)}),l(void 0))};return t?(t.addEventListener("mousedown",c),()=>t.removeEventListener("mousedown",c)):()=>{}},[t,d]),ke(()=>{let c=u=>{r&&!h&&l({x:Math.round(e.current.x),y:Math.round(e.current.y)})};return t?(t.addEventListener("mouseup",c),()=>t.removeEventListener("mouseup",c)):()=>{}},[t,r,h]),ke(()=>{r&&h&&s({x:Math.min(r.x,h.x),y:Math.min(r.y,h.y),width:Math.abs(h.x-r.x),height:Math.abs(h.y-r.y)})},[r,s,h]),null};import Qr,{useLayoutEffect as as,useRef as Fe}from"react";import{version as rs}from"react";async function os(s,e,t){if(rs.startsWith("18.")||rs.startsWith("19.")){let i=await import("react-dom/client"),n=i.default?i.default.createRoot:i.createRoot;t.current||(t.current=n(s)),t.current.render(e)}else if(typeof ReactDOM<"u"){let{render:i,unmountComponentAtNode:n}=ReactDOM;i(e,s),t.current={unmount(){n(s)}}}else{let i=await import("react-dom"),n=i.default?i.default.render:i.render,r=i.default?i.default.unmountComponentAtNode:i.unmountComponentAtNode;n(e,s),t.current={unmount(){r(s)}}}}import{jsx as hs}from"react/jsx-runtime";var hi=Qr.forwardRef(({children:s,...e},t)=>{let i=Fe(),n=B(),r=Fe(0),o=Fe(),h=Fe();return It(()=>{if(e.relative){let l=i.current;if(l&&n){let d=n.getScaleFactor();r.current!==d&&(r.current=d,l.style.transformOrigin="0 0",l.style.transform=`scale(${1/r.current})`,l.style.width=`${r.current*100}%`,l.style.height=`${r.current*100}%`,i.current&&o.current?.__owner.value?.rotation&&(l.style.transform=`scale(${1/r.current}) translate(50%, 50%) rotate(${o.current?.__owner.value?.rotation||0}deg) translate(-50%, -50%)`))}}},[e.relative]),as(()=>{let l=o.current;t&&l&&(typeof t=="function"?t(l):t.current=l);async function d(){if(l&&l.__host){let c=e.relative?hs("div",{ref:i,children:s}):s;await os(l.__host.element,c,h)}}l&&l.__host?d():l&&(l.__onCreate=d)},[t,s,o,e.relative]),as(()=>()=>{h.current&&setTimeout(()=>{h.current.unmount()},0)},[]),hs("box",{html:!0,...e,ref:o})});hi.displayName="HTMLPortal";import{useCallback as io}from"react";import{useMemo as ot}from"react";import{useCallback as di,useEffect as ui,useMemo as to,useRef as kt,useState as eo}from"react";import{useEffect as qr}from"react";var li=(s,e,t=[])=>{let i=B(),n=i?i.world:void 0;qr(()=>{if(i){let r=e,o=q[s];i.world.activatedEvents.push(o);let h=o.slice(2).toLowerCase();return i.world.addEventListener(h,r),()=>{i.world.removeEventListener(h,r)}}return()=>{}},[n,s,...t])};function ci(s,e){if(s===0)return[0,1];if(e===0)return[1,0];let t=Math.abs(s)/Math.abs(e);return[t,1-t]}import{useLayoutEffect as Kr,useRef as Jr}from"react";function ls(){let s=Jr({ctrl:!1,shift:!1,alt:!1});return Kr(()=>{function e(i){i.key==="Shift"&&(s.current.shift=!0),i.key==="Control"&&(s.current.ctrl=!0),i.key==="Alt"&&(s.current.alt=!0)}function t(i){i.key==="Shift"&&(s.current.shift=!1),i.key==="Control"&&(s.current.ctrl=!1),i.key==="Alt"&&(s.current.alt=!1)}return window.addEventListener("keydown",e),window.addEventListener("keyup",t),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",t)}},[]),s}var cs=(s,e)=>{let t=Ee(),i=B(),n=Ie(),r=kt(),o=kt(null),h=kt(),[l,d]=eo(!1),c=kt(!1),u=kt({north:0,south:0,east:0,west:0}),m=ls(),f=di(p=>E=>{if(c.current=!0,d(!0),n&&i){let{top:C,left:S}=n,P=i.viewerToWorld(E.pageX-S,E.pageY-C);h.current={x:P.x,y:P.y},r.current=p}},[n,i]),y=to(()=>s.width/s.height,[s.width,s.height]),w=di(p=>{if(!Math.abs(p.north-p.south+(p.east-p.west)))return;let C=-p.west+p.east,S=-p.north+p.south,P=s.width+C,A=s.height+S;if(P/A>=y){let F=A*y,x=P-F,[_,M]=ci(p.east,p.west);p.west=p.west+x*M,p.east=p.east-x*_}else{let F=P/y,x=A-F,[_,M]=ci(p.north,p.south);p.north=p.north+x*_,p.south=p.south-x*M}},[s.width,s.height,y]);It(()=>{h&&i&&i.updateNextFrame()}),ui(()=>{i&&i.updateNextFrame()},[i,l]);let v=di(p=>{if(!i||!n||i.mode!=="sketch")return;let{top:E,left:C}=n,S=i.viewerToWorld(p.pageX-C,p.pageY-E),P=o.current,A=!s.maintainAspectRatio&&m.current.alt,T=!A&&m.current.shift&&r.current?.indexOf("-")!==-1;if((r.current==="translate"||r.current==="east"||r.current==="north-east"||r.current==="south-east")&&(u.current.east=S.x-(h.current?h.current.x:0),A&&(u.current.west=-u.current.east)),(r.current==="translate"||r.current==="west"||r.current==="north-west"||r.current==="south-west")&&(u.current.west=S.x-(h.current?h.current.x:0),A&&(u.current.east=-u.current.west)),(r.current==="translate"||r.current==="north"||r.current==="north-east"||r.current==="north-west")&&(u.current.north=S.y-(h.current?h.current.y:0),A&&(u.current.south=-u.current.north)),(r.current==="translate"||r.current==="south"||r.current==="south-west"||r.current==="south-east")&&(u.current.south=S.y-(h.current?h.current.y:0),A&&(u.current.north=-u.current.south)),(s.maintainAspectRatio||T)&&w(u.current),P){let F=u.current.west,x=u.current.north,_=s.width+u.current.east,M=s.height+u.current.south;P.points[1]=Math.min(F,_),P.points[2]=Math.min(x,M),P.points[3]=Math.max(F,_),P.points[4]=Math.max(x,M),i.updateNextFrame()}},[i,s.width,s.height,s.maintainAspectRatio,n]);li("mousemove",v,[s.width,s.height,n]),li("pointermove",v,[s.width,s.height,n]);let g=kt();return ui(()=>{g.current=()=>{if(c.current){let p=u.current.west,E=u.current.north,C=s.width+u.current.east,S=s.height+u.current.south,P=Math.min(p,C),A=Math.min(E,S),T=Math.max(p,C),F=Math.max(E,S),x={x:(s.x||0)+P,y:(s.y||0)+A,width:T-P||1,height:F-A||1};s.maintainAspectRatio,e(x),r.current=void 0,h.current=void 0,u.current.east=0,u.current.west=0,u.current.north=0,u.current.south=0,c.current=!1,d(!1)}}},[e,s.height,s.width,s.x,s.y]),ui(()=>{let p=()=>{g.current&&g.current()};return window.addEventListener("pointerup",p),window.addEventListener("touchend",p),()=>{window.removeEventListener("pointerup",p),window.removeEventListener("touchend",p)}},[]),{portalRef:o,mode:t,mouseEvent:f,onPointerMoveCallback:v,isEditing:l}};import{Fragment as mi,jsx as Y,jsxs as fi}from"react/jsx-runtime";function ds({handleSize:s,resizable:e,onSave:t,children:i,maintainAspectRatio:n,disableCardinalControls:r,...o}){let h=typeof s>"u"?n?10:8:s,{portalRef:l,mode:d,mouseEvent:c,isEditing:u}=cs({x:o.x||0,y:o.y||0,width:o.width,height:o.height,maintainAspectRatio:n},t),m=ot(()=>c("translate"),[c]),f=ot(()=>c("east"),[c]),y=ot(()=>c("west"),[c]),w=ot(()=>c("south"),[c]),v=ot(()=>c("north"),[c]),g=ot(()=>c("south-east"),[c]),p=ot(()=>c("south-west"),[c]),E=ot(()=>c("north-east"),[c]),C=ot(()=>c("north-west"),[c]),S=d==="sketch",P={zIndex:999,boxShadow:"0px 2px 3px 0 rgba(0,0,0,0.2)",border:"1px solid rgba(155,155,155,.7)",borderRadius:n||r?"50%":2,position:"absolute",background:"#fff",pointerEvents:u?"none":S?"initial":"none"};return Y(mi,{children:fi("world-object",{...o,children:[i,S&&e?Y(hi,{ref:l,target:{x:0,y:0,height:o.height,width:o.width},relative:!0,interactive:!1,children:S&&e?fi(mi,{children:[Y("div",{onMouseDown:m,onTouchStart:m,style:{display:"block",width:"100%",height:"100%",position:"relative",border:"1px solid rgba(155,155,155, .7)",boxSizing:"border-box",pointerEvents:u?"none":S?"initial":"none"}}),n?null:fi(mi,{children:[Y("div",{title:"east",onTouchStart:f,onMouseDown:f,style:{...P,cursor:"e-resize",height:h*2,width:h,right:0,top:"50%",opacity:r?0:1,transform:`translate(${h/2}px, -${h}px)`}}),Y("div",{title:"west",onMouseDown:y,style:{...P,cursor:"w-resize",position:"absolute",height:h*2,width:h,left:0,top:"50%",opacity:r?0:1,transform:`translate(-${h/2}px, -${h}px)`}}),Y("div",{title:"north",onMouseDown:v,style:{...P,cursor:"n-resize",position:"absolute",height:h,width:h*2,left:"50%",top:0,opacity:r?0:1,transform:`translate(-${h}px, -${h/2}px)`}}),Y("div",{title:"south",onMouseDown:w,style:{...P,cursor:"s-resize",position:"absolute",height:h,width:h*2,left:"50%",bottom:0,opacity:r?0:1,transform:`translate(-${h}px, ${h/2}px)`}})]}),Y("div",{title:"north-east",onMouseDown:E,style:{...P,cursor:"ne-resize",position:"absolute",height:h,width:h,right:0,top:0,transform:`translate(${h/2}px, -${h/2}px)`}}),Y("div",{title:"south-east",onMouseDown:g,style:{...P,cursor:"se-resize",position:"absolute",height:h,width:h,bottom:0,right:0,transform:`translate(${h/2}px, ${h/2}px)`}}),Y("div",{title:"south-west",onMouseDown:p,style:{...P,cursor:"sw-resize",position:"absolute",height:h,width:h,bottom:0,left:0,transform:`translate(-${h/2}px, ${h/2}px)`}}),Y("div",{title:"north-west",onMouseDown:C,style:{...P,cursor:"nw-resize",position:"absolute",height:h,width:h,top:0,left:0,transform:`translate(-${h/2}px, -${h/2}px)`}})]}):null}):null]})})}import{jsx as us}from"react/jsx-runtime";function gu({interactive:s,region:e,onClick:t,onSave:i,maintainAspectRatio:n,disableCardinalControls:r,isEditing:o,rotation:h,style:l={backgroundColor:"rgba(0,0,0,.5)"}}){let d=io(c=>{i({id:e.id,x:e.x,y:e.y,height:e.height,width:e.width,...c})},[i,e.id,e.x,e.y,e.height,e.width]);return us(ds,{x:e.x,y:e.y,rotation:h,width:e.width,height:e.height,resizable:o,onSave:d,maintainAspectRatio:n,disableCardinalControls:r,children:us("box",{interactive:s,onContextMenu:c=>{c.preventDefault()},onClick:c=>{c.preventDefault(),c.stopPropagation(),t(e)},target:{x:0,y:0,width:e.width,height:e.height},style:l})})}import{useMemo as gi}from"react";import{jsx as De,jsxs as no}from"react/jsx-runtime";var ms=s=>{let e=s.width/(s.crop?.width||s.tiles.width),t=s.tiles.imageService.sizes||[],i=s.enableThumbnail,n=s.enableSizes,r=gi(()=>{let l=s.tiles.imageService.id||s.tiles.imageService["@id"];return l&&l.endsWith("/info.json")?l.slice(0,-1*10):l},[s.tiles.imageService.id]),o=gi(()=>{let l=s.tiles.imageService.tiles||[];if(!l.length){let d=s.width,c=[1],u=1;for(;Math.pow(2,u)<d;)u=u*2,c.push(u);return[]}return l},[s.tiles.imageService]),h=gi(()=>{let l=s.tiles.imageService;return(l?l["@context"]?Array.isArray(l["@context"])?l["@context"]:[l["@context"]]:[]:[]).indexOf("http://iiif.io/api/image/3/context.json")!==-1},[s.tiles.imageService.id]);return De("world-object",{rotation:s.rotation,scale:e,height:s.crop?.height||s.tiles.height,width:s.crop?.width||s.tiles.width,x:s.x,y:s.y,onClick:s.onClick,children:no("composite-image",{id:s.tiles.imageService.id,width:s.crop?.width||s.tiles.width,height:s.crop?.height||s.tiles.height,crop:s.crop,renderOptions:s.renderOptions,children:[i&&s.tiles.thumbnail?De("world-image",{priority:!0,uri:s.tiles.thumbnail.id,target:{width:s.tiles.width,height:s.tiles.height},display:{width:s.tiles.thumbnail.width,height:s.tiles.thumbnail.height},crop:s.crop}):null,n&&t.map((l,d)=>De("world-image",{uri:`${r}/full/${l.width},${l.height}/0/default.jpg`,target:{width:s.tiles.width,height:s.tiles.height},display:{width:l.width,height:l.height},crop:s.crop},d)),o.map(l=>(l.scaleFactors||[]).map(d=>De("tiled-image",{uri:s.tiles.imageService.id,display:{width:s.tiles.width,height:s.tiles.height},tile:l,scaleFactor:d,crop:s.crop,version3:h},`${s.tiles.imageService.id}-tile-${d}`)))]},s.tiles.imageService.id)},s.tiles.imageService.id)};import{useEffect as co,useState as uo}from"react";function fs(s){return s.id||s["@id"]}import{ImageServiceLoader as so}from"@atlas-viewer/iiif-image-api";import{createThumbnailHelper as ro}from"@iiif/helpers/thumbnail";function oo(){return typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}function ao(){let s=oo();if(typeof s.IIIF_VAULT<"u")return s.IIIF_VAULT;if(typeof s.IIIFVault>"u")throw new Error("Vault not found");return s.IIIF_VAULT=new s.IIIFVault.Vault,s.IIIF_VAULT}var wt={};function Yt(){return wt.helper||(wt.vault=ao(),wt.loader=new so,wt.helper=ro(wt.vault,{imageServiceLoader:wt.loader})),wt}async function pi(s,e,t){let{loader:i}=Yt(),n=await i.loadService({id:s,width:e,height:t});return{id:fs(n),width:e,height:t,imageService:n,thumbnail:void 0}}async function ho(s,e=512){let{vault:t,loader:i,helper:n}=Yt(),r=[];for(let o of s.items)for(let h of t.get(o).items){let d=t.get(t.get(h).body[0]).service[0],c=await pi(d.id,s.width,s.height),{best:u}=await n.getBestThumbnailAtSize(t,i,s,{maxHeight:e,maxWidth:e},!0);u&&(c.thumbnail=u),r.push(c)}return r}async function lo(s){let{vault:e}=Yt(),t=[];for(let i of s.items){let n=e.get(i);t.push(...await ho(n))}return t}async function Ou(s){try{let{vault:e}=Yt(),t=await e.loadManifest(s);return t?lo(t):[]}catch(e){return console.log("ERR",e),[]}}import{jsx as gs}from"react/jsx-runtime";var Wu=s=>{let[e,t]=uo();return co(()=>{pi(s.id,s.width,s.height).then(i=>{t(i)})},[s.height,s.id,s.width]),gs("world-object",{x:s.x||0,y:s.y||0,width:s.width,height:s.height,scale:s.scale,children:e?gs(ms,{tiles:e,x:s.x,y:s.y,width:s.crop?.width||s.width,height:s.crop?.height||s.height,rotation:s.rotation,crop:s.crop,enableSizes:s.enableSizes,enableThumbnail:s.enableThumbnail,renderOptions:s.renderOptions,children:s.children}):null})};import{useEffect as mo}from"react";var ju=(s,e=[])=>{let t=B();mo(()=>t?t.registerHook("useAfterPaint",s):()=>{},e)};import{useCallback as fo,useEffect as xt,useMemo as go,useRef as ps,useState as yi}from"react";import{jsx as bi}from"react/jsx-runtime";var qu=(s,{onCreated:e,resetWorldOnChange:t=!0,mode:i="explore",cover:n,containerRef:r,...o})=>{let[h,l]=yi(!1),[d,c]=yi(void 0),[u,m]=yi(void 0),f=ps(),y=ps(),w=go(()=>({width:o.width,height:o.height}),[o.width,o.height]),[v,g,p,E]=Me(void 0,{width:o.width,height:o.height});$(()=>{let S=document.createElement("canvas");S.height=w.height,S.width=w.width,f.current=S},[]),$(()=>{let S=f.current;S&&(S.height=w.height,S.width=w.width)},[w.width,w.height]),xt(()=>g?g.runtime.registerHook("useAfterFrame",()=>{if(f.current)try{c(f.current.toDataURL())}catch(P){P instanceof Error&&m(P.message)}}):()=>{},[]),xt(()=>g?g.runtime.world.addLayoutSubscriber(P=>{P==="ready"&&l(!0)}):()=>{},[]),xt(()=>{g&&g.em&&g.em.updateBounds()},[w]),xt(()=>{g&&(g.runtime.mode=i)},[i]),xt(()=>{if(g){let S=g.runtime;S.resize(p.current.width,o.width,p.current.height,o.height),n?S.cover():S.goHome(),p.current.width=o.width,p.current.height=o.height,S.updateNextFrame()}},[o.width,o.height]),$(()=>{let S=y.current;S&&(S.style.width=`${w.width}px`,S.style.height=`${w.height}px`,S.style.pointerEvents="none",S.style.overflow="hidden")},[w.height,w.width]),$(()=>{let S=()=>{if(g&&g.runtime){let P=g.runtime;P.resize(p.current.width,o.width,p.current.height,o.height),p.current.width=o.width,p.current.height=o.height,P.updateNextFrame()}};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[g,o.height,o.width]);let C=fo(function(P){let A=()=>{g&&(g.ready=!0)};return xt(()=>{if(g){let T=e&&e(g);return void(T&&T.then?T.then(A):A())}return()=>{}},[]),P.children},[g]);return xt(()=>{if(g&&g.runtime){let S=g.runtime;if(t)return S.world.addLayoutSubscriber(P=>{P==="recalculate-world-size"&&S.goHome({cover:n})})}return()=>{}},[g,n,t]),$(()=>{g&&Vt.render(bi(C,{children:bi(st.Provider,{value:i,children:bi(rt.Provider,{value:g,children:s})})}),g.runtime)},[g,i,s]),{loading:!d&&h,uri:d,imageError:u}};import{useEffect as po}from"react";var im=(s,e=[])=>{let t=B();po(()=>t?t.registerHook("useBeforeFrame",s):()=>{},e)};import{useCallback as We,useState as vi}from"react";var om=(s=[])=>{let[e,t]=vi(s),[i,n]=vi(!1),[r,o]=vi(),h=We(()=>{n(!0),o(void 0)},[]),l=We(m=>{n(!0),o(m)},[]),d=m=>{t(f=>f.map(y=>y.id===m.id?m:y))},c=We(m=>{let f=K();t(y=>[...y,{id:f,...m}]),n(!1),o(void 0)},[]),u=We(()=>{n(!1),o(void 0)},[]);return{isEditing:i,onDeselect:u,selectedAnnotation:r,onCreateNewAnnotation:c,annotations:e,onUpdateAnnotation:d,setIsEditing:n,setSelectedAnnotation:o,editAnnotation:l,addNewAnnotation:h}};function hm(s){return s.current==="sketch"}function cm(s,e){return s?e?{...s,...e||{},":hover":s[":hover"]?Object.assign(s[":hover"]||{},e[":hover"]||{}):e[":hover"],":active":s[":active"]?Object.assign(s[":active"]||{},e[":active"]||{}):e[":hover"]}:s:e}export{Jn as Atlas,td as AtlasAuto,rt as AtlasContext,bt as BoundsContext,J as Box,Lt as BrowserEventManager,ye as CanvasRenderer,_t as CompositeRenderer,te as CompositeResource,be as DebugRenderer,_d as DrawBox,Ct as Geometry,an as GridBuilder,hi as HTMLPortal,Wu as ImageService,ft as ImageTexture,st as ModeContext,jh as ModeProvider,Ot as OverlayRenderer,Vt as ReactAtlas,gu as RegionHighlight,ds as ResizeWorldItem,nt as Runtime,z as SingleImage,Oe as StaticRenderer,ht as Text,ms as TileSet,G as TiledImage,_e as WebGLRenderer,X as World,it as WorldObject,Hi as Zone,jn as activateEvents,Hn as applyProps,he as bounceOut,hm as canDrag,Ti as createDefaultEventMap,dr as defaultConfig,Ae as defaultPreset,tt as easingFunctions,Pa as fromImage,fs as getId,ho as getTileFromCanvas,pi as getTileFromImageService,Ou as getTiles,lo as getTilesFromManifest,cm as mergeStyles,Pe as popmotionController,Zn as presets,Xn as staticPreset,Wt as supportedEventAttributes,q as supportedEventMap,$t as unmountComponentAtNode,is as useAfterFrame,ju as useAfterPaint,Le as useAtlas,qu as useAtlasImage,im as useBeforeFrame,ns as useCanvas,om as useControlledAnnotationList,It as useFrame,Ee as useMode,cs as useResizeWorldItem,B as useRuntime,li as useWorldEvent};
|
|
62
|
+
`}),n]})});import{useEffect as ke,useRef as Ys,useState as rr}from"react";import{useContext as Vs}from"react";var Me=()=>Vs(st);var B=()=>{let r=Me();return r?r.runtime:void 0};import{useEffect as Gs}from"react";var ir=(r,e=[])=>{let t=B();Gs(()=>t?t.registerHook("useAfterFrame",r):()=>{},e)};import{useEffect as Xs}from"react";var It=(r,e=[])=>{let t=B();Xs(()=>t?t.registerHook("useFrame",r):()=>{},e)};var nr=()=>{let r=Me();return r&&r.canvas?r.canvas:void 0};import{useContext as Zs}from"react";function Ie(){return Zs(bt)}var Rd=({onCreate:r})=>{let e=Ys({x:0,y:0}),t=nr(),i=Ie(),n=B(),[s,o]=rr(),[h,l]=rr(),d=Ee();return It(()=>{n&&s&&!h&&(n.pendingUpdate=!0)},[s,h]),ir(()=>{if(s&&t&&n){let c=t.getContext("2d");if(c){let{x:u,y:m,width:f,height:y}=n.worldToViewer(s.x,s.y,(h?h.x:e.current.x)-s.x,(h?h.y:e.current.y)-s.y);c.lineWidth=h?3:1,c.strokeStyle="#fff",c.strokeRect(u,m,f,y),c.lineWidth=h?3:1,c.strokeStyle="#000",c.strokeRect(u+1,m+1,f-2,y-2)}}},[s,h]),ke(()=>{let c=u=>{if(i&&n){let{x:m,y:f}=n.viewerToWorld(u.clientX-i.left,u.clientY-i.top);e.current.x=~~m,e.current.y=~~f}};return t?(t.addEventListener("mousemove",c),()=>t.removeEventListener("mousemove",c)):()=>{}},[i,t,n]),ke(()=>{let c=u=>{d==="sketch"&&(o({x:Math.round(e.current.x),y:Math.round(e.current.y)}),l(void 0))};return t?(t.addEventListener("mousedown",c),()=>t.removeEventListener("mousedown",c)):()=>{}},[t,d]),ke(()=>{let c=u=>{s&&!h&&l({x:Math.round(e.current.x),y:Math.round(e.current.y)})};return t?(t.addEventListener("mouseup",c),()=>t.removeEventListener("mouseup",c)):()=>{}},[t,s,h]),ke(()=>{s&&h&&r({x:Math.min(s.x,h.x),y:Math.min(s.y,h.y),width:Math.abs(h.x-s.x),height:Math.abs(h.y-s.y)})},[s,r,h]),null};import Qs,{useLayoutEffect as ar,useRef as Fe}from"react";import{version as sr}from"react";async function or(r,e,t){if(sr.startsWith("18.")||sr.startsWith("19.")){let i=await import("react-dom/client"),n=i.default?i.default.createRoot:i.createRoot;t.current||(t.current=n(r)),t.current.render(e)}else if(typeof ReactDOM<"u"){let{render:i,unmountComponentAtNode:n}=ReactDOM;i(e,r),t.current={unmount(){n(r)}}}else{let i=await import("react-dom"),n=i.default?i.default.render:i.render,s=i.default?i.default.unmountComponentAtNode:i.unmountComponentAtNode;n(e,r),t.current={unmount(){s(r)}}}}import{jsx as hr}from"react/jsx-runtime";var hi=Qs.forwardRef(({children:r,...e},t)=>{let i=Fe(),n=B(),s=Fe(0),o=Fe(),h=Fe();return It(()=>{if(e.relative){let l=i.current;if(l&&n){let d=n.getScaleFactor();s.current!==d&&(s.current=d,l.style.transformOrigin="0 0",l.style.transform=`scale(${1/s.current})`,l.style.width=`${s.current*100}%`,l.style.height=`${s.current*100}%`,i.current&&o.current?.__owner.value?.rotation&&(l.style.transform=`scale(${1/s.current}) translate(50%, 50%) rotate(${o.current?.__owner.value?.rotation||0}deg) translate(-50%, -50%)`))}}},[e.relative]),ar(()=>{let l=o.current;t&&l&&(typeof t=="function"?t(l):t.current=l);async function d(){if(l&&l.__host){let c=e.relative?hr("div",{ref:i,children:r}):r;await or(l.__host.element,c,h)}}l&&l.__host?d():l&&(l.__onCreate=d)},[t,r,o,e.relative]),ar(()=>()=>{h.current&&setTimeout(()=>{h.current.unmount()},0)},[]),hr("box",{html:!0,...e,ref:o})});hi.displayName="HTMLPortal";import{useCallback as io}from"react";import{useMemo as ot}from"react";import{useCallback as di,useEffect as ui,useMemo as to,useRef as kt,useState as eo}from"react";import{useEffect as qs}from"react";var li=(r,e,t=[])=>{let i=B(),n=i?i.world:void 0;qs(()=>{if(i){let s=e,o=q[r];i.world.activatedEvents.push(o);let h=o.slice(2).toLowerCase();return i.world.addEventListener(h,s),()=>{i.world.removeEventListener(h,s)}}return()=>{}},[n,r,...t])};function ci(r,e){if(r===0)return[0,1];if(e===0)return[1,0];let t=Math.abs(r)/Math.abs(e);return[t,1-t]}import{useLayoutEffect as Ks,useRef as Js}from"react";function lr(){let r=Js({ctrl:!1,shift:!1,alt:!1});return Ks(()=>{function e(i){i.key==="Shift"&&(r.current.shift=!0),i.key==="Control"&&(r.current.ctrl=!0),i.key==="Alt"&&(r.current.alt=!0)}function t(i){i.key==="Shift"&&(r.current.shift=!1),i.key==="Control"&&(r.current.ctrl=!1),i.key==="Alt"&&(r.current.alt=!1)}return window.addEventListener("keydown",e),window.addEventListener("keyup",t),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",t)}},[]),r}var cr=(r,e)=>{let t=Ee(),i=B(),n=Ie(),s=kt(),o=kt(null),h=kt(),[l,d]=eo(!1),c=kt(!1),u=kt({north:0,south:0,east:0,west:0}),m=lr(),f=di(p=>E=>{if(c.current=!0,d(!0),n&&i){let{top:C,left:S}=n,P=i.viewerToWorld(E.pageX-S,E.pageY-C);h.current={x:P.x,y:P.y},s.current=p}},[n,i]),y=to(()=>r.width/r.height,[r.width,r.height]),w=di(p=>{if(!Math.abs(p.north-p.south+(p.east-p.west)))return;let C=-p.west+p.east,S=-p.north+p.south,P=r.width+C,A=r.height+S;if(P/A>=y){let F=A*y,x=P-F,[_,L]=ci(p.east,p.west);p.west=p.west+x*L,p.east=p.east-x*_}else{let F=P/y,x=A-F,[_,L]=ci(p.north,p.south);p.north=p.north+x*_,p.south=p.south-x*L}},[r.width,r.height,y]);It(()=>{h&&i&&i.updateNextFrame()}),ui(()=>{i&&i.updateNextFrame()},[i,l]);let v=di(p=>{if(!i||!n||i.mode!=="sketch")return;let{top:E,left:C}=n,S=i.viewerToWorld(p.pageX-C,p.pageY-E),P=o.current,A=!r.maintainAspectRatio&&m.current.alt,T=!A&&m.current.shift&&s.current?.indexOf("-")!==-1;if((s.current==="translate"||s.current==="east"||s.current==="north-east"||s.current==="south-east")&&(u.current.east=S.x-(h.current?h.current.x:0),A&&(u.current.west=-u.current.east)),(s.current==="translate"||s.current==="west"||s.current==="north-west"||s.current==="south-west")&&(u.current.west=S.x-(h.current?h.current.x:0),A&&(u.current.east=-u.current.west)),(s.current==="translate"||s.current==="north"||s.current==="north-east"||s.current==="north-west")&&(u.current.north=S.y-(h.current?h.current.y:0),A&&(u.current.south=-u.current.north)),(s.current==="translate"||s.current==="south"||s.current==="south-west"||s.current==="south-east")&&(u.current.south=S.y-(h.current?h.current.y:0),A&&(u.current.north=-u.current.south)),(r.maintainAspectRatio||T)&&w(u.current),P){let F=u.current.west,x=u.current.north,_=r.width+u.current.east,L=r.height+u.current.south;P.points[1]=Math.min(F,_),P.points[2]=Math.min(x,L),P.points[3]=Math.max(F,_),P.points[4]=Math.max(x,L),i.updateNextFrame()}},[i,r.width,r.height,r.maintainAspectRatio,n]);li("mousemove",v,[r.width,r.height,n]),li("pointermove",v,[r.width,r.height,n]);let g=kt();return ui(()=>{g.current=()=>{if(c.current){let p=u.current.west,E=u.current.north,C=r.width+u.current.east,S=r.height+u.current.south,P=Math.min(p,C),A=Math.min(E,S),T=Math.max(p,C),F=Math.max(E,S),x={x:(r.x||0)+P,y:(r.y||0)+A,width:T-P||1,height:F-A||1};r.maintainAspectRatio,e(x),s.current=void 0,h.current=void 0,u.current.east=0,u.current.west=0,u.current.north=0,u.current.south=0,c.current=!1,d(!1)}}},[e,r.height,r.width,r.x,r.y]),ui(()=>{let p=()=>{g.current&&g.current()};return window.addEventListener("pointerup",p),window.addEventListener("touchend",p),()=>{window.removeEventListener("pointerup",p),window.removeEventListener("touchend",p)}},[]),{portalRef:o,mode:t,mouseEvent:f,onPointerMoveCallback:v,isEditing:l}};import{Fragment as mi,jsx as Y,jsxs as fi}from"react/jsx-runtime";function dr({handleSize:r,resizable:e,onSave:t,children:i,maintainAspectRatio:n,disableCardinalControls:s,...o}){let h=typeof r>"u"?n?10:8:r,{portalRef:l,mode:d,mouseEvent:c,isEditing:u}=cr({x:o.x||0,y:o.y||0,width:o.width,height:o.height,maintainAspectRatio:n},t),m=ot(()=>c("translate"),[c]),f=ot(()=>c("east"),[c]),y=ot(()=>c("west"),[c]),w=ot(()=>c("south"),[c]),v=ot(()=>c("north"),[c]),g=ot(()=>c("south-east"),[c]),p=ot(()=>c("south-west"),[c]),E=ot(()=>c("north-east"),[c]),C=ot(()=>c("north-west"),[c]),S=d==="sketch",P={zIndex:999,boxShadow:"0px 2px 3px 0 rgba(0,0,0,0.2)",border:"1px solid rgba(155,155,155,.7)",borderRadius:n||s?"50%":2,position:"absolute",background:"#fff",pointerEvents:u?"none":S?"initial":"none"};return Y(mi,{children:fi("world-object",{...o,children:[i,S&&e?Y(hi,{ref:l,target:{x:0,y:0,height:o.height,width:o.width},relative:!0,interactive:!1,children:S&&e?fi(mi,{children:[Y("div",{onMouseDown:m,onTouchStart:m,style:{display:"block",width:"100%",height:"100%",position:"relative",border:"1px solid rgba(155,155,155, .7)",boxSizing:"border-box",pointerEvents:u?"none":S?"initial":"none"}}),n?null:fi(mi,{children:[Y("div",{title:"east",onTouchStart:f,onMouseDown:f,style:{...P,cursor:"e-resize",height:h*2,width:h,right:0,top:"50%",opacity:s?0:1,transform:`translate(${h/2}px, -${h}px)`}}),Y("div",{title:"west",onMouseDown:y,style:{...P,cursor:"w-resize",position:"absolute",height:h*2,width:h,left:0,top:"50%",opacity:s?0:1,transform:`translate(-${h/2}px, -${h}px)`}}),Y("div",{title:"north",onMouseDown:v,style:{...P,cursor:"n-resize",position:"absolute",height:h,width:h*2,left:"50%",top:0,opacity:s?0:1,transform:`translate(-${h}px, -${h/2}px)`}}),Y("div",{title:"south",onMouseDown:w,style:{...P,cursor:"s-resize",position:"absolute",height:h,width:h*2,left:"50%",bottom:0,opacity:s?0:1,transform:`translate(-${h}px, ${h/2}px)`}})]}),Y("div",{title:"north-east",onMouseDown:E,style:{...P,cursor:"ne-resize",position:"absolute",height:h,width:h,right:0,top:0,transform:`translate(${h/2}px, -${h/2}px)`}}),Y("div",{title:"south-east",onMouseDown:g,style:{...P,cursor:"se-resize",position:"absolute",height:h,width:h,bottom:0,right:0,transform:`translate(${h/2}px, ${h/2}px)`}}),Y("div",{title:"south-west",onMouseDown:p,style:{...P,cursor:"sw-resize",position:"absolute",height:h,width:h,bottom:0,left:0,transform:`translate(-${h/2}px, ${h/2}px)`}}),Y("div",{title:"north-west",onMouseDown:C,style:{...P,cursor:"nw-resize",position:"absolute",height:h,width:h,top:0,left:0,transform:`translate(-${h/2}px, -${h/2}px)`}})]}):null}):null]})})}import{jsx as ur}from"react/jsx-runtime";function fu({interactive:r,region:e,onClick:t,onSave:i,maintainAspectRatio:n,disableCardinalControls:s,isEditing:o,rotation:h,style:l={backgroundColor:"rgba(0,0,0,.5)"}}){let d=io(c=>{i({id:e.id,x:e.x,y:e.y,height:e.height,width:e.width,...c})},[i,e.id,e.x,e.y,e.height,e.width]);return ur(dr,{x:e.x,y:e.y,rotation:h,width:e.width,height:e.height,resizable:o,onSave:d,maintainAspectRatio:n,disableCardinalControls:s,children:ur("box",{interactive:r,onContextMenu:c=>{c.preventDefault()},onClick:c=>{c.preventDefault(),c.stopPropagation(),t(e)},target:{x:0,y:0,width:e.width,height:e.height},style:l})})}import{useMemo as gi}from"react";import{jsx as De,jsxs as no}from"react/jsx-runtime";var mr=r=>{let e=r.width/(r.crop?.width||r.tiles.width),t=r.tiles.imageService.sizes||[],i=r.enableThumbnail,n=r.enableSizes,s=gi(()=>{let l=r.tiles.imageService.id||r.tiles.imageService["@id"];return l&&l.endsWith("/info.json")?l.slice(0,-1*10):l},[r.tiles.imageService.id]),o=gi(()=>{let l=r.tiles.imageService.tiles||[];if(!l.length){let d=r.width,c=[1],u=1;for(;Math.pow(2,u)<d;)u=u*2,c.push(u);return[]}return l},[r.tiles.imageService]),h=gi(()=>{let l=r.tiles.imageService;return(l?l["@context"]?Array.isArray(l["@context"])?l["@context"]:[l["@context"]]:[]:[]).indexOf("http://iiif.io/api/image/3/context.json")!==-1},[r.tiles.imageService.id]);return De("world-object",{rotation:r.rotation,scale:e,height:r.crop?.height||r.tiles.height,width:r.crop?.width||r.tiles.width,x:r.x,y:r.y,onClick:r.onClick,children:no("composite-image",{id:r.tiles.imageService.id,width:r.crop?.width||r.tiles.width,height:r.crop?.height||r.tiles.height,crop:r.crop,renderOptions:r.renderOptions,children:[i&&r.tiles.thumbnail?De("world-image",{priority:!0,uri:r.tiles.thumbnail.id,target:{width:r.tiles.width,height:r.tiles.height},display:{width:r.tiles.thumbnail.width,height:r.tiles.thumbnail.height},crop:r.crop}):null,n&&t.map((l,d)=>De("world-image",{uri:`${s}/full/${l.width},${l.height}/0/default.jpg`,target:{width:r.tiles.width,height:r.tiles.height},display:{width:l.width,height:l.height},crop:r.crop},d)),o.map(l=>(l.scaleFactors||[]).map(d=>De("tiled-image",{uri:r.tiles.imageService.id,display:{width:r.tiles.width,height:r.tiles.height},tile:l,scaleFactor:d,crop:r.crop,version3:h},`${r.tiles.imageService.id}-tile-${d}`)))]},r.tiles.imageService.id)},r.tiles.imageService.id)};import{useEffect as co,useState as uo}from"react";function fr(r){return r.id||r["@id"]}import{ImageServiceLoader as ro}from"@atlas-viewer/iiif-image-api";import{createThumbnailHelper as so}from"@iiif/helpers/thumbnail";function oo(){return typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}function ao(){let r=oo();if(typeof r.IIIF_VAULT<"u")return r.IIIF_VAULT;if(typeof r.IIIFVault>"u")throw new Error("Vault not found");return r.IIIF_VAULT=new r.IIIFVault.Vault,r.IIIF_VAULT}var wt={};function Yt(){return wt.helper||(wt.vault=ao(),wt.loader=new ro,wt.helper=so(wt.vault,{imageServiceLoader:wt.loader})),wt}async function pi(r,e,t){let{loader:i}=Yt(),n=await i.loadService({id:r,width:e,height:t});return{id:fr(n),width:e,height:t,imageService:n,thumbnail:void 0}}async function ho(r,e=512){let{vault:t,loader:i,helper:n}=Yt(),s=[];for(let o of r.items)for(let h of t.get(o).items){let d=t.get(t.get(h).body[0]).service[0],c=await pi(d.id,r.width,r.height),{best:u}=await n.getBestThumbnailAtSize(t,i,r,{maxHeight:e,maxWidth:e},!0);u&&(c.thumbnail=u),s.push(c)}return s}async function lo(r){let{vault:e}=Yt(),t=[];for(let i of r.items){let n=e.get(i);t.push(...await ho(n))}return t}async function Au(r){try{let{vault:e}=Yt(),t=await e.loadManifest(r);return t?lo(t):[]}catch(e){return console.log("ERR",e),[]}}import{jsx as gr}from"react/jsx-runtime";var Du=r=>{let[e,t]=uo();return co(()=>{pi(r.id,r.width,r.height).then(i=>{t(i)})},[r.height,r.id,r.width]),gr("world-object",{x:r.x||0,y:r.y||0,width:r.width,height:r.height,scale:r.scale,children:e?gr(mr,{tiles:e,x:r.x,y:r.y,width:r.crop?.width||r.width,height:r.crop?.height||r.height,rotation:r.rotation,crop:r.crop,enableSizes:r.enableSizes,enableThumbnail:r.enableThumbnail,renderOptions:r.renderOptions,children:r.children}):null})};import{useEffect as mo}from"react";var Hu=(r,e=[])=>{let t=B();mo(()=>t?t.registerHook("useAfterPaint",r):()=>{},e)};import{useCallback as fo,useEffect as xt,useMemo as go,useRef as pr,useState as yi}from"react";import{jsx as bi}from"react/jsx-runtime";var Qu=(r,{onCreated:e,resetWorldOnChange:t=!0,mode:i="explore",cover:n,containerRef:s,...o})=>{let[h,l]=yi(!1),[d,c]=yi(void 0),[u,m]=yi(void 0),f=pr(),y=pr(),w=go(()=>({width:o.width,height:o.height}),[o.width,o.height]),[v,g,p,E]=Le(void 0,{width:o.width,height:o.height});$(()=>{let S=document.createElement("canvas");S.height=w.height,S.width=w.width,f.current=S},[]),$(()=>{let S=f.current;S&&(S.height=w.height,S.width=w.width)},[w.width,w.height]),xt(()=>g?g.runtime.registerHook("useAfterFrame",()=>{if(f.current)try{c(f.current.toDataURL())}catch(P){P instanceof Error&&m(P.message)}}):()=>{},[]),xt(()=>g?g.runtime.world.addLayoutSubscriber(P=>{P==="ready"&&l(!0)}):()=>{},[]),xt(()=>{g&&g.em&&g.em.updateBounds()},[w]),xt(()=>{g&&(g.runtime.mode=i)},[i]),xt(()=>{if(g){let S=g.runtime;S.resize(p.current.width,o.width,p.current.height,o.height),n?S.cover():S.goHome(),p.current.width=o.width,p.current.height=o.height,S.updateNextFrame()}},[o.width,o.height]),$(()=>{let S=y.current;S&&(S.style.width=`${w.width}px`,S.style.height=`${w.height}px`,S.style.pointerEvents="none",S.style.overflow="hidden")},[w.height,w.width]),$(()=>{let S=()=>{if(g&&g.runtime){let P=g.runtime;P.resize(p.current.width,o.width,p.current.height,o.height),p.current.width=o.width,p.current.height=o.height,P.updateNextFrame()}};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[g,o.height,o.width]);let C=fo(function(P){let A=()=>{g&&(g.ready=!0)};return xt(()=>{if(g){let T=e&&e(g);return void(T&&T.then?T.then(A):A())}return()=>{}},[]),P.children},[g]);return xt(()=>{if(g&&g.runtime){let S=g.runtime;if(t)return S.world.addLayoutSubscriber(P=>{P==="recalculate-world-size"&&S.goHome({cover:n})})}return()=>{}},[g,n,t]),$(()=>{g&&Vt.render(bi(C,{children:bi(rt.Provider,{value:i,children:bi(st.Provider,{value:g,children:r})})}),g.runtime)},[g,i,r]),{loading:!d&&h,uri:d,imageError:u}};import{useEffect as po}from"react";var em=(r,e=[])=>{let t=B();po(()=>t?t.registerHook("useBeforeFrame",r):()=>{},e)};import{useCallback as We,useState as vi}from"react";var sm=(r=[])=>{let[e,t]=vi(r),[i,n]=vi(!1),[s,o]=vi(),h=We(()=>{n(!0),o(void 0)},[]),l=We(m=>{n(!0),o(m)},[]),d=m=>{t(f=>f.map(y=>y.id===m.id?m:y))},c=We(m=>{let f=K();t(y=>[...y,{id:f,...m}]),n(!1),o(void 0)},[]),u=We(()=>{n(!1),o(void 0)},[]);return{isEditing:i,onDeselect:u,selectedAnnotation:s,onCreateNewAnnotation:c,annotations:e,onUpdateAnnotation:d,setIsEditing:n,setSelectedAnnotation:o,editAnnotation:l,addNewAnnotation:h}};function am(r){return r.current==="sketch"}function lm(r,e){return r?e?{...r,...e||{},":hover":r[":hover"]?Object.assign(r[":hover"]||{},e[":hover"]||{}):e[":hover"],":active":r[":active"]?Object.assign(r[":active"]||{},e[":active"]||{}):e[":hover"]}:r:e}export{Jn as Atlas,Jc as AtlasAuto,st as AtlasContext,bt as BoundsContext,J as Box,Mt as BrowserEventManager,ye as CanvasRenderer,_t as CompositeRenderer,te as CompositeResource,be as DebugRenderer,Rd as DrawBox,Ct as Geometry,an as GridBuilder,hi as HTMLPortal,Du as ImageService,ft as ImageTexture,rt as ModeContext,jh as ModeProvider,Ot as OverlayRenderer,Vt as ReactAtlas,fu as RegionHighlight,dr as ResizeWorldItem,nt as Runtime,z as SingleImage,Oe as StaticRenderer,ht as Text,mr as TileSet,G as TiledImage,_e as WebGLRenderer,X as World,it as WorldObject,Hi as Zone,Un as activateEvents,jn as applyProps,he as bounceOut,am as canDrag,Ti as createDefaultEventMap,ds as defaultConfig,Ae as defaultPreset,tt as easingFunctions,Pa as fromImage,fr as getId,ho as getTileFromCanvas,pi as getTileFromImageService,Au as getTiles,lo as getTilesFromManifest,lm as mergeStyles,Pe as popmotionController,Zn as presets,Xn as staticPreset,Wt as supportedEventAttributes,q as supportedEventMap,$t as unmountComponentAtNode,ir as useAfterFrame,Hu as useAfterPaint,Me as useAtlas,Qu as useAtlasImage,em as useBeforeFrame,nr as useCanvas,sm as useControlledAnnotationList,It as useFrame,Ee as useMode,cr as useResizeWorldItem,B as useRuntime,li as useWorldEvent};
|
|
63
63
|
/*! Bundled license information:
|
|
64
64
|
|
|
65
65
|
normalize-wheel/src/isEventSupported.js:
|