"use strict";var Minimap=function(i,e){var a=this;this.underlyingMapGui=new MapGui(this),this.$minimap_elem=$('<div id="mapDiv" class="onscreenGui onscreenGuiElement minimap"></div>'),i.append(this.$minimap_elem),gui.disablePickingCaptionWhenMouseOver(this.$minimap_elem),this.$minimapTwin_elem=$('<div class="'+this.$minimap_elem.attr("class")+'"></div>'),gui.disablePickingCaptionWhenMouseOver(this.$minimapTwin_elem),this.$minimapTwin_elem.click(function(i){}),i.append(this.$minimapTwin_elem),this.$areaCaption_elem=$('<div id="areaCaption" class="fontOutline"></div>'),this.$areaCaptionInfoAbove_elem=$('<div id="areaCaptionInfoAbove" class="areaCaption areaCaptionInfoAbove fontOutline" langcaption="GUI_AREA_CAPTION_INFO"></div>'),this.$areaCaptions=$('<div class="areaCaptions"></div>'),this.$areaCaptions.append(this.$areaCaptionInfoAbove_elem),this.$areaCaptions.append(this.$areaCaption_elem),Preferences.Browser.EDGE&&this.$areaCaptions.hide(),this.$minimapTwin_elem.append(this.$areaCaptions),this.hide(),this.currentArea=null,this.areaMapImage=assetLoader.loadImageRawData(Preferences.Map.AREA_MAP_FILENAME,this,"areaMapImage"),this.areaIdToNameMap={},this.areaNameToOrigColorToIdMap={};var n=assetLoader.makeDummyJob("area map SVG dom loading",!0,function(){});Gui.loadSvg("areaImage",Preferences.Map.AREA_MAP_FILENAME,function(i){var e=i.svgWrapper;e.find('[id^="'+Preferences.Prefixes.SVG_AREA_MAP_LOCATION+'"]').each(function(){var i=$(this),e=Util.cutPrefixFromString(i.attr("id"),Preferences.Prefixes.SVG_AREA_MAP_LOCATION),n=Util.parseRGB(i.css("fill"),!0),t=renderer.colorId(n);a.areaIdToNameMap[t]=e}),a.areaIdToNameMap[0]=null},null,n),e.waitForFinish(n);var t=assetLoader.makeDummyJob("minimap creation",!0,function(){}),r=assetLoader.makeExternalLoadingJob("minimap image load");t.waitFor(r),this.$minimapImage_elem=$('<div id="map" class="minimap-image minimapImage"></div>'),this.$minimap_elem.append($('<div class="minimapImageBackground"></div>')),this.$minimap_elem.append(this.$minimapImage_elem);var o=assetLoader.makeExternalLoadingJob("minimap vision cone image load");t.waitFor(o),this.$mapVisionCone_elem=$('<img class="mapVisionCone" src="data/gui/map_view.svg" />').on("load",function(){o.startJob()});var m=assetLoader.makeExternalLoadingJob("marker image load");t.waitFor(m),this.$minimap_elem.append(this.$mapVisionCone_elem),t.startJob()};Minimap.prototype._resizeCallback=function(){this.underlyingMapGui._resizeCallback()},Minimap.prototype.show=function(){this.$minimap_elem.show(),this.$minimapTwin_elem.show()},Minimap.prototype.hide=function(){this.$minimap_elem.hide(),this.$minimapTwin_elem.hide()},Minimap.prototype.zoomIn=function(){this.underlyingMapGui.zoomIn()},Minimap.prototype.zoomOut=function(){this.underlyingMapGui.zoomOut()},Minimap.prototype.findAreaAt2dCoordinatesInMap=function(i,e){var a=renderer.colorId(Renderer.readPixelColor(this.areaMapImage,heightmapWorld.map.width,heightmapWorld.map.height,i,e));return this.areaIdToNameMap[a]},Minimap.prototype.findAreaCaption=function(i){if(i.computeHeightmapCoordinates(),!Preferences.Browser.EDGE){var e=this.findAreaAt2dCoordinatesInMap(i.heightmapCoord.x,i.heightmapCoord.y);e!==this.currentArea&&Util.isPropertyDefined(e)&&(this.currentArea=e,this.updateAreaCaption())}},Minimap.prototype.updateAreaCaption=function(){this.$areaCaption_elem.text(ContentLibrary.getContentString(this.currentArea?this.currentArea:"OUTSIDE"))},Minimap.prototype.updateMinimap=function(i){var e=(this.underlyingMapGui.computeCoordinatesInMapImage(i,!0),appMain.getCurrentEntity().camera),a=e.getPosition(),n="";n+=-a.x/396.4980774*50+"%",n+=",",n+=-a.z/204.1816254*50+"%",this.$minimapImage_elem[0].style.transform="translate("+n+")";var t=-i.camera.angleHorizontal+Preferences.Map.MAP_HORIZONTAL_ANGLE_SYNC_VALUE;t=Preferences.Math.RAD_TO_DEG_CONVERSION*t,this.$mapVisionCone_elem[0].style.transform="rotate("+t+"deg)",this.findAreaCaption(i)},Minimap.prototype.getUnderlyingMap=function(){return this.underlyingMapGui.underlyingMap};