Ext.namespace("Zarafa.plugins.maps"),Zarafa.plugins.maps.MapsPlugin=Ext.extend(Zarafa.core.Plugin,{initPlugin:function(){Zarafa.plugins.maps.MapsPlugin.superclass.initPlugin.apply(this,arguments),this.registerInsertionPoint("context.contact.contactcontentpanel.tabs",this.showContactLocation,this),this.registerInsertionPoint("context.addressbook.abuserdetailcontentpanel.tabs",this.showABUserLocation,this)},showContactLocation:function(){return{xtype:"maps.contactmapstab",itemId:"contact"}},showABUserLocation:function(){return{xtype:"maps.contactmapstab",itemId:"abuser"}}}),Zarafa.onReady((function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"maps",displayName:_("Openstreetmap"),pluginConstructor:Zarafa.plugins.maps.MapsPlugin}))})),Ext.namespace("Zarafa.plugins.maps"),Zarafa.plugins.maps.MapsTab=Ext.extend(Ext.Panel,{map:void 0,provider:null,mapID:0,constructor:function(t){(t=t||{}).plugins=Ext.value(t.plugins,[]),t.plugins.push("zarafa.recordcomponentupdaterplugin"),this.mapID=(new Date).getUTCMilliseconds(),Ext.apply(t,{id:"map"+this.mapID,xtype:"container",title:_("Map"),cls:"map"+this.mapID,listeners:{resize:this.resizeMap,scope:this}}),Zarafa.plugins.maps.MapsTab.superclass.constructor.call(this,t)},onRender:function(...t){Zarafa.plugins.maps.MapsTab.superclass.onRender.apply(this,arguments),this.map=this.createGmap(),this.provider=new GeoSearch.OpenStreetMapProvider},createGmap:function(t){const a=L.map("map"+this.mapID).setView([48.23185800542299,16.412903051527447],13);return L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}).addTo(a),a},resizeMap:function(){this.map&&this.map.invalidateSize()},update:function(t,a){if(t&&t.isOpened())switch(this.itemId){case"contact":if(a||t.isModifiedSinceLastUpdate("home_address")||t.isModifiedSinceLastUpdate("business_address")||t.isModifiedSinceLastUpdate("other_address")){var s=t.get("home_address");Ext.isEmpty(s.trim())||this.showOnMap(s,_("Home Address"));var e=t.get("business_address");Ext.isEmpty(e.trim())||this.showOnMap(e,_("Business Address"));var i=t.get("other_address");Ext.isEmpty(i.trim())||this.showOnMap(i,_("Other Address"))}break;case"abuser":if(a){var n=t.get("street_address")+" "+t.get("state_or_province")+" "+t.get("locality")+" "+t.get("postal_code")+" "+t.get("country");Ext.isEmpty(n.trim())||this.showOnMap(n,_("Address"))}}},showOnMap:async function(t,a){if(this.map&&this.provider){const s=await this.provider.search({query:t})||[];if(s.length>0){const t=[s[0].y,s[0].x];L.marker(t,{title:a}).addTo(this.map).bindPopup(a),this.map.setView(t,6)}}}}),Ext.reg("maps.contactmapstab",Zarafa.plugins.maps.MapsTab);
//# sourceMappingURL=maps.js.map