!function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};__webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=1)}([function(module,exports,__webpack_require__){"use strict";var namespace=function(_namespace){return function(target){var namespaceArray=_namespace.split("."),mainPath=namespaceArray[0];window[mainPath]||(window[mainPath]={}),function constructObject(namespaceArray,obj){if(namespaceArray.length>0){var name=namespaceArray[0];obj[name]||(obj[name]={}),constructObject(namespaceArray.splice(1),obj[name])}else obj[target.name]=target;return obj}(namespaceArray.splice(1),window[mainPath])}};module.exports=namespace},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var _dec,_class,_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_decorator=__webpack_require__(0),_decorator2=_interopRequireDefault(_decorator),_addservicesControl=__webpack_require__(2),_addservices=(_interopRequireDefault(_addservicesControl),__webpack_require__(4));_interopRequireDefault(_addservices),(_dec=(0,_decorator2.default)("M.plugin"))(_class=function(_M$Plugin){function AddServices(){_classCallCheck(this,AddServices);var _this=_possibleConstructorReturn(this,(AddServices.__proto__||Object.getPrototypeOf(AddServices)).call(this));return _this.map_=null,_this.controls_=[],_this.panel_=null,_this}return _inherits(AddServices,_M$Plugin),_createClass(AddServices,null,[{key:"NAME",get:function(){return"addservices"}}]),_createClass(AddServices,[{key:"addTo",value:function(map){var _this2=this,control=new M.control.AddServicesControl;control.on(M.evt.ADDED_TO_MAP,function(){_this2.fire(M.evt.ADDED_TO_MAP)}),this.controls_.push(control),this.map_=map,this.panel_=new M.ui.Panel(M.plugin.AddServices.NAME,{collapsible:!0,className:"m-addservices",collapsedButtonClass:"g-cartografia-capas",position:M.ui.position.TR,tooltip:"Cargar WMS"}),this.panel_.addControls(this.controls_),map.addPanels(this.panel_)}},{key:"destroy",value:function(){this.map_.removeControls(this.controls_),this.map_=null,this.controls_=null,this.panel_=null,this.name=null}}]),AddServices}(M.Plugin))},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AddServicesControl=void 0;var _dec,_class,_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_decorator=__webpack_require__(0),_decorator2=_interopRequireDefault(_decorator),_addservicesControl=__webpack_require__(3);_interopRequireDefault(_addservicesControl),exports.AddServicesControl=(_dec=(0,_decorator2.default)("M.control"))(_class=function(_M$Control){function AddServicesControl(){_classCallCheck(this,AddServicesControl),M.utils.isUndefined(M.impl.control.AddServicesControl)&&M.exception("La implementación usada no puede crear controles PluginControl");var impl=new M.impl.control.AddServicesControl,_this=_possibleConstructorReturn(this,(AddServicesControl.__proto__||Object.getPrototypeOf(AddServicesControl)).call(this,impl,M.plugin.AddServices.NAME));return _this.urlService_=null,_this.btnAddUrl_=null,_this.btnClear_=null,_this.facadeMap_=null,_this.containerAddservices_=null,_this.containerSearching_=null,_this.containerResults_=null,_this.containerSearch_=null,_this.capabilities_=null,_this.stateSelectAll_=!1,_this}return _inherits(AddServicesControl,_M$Control),_createClass(AddServicesControl,[{key:"addEvents",value:function(html){var _this2=this;this.urlService_=html.getElementsByTagName("input")["m-addservices-search-input"],this.btnAddUrl_=html.getElementsByTagName("button")["m-addservices-search-btn"],this.btnClear_=html.getElementsByTagName("button")["m-addservices-clear-btn"],this.containerAddservices_=html,this.containerSearching_=html.getElementsByTagName("div")["m-searching-result-addservices"],this.containerResults_=html.getElementsByTagName("div")["m-addservices-results"],this.containerSearch_=html.getElementsByTagName("div")["m-addservices-search"],this.btnAddUrl_.addEventListener("click",function(evt){return _this2.readCapabilities_(evt)}),this.btnClear_.addEventListener("click",function(evt){return _this2.removeContains_(evt)})}},{key:"createView",value:function(map){var _this3=this;return this.facadeMap_=map,new Promise(function(success,fail){M.template.compile("addservices.html").then(function(html){_this3.addEvents(html),success(html)})})}},{key:"readCapabilities_",value:function(evt){var _this4=this;evt.preventDefault(),M.utils.isNullOrEmpty(this.urlService_.value)?M.dialog.error("Los campos están vacíos."):M.utils.isUrl(this.urlService_.value)?(this.containerAddservices_.classList.add("m-searching"),M.remote.get(M.utils.getWMSGetCapabilitiesUrl(this.urlService_.value)).then(function(response){try{var getCapabilitiesParser=new M.impl.format.WMSCapabilities,getCapabilities=getCapabilitiesParser.read(response.xml),getCapabilitiesUtils=new M.impl.GetCapabilities(getCapabilities,_this4.urlService_.value,_this4.facadeMap_.getProjection().code);_this4.capabilities_=getCapabilitiesUtils.getLayers(),_this4.showResults_()}catch(err){M.dialog.error("Ha ocurrido un error al obtener el documento GetCapabilities.")}_this4.containerAddservices_.classList.remove("m-searching")})):M.dialog.error("Debes indicar una URL válida.")}},{key:"showResults_",value:function(){var _this5=this,result=[];this.capabilities_.forEach(function(capability){result.push(capability.getImpl())}),M.template.compile("addservices_results.html",{vars:{result:result}}).then(function(html){_this5.containerResults_.innerHTML=html.innerHTML,M.utils.enableTouchScroll(_this5.containerResults_);for(var results=_this5.containerResults_.getElementsByTagName("span"),i=0,ilen=results.length;i<ilen;i++)results[i].addEventListener("click",function(evt){return _this5.registerCheck_(evt)});_this5.containerResults_.getElementsByTagName("th")["m-addservices-selectall"].addEventListener("click",function(evt){return _this5.registerCheck_(evt)}),_this5.containerResults_.getElementsByClassName("m-addservices-add")[0].addEventListener("click",function(evt){return _this5.addLayers_(evt)})})}},{key:"registerCheck_",value:function(evt){evt=evt||window.event,!M.utils.isNullOrEmpty(evt.target)&&evt.target.classList.contains("m-check-addservices")?(evt.stopPropagation(),evt.target.classList.toggle("g-cartografia-check2"),evt.target.classList.toggle("g-cartografia-check3"),this.containerResults_.querySelectorAll(".g-cartografia-check3").length?this.containerResults_.querySelectorAll(".g-cartografia-check2").length||(this.stateSelectAll_=!0):this.stateSelectAll_=!1):M.utils.isNullOrEmpty(evt.target)||"m-addservices-selectall"!==evt.target.id||(this.stateSelectAll_?(this.unSelect_(),this.stateSelectAll_=!1):(this.select_(),this.stateSelectAll_=!0))}},{key:"unSelect_",value:function(){for(var unSelect=this.containerResults_.querySelectorAll(".g-cartografia-check3"),i=0;i<unSelect.length;i++)unSelect[i].classList.remove("g-cartografia-check3"),unSelect[i].classList.add("g-cartografia-check2")}},{key:"select_",value:function(){for(var select=this.containerResults_.querySelectorAll(".g-cartografia-check2"),i=0;i<select.length;i++)select[i].classList.remove("g-cartografia-check2"),select[i].classList.add("g-cartografia-check3")}},{key:"addLayers_",value:function(evt){evt.preventDefault();var layers=[],elmSel=this.containerResults_.querySelectorAll(".g-cartografia-check3");if(0===elmSel.length)M.dialog.error("Debes seleccionar al menos una capa.");else{for(var i=0,ilen=elmSel.length;i<ilen;i++)for(var j=0,ilen2=this.capabilities_.length;j<ilen2;j++)elmSel[i].id===this.capabilities_[j].legend&&(this.capabilities_[j].options.origen="WMS",layers.push(this.capabilities_[j]));this.facadeMap_.addLayers(layers)}}},{key:"removeContains_",value:function(evt){evt.preventDefault(),this.containerResults_.innerHTML="",this.urlService_.value=""}},{key:"equals",value:function(obj){var equals=!1;return obj instanceof AddServicesControl&&(equals=this.name===obj.name),equals}},{key:"getActivationButton",value:function(html){return html.querySelector("button#m-addservicescontrol-button")}}]),AddServicesControl}(M.Control))||_class},function(module,exports,__webpack_require__){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AddServicesControl=void 0;var _dec,_class,_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_get=function get(object,property,receiver){null===object&&(object=Function.prototype);var desc=Object.getOwnPropertyDescriptor(object,property);if(void 0===desc){var parent=Object.getPrototypeOf(object);return null===parent?void 0:get(parent,property,receiver)}if("value"in desc)return desc.value;var getter=desc.get;if(void 0!==getter)return getter.call(receiver)},_decorator=__webpack_require__(0),_decorator2=function(obj){return obj&&obj.__esModule?obj:{default:obj}}(_decorator);exports.AddServicesControl=(_dec=(0,_decorator2.default)("M.impl.control"))(_class=function(_M$impl$Control){function AddServicesControl(){_classCallCheck(this,AddServicesControl);var _this=_possibleConstructorReturn(this,(AddServicesControl.__proto__||Object.getPrototypeOf(AddServicesControl)).call(this));return _this.facadeMap_=null,_this}return _inherits(AddServicesControl,_M$impl$Control),_createClass(AddServicesControl,[{key:"addTo",value:function(map,html){this.facadeMap_=map,_get(AddServicesControl.prototype.__proto__||Object.getPrototypeOf(AddServicesControl.prototype),"addTo",this).call(this,map,html)}},{key:"activate",value:function(){M.dialog.info("Hello World!")}},{key:"deactivate",value:function(){M.dialog.info("Bye World!")}},{key:"destroy",value:function(){this.facadeMap_.getMapImpl().removeControl(this)}}]),AddServicesControl}(M.impl.Control))||_class},function(module,exports){}]),M.template.add("addservices_results.html",Handlebars.template({1:function(container,depth0,helpers,partials,data){var helper,alias1=null!=depth0?depth0:container.nullContext||{},alias2=helpers.helperMissing,alias4=container.escapeExpression;return"                <tr>\r\n                    <td>"+alias4((helper=null!=(helper=helpers.name||(null!=depth0?depth0.name:depth0))?helper:alias2,"function"==typeof helper?helper.call(alias1,{name:"name",hash:{},data:data}):helper))+"</td>\r\n                    <td><span id="+alias4((helper=null!=(helper=helpers.name||(null!=depth0?depth0.name:depth0))?helper:alias2,"function"==typeof helper?helper.call(alias1,{name:"name",hash:{},data:data}):helper))+' class="m-check-addservices g-cartografia-check2"></span></td>\r\n                </tr>\r\n'},compiler:[7,">= 4.0.0"],main:function(container,depth0,helpers,partials,data){var stack1;return'<div class="results-panels">\r\n    <div class="table-results">\r\n        <table>\r\n            <thead>\r\n                <tr>\r\n                    <th>Capa</th>\r\n                    <th id="m-addservices-selectall">Seleccionar todas</th>\r\n                </tr>\r\n            </thead>\r\n            <tbody>\r\n'+(null!=(stack1=helpers.each.call(null!=depth0?depth0:container.nullContext||{},null!=depth0?depth0.result:depth0,{name:"each",hash:{},fn:container.program(1,data,0),inverse:container.noop,data:data}))?stack1:"")+'            </tbody>\r\n        </table>\r\n        <div class="button">\r\n            <button class="m-addservices-add"><i class="g-cartografia-subir"></i>Añadir</button>\r\n        </div>\r\n    </div>\r\n</div>'},useData:!0})),M.template.add("addservices.html",Handlebars.template({compiler:[7,">= 4.0.0"],main:function(container,depth0,helpers,partials,data){return'<div class="m-control m-addservices-container">\r\n    <div id="m-searching-result-addservices" class="m-searching-result g-cartografia-spinner"></div>\r\n    <div class="title">Cargar servicios WMS</div>\r\n    \x3c!--         <div id="m-addservices-search" class="search-panel form">\r\n            <input id="m-addservice-url" type="text" placeholder="URL del servicio" />\r\n            <button id="m-addservices-btnurl" class="g-cartografia-mas2" title="Añadir WMS"></button>\r\n        </div> --\x3e\r\n    \x3c!-- search panel --\x3e\r\n    <div class="search-panel">\r\n        <input type="text" id="m-addservices-search-input" placeholder="URL del servicio" class="m-input-search" />\r\n        <button id="m-addservices-search-btn" class="g-cartografia-zoom m-search-btn" title="Conectar al servicio WMS"></button>\r\n        <button id="m-addservices-clear-btn" class="g-cartografia-cancelar m-clear-btn" title="Limpiar búsqueda"></button>\r\n    </div>\r\n    <div id="m-addservices-results"></div>\r\n</div>'},useData:!0}));