shop-components 0.1.34 → 0.1.35

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.
@@ -65208,7 +65208,7 @@ class aH {
65208
65208
  typeof A == "string" || (Array.isArray(A) ? this._outlinePass.selectedObjects = [...A] : this._outlinePass.selectedObjects = [A]);
65209
65209
  }
65210
65210
  appendTo(A) {
65211
- A.append(this.renderer.domElement), A.append(this.stats.dom), A.append(this.lines), A.append(this.css2dRenderer.domElement), this.stats.dom.style.bottom = "0", this.stats.dom.style.top = "auto", this.resize(), this._resizeObserver = new ResizeObserver(this.resize), this._resizeObserver.observe(A);
65211
+ A.append(this.renderer.domElement), A.append(this.stats.dom), A.append(this.lines), A.append(this.css2dRenderer.domElement), this.stats.dom.style.bottom = "0", this.stats.dom.style.top = "auto", this.resize(), this._resizeObserver = new ResizeObserver(this.resize.bind(this)), this._resizeObserver.observe(A);
65212
65212
  }
65213
65213
  add(A) {
65214
65214
  this._container.add(A);
@@ -9864,7 +9864,7 @@ vTroikaGlyphColor = uTroikaUseGlyphColors ? aTroikaGlyphColor / 255.0 : diffuse;
9864
9864
  color *= newPeak * invPeak;
9865
9865
  float g = 1. - 3. / (desaturation * extraBrightness + 3.);
9866
9866
  return mix(color, vec3(1, 1, 1), g);
9867
- }`),this.camera.position.set(10,6,-10),this.camera.lookAt(new O);const{tiles:e}=q9();this.pathTracer=new tO(this.renderer),this.pathTracer.filterGlossyFactor=.6,this.pathTracer.renderScale=window.devicePixelRatio,this.pathTracer.bounces=10,this.pathTracer.transmissiveBounces=8,this.pathTracer.tiles.set(e,e),this.pathTracer.fadeDuration=0,this.pathTracer.setBVHWorker(new MK),this.controls.addEventListener("change",()=>{var t;this.sampleCount=0,(t=this.pathTracer)==null||t.updateCamera()}),this._composer=new nO(this.renderer),this._composer.setPixelRatio(window.devicePixelRatio),this._composer.addPass(new oE(this.scene,this.camera)),this._composer.addPass(new uE),this._outlinePass=new Hn(new uA(window.innerWidth,window.innerHeight),this.scene,this.camera),this._outlinePass.visibleEdgeColor.set(26367),this._outlinePass.edgeThickness=.5,this._outlinePass.hiddenEdgeColor.set(26367),this._outlinePass.edgeStrength=3,this._outlinePass.edgeGlow=0,this._composer.addPass(this._outlinePass),this._outlinePassError=new Hn(new uA(window.innerWidth,window.innerHeight),this.scene,this.camera),this._outlinePassError.visibleEdgeColor.set(16711680),this._outlinePassError.edgeThickness=.5,this._outlinePassError.hiddenEdgeColor.set(16711680),this._outlinePassError.edgeStrength=3,this._outlinePassError.edgeGlow=0,this._composer.addPass(this._outlinePassError),this._composer.renderTarget1.texture.colorSpace=je,this._composer.renderTarget2.texture.colorSpace=je,this._fxaaPass=new J1(aE),this._composer.addPass(this._fxaaPass),this._container.add(this.amr),this.scene.add(this._container),this.ticker(),this._loadEnv(),this._initEvents(),this._ground.rotateX(-Math.PI/2),this.scene.add(this._ground)}get usePathTracing(){return this._usePathTracing}set usePathTracing(A){A?(this.amr&&(this.amr.bodyOpacity=1),this.amr.slots.forEach(e=>e.hide()),this.amr.controllers.forEach(e=>e.hide()),this.lines.hide(),this.amr.sizeBox.hide(),this.amr.goods.forEach(e=>e.hide()),this.pathTracer.renderToCanvas=!0):(this.amr.sizeBox.show(),this.amr.goods.forEach(e=>e.show()),this.amr.slots.forEach(e=>e.show()),this.amr.controllers.forEach(e=>e.show()),this.lines.show(),this.amr&&this.amr.opacityCache!==void 0?(this.amr.bodyOpacity=this.amr.opacityCache,this.amr.opacityCache=void 0):this.amr&&(this.amr.bodyOpacity=1),this.pathTracer.reset(),this._ground.visible=!1,this.scene.background=null),this._usePathTracing=A,this.controls.dampingFactor=A?1:MS,this.sampleCount=0}get fpsAverage(){return bb(this._fpsCache)}showState(){this.stats.dom.style.display="block"}hideState(){this.stats.dom.style.display="none"}_loadEnv(){new iE(new R1).load(mk,e=>{e.mapping=eo,e.minFilter=we,e.magFilter=we,e.colorSpace=je,e.format=_e,e.needsUpdate=!0,this._usePathTracing||(this.scene.environment=e,this.overlayScene.environment=e,this.scene.environmentRotation.y=Math.PI*.1,this.scene.environmentIntensity=1,this.overlayScene.environmentIntensity=1),this.pathTracer.updateEnvironment()},()=>{},()=>{})}_initEvents(){window.addEventListener("drag",this._drag),window.addEventListener("dragend",this._dragend),document.addEventListener("wheel",this._detectTrackpad),window.addEventListener("pointermove",this._pointermove),this.renderer.domElement.addEventListener("pointerdown",this._pointerdown)}async generateBVH(){this.pathTracer.pausePathTracing=!1,this.amr.slots.forEach(A=>A.hide()),this.lines.hide(),this.amr&&(this.amr.opacityCache=this.amr.bodyOpacity,this.amr.bodyOpacity=1),this.usePathTracing=!0,this.pathTracer.setScene(this.scene,this.camera)}download(){return this.renderer.domElement.toDataURL("image/png")}clearAMR(){this.amr.clean(),this.usePathTracing=!1,this.lines.clear()}async exportAMR(){const A=this._container.clone(!0);return A.traverse(e=>{e.dispose&&(e.dispose(),e.removeFromParent())}),await Hb.parseAsync(A,{onlyVisible:!0,binary:!0})}async addAMR(A){this.amr.init(this),await this.amr.load(A),this.amr.addEventListener("shape-key-changed",()=>{this.pathTracer.reset(),this.sampleCount=0,this.pathTracer.setScene(this.scene,this.camera)}),this.amr.logos.forEach(e=>{this.overlayScene.add(e.target)})}generateEdges(){this._container.traverse(A=>{if(A instanceof Te){const e=A.geometry.clone(),t=GK.generate(e);let i=t.next();for(;!i.done;)i=t.next();const r=new bl(i.value,new Bh({color:3355443}));r.position.z=-1.4,this.add(r),e.dispose()}})}select(A){typeof A=="string"||(Array.isArray(A)?this._outlinePass.selectedObjects=[...A]:this._outlinePass.selectedObjects=[A])}appendTo(A){A.append(this.renderer.domElement),A.append(this.stats.dom),A.append(this.lines),A.append(this.css2dRenderer.domElement),this.stats.dom.style.bottom="0",this.stats.dom.style.top="auto",this.resize(),this._resizeObserver=new ResizeObserver(this.resize),this._resizeObserver.observe(A)}add(A){this._container.add(A)}updatePosition(){this.lines.forceUpdate()}destroy(){var e,t;this.amr.destroy(),xs.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(e=this._fitAnimation)==null||e.stop(),window.removeEventListener("drag",this._drag),document.removeEventListener("wheel",this._detectTrackpad),window.removeEventListener("pointermove",this._pointermove),this.renderer.domElement.removeEventListener("pointerdown",this._pointerdown);const A=this.renderer.domElement.parentElement;A&&((t=this._resizeObserver)==null||t.unobserve(A)),this.controls.dispose(),this.renderer.dispose(),this._composer.dispose(),this.scene.traverse(i=>{var r;i instanceof Te?(i.geometry.dispose(),Array.isArray(i.material)?i.material.forEach(s=>s.dispose()):i.material&&i.material.dispose()):i instanceof jf?i.dispose():(r=i.dispose)==null||r.call(i),i.removeFromParent()})}}var ZK=Object.defineProperty,XK=(n,A,e)=>A in n?ZK(n,A,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[A]=e,pA=(n,A,e)=>(XK(n,typeof A!="symbol"?A+"":A,e),e);class Li{constructor(A){pA(this,"parent"),pA(this,"paused"),this.parent=A,this.paused=!1}destroy(){}down(A){return!1}move(A){return!1}up(A){return!1}wheel(A){return!1}update(A){}resize(){}reset(){}pause(){this.paused=!0}resume(){this.paused=!1}}var QK=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},PS={exports:{}};(function(n,A){(function(){var e,t;t=function(i){return n.exports=i},e={linear:function(i,r,s,o){return s*i/o+r},easeInQuad:function(i,r,s,o){return s*(i/=o)*i+r},easeOutQuad:function(i,r,s,o){return-s*(i/=o)*(i-2)+r},easeInOutQuad:function(i,r,s,o){return(i/=o/2)<1?s/2*i*i+r:-s/2*(--i*(i-2)-1)+r},easeInCubic:function(i,r,s,o){return s*(i/=o)*i*i+r},easeOutCubic:function(i,r,s,o){return s*((i=i/o-1)*i*i+1)+r},easeInOutCubic:function(i,r,s,o){return(i/=o/2)<1?s/2*i*i*i+r:s/2*((i-=2)*i*i+2)+r},easeInQuart:function(i,r,s,o){return s*(i/=o)*i*i*i+r},easeOutQuart:function(i,r,s,o){return-s*((i=i/o-1)*i*i*i-1)+r},easeInOutQuart:function(i,r,s,o){return(i/=o/2)<1?s/2*i*i*i*i+r:-s/2*((i-=2)*i*i*i-2)+r},easeInQuint:function(i,r,s,o){return s*(i/=o)*i*i*i*i+r},easeOutQuint:function(i,r,s,o){return s*((i=i/o-1)*i*i*i*i+1)+r},easeInOutQuint:function(i,r,s,o){return(i/=o/2)<1?s/2*i*i*i*i*i+r:s/2*((i-=2)*i*i*i*i+2)+r},easeInSine:function(i,r,s,o){return-s*Math.cos(i/o*(Math.PI/2))+s+r},easeOutSine:function(i,r,s,o){return s*Math.sin(i/o*(Math.PI/2))+r},easeInOutSine:function(i,r,s,o){return-s/2*(Math.cos(Math.PI*i/o)-1)+r},easeInExpo:function(i,r,s,o){return i===0?r:s*Math.pow(2,10*(i/o-1))+r},easeOutExpo:function(i,r,s,o){return i===o?r+s:s*(-Math.pow(2,-10*i/o)+1)+r},easeInOutExpo:function(i,r,s,o){return(i/=o/2)<1?s/2*Math.pow(2,10*(i-1))+r:s/2*(-Math.pow(2,-10*--i)+2)+r},easeInCirc:function(i,r,s,o){return-s*(Math.sqrt(1-(i/=o)*i)-1)+r},easeOutCirc:function(i,r,s,o){return s*Math.sqrt(1-(i=i/o-1)*i)+r},easeInOutCirc:function(i,r,s,o){return(i/=o/2)<1?-s/2*(Math.sqrt(1-i*i)-1)+r:s/2*(Math.sqrt(1-(i-=2)*i)+1)+r},easeInElastic:function(i,r,s,o){var a,l,u;return u=1.70158,l=0,a=s,i===0||(i/=o),l||(l=o*.3),a<Math.abs(s)?(a=s,u=l/4):u=l/(2*Math.PI)*Math.asin(s/a),-(a*Math.pow(2,10*(i-=1))*Math.sin((i*o-u)*(2*Math.PI)/l))+r},easeOutElastic:function(i,r,s,o){var a,l,u;return u=1.70158,l=0,a=s,i===0||(i/=o),l||(l=o*.3),a<Math.abs(s)?(a=s,u=l/4):u=l/(2*Math.PI)*Math.asin(s/a),a*Math.pow(2,-10*i)*Math.sin((i*o-u)*(2*Math.PI)/l)+s+r},easeInOutElastic:function(i,r,s,o){var a,l,u;return u=1.70158,l=0,a=s,i===0||(i/=o/2),l||(l=o*(.3*1.5)),a<Math.abs(s)?(a=s,u=l/4):u=l/(2*Math.PI)*Math.asin(s/a),i<1?-.5*(a*Math.pow(2,10*(i-=1))*Math.sin((i*o-u)*(2*Math.PI)/l))+r:a*Math.pow(2,-10*(i-=1))*Math.sin((i*o-u)*(2*Math.PI)/l)*.5+s+r},easeInBack:function(i,r,s,o,a){return a===void 0&&(a=1.70158),s*(i/=o)*i*((a+1)*i-a)+r},easeOutBack:function(i,r,s,o,a){return a===void 0&&(a=1.70158),s*((i=i/o-1)*i*((a+1)*i+a)+1)+r},easeInOutBack:function(i,r,s,o,a){return a===void 0&&(a=1.70158),(i/=o/2)<1?s/2*(i*i*(((a*=1.525)+1)*i-a))+r:s/2*((i-=2)*i*(((a*=1.525)+1)*i+a)+2)+r},easeInBounce:function(i,r,s,o){var a;return a=e.easeOutBounce(o-i,0,s,o),s-a+r},easeOutBounce:function(i,r,s,o){return(i/=o)<1/2.75?s*(7.5625*i*i)+r:i<2/2.75?s*(7.5625*(i-=1.5/2.75)*i+.75)+r:i<2.5/2.75?s*(7.5625*(i-=2.25/2.75)*i+.9375)+r:s*(7.5625*(i-=2.625/2.75)*i+.984375)+r},easeInOutBounce:function(i,r,s,o){var a;return i<o/2?(a=e.easeInBounce(i*2,0,s,o),a*.5+r):(a=e.easeOutBounce(i*2-o,0,s,o),a*.5+s*.5+r)}},t(e)}).call(QK)})(PS);const TS=PS.exports;function yd(n,A){if(n){if(typeof n=="function")return n;if(typeof n=="string")return TS[n]}else return TS[A]}const VK={removeOnInterrupt:!1,ease:"linear",time:1e3};class $K extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"startX"),pA(this,"startY"),pA(this,"deltaX"),pA(this,"deltaY"),pA(this,"keepCenter"),pA(this,"startWidth",null),pA(this,"startHeight",null),pA(this,"deltaWidth",null),pA(this,"deltaHeight",null),pA(this,"width",null),pA(this,"height",null),pA(this,"time",0),this.options=Object.assign({},VK,e),this.options.ease=yd(this.options.ease),this.setupPosition(),this.setupZoom(),this.time=0}setupPosition(){typeof this.options.position<"u"?(this.startX=this.parent.center.x,this.startY=this.parent.center.y,this.deltaX=this.options.position.x-this.parent.center.x,this.deltaY=this.options.position.y-this.parent.center.y,this.keepCenter=!1):this.keepCenter=!0}setupZoom(){this.width=null,this.height=null,typeof this.options.scale<"u"?this.width=this.parent.screenWidth/this.options.scale:typeof this.options.scaleX<"u"||typeof this.options.scaleY<"u"?(typeof this.options.scaleX<"u"&&(this.width=this.parent.screenWidth/this.options.scaleX),typeof this.options.scaleY<"u"&&(this.height=this.parent.screenHeight/this.options.scaleY)):(typeof this.options.width<"u"&&(this.width=this.options.width),typeof this.options.height<"u"&&(this.height=this.options.height)),this.width!==null&&(this.startWidth=this.parent.screenWidthInWorldPixels,this.deltaWidth=this.width-this.startWidth),this.height!==null&&(this.startHeight=this.parent.screenHeightInWorldPixels,this.deltaHeight=this.height-this.startHeight)}down(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("animate"),!1}complete(){this.parent.plugins.remove("animate"),this.width!==null&&this.parent.fitWidth(this.width,this.keepCenter,this.height===null),this.height!==null&&this.parent.fitHeight(this.height,this.keepCenter,this.width===null),!this.keepCenter&&this.options.position&&this.parent.moveCenter(this.options.position),this.parent.emit("animate-end",this.parent),this.options.callbackOnComplete&&this.options.callbackOnComplete(this.parent)}update(A){if(this.paused)return;this.time+=A;const e=new VA(this.parent.scale.x,this.parent.scale.y);if(this.time>=this.options.time){const t=this.parent.width,i=this.parent.height;this.complete(),(t!==this.parent.width||i!==this.parent.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}else{const t=this.options.ease(this.time,0,1,this.options.time);if(this.width!==null){const i=this.startWidth,r=this.deltaWidth;this.parent.fitWidth(i+r*t,this.keepCenter,this.height===null)}if(this.height!==null){const i=this.startHeight,r=this.deltaHeight;this.parent.fitHeight(i+r*t,this.keepCenter,this.width===null)}if(this.width===null?this.parent.scale.x=this.parent.scale.y:this.height===null&&(this.parent.scale.y=this.parent.scale.x),!this.keepCenter){const i=this.startX,r=this.startY,s=this.deltaX,o=this.deltaY,a=new VA(this.parent.x,this.parent.y);this.parent.moveCenter(i+s*t,r+o*t),this.parent.emit("moved",{viewport:this.parent,original:a,type:"animate"})}(this.width||this.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}}}const AF={sides:"all",friction:.5,time:150,ease:"easeInOutSine",underflow:"center",bounceBox:null};class eF extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"left"),pA(this,"top"),pA(this,"right"),pA(this,"bottom"),pA(this,"underflowX"),pA(this,"underflowY"),pA(this,"ease"),pA(this,"toX"),pA(this,"toY"),this.options=Object.assign({},AF,e),this.ease=yd(this.options.ease,"easeInOutSine"),this.options.sides?this.options.sides==="all"?this.top=this.bottom=this.left=this.right=!0:this.options.sides==="horizontal"?(this.right=this.left=!0,this.top=this.bottom=!1):this.options.sides==="vertical"?(this.left=this.right=!1,this.top=this.bottom=!0):(this.top=this.options.sides.indexOf("top")!==-1,this.bottom=this.options.sides.indexOf("bottom")!==-1,this.left=this.options.sides.indexOf("left")!==-1,this.right=this.options.sides.indexOf("right")!==-1):this.left=this.top=this.right=this.bottom=!1;const t=this.options.underflow.toLowerCase();t==="center"?(this.underflowX=0,this.underflowY=0):(this.underflowX=t.indexOf("left")!==-1?-1:t.indexOf("right")!==-1?1:0,this.underflowY=t.indexOf("top")!==-1?-1:t.indexOf("bottom")!==-1?1:0),this.reset()}isActive(){return this.toX!==null||this.toY!==null}down(){return this.toX=this.toY=null,!1}up(){return this.bounce(),!1}update(A){if(!this.paused){if(this.bounce(),this.toX){const e=this.toX;e.time+=A,this.parent.emit("moved",{viewport:this.parent,type:"bounce-x"}),e.time>=this.options.time?(this.parent.x=e.end,this.toX=null,this.parent.emit("bounce-x-end",this.parent)):this.parent.x=this.ease(e.time,e.start,e.delta,this.options.time)}if(this.toY){const e=this.toY;e.time+=A,this.parent.emit("moved",{viewport:this.parent,type:"bounce-y"}),e.time>=this.options.time?(this.parent.y=e.end,this.toY=null,this.parent.emit("bounce-y-end",this.parent)):this.parent.y=this.ease(e.time,e.start,e.delta,this.options.time)}}}calcUnderflowX(){let A;switch(this.underflowX){case-1:A=0;break;case 1:A=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:A=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}return A}calcUnderflowY(){let A;switch(this.underflowY){case-1:A=0;break;case 1:A=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:A=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}return A}oob(){const A=this.options.bounceBox;if(A){const e=typeof A.x>"u"?0:A.x,t=typeof A.y>"u"?0:A.y,i=typeof A.width>"u"?this.parent.worldWidth:A.width,r=typeof A.height>"u"?this.parent.worldHeight:A.height;return{left:this.parent.left<e,right:this.parent.right>i,top:this.parent.top<t,bottom:this.parent.bottom>r,topLeft:new VA(e*this.parent.scale.x,t*this.parent.scale.y),bottomRight:new VA(i*this.parent.scale.x-this.parent.screenWidth,r*this.parent.scale.y-this.parent.screenHeight)}}return{left:this.parent.left<0,right:this.parent.right>this.parent.worldWidth,top:this.parent.top<0,bottom:this.parent.bottom>this.parent.worldHeight,topLeft:new VA(0,0),bottomRight:new VA(this.parent.worldWidth*this.parent.scale.x-this.parent.screenWidth,this.parent.worldHeight*this.parent.scale.y-this.parent.screenHeight)}}bounce(){var A,e;if(this.paused)return;let t,i=this.parent.plugins.get("decelerate",!0);i&&(i.x||i.y)&&(i.x&&i.percentChangeX===((A=i.options)==null?void 0:A.friction)||i.y&&i.percentChangeY===((e=i.options)==null?void 0:e.friction))&&(t=this.oob(),(t.left&&this.left||t.right&&this.right)&&(i.percentChangeX=this.options.friction),(t.top&&this.top||t.bottom&&this.bottom)&&(i.percentChangeY=this.options.friction));const r=this.parent.plugins.get("drag",!0)||{},s=this.parent.plugins.get("pinch",!0)||{};if(i=i||{},!(r!=null&&r.active)&&!(s!=null&&s.active)&&(!this.toX||!this.toY)&&(!i.x||!i.y)){t=t||this.oob();const o=t.topLeft,a=t.bottomRight;if(!this.toX&&!i.x){let l=null;t.left&&this.left?l=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-o.x:t.right&&this.right&&(l=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-a.x),l!==null&&this.parent.x!==l&&(this.toX={time:0,start:this.parent.x,delta:l-this.parent.x,end:l},this.parent.emit("bounce-x-start",this.parent))}if(!this.toY&&!i.y){let l=null;t.top&&this.top?l=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-o.y:t.bottom&&this.bottom&&(l=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-a.y),l!==null&&this.parent.y!==l&&(this.toY={time:0,start:this.parent.y,delta:l-this.parent.y,end:l},this.parent.emit("bounce-y-start",this.parent))}}}reset(){this.toX=this.toY=null,this.bounce()}}const tF={left:!1,right:!1,top:!1,bottom:!1,direction:null,underflow:"center"};class iF extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"last"),pA(this,"noUnderflow"),pA(this,"underflowX"),pA(this,"underflowY"),this.options=Object.assign({},tF,e),this.options.direction&&(this.options.left=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.right=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.top=this.options.direction==="y"||this.options.direction==="all"?!0:null,this.options.bottom=this.options.direction==="y"||this.options.direction==="all"?!0:null),this.parseUnderflow(),this.last={x:null,y:null,scaleX:null,scaleY:null},this.update()}parseUnderflow(){const A=this.options.underflow.toLowerCase();A==="none"?this.noUnderflow=!0:A==="center"?(this.underflowX=this.underflowY=0,this.noUnderflow=!1):(this.underflowX=A.indexOf("left")!==-1?-1:A.indexOf("right")!==-1?1:0,this.underflowY=A.indexOf("top")!==-1?-1:A.indexOf("bottom")!==-1?1:0,this.noUnderflow=!1)}move(){return this.update(),!1}update(){if(this.paused||this.parent.x===this.last.x&&this.parent.y===this.last.y&&this.parent.scale.x===this.last.scaleX&&this.parent.scale.y===this.last.scaleY)return;const A=new VA(this.parent.x,this.parent.y),e=this.parent.plugins.decelerate||{};if(this.options.left!==null||this.options.right!==null){let t=!1;if(!this.noUnderflow&&this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x!==0&&(this.parent.x=0,t=!0);break;case 1:this.parent.x!==this.parent.screenWidth-this.parent.screenWorldWidth&&(this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth,t=!0);break;default:this.parent.x!==(this.parent.screenWidth-this.parent.screenWorldWidth)/2&&(this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2,t=!0)}else this.options.left!==null&&this.parent.left<(this.options.left===!0?0:this.options.left)&&(this.parent.x=-(this.options.left===!0?0:this.options.left)*this.parent.scale.x,e.x=0,t=!0),this.options.right!==null&&this.parent.right>(this.options.right===!0?this.parent.worldWidth:this.options.right)&&(this.parent.x=-(this.options.right===!0?this.parent.worldWidth:this.options.right)*this.parent.scale.x+this.parent.screenWidth,e.x=0,t=!0);t&&this.parent.emit("moved",{viewport:this.parent,original:A,type:"clamp-x"})}if(this.options.top!==null||this.options.bottom!==null){let t=!1;if(!this.noUnderflow&&this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y!==0&&(this.parent.y=0,t=!0);break;case 1:this.parent.y!==this.parent.screenHeight-this.parent.screenWorldHeight&&(this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight,t=!0);break;default:this.parent.y!==(this.parent.screenHeight-this.parent.screenWorldHeight)/2&&(this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2,t=!0)}else this.options.top!==null&&this.parent.top<(this.options.top===!0?0:this.options.top)&&(this.parent.y=-(this.options.top===!0?0:this.options.top)*this.parent.scale.y,e.y=0,t=!0),this.options.bottom!==null&&this.parent.bottom>(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)&&(this.parent.y=-(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)*this.parent.scale.y+this.parent.screenHeight,e.y=0,t=!0);t&&this.parent.emit("moved",{viewport:this.parent,original:A,type:"clamp-y"})}this.last.x=this.parent.x,this.last.y=this.parent.y,this.last.scaleX=this.parent.scale.x,this.last.scaleY=this.parent.scale.y}reset(){this.update()}}const nF={minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,minScale:null,maxScale:null};class rF extends Li{constructor(A,e={}){super(A),pA(this,"options"),this.options=Object.assign({},nF,e),this.clamp()}resize(){this.clamp()}clamp(){if(!this.paused){if(this.options.minWidth||this.options.minHeight||this.options.maxWidth||this.options.maxHeight){let A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight;if(this.options.minWidth!==null&&A<this.options.minWidth){const t=this.parent.scale.x;this.parent.fitWidth(this.options.minWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/t,A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxWidth!==null&&A>this.options.maxWidth){const t=this.parent.scale.x;this.parent.fitWidth(this.options.maxWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/t,A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.minHeight!==null&&e<this.options.minHeight){const t=this.parent.scale.y;this.parent.fitHeight(this.options.minHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/t,A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxHeight!==null&&e>this.options.maxHeight){const t=this.parent.scale.y;this.parent.fitHeight(this.options.maxHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/t,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}}else if(this.options.minScale||this.options.maxScale){const A={x:null,y:null},e={x:null,y:null};if(typeof this.options.minScale=="number")A.x=this.options.minScale,A.y=this.options.minScale;else if(this.options.minScale!==null){const r=this.options.minScale;A.x=typeof r.x>"u"?null:r.x,A.y=typeof r.y>"u"?null:r.y}if(typeof this.options.maxScale=="number")e.x=this.options.maxScale,e.y=this.options.maxScale;else if(this.options.maxScale!==null){const r=this.options.maxScale;e.x=typeof r.x>"u"?null:r.x,e.y=typeof r.y>"u"?null:r.y}let t=this.parent.scale.x,i=this.parent.scale.y;A.x!==null&&t<A.x&&(t=A.x),e.x!==null&&t>e.x&&(t=e.x),A.y!==null&&i<A.y&&(i=A.y),e.y!==null&&i>e.y&&(i=e.y),(t!==this.parent.scale.x||i!==this.parent.scale.y)&&(this.parent.scale.set(t,i),this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"}))}}}reset(){this.clamp()}}const sF={friction:.98,bounce:.8,minSpeed:.01},$r=16;class oF extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"x"),pA(this,"y"),pA(this,"percentChangeX"),pA(this,"percentChangeY"),pA(this,"saved"),pA(this,"timeSinceRelease"),this.options=Object.assign({},sF,e),this.saved=[],this.timeSinceRelease=0,this.reset(),this.parent.on("moved",t=>this.handleMoved(t))}down(){return this.saved=[],this.x=this.y=null,!1}isActive(){return!!(this.x||this.y)}move(){if(this.paused)return!1;const A=this.parent.input.count();return(A===1||A>1&&!this.parent.plugins.get("pinch",!0))&&(this.saved.push({x:this.parent.x,y:this.parent.y,time:performance.now()}),this.saved.length>60&&this.saved.splice(0,30)),!1}handleMoved(A){if(this.saved.length){const e=this.saved[this.saved.length-1];A.type==="clamp-x"&&A.original?e.x===A.original.x&&(e.x=this.parent.x):A.type==="clamp-y"&&A.original&&e.y===A.original.y&&(e.y=this.parent.y)}}up(){if(this.parent.input.count()===0&&this.saved.length){const A=performance.now();for(const e of this.saved)if(e.time>=A-100){const t=A-e.time;this.x=(this.parent.x-e.x)/t,this.y=(this.parent.y-e.y)/t,this.percentChangeX=this.percentChangeY=this.options.friction,this.timeSinceRelease=0;break}}return!1}activate(A){A=A||{},typeof A.x<"u"&&(this.x=A.x,this.percentChangeX=this.options.friction),typeof A.y<"u"&&(this.y=A.y,this.percentChangeY=this.options.friction)}update(A){if(this.paused)return;const e=this.x||this.y,t=this.timeSinceRelease,i=this.timeSinceRelease+A;if(this.x){const r=this.percentChangeX,s=Math.log(r);this.parent.x+=this.x*$r/s*(Math.pow(r,i/$r)-Math.pow(r,t/$r)),this.x*=Math.pow(this.percentChangeX,A/$r)}if(this.y){const r=this.percentChangeY,s=Math.log(r);this.parent.y+=this.y*$r/s*(Math.pow(r,i/$r)-Math.pow(r,t/$r)),this.y*=Math.pow(this.percentChangeY,A/$r)}this.timeSinceRelease+=A,this.x&&this.y?Math.abs(this.x)<this.options.minSpeed&&Math.abs(this.y)<this.options.minSpeed&&(this.x=0,this.y=0):(Math.abs(this.x||0)<this.options.minSpeed&&(this.x=0),Math.abs(this.y||0)<this.options.minSpeed&&(this.y=0)),e&&this.parent.emit("moved",{viewport:this.parent,type:"decelerate"})}reset(){this.x=this.y=null}}const aF={direction:"all",pressDrag:!0,wheel:!0,wheelScroll:1,reverse:!1,clampWheel:!1,underflow:"center",factor:1,mouseButtons:"all",keyToPress:null,ignoreKeyToPressOnTouch:!1,lineHeight:20,wheelSwapAxes:!1};class lF extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"moved"),pA(this,"reverse"),pA(this,"xDirection"),pA(this,"yDirection"),pA(this,"keyIsPressed"),pA(this,"mouse"),pA(this,"underflowX"),pA(this,"underflowY"),pA(this,"last"),pA(this,"current"),pA(this,"windowEventHandlers",[]),this.options=Object.assign({},aF,e),this.moved=!1,this.reverse=this.options.reverse?1:-1,this.xDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="x",this.yDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="y",this.keyIsPressed=!1,this.parseUnderflow(),this.mouseButtons(this.options.mouseButtons),this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(A){const e=i=>{A.includes(i.code)&&(this.keyIsPressed=!0)},t=i=>{A.includes(i.code)&&(this.keyIsPressed=!1)};this.addWindowEventHandler("keyup",t),this.addWindowEventHandler("keydown",e)}addWindowEventHandler(A,e){window.addEventListener(A,e),this.windowEventHandlers.push({event:A,handler:e})}destroy(){this.windowEventHandlers.forEach(({event:A,handler:e})=>{window.removeEventListener(A,e)})}mouseButtons(A){!A||A==="all"?this.mouse=[!0,!0,!0]:this.mouse=[A.indexOf("left")!==-1,A.indexOf("middle")!==-1,A.indexOf("right")!==-1]}parseUnderflow(){const A=this.options.underflow.toLowerCase();A==="center"?(this.underflowX=0,this.underflowY=0):(A.includes("left")?this.underflowX=-1:A.includes("right")?this.underflowX=1:this.underflowX=0,A.includes("top")?this.underflowY=-1:A.includes("bottom")?this.underflowY=1:this.underflowY=0)}checkButtons(A){const e=A.pointerType==="mouse",t=this.parent.input.count();return!!((t===1||t>1&&!this.parent.plugins.get("pinch",!0))&&(!e||this.mouse[A.button]))}checkKeyPress(A){return!this.options.keyToPress||this.keyIsPressed||this.options.ignoreKeyToPressOnTouch&&A.data.pointerType==="touch"}down(A){return this.paused||!this.options.pressDrag?!1:this.checkButtons(A)&&this.checkKeyPress(A)?(this.last={x:A.global.x,y:A.global.y},this.current=A.pointerId,!0):(this.last=null,!1)}get active(){return this.moved}move(A){if(this.paused||!this.options.pressDrag)return!1;if(this.last&&this.current===A.data.pointerId){const e=A.global.x,t=A.global.y,i=this.parent.input.count();if(i===1||i>1&&!this.parent.plugins.get("pinch",!0)){const r=e-this.last.x,s=t-this.last.y;if(this.moved||this.xDirection&&this.parent.input.checkThreshold(r)||this.yDirection&&this.parent.input.checkThreshold(s)){const o={x:e,y:t};return this.xDirection&&(this.parent.x+=(o.x-this.last.x)*this.options.factor),this.yDirection&&(this.parent.y+=(o.y-this.last.y)*this.options.factor),this.last=o,this.moved||this.parent.emit("drag-start",{event:A,screen:new VA(this.last.x,this.last.y),world:this.parent.toWorld(new VA(this.last.x,this.last.y)),viewport:this.parent}),this.moved=!0,this.parent.emit("moved",{viewport:this.parent,type:"drag"}),!0}}else this.moved=!1}return!1}up(A){if(this.paused)return!1;const e=this.parent.input.touches;if(e.length===1){const t=e[0];return t.last&&(this.last={x:t.last.x,y:t.last.y},this.current=t.id),this.moved=!1,!0}else if(this.last&&this.moved){const t=new VA(this.last.x,this.last.y);return this.parent.emit("drag-end",{event:A,screen:t,world:this.parent.toWorld(t),viewport:this.parent}),this.last=null,this.moved=!1,!0}return!1}wheel(A){if(this.paused)return!1;if(this.options.wheel){const e=this.parent.plugins.get("wheel",!0);if(!e||!e.options.wheelZoom&&!A.ctrlKey){const t=A.deltaMode?this.options.lineHeight:1,i=[A.deltaX,A.deltaY],[r,s]=this.options.wheelSwapAxes?i.reverse():i;return this.xDirection&&(this.parent.x+=r*t*this.options.wheelScroll*this.reverse),this.yDirection&&(this.parent.y+=s*t*this.options.wheelScroll*this.reverse),this.options.clampWheel&&this.clamp(),this.parent.emit("wheel-scroll",this.parent),this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.options.passiveWheel||A.preventDefault(),this.parent.options.stopPropagation&&A.stopPropagation(),!0}}return!1}resume(){this.last=null,this.paused=!1}clamp(){const A=this.parent.plugins.get("decelerate",!0)||{};if(this.options.clampWheel!=="y")if(this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x=0;break;case 1:this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}else this.parent.left<0?(this.parent.x=0,A.x=0):this.parent.right>this.parent.worldWidth&&(this.parent.x=-this.parent.worldWidth*this.parent.scale.x+this.parent.screenWidth,A.x=0);if(this.options.clampWheel!=="x")if(this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y=0;break;case 1:this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}else this.parent.top<0&&(this.parent.y=0,A.y=0),this.parent.bottom>this.parent.worldHeight&&(this.parent.y=-this.parent.worldHeight*this.parent.scale.y+this.parent.screenHeight,A.y=0)}}const cF={speed:0,acceleration:null,radius:null};class hF extends Li{constructor(A,e,t={}){super(A),pA(this,"options"),pA(this,"target"),pA(this,"velocity"),this.target=e,this.options=Object.assign({},cF,t),this.velocity={x:0,y:0}}update(A){if(this.paused)return;const e=this.parent.center;let t=this.target.x,i=this.target.y;if(this.options.radius)if(Math.sqrt(Math.pow(this.target.y-e.y,2)+Math.pow(this.target.x-e.x,2))>this.options.radius){const o=Math.atan2(this.target.y-e.y,this.target.x-e.x);t=this.target.x-Math.cos(o)*this.options.radius,i=this.target.y-Math.sin(o)*this.options.radius}else return;const r=t-e.x,s=i-e.y;if(r||s)if(this.options.speed)if(this.options.acceleration){const o=Math.atan2(i-e.y,t-e.x),a=Math.sqrt(Math.pow(r,2)+Math.pow(s,2));if(a){const l=(Math.pow(this.velocity.x,2)+Math.pow(this.velocity.y,2))/(2*this.options.acceleration);a>l?this.velocity={x:Math.min(this.velocity.x+(this.options.acceleration*A,this.options.speed)),y:Math.min(this.velocity.y+(this.options.acceleration*A,this.options.speed))}:this.velocity={x:Math.max(this.velocity.x-this.options.acceleration*this.options.speed,0),y:Math.max(this.velocity.y-this.options.acceleration*this.options.speed,0)};const u=Math.cos(o)*this.velocity.x,c=Math.sin(o)*this.velocity.y,h=Math.abs(u)>Math.abs(r)?t:e.x+u,f=Math.abs(c)>Math.abs(s)?i:e.y+c;this.parent.moveCenter(h,f),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}else{const o=Math.atan2(i-e.y,t-e.x),a=Math.cos(o)*this.options.speed,l=Math.sin(o)*this.options.speed,u=Math.abs(a)>Math.abs(r)?t:e.x+a,c=Math.abs(l)>Math.abs(s)?i:e.y+l;this.parent.moveCenter(u,c),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}else this.parent.moveCenter(t,i),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}const uF={radius:null,distance:null,top:null,bottom:null,left:null,right:null,speed:8,reverse:!1,noDecelerate:!1,linear:!1,allowButtons:!1};class fF extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"reverse"),pA(this,"radiusSquared"),pA(this,"left"),pA(this,"top"),pA(this,"right"),pA(this,"bottom"),pA(this,"horizontal"),pA(this,"vertical"),this.options=Object.assign({},uF,e),this.reverse=this.options.reverse?1:-1,this.radiusSquared=typeof this.options.radius=="number"?Math.pow(this.options.radius,2):null,this.resize()}resize(){const A=this.options.distance;A!==null?(this.left=A,this.top=A,this.right=this.parent.screenWidth-A,this.bottom=this.parent.screenHeight-A):this.options.radius||(this.left=this.options.left,this.top=this.options.top,this.right=this.options.right===null?null:this.parent.screenWidth-this.options.right,this.bottom=this.options.bottom===null?null:this.parent.screenHeight-this.options.bottom)}down(){return this.paused||this.options.allowButtons||(this.horizontal=this.vertical=null),!1}move(A){if(this.paused||A.pointerType!=="mouse"&&A.pointerId!==1||!this.options.allowButtons&&A.buttons!==0)return!1;const e=A.global.x,t=A.global.y;if(this.radiusSquared){const i=this.parent.toScreen(this.parent.center);if(Math.pow(i.x-e,2)+Math.pow(i.y-t,2)>=this.radiusSquared){const r=Math.atan2(i.y-t,i.x-e);this.options.linear?(this.horizontal=Math.round(Math.cos(r))*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.round(Math.sin(r))*this.options.speed*this.reverse*(60/1e3)):(this.horizontal=Math.cos(r)*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.sin(r)*this.options.speed*this.reverse*(60/1e3))}else this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=0}else this.left!==null&&e<this.left?this.horizontal=Number(this.reverse)*this.options.speed*(60/1e3):this.right!==null&&e>this.right?this.horizontal=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateHorizontal(),this.horizontal=0),this.top!==null&&t<this.top?this.vertical=Number(this.reverse)*this.options.speed*(60/1e3):this.bottom!==null&&t>this.bottom?this.vertical=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateVertical(),this.vertical=0);return!1}decelerateHorizontal(){const A=this.parent.plugins.get("decelerate",!0);this.horizontal&&A&&!this.options.noDecelerate&&A.activate({x:this.horizontal*this.options.speed*this.reverse/(1e3/60)})}decelerateVertical(){const A=this.parent.plugins.get("decelerate",!0);this.vertical&&A&&!this.options.noDecelerate&&A.activate({y:this.vertical*this.options.speed*this.reverse/(1e3/60)})}up(){return this.paused||(this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=null),!1}update(){if(!this.paused&&(this.horizontal||this.vertical)){const A=this.parent.center;this.horizontal&&(A.x+=this.horizontal*this.options.speed),this.vertical&&(A.y+=this.vertical*this.options.speed),this.parent.moveCenter(A),this.parent.emit("moved",{viewport:this.parent,type:"mouse-edges"})}}}const dF={noDrag:!1,percent:1,center:null,factor:1,axis:"all"};class pF extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"active",!1),pA(this,"pinching",!1),pA(this,"moved",!1),pA(this,"lastCenter"),this.options=Object.assign({},dF,e)}down(){return this.parent.input.count()>=2?(this.active=!0,!0):!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}move(A){if(this.paused||!this.active)return!1;const e=A.global.x,t=A.global.y,i=this.parent.input.touches;if(i.length>=2){const r=i[0],s=i[1],o=r.last&&s.last?Math.sqrt(Math.pow(s.last.x-r.last.x,2)+Math.pow(s.last.y-r.last.y,2)):null;if(r.id===A.pointerId?r.last={x:e,y:t,data:A}:s.id===A.pointerId&&(s.last={x:e,y:t,data:A}),o){let a;const l=new VA(r.last.x+(s.last.x-r.last.x)/2,r.last.y+(s.last.y-r.last.y)/2);this.options.center||(a=this.parent.toLocal(l));let u=Math.sqrt(Math.pow(s.last.x-r.last.x,2)+Math.pow(s.last.y-r.last.y,2));u=u===0?u=1e-10:u;const c=(1-o/u)*this.options.percent*(this.isAxisX()?this.parent.scale.x:this.parent.scale.y);this.isAxisX()&&(this.parent.scale.x+=c),this.isAxisY()&&(this.parent.scale.y+=c),this.parent.emit("zoomed",{viewport:this.parent,type:"pinch",center:l});const h=this.parent.plugins.get("clamp-zoom",!0);if(h&&h.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const f=this.parent.toGlobal(a);this.parent.x+=(l.x-f.x)*this.options.factor,this.parent.y+=(l.y-f.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})}!this.options.noDrag&&this.lastCenter&&(this.parent.x+=(l.x-this.lastCenter.x)*this.options.factor,this.parent.y+=(l.y-this.lastCenter.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})),this.lastCenter=l,this.moved=!0}else this.pinching||(this.parent.emit("pinch-start",this.parent),this.pinching=!0);return!0}return!1}up(){return this.pinching&&this.parent.input.touches.length<=1?(this.active=!1,this.lastCenter=null,this.pinching=!1,this.moved=!1,this.parent.emit("pinch-end",this.parent),!0):!1}}const gF={topLeft:!1,friction:.8,time:1e3,ease:"easeInOutSine",interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1};class mF extends Li{constructor(A,e,t,i={}){super(A),pA(this,"options"),pA(this,"ease"),pA(this,"x"),pA(this,"y"),pA(this,"percent"),pA(this,"snapping"),pA(this,"deltaX"),pA(this,"deltaY"),pA(this,"startX"),pA(this,"startY"),this.options=Object.assign({},gF,i),this.ease=yd(i.ease,"easeInOutSine"),this.x=e,this.y=t,this.options.forceStart&&this.snapStart()}snapStart(){this.percent=0,this.snapping={time:0};const A=this.options.topLeft?this.parent.corner:this.parent.center;this.deltaX=this.x-A.x,this.deltaY=this.y-A.y,this.startX=A.x,this.startY=A.y,this.parent.emit("snap-start",this.parent)}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap"):this.options.interrupt&&(this.snapping=null),!1}up(){if(this.parent.input.count()===0){const A=this.parent.plugins.get("decelerate",!0);A&&(A.x||A.y)&&(A.percentChangeX=A.percentChangeY=this.options.friction)}return!1}update(A){if(!this.paused&&!(this.options.interrupt&&this.parent.input.count()!==0))if(this.snapping){const e=this.snapping;e.time+=A;let t,i,r;const s=this.startX,o=this.startY,a=this.deltaX,l=this.deltaY;if(e.time>this.options.time)t=!0,i=s+a,r=o+l;else{const u=this.ease(e.time,0,1,this.options.time);i=s+a*u,r=o+l*u}this.options.topLeft?this.parent.moveCorner(i,r):this.parent.moveCenter(i,r),this.parent.emit("moved",{viewport:this.parent,type:"snap"}),t&&(this.options.removeOnComplete&&this.parent.plugins.remove("snap"),this.parent.emit("snap-end",this.parent),this.snapping=null)}else{const e=this.options.topLeft?this.parent.corner:this.parent.center;(e.x!==this.x||e.y!==this.y)&&this.snapStart()}}}const vF={width:0,height:0,time:1e3,ease:"easeInOutSine",center:null,interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1,noMove:!1};class yF extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"ease"),pA(this,"xScale"),pA(this,"yScale"),pA(this,"xIndependent"),pA(this,"yIndependent"),pA(this,"snapping"),this.options=Object.assign({},vF,e),this.ease=yd(this.options.ease),this.xIndependent=!1,this.yIndependent=!1,this.xScale=0,this.yScale=0,this.options.width>0&&(this.xScale=A.screenWidth/this.options.width,this.xIndependent=!0),this.options.height>0&&(this.yScale=A.screenHeight/this.options.height,this.yIndependent=!0),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale,this.options.time===0?(A.container.scale.x=this.xScale,A.container.scale.y=this.yScale,this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom")):e.forceStart&&this.createSnapping()}createSnapping(){const A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,t=this.parent.screenWidth/this.xScale,i=this.parent.screenHeight/this.yScale;this.snapping={time:0,startX:A,startY:e,deltaX:t-A,deltaY:i-e},this.parent.emit("snap-zoom-start",this.parent)}resize(){this.snapping=null,this.options.width>0&&(this.xScale=this.parent.screenWidth/this.options.width),this.options.height>0&&(this.yScale=this.parent.screenHeight/this.options.height),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap-zoom"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap-zoom"):this.options.interrupt&&(this.snapping=null),!1}update(A){if(this.paused||this.options.interrupt&&this.parent.input.count()!==0)return;let e;if(!this.options.center&&!this.options.noMove&&(e=this.parent.center),!this.snapping)(this.parent.scale.x!==this.xScale||this.parent.scale.y!==this.yScale)&&this.createSnapping();else if(this.snapping){const t=this.snapping;if(t.time+=A,t.time>=this.options.time)this.parent.scale.set(this.xScale,this.yScale),this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom"),this.parent.emit("snap-zoom-end",this.parent),this.snapping=null;else{const r=this.snapping,s=this.ease(r.time,r.startX,r.deltaX,this.options.time),o=this.ease(r.time,r.startY,r.deltaY,this.options.time);this.parent.scale.x=this.parent.screenWidth/s,this.parent.scale.y=this.parent.screenHeight/o}const i=this.parent.plugins.get("clamp-zoom",!0);i&&i.clamp(),this.options.noMove||(this.options.center?this.parent.moveCenter(this.options.center):this.parent.moveCenter(e))}}resume(){this.snapping=null,super.resume()}}const wF={percent:.1,smooth:!1,interrupt:!0,reverse:!1,center:null,lineHeight:20,axis:"all",keyToPress:null,trackpadPinch:!1,wheelZoom:!0};class CF extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"smoothing"),pA(this,"smoothingCenter"),pA(this,"smoothingCount"),pA(this,"keyIsPressed"),this.options=Object.assign({},wF,e),this.keyIsPressed=!1,this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(A){window.addEventListener("keydown",e=>{A.includes(e.code)&&(this.keyIsPressed=!0)}),window.addEventListener("keyup",e=>{A.includes(e.code)&&(this.keyIsPressed=!1)})}checkKeyPress(){return!this.options.keyToPress||this.keyIsPressed}down(){return this.options.interrupt&&(this.smoothing=null),!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}update(){if(this.smoothing){const A=this.smoothingCenter,e=this.smoothing;let t;this.options.center||(t=this.parent.toLocal(A)),this.isAxisX()&&(this.parent.scale.x+=e.x),this.isAxisY()&&(this.parent.scale.y+=e.y),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const i=this.parent.plugins.get("clamp-zoom",!0);if(i&&i.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const r=this.parent.toGlobal(t);this.parent.x+=A.x-r.x,this.parent.y+=A.y-r.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.smoothingCount++,this.smoothingCount>=this.options.smooth&&(this.smoothing=null)}}pinch(A){if(this.paused)return;const e=this.parent.input.getPointerPosition(A),t=-A.deltaY*(A.deltaMode?this.options.lineHeight:1)/200,i=Math.pow(2,(1+this.options.percent)*t);let r;this.options.center||(r=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=i),this.isAxisY()&&(this.parent.scale.y*=i),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const s=this.parent.plugins.get("clamp-zoom",!0);if(s&&s.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const o=this.parent.toGlobal(r);this.parent.x+=e.x-o.x,this.parent.y+=e.y-o.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{event:A,viewport:this.parent})}wheel(A){if(this.paused||!this.checkKeyPress())return!1;if(A.ctrlKey&&this.options.trackpadPinch)this.pinch(A);else if(this.options.wheelZoom){const e=this.parent.input.getPointerPosition(A),t=(this.options.reverse?-1:1)*-A.deltaY*(A.deltaMode?this.options.lineHeight:1)/500,i=Math.pow(2,(1+this.options.percent)*t);if(this.options.smooth){const r={x:this.smoothing?this.smoothing.x*(this.options.smooth-this.smoothingCount):0,y:this.smoothing?this.smoothing.y*(this.options.smooth-this.smoothingCount):0};this.smoothing={x:((this.parent.scale.x+r.x)*i-this.parent.scale.x)/this.options.smooth,y:((this.parent.scale.y+r.y)*i-this.parent.scale.y)/this.options.smooth},this.smoothingCount=0,this.smoothingCenter=e}else{let r;this.options.center||(r=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=i),this.isAxisY()&&(this.parent.scale.y*=i),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const s=this.parent.plugins.get("clamp-zoom",!0);if(s&&s.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const o=this.parent.toGlobal(r);this.parent.x+=e.x-o.x,this.parent.y+=e.y-o.y}}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{event:A,viewport:this.parent})}return!this.parent.options.passiveWheel}}class xF{constructor(A){pA(this,"viewport"),pA(this,"clickedAvailable"),pA(this,"isMouseDown"),pA(this,"last"),pA(this,"wheelFunction"),pA(this,"touches"),this.viewport=A,this.touches=[],this.addListeners()}addListeners(){this.viewport.eventMode="static",this.viewport.forceHitArea||(this.viewport.hitArea=new ee(0,0,this.viewport.worldWidth,this.viewport.worldHeight)),this.viewport.on("pointerdown",this.down,this),this.viewport.options.allowPreserveDragOutside?this.viewport.on("globalpointermove",this.move,this):this.viewport.on("pointermove",this.move,this),this.viewport.on("pointerup",this.up,this),this.viewport.on("pointerupoutside",this.up,this),this.viewport.on("pointercancel",this.up,this),this.viewport.options.allowPreserveDragOutside||this.viewport.on("pointerleave",this.up,this),this.wheelFunction=A=>this.handleWheel(A),this.viewport.options.events.domElement.addEventListener("wheel",this.wheelFunction,{passive:this.viewport.options.passiveWheel}),this.isMouseDown=!1}destroy(){this.viewport.options.events.domElement.removeEventListener("wheel",this.wheelFunction)}down(A){if(!(this.viewport.pause||!this.viewport.worldVisible)){if(A.pointerType==="mouse"?this.isMouseDown=!0:this.get(A.pointerId)||this.touches.push({id:A.pointerId,last:null}),this.count()===1){this.last=A.global.clone();const e=this.viewport.plugins.get("decelerate",!0),t=this.viewport.plugins.get("bounce",!0);(!e||!e.isActive())&&(!t||!t.isActive())?this.clickedAvailable=!0:this.clickedAvailable=!1}else this.clickedAvailable=!1;this.viewport.plugins.down(A)&&this.viewport.options.stopPropagation&&A.stopPropagation()}}clear(){this.isMouseDown=!1,this.touches=[],this.last=null}checkThreshold(A){return Math.abs(A)>=this.viewport.threshold}move(A){if(this.viewport.pause||!this.viewport.worldVisible)return;const e=this.viewport.plugins.move(A);if(this.clickedAvailable&&this.last){const t=A.global.x-this.last.x,i=A.global.y-this.last.y;(this.checkThreshold(t)||this.checkThreshold(i))&&(this.clickedAvailable=!1)}e&&this.viewport.options.stopPropagation&&A.stopPropagation()}up(A){if(this.viewport.pause||!this.viewport.worldVisible)return;A.pointerType==="mouse"&&(this.isMouseDown=!1),A.pointerType!=="mouse"&&this.remove(A.pointerId);const e=this.viewport.plugins.up(A);this.clickedAvailable&&this.count()===0&&this.last&&(this.viewport.emit("clicked",{event:A,screen:this.last,world:this.viewport.toWorld(this.last),viewport:this.viewport}),this.clickedAvailable=!1),e&&this.viewport.options.stopPropagation&&A.stopPropagation()}getPointerPosition(A){const e=new VA;return this.viewport.options.events.mapPositionToPoint(e,A.clientX,A.clientY),e}handleWheel(A){if(this.viewport.pause||!this.viewport.worldVisible)return;const e=this.viewport.toLocal(this.getPointerPosition(A));this.viewport.left<=e.x&&e.x<=this.viewport.right&&this.viewport.top<=e.y&&e.y<=this.viewport.bottom&&this.viewport.plugins.wheel(A)&&!this.viewport.options.passiveWheel&&A.preventDefault()}pause(){this.touches=[],this.isMouseDown=!1}get(A){for(const e of this.touches)if(e.id===A)return e;return null}remove(A){for(let e=0;e<this.touches.length;e++)if(this.touches[e].id===A){this.touches.splice(e,1);return}}count(){return(this.isMouseDown?1:0)+this.touches.length}}const Nc=["drag","pinch","wheel","follow","mouse-edges","decelerate","animate","bounce","snap-zoom","clamp-zoom","snap","clamp"];class IF{constructor(A){pA(this,"plugins"),pA(this,"list"),pA(this,"viewport"),this.viewport=A,this.list=[],this.plugins={}}add(A,e,t=Nc.length){const i=this.plugins[A];i&&i.destroy(),this.plugins[A]=e;const r=Nc.indexOf(A);r!==-1&&Nc.splice(r,1),Nc.splice(t,0,A),this.sort()}get(A,e){var t;return e&&(t=this.plugins[A])!=null&&t.paused?null:this.plugins[A]}update(A){for(const e of this.list)e.update(A)}resize(){for(const A of this.list)A.resize()}reset(){for(const A of this.list)A.reset()}removeAll(){this.list.forEach(A=>{A.destroy()}),this.plugins={},this.sort()}remove(A){var e;this.plugins[A]&&((e=this.plugins[A])==null||e.destroy(),delete this.plugins[A],this.viewport.emit("plugin-remove",A),this.sort())}pause(A){var e;(e=this.plugins[A])==null||e.pause()}resume(A){var e;(e=this.plugins[A])==null||e.resume()}sort(){this.list=[];for(const A of Nc)this.plugins[A]&&this.list.push(this.plugins[A])}down(A){let e=!1;for(const t of this.list)t.down(A)&&(e=!0);return e}move(A){let e=!1;for(const t of this.viewport.plugins.list)t.move(A)&&(e=!0);return e}up(A){let e=!1;for(const t of this.list)t.up(A)&&(e=!0);return e}wheel(A){let e=!1;for(const t of this.list)t.wheel(A)&&(e=!0);return e}}const bF={screenWidth:window.innerWidth,screenHeight:window.innerHeight,worldWidth:null,worldHeight:null,threshold:5,passiveWheel:!0,stopPropagation:!1,forceHitArea:null,noTicker:!1,disableOnContextMenu:!1,ticker:Xt.shared,allowPreserveDragOutside:!1};class _F extends bi{constructor(A){super(),pA(this,"moving"),pA(this,"screenWidth"),pA(this,"screenHeight"),pA(this,"threshold"),pA(this,"input"),pA(this,"plugins"),pA(this,"zooming"),pA(this,"lastViewport"),pA(this,"options"),pA(this,"_dirty"),pA(this,"_forceHitArea"),pA(this,"_hitAreaDefault"),pA(this,"_pause"),pA(this,"tickerFunction"),pA(this,"_worldWidth"),pA(this,"_worldHeight"),pA(this,"_disableOnContextMenu",e=>e.preventDefault()),this.options={...bF,...A},this.screenWidth=this.options.screenWidth,this.screenHeight=this.options.screenHeight,this._worldWidth=this.options.worldWidth,this._worldHeight=this.options.worldHeight,this.forceHitArea=this.options.forceHitArea,this.threshold=this.options.threshold,this.options.disableOnContextMenu&&this.options.events.domElement.addEventListener("contextmenu",this._disableOnContextMenu),this.options.noTicker||(this.tickerFunction=()=>this.update(this.options.ticker.elapsedMS),this.options.ticker.add(this.tickerFunction)),this.input=new xF(this),this.plugins=new IF(this)}destroy(A){!this.options.noTicker&&this.tickerFunction&&this.options.ticker.remove(this.tickerFunction),this.options.disableOnContextMenu&&this.options.events.domElement.removeEventListener("contextmenu",this._disableOnContextMenu),this.input.destroy(),super.destroy(A)}update(A){this.pause||(this.plugins.update(A),this.lastViewport&&(this.lastViewport.x!==this.x||this.lastViewport.y!==this.y?this.moving=!0:this.moving&&(this.emit("moved-end",this),this.moving=!1),this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y?this.zooming=!0:this.zooming&&(this.emit("zoomed-end",this),this.zooming=!1)),this.forceHitArea||(this._hitAreaDefault=new ee(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight),this.hitArea=this._hitAreaDefault),this._dirty=this._dirty||!this.lastViewport||this.lastViewport.x!==this.x||this.lastViewport.y!==this.y||this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y,this.lastViewport={x:this.x,y:this.y,scaleX:this.scale.x,scaleY:this.scale.y},this.emit("frame-end",this))}resize(A=window.innerWidth,e=window.innerHeight,t,i){this.screenWidth=A,this.screenHeight=e,typeof t<"u"&&(this._worldWidth=t),typeof i<"u"&&(this._worldHeight=i),this.plugins.resize(),this.dirty=!0}get worldWidth(){return this._worldWidth?this._worldWidth:this.width/this.scale.x}set worldWidth(A){this._worldWidth=A,this.plugins.resize()}get worldHeight(){return this._worldHeight?this._worldHeight:this.height/this.scale.y}set worldHeight(A){this._worldHeight=A,this.plugins.resize()}getVisibleBounds(){return new ee(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight)}toWorld(A,e){return arguments.length===2?this.toLocal(new VA(A,e)):this.toLocal(A)}toScreen(A,e){return arguments.length===2?this.toGlobal(new VA(A,e)):this.toGlobal(A)}get worldScreenWidth(){return this.screenWidth/this.scale.x}get worldScreenHeight(){return this.screenHeight/this.scale.y}get screenWorldWidth(){return this.worldWidth*this.scale.x}get screenWorldHeight(){return this.worldHeight*this.scale.y}get center(){return new VA(this.worldScreenWidth/2-this.x/this.scale.x,this.worldScreenHeight/2-this.y/this.scale.y)}set center(A){this.moveCenter(A)}moveCenter(...A){let e,t;typeof A[0]=="number"?(e=A[0],t=A[1]):(e=A[0].x,t=A[0].y);const i=(this.worldScreenWidth/2-e)*this.scale.x,r=(this.worldScreenHeight/2-t)*this.scale.y;return(this.x!==i||this.y!==r)&&(this.position.set(i,r),this.plugins.reset(),this.dirty=!0),this}get corner(){return new VA(-this.x/this.scale.x,-this.y/this.scale.y)}set corner(A){this.moveCorner(A)}moveCorner(...A){let e,t;return A.length===1?(e=-A[0].x*this.scale.x,t=-A[0].y*this.scale.y):(e=-A[0]*this.scale.x,t=-A[1]*this.scale.y),(e!==this.x||t!==this.y)&&(this.position.set(e,t),this.plugins.reset(),this.dirty=!0),this}get screenWidthInWorldPixels(){return this.screenWidth/this.scale.x}get screenHeightInWorldPixels(){return this.screenHeight/this.scale.y}findFitWidth(A){return this.screenWidth/A}findFitHeight(A){return this.screenHeight/A}findFit(A,e){const t=this.screenWidth/A,i=this.screenHeight/e;return Math.min(t,i)}findCover(A,e){const t=this.screenWidth/A,i=this.screenHeight/e;return Math.max(t,i)}fitWidth(A=this.worldWidth,e,t=!0,i){let r;e&&(r=this.center),this.scale.x=this.screenWidth/A,t&&(this.scale.y=this.scale.x);const s=this.plugins.get("clamp-zoom",!0);return!i&&s&&s.clamp(),e&&r&&this.moveCenter(r),this}fitHeight(A=this.worldHeight,e,t=!0,i){let r;e&&(r=this.center),this.scale.y=this.screenHeight/A,t&&(this.scale.x=this.scale.y);const s=this.plugins.get("clamp-zoom",!0);return!i&&s&&s.clamp(),e&&r&&this.moveCenter(r),this}fitWorld(A){let e;A&&(e=this.center),this.scale.x=this.screenWidth/this.worldWidth,this.scale.y=this.screenHeight/this.worldHeight,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const t=this.plugins.get("clamp-zoom",!0);return t&&t.clamp(),A&&e&&this.moveCenter(e),this}fit(A,e=this.worldWidth,t=this.worldHeight){let i;A&&(i=this.center),this.scale.x=this.screenWidth/e,this.scale.y=this.screenHeight/t,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const r=this.plugins.get("clamp-zoom",!0);return r&&r.clamp(),A&&i&&this.moveCenter(i),this}setZoom(A,e){let t;e&&(t=this.center),this.scale.set(A);const i=this.plugins.get("clamp-zoom",!0);return i&&i.clamp(),e&&t&&this.moveCenter(t),this}zoomPercent(A,e){return this.setZoom(this.scale.x+this.scale.x*A,e)}zoom(A,e){return this.fitWidth(A+this.worldScreenWidth,e),this}get scaled(){return this.scale.x}set scaled(A){this.setZoom(A,!0)}snapZoom(A){return this.plugins.add("snap-zoom",new yF(this,A)),this}OOB(){return{left:this.left<0,right:this.right>this.worldWidth,top:this.top<0,bottom:this.bottom>this.worldHeight,cornerPoint:new VA(this.worldWidth*this.scale.x-this.screenWidth,this.worldHeight*this.scale.y-this.screenHeight)}}get right(){return-this.x/this.scale.x+this.worldScreenWidth}set right(A){this.x=-A*this.scale.x+this.screenWidth,this.plugins.reset()}get left(){return-this.x/this.scale.x}set left(A){this.x=-A*this.scale.x,this.plugins.reset()}get top(){return-this.y/this.scale.y}set top(A){this.y=-A*this.scale.y,this.plugins.reset()}get bottom(){return-this.y/this.scale.y+this.worldScreenHeight}set bottom(A){this.y=-A*this.scale.y+this.screenHeight,this.plugins.reset()}get dirty(){return!!this._dirty}set dirty(A){this._dirty=A}get forceHitArea(){return this._forceHitArea}set forceHitArea(A){A?(this._forceHitArea=A,this.hitArea=A):(this._forceHitArea=null,this.hitArea=new ee(0,0,this.worldWidth,this.worldHeight))}drag(A){return this.plugins.add("drag",new lF(this,A)),this}clamp(A){return this.plugins.add("clamp",new iF(this,A)),this}decelerate(A){return this.plugins.add("decelerate",new oF(this,A)),this}bounce(A){return this.plugins.add("bounce",new eF(this,A)),this}pinch(A){return this.plugins.add("pinch",new pF(this,A)),this}snap(A,e,t){return this.plugins.add("snap",new mF(this,A,e,t)),this}follow(A,e){return this.plugins.add("follow",new hF(this,A,e)),this}wheel(A){return this.plugins.add("wheel",new CF(this,A)),this}animate(A){return this.plugins.add("animate",new $K(this,A)),this}clampZoom(A){return this.plugins.add("clamp-zoom",new rF(this,A)),this}mouseEdges(A){return this.plugins.add("mouse-edges",new fF(this,A)),this}get pause(){return!!this._pause}set pause(A){this._pause=A,this.lastViewport=null,this.moving=!1,this.zooming=!1,A&&this.input.pause()}ensureVisible(A,e,t,i,r){r&&(t>this.worldScreenWidth||i>this.worldScreenHeight)&&(this.fit(!0,t,i),this.emit("zoomed",{viewport:this,type:"ensureVisible"}));let s=!1;A<this.left?(this.left=A,s=!0):A+t>this.right&&(this.right=A+t,s=!0),e<this.top?(this.top=e,s=!0):e+i>this.bottom&&(this.bottom=e+i,s=!0),s&&this.emit("moved",{viewport:this,type:"ensureVisible"})}}const SF="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAIrSURBVHic7dWhEcQwAAPBJEW4//bsJvzwg446YLcCkRvdc8598RljjNMTeHlOD4AvEwgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUC499779Aj+1lqnJ/DiQSAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIPwAhCgMRcz+Nz0AAAAASUVORK5CYII=";var MF=Object.defineProperty,PF=Object.getOwnPropertyDescriptor,$a=(n,A,e,t)=>{for(var i=t>1?void 0:t?PF(A,e):A,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=(t?s(A,e,i):s(i))||i);return t&&i&&MF(A,e,i),i};ue.Cropper=class extends Gr{constructor(){super(),this._domBoundingRect={x:0,y:0,width:0,height:0},this.app=new N2({backgroundAlpha:0,autoDensity:!0,resolution:2}),this.viewport=new _F({events:this.app.renderer.events,worldWidth:250,worldHeight:250}),this.imageSize={width:0,height:0},this.logoSize={width:0,height:0},this._imageUrl="",this._canvasScale=1,this.texture=new lt(this.app.view),this._timer=0,this._loading=!1,this.pathD="",this.getConfigs=()=>{const{screenWidth:A,screenHeight:e}=this.viewport;if(!this._sprite)return{canvasWidth:A,canvasHeight:e,scaleX:1,scaleY:1,ox:0,oy:0,x:0,y:0,url:this._imageUrl};const t=A/this._sprite.width,i=e/this._sprite.height,r=this.viewport.scale.x/t,s=this.viewport.scale.x/i,o=this._sprite.toGlobal(new uA(-this._sprite.width/2,-this._sprite.height/2)),a=-o.x/(this._sprite.width*this.viewport.scale.x),l=-o.y/(this._sprite.height*this.viewport.scale.y);return{canvasWidth:A,canvasHeight:e,scaleX:r,scaleY:s,ox:a,oy:l,x:this.viewport.position.x,y:this.viewport.position.y,url:this._imageUrl}},this._onChanged=async()=>{if(!this.imageSize.width||!this.imageSize.height||!this.app.view.toDataURL)return;const A=this.app.view.toDataURL("image/png",.75),e=this.app.renderer.gl,{screenWidth:t,screenHeight:i}=this.viewport;if(this._timer&&clearTimeout(this._timer),e){const r=this.app.renderer.width,s=this.app.renderer.height,o=new Uint8Array(r*s*4);e.readPixels(0,0,r,s,e.RGBA,e.UNSIGNED_BYTE,o);let a=r,l=0,u=s,c=0;for(let g=0;g<s;g++)for(let y=0;y<r;y++){const v=(g*r+y)*4;o[v+3]>0&&(a=Math.min(a,y),l=Math.max(l,y),u=Math.min(u,g),c=Math.max(c,g))}const h=this.app.renderer.view.getBoundingClientRect(),f={x:a,y:u,width:l-a+1,height:c-u+1};(a>l||u>c)&&console.log("没有非透明区域"),this.axiosX&&(this.axiosX.style.display="none"),this.axiosY&&(this.axiosY.style.display="none");const p=2,m=t/2,d=i/2;if(h){const g={x:f.x*(h.width/this.app.renderer.width),y:(this.app.renderer.height-f.y-f.height)*(h.height/this.app.renderer.height),width:f.width*(h.width/this.app.renderer.width),height:f.height*(h.height/this.app.renderer.height)};this._domBoundingRect=g,this.boundRect&&(this.boundRect.style.left=`${g.x}px`,this.boundRect.style.top=`${g.y}px`,this.boundRect.style.width=`${g.width}px`,this.boundRect.style.height=`${g.height}px`);const y=g.x+g.width/2,v=g.y+g.height/2,w=m-y,C=d-v;Math.abs(w)<p&&(this.viewport.position.x+=w,this.axiosY&&(this.axiosY.style.display="block")),Math.abs(C)<p&&(this.viewport.position.y+=C,this.axiosX&&(this.axiosX.style.display="block"))}else Math.abs(this.viewport.position.x-m)<p&&(this.viewport.position.x=m,this.axiosY&&(this.axiosY.style.display="block")),Math.abs(this.viewport.position.y-d)<p&&(this.viewport.position.y=d,this.axiosX&&(this.axiosX.style.display="block"));this._timer=window.setTimeout(()=>{this.axiosX&&(this.axiosX.style.display="none"),this.axiosY&&(this.axiosY.style.display="none")},600)}this.dispatchEvent(new CustomEvent("image-change",{detail:{image:A},bubbles:!0,composed:!0}))},this._wheelEvent=A=>{A.preventDefault()},this.updateConfigs=async({canvasWidth:A,x:e,y:t,scaleX:i,url:r})=>{var a;const{screenWidth:s}=this.viewport;this._canvasScale=s/A,await this.add(r,this.logoSize);const o=i*s/(((a=this._sprite)==null?void 0:a.width)||1);this.viewport.scale.set(o*this._canvasScale),this.viewport.position.set(e*this._canvasScale,t*this._canvasScale)},this.app.stage.addChild(this.viewport),this.viewport.drag({}).pinch().wheel().decelerate({friction:0,bounce:1}).on("zoomed-end",this._onChanged).on("moved-end",this._onChanged),this.app.view.addEventListener("wheel",this._wheelEvent,{passive:!1})}get supports(){return["png","jpg","jpeg","svg","webp"]}get loading(){return this._loading}get canvas(){return this.app.view}get imageScale(){if(!this._sprite)return{x:0,y:0};const{screenWidth:A,screenHeight:e}=this.viewport,t=this.viewport.scale.x,i=this._sprite.width*t/2,r=this._sprite.height*t/2,s=this._domBoundingRect.width/i*(i/A),o=this._domBoundingRect.height/r*(r/e);return{x:s,y:o}}get imageRealSize(){const{x:A,y:e}=this.imageScale;let{width:t,height:i}=this.logoSize;const r=Math.max(t,i);return t=r*A,i=r*e,{width:t,height:i}}resize(A,e){this.app.renderer.resize(A,e),this.viewport.resize(A,e)}firstUpdated(A){var e;super.firstUpdated(A),this.container&&((e=this.container)==null||e.append(this.app.view),this.app.resizeTo=this.container)}setUV(A){const{screenWidth:e,screenHeight:t}=this.viewport,i=A.attributes.uv,r=A.index;if(!r){this.pathD="";return}let s=[];for(let a=0;a<r.count;a+=3){const l=r.getX(a),u=r.getX(a+1),c=r.getX(a+2),h=[i.getX(l)*e,i.getY(l)*t],f=[i.getX(u)*e,i.getY(u)*t],p=[i.getX(c)*e,i.getY(c)*t];s.push(h,f,p)}let o="";s.forEach((a,l)=>{l%3===0?o+=`M${a[0]},${a[1]} `:o+=`L${a[0]},${a[1]} `,l%3===2&&(o+="Z ")}),s=[],this.pathD=o}async add(A,e){this.clear(),this._imageUrl=A,this.logoSize=e,this._loading=!0;const t=await GA.fromURL(A);this._sprite=new js(t),this.viewport.addChild(this._sprite),this.imageSize.width=this._sprite.texture.width,this.imageSize.height=this._sprite.texture.height,this.fit(),this._loading=!1}clear(){var A,e;(A=this._sprite)==null||A.texture.destroy(!0),(e=this._sprite)==null||e.removeFromParent(),this.boundRect&&(this.boundRect.style.left="0px",this.boundRect.style.top="0px",this.boundRect.style.width="0px",this.boundRect.style.height="0px")}fit(){if(!this._sprite)return;this.viewport.scale.set(1,1),this._sprite.anchor.set(.5,.5),this.viewport.moveCenter(this._sprite.position.x,this._sprite.position.y);const A=this.viewport.screenWidth,e=this.viewport.screenHeight,t=this._sprite.width/A,i=this._sprite.height/e,r=Math.max(t,i);this.viewport.scale.set(1/r,1/r)}disconnectedCallback(){super.disconnectedCallback(),this.clear(),this.viewport.destroy({children:!0,texture:!0,baseTexture:!0}),this.viewport.off("zoomed"),this.viewport.off("moved"),this.viewport.off("moved-end"),this.app.view.removeEventListener("wheel",this._wheelEvent),this.app.destroy(!0)}render(){const{screenWidth:A,screenHeight:e}=this.viewport;return $i`
9867
+ }`),this.camera.position.set(10,6,-10),this.camera.lookAt(new O);const{tiles:e}=q9();this.pathTracer=new tO(this.renderer),this.pathTracer.filterGlossyFactor=.6,this.pathTracer.renderScale=window.devicePixelRatio,this.pathTracer.bounces=10,this.pathTracer.transmissiveBounces=8,this.pathTracer.tiles.set(e,e),this.pathTracer.fadeDuration=0,this.pathTracer.setBVHWorker(new MK),this.controls.addEventListener("change",()=>{var t;this.sampleCount=0,(t=this.pathTracer)==null||t.updateCamera()}),this._composer=new nO(this.renderer),this._composer.setPixelRatio(window.devicePixelRatio),this._composer.addPass(new oE(this.scene,this.camera)),this._composer.addPass(new uE),this._outlinePass=new Hn(new uA(window.innerWidth,window.innerHeight),this.scene,this.camera),this._outlinePass.visibleEdgeColor.set(26367),this._outlinePass.edgeThickness=.5,this._outlinePass.hiddenEdgeColor.set(26367),this._outlinePass.edgeStrength=3,this._outlinePass.edgeGlow=0,this._composer.addPass(this._outlinePass),this._outlinePassError=new Hn(new uA(window.innerWidth,window.innerHeight),this.scene,this.camera),this._outlinePassError.visibleEdgeColor.set(16711680),this._outlinePassError.edgeThickness=.5,this._outlinePassError.hiddenEdgeColor.set(16711680),this._outlinePassError.edgeStrength=3,this._outlinePassError.edgeGlow=0,this._composer.addPass(this._outlinePassError),this._composer.renderTarget1.texture.colorSpace=je,this._composer.renderTarget2.texture.colorSpace=je,this._fxaaPass=new J1(aE),this._composer.addPass(this._fxaaPass),this._container.add(this.amr),this.scene.add(this._container),this.ticker(),this._loadEnv(),this._initEvents(),this._ground.rotateX(-Math.PI/2),this.scene.add(this._ground)}get usePathTracing(){return this._usePathTracing}set usePathTracing(A){A?(this.amr&&(this.amr.bodyOpacity=1),this.amr.slots.forEach(e=>e.hide()),this.amr.controllers.forEach(e=>e.hide()),this.lines.hide(),this.amr.sizeBox.hide(),this.amr.goods.forEach(e=>e.hide()),this.pathTracer.renderToCanvas=!0):(this.amr.sizeBox.show(),this.amr.goods.forEach(e=>e.show()),this.amr.slots.forEach(e=>e.show()),this.amr.controllers.forEach(e=>e.show()),this.lines.show(),this.amr&&this.amr.opacityCache!==void 0?(this.amr.bodyOpacity=this.amr.opacityCache,this.amr.opacityCache=void 0):this.amr&&(this.amr.bodyOpacity=1),this.pathTracer.reset(),this._ground.visible=!1,this.scene.background=null),this._usePathTracing=A,this.controls.dampingFactor=A?1:MS,this.sampleCount=0}get fpsAverage(){return bb(this._fpsCache)}showState(){this.stats.dom.style.display="block"}hideState(){this.stats.dom.style.display="none"}_loadEnv(){new iE(new R1).load(mk,e=>{e.mapping=eo,e.minFilter=we,e.magFilter=we,e.colorSpace=je,e.format=_e,e.needsUpdate=!0,this._usePathTracing||(this.scene.environment=e,this.overlayScene.environment=e,this.scene.environmentRotation.y=Math.PI*.1,this.scene.environmentIntensity=1,this.overlayScene.environmentIntensity=1),this.pathTracer.updateEnvironment()},()=>{},()=>{})}_initEvents(){window.addEventListener("drag",this._drag),window.addEventListener("dragend",this._dragend),document.addEventListener("wheel",this._detectTrackpad),window.addEventListener("pointermove",this._pointermove),this.renderer.domElement.addEventListener("pointerdown",this._pointerdown)}async generateBVH(){this.pathTracer.pausePathTracing=!1,this.amr.slots.forEach(A=>A.hide()),this.lines.hide(),this.amr&&(this.amr.opacityCache=this.amr.bodyOpacity,this.amr.bodyOpacity=1),this.usePathTracing=!0,this.pathTracer.setScene(this.scene,this.camera)}download(){return this.renderer.domElement.toDataURL("image/png")}clearAMR(){this.amr.clean(),this.usePathTracing=!1,this.lines.clear()}async exportAMR(){const A=this._container.clone(!0);return A.traverse(e=>{e.dispose&&(e.dispose(),e.removeFromParent())}),await Hb.parseAsync(A,{onlyVisible:!0,binary:!0})}async addAMR(A){this.amr.init(this),await this.amr.load(A),this.amr.addEventListener("shape-key-changed",()=>{this.pathTracer.reset(),this.sampleCount=0,this.pathTracer.setScene(this.scene,this.camera)}),this.amr.logos.forEach(e=>{this.overlayScene.add(e.target)})}generateEdges(){this._container.traverse(A=>{if(A instanceof Te){const e=A.geometry.clone(),t=GK.generate(e);let i=t.next();for(;!i.done;)i=t.next();const r=new bl(i.value,new Bh({color:3355443}));r.position.z=-1.4,this.add(r),e.dispose()}})}select(A){typeof A=="string"||(Array.isArray(A)?this._outlinePass.selectedObjects=[...A]:this._outlinePass.selectedObjects=[A])}appendTo(A){A.append(this.renderer.domElement),A.append(this.stats.dom),A.append(this.lines),A.append(this.css2dRenderer.domElement),this.stats.dom.style.bottom="0",this.stats.dom.style.top="auto",this.resize(),this._resizeObserver=new ResizeObserver(this.resize.bind(this)),this._resizeObserver.observe(A)}add(A){this._container.add(A)}updatePosition(){this.lines.forceUpdate()}destroy(){var e,t;this.amr.destroy(),xs.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(e=this._fitAnimation)==null||e.stop(),window.removeEventListener("drag",this._drag),document.removeEventListener("wheel",this._detectTrackpad),window.removeEventListener("pointermove",this._pointermove),this.renderer.domElement.removeEventListener("pointerdown",this._pointerdown);const A=this.renderer.domElement.parentElement;A&&((t=this._resizeObserver)==null||t.unobserve(A)),this.controls.dispose(),this.renderer.dispose(),this._composer.dispose(),this.scene.traverse(i=>{var r;i instanceof Te?(i.geometry.dispose(),Array.isArray(i.material)?i.material.forEach(s=>s.dispose()):i.material&&i.material.dispose()):i instanceof jf?i.dispose():(r=i.dispose)==null||r.call(i),i.removeFromParent()})}}var ZK=Object.defineProperty,XK=(n,A,e)=>A in n?ZK(n,A,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[A]=e,pA=(n,A,e)=>(XK(n,typeof A!="symbol"?A+"":A,e),e);class Li{constructor(A){pA(this,"parent"),pA(this,"paused"),this.parent=A,this.paused=!1}destroy(){}down(A){return!1}move(A){return!1}up(A){return!1}wheel(A){return!1}update(A){}resize(){}reset(){}pause(){this.paused=!0}resume(){this.paused=!1}}var QK=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},PS={exports:{}};(function(n,A){(function(){var e,t;t=function(i){return n.exports=i},e={linear:function(i,r,s,o){return s*i/o+r},easeInQuad:function(i,r,s,o){return s*(i/=o)*i+r},easeOutQuad:function(i,r,s,o){return-s*(i/=o)*(i-2)+r},easeInOutQuad:function(i,r,s,o){return(i/=o/2)<1?s/2*i*i+r:-s/2*(--i*(i-2)-1)+r},easeInCubic:function(i,r,s,o){return s*(i/=o)*i*i+r},easeOutCubic:function(i,r,s,o){return s*((i=i/o-1)*i*i+1)+r},easeInOutCubic:function(i,r,s,o){return(i/=o/2)<1?s/2*i*i*i+r:s/2*((i-=2)*i*i+2)+r},easeInQuart:function(i,r,s,o){return s*(i/=o)*i*i*i+r},easeOutQuart:function(i,r,s,o){return-s*((i=i/o-1)*i*i*i-1)+r},easeInOutQuart:function(i,r,s,o){return(i/=o/2)<1?s/2*i*i*i*i+r:-s/2*((i-=2)*i*i*i-2)+r},easeInQuint:function(i,r,s,o){return s*(i/=o)*i*i*i*i+r},easeOutQuint:function(i,r,s,o){return s*((i=i/o-1)*i*i*i*i+1)+r},easeInOutQuint:function(i,r,s,o){return(i/=o/2)<1?s/2*i*i*i*i*i+r:s/2*((i-=2)*i*i*i*i+2)+r},easeInSine:function(i,r,s,o){return-s*Math.cos(i/o*(Math.PI/2))+s+r},easeOutSine:function(i,r,s,o){return s*Math.sin(i/o*(Math.PI/2))+r},easeInOutSine:function(i,r,s,o){return-s/2*(Math.cos(Math.PI*i/o)-1)+r},easeInExpo:function(i,r,s,o){return i===0?r:s*Math.pow(2,10*(i/o-1))+r},easeOutExpo:function(i,r,s,o){return i===o?r+s:s*(-Math.pow(2,-10*i/o)+1)+r},easeInOutExpo:function(i,r,s,o){return(i/=o/2)<1?s/2*Math.pow(2,10*(i-1))+r:s/2*(-Math.pow(2,-10*--i)+2)+r},easeInCirc:function(i,r,s,o){return-s*(Math.sqrt(1-(i/=o)*i)-1)+r},easeOutCirc:function(i,r,s,o){return s*Math.sqrt(1-(i=i/o-1)*i)+r},easeInOutCirc:function(i,r,s,o){return(i/=o/2)<1?-s/2*(Math.sqrt(1-i*i)-1)+r:s/2*(Math.sqrt(1-(i-=2)*i)+1)+r},easeInElastic:function(i,r,s,o){var a,l,u;return u=1.70158,l=0,a=s,i===0||(i/=o),l||(l=o*.3),a<Math.abs(s)?(a=s,u=l/4):u=l/(2*Math.PI)*Math.asin(s/a),-(a*Math.pow(2,10*(i-=1))*Math.sin((i*o-u)*(2*Math.PI)/l))+r},easeOutElastic:function(i,r,s,o){var a,l,u;return u=1.70158,l=0,a=s,i===0||(i/=o),l||(l=o*.3),a<Math.abs(s)?(a=s,u=l/4):u=l/(2*Math.PI)*Math.asin(s/a),a*Math.pow(2,-10*i)*Math.sin((i*o-u)*(2*Math.PI)/l)+s+r},easeInOutElastic:function(i,r,s,o){var a,l,u;return u=1.70158,l=0,a=s,i===0||(i/=o/2),l||(l=o*(.3*1.5)),a<Math.abs(s)?(a=s,u=l/4):u=l/(2*Math.PI)*Math.asin(s/a),i<1?-.5*(a*Math.pow(2,10*(i-=1))*Math.sin((i*o-u)*(2*Math.PI)/l))+r:a*Math.pow(2,-10*(i-=1))*Math.sin((i*o-u)*(2*Math.PI)/l)*.5+s+r},easeInBack:function(i,r,s,o,a){return a===void 0&&(a=1.70158),s*(i/=o)*i*((a+1)*i-a)+r},easeOutBack:function(i,r,s,o,a){return a===void 0&&(a=1.70158),s*((i=i/o-1)*i*((a+1)*i+a)+1)+r},easeInOutBack:function(i,r,s,o,a){return a===void 0&&(a=1.70158),(i/=o/2)<1?s/2*(i*i*(((a*=1.525)+1)*i-a))+r:s/2*((i-=2)*i*(((a*=1.525)+1)*i+a)+2)+r},easeInBounce:function(i,r,s,o){var a;return a=e.easeOutBounce(o-i,0,s,o),s-a+r},easeOutBounce:function(i,r,s,o){return(i/=o)<1/2.75?s*(7.5625*i*i)+r:i<2/2.75?s*(7.5625*(i-=1.5/2.75)*i+.75)+r:i<2.5/2.75?s*(7.5625*(i-=2.25/2.75)*i+.9375)+r:s*(7.5625*(i-=2.625/2.75)*i+.984375)+r},easeInOutBounce:function(i,r,s,o){var a;return i<o/2?(a=e.easeInBounce(i*2,0,s,o),a*.5+r):(a=e.easeOutBounce(i*2-o,0,s,o),a*.5+s*.5+r)}},t(e)}).call(QK)})(PS);const TS=PS.exports;function yd(n,A){if(n){if(typeof n=="function")return n;if(typeof n=="string")return TS[n]}else return TS[A]}const VK={removeOnInterrupt:!1,ease:"linear",time:1e3};class $K extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"startX"),pA(this,"startY"),pA(this,"deltaX"),pA(this,"deltaY"),pA(this,"keepCenter"),pA(this,"startWidth",null),pA(this,"startHeight",null),pA(this,"deltaWidth",null),pA(this,"deltaHeight",null),pA(this,"width",null),pA(this,"height",null),pA(this,"time",0),this.options=Object.assign({},VK,e),this.options.ease=yd(this.options.ease),this.setupPosition(),this.setupZoom(),this.time=0}setupPosition(){typeof this.options.position<"u"?(this.startX=this.parent.center.x,this.startY=this.parent.center.y,this.deltaX=this.options.position.x-this.parent.center.x,this.deltaY=this.options.position.y-this.parent.center.y,this.keepCenter=!1):this.keepCenter=!0}setupZoom(){this.width=null,this.height=null,typeof this.options.scale<"u"?this.width=this.parent.screenWidth/this.options.scale:typeof this.options.scaleX<"u"||typeof this.options.scaleY<"u"?(typeof this.options.scaleX<"u"&&(this.width=this.parent.screenWidth/this.options.scaleX),typeof this.options.scaleY<"u"&&(this.height=this.parent.screenHeight/this.options.scaleY)):(typeof this.options.width<"u"&&(this.width=this.options.width),typeof this.options.height<"u"&&(this.height=this.options.height)),this.width!==null&&(this.startWidth=this.parent.screenWidthInWorldPixels,this.deltaWidth=this.width-this.startWidth),this.height!==null&&(this.startHeight=this.parent.screenHeightInWorldPixels,this.deltaHeight=this.height-this.startHeight)}down(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("animate"),!1}complete(){this.parent.plugins.remove("animate"),this.width!==null&&this.parent.fitWidth(this.width,this.keepCenter,this.height===null),this.height!==null&&this.parent.fitHeight(this.height,this.keepCenter,this.width===null),!this.keepCenter&&this.options.position&&this.parent.moveCenter(this.options.position),this.parent.emit("animate-end",this.parent),this.options.callbackOnComplete&&this.options.callbackOnComplete(this.parent)}update(A){if(this.paused)return;this.time+=A;const e=new VA(this.parent.scale.x,this.parent.scale.y);if(this.time>=this.options.time){const t=this.parent.width,i=this.parent.height;this.complete(),(t!==this.parent.width||i!==this.parent.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}else{const t=this.options.ease(this.time,0,1,this.options.time);if(this.width!==null){const i=this.startWidth,r=this.deltaWidth;this.parent.fitWidth(i+r*t,this.keepCenter,this.height===null)}if(this.height!==null){const i=this.startHeight,r=this.deltaHeight;this.parent.fitHeight(i+r*t,this.keepCenter,this.width===null)}if(this.width===null?this.parent.scale.x=this.parent.scale.y:this.height===null&&(this.parent.scale.y=this.parent.scale.x),!this.keepCenter){const i=this.startX,r=this.startY,s=this.deltaX,o=this.deltaY,a=new VA(this.parent.x,this.parent.y);this.parent.moveCenter(i+s*t,r+o*t),this.parent.emit("moved",{viewport:this.parent,original:a,type:"animate"})}(this.width||this.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}}}const AF={sides:"all",friction:.5,time:150,ease:"easeInOutSine",underflow:"center",bounceBox:null};class eF extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"left"),pA(this,"top"),pA(this,"right"),pA(this,"bottom"),pA(this,"underflowX"),pA(this,"underflowY"),pA(this,"ease"),pA(this,"toX"),pA(this,"toY"),this.options=Object.assign({},AF,e),this.ease=yd(this.options.ease,"easeInOutSine"),this.options.sides?this.options.sides==="all"?this.top=this.bottom=this.left=this.right=!0:this.options.sides==="horizontal"?(this.right=this.left=!0,this.top=this.bottom=!1):this.options.sides==="vertical"?(this.left=this.right=!1,this.top=this.bottom=!0):(this.top=this.options.sides.indexOf("top")!==-1,this.bottom=this.options.sides.indexOf("bottom")!==-1,this.left=this.options.sides.indexOf("left")!==-1,this.right=this.options.sides.indexOf("right")!==-1):this.left=this.top=this.right=this.bottom=!1;const t=this.options.underflow.toLowerCase();t==="center"?(this.underflowX=0,this.underflowY=0):(this.underflowX=t.indexOf("left")!==-1?-1:t.indexOf("right")!==-1?1:0,this.underflowY=t.indexOf("top")!==-1?-1:t.indexOf("bottom")!==-1?1:0),this.reset()}isActive(){return this.toX!==null||this.toY!==null}down(){return this.toX=this.toY=null,!1}up(){return this.bounce(),!1}update(A){if(!this.paused){if(this.bounce(),this.toX){const e=this.toX;e.time+=A,this.parent.emit("moved",{viewport:this.parent,type:"bounce-x"}),e.time>=this.options.time?(this.parent.x=e.end,this.toX=null,this.parent.emit("bounce-x-end",this.parent)):this.parent.x=this.ease(e.time,e.start,e.delta,this.options.time)}if(this.toY){const e=this.toY;e.time+=A,this.parent.emit("moved",{viewport:this.parent,type:"bounce-y"}),e.time>=this.options.time?(this.parent.y=e.end,this.toY=null,this.parent.emit("bounce-y-end",this.parent)):this.parent.y=this.ease(e.time,e.start,e.delta,this.options.time)}}}calcUnderflowX(){let A;switch(this.underflowX){case-1:A=0;break;case 1:A=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:A=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}return A}calcUnderflowY(){let A;switch(this.underflowY){case-1:A=0;break;case 1:A=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:A=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}return A}oob(){const A=this.options.bounceBox;if(A){const e=typeof A.x>"u"?0:A.x,t=typeof A.y>"u"?0:A.y,i=typeof A.width>"u"?this.parent.worldWidth:A.width,r=typeof A.height>"u"?this.parent.worldHeight:A.height;return{left:this.parent.left<e,right:this.parent.right>i,top:this.parent.top<t,bottom:this.parent.bottom>r,topLeft:new VA(e*this.parent.scale.x,t*this.parent.scale.y),bottomRight:new VA(i*this.parent.scale.x-this.parent.screenWidth,r*this.parent.scale.y-this.parent.screenHeight)}}return{left:this.parent.left<0,right:this.parent.right>this.parent.worldWidth,top:this.parent.top<0,bottom:this.parent.bottom>this.parent.worldHeight,topLeft:new VA(0,0),bottomRight:new VA(this.parent.worldWidth*this.parent.scale.x-this.parent.screenWidth,this.parent.worldHeight*this.parent.scale.y-this.parent.screenHeight)}}bounce(){var A,e;if(this.paused)return;let t,i=this.parent.plugins.get("decelerate",!0);i&&(i.x||i.y)&&(i.x&&i.percentChangeX===((A=i.options)==null?void 0:A.friction)||i.y&&i.percentChangeY===((e=i.options)==null?void 0:e.friction))&&(t=this.oob(),(t.left&&this.left||t.right&&this.right)&&(i.percentChangeX=this.options.friction),(t.top&&this.top||t.bottom&&this.bottom)&&(i.percentChangeY=this.options.friction));const r=this.parent.plugins.get("drag",!0)||{},s=this.parent.plugins.get("pinch",!0)||{};if(i=i||{},!(r!=null&&r.active)&&!(s!=null&&s.active)&&(!this.toX||!this.toY)&&(!i.x||!i.y)){t=t||this.oob();const o=t.topLeft,a=t.bottomRight;if(!this.toX&&!i.x){let l=null;t.left&&this.left?l=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-o.x:t.right&&this.right&&(l=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-a.x),l!==null&&this.parent.x!==l&&(this.toX={time:0,start:this.parent.x,delta:l-this.parent.x,end:l},this.parent.emit("bounce-x-start",this.parent))}if(!this.toY&&!i.y){let l=null;t.top&&this.top?l=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-o.y:t.bottom&&this.bottom&&(l=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-a.y),l!==null&&this.parent.y!==l&&(this.toY={time:0,start:this.parent.y,delta:l-this.parent.y,end:l},this.parent.emit("bounce-y-start",this.parent))}}}reset(){this.toX=this.toY=null,this.bounce()}}const tF={left:!1,right:!1,top:!1,bottom:!1,direction:null,underflow:"center"};class iF extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"last"),pA(this,"noUnderflow"),pA(this,"underflowX"),pA(this,"underflowY"),this.options=Object.assign({},tF,e),this.options.direction&&(this.options.left=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.right=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.top=this.options.direction==="y"||this.options.direction==="all"?!0:null,this.options.bottom=this.options.direction==="y"||this.options.direction==="all"?!0:null),this.parseUnderflow(),this.last={x:null,y:null,scaleX:null,scaleY:null},this.update()}parseUnderflow(){const A=this.options.underflow.toLowerCase();A==="none"?this.noUnderflow=!0:A==="center"?(this.underflowX=this.underflowY=0,this.noUnderflow=!1):(this.underflowX=A.indexOf("left")!==-1?-1:A.indexOf("right")!==-1?1:0,this.underflowY=A.indexOf("top")!==-1?-1:A.indexOf("bottom")!==-1?1:0,this.noUnderflow=!1)}move(){return this.update(),!1}update(){if(this.paused||this.parent.x===this.last.x&&this.parent.y===this.last.y&&this.parent.scale.x===this.last.scaleX&&this.parent.scale.y===this.last.scaleY)return;const A=new VA(this.parent.x,this.parent.y),e=this.parent.plugins.decelerate||{};if(this.options.left!==null||this.options.right!==null){let t=!1;if(!this.noUnderflow&&this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x!==0&&(this.parent.x=0,t=!0);break;case 1:this.parent.x!==this.parent.screenWidth-this.parent.screenWorldWidth&&(this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth,t=!0);break;default:this.parent.x!==(this.parent.screenWidth-this.parent.screenWorldWidth)/2&&(this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2,t=!0)}else this.options.left!==null&&this.parent.left<(this.options.left===!0?0:this.options.left)&&(this.parent.x=-(this.options.left===!0?0:this.options.left)*this.parent.scale.x,e.x=0,t=!0),this.options.right!==null&&this.parent.right>(this.options.right===!0?this.parent.worldWidth:this.options.right)&&(this.parent.x=-(this.options.right===!0?this.parent.worldWidth:this.options.right)*this.parent.scale.x+this.parent.screenWidth,e.x=0,t=!0);t&&this.parent.emit("moved",{viewport:this.parent,original:A,type:"clamp-x"})}if(this.options.top!==null||this.options.bottom!==null){let t=!1;if(!this.noUnderflow&&this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y!==0&&(this.parent.y=0,t=!0);break;case 1:this.parent.y!==this.parent.screenHeight-this.parent.screenWorldHeight&&(this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight,t=!0);break;default:this.parent.y!==(this.parent.screenHeight-this.parent.screenWorldHeight)/2&&(this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2,t=!0)}else this.options.top!==null&&this.parent.top<(this.options.top===!0?0:this.options.top)&&(this.parent.y=-(this.options.top===!0?0:this.options.top)*this.parent.scale.y,e.y=0,t=!0),this.options.bottom!==null&&this.parent.bottom>(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)&&(this.parent.y=-(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)*this.parent.scale.y+this.parent.screenHeight,e.y=0,t=!0);t&&this.parent.emit("moved",{viewport:this.parent,original:A,type:"clamp-y"})}this.last.x=this.parent.x,this.last.y=this.parent.y,this.last.scaleX=this.parent.scale.x,this.last.scaleY=this.parent.scale.y}reset(){this.update()}}const nF={minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,minScale:null,maxScale:null};class rF extends Li{constructor(A,e={}){super(A),pA(this,"options"),this.options=Object.assign({},nF,e),this.clamp()}resize(){this.clamp()}clamp(){if(!this.paused){if(this.options.minWidth||this.options.minHeight||this.options.maxWidth||this.options.maxHeight){let A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight;if(this.options.minWidth!==null&&A<this.options.minWidth){const t=this.parent.scale.x;this.parent.fitWidth(this.options.minWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/t,A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxWidth!==null&&A>this.options.maxWidth){const t=this.parent.scale.x;this.parent.fitWidth(this.options.maxWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/t,A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.minHeight!==null&&e<this.options.minHeight){const t=this.parent.scale.y;this.parent.fitHeight(this.options.minHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/t,A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxHeight!==null&&e>this.options.maxHeight){const t=this.parent.scale.y;this.parent.fitHeight(this.options.maxHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/t,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}}else if(this.options.minScale||this.options.maxScale){const A={x:null,y:null},e={x:null,y:null};if(typeof this.options.minScale=="number")A.x=this.options.minScale,A.y=this.options.minScale;else if(this.options.minScale!==null){const r=this.options.minScale;A.x=typeof r.x>"u"?null:r.x,A.y=typeof r.y>"u"?null:r.y}if(typeof this.options.maxScale=="number")e.x=this.options.maxScale,e.y=this.options.maxScale;else if(this.options.maxScale!==null){const r=this.options.maxScale;e.x=typeof r.x>"u"?null:r.x,e.y=typeof r.y>"u"?null:r.y}let t=this.parent.scale.x,i=this.parent.scale.y;A.x!==null&&t<A.x&&(t=A.x),e.x!==null&&t>e.x&&(t=e.x),A.y!==null&&i<A.y&&(i=A.y),e.y!==null&&i>e.y&&(i=e.y),(t!==this.parent.scale.x||i!==this.parent.scale.y)&&(this.parent.scale.set(t,i),this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"}))}}}reset(){this.clamp()}}const sF={friction:.98,bounce:.8,minSpeed:.01},$r=16;class oF extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"x"),pA(this,"y"),pA(this,"percentChangeX"),pA(this,"percentChangeY"),pA(this,"saved"),pA(this,"timeSinceRelease"),this.options=Object.assign({},sF,e),this.saved=[],this.timeSinceRelease=0,this.reset(),this.parent.on("moved",t=>this.handleMoved(t))}down(){return this.saved=[],this.x=this.y=null,!1}isActive(){return!!(this.x||this.y)}move(){if(this.paused)return!1;const A=this.parent.input.count();return(A===1||A>1&&!this.parent.plugins.get("pinch",!0))&&(this.saved.push({x:this.parent.x,y:this.parent.y,time:performance.now()}),this.saved.length>60&&this.saved.splice(0,30)),!1}handleMoved(A){if(this.saved.length){const e=this.saved[this.saved.length-1];A.type==="clamp-x"&&A.original?e.x===A.original.x&&(e.x=this.parent.x):A.type==="clamp-y"&&A.original&&e.y===A.original.y&&(e.y=this.parent.y)}}up(){if(this.parent.input.count()===0&&this.saved.length){const A=performance.now();for(const e of this.saved)if(e.time>=A-100){const t=A-e.time;this.x=(this.parent.x-e.x)/t,this.y=(this.parent.y-e.y)/t,this.percentChangeX=this.percentChangeY=this.options.friction,this.timeSinceRelease=0;break}}return!1}activate(A){A=A||{},typeof A.x<"u"&&(this.x=A.x,this.percentChangeX=this.options.friction),typeof A.y<"u"&&(this.y=A.y,this.percentChangeY=this.options.friction)}update(A){if(this.paused)return;const e=this.x||this.y,t=this.timeSinceRelease,i=this.timeSinceRelease+A;if(this.x){const r=this.percentChangeX,s=Math.log(r);this.parent.x+=this.x*$r/s*(Math.pow(r,i/$r)-Math.pow(r,t/$r)),this.x*=Math.pow(this.percentChangeX,A/$r)}if(this.y){const r=this.percentChangeY,s=Math.log(r);this.parent.y+=this.y*$r/s*(Math.pow(r,i/$r)-Math.pow(r,t/$r)),this.y*=Math.pow(this.percentChangeY,A/$r)}this.timeSinceRelease+=A,this.x&&this.y?Math.abs(this.x)<this.options.minSpeed&&Math.abs(this.y)<this.options.minSpeed&&(this.x=0,this.y=0):(Math.abs(this.x||0)<this.options.minSpeed&&(this.x=0),Math.abs(this.y||0)<this.options.minSpeed&&(this.y=0)),e&&this.parent.emit("moved",{viewport:this.parent,type:"decelerate"})}reset(){this.x=this.y=null}}const aF={direction:"all",pressDrag:!0,wheel:!0,wheelScroll:1,reverse:!1,clampWheel:!1,underflow:"center",factor:1,mouseButtons:"all",keyToPress:null,ignoreKeyToPressOnTouch:!1,lineHeight:20,wheelSwapAxes:!1};class lF extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"moved"),pA(this,"reverse"),pA(this,"xDirection"),pA(this,"yDirection"),pA(this,"keyIsPressed"),pA(this,"mouse"),pA(this,"underflowX"),pA(this,"underflowY"),pA(this,"last"),pA(this,"current"),pA(this,"windowEventHandlers",[]),this.options=Object.assign({},aF,e),this.moved=!1,this.reverse=this.options.reverse?1:-1,this.xDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="x",this.yDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="y",this.keyIsPressed=!1,this.parseUnderflow(),this.mouseButtons(this.options.mouseButtons),this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(A){const e=i=>{A.includes(i.code)&&(this.keyIsPressed=!0)},t=i=>{A.includes(i.code)&&(this.keyIsPressed=!1)};this.addWindowEventHandler("keyup",t),this.addWindowEventHandler("keydown",e)}addWindowEventHandler(A,e){window.addEventListener(A,e),this.windowEventHandlers.push({event:A,handler:e})}destroy(){this.windowEventHandlers.forEach(({event:A,handler:e})=>{window.removeEventListener(A,e)})}mouseButtons(A){!A||A==="all"?this.mouse=[!0,!0,!0]:this.mouse=[A.indexOf("left")!==-1,A.indexOf("middle")!==-1,A.indexOf("right")!==-1]}parseUnderflow(){const A=this.options.underflow.toLowerCase();A==="center"?(this.underflowX=0,this.underflowY=0):(A.includes("left")?this.underflowX=-1:A.includes("right")?this.underflowX=1:this.underflowX=0,A.includes("top")?this.underflowY=-1:A.includes("bottom")?this.underflowY=1:this.underflowY=0)}checkButtons(A){const e=A.pointerType==="mouse",t=this.parent.input.count();return!!((t===1||t>1&&!this.parent.plugins.get("pinch",!0))&&(!e||this.mouse[A.button]))}checkKeyPress(A){return!this.options.keyToPress||this.keyIsPressed||this.options.ignoreKeyToPressOnTouch&&A.data.pointerType==="touch"}down(A){return this.paused||!this.options.pressDrag?!1:this.checkButtons(A)&&this.checkKeyPress(A)?(this.last={x:A.global.x,y:A.global.y},this.current=A.pointerId,!0):(this.last=null,!1)}get active(){return this.moved}move(A){if(this.paused||!this.options.pressDrag)return!1;if(this.last&&this.current===A.data.pointerId){const e=A.global.x,t=A.global.y,i=this.parent.input.count();if(i===1||i>1&&!this.parent.plugins.get("pinch",!0)){const r=e-this.last.x,s=t-this.last.y;if(this.moved||this.xDirection&&this.parent.input.checkThreshold(r)||this.yDirection&&this.parent.input.checkThreshold(s)){const o={x:e,y:t};return this.xDirection&&(this.parent.x+=(o.x-this.last.x)*this.options.factor),this.yDirection&&(this.parent.y+=(o.y-this.last.y)*this.options.factor),this.last=o,this.moved||this.parent.emit("drag-start",{event:A,screen:new VA(this.last.x,this.last.y),world:this.parent.toWorld(new VA(this.last.x,this.last.y)),viewport:this.parent}),this.moved=!0,this.parent.emit("moved",{viewport:this.parent,type:"drag"}),!0}}else this.moved=!1}return!1}up(A){if(this.paused)return!1;const e=this.parent.input.touches;if(e.length===1){const t=e[0];return t.last&&(this.last={x:t.last.x,y:t.last.y},this.current=t.id),this.moved=!1,!0}else if(this.last&&this.moved){const t=new VA(this.last.x,this.last.y);return this.parent.emit("drag-end",{event:A,screen:t,world:this.parent.toWorld(t),viewport:this.parent}),this.last=null,this.moved=!1,!0}return!1}wheel(A){if(this.paused)return!1;if(this.options.wheel){const e=this.parent.plugins.get("wheel",!0);if(!e||!e.options.wheelZoom&&!A.ctrlKey){const t=A.deltaMode?this.options.lineHeight:1,i=[A.deltaX,A.deltaY],[r,s]=this.options.wheelSwapAxes?i.reverse():i;return this.xDirection&&(this.parent.x+=r*t*this.options.wheelScroll*this.reverse),this.yDirection&&(this.parent.y+=s*t*this.options.wheelScroll*this.reverse),this.options.clampWheel&&this.clamp(),this.parent.emit("wheel-scroll",this.parent),this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.options.passiveWheel||A.preventDefault(),this.parent.options.stopPropagation&&A.stopPropagation(),!0}}return!1}resume(){this.last=null,this.paused=!1}clamp(){const A=this.parent.plugins.get("decelerate",!0)||{};if(this.options.clampWheel!=="y")if(this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x=0;break;case 1:this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}else this.parent.left<0?(this.parent.x=0,A.x=0):this.parent.right>this.parent.worldWidth&&(this.parent.x=-this.parent.worldWidth*this.parent.scale.x+this.parent.screenWidth,A.x=0);if(this.options.clampWheel!=="x")if(this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y=0;break;case 1:this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}else this.parent.top<0&&(this.parent.y=0,A.y=0),this.parent.bottom>this.parent.worldHeight&&(this.parent.y=-this.parent.worldHeight*this.parent.scale.y+this.parent.screenHeight,A.y=0)}}const cF={speed:0,acceleration:null,radius:null};class hF extends Li{constructor(A,e,t={}){super(A),pA(this,"options"),pA(this,"target"),pA(this,"velocity"),this.target=e,this.options=Object.assign({},cF,t),this.velocity={x:0,y:0}}update(A){if(this.paused)return;const e=this.parent.center;let t=this.target.x,i=this.target.y;if(this.options.radius)if(Math.sqrt(Math.pow(this.target.y-e.y,2)+Math.pow(this.target.x-e.x,2))>this.options.radius){const o=Math.atan2(this.target.y-e.y,this.target.x-e.x);t=this.target.x-Math.cos(o)*this.options.radius,i=this.target.y-Math.sin(o)*this.options.radius}else return;const r=t-e.x,s=i-e.y;if(r||s)if(this.options.speed)if(this.options.acceleration){const o=Math.atan2(i-e.y,t-e.x),a=Math.sqrt(Math.pow(r,2)+Math.pow(s,2));if(a){const l=(Math.pow(this.velocity.x,2)+Math.pow(this.velocity.y,2))/(2*this.options.acceleration);a>l?this.velocity={x:Math.min(this.velocity.x+(this.options.acceleration*A,this.options.speed)),y:Math.min(this.velocity.y+(this.options.acceleration*A,this.options.speed))}:this.velocity={x:Math.max(this.velocity.x-this.options.acceleration*this.options.speed,0),y:Math.max(this.velocity.y-this.options.acceleration*this.options.speed,0)};const u=Math.cos(o)*this.velocity.x,c=Math.sin(o)*this.velocity.y,h=Math.abs(u)>Math.abs(r)?t:e.x+u,f=Math.abs(c)>Math.abs(s)?i:e.y+c;this.parent.moveCenter(h,f),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}else{const o=Math.atan2(i-e.y,t-e.x),a=Math.cos(o)*this.options.speed,l=Math.sin(o)*this.options.speed,u=Math.abs(a)>Math.abs(r)?t:e.x+a,c=Math.abs(l)>Math.abs(s)?i:e.y+l;this.parent.moveCenter(u,c),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}else this.parent.moveCenter(t,i),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}const uF={radius:null,distance:null,top:null,bottom:null,left:null,right:null,speed:8,reverse:!1,noDecelerate:!1,linear:!1,allowButtons:!1};class fF extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"reverse"),pA(this,"radiusSquared"),pA(this,"left"),pA(this,"top"),pA(this,"right"),pA(this,"bottom"),pA(this,"horizontal"),pA(this,"vertical"),this.options=Object.assign({},uF,e),this.reverse=this.options.reverse?1:-1,this.radiusSquared=typeof this.options.radius=="number"?Math.pow(this.options.radius,2):null,this.resize()}resize(){const A=this.options.distance;A!==null?(this.left=A,this.top=A,this.right=this.parent.screenWidth-A,this.bottom=this.parent.screenHeight-A):this.options.radius||(this.left=this.options.left,this.top=this.options.top,this.right=this.options.right===null?null:this.parent.screenWidth-this.options.right,this.bottom=this.options.bottom===null?null:this.parent.screenHeight-this.options.bottom)}down(){return this.paused||this.options.allowButtons||(this.horizontal=this.vertical=null),!1}move(A){if(this.paused||A.pointerType!=="mouse"&&A.pointerId!==1||!this.options.allowButtons&&A.buttons!==0)return!1;const e=A.global.x,t=A.global.y;if(this.radiusSquared){const i=this.parent.toScreen(this.parent.center);if(Math.pow(i.x-e,2)+Math.pow(i.y-t,2)>=this.radiusSquared){const r=Math.atan2(i.y-t,i.x-e);this.options.linear?(this.horizontal=Math.round(Math.cos(r))*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.round(Math.sin(r))*this.options.speed*this.reverse*(60/1e3)):(this.horizontal=Math.cos(r)*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.sin(r)*this.options.speed*this.reverse*(60/1e3))}else this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=0}else this.left!==null&&e<this.left?this.horizontal=Number(this.reverse)*this.options.speed*(60/1e3):this.right!==null&&e>this.right?this.horizontal=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateHorizontal(),this.horizontal=0),this.top!==null&&t<this.top?this.vertical=Number(this.reverse)*this.options.speed*(60/1e3):this.bottom!==null&&t>this.bottom?this.vertical=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateVertical(),this.vertical=0);return!1}decelerateHorizontal(){const A=this.parent.plugins.get("decelerate",!0);this.horizontal&&A&&!this.options.noDecelerate&&A.activate({x:this.horizontal*this.options.speed*this.reverse/(1e3/60)})}decelerateVertical(){const A=this.parent.plugins.get("decelerate",!0);this.vertical&&A&&!this.options.noDecelerate&&A.activate({y:this.vertical*this.options.speed*this.reverse/(1e3/60)})}up(){return this.paused||(this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=null),!1}update(){if(!this.paused&&(this.horizontal||this.vertical)){const A=this.parent.center;this.horizontal&&(A.x+=this.horizontal*this.options.speed),this.vertical&&(A.y+=this.vertical*this.options.speed),this.parent.moveCenter(A),this.parent.emit("moved",{viewport:this.parent,type:"mouse-edges"})}}}const dF={noDrag:!1,percent:1,center:null,factor:1,axis:"all"};class pF extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"active",!1),pA(this,"pinching",!1),pA(this,"moved",!1),pA(this,"lastCenter"),this.options=Object.assign({},dF,e)}down(){return this.parent.input.count()>=2?(this.active=!0,!0):!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}move(A){if(this.paused||!this.active)return!1;const e=A.global.x,t=A.global.y,i=this.parent.input.touches;if(i.length>=2){const r=i[0],s=i[1],o=r.last&&s.last?Math.sqrt(Math.pow(s.last.x-r.last.x,2)+Math.pow(s.last.y-r.last.y,2)):null;if(r.id===A.pointerId?r.last={x:e,y:t,data:A}:s.id===A.pointerId&&(s.last={x:e,y:t,data:A}),o){let a;const l=new VA(r.last.x+(s.last.x-r.last.x)/2,r.last.y+(s.last.y-r.last.y)/2);this.options.center||(a=this.parent.toLocal(l));let u=Math.sqrt(Math.pow(s.last.x-r.last.x,2)+Math.pow(s.last.y-r.last.y,2));u=u===0?u=1e-10:u;const c=(1-o/u)*this.options.percent*(this.isAxisX()?this.parent.scale.x:this.parent.scale.y);this.isAxisX()&&(this.parent.scale.x+=c),this.isAxisY()&&(this.parent.scale.y+=c),this.parent.emit("zoomed",{viewport:this.parent,type:"pinch",center:l});const h=this.parent.plugins.get("clamp-zoom",!0);if(h&&h.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const f=this.parent.toGlobal(a);this.parent.x+=(l.x-f.x)*this.options.factor,this.parent.y+=(l.y-f.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})}!this.options.noDrag&&this.lastCenter&&(this.parent.x+=(l.x-this.lastCenter.x)*this.options.factor,this.parent.y+=(l.y-this.lastCenter.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})),this.lastCenter=l,this.moved=!0}else this.pinching||(this.parent.emit("pinch-start",this.parent),this.pinching=!0);return!0}return!1}up(){return this.pinching&&this.parent.input.touches.length<=1?(this.active=!1,this.lastCenter=null,this.pinching=!1,this.moved=!1,this.parent.emit("pinch-end",this.parent),!0):!1}}const gF={topLeft:!1,friction:.8,time:1e3,ease:"easeInOutSine",interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1};class mF extends Li{constructor(A,e,t,i={}){super(A),pA(this,"options"),pA(this,"ease"),pA(this,"x"),pA(this,"y"),pA(this,"percent"),pA(this,"snapping"),pA(this,"deltaX"),pA(this,"deltaY"),pA(this,"startX"),pA(this,"startY"),this.options=Object.assign({},gF,i),this.ease=yd(i.ease,"easeInOutSine"),this.x=e,this.y=t,this.options.forceStart&&this.snapStart()}snapStart(){this.percent=0,this.snapping={time:0};const A=this.options.topLeft?this.parent.corner:this.parent.center;this.deltaX=this.x-A.x,this.deltaY=this.y-A.y,this.startX=A.x,this.startY=A.y,this.parent.emit("snap-start",this.parent)}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap"):this.options.interrupt&&(this.snapping=null),!1}up(){if(this.parent.input.count()===0){const A=this.parent.plugins.get("decelerate",!0);A&&(A.x||A.y)&&(A.percentChangeX=A.percentChangeY=this.options.friction)}return!1}update(A){if(!this.paused&&!(this.options.interrupt&&this.parent.input.count()!==0))if(this.snapping){const e=this.snapping;e.time+=A;let t,i,r;const s=this.startX,o=this.startY,a=this.deltaX,l=this.deltaY;if(e.time>this.options.time)t=!0,i=s+a,r=o+l;else{const u=this.ease(e.time,0,1,this.options.time);i=s+a*u,r=o+l*u}this.options.topLeft?this.parent.moveCorner(i,r):this.parent.moveCenter(i,r),this.parent.emit("moved",{viewport:this.parent,type:"snap"}),t&&(this.options.removeOnComplete&&this.parent.plugins.remove("snap"),this.parent.emit("snap-end",this.parent),this.snapping=null)}else{const e=this.options.topLeft?this.parent.corner:this.parent.center;(e.x!==this.x||e.y!==this.y)&&this.snapStart()}}}const vF={width:0,height:0,time:1e3,ease:"easeInOutSine",center:null,interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1,noMove:!1};class yF extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"ease"),pA(this,"xScale"),pA(this,"yScale"),pA(this,"xIndependent"),pA(this,"yIndependent"),pA(this,"snapping"),this.options=Object.assign({},vF,e),this.ease=yd(this.options.ease),this.xIndependent=!1,this.yIndependent=!1,this.xScale=0,this.yScale=0,this.options.width>0&&(this.xScale=A.screenWidth/this.options.width,this.xIndependent=!0),this.options.height>0&&(this.yScale=A.screenHeight/this.options.height,this.yIndependent=!0),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale,this.options.time===0?(A.container.scale.x=this.xScale,A.container.scale.y=this.yScale,this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom")):e.forceStart&&this.createSnapping()}createSnapping(){const A=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,t=this.parent.screenWidth/this.xScale,i=this.parent.screenHeight/this.yScale;this.snapping={time:0,startX:A,startY:e,deltaX:t-A,deltaY:i-e},this.parent.emit("snap-zoom-start",this.parent)}resize(){this.snapping=null,this.options.width>0&&(this.xScale=this.parent.screenWidth/this.options.width),this.options.height>0&&(this.yScale=this.parent.screenHeight/this.options.height),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap-zoom"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap-zoom"):this.options.interrupt&&(this.snapping=null),!1}update(A){if(this.paused||this.options.interrupt&&this.parent.input.count()!==0)return;let e;if(!this.options.center&&!this.options.noMove&&(e=this.parent.center),!this.snapping)(this.parent.scale.x!==this.xScale||this.parent.scale.y!==this.yScale)&&this.createSnapping();else if(this.snapping){const t=this.snapping;if(t.time+=A,t.time>=this.options.time)this.parent.scale.set(this.xScale,this.yScale),this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom"),this.parent.emit("snap-zoom-end",this.parent),this.snapping=null;else{const r=this.snapping,s=this.ease(r.time,r.startX,r.deltaX,this.options.time),o=this.ease(r.time,r.startY,r.deltaY,this.options.time);this.parent.scale.x=this.parent.screenWidth/s,this.parent.scale.y=this.parent.screenHeight/o}const i=this.parent.plugins.get("clamp-zoom",!0);i&&i.clamp(),this.options.noMove||(this.options.center?this.parent.moveCenter(this.options.center):this.parent.moveCenter(e))}}resume(){this.snapping=null,super.resume()}}const wF={percent:.1,smooth:!1,interrupt:!0,reverse:!1,center:null,lineHeight:20,axis:"all",keyToPress:null,trackpadPinch:!1,wheelZoom:!0};class CF extends Li{constructor(A,e={}){super(A),pA(this,"options"),pA(this,"smoothing"),pA(this,"smoothingCenter"),pA(this,"smoothingCount"),pA(this,"keyIsPressed"),this.options=Object.assign({},wF,e),this.keyIsPressed=!1,this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(A){window.addEventListener("keydown",e=>{A.includes(e.code)&&(this.keyIsPressed=!0)}),window.addEventListener("keyup",e=>{A.includes(e.code)&&(this.keyIsPressed=!1)})}checkKeyPress(){return!this.options.keyToPress||this.keyIsPressed}down(){return this.options.interrupt&&(this.smoothing=null),!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}update(){if(this.smoothing){const A=this.smoothingCenter,e=this.smoothing;let t;this.options.center||(t=this.parent.toLocal(A)),this.isAxisX()&&(this.parent.scale.x+=e.x),this.isAxisY()&&(this.parent.scale.y+=e.y),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const i=this.parent.plugins.get("clamp-zoom",!0);if(i&&i.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const r=this.parent.toGlobal(t);this.parent.x+=A.x-r.x,this.parent.y+=A.y-r.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.smoothingCount++,this.smoothingCount>=this.options.smooth&&(this.smoothing=null)}}pinch(A){if(this.paused)return;const e=this.parent.input.getPointerPosition(A),t=-A.deltaY*(A.deltaMode?this.options.lineHeight:1)/200,i=Math.pow(2,(1+this.options.percent)*t);let r;this.options.center||(r=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=i),this.isAxisY()&&(this.parent.scale.y*=i),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const s=this.parent.plugins.get("clamp-zoom",!0);if(s&&s.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const o=this.parent.toGlobal(r);this.parent.x+=e.x-o.x,this.parent.y+=e.y-o.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{event:A,viewport:this.parent})}wheel(A){if(this.paused||!this.checkKeyPress())return!1;if(A.ctrlKey&&this.options.trackpadPinch)this.pinch(A);else if(this.options.wheelZoom){const e=this.parent.input.getPointerPosition(A),t=(this.options.reverse?-1:1)*-A.deltaY*(A.deltaMode?this.options.lineHeight:1)/500,i=Math.pow(2,(1+this.options.percent)*t);if(this.options.smooth){const r={x:this.smoothing?this.smoothing.x*(this.options.smooth-this.smoothingCount):0,y:this.smoothing?this.smoothing.y*(this.options.smooth-this.smoothingCount):0};this.smoothing={x:((this.parent.scale.x+r.x)*i-this.parent.scale.x)/this.options.smooth,y:((this.parent.scale.y+r.y)*i-this.parent.scale.y)/this.options.smooth},this.smoothingCount=0,this.smoothingCenter=e}else{let r;this.options.center||(r=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=i),this.isAxisY()&&(this.parent.scale.y*=i),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const s=this.parent.plugins.get("clamp-zoom",!0);if(s&&s.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const o=this.parent.toGlobal(r);this.parent.x+=e.x-o.x,this.parent.y+=e.y-o.y}}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{event:A,viewport:this.parent})}return!this.parent.options.passiveWheel}}class xF{constructor(A){pA(this,"viewport"),pA(this,"clickedAvailable"),pA(this,"isMouseDown"),pA(this,"last"),pA(this,"wheelFunction"),pA(this,"touches"),this.viewport=A,this.touches=[],this.addListeners()}addListeners(){this.viewport.eventMode="static",this.viewport.forceHitArea||(this.viewport.hitArea=new ee(0,0,this.viewport.worldWidth,this.viewport.worldHeight)),this.viewport.on("pointerdown",this.down,this),this.viewport.options.allowPreserveDragOutside?this.viewport.on("globalpointermove",this.move,this):this.viewport.on("pointermove",this.move,this),this.viewport.on("pointerup",this.up,this),this.viewport.on("pointerupoutside",this.up,this),this.viewport.on("pointercancel",this.up,this),this.viewport.options.allowPreserveDragOutside||this.viewport.on("pointerleave",this.up,this),this.wheelFunction=A=>this.handleWheel(A),this.viewport.options.events.domElement.addEventListener("wheel",this.wheelFunction,{passive:this.viewport.options.passiveWheel}),this.isMouseDown=!1}destroy(){this.viewport.options.events.domElement.removeEventListener("wheel",this.wheelFunction)}down(A){if(!(this.viewport.pause||!this.viewport.worldVisible)){if(A.pointerType==="mouse"?this.isMouseDown=!0:this.get(A.pointerId)||this.touches.push({id:A.pointerId,last:null}),this.count()===1){this.last=A.global.clone();const e=this.viewport.plugins.get("decelerate",!0),t=this.viewport.plugins.get("bounce",!0);(!e||!e.isActive())&&(!t||!t.isActive())?this.clickedAvailable=!0:this.clickedAvailable=!1}else this.clickedAvailable=!1;this.viewport.plugins.down(A)&&this.viewport.options.stopPropagation&&A.stopPropagation()}}clear(){this.isMouseDown=!1,this.touches=[],this.last=null}checkThreshold(A){return Math.abs(A)>=this.viewport.threshold}move(A){if(this.viewport.pause||!this.viewport.worldVisible)return;const e=this.viewport.plugins.move(A);if(this.clickedAvailable&&this.last){const t=A.global.x-this.last.x,i=A.global.y-this.last.y;(this.checkThreshold(t)||this.checkThreshold(i))&&(this.clickedAvailable=!1)}e&&this.viewport.options.stopPropagation&&A.stopPropagation()}up(A){if(this.viewport.pause||!this.viewport.worldVisible)return;A.pointerType==="mouse"&&(this.isMouseDown=!1),A.pointerType!=="mouse"&&this.remove(A.pointerId);const e=this.viewport.plugins.up(A);this.clickedAvailable&&this.count()===0&&this.last&&(this.viewport.emit("clicked",{event:A,screen:this.last,world:this.viewport.toWorld(this.last),viewport:this.viewport}),this.clickedAvailable=!1),e&&this.viewport.options.stopPropagation&&A.stopPropagation()}getPointerPosition(A){const e=new VA;return this.viewport.options.events.mapPositionToPoint(e,A.clientX,A.clientY),e}handleWheel(A){if(this.viewport.pause||!this.viewport.worldVisible)return;const e=this.viewport.toLocal(this.getPointerPosition(A));this.viewport.left<=e.x&&e.x<=this.viewport.right&&this.viewport.top<=e.y&&e.y<=this.viewport.bottom&&this.viewport.plugins.wheel(A)&&!this.viewport.options.passiveWheel&&A.preventDefault()}pause(){this.touches=[],this.isMouseDown=!1}get(A){for(const e of this.touches)if(e.id===A)return e;return null}remove(A){for(let e=0;e<this.touches.length;e++)if(this.touches[e].id===A){this.touches.splice(e,1);return}}count(){return(this.isMouseDown?1:0)+this.touches.length}}const Nc=["drag","pinch","wheel","follow","mouse-edges","decelerate","animate","bounce","snap-zoom","clamp-zoom","snap","clamp"];class IF{constructor(A){pA(this,"plugins"),pA(this,"list"),pA(this,"viewport"),this.viewport=A,this.list=[],this.plugins={}}add(A,e,t=Nc.length){const i=this.plugins[A];i&&i.destroy(),this.plugins[A]=e;const r=Nc.indexOf(A);r!==-1&&Nc.splice(r,1),Nc.splice(t,0,A),this.sort()}get(A,e){var t;return e&&(t=this.plugins[A])!=null&&t.paused?null:this.plugins[A]}update(A){for(const e of this.list)e.update(A)}resize(){for(const A of this.list)A.resize()}reset(){for(const A of this.list)A.reset()}removeAll(){this.list.forEach(A=>{A.destroy()}),this.plugins={},this.sort()}remove(A){var e;this.plugins[A]&&((e=this.plugins[A])==null||e.destroy(),delete this.plugins[A],this.viewport.emit("plugin-remove",A),this.sort())}pause(A){var e;(e=this.plugins[A])==null||e.pause()}resume(A){var e;(e=this.plugins[A])==null||e.resume()}sort(){this.list=[];for(const A of Nc)this.plugins[A]&&this.list.push(this.plugins[A])}down(A){let e=!1;for(const t of this.list)t.down(A)&&(e=!0);return e}move(A){let e=!1;for(const t of this.viewport.plugins.list)t.move(A)&&(e=!0);return e}up(A){let e=!1;for(const t of this.list)t.up(A)&&(e=!0);return e}wheel(A){let e=!1;for(const t of this.list)t.wheel(A)&&(e=!0);return e}}const bF={screenWidth:window.innerWidth,screenHeight:window.innerHeight,worldWidth:null,worldHeight:null,threshold:5,passiveWheel:!0,stopPropagation:!1,forceHitArea:null,noTicker:!1,disableOnContextMenu:!1,ticker:Xt.shared,allowPreserveDragOutside:!1};class _F extends bi{constructor(A){super(),pA(this,"moving"),pA(this,"screenWidth"),pA(this,"screenHeight"),pA(this,"threshold"),pA(this,"input"),pA(this,"plugins"),pA(this,"zooming"),pA(this,"lastViewport"),pA(this,"options"),pA(this,"_dirty"),pA(this,"_forceHitArea"),pA(this,"_hitAreaDefault"),pA(this,"_pause"),pA(this,"tickerFunction"),pA(this,"_worldWidth"),pA(this,"_worldHeight"),pA(this,"_disableOnContextMenu",e=>e.preventDefault()),this.options={...bF,...A},this.screenWidth=this.options.screenWidth,this.screenHeight=this.options.screenHeight,this._worldWidth=this.options.worldWidth,this._worldHeight=this.options.worldHeight,this.forceHitArea=this.options.forceHitArea,this.threshold=this.options.threshold,this.options.disableOnContextMenu&&this.options.events.domElement.addEventListener("contextmenu",this._disableOnContextMenu),this.options.noTicker||(this.tickerFunction=()=>this.update(this.options.ticker.elapsedMS),this.options.ticker.add(this.tickerFunction)),this.input=new xF(this),this.plugins=new IF(this)}destroy(A){!this.options.noTicker&&this.tickerFunction&&this.options.ticker.remove(this.tickerFunction),this.options.disableOnContextMenu&&this.options.events.domElement.removeEventListener("contextmenu",this._disableOnContextMenu),this.input.destroy(),super.destroy(A)}update(A){this.pause||(this.plugins.update(A),this.lastViewport&&(this.lastViewport.x!==this.x||this.lastViewport.y!==this.y?this.moving=!0:this.moving&&(this.emit("moved-end",this),this.moving=!1),this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y?this.zooming=!0:this.zooming&&(this.emit("zoomed-end",this),this.zooming=!1)),this.forceHitArea||(this._hitAreaDefault=new ee(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight),this.hitArea=this._hitAreaDefault),this._dirty=this._dirty||!this.lastViewport||this.lastViewport.x!==this.x||this.lastViewport.y!==this.y||this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y,this.lastViewport={x:this.x,y:this.y,scaleX:this.scale.x,scaleY:this.scale.y},this.emit("frame-end",this))}resize(A=window.innerWidth,e=window.innerHeight,t,i){this.screenWidth=A,this.screenHeight=e,typeof t<"u"&&(this._worldWidth=t),typeof i<"u"&&(this._worldHeight=i),this.plugins.resize(),this.dirty=!0}get worldWidth(){return this._worldWidth?this._worldWidth:this.width/this.scale.x}set worldWidth(A){this._worldWidth=A,this.plugins.resize()}get worldHeight(){return this._worldHeight?this._worldHeight:this.height/this.scale.y}set worldHeight(A){this._worldHeight=A,this.plugins.resize()}getVisibleBounds(){return new ee(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight)}toWorld(A,e){return arguments.length===2?this.toLocal(new VA(A,e)):this.toLocal(A)}toScreen(A,e){return arguments.length===2?this.toGlobal(new VA(A,e)):this.toGlobal(A)}get worldScreenWidth(){return this.screenWidth/this.scale.x}get worldScreenHeight(){return this.screenHeight/this.scale.y}get screenWorldWidth(){return this.worldWidth*this.scale.x}get screenWorldHeight(){return this.worldHeight*this.scale.y}get center(){return new VA(this.worldScreenWidth/2-this.x/this.scale.x,this.worldScreenHeight/2-this.y/this.scale.y)}set center(A){this.moveCenter(A)}moveCenter(...A){let e,t;typeof A[0]=="number"?(e=A[0],t=A[1]):(e=A[0].x,t=A[0].y);const i=(this.worldScreenWidth/2-e)*this.scale.x,r=(this.worldScreenHeight/2-t)*this.scale.y;return(this.x!==i||this.y!==r)&&(this.position.set(i,r),this.plugins.reset(),this.dirty=!0),this}get corner(){return new VA(-this.x/this.scale.x,-this.y/this.scale.y)}set corner(A){this.moveCorner(A)}moveCorner(...A){let e,t;return A.length===1?(e=-A[0].x*this.scale.x,t=-A[0].y*this.scale.y):(e=-A[0]*this.scale.x,t=-A[1]*this.scale.y),(e!==this.x||t!==this.y)&&(this.position.set(e,t),this.plugins.reset(),this.dirty=!0),this}get screenWidthInWorldPixels(){return this.screenWidth/this.scale.x}get screenHeightInWorldPixels(){return this.screenHeight/this.scale.y}findFitWidth(A){return this.screenWidth/A}findFitHeight(A){return this.screenHeight/A}findFit(A,e){const t=this.screenWidth/A,i=this.screenHeight/e;return Math.min(t,i)}findCover(A,e){const t=this.screenWidth/A,i=this.screenHeight/e;return Math.max(t,i)}fitWidth(A=this.worldWidth,e,t=!0,i){let r;e&&(r=this.center),this.scale.x=this.screenWidth/A,t&&(this.scale.y=this.scale.x);const s=this.plugins.get("clamp-zoom",!0);return!i&&s&&s.clamp(),e&&r&&this.moveCenter(r),this}fitHeight(A=this.worldHeight,e,t=!0,i){let r;e&&(r=this.center),this.scale.y=this.screenHeight/A,t&&(this.scale.x=this.scale.y);const s=this.plugins.get("clamp-zoom",!0);return!i&&s&&s.clamp(),e&&r&&this.moveCenter(r),this}fitWorld(A){let e;A&&(e=this.center),this.scale.x=this.screenWidth/this.worldWidth,this.scale.y=this.screenHeight/this.worldHeight,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const t=this.plugins.get("clamp-zoom",!0);return t&&t.clamp(),A&&e&&this.moveCenter(e),this}fit(A,e=this.worldWidth,t=this.worldHeight){let i;A&&(i=this.center),this.scale.x=this.screenWidth/e,this.scale.y=this.screenHeight/t,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const r=this.plugins.get("clamp-zoom",!0);return r&&r.clamp(),A&&i&&this.moveCenter(i),this}setZoom(A,e){let t;e&&(t=this.center),this.scale.set(A);const i=this.plugins.get("clamp-zoom",!0);return i&&i.clamp(),e&&t&&this.moveCenter(t),this}zoomPercent(A,e){return this.setZoom(this.scale.x+this.scale.x*A,e)}zoom(A,e){return this.fitWidth(A+this.worldScreenWidth,e),this}get scaled(){return this.scale.x}set scaled(A){this.setZoom(A,!0)}snapZoom(A){return this.plugins.add("snap-zoom",new yF(this,A)),this}OOB(){return{left:this.left<0,right:this.right>this.worldWidth,top:this.top<0,bottom:this.bottom>this.worldHeight,cornerPoint:new VA(this.worldWidth*this.scale.x-this.screenWidth,this.worldHeight*this.scale.y-this.screenHeight)}}get right(){return-this.x/this.scale.x+this.worldScreenWidth}set right(A){this.x=-A*this.scale.x+this.screenWidth,this.plugins.reset()}get left(){return-this.x/this.scale.x}set left(A){this.x=-A*this.scale.x,this.plugins.reset()}get top(){return-this.y/this.scale.y}set top(A){this.y=-A*this.scale.y,this.plugins.reset()}get bottom(){return-this.y/this.scale.y+this.worldScreenHeight}set bottom(A){this.y=-A*this.scale.y+this.screenHeight,this.plugins.reset()}get dirty(){return!!this._dirty}set dirty(A){this._dirty=A}get forceHitArea(){return this._forceHitArea}set forceHitArea(A){A?(this._forceHitArea=A,this.hitArea=A):(this._forceHitArea=null,this.hitArea=new ee(0,0,this.worldWidth,this.worldHeight))}drag(A){return this.plugins.add("drag",new lF(this,A)),this}clamp(A){return this.plugins.add("clamp",new iF(this,A)),this}decelerate(A){return this.plugins.add("decelerate",new oF(this,A)),this}bounce(A){return this.plugins.add("bounce",new eF(this,A)),this}pinch(A){return this.plugins.add("pinch",new pF(this,A)),this}snap(A,e,t){return this.plugins.add("snap",new mF(this,A,e,t)),this}follow(A,e){return this.plugins.add("follow",new hF(this,A,e)),this}wheel(A){return this.plugins.add("wheel",new CF(this,A)),this}animate(A){return this.plugins.add("animate",new $K(this,A)),this}clampZoom(A){return this.plugins.add("clamp-zoom",new rF(this,A)),this}mouseEdges(A){return this.plugins.add("mouse-edges",new fF(this,A)),this}get pause(){return!!this._pause}set pause(A){this._pause=A,this.lastViewport=null,this.moving=!1,this.zooming=!1,A&&this.input.pause()}ensureVisible(A,e,t,i,r){r&&(t>this.worldScreenWidth||i>this.worldScreenHeight)&&(this.fit(!0,t,i),this.emit("zoomed",{viewport:this,type:"ensureVisible"}));let s=!1;A<this.left?(this.left=A,s=!0):A+t>this.right&&(this.right=A+t,s=!0),e<this.top?(this.top=e,s=!0):e+i>this.bottom&&(this.bottom=e+i,s=!0),s&&this.emit("moved",{viewport:this,type:"ensureVisible"})}}const SF="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAIrSURBVHic7dWhEcQwAAPBJEW4//bsJvzwg446YLcCkRvdc8598RljjNMTeHlOD4AvEwgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUC499779Aj+1lqnJ/DiQSAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIPwAhCgMRcz+Nz0AAAAASUVORK5CYII=";var MF=Object.defineProperty,PF=Object.getOwnPropertyDescriptor,$a=(n,A,e,t)=>{for(var i=t>1?void 0:t?PF(A,e):A,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=(t?s(A,e,i):s(i))||i);return t&&i&&MF(A,e,i),i};ue.Cropper=class extends Gr{constructor(){super(),this._domBoundingRect={x:0,y:0,width:0,height:0},this.app=new N2({backgroundAlpha:0,autoDensity:!0,resolution:2}),this.viewport=new _F({events:this.app.renderer.events,worldWidth:250,worldHeight:250}),this.imageSize={width:0,height:0},this.logoSize={width:0,height:0},this._imageUrl="",this._canvasScale=1,this.texture=new lt(this.app.view),this._timer=0,this._loading=!1,this.pathD="",this.getConfigs=()=>{const{screenWidth:A,screenHeight:e}=this.viewport;if(!this._sprite)return{canvasWidth:A,canvasHeight:e,scaleX:1,scaleY:1,ox:0,oy:0,x:0,y:0,url:this._imageUrl};const t=A/this._sprite.width,i=e/this._sprite.height,r=this.viewport.scale.x/t,s=this.viewport.scale.x/i,o=this._sprite.toGlobal(new uA(-this._sprite.width/2,-this._sprite.height/2)),a=-o.x/(this._sprite.width*this.viewport.scale.x),l=-o.y/(this._sprite.height*this.viewport.scale.y);return{canvasWidth:A,canvasHeight:e,scaleX:r,scaleY:s,ox:a,oy:l,x:this.viewport.position.x,y:this.viewport.position.y,url:this._imageUrl}},this._onChanged=async()=>{if(!this.imageSize.width||!this.imageSize.height||!this.app.view.toDataURL)return;const A=this.app.view.toDataURL("image/png",.75),e=this.app.renderer.gl,{screenWidth:t,screenHeight:i}=this.viewport;if(this._timer&&clearTimeout(this._timer),e){const r=this.app.renderer.width,s=this.app.renderer.height,o=new Uint8Array(r*s*4);e.readPixels(0,0,r,s,e.RGBA,e.UNSIGNED_BYTE,o);let a=r,l=0,u=s,c=0;for(let g=0;g<s;g++)for(let y=0;y<r;y++){const v=(g*r+y)*4;o[v+3]>0&&(a=Math.min(a,y),l=Math.max(l,y),u=Math.min(u,g),c=Math.max(c,g))}const h=this.app.renderer.view.getBoundingClientRect(),f={x:a,y:u,width:l-a+1,height:c-u+1};(a>l||u>c)&&console.log("没有非透明区域"),this.axiosX&&(this.axiosX.style.display="none"),this.axiosY&&(this.axiosY.style.display="none");const p=2,m=t/2,d=i/2;if(h){const g={x:f.x*(h.width/this.app.renderer.width),y:(this.app.renderer.height-f.y-f.height)*(h.height/this.app.renderer.height),width:f.width*(h.width/this.app.renderer.width),height:f.height*(h.height/this.app.renderer.height)};this._domBoundingRect=g,this.boundRect&&(this.boundRect.style.left=`${g.x}px`,this.boundRect.style.top=`${g.y}px`,this.boundRect.style.width=`${g.width}px`,this.boundRect.style.height=`${g.height}px`);const y=g.x+g.width/2,v=g.y+g.height/2,w=m-y,C=d-v;Math.abs(w)<p&&(this.viewport.position.x+=w,this.axiosY&&(this.axiosY.style.display="block")),Math.abs(C)<p&&(this.viewport.position.y+=C,this.axiosX&&(this.axiosX.style.display="block"))}else Math.abs(this.viewport.position.x-m)<p&&(this.viewport.position.x=m,this.axiosY&&(this.axiosY.style.display="block")),Math.abs(this.viewport.position.y-d)<p&&(this.viewport.position.y=d,this.axiosX&&(this.axiosX.style.display="block"));this._timer=window.setTimeout(()=>{this.axiosX&&(this.axiosX.style.display="none"),this.axiosY&&(this.axiosY.style.display="none")},600)}this.dispatchEvent(new CustomEvent("image-change",{detail:{image:A},bubbles:!0,composed:!0}))},this._wheelEvent=A=>{A.preventDefault()},this.updateConfigs=async({canvasWidth:A,x:e,y:t,scaleX:i,url:r})=>{var a;const{screenWidth:s}=this.viewport;this._canvasScale=s/A,await this.add(r,this.logoSize);const o=i*s/(((a=this._sprite)==null?void 0:a.width)||1);this.viewport.scale.set(o*this._canvasScale),this.viewport.position.set(e*this._canvasScale,t*this._canvasScale)},this.app.stage.addChild(this.viewport),this.viewport.drag({}).pinch().wheel().decelerate({friction:0,bounce:1}).on("zoomed-end",this._onChanged).on("moved-end",this._onChanged),this.app.view.addEventListener("wheel",this._wheelEvent,{passive:!1})}get supports(){return["png","jpg","jpeg","svg","webp"]}get loading(){return this._loading}get canvas(){return this.app.view}get imageScale(){if(!this._sprite)return{x:0,y:0};const{screenWidth:A,screenHeight:e}=this.viewport,t=this.viewport.scale.x,i=this._sprite.width*t/2,r=this._sprite.height*t/2,s=this._domBoundingRect.width/i*(i/A),o=this._domBoundingRect.height/r*(r/e);return{x:s,y:o}}get imageRealSize(){const{x:A,y:e}=this.imageScale;let{width:t,height:i}=this.logoSize;const r=Math.max(t,i);return t=r*A,i=r*e,{width:t,height:i}}resize(A,e){this.app.renderer.resize(A,e),this.viewport.resize(A,e)}firstUpdated(A){var e;super.firstUpdated(A),this.container&&((e=this.container)==null||e.append(this.app.view),this.app.resizeTo=this.container)}setUV(A){const{screenWidth:e,screenHeight:t}=this.viewport,i=A.attributes.uv,r=A.index;if(!r){this.pathD="";return}let s=[];for(let a=0;a<r.count;a+=3){const l=r.getX(a),u=r.getX(a+1),c=r.getX(a+2),h=[i.getX(l)*e,i.getY(l)*t],f=[i.getX(u)*e,i.getY(u)*t],p=[i.getX(c)*e,i.getY(c)*t];s.push(h,f,p)}let o="";s.forEach((a,l)=>{l%3===0?o+=`M${a[0]},${a[1]} `:o+=`L${a[0]},${a[1]} `,l%3===2&&(o+="Z ")}),s=[],this.pathD=o}async add(A,e){this.clear(),this._imageUrl=A,this.logoSize=e,this._loading=!0;const t=await GA.fromURL(A);this._sprite=new js(t),this.viewport.addChild(this._sprite),this.imageSize.width=this._sprite.texture.width,this.imageSize.height=this._sprite.texture.height,this.fit(),this._loading=!1}clear(){var A,e;(A=this._sprite)==null||A.texture.destroy(!0),(e=this._sprite)==null||e.removeFromParent(),this.boundRect&&(this.boundRect.style.left="0px",this.boundRect.style.top="0px",this.boundRect.style.width="0px",this.boundRect.style.height="0px")}fit(){if(!this._sprite)return;this.viewport.scale.set(1,1),this._sprite.anchor.set(.5,.5),this.viewport.moveCenter(this._sprite.position.x,this._sprite.position.y);const A=this.viewport.screenWidth,e=this.viewport.screenHeight,t=this._sprite.width/A,i=this._sprite.height/e,r=Math.max(t,i);this.viewport.scale.set(1/r,1/r)}disconnectedCallback(){super.disconnectedCallback(),this.clear(),this.viewport.destroy({children:!0,texture:!0,baseTexture:!0}),this.viewport.off("zoomed"),this.viewport.off("moved"),this.viewport.off("moved-end"),this.app.view.removeEventListener("wheel",this._wheelEvent),this.app.destroy(!0)}render(){const{screenWidth:A,screenHeight:e}=this.viewport;return $i`
9868
9868
  <div class="cropper-container">
9869
9869
  <div class="rect"></div>
9870
9870
  <div class="axios-x"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shop-components",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "description": "Shop components",
5
5
  "main": "dist/shop-components.umd.js",
6
6
  "module": "dist/shop-components.mjs",