YGG.MiniMap=function(t){let e,a=this,n=20,i=new Image,s=new Image,o=new Image,h=0,l=0,r=0,f=0,c=0,g=1,u=0,d=0,m=0,p=0,M=10/n,w=.12,_=1.2,E=t.getContext("2d"),v=-1,R=t.width/2,L=t.height/2,Y=!1,b=function(t){},X=0;function x(t){if(null==t||null==t||9!=t.length)return null;let e={mall_folder:"zones",zone_id:"",shop_id:""},a=t[0].toLowerCase(),n="z";0==a.localeCompare("v")?(n="f",e.mall_folder="virtual_mall"):0==a.localeCompare("e")&&(e.mall_folder="exhibition");let i=parseInt(t[2]);return isNaN(i)?e.zone_id=n+"000"+t[2].toLowerCase():e.zone_id=n+"00"+t.substring(1,3),e.shop_id="s0"+t.substring(6,9),e}function O(){let e=-i.naturalWidth/2+t.width/2+r,a=-i.naturalHeight/2+t.height/2+f,n=i.naturalWidth/2-t.width/2+r,s=i.naturalHeight/2-t.height/2+f;if(1==X)u=Math.min(Math.max(u,e),n),d=Math.min(Math.max(d,a),s);else{let t=e*Math.cos(c)+a*Math.sin(c),i=e*Math.sin(c)+a*Math.cos(c),o=e*Math.cos(c)+s*Math.sin(c),h=e*Math.sin(c)+s*Math.cos(c),l=n*Math.cos(c)+a*Math.sin(c),r=n*Math.sin(c)+a*Math.cos(c),f=n*Math.cos(c)+s*Math.sin(c),g=n*Math.sin(c)+s*Math.cos(c);u=Math.min(Math.max(u,Math.min(t,o,l,f)),Math.max(t,o,l,f)),d=Math.min(Math.max(d,Math.min(i,h,r,g)),Math.max(i,h,r,g))}}function H(t){const e=t.getBoundingClientRect();return{left:e.left+window.scrollX,top:e.top+window.scrollY}}function I(t){var e=Math.pow(1.1,t);M*=e;let a=!1,n=!1;M<=w?(a=!0,n=!1,M=w):M>=_&&(a=!1,n=!0,M=_),b({min:a,max:n}),T()}function T(){switch(t.width=t.offsetWidth,t.height=t.offsetHeight,E.clearRect(-2e3,-2e3,4e3,4e3),X){case 1:E.translate(t.width/2,t.height/2),E.scale(M,M),E.translate(u,d),E.translate(-r+h,-f+l),E.imageSmoothingEnabled=!0,E.drawImage(i,-i.naturalWidth/2,-i.naturalHeight/2,i.naturalWidth,i.naturalHeight),E.translate(r-h,f-l),E.translate(-u,-d),E.scale(1/M,1/M),E.translate(-t.width/2,-t.height/2),E.translate(t.width/2,t.height/2),E.scale(M,M),E.translate(u,d),E.rotate(-c-p),E.scale(g,g),E.imageSmoothingEnabled=!0,E.drawImage(s,0,0,s.naturalWidth,s.naturalHeight,-2*n,-2.53125*n,4*n,4*n),E.scale(1/g,1/g),E.rotate(c+p),E.translate(-u,-d),E.scale(1/M,1/M),E.translate(-t.width/2,-t.height/2);break;default:E.translate(t.width/2,t.height/2),E.scale(M,M),E.translate(u,d),E.rotate(c),E.translate(-r+h,-f+l),E.imageSmoothingEnabled=!0,E.drawImage(i,-i.naturalWidth/2,-i.naturalHeight/2,i.naturalWidth,i.naturalHeight),E.translate(r-h,f-l),E.rotate(-c),E.translate(-u,-d),E.scale(1/M,1/M),E.translate(-t.width/2,-t.height/2),E.translate(t.width/2,t.height/2),E.scale(M,M),E.translate(u,d),E.scale(g,g),E.imageSmoothingEnabled=!0,E.drawImage(s,0,0,s.naturalWidth,s.naturalHeight,-2*n,-2.53125*n,4*n,4*n),E.scale(1/g,1/g),E.translate(-u,-d),E.scale(1/M,1/M),E.translate(-t.width/2,-t.height/2),E.translate(24,t.height-24),E.rotate(c+p),E.drawImage(o,0,0,o.naturalWidth,o.naturalHeight,-18,-18,36,36),E.rotate(-c-p),E.translate(-24,t.height+24)}}t.addEventListener("contextmenu",t=>(t.preventDefault(),!1)),i.onload=function(){T()},i.onerror=function(){i.src=RESOURCE_PATH+"image/UI/minimap_close.png"},s.src=RESOURCE_PATH+"image/UI/minimap_user.png",o.src=RESOURCE_PATH+"image/UI/minimap_compass.png",t.addEventListener("mousedown",(function(a){if(a.preventDefault(),v<0)switch(a.button){case 0:R=a.offsetX||a.pageX-t.offsetLeft,L=a.offsetY||a.pageY-t.offsetTop,e=!0,dragged=!1,v=0;break;case 2:R=a.offsetX||a.pageX-t.offsetLeft,L=a.offsetY||a.pageY-t.offsetTop,e=!0,dragged=!1,v=2;break}}),!1),t.addEventListener("mousemove",(function(a){if(a.preventDefault(),e){switch(v){case 0:{dragged=!0;let e=(R-(a.offsetX||a.pageX-t.offsetLeft))/M,n=(L-(a.offsetY||a.pageY-t.offsetTop))/M,i=Math.cos(m)*e-Math.sin(m)*n,s=Math.sin(m)*e+Math.cos(m)*n;u-=i,d-=s,R=a.offsetX||a.pageX-t.offsetLeft,L=a.offsetY||a.pageY-t.offsetTop}break;case 2:{dragged=!0;let e=(R-(a.offsetX||a.pageX-t.offsetLeft))/M,n=(L-(a.offsetY||a.pageY-t.offsetTop))/M,i=Math.cos(m)*e-Math.sin(m)*n,s=Math.sin(m)*e+Math.cos(m)*n;u-=i,d-=s,R=a.offsetX||a.pageX-t.offsetLeft,L=a.offsetY||a.pageY-t.offsetTop}break}O(),T()}}),!1),t.addEventListener("mouseup",(function(t){t.preventDefault(),T(),e=!1,dragged=!1,t.button==v&&(v=-1)}),!1),t.addEventListener("mousewheel",(function(t){var e=t.wheelDelta?t.wheelDelta/40:t.detail?-t.detail:0;e&&I(e);return t.preventDefault()&&!1}),!1),t.addEventListener("mouseleave",(function(t){}),!1),t.addEventListener("touchstart",(function(a){switch(a.preventDefault(),a.touches.length){case 1:{let n=H(t),i=a.touches[0].pageX-t.width/2-n.left,s=a.touches[0].pageY-t.height/2-n.top;startAngle=Math.atan2(s,i),R=i,L=s,e=!0,dragged=!1,v=0}break;case 2:{let n=H(t),i=(a.touches[0].pageX+a.touches[1].pageX)/2-t.width/2-n.left,s=(a.touches[0].pageY+a.touches[1].pageY)/2-t.height/2-n.top;R=i,L=s,e=!0,dragged=!1,v=2}break}}),!1),t.addEventListener("touchend",(function(t){t.preventDefault(),0==t.touches.length&&(T(),e=!1,dragged=!1,t.button==v&&(v=-1))}),!1),t.addEventListener("touchmove",(function(a){if(a.preventDefault(),e){switch(a.touches.length){case 1:{dragged=!0;let e=H(t),n=a.touches[0].pageX-t.width/2-e.left,i=a.touches[0].pageY-t.height/2-e.top,s=(R-n)/M,o=(L-i)/M,h=Math.cos(m)*s-Math.sin(m)*o,l=Math.sin(m)*s+Math.cos(m)*o;u-=h,d-=l,R=n,L=i}break;case 2:{dragged=!0;let e=H(t),n=(a.touches[0].pageX+a.touches[1].pageX)/2-t.width/2-e.left,i=(a.touches[0].pageY+a.touches[1].pageY)/2-t.height/2-e.top,s=(R-n)/M,o=(L-i)/M,h=Math.cos(m)*s-Math.sin(m)*o,l=Math.sin(m)*s+Math.cos(m)*o;u-=h,d-=l,R=n,L=i}break}O(),T()}}),!1),this.setIsShow=function(t){Y=t},this.isShow=function(){return Y},this.reset=function(){u=0,d=0,m=0,r=0,f=0,c=0,M=10/n,T()},this.setImage=function(t,e){let a=x(t);null!=a&&(null!=e&&null!=e&&e.length>0?i.src=RESOURCE_VR_ROOTPATH+a.mall_folder+"/"+a.zone_id+"/"+a.zone_id+"_minimap"+e:i.src=RESOURCE_VR_ROOTPATH+a.mall_folder+"/"+a.zone_id+"/"+a.zone_id+"_minimap.png")},this.setImageShop=function(t){let e=x(t);null!=e&&(null!=fileExtensions&&null!=fileExtensions&&fileExtensions.length>0?i.src=RESOURCE_VR_ROOTPATH+e.mall_folder+"/"+e.zone_id+"/shops/"+e.shop_id+"/"+e.zone_id+"_minimap"+fileExtensions:i.src=RESOURCE_VR_ROOTPATH+e.mall_folder+"/"+e.zone_id+"/shops/"+e.shop_id+"/"+e.shop_id+"_minimap.png")},this.setUserScale=function(t){g=t},this.setOnZoomLimited=function(t){b=t},this.setMinZoomLimit=function(t){w=t,I(0)},this.setMaxZoomLimit=function(t){_=t,I(0)},this.setZoomLimit=function(t,e){a.setMinZoomLimit(t),a.setMaxZoomLimit(e)},this.setPixelPerMeter=function(t){n=t,M=10/n},this.setImageOffset=function(t,e){h=t,l=e},this.setRenderMode=function(t){X=t},this.updateUser=function(t){r=t.x*n,f=t.y*n,c=t.angle,t.alpha<=0||(t.alpha>=1?(u=0,d=0):(u*=1-t.alpha,d*=1-t.alpha)),p=t.north,T()},this.zoomIn=function(){I(2)},this.zoomOut=function(){I(-2)},this.resizeCanvas=function(){T()},this.draw=function(){T()}};