L.Control.Fullscreen=L.Control.extend({options:{position:"topleft",title:{false:"View Fullscreen",true:"Exit Fullscreen"}},onAdd:function(e){var l=L.DomUtil.create("div","leaflet-control-fullscreen leaflet-bar leaflet-control");return this.link=L.DomUtil.create("a","leaflet-control-fullscreen-button leaflet-bar-part",l),this.link.href="#",this._map=e,this._map.on("fullscreenchange",this._toggleTitle,this),this._toggleTitle(),L.DomEvent.on(this.link,"click",this._click,this),l},_click:function(e){L.DomEvent.stopPropagation(e),L.DomEvent.preventDefault(e),this._map.toggleFullscreen(this.options)},_toggleTitle:function(){this.link.title=this.options.title[this._map.isFullscreen()]}}),L.Map.include({isFullscreen:function(){return this._isFullscreen||!1},toggleFullscreen:function(e){var l=this.getContainer();this.isFullscreen()?e&&e.pseudoFullscreen?this._disablePseudoFullscreen(l):document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msExitFullscreen?document.msExitFullscreen():this._disablePseudoFullscreen(l):e&&e.pseudoFullscreen?this._enablePseudoFullscreen(l):l.requestFullscreen?l.requestFullscreen():l.mozRequestFullScreen?l.mozRequestFullScreen():l.webkitRequestFullscreen?l.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT):l.msRequestFullscreen?l.msRequestFullscreen():this._enablePseudoFullscreen(l)},_enablePseudoFullscreen:function(e){L.DomUtil.addClass(e,"leaflet-pseudo-fullscreen"),this._setFullscreen(!0),this.fire("fullscreenchange")},_disablePseudoFullscreen:function(e){L.DomUtil.removeClass(e,"leaflet-pseudo-fullscreen"),this._setFullscreen(!1),this.fire("fullscreenchange")},_setFullscreen:function(e){this._isFullscreen=e;var l=this.getContainer();e?L.DomUtil.addClass(l,"leaflet-fullscreen-on"):L.DomUtil.removeClass(l,"leaflet-fullscreen-on"),this.invalidateSize()},_onFullscreenChange:function(e){var l=document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement;l!==this.getContainer()||this._isFullscreen?l!==this.getContainer()&&this._isFullscreen&&(this._setFullscreen(!1),this.fire("fullscreenchange")):(this._setFullscreen(!0),this.fire("fullscreenchange"))}}),L.Map.mergeOptions({fullscreenControl:!1}),L.Map.addInitHook((function(){var e;if(this.options.fullscreenControl&&(this.fullscreenControl=new L.Control.Fullscreen(this.options.fullscreenControl),this.addControl(this.fullscreenControl)),"onfullscreenchange"in document?e="fullscreenchange":"onmozfullscreenchange"in document?e="mozfullscreenchange":"onwebkitfullscreenchange"in document?e="webkitfullscreenchange":"onmsfullscreenchange"in document&&(e="MSFullscreenChange"),e){var l=L.bind(this._onFullscreenChange,this);this.whenReady((function(){L.DomEvent.on(document,e,l)})),this.on("unload",(function(){L.DomEvent.off(document,e,l)}))}})),L.control.fullscreen=function(e){return new L.Control.Fullscreen(e)};