ol-wfst 4.0.3 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("ol/style"),require("ol/control"),require("ol/interaction"),require("ol/events/Event"),require("ol/events/condition"),require("ol/Observable"),require("ol/layer/Vector"),require("ol/layer/Base"),require("ol/format/GeoJSON"),require("ol/source/Vector"),require("ol/proj"),require("ol/loadingstrategy"),require("ol/layer/Tile"),require("ol/format"),require("ol/source/TileWMS"),require("ol/geom"),require("ol/Object"),require("ol/geom/Polygon"),require("ol/extent")):"function"==typeof define&&define.amd?define(["ol/style","ol/control","ol/interaction","ol/events/Event","ol/events/condition","ol/Observable","ol/layer/Vector","ol/layer/Base","ol/format/GeoJSON","ol/source/Vector","ol/proj","ol/loadingstrategy","ol/layer/Tile","ol/format","ol/source/TileWMS","ol/geom","ol/Object","ol/geom/Polygon","ol/extent"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Wfst=t(e.ol.style,e.ol.control,e.ol.interaction,e.ol.events.Event,e.ol.events.condition,e.ol.Observable,e.ol.layer.Vector,e.ol.layer.Base,e.ol.format.GeoJSON,e.ol.source.Vector,e.ol.proj,e.ol.loadingstrategy,e.ol.layer.Tile,e.ol.format,e.ol.source.TileWMS,e.ol.geom,e.ol.Object,e.ol.geom.Polygon,e.ol.extent)}(this,(function(e,t,o,n,s,i,r,a,l,c,d,h,u,p,m,f,g,v,y){"use strict";function _(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var b=_(n),w=_(r),E=_(a),S=_(l),C=_(c),F=_(u),L=_(m),T=_(g);const k={1:"The view center is not defined",2:"The view resolution is not defined",3:"The view rotation is not defined",4:"`image` and `src` cannot be provided at the same time",5:"`imgSize` must be set when `image` is provided",7:"`format` must be set when `url` is set",8:"Unknown `serverType` configured",9:"`url` must be configured or set using `#setUrl()`",10:"The default `geometryFunction` can only handle `Point` geometries",11:"`options.featureTypes` must be an Array",12:"`options.geometryName` must also be provided when `options.bbox` is set",13:"Invalid corner",14:"Invalid color",15:"Tried to get a value for a key that does not exist in the cache",16:"Tried to set a value for a key that is used already",17:"`resolutions` must be sorted in descending order",18:"Either `origin` or `origins` must be configured, never both",19:"Number of `tileSizes` and `resolutions` must be equal",20:"Number of `origins` and `resolutions` must be equal",22:"Either `tileSize` or `tileSizes` must be configured, never both",24:"Invalid extent or geometry provided as `geometry`",25:"Cannot fit empty extent provided as `geometry`",26:"Features must have an id set",27:"Features must have an id set",28:'`renderMode` must be `"hybrid"` or `"vector"`',30:"The passed `feature` was already added to the source",31:"Tried to enqueue an `element` that was already added to the queue",32:"Transformation matrix cannot be inverted",33:"Invalid units",34:"Invalid geometry layout",36:"Unknown SRS type",37:"Unknown geometry type found",38:"`styleMapValue` has an unknown type",39:"Unknown geometry type",40:"Expected `feature` to have a geometry",41:"Expected an `ol/style/Style` or an array of `ol/style/Style.js`",42:"Question unknown, the answer is 42",43:"Expected `layers` to be an array or a `Collection`",47:"Expected `controls` to be an array or an `ol/Collection`",48:"Expected `interactions` to be an array or an `ol/Collection`",49:"Expected `overlays` to be an array or an `ol/Collection`",50:"`options.featureTypes` should be an Array",51:"Either `url` or `tileJSON` options must be provided",52:"Unknown `serverType` configured",53:"Unknown `tierSizeCalculation` configured",55:"The {-y} placeholder requires a tile grid with extent",56:"mapBrowserEvent must originate from a pointer event",57:"At least 2 conditions are required",59:"Invalid command found in the PBF",60:"Missing or invalid `size`",61:"Cannot determine IIIF Image API version from provided image information JSON",62:"A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`",64:"Layer opacity must be a number",66:"`forEachFeatureAtCoordinate` cannot be used on a WebGL layer if the hit detection logic has not been enabled. This is done by providing adequate shaders using the `hitVertexShader` and `hitFragmentShader` properties of `WebGLPointsLayerRenderer`",67:"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both",68:"A VectorTile source can only be rendered if it has a projection compatible with the view projection"};class M extends Error{constructor(e){const t=k[e];super(t),this.code=e,this.name="AssertionError",this.message=t}}var A=M;var P=class{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}},x="propertychange";var N=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}};function O(){}function I(e){for(const t in e)delete e[t]}var G=class extends N{constructor(e){super(),this.eventTarget_=e,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(e,t){if(!e||!t)return;const o=this.listeners_||(this.listeners_={}),n=o[e]||(o[e]=[]);n.includes(t)||n.push(t)}dispatchEvent(e){const t="string"==typeof e,o=t?e:e.type,n=this.listeners_&&this.listeners_[o];if(!n)return;const s=t?new P(e):e;s.target||(s.target=this.eventTarget_||this);const i=this.dispatching_||(this.dispatching_={}),r=this.pendingRemovals_||(this.pendingRemovals_={});let a;o in i||(i[o]=0,r[o]=0),++i[o];for(let e=0,t=n.length;e<t;++e)if(a="handleEvent"in n[e]?n[e].handleEvent(s):n[e].call(this,s),!1===a||s.propagationStopped){a=!1;break}if(0==--i[o]){let e=r[o];for(delete r[o];e--;)this.removeEventListener(o,O);delete i[o]}return a}disposeInternal(){this.listeners_&&I(this.listeners_)}getListeners(e){return this.listeners_&&this.listeners_[e]||void 0}hasListener(e){return!!this.listeners_&&(e?e in this.listeners_:Object.keys(this.listeners_).length>0)}removeEventListener(e,t){const o=this.listeners_&&this.listeners_[e];if(o){const n=o.indexOf(t);-1!==n&&(this.pendingRemovals_&&e in this.pendingRemovals_?(o[n]=O,++this.pendingRemovals_[e]):(o.splice(n,1),0===o.length&&delete this.listeners_[e]))}}},D="change";function R(e,t,o,n,s){if(n&&n!==e&&(o=o.bind(n)),s){const n=o;o=function(){e.removeEventListener(t,o),n.apply(this,arguments)}}const i={target:e,type:t,listener:o};return e.addEventListener(t,o),i}function j(e,t,o,n){return R(e,t,o,n,!0)}function V(e){e&&e.target&&(e.target.removeEventListener(e.type,e.listener),I(e))}class U extends G{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(D)}getRevision(){return this.revision_}onInternal(e,t){if(Array.isArray(e)){const o=e.length,n=new Array(o);for(let s=0;s<o;++s)n[s]=R(this,e[s],t);return n}return R(this,e,t)}onceInternal(e,t){let o;if(Array.isArray(e)){const n=e.length;o=new Array(n);for(let s=0;s<n;++s)o[s]=j(this,e[s],t)}else o=j(this,e,t);return t.ol_key=o,o}unInternal(e,t){const o=t.ol_key;if(o)!function(e){if(Array.isArray(e))for(let t=0,o=e.length;t<o;++t)V(e[t]);else V(e)}(o);else if(Array.isArray(e))for(let o=0,n=e.length;o<n;++o)this.removeEventListener(e[o],t);else this.removeEventListener(e,t)}}U.prototype.on,U.prototype.once,U.prototype.un;var q=U;let z=0;class H extends P{constructor(e,t,o){super(e),this.key=t,this.oldValue=o}}var B=class extends q{constructor(e){var t;super(),this.on,this.once,this.un,(t=this).ol_uid||(t.ol_uid=String(++z)),this.values_=null,void 0!==e&&this.setProperties(e)}get(e){let t;return this.values_&&this.values_.hasOwnProperty(e)&&(t=this.values_[e]),t}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}hasProperties(){return!!this.values_}notify(e,t){let o;o=`change:${e}`,this.hasListener(o)&&this.dispatchEvent(new H(o,e,t)),o=x,this.hasListener(o)&&this.dispatchEvent(new H(o,e,t))}addChangeListener(e,t){this.addEventListener(`change:${e}`,t)}removeChangeListener(e,t){this.removeEventListener(`change:${e}`,t)}set(e,t,o){const n=this.values_||(this.values_={});if(o)n[e]=t;else{const o=n[e];n[e]=t,o!==t&&this.notify(e,o)}}setProperties(e,t){for(const o in e)this.set(o,e[o],t)}applyProperties(e){e.values_&&Object.assign(this.values_||(this.values_={}),e.values_)}unset(e,t){if(this.values_&&e in this.values_){const o=this.values_[e];delete this.values_[e],function(e){let t;for(t in e)return!1;return!t}(this.values_)&&(this.values_=null),t||this.notify(e,o)}}},$="add",W="remove";const K="length";class Z extends P{constructor(e,t,o){super(e),this.element=t,this.index=o}}var J=class extends B{constructor(e,t){if(super(),this.on,this.once,this.un,t=t||{},this.unique_=!!t.unique,this.array_=e||[],this.unique_)for(let e=0,t=this.array_.length;e<t;++e)this.assertUnique_(this.array_[e],e);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(e){for(let t=0,o=e.length;t<o;++t)this.push(e[t]);return this}forEach(e){const t=this.array_;for(let o=0,n=t.length;o<n;++o)e(t[o],o,t)}getArray(){return this.array_}item(e){return this.array_[e]}getLength(){return this.get(K)}insertAt(e,t){if(e<0||e>this.getLength())throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t),this.array_.splice(e,0,t),this.updateLength_(),this.dispatchEvent(new Z($,t,e))}pop(){return this.removeAt(this.getLength()-1)}push(e){this.unique_&&this.assertUnique_(e);const t=this.getLength();return this.insertAt(t,e),this.getLength()}remove(e){const t=this.array_;for(let o=0,n=t.length;o<n;++o)if(t[o]===e)return this.removeAt(o)}removeAt(e){if(e<0||e>=this.getLength())return;const t=this.array_[e];return this.array_.splice(e,1),this.updateLength_(),this.dispatchEvent(new Z(W,t,e)),t}setAt(e,t){if(e>=this.getLength())return void this.insertAt(e,t);if(e<0)throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t,e);const o=this.array_[e];this.array_[e]=t,this.dispatchEvent(new Z(W,o,e)),this.dispatchEvent(new Z($,t,e))}updateLength_(){this.set(K,this.array_.length)}assertUnique_(e,t){for(let o=0,n=this.array_.length;o<n;++o)if(this.array_[o]===e&&o!==t)throw new A(58)}};class Y extends B{constructor(e){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),e)if("function"==typeof e.getSimplifiedGeometry){const t=e;this.setGeometry(t)}else{const t=e;this.setProperties(t)}}clone(){const e=new Y(this.hasProperties()?this.getProperties():null);e.setGeometryName(this.getGeometryName());const t=this.getGeometry();t&&e.setGeometry(t.clone());const o=this.getStyle();return o&&e.setStyle(o),e}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(V(this.geometryChangeKey_),this.geometryChangeKey_=null);const e=this.getGeometry();e&&(this.geometryChangeKey_=R(e,D,this.handleGeometryChange_,this)),this.changed()}setGeometry(e){this.set(this.geometryName_,e)}setStyle(e){this.style_=e,this.styleFunction_=e?function(e){if("function"==typeof e)return e;{let t;if(Array.isArray(e))t=e;else{!function(e,t){if(!e)throw new A(t)}("function"==typeof e.getZIndex,41);t=[e]}return function(){return t}}}(e):void 0,this.changed()}setId(e){this.id_=e,this.changed()}setGeometryName(e){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=e,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}}var X=Y;function Q(e){let t=e.offsetWidth;const o=getComputedStyle(e);return t+=parseInt(o.marginLeft,10)+parseInt(o.marginRight,10),t}function ee(e){let t=e.offsetHeight;const o=getComputedStyle(e);return t+=parseInt(o.marginTop,10)+parseInt(o.marginBottom,10),t}function te(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function oe(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(o){var n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:function(){return e[o]}})})),t}var ne=2,se=3,ie="postrender";const re="element",ae="map",le="offset",ce="position",de="positioning";var he=class extends B{constructor(e){super(),this.on,this.once,this.un,this.options=e,this.id=e.id,this.insertFirst=void 0===e.insertFirst||e.insertFirst,this.stopEvent=void 0===e.stopEvent||e.stopEvent,this.element=document.createElement("div"),this.element.className=void 0!==e.className?e.className:"ol-overlay-container ol-selectable",this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=!0===e.autoPan?{}:e.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(re,this.handleElementChanged),this.addChangeListener(ae,this.handleMapChanged),this.addChangeListener(le,this.handleOffsetChanged),this.addChangeListener(ce,this.handlePositionChanged),this.addChangeListener(de,this.handlePositioningChanged),void 0!==e.element&&this.setElement(e.element),this.setOffset(void 0!==e.offset?e.offset:[0,0]),this.setPositioning(e.positioning||"top-left"),void 0!==e.position&&this.setPosition(e.position)}getElement(){return this.get(re)}getId(){return this.id}getMap(){return this.get(ae)||null}getOffset(){return this.get(le)}getPosition(){return this.get(ce)}getPositioning(){return this.get(de)}handleElementChanged(){!function(e){for(;e.lastChild;)e.removeChild(e.lastChild)}(this.element);const e=this.getElement();e&&this.element.appendChild(e)}handleMapChanged(){var e;this.mapPostrenderListenerKey&&((e=this.element)&&e.parentNode&&e.parentNode.removeChild(e),V(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const t=this.getMap();if(t){this.mapPostrenderListenerKey=R(t,ie,this.render,this),this.updatePixelPosition();const e=this.stopEvent?t.getOverlayContainerStopEvent():t.getOverlayContainer();this.insertFirst?e.insertBefore(this.element,e.childNodes[0]||null):e.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(e){this.set(re,e)}setMap(e){this.set(ae,e)}setOffset(e){this.set(le,e)}setPosition(e){this.set(ce,e)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(e){const t=this.getMap();if(!t||!t.getTargetElement()||!this.get(ce))return;const o=this.getRect(t.getTargetElement(),t.getSize()),n=this.getElement(),s=this.getRect(n,[Q(n),ee(n)]),i=void 0===(e=e||{}).margin?20:e.margin;if(a=s,!((r=o)[0]<=a[0]&&a[2]<=r[2]&&r[1]<=a[1]&&a[3]<=r[3])){const n=s[0]-o[0],r=o[2]-s[2],a=s[1]-o[1],l=o[3]-s[3],c=[0,0];if(n<0?c[0]=n-i:r<0&&(c[0]=Math.abs(r)+i),a<0?c[1]=a-i:l<0&&(c[1]=Math.abs(l)+i),0!==c[0]||0!==c[1]){const o=t.getView().getCenterInternal(),n=t.getPixelFromCoordinateInternal(o);if(!n)return;const s=[n[0]+c[0],n[1]+c[1]],i=e.animation||{};t.getView().animateInternal({center:t.getCoordinateFromPixelInternal(s),duration:i.duration,easing:i.easing})}}var r,a}getRect(e,t){const o=e.getBoundingClientRect(),n=o.left+window.pageXOffset,s=o.top+window.pageYOffset;return[n,s,n+t[0],s+t[1]]}setPositioning(e){this.set(de,e)}setVisible(e){this.rendered.visible!==e&&(this.element.style.display=e?"":"none",this.rendered.visible=e)}updatePixelPosition(){const e=this.getMap(),t=this.getPosition();if(!e||!e.isRendered()||!t)return void this.setVisible(!1);const o=e.getPixelFromCoordinate(t),n=e.getSize();this.updateRenderedPosition(o,n)}updateRenderedPosition(e,t){const o=this.element.style,n=this.getOffset(),s=this.getPositioning();this.setVisible(!0);let i="0%",r="0%";"bottom-right"==s||"center-right"==s||"top-right"==s?i="-100%":"bottom-center"!=s&&"center-center"!=s&&"top-center"!=s||(i="-50%"),"bottom-left"==s||"bottom-center"==s||"bottom-right"==s?r="-100%":"center-left"!=s&&"center-center"!=s&&"center-right"!=s||(r="-50%");const a=`translate(${i}, ${r}) translate(${Math.round(e[0]+n[0])+"px"}, ${Math.round(e[1]+n[1])+"px"})`;this.rendered.transform_!=a&&(this.rendered.transform_=a,o.transform=a)}getOptions(){return this.options}};function ue(){}function pe(){pe.init.call(this)}function me(e){return void 0===e._maxListeners?pe.defaultMaxListeners:e._maxListeners}function fe(e,t,o){if(t)e.call(o);else for(var n=e.length,s=Se(e,n),i=0;i<n;++i)s[i].call(o)}function ge(e,t,o,n){if(t)e.call(o,n);else for(var s=e.length,i=Se(e,s),r=0;r<s;++r)i[r].call(o,n)}function ve(e,t,o,n,s){if(t)e.call(o,n,s);else for(var i=e.length,r=Se(e,i),a=0;a<i;++a)r[a].call(o,n,s)}function ye(e,t,o,n,s,i){if(t)e.call(o,n,s,i);else for(var r=e.length,a=Se(e,r),l=0;l<r;++l)a[l].call(o,n,s,i)}function _e(e,t,o,n){if(t)e.apply(o,n);else for(var s=e.length,i=Se(e,s),r=0;r<s;++r)i[r].apply(o,n)}function be(e,t,o,n){var s,i,r,a;if("function"!=typeof o)throw new TypeError('"listener" argument must be a function');if((i=e._events)?(i.newListener&&(e.emit("newListener",t,o.listener?o.listener:o),i=e._events),r=i[t]):(i=e._events=new ue,e._eventsCount=0),r){if("function"==typeof r?r=i[t]=n?[o,r]:[r,o]:n?r.unshift(o):r.push(o),!r.warned&&(s=me(e))&&s>0&&r.length>s){r.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=r.length,a=l,"function"==typeof console.warn?console.warn(a):console.log(a)}}else r=i[t]=o,++e._eventsCount;return e}function we(e,t,o){var n=!1;function s(){e.removeListener(t,s),n||(n=!0,o.apply(e,arguments))}return s.listener=o,s}function Ee(e){var t=this._events;if(t){var o=t[e];if("function"==typeof o)return 1;if(o)return o.length}return 0}function Se(e,t){for(var o=new Array(t);t--;)o[t]=e[t];return o}ue.prototype=Object.create(null),pe.EventEmitter=pe,pe.usingDomains=!1,pe.prototype.domain=void 0,pe.prototype._events=void 0,pe.prototype._maxListeners=void 0,pe.defaultMaxListeners=10,pe.init=function(){this.domain=null,pe.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new ue,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},pe.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},pe.prototype.getMaxListeners=function(){return me(this)},pe.prototype.emit=function(e){var t,o,n,s,i,r,a,l="error"===e;if(r=this._events)l=l&&null==r.error;else if(!l)return!1;if(a=this.domain,l){if(t=arguments[1],!a){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(o=r[e]))return!1;var d="function"==typeof o;switch(n=arguments.length){case 1:fe(o,d,this);break;case 2:ge(o,d,this,arguments[1]);break;case 3:ve(o,d,this,arguments[1],arguments[2]);break;case 4:ye(o,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(s=new Array(n-1),i=1;i<n;i++)s[i-1]=arguments[i];_e(o,d,this,s)}return!0},pe.prototype.addListener=function(e,t){return be(this,e,t,!1)},pe.prototype.on=pe.prototype.addListener,pe.prototype.prependListener=function(e,t){return be(this,e,t,!0)},pe.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,we(this,e,t)),this},pe.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,we(this,e,t)),this},pe.prototype.removeListener=function(e,t){var o,n,s,i,r;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(o=n[e]))return this;if(o===t||o.listener&&o.listener===t)0==--this._eventsCount?this._events=new ue:(delete n[e],n.removeListener&&this.emit("removeListener",e,o.listener||t));else if("function"!=typeof o){for(s=-1,i=o.length;i-- >0;)if(o[i]===t||o[i].listener&&o[i].listener===t){r=o[i].listener,s=i;break}if(s<0)return this;if(1===o.length){if(o[0]=void 0,0==--this._eventsCount)return this._events=new ue,this;delete n[e]}else!function(e,t){for(var o=t,n=o+1,s=e.length;n<s;o+=1,n+=1)e[o]=e[n];e.pop()}(o,s);n.removeListener&&this.emit("removeListener",e,r||t)}return this},pe.prototype.off=function(e,t){return this.removeListener(e,t)},pe.prototype.removeAllListeners=function(e){var t,o;if(!(o=this._events))return this;if(!o.removeListener)return 0===arguments.length?(this._events=new ue,this._eventsCount=0):o[e]&&(0==--this._eventsCount?this._events=new ue:delete o[e]),this;if(0===arguments.length){for(var n,s=Object.keys(o),i=0;i<s.length;++i)"removeListener"!==(n=s[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new ue,this._eventsCount=0,this}if("function"==typeof(t=o[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},pe.prototype.listeners=function(e){var t,o=this._events;return o&&(t=o[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),o=0;o<t.length;++o)t[o]=e[o].listener||e[o];return t}(t):[]},pe.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Ee.call(e,t)},pe.prototype.listenerCount=Ee,pe.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Ce=oe(Object.freeze({__proto__:null,default:pe,EventEmitter:pe})),Fe=function(e){var t={exports:{}};return e(t,t.exports),t.exports}((function(e){e.exports=function(e){var t={};function o(n){if(t[n])return t[n].exports;var s=t[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,o),s.l=!0,s.exports}return o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=0)}([function(e,t,o){e.exports=o(1).default},function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0});var n,s=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=o(2),l=(n=a)&&n.__esModule?n:{default:n};function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var h=null,u=Object.freeze({el:null,animate:!0,animateClass:"fade",animateInClass:"show",appendTo:"body",backdrop:!0,keyboard:!0,title:!1,header:!0,content:!1,footer:!0,buttons:null,headerClose:!0,construct:!1,transition:300,backdropTransition:150}),p=function e(t){for(var o in t)Array.isArray(t[o])?t[o].forEach((function(t){e(t)})):null!==t[o]&&"object"===r(t[o])&&Object.freeze(t[o]);return Object.freeze(t)}({dialog:[{text:"Cancel",value:!1,attr:{class:"btn btn-default","data-dismiss":"modal"}},{text:"OK",value:!0,attr:{class:"btn btn-primary","data-dismiss":"modal"}}],alert:[{text:"OK",attr:{class:"btn btn-primary","data-dismiss":"modal"}}],confirm:[{text:"Cancel",value:!1,attr:{class:"btn btn-default","data-dismiss":"modal"}},{text:"OK",value:!0,attr:{class:"btn btn-primary","data-dismiss":"modal"}}]}),m={container:'<div class="modal"></div>',dialog:'<div class="modal-dialog"></div>',content:'<div class="modal-content"></div>',header:'<div class="modal-header"></div>',headerClose:'<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>',body:'<div class="modal-body"></div>',footer:'<div class="modal-footer"></div>',backdrop:'<div class="modal-backdrop"></div>'};function f(){return(65536*(1+Math.random())|0).toString(16)+(65536*(1+Math.random())|0).toString(16)}function g(e,t,o){var n=e.data||{};if(void 0===o){if(e.data&&e.data[t])return e.data[t];var s=e.getAttribute("data-"+t);return void 0!==s?s:null}return n[t]=o,e.data=n,e}function v(e,t){return e.nodeName?e:(e=e.replace(/(\t|\n$)/g,""),h||(h=document.createElement("div")),h.innerHTML="",h.innerHTML=e,!0===t?h.childNodes:h.childNodes[0])}function y(){var e,t,o=void 0,n=document.createElement("div");return i(n.style,{visibility:"hidden",width:"100px"}),document.body.appendChild(n),t=n.offsetWidth,n.style.overflow="scroll",(o=document.createElement("div")).style.width="100%",n.appendChild(o),e=t-o.offsetWidth,document.body.removeChild(n),e}function _(e){for(var t=[e];e.parentNode;)e=e.parentNode,t.push(e);return t}var b=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c(this,t);var o=d(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));if(o.id=f(),o.el=null,o._html={},o._events={},o._visible=!1,o._pointerInContent=!1,o._options=i({},t.options,e),o._templates=i({},t.templates,e.templates||{}),o._html.appendTo=document.querySelector(o._options.appendTo),o._scrollbarWidth=y(),null===o._options.buttons&&(o._options.buttons=t.buttons.dialog),o._options.el){var n=o._options.el;if("string"==typeof o._options.el&&!(n=document.querySelector(o._options.el)))throw new Error("Selector: DOM Element "+o._options.el+" not found.");g(n,"modal",o),o.el=n}else o._options.construct=!0;return o._options.construct?o._render():o._mapDom(),o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),s(t,null,[{key:"alert",value:function(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i({},u,{title:e,content:!1,construct:!0,headerClose:!1,buttons:t.buttons.alert},o);return new t(n)}},{key:"confirm",value:function(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i({},u,{title:e,content:!1,construct:!0,headerClose:!1,buttons:t.buttons.confirm},o);return new t(n)}},{key:"templates",set:function(e){this._baseTemplates=e},get:function(){return i({},m,t._baseTemplates||{})}},{key:"buttons",set:function(e){this._baseButtons=e},get:function(){return i({},p,t._baseButtons||{})}},{key:"options",set:function(e){this._baseOptions=e},get:function(){return i({},u,t._baseOptions||{})}},{key:"version",get:function(){return"0.12.0"}}]),s(t,[{key:"_render",value:function(){var e=this._html,t=this._options,o=this._templates,n=!!t.animate&&t.animateClass;return e.container=v(o.container),e.dialog=v(o.dialog),e.content=v(o.content),e.header=v(o.header),e.headerClose=v(o.headerClose),e.body=v(o.body),e.footer=v(o.footer),n&&e.container.classList.add(n),this._setHeader(),this._setContent(),this._setFooter(),this.el=e.container,e.dialog.appendChild(e.content),e.container.appendChild(e.dialog),this}},{key:"_mapDom",value:function(){var e=this._html,t=this._options;return this.el.classList.contains(t.animateClass)&&(t.animate=!0),e.container=this.el,e.dialog=this.el.querySelector(".modal-dialog"),e.content=this.el.querySelector(".modal-content"),e.header=this.el.querySelector(".modal-header"),e.headerClose=this.el.querySelector(".modal-header .close"),e.body=this.el.querySelector(".modal-body"),e.footer=this.el.querySelector(".modal-footer"),this._setHeader(),this._setContent(),this._setFooter(),this}},{key:"_setHeader",value:function(){var e=this._html,t=this._options;t.header&&e.header&&(t.title.nodeName?e.header.innerHTML=t.title.outerHTML:"string"==typeof t.title&&(e.header.innerHTML='<h4 class="modal-title">'+t.title+"</h4>"),null===this.el&&e.headerClose&&t.headerClose&&e.header.appendChild(e.headerClose),t.construct&&e.content.appendChild(e.header))}},{key:"_setContent",value:function(){var e=this._html,t=this._options;t.content&&e.body&&("string"==typeof t.content?e.body.innerHTML=t.content:e.body.innerHTML=t.content.outerHTML,t.construct&&e.content.appendChild(e.body))}},{key:"_setFooter",value:function(){var e=this._html,t=this._options;t.footer&&e.footer&&(t.footer.nodeName?e.footer.ineerHTML=t.footer.outerHTML:"string"==typeof t.footer?e.footer.innerHTML=t.footer:e.footer.children.length||t.buttons.forEach((function(t){var o=document.createElement("button");for(var n in g(o,"button",t),o.innerHTML=t.text,o.setAttribute("type","button"),t.attr)o.setAttribute(n,t.attr[n]);e.footer.appendChild(o)})),t.construct&&e.content.appendChild(e.footer))}},{key:"_setEvents",value:function(){this._options;var e=this._html;this._events.keydownHandler=this._handleKeydownEvent.bind(this),document.body.addEventListener("keydown",this._events.keydownHandler),this._events.mousedownHandler=this._handleMousedownEvent.bind(this),e.container.addEventListener("mousedown",this._events.mousedownHandler),this._events.clickHandler=this._handleClickEvent.bind(this),e.container.addEventListener("click",this._events.clickHandler),this._events.resizeHandler=this._handleResizeEvent.bind(this),window.addEventListener("resize",this._events.resizeHandler)}},{key:"_handleMousedownEvent",value:function(e){var t=this;this._pointerInContent=!1,_(e.target).every((function(e){return!e.classList||!e.classList.contains("modal-content")||(t._pointerInContent=!0,!1)}))}},{key:"_handleClickEvent",value:function(e){var t=this;_(e.target).every((function(o){return"HTML"!==o.tagName&&((!0===t._options.backdrop||!o.classList.contains("modal"))&&(!o.classList.contains("modal-content")&&("modal"===o.getAttribute("data-dismiss")?(t.emit("dismiss",t,e,g(e.target,"button")),t.hide(),!1):!(!t._pointerInContent&&o.classList.contains("modal"))||(t.emit("dismiss",t,e,null),t.hide(),!1))))})),this._pointerInContent=!1}},{key:"_handleKeydownEvent",value:function(e){27===e.which&&this._options.keyboard&&(this.emit("dismiss",this,e,null),this.hide())}},{key:"_handleResizeEvent",value:function(e){this._resize()}},{key:"show",value:function(){var e=this,t=this._options,o=this._html;return this.emit("show",this),this._checkScrollbar(),this._setScrollbar(),document.body.classList.add("modal-open"),t.construct&&o.appendTo.appendChild(o.container),o.container.style.display="block",o.container.scrollTop=0,!1!==t.backdrop?(this.once("showBackdrop",(function(){e._setEvents(),t.animate&&o.container.offsetWidth,o.container.classList.add(t.animateInClass),setTimeout((function(){e._visible=!0,e.emit("shown",e)}),t.transition)})),this._backdrop()):(this._setEvents(),t.animate&&o.container.offsetWidth,o.container.classList.add(t.animateInClass),setTimeout((function(){e._visible=!0,e.emit("shown",e)}),t.transition)),this._resize(),this}},{key:"toggle",value:function(){this._visible?this.hide():this.show()}},{key:"_resize",value:function(){var e=this._html.container.scrollHeight>document.documentElement.clientHeight;this._html.container.style.paddingLeft=!this.bodyIsOverflowing&&e?this._scrollbarWidth+"px":"",this._html.container.style.paddingRight=this.bodyIsOverflowing&&!e?this._scrollbarWidth+"px":""}},{key:"_backdrop",value:function(){var e=this,t=this._html,o=this._templates,n=this._options,s=!!n.animate&&n.animateClass;t.backdrop=v(o.backdrop),s&&t.backdrop.classList.add(s),t.appendTo.appendChild(t.backdrop),s&&t.backdrop.offsetWidth,t.backdrop.classList.add(n.animateInClass),setTimeout((function(){e.emit("showBackdrop",e)}),this._options.backdropTransition)}},{key:"hide",value:function(){var e=this,t=this._html,o=this._options,n=t.container.classList;(this.emit("hide",this),n.remove(o.animateInClass),o.backdrop)&&t.backdrop.classList.remove(o.animateInClass);return this._removeEvents(),setTimeout((function(){document.body.classList.remove("modal-open"),document.body.style.paddingRight=e.originalBodyPad}),o.backdropTransition),setTimeout((function(){o.backdrop&&t.backdrop.parentNode.removeChild(t.backdrop),t.container.style.display="none",o.construct&&t.container.parentNode.removeChild(t.container),e._visible=!1,e.emit("hidden",e)}),o.transition),this}},{key:"_removeEvents",value:function(){this._events.keydownHandler&&document.body.removeEventListener("keydown",this._events.keydownHandler),this._html.container.removeEventListener("mousedown",this._events.mousedownHandler),this._html.container.removeEventListener("click",this._events.clickHandler),window.removeEventListener("resize",this._events.resizeHandler)}},{key:"_checkScrollbar",value:function(){this.bodyIsOverflowing=document.body.clientWidth<window.innerWidth}},{key:"_setScrollbar",value:function(){if(this.originalBodyPad=document.body.style.paddingRight||"",this.bodyIsOverflowing){var e=parseInt(this.originalBodyPad||0,10);document.body.style.paddingRight=e+this._scrollbarWidth+"px"}}}]),t}(l.default);t.default=b},function(e,t){e.exports=Ce}])})),Le=te(Fe);let Te={};const ke=new Set,Me=e=>"exceptions"in e?e.exceptions.map((e=>e.text)).join(","):"",Ae=(e,t=null,o="")=>{if(ke.has(o))return;ke.add(o);let n=`<b>Error: ${e}</b>`;t&&(n+=`. ${t.message}`);const s=Le.alert(n,Te);s.show(),s.on("hidden",(()=>{ke.delete(o)}))},Pe={labels:{select:"Select",addElement:"Toggle Draw mode",editElement:"Edit feature",save:"Save",delete:"Delete",cancel:"Cancel",apply:"Apply changes",upload:"Upload",editMode:"Edit Mode",confirmDelete:"Are you sure to delete the feature?",geomTypeNotSupported:"Geometry not supported by layer",editFields:"Edit fields",editGeom:"Edit geometry",selectDrawType:"Geometry type to draw",uploadToLayer:"Upload file to selected layer",uploadFeatures:"Uploaded features to layer",validFeatures:"Valid geometries",invalidFeatures:"Invalid",loading:"Loading...",toggleVisibility:"Toggle layer visibility",close:"Close"},errors:{capabilities:"GeoServer Capabilities could not be downloaded.",wfst:"The GeoServer does not support Transactions",layer:"Could not get data from layer",layerNotFound:"Layer not found",layerNotVisible:"Layer is not visible",noValidGeometry:"No valid geometries found to add to this layer",geoserver:"Failed to get data from GeoServer",badFormat:"Unsupported format",badFile:"Error reading items from file",lockFeature:"Could not lock items on the GeoServer.",transaction:"Error when doing Transaction with GeoServer.",getFeatures:"Error getting elements from GeoServer."}},xe={es:{labels:{select:"Seleccionar",addElement:"Modo dibujo",editElement:"Editar elemento",save:"Guardar",delete:"Eliminar",cancel:"Cancelar",apply:"Aplicar cambios",upload:"Subir",editMode:"Modo Edición",confirmDelete:"¿Estás seguro de borrar el elemento?",geomTypeNotSupported:"Geometría no compatible con la capa",editFields:"Editar campos",editGeom:"Editar geometría",selectDrawType:"Tipo de geometría para dibujar",uploadToLayer:"Subir archivo a la capa seleccionada",uploadFeatures:"Subida de elementos a la capa",validFeatures:"Válidas",invalidFeatures:"Invalidas",loading:"Cargando...",toggleVisibility:"Cambiar visibilidad de la capa",close:"Cerrar"},errors:{capabilities:"No se pudieron obtener las Capabilidades del GeoServer",wfst:"El GeoServer no tiene soporte a Transacciones",layer:"No se pudieron obtener datos de la capa",layerNotFound:"Capa no encontrada",layerNotVisible:"La capa no está visible",noValidGeometry:"No se encontraron geometrías válidas para agregar a esta capa",geoserver:"No se pudieron obtener datos desde el GeoServer",badFormat:"Formato no soportado",badFile:"Error al leer elementos del archivo",lockFeature:"No se pudieron bloquear elementos en el GeoServer.",transaction:"Error al hacer transacción con el GeoServer.",getFeatures:"Error al obtener elemento desde el GeoServer."}},en:Pe,zh:{labels:{select:"选择",addElement:"切换绘图类型",editElement:"编辑元素",save:"保存",delete:"删除",cancel:"取消",apply:"确认并应用改变",upload:"上传",editMode:"编辑模式",confirmDelete:"确认删除元素?",geomTypeNotSupported:"图层不支持该几何",editFields:"编辑区域",editGeom:"编辑几何",selectDrawType:"几何类型",uploadToLayer:"通过文件上传图层",uploadFeatures:"上传元素到图层",validFeatures:"合法的几何类型",invalidFeatures:"不合法",loading:"加载中...",toggleVisibility:"切换图层透明度",close:"关闭"},errors:{capabilities:"无法加载GeoServer服务所支持的能力.",wfst:"GeoServer不支持事务",layer:"无法从图层获得数据",layerNotFound:"Layer not found",layerNotVisible:"Layer is not visible",noValidGeometry:"不支持的几何类型无法加载到图层",geoserver:"无法从GeoServer获取数据",badFormat:"不支持的格式",badFile:"读取文件数据出错",lockFeature:"无法锁定GeoServer上的元素.",transaction:"GeoServer处理事务出错.",getFeatures:"从GeoServer获取元素出错."}}};let Ne=Pe;let Oe;const Ie=(e=!0)=>{e?Oe.classList.add("ol-wfst--tools-control--loading-show"):Oe.classList.remove("ol-wfst--tools-control--loading-show")},Ge=(e,t,o=[])=>{const n=Object.getOwnPropertyDescriptors(t);for(let e of o)delete n[e];Object.defineProperties(e,n)},De=(e,t=[e])=>{const o=Object.getPrototypeOf(e);return null===o?t:De(o,[...t,o])},Re=(e,t,o=[])=>{var n;const s=null!==(n=((...e)=>{if(0===e.length)return;let t;const o=e.map((e=>De(e)));for(;o.every((e=>e.length>0));){const e=o.map((e=>e.pop())),n=e[0];if(!e.every((e=>e===n)))break;t=n}return t})(...e))&&void 0!==n?n:Object.prototype,i=Object.create(s),r=De(s);for(let t of e){let e=De(t);for(let t=e.length-1;t>=0;t--){let n=e[t];-1===r.indexOf(n)&&(Ge(i,n,["constructor",...o]),r.push(n))}}return i.constructor=t,i},je=e=>e.filter(((t,o)=>e.indexOf(t)==o)),Ve=new Map,Ue=e=>Ve.get(e),qe=(e,t)=>{var o,n;const s=je([...Object.getOwnPropertyNames(e),...Object.getOwnPropertyNames(t)]),i={};for(let r of s)i[r]=je([...null!==(o=null==e?void 0:e[r])&&void 0!==o?o:[],...null!==(n=null==t?void 0:t[r])&&void 0!==n?n:[]]);return i},ze=(e,t)=>{var o,n,s,i;return{property:qe(null!==(o=null==e?void 0:e.property)&&void 0!==o?o:{},null!==(n=null==t?void 0:t.property)&&void 0!==n?n:{}),method:qe(null!==(s=null==e?void 0:e.method)&&void 0!==s?s:{},null!==(i=null==t?void 0:t.method)&&void 0!==i?i:{})}},He=new Map,Be=(...e)=>{const t=((...e)=>{var t;const o=new Set,n=new Set([...e]);for(;n.size>0;)for(let e of n){const s=[...De(e.prototype).map((e=>e.constructor)),...null!==(t=Ue(e))&&void 0!==t?t:[]].filter((e=>!o.has(e)));for(let e of s)n.add(e);o.add(e),n.delete(e)}return[...o]})(...e).map((e=>He.get(e))).filter((e=>!!e));return 0==t.length?{}:1==t.length?t[0]:t.reduce(((e,t)=>((e,t)=>{var o,n,s,i,r,a;return{class:je([...null!==(o=null==e?void 0:e.class)&&void 0!==o?o:[],...null!==(n=null==t?void 0:t.class)&&void 0!==n?n:[]]),static:ze(null!==(s=null==e?void 0:e.static)&&void 0!==s?s:{},null!==(i=null==t?void 0:t.static)&&void 0!==i?i:{}),instance:ze(null!==(r=null==e?void 0:e.instance)&&void 0!==r?r:{},null!==(a=null==t?void 0:t.instance)&&void 0!==a?a:{})}})(e,t)))};function $e(...e){var t,o,n;const s=e.map((e=>e.prototype));function i(...t){for(const o of e)Ge(this,new o(...t))}i.prototype=Re(s,i),Object.setPrototypeOf(i,Re(e,null,["prototype"]));let r=i;{const s=Be(...e);for(let e of null!==(t=null==s?void 0:s.class)&&void 0!==t?t:[])r=e(r);We(null!==(o=null==s?void 0:s.static)&&void 0!==o?o:{},r),We(null!==(n=null==s?void 0:s.instance)&&void 0!==n?n:{},r.prototype)}var a,l;return a=r,l=e,Ve.set(a,l),r}const We=(e,t)=>{const o=e.property,n=e.method;if(o)for(let e in o)for(let n of o[e])n(t,e);if(n)for(let e in n)for(let o of n[e])o(t,e,Object.getOwnPropertyDescriptor(t,e))};var Ke,Ze;let Je;!function(e){e.Point="Point",e.LineString="LineString",e.LinearRing="LinearRing",e.Polygon="Polygon",e.MultiPoint="MultiPoint",e.MultiLineString="MultiLineString",e.MultiPolygon="MultiPolygon",e.GeometryCollection="GeometryCollection",e.Circle="Circle"}(Ke||(Ke={})),function(e){e.Insert="insert",e.Delete="delete",e.Update="update"}(Ze||(Ze={}));let Ye=null,Xe=null;var Qe;function et(e=null){Xe=e}function tt(){return Xe}!function(e){e.Edit="EDIT",e.Draw="DRAW"}(Qe||(Qe={}));const ot=new Set,nt={};function st(){return Je}function it(e){Ye=e}function rt(){return Ye}function at(){return nt}function lt(e){return at()[e]}function ct(e){ot.add(String(e.getId()))}function dt(e){ot.delete(String(e.getId()))}function ht(e){return ot.has(String(e.getId()))}class ut extends E.default{_init(){const e=this.getGeoserver();e.isLoaded()?this.getAndUpdateDescribeFeatureType():e.on("change:capabilities",(()=>{this.getAndUpdateDescribeFeatureType()}))}async getAndUpdateDescribeFeatureType(){const e=this.get(pt.NAME),t=this.get(pt.LABEL);try{const t=this.getGeoserver(),o=new URLSearchParams({service:"wfs",version:t.getAdvanced().describeFeatureTypeVersion,request:"DescribeFeatureType",typeName:e,outputFormat:"application/json",exceptions:"application/json"}),n=t.getUrl()+"?"+o.toString(),s=await fetch(n,{headers:t.getHeaders(),credentials:t.getCredentials()});if(!s.ok)throw new Error("");const i=await s.json();if(!i)throw new Error("");const r=i.targetNamespace,a=i.featureTypes[0].properties,l=a.find((e=>e.type.indexOf("gml:")>=0));i._parsed={namespace:r,properties:a,geomType:l.localType,geomField:l.name},this.set(pt.DESCRIBEFEATURETYPE,i)}catch(e){throw console.error(e),new Error(`${Ne.errors.layer} "${t}"`)}}isVisibleByZoom(){return st().getView().getZoom()>this.getMinZoom()}async transactFeatures(e,t){return this.getGeoserver().transact(e,t,this.get(pt.NAME))}async insertFeatures(e){return this.transactFeatures(Ze.Insert,e)}async maybeLockFeature(e){const t=this.getGeoserver();return t.getUseLockFeature()&&t.hasLockFeature()?await t.lockFeature(e,this.get(pt.NAME)):null}getGeoserver(){return this.get(pt.GEOSERVER)}getDescribeFeatureType(){return this.get(pt.DESCRIBEFEATURETYPE)}}var pt;!function(e){e.NAME="name",e.LABEL="label",e.DESCRIBEFEATURETYPE="describeFeatureType",e.ISVISIBLE="isVisible",e.GEOSERVER="geoserver"}(pt||(pt={}));class mt extends C.default{urlParams=new URLSearchParams({SERVICE:"wfs",REQUEST:"GetFeature",OUTPUTFORMAT:"application/json",EXCEPTIONS:"application/json"});constructor(e){super({...e,format:new S.default,loader:async(t,o,n,s,i)=>{try{if(e.strategy==h.bbox){const o=d.transformExtent(t,n.getCode(),e.geoServerAdvanced.projection);this.urlParams.set("bbox",o.toString()+`,${e.geoServerAdvanced.projection}`)}const o=e.geoserverUrl+"?"+this.urlParams.toString(),i=await fetch(o,{headers:e.headers,credentials:e.credentials});if(!i.ok)throw new Error("");const r=await i.json();if(r.exceptions)throw new Error(Me(r));const a=this.getFormat().readFeatures(r,{featureProjection:n.getCode(),dataProjection:e.geoServerAdvanced.projection});a.forEach((t=>{t.set("_layerName_",e.name,!0)})),this.addFeatures(a),s(a)}catch(o){this.removeLoadedExtent(t),Ae(Ne.errors.geoserver,o,e.name),i()}}}),this.urlParams.set("version",e.geoServerAdvanced.getFeatureVersion),this.urlParams.set("typename",e.name),this.urlParams.set("srsName",e.geoServerAdvanced.projection.toString())}}class ft extends($e(ut,w.default)){_loadingCount=0;_loadedCount=0;beforeTransactFeature;constructor(e){super({name:e.name,label:e.label||e.name,minZoom:e.minZoom,...e}),e.beforeTransactFeature&&(this.beforeTransactFeature=e.beforeTransactFeature);const t=e.geoserver,o=new mt({name:e.name,geoserverUrl:t.getUrl(),geoServerAdvanced:t.getAdvanced(),...e.strategy&&{strategy:e.strategy},geoserverVendor:e.geoserverVendor});this._loadingCount=0,this._loadedCount=0,o.on("featuresloadstart",(()=>{this._loadingCount++,1===this._loadingCount&&this.isVisibleByZoom()&&Ie()})),o.on(["featuresloadend","featuresloaderror"],(()=>{this._loadedCount++,this._loadingCount===this._loadedCount&&(this._loadingCount=0,this._loadedCount=0,setTimeout((()=>{this.dispatchEvent("layerRendered")}),300))})),this.setSource(o);const n=e.geoserverVendor;Object.keys(n).forEach((e=>{o.urlParams.set(e,n[e])}))}refresh(){this.getSource().refresh()}setCustomParam(e,t=null,o=!0){const n=this.getSource();return null==t?n.urlParams.delete(e):n.urlParams.set(e,t),o&&this.refresh(),n.urlParams}}class gt extends L.default{constructor(e){super({url:e.geoserverUrl,serverType:"geoserver",params:{SERVICE:"wms",TILED:!0,LAYERS:e.name,EXCEPTIONS:"application/json",...e.geoserverVendor&&e.geoserverVendor},tileLoadFunction:async(t,o)=>{try{const s=await fetch(o,{headers:e.headers,credentials:e.credentials});if(!s.ok)throw new Error("");let i=await s.blob();if("application/json"==i.type){const e=await(n=i,new Promise((e=>{const t=new FileReader;t.onloadend=()=>e(JSON.parse(t.result)),t.readAsText(n)})));throw new Error(Me(e))}t.getImage().src=URL.createObjectURL(i),t.setState(ne)}catch(o){Ae(Ne.errors.geoserver,o,e.name),t.setState(se)}var n},...e})}}class vt extends($e(ut,F.default)){_loadingCount=0;_loadedCount=0;beforeTransactFeature;_formatGeoJSON;constructor(e){super({name:e.name,label:e.label||e.name,minZoom:e.minZoom,...e}),e.beforeTransactFeature&&(this.beforeTransactFeature=e.beforeTransactFeature),this._formatGeoJSON=new p.GeoJSON;const t=e.geoserver,o=new gt({name:e.name,geoserverUrl:t.getUrl(),geoServerAdvanced:t.getAdvanced(),geoserverVendor:e.geoserverVendor});this._loadingCount=0,this._loadedCount=0,o.on("tileloadstart",(()=>{this._loadingCount++,1===this._loadingCount&&this.isVisibleByZoom()&&Ie()})),o.on(["tileloadend","tileloaderror"],(()=>{this._loadedCount++,this._loadingCount===this._loadedCount&&(this._loadingCount=0,this._loadedCount=0,setTimeout((()=>{this.dispatchEvent("layerRendered")}),300))})),this.setSource(o)}async _getFeaturesByClickEvent(e){const t=e.coordinate,o=st().getView(),n=o.getZoom()>10?10:5,s=this.getSource(),i=s["getFeatureInfoUrl"in s?"getFeatureInfoUrl":"getGetFeatureInfoUrl"](t,o.getResolution(),o.getProjection().getCode(),{INFO_FORMAT:"application/json",BUFFER:n,FEATURE_COUNT:1,EXCEPTIONS:"application/json"}),r=this.getGeoserver();try{const e=await fetch(i,{headers:r.getHeaders(),credentials:r.getCredentials()});if(!e.ok)throw new Error(`${Ne.errors.getFeatures} ${e.status}`);const t=await e.json();return this._formatGeoJSON.readFeatures(t)}catch(e){Ae(e.message,e)}}refresh(){const e=this.getSource();e.refresh();const t=e.getParams();t.t=(new Date).getMilliseconds(),e.updateParams(t)}setCustomParam(e,t=null,o=!0){const n=this.getSource();return n.updateParams({[e]:t}),o&&this.refresh(),n.getParams()}}function yt(e,t={},...o){if("function"==typeof e)return e(t,o);const n=null===e?new DocumentFragment:document.createElement(e);Object.entries(t||{}).forEach((([e,t])=>{void 0!==typeof t&&null!=t&&(e.startsWith("on")&&e.toLowerCase()in window?n.addEventListener(e.toLowerCase().substr(2),t):"className"===e?n.setAttribute("class",t.toString()):"htmlFor"===e?n.setAttribute("for",t.toString()):n.setAttribute(e,t.toString()))}));for(const e of o)e&&(Array.isArray(e)?n.append(...e):void 0===e.nodeType?n.innerHTML+=e:n.appendChild(e));return n}const _t=()=>{const e=document.querySelector(".ol-wfst--tools-control-btn.wfst--active");e&&e.classList.remove("wfst--active")};class bt extends q{_uploads;_uploadFormats;constructor(e,t){super(),this._uploads=e,this._uploadFormats=t}addLayerEl(e){const t=document.querySelector(".wfst--tools-control--select-layers"),o=e.get(pt.NAME),n=yt("input",{value:o,id:`wfst--${o}`,type:"radio",className:"ol-wfst--tools-control-input",name:"wfst--select-layer",...e===rt()?{checked:"checked"}:{},onchange:t=>this._layerChangeHandler(t,e)}),s=yt("div",{className:`wfst--layer-control \n ${e.getVisible()?"ol-wfst--visible-on":""}\n ${e===rt()?"ol-wfst--selected-on":""}`,"data-layer":o},yt("div",{className:"ol-wfst--tools-control-visible"},yt("span",{className:"ol-wfst--tools-control-visible-btn ol-wfst--visible-btn-on",title:Ne.labels.toggleVisibility,onclick:e=>this._visibilityClickHandler(e)},yt("img",{src:"data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e%3cpath d='M384 288q39 0 67.5 28.5t28.5 67.5-28.5 67.5-67.5 28.5-67.5-28.5-28.5-67.5 28.5-67.5 67.5-28.5zM384 544.5q66 0 113.25-47.25t47.25-113.25-47.25-113.25-113.25-47.25-113.25 47.25-47.25 113.25 47.25 113.25 113.25 47.25zM384 144q118.5 0 214.5 66t138 174q-42 108-138 174t-214.5 66-214.5-66-138-174q42-108 138-174t214.5-66z'%3e%3c/path%3e%3c/svg%3e"})),yt("span",{className:"ol-wfst--tools-control-visible-btn ol-wfst--visible-btn-off",title:Ne.labels.toggleVisibility,onclick:e=>this._visibilityClickHandler(e)},yt("img",{src:"data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e%3cpath d='M379.5 288h4.5q39 0 67.5 28.5t28.5 67.5v6zM241.5 313.5q-18 36-18 70.5 0 66 47.25 113.25t113.25 47.25q34.5 0 70.5-18l-49.5-49.5q-12 3-21 3-39 0-67.5-28.5t-28.5-67.5q0-9 3-21zM64.5 136.5l40.5-40.5 567 567-40.5 40.5q-7.5-7.5-47.25-46.5t-60.75-60q-64.5 27-139.5 27-118.5 0-214.5-66t-138-174q16.5-39 51.75-86.25t68.25-72.75q-18-18-50.25-51t-36.75-37.5zM384 223.5q-30 0-58.5 12l-69-69q58.5-22.5 127.5-22.5 118.5 0 213.75 66t137.25 174q-36 88.5-109.5 151.5l-93-93q12-28.5 12-58.5 0-66-47.25-113.25t-113.25-47.25z'%3e%3c/path%3e%3c/svg%3e"}))),yt("label",{htmlFor:`wfst--${o}`},n,yt("span",{title:e.getDescribeFeatureType()._parsed.geomType},e.get(pt.LABEL))));return t.appendChild(s),e===rt()&&n.dispatchEvent(new Event("change")),s}_changeStateSelect(e,t=null){const o=(e,t)=>{Array.from(n.options).forEach((o=>{o.selected=o.value===e,o.disabled="all"!==t&&!t.includes(o.value),o.title=o.disabled?Ne.labels.geomTypeNotSupported:""}))},n=document.querySelector(".wfst--tools-control--select-draw");let s;if(n){const i=e.getDescribeFeatureType()._parsed.geomType;t?s=n.value:i===Ke.GeometryCollection?(s=Ke.LineString,o(s,"all")):i===Ke.LinearRing?(s=Ke.LineString,o(s,[Ke.Circle,Ke.LinearRing,Ke.Polygon]),n.value=s):(s=i,o(s,[i]))}return s}_visibilityClickHandler(e){const t=e.currentTarget.closest(".wfst--layer-control"),o=t.dataset.layer;t.classList.toggle("ol-wfst--visible-on");const n=at()[o];t.classList.contains("ol-wfst--visible-on")?n.setVisible(!0):n.setVisible(!1)}_layerChangeHandler(e,t){const o=e.currentTarget.closest(".wfst--layer-control"),n=document.querySelector(".ol-wfst--selected-on");n&&n.classList.remove("ol-wfst--selected-on"),o.classList.add("ol-wfst--selected-on"),it(t),this._changeStateSelect(t)}render(){return yt(null,null,yt("div",{className:"wfst--tools-control--head"},this._uploads&&yt("div",null,yt("input",{id:"ol-wfst--upload",type:"file",accept:this._uploadFormats,onchange:e=>this._uploads.process(e)}),yt("label",{className:"ol-wfst--tools-control-btn ol-wfst--tools-control-btn-upload",htmlFor:"ol-wfst--upload",title:Ne.labels.uploadToLayer},yt("img",{src:"data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'%3e%3cpath d='M240 352h-240v128h480v-128h-240zM448 416h-64v-32h64v32zM112 160l128-128 128 128h-80v160h-96v-160z'%3e%3c/path%3e%3c/svg%3e"}))),yt("div",{className:"ol-wfst--tools-control-draw-cnt"},yt("button",{className:"ol-wfst--tools-control-btn ol-wfst--tools-control-btn-draw",type:"button",title:Ne.labels.addElement,onclick:()=>{this.dispatchEvent("drawMode")}},yt("img",{src:"data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e %3cpath d='M663 225l-58.5 58.5-120-120 58.5-58.5q9-9 22.5-9t22.5 9l75 75q9 9 9 22.5t-9 22.5zM96 552l354-354 120 120-354 354h-120v-120z'%3e%3c/path%3e%3c/svg%3e"})),yt("select",{title:Ne.labels.selectDrawType,className:"wfst--tools-control--select-draw",onchange:e=>{const t=e.target.value;this._changeStateSelect(rt(),t),this.dispatchEvent("changeGeom")}},[Ke.Point,Ke.MultiPoint,Ke.LineString,Ke.MultiLineString,Ke.Polygon,Ke.MultiPolygon,Ke.Circle].map((e=>yt("option",{value:e},e)))))),yt("div",{className:"wfst--tools-control--select-layers"}))}}let wt=new w.default({source:new C.default,zIndex:100});const Et=()=>wt;class St extends q{_options;_formatWFS;_formatGeoJSON;_formatKml;_xs;_processUpload;constructor(e){super(),this._options=e,this._processUpload=e.processUpload,this._formatWFS=new p.WFS,this._formatGeoJSON=new p.GeoJSON,this._formatKml=new p.KML({extractStyles:!1,showPointNames:!1}),this._xs=new XMLSerializer}async process(e){const t=st().getView(),o=e.target.files[0];let n;if(!o)return;const s=o.name.split(".").pop().toLowerCase();try{if(this._processUpload&&(n=this._processUpload(o)),!n){const e=await this._fileReader(o);"geojson"===s||"json"===s?n=this._formatGeoJSON.readFeatures(e,{featureProjection:t.getProjection().getCode()}):"kml"===s?n=this._formatKml.readFeatures(e,{featureProjection:t.getProjection().getCode()}):Ae(Ne.errors.badFormat)}let i=0,r=0;const a=[];for(let e of n)this._checkGeometry(e)||(e=this._fixGeometry(e)),e?(a.push(e),r++):i++;if(r){_t(),this.dispatchEvent(new c.VectorSourceEvent("loadedFeatures",null,a));const e=`\n ${Ne.labels.validFeatures}: ${r}<br>\n ${i?`${Ne.labels.invalidFeatures}: ${i}`:""}`;this._initModal(e,a)}else Ae(Ne.errors.noValidGeometry);e.target.value=null}catch(e){Ae(Ne.errors.badFile,e)}}async _fileReader(e){return new Promise(((t,o)=>{const n=new FileReader;n.addEventListener("load",(async e=>{const o=e.target.result;t(o)})),n.addEventListener("error",(e=>{console.error("Error"+e),o()})),n.readAsText(e)}))}_fixGeometry(e){const t=rt().getDescribeFeatureType()._parsed.geomType;let o;switch(e.getGeometry().getType()){case Ke.Point:if(t===Ke.MultiPoint){const t=e.getGeometry().getCoordinates();o=new f.MultiPoint([t])}break;case Ke.LineString:if(t===Ke.MultiLineString){const t=e.getGeometry().getCoordinates();o=new f.MultiLineString([t])}break;case Ke.Polygon:if(t===Ke.MultiPolygon){const t=e.getGeometry().getCoordinates();o=new f.MultiPolygon([t])}break;default:o=null}return o?(e.setGeometry(o),e):null}_checkGeometry(e){const t=rt().getDescribeFeatureType()._parsed.geomType,o=e.getGeometry().getType();return t===Ke.GeometryCollection||o===t}_initModal(e,t){const o=`\n <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">\n ${Ne.labels.cancel}\n </button>\n <button type="button" class="btn btn-sm btn-primary" data-action="save" data-dismiss="modal">\n ${Ne.labels.upload}\n </button>\n `;new Le({...this._options.modal,header:!0,headerClose:!1,title:Ne.labels.uploadFeatures+" "+rt().get(pt.NAME),content:e,backdrop:"static",footer:o}).show().on("dismiss",((e,o)=>{"save"===o.target.dataset.action?this.dispatchEvent(new c.VectorSourceEvent("addedFeatures",null,t)):Et().getSource().clear()}))}}const Ct=(e,...t)=>(t.forEach((t=>{Object.keys(t).forEach((o=>{const n=t[o],s=e[o];e[o]=s&&n&&"object"==typeof s&&"object"==typeof n&&!Array.isArray(s)?Ct(s,n):n}))})),e);class Ft extends t.Control{constructor(e){super({element:yt("div",{className:"ol-wfst--changes-control"},yt("div",{className:"ol-wfst--changes-control-el"},yt("div",{className:"ol-wfst--changes-control-id"},yt("b",null,Ne.labels.editMode)," -"," ",yt("i",null,String(e.getId()))),yt("button",{type:"button",className:"btn btn-sm btn-secondary",onclick:()=>{this.dispatchEvent(new c.VectorSourceEvent("cancel",e))}},Ne.labels.cancel),yt("button",{type:"button",className:"btn btn-sm btn-primary",onclick:()=>{this.dispatchEvent(new c.VectorSourceEvent("apply",e))}},Ne.labels.apply),yt("button",{type:"button",className:"btn btn-sm btn-danger-outline",onclick:()=>{this.dispatchEvent(new c.VectorSourceEvent("delete",e))}},Ne.labels.delete)))})}}function Lt(t){const o=e=>{let t=e.getGeometry();t instanceof f.GeometryCollection&&(t=t.getGeometries()[0]);const o=t.getCoordinates();let n=null;if(n=t instanceof f.Polygon||t instanceof f.MultiLineString?o.flat(1):t instanceof f.MultiPolygon?o.flat(2):o,n&&n.length)return new f.MultiPoint(n)};let n=t.getGeometry(),s=n.getType();switch(n instanceof f.GeometryCollection&&(n=n.getGeometries()[0],s=n.getType()),s){case Ke.Point:case Ke.MultiPoint:return tt()===Qe.Edit?[new e.Style({image:new e.Circle({radius:6,fill:new e.Fill({color:"#000000"})})}),new e.Style({image:new e.Circle({radius:4,fill:new e.Fill({color:"#ff0000"})})})]:[new e.Style({image:new e.Circle({radius:5,fill:new e.Fill({color:"#ff0000"})})}),new e.Style({image:new e.Circle({radius:2,fill:new e.Fill({color:"#000000"})})})];default:return tt()==Qe.Draw||tt()==Qe.Edit?[new e.Style({stroke:new e.Stroke({color:"rgba( 255, 0, 0, 1)",width:4}),fill:new e.Fill({color:"rgba(255, 0, 0, 0.7)"})}),new e.Style({image:new e.Circle({radius:4,fill:new e.Fill({color:"#ff0000"}),stroke:new e.Stroke({width:2,color:"rgba(5, 5, 5, 0.9)"})}),geometry:e=>o(e)}),new e.Style({stroke:new e.Stroke({color:"rgba(255, 255, 255, 0.7)",width:2})})]:[new e.Style({image:new e.Circle({radius:2,fill:new e.Fill({color:"#000000"})}),geometry:e=>o(e)}),new e.Style({stroke:new e.Stroke({color:"#ff0000",width:4}),fill:new e.Fill({color:"rgba(255, 0, 0, 0.7)"})})]}}class Tt extends q{_options;_modal;_feature;constructor(e){super(),this._options=e;const t=`\n <button type="button" class="btn btn-sm btn-link btn-third" data-action="delete" data-dismiss="modal">\n ${Ne.labels.delete}\n </button>\n <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">\n ${Ne.labels.cancel}\n </button>\n <button type="button" class="btn btn-sm btn-primary" data-action="save" data-dismiss="modal">\n ${Ne.labels.save}\n </button>\n `;this._modal=new Le({...this._options,header:!0,headerClose:!0,title:"",content:"<div></div>",footer:t}),this._modal.on("dismiss",((e,t)=>{if("save"===t.target.dataset.action){e.el.querySelectorAll("input").forEach((e=>{const t=e.value,o=e.name;this._feature.set(o,t,!0)})),this._feature.changed(),ct(this._feature),this.dispatchEvent(new c.VectorSourceEvent("save",this._feature))}else"delete"===t.target.dataset.action&&this.dispatchEvent(new c.VectorSourceEvent("delete",this._feature))}))}show(e){this._feature=e;const t=`${Ne.labels.editElement} ${e.getId()} `,o=e.getProperties(),n=lt(e.get("_layerName_")).getDescribeFeatureType()._parsed.properties;let s='<form autocomplete="false">';Object.keys(o).forEach((e=>{const t=n.find((t=>t.name===e));if(t){let n;switch(t.type){case"xsd:string":default:n="text";break;case"xsd:number":case"xsd:int":n="number";break;case"xsd:date-time":n="datetime"}n&&(s+=`\n <div class="ol-wfst--input-field-container">\n <label class="ol-wfst--input-field-label" for="${e}">${e}</label>\n <input placeholder="NULL" class="ol-wfst--input-field-input" type="${n}" name="${e}" value="${o[e]||""}">\n </div>`)}})),s+="</form>",this._modal._html.body.innerHTML=s,this._modal._html.header.innerHTML=t,this._modal.show()}}class kt extends T.default{_options;_countRequests;_insertFeatures;_updateFeatures;_deleteFeatures;_formatWFS;_formatGeoJSON;_formatKml;_xs;state_;constructor(e){super();const t={url:null,advanced:{getCapabilitiesVersion:"1.3.0",getFeatureVersion:"1.0.0",describeFeatureTypeVersion:"1.1.0",lockFeatureVersion:"1.1.0",wfsTransactionVersion:"1.1.0",projection:"EPSG:3857",lockFeatureParams:{expiry:5,lockId:"GeoServer",releaseAction:"SOME"}},headers:{},credentials:"same-origin",useLockFeature:!0};this._options=Ct(t,e),this.setAdvanced(this._options.advanced),this.setHeaders(this._options.headers),this.setCredentials(this._options.credentials),this.setUrl(this._options.url),this.setUseLockFeature(this._options.useLockFeature),this._countRequests=0,this._insertFeatures=[],this._updateFeatures=[],this._deleteFeatures=[],this._formatWFS=new p.WFS,this._formatGeoJSON=new p.GeoJSON,this._formatKml=new p.KML({extractStyles:!1,showPointNames:!1}),this._xs=new XMLSerializer,this.getAndUpdateCapabilities(),this.on("change:capabilities",(()=>{this._checkGeoserverCapabilities()}))}getCapabilities(){return this.get(Mt.CAPABILITIES)}setUrl(e,t=!1){this.set(Mt.URL,e,t)}getUrl(){return this.get(Mt.URL)}setHeaders(e={},t=!1){return this.set(Mt.HEADERS,e,t)}getHeaders(){return this.get(Mt.HEADERS)}setCredentials(e=null,t=!1){this.set(Mt.CREDENTIALS,e,t)}getCredentials(){return this.get(Mt.CREDENTIALS)}setAdvanced(e={},t=!1){this.set(Mt.ADVANCED,e,t)}getAdvanced(){return this.get(Mt.ADVANCED)}hasTransaction(){return this.get(Mt.HASTRASNACTION)}hasLockFeature(){return this.get(Mt.HASLOCKFEATURE)}getUseLockFeature(){return this.get(Mt.USELOCKFEATURE)}setUseLockFeature(e,t=!1){this.set(Mt.USELOCKFEATURE,e,t)}isLoaded(){return this.get(Mt.ISLOADED)}getState(){return this.state_}async getAndUpdateCapabilities(){try{const e=new URLSearchParams({service:"wfs",version:this.getAdvanced().getCapabilitiesVersion,request:"GetCapabilities",exceptions:"application/json"}),t=this.getUrl()+"?"+e.toString(),o=await fetch(t,{headers:this.getHeaders(),credentials:this.getCredentials()});if(!o.ok)throw new Error("");const n=await o.text(),s=(new window.DOMParser).parseFromString(n,"text/xml");return this.set(Mt.CAPABILITIES,s),this.state_=s?"ready":"error",s}catch(e){console.error(e);const t="string"==typeof e?e:Ne.errors.capabilities;Ae(t,e)}}_checkGeoserverCapabilities(){const e=this.getCapabilities().getElementsByTagName("ows:Operation");if(Array.from(e).forEach((e=>{"Transaction"===e.getAttribute("name")?this.set(Mt.HASTRASNACTION,!0):"LockFeature"===e.getAttribute("name")?this.set(Mt.HASLOCKFEATURE,!0):"DescribeFeatureType"===e.getAttribute("name")&&this.set(Mt.HASDESCRIBEFEATURETYPE,!0)})),!this.hasTransaction())throw Ne.errors.wfst}async transact(e,t,o){t=Array.isArray(t)?t:[t];const n=[],s=lt(o);for(const o of t){let t=this._cloneFeature(o);const i=t.getGeometry();i instanceof f.GeometryCollection?this._transformGeoemtryCollectionToGeometries(t,i):i instanceof f.Circle&&this._transformCircleToPolygon(t,i),"beforeTransactFeature"in s&&"function"==typeof s.beforeTransactFeature&&(t=s.beforeTransactFeature(t,e)),t&&n.push(t)}if(!n.length)return Ae(Ne.errors.noValidGeometry),!1;switch(e){case Ze.Insert:this._insertFeatures=[...this._insertFeatures,...n];break;case Ze.Update:this._updateFeatures=[...this._updateFeatures,...n];break;case Ze.Delete:this._deleteFeatures=[...this._deleteFeatures,...n]}this._countRequests++;const i=this._countRequests;return new Promise(((n,r)=>{setTimeout((async()=>{try{if(i!==this._countRequests)return;let r=st().getView().getProjection().getCode();r="EPSG:4326"===r?"urn:x-ogc:def:crs:EPSG:4326":r;const a=s.getDescribeFeatureType()._parsed;if(!s)throw new Error(Ne.errors.layerNotFound);const l={featureNS:a.namespace,featureType:o,srsName:r,featurePrefix:null,nativeElements:null,version:this.getAdvanced().wfsTransactionVersion},c=this._formatWFS.writeTransaction(this._insertFeatures,this._updateFeatures,this._deleteFeatures,l);let d=this._xs.serializeToString(c);const h=a.geomType,u=a.geomField;if(h===Ke.GeometryCollection)if(e===Ze.Insert)d=d.replace(/<geometry>/g,`<geometry><MultiGeometry xmlns="http://www.opengis.net/gml" srsName="${r}"><geometryMember>`),d=d.replace(/<\/geometry>/g,"</geometryMember></MultiGeometry></geometry>");else if(e===Ze.Update){const e=`<MultiGeometry xmlns="http://www.opengis.net/gml" srsName="${r}"><geometryMember>`,t="</geometryMember></MultiGeometry>";d=d.replace(/(.*)(<Name>geometry<\/Name><Value>)(.*?)(<\/Value>)(.*)/g,`$1$2${e}$3${t}$4$5`)}d=e===Ze.Insert?d.replace(/<(\/?)\bgeometry\b>/g,`<$1${u}>`):d.replace(/<Name>geometry<\/Name>/g,`<Name>${u}</Name>`),this.hasLockFeature&&this.getUseLockFeature()&&e!==Ze.Insert&&(d=d.replace("</Transaction>",`<LockId>${this._options.advanced.lockFeatureParams.lockId}</LockId></Transaction>`));const p={"Content-Type":"text/xml",...this.getHeaders()},m=await fetch(this.getUrl(),{method:"POST",body:d,headers:p,credentials:this._options.credentials});if(!m.ok)throw new Error(Ne.errors.transaction+" "+m.status);const f=this._formatWFS.readTransactionResponse(await m.text());if(!Object.keys(f).length){const e=await m.text(),t=String(e).match(/<ows:ExceptionText>([\s\S]*?)<\/ows:ExceptionText>/);if(t)throw new Error(t[1])}if(e!==Ze.Delete)for(const e of t)Et().getSource().removeFeature(e);lt(o).refresh(),Ie(!1),this._insertFeatures=[],this._updateFeatures=[],this._deleteFeatures=[],this._countRequests=0,n(f)}catch(e){Ae(e.message,e),Ie(!1),this._countRequests=0,r()}}),0)}))}_transformCircleToPolygon(e,t){const o=v.fromCircle(t);e.setGeometry(o)}_transformGeoemtryCollectionToGeometries(e,t){let o=t.getGeometries()[0];o instanceof f.Circle&&(o=v.fromCircle(o)),e.setGeometry(o)}_cloneFeature(e){dt(e);const t=e.getProperties();delete t.boundedBy,delete t._layerName_;const o=new X(t);return o.setId(e.getId()),o}async lockFeature(e,t,o=0){const n=new URLSearchParams({service:"wfs",version:this.getAdvanced().lockFeatureVersion,request:"LockFeature",typeName:t,expiry:String(this._options.advanced.lockFeatureParams.expiry),LockId:this._options.advanced.lockFeatureParams.lockId,releaseAction:this._options.advanced.lockFeatureParams.releaseAction,exceptions:"application/json",featureid:`${e}`}),s=this.getUrl()+"?"+n.toString();try{const n=await fetch(s,{headers:this._options.headers,credentials:this._options.credentials});if(!n.ok)throw new Error(Ne.errors.lockFeature);const i=await n.text();try{const n=JSON.parse(i);if("exceptions"in n){const s=n.exceptions;"CannotLockAllFeatures"===s[0].code?o?Ae(Ne.errors.lockFeature,s):this.lockFeature(e,t,1):Ae(s[0].text,s)}}catch(e){}return i}catch(e){Ae(e.message,e)}}}var Mt;!function(e){e.CAPABILITIES="capabilities",e.URL="url",e.HEADERS="headers",e.CREDENTIALS="credentials",e.ADVANCED="advanced",e.HASTRASNACTION="hasTransaction",e.HASLOCKFEATURE="hasLockFeature",e.HASDESCRIBEFEATURETYPE="hasDescribeFeatureType",e.USELOCKFEATURE="useLockFeature",e.ISLOADED="isLoaded"}(Mt||(Mt={}));class At extends he{constructor(e,t=null){super({id:e.getId(),position:t||y.getCenter(e.getGeometry().getExtent()),positioning:"center-center",offset:[0,-40],stopEvent:!0,element:yt("div",null,yt("div",{className:"ol-wfst--edit-button-cnt",onclick:()=>{this.dispatchEvent("editFields")}},yt("button",{className:"ol-wfst--edit-button",type:"button",title:Ne.labels.editFields},yt("img",{src:"data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='448' height='448' viewBox='0 0 448 448'%3e %3cpath d='M222 296l29-29-38-38-29 29v14h24v24h14zM332 116c-2.25-2.25-6-2-8.25 0.25l-87.5 87.5c-2.25 2.25-2.5 6-0.25 8.25s6 2 8.25-0.25l87.5-87.5c2.25-2.25 2.5-6 0.25-8.25zM352 264.5v47.5c0 39.75-32.25 72-72 72h-208c-39.75 0-72-32.25-72-72v-208c0-39.75 32.25-72 72-72h208c10 0 20 2 29.25 6.25 2.25 1 4 3.25 4.5 5.75 0.5 2.75-0.25 5.25-2.25 7.25l-12.25 12.25c-2.25 2.25-5.25 3-8 2-3.75-1-7.5-1.5-11.25-1.5h-208c-22 0-40 18-40 40v208c0 22 18 40 40 40h208c22 0 40-18 40-40v-31.5c0-2 0.75-4 2.25-5.5l16-16c2.5-2.5 5.75-3 8.75-1.75s5 4 5 7.25zM328 80l72 72-168 168h-72v-72zM439 113l-23 23-72-72 23-23c9.25-9.25 24.75-9.25 34 0l38 38c9.25 9.25 9.25 24.75 0 34z'%3e%3c/path%3e%3c/svg%3e",alt:Ne.labels.editFields}))),yt("div",{className:"ol-wfst--edit-button-cnt",onclick:()=>{this.dispatchEvent("editGeom")}},yt("button",{class:"ol-wfst--edit-button",type:"button",title:Ne.labels.editGeom},yt("img",{src:"data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='541' height='512' viewBox='0 0 541 512'%3e %3cpath fill='black' d='M103.306 228.483l129.493-125.249c-17.662-4.272-31.226-18.148-34.98-35.663l-0.055-0.307-129.852 125.248c17.812 4.15 31.53 18.061 35.339 35.662l0.056 0.308z'%3e%3c/path%3e %3cpath fill='black' d='M459.052 393.010c-13.486-8.329-22.346-23.018-22.373-39.779v-0.004c-0.053-0.817-0.082-1.772-0.082-2.733s0.030-1.916 0.089-2.863l-0.007 0.13-149.852 71.94c9.598 8.565 15.611 20.969 15.611 34.779 0 0.014 0 0.029 0 0.043v-0.002c-0.048 5.164-0.94 10.104-2.544 14.711l0.098-0.322z'%3e%3c/path%3e %3cpath fill='black' d='M290.207 57.553c-0.009 15.55-7.606 29.324-19.289 37.819l-0.135 0.093 118.054 46.69c-0.216-1.608-0.346-3.48-0.36-5.379v-0.017c0.033-16.948 9.077-31.778 22.596-39.953l0.209-0.118-122.298-48.056c0.659 2.633 1.098 5.693 1.221 8.834l0.002 0.087z'%3e%3c/path%3e %3cpath fill='black' d='M241.36 410.132l-138.629-160.067c-4.734 17.421-18.861 30.61-36.472 33.911l-0.29 0.045 143.881 166.255c1.668-18.735 14.197-34.162 31.183-40.044l0.327-0.099z'%3e%3c/path%3e %3cpath fill='black' d='M243.446 115.105c-31.785 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.785 0 57.552 25.767 57.552 57.553v0c0 31.786-25.767 57.553-57.553 57.553v0zM243.446 21.582c-19.866 0-35.97 16.105-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c0-19.866-16.104-35.97-35.97-35.97v0z'%3e%3c/path%3e %3cpath fill='black' d='M483.224 410.78c-31.786 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.786 0 57.552 25.767 57.552 57.553v0c0 31.786-25.767 57.553-57.553 57.553v0zM483.224 317.257c-19.866 0-35.97 16.104-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c0-19.866-16.105-35.97-35.97-35.97v0z'%3e%3c/path%3e %3cpath fill='black' d='M57.553 295.531c-31.785 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.785 0 57.553 25.767 57.553 57.553v0c0 31.786-25.767 57.553-57.553 57.553v0zM57.553 202.008c-19.866 0-35.97 16.105-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c-0.041-19.835-16.13-35.898-35.97-35.898 0 0 0 0 0 0v0z'%3e%3c/path%3e %3cpath fill='black' d='M256.036 512.072c-31.786 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.786 0 57.553 25.767 57.553 57.553v0c0 31.786-25.767 57.553-57.553 57.553v0zM256.036 418.55c-19.866 0-35.97 16.104-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c0-19.866-16.105-35.97-35.97-35.97v0z'%3e%3c/path%3e %3cpath fill='black' d='M435.24 194.239c-31.786 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.786 0 57.553 25.767 57.553 57.553v0c0 31.785-25.767 57.553-57.553 57.553v0zM435.24 100.716c-19.866 0-35.97 16.105-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c0-19.866-16.105-35.97-35.97-35.97v0z'%3e%3c/path%3e%3c/svg%3e",alt:Ne.labels.editGeom}))))})}}const Pt=document.createElement("div");class xt extends t.Control{_options;_i18n;_map;_view;_viewport;_initialized=!1;_layersControl;_overlay;_interactionWfsSelect;_interactionSelectModify;_collectionModify;_interactionModify;_interactionSnap;_interactionDraw;_keyClickWms;_keyRemove;_keySelect;_controlApplyDiscardChanges;_controlWidgetToolsDiv;_selectDraw;_currentZoom;_lastZoom;_editFeature;_editFeatureOriginal;_uploads;_editFields;constructor(e){super({target:null,element:Pt,render:()=>{this._map||this._init()}}),((e="en",t=null)=>{e in xe&&(Ne=xe[e]),t&&(Ne={...Ne,...t})})(e.language,e.i18n);const t={layers:null,evtType:"singleclick",active:!0,showControl:!0,language:"en",uploadFormats:".geojson,.json,.kml",processUpload:null,modal:{animateClass:"fade",animateInClass:"show",transition:300,backdropTransition:150,templates:{dialog:'<div class="modal-dialog modal-dialog-centered"></div>',headerClose:`<button type="button" class="btn-close" data-dismiss="modal" aria-label="${Ne.labels.close}"><span aria-hidden="true">×</span></button>`}}};this._options=Ct(t,e),it(this._options.layers[0]),this._controlWidgetToolsDiv=Pt,this._controlWidgetToolsDiv.className="ol-wfst--tools-control",this._uploads=new St(this._options),this._editFields=new Tt(this._options.modal)}getLayers(){return Object.values(at())}getLayerByName(e=""){const t=at();return e&&e in t?t[e]:null}async _initMapAndLayers(){try{const e=this._options.layers;if(e.length){let t=0,o=0;e.forEach((e=>{var n;e.getVisible()&&o++,e.on("layerRendered",(()=>{t++,t>=o&&(this._initialized||(this.dispatchEvent("load"),this._initialized=!0),Ie(!1))})),e.on("change:describeFeatureType",(()=>{const t=this._layersControl.addLayerEl(e);e.on("change:isVisible",(()=>{const o="ol-wfst--layer-not-visible";e.isVisibleByZoom()?t.classList.remove(o):t.classList.add(o)})),e.set(pt.ISVISIBLE,this._currentZoom>e.getMinZoom()),this.dispatchEvent(new Nt({type:"describeFeatureType",layer:e,data:e.getDescribeFeatureType()}))})),e._init(),this._map.addLayer(e),n={[e.get(pt.NAME)]:e},Object.assign(nt,n)})),this._createMapElements(this._options.showControl,this._options.active)}}catch(e){Ie(!1),Ae(e.message,e)}}_init(){var e,t;this._map=super.getMap(),this._view=this._map.getView(),this._viewport=this._map.getViewport(),e=this._map,Je=e,this._uploads.on("addedFeatures",(({features:e})=>{rt().insertFeatures(e)})),this._uploads.on("loadedFeatures",(({features:e})=>{this.activateEditMode();const t=Et().getSource();t.addFeatures(e),this._view.fit(t.getExtent(),{size:this._map.getSize(),maxZoom:21,padding:[100,100,100,100]})})),this._editFields.on("save",(({feature:e})=>{this._collectionModify.remove(e)})),this._editFields.dispose("delete",(({feature:e})=>{this._deleteFeature(e,!0)})),this._addMapEvents(),t=this._options.modal,Te=t,this._controlWidgetToolsDiv.append((Oe=document.createElement("div"),Oe.className="ol-wfst--tools-control--loading",Oe.innerHTML=Ne.labels.loading,Oe)),this._initMapAndLayers()}async _createMapElements(e,t){this._prepareEditLayer(),this._addInteractions(),this._addInteractionHandlers(),e&&this._addMapControl(),this.activateEditMode(t)}_addInteractions(){const t=()=>{this._collectionModify=new J,this._interactionWfsSelect=new o.Select({hitTolerance:10,style:e=>Lt(e),toggleCondition:s.never,filter:(e,t)=>tt()!==Qe.Edit&&t&&t instanceof ft&&t===rt()}),this._map.addInteraction(this._interactionWfsSelect),this._interactionWfsSelect.on("select",(({selected:e,deselected:t,mapBrowserEvent:o})=>{const n=o.coordinate;e.length&&e.forEach((e=>{if(!ht(e)){const t=this._interactionWfsSelect.getLayer(e);t.getSource().removeFeature(e),this._addFeatureToEditMode(e,n,t.get(pt.NAME))}})),t.length&&tt()!==Qe.Edit&&t.forEach((e=>{this._collectionModify.remove(e)}))}))},n=()=>{this._interactionSelectModify=new o.Select({style:e=>Lt(e),layers:[Et()],toggleCondition:s.never,removeCondition:()=>tt()===Qe.Edit}),this._map.addInteraction(this._interactionSelectModify),this._collectionModify=this._interactionSelectModify.getFeatures(),this._keyClickWms=this._map.on(this._options.evtType,(async e=>{if(!this._map.hasFeatureAtPixel(e.pixel)&&tt()!==Qe.Edit){const t=rt();if(!t.getVisible()||!t.isVisibleByZoom()||t instanceof ft)return;const o=await t._getFeaturesByClickEvent(e);if(!o.length)return;this._addFeatureToEditMode(o[0],e.coordinate,t.get(pt.NAME))}}))};this._options.layers.find((e=>e instanceof ft))&&t(),this._options.layers.find((e=>e instanceof vt))&&n(),this._interactionModify=new o.Modify({style:()=>tt()===Qe.Edit?new e.Style({image:new e.Circle({radius:6,fill:new e.Fill({color:"#ff0000"}),stroke:new e.Stroke({width:2,color:"rgba(5, 5, 5, 0.9)"})})}):void 0,features:this._collectionModify,condition:e=>s.primaryAction(e)&&tt()===Qe.Edit}),this._map.addInteraction(this._interactionModify),this._interactionSnap=new o.Snap({source:Et().getSource()}),this._map.addInteraction(this._interactionSnap)}_prepareEditLayer(){this._map.addLayer(Et())}_addMapEvents(){(()=>{document.addEventListener("keydown",(({key:e})=>{if(!document.querySelector("input:focus")&&"Delete"===e){const e=this._collectionModify;e&&e.forEach((e=>{this._deleteFeature(e,!0)}))}}))})(),this._map.on("moveend",(()=>{if(this._currentZoom=this._view.getZoom(),this._currentZoom!==this._lastZoom){const e=at();Object.keys(e).forEach((t=>{const o=e[t];this._currentZoom>o.getMinZoom()?o.get(pt.ISVISIBLE)||o.set(pt.ISVISIBLE,!0):o.get(pt.ISVISIBLE)&&o.set(pt.ISVISIBLE,!1)})),this._lastZoom=this._currentZoom}}))}_addInteractionHandlers(){this._interactionModify.on("modifyend",(e=>{ct(e.features.item(0)),super.dispatchEvent(e)})),this._interactionModify.on("modifystart",(e=>{super.dispatchEvent(e)})),this._onDeselectFeatureEvent(),this._onRemoveFeatureEvent()}_addMapControl(){this._layersControl=new bt(this._options.showUpload?this._uploads:null,this._options.uploadFormats),this._layersControl.on("drawMode",(()=>{if(tt()===Qe.Draw)_t(),this.activateEditMode();else{rt().isVisibleByZoom()?this.activateDrawMode(rt()):Ae(Ne.errors.layerNotVisible)}})),this._layersControl.on("changeGeom",(()=>{tt()===Qe.Draw&&this.activateDrawMode(rt())}));const e=this._layersControl.render();this._selectDraw=e.querySelector(".wfst--tools-control--select-draw"),this._controlWidgetToolsDiv.append(e)}_deselectEditFeature(e){this._removeOverlayHelper(e)}_restoreFeatureToLayer(e,t){t=t||e.get("_layerName_");at()[t].getSource().addFeature(e)}_removeFeatureFromTmpLayer(e){Et().getSource().removeFeature(e)}_onDeselectFeatureEvent(){const e=e=>{const t=e.get("_layerName_"),o=this._options.layers.find((e=>e.get(pt.NAME)===t));o instanceof ft&&this._interactionWfsSelect.getFeatures().remove(e),ht(e)?o.transactFeatures(Ze.Update,e):(o instanceof ft&&this._restoreFeatureToLayer(e,t),this._removeFeatureFromTmpLayer(e))};this._keySelect=this._collectionModify.on("remove",(t=>{const o=t.element;this._deselectEditFeature(o),e(o),this._editModeOff()}))}_onRemoveFeatureEvent(){this._keyRemove=Et().getSource().on("removefeature",(e=>{const t=e.feature;if(!t.get("_delete_"))return;this._keySelect&&i.unByKey(this._keySelect);const o=t.get("_layerName_");this.getLayerByName(o).transactFeatures(Ze.Delete,t),this._deselectEditFeature(t),this._editModeOff(),this._keySelect&&setTimeout((()=>{this._onDeselectFeatureEvent()}),150)}))}_editModeOn(e){this._editFeatureOriginal=e.clone(),et(Qe.Edit),Et().getSource().changed(),this._removeOverlayHelper(e),this._controlApplyDiscardChanges=new Ft(e),this._controlApplyDiscardChanges.on("cancel",(({feature:e})=>{e.setGeometry(this._editFeatureOriginal.getGeometry()),dt(e),this._collectionModify.remove(e)})),this._controlApplyDiscardChanges.on("apply",(({feature:e})=>{Ie(),this._collectionModify.remove(e)})),this._controlApplyDiscardChanges.on("delete",(({feature:e})=>{this._deleteFeature(e,!0)})),this._map.addControl(this._controlApplyDiscardChanges)}_editModeOff(){et(null),this._map.removeControl(this._controlApplyDiscardChanges)}_deleteFeature(e,t){const o=()=>{(Array.isArray(e)?e:[e]).forEach((e=>{e.set("_delete_",!0,!0),Et().getSource().removeFeature(e)})),this._collectionModify.clear();const t=e.get("_layerName_");this._options.layers.find((e=>e.get(pt.NAME)===t))instanceof ft&&this._interactionWfsSelect.getFeatures().remove(e)};if(t){Le.confirm(Ne.labels.confirmDelete,{...this._options.modal}).show().once("dismiss",(function(e,t,n){n&&n.value&&o()}))}else o()}_addFeatureToEditMode(e,t=null,o=null){if(this._collectionModify.getLength())return;o&&e.set("_layerName_",o);if((e?e.getProperties():"")&&e.getGeometry()){Et().getSource().addFeature(e),this._collectionModify.push(e);const n=new At(e,t);n.on("editFields",(()=>{this._editFields.show(e)})),n.on("editGeom",(()=>{this._editModeOn(e)})),this._map.addOverlay(n);const s=lt(o);s&&s.maybeLockFeature(e.getId())}}activateDrawMode(e){const t=e=>{this.activateEditMode(!1),this._interactionDraw&&this._map.removeInteraction(this._interactionDraw);const t=this._selectDraw.value;this._interactionDraw=new o.Draw({source:Et().getSource(),type:t,style:e=>Lt(e),stopClick:!0}),this._map.addInteraction(this._interactionDraw),this._interactionDraw.on("drawstart",(e=>{super.dispatchEvent(e)})),this._interactionDraw.on("drawend",(t=>{const o=t.feature;e.transactFeatures(Ze.Insert,o),super.dispatchEvent(t)}))};if(this._interactionDraw||e){if(e){if(!e.getVisible())return;(()=>{const e=document.querySelector(".ol-wfst--tools-control-btn-draw");e&&e.classList.add("wfst--active")})(),this._viewport.classList.add("draw-mode"),t(e)}else this._map.removeInteraction(this._interactionDraw),this._viewport.classList.remove("draw-mode");et(e?Qe.Draw:null)}}activateEditMode(e=!0){e?((()=>{const e=document.querySelector(".ol-wfst--tools-control-btn-edit");e&&e.classList.add("wfst--active")})(),this.activateDrawMode(!1)):this._collectionModify.clear(),this._interactionSelectModify&&this._interactionSelectModify.setActive(e),this._interactionModify.setActive(e),this._interactionWfsSelect&&this._interactionWfsSelect.setActive(e)}_removeOverlayHelper(e){const t=e.getId();if(!t)return;const o=this._map.getOverlayById(t);o&&this._map.removeOverlay(o)}}class Nt extends b.default{data;layer;constructor(e){super(e.type),this.layer=e.layer,this.data=e.data}}var Ot={WfsLayer:ft,WmsLayer:vt,Geoserver:kt};return Object.assign(xt,Ot),xt}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("ol/style"),require("ol/control"),require("ol/interaction"),require("ol/events/Event"),require("ol/events/condition"),require("ol/Observable"),require("ol/layer/Vector"),require("ol/layer/Base"),require("ol/format/GeoJSON"),require("ol/source/Vector"),require("ol/proj"),require("ol/loadingstrategy"),require("ol/layer/Tile"),require("ol/format"),require("ol/source/TileWMS"),require("ol/geom"),require("ol/Object"),require("ol/geom/Polygon"),require("ol/extent")):"function"==typeof define&&define.amd?define(["ol/style","ol/control","ol/interaction","ol/events/Event","ol/events/condition","ol/Observable","ol/layer/Vector","ol/layer/Base","ol/format/GeoJSON","ol/source/Vector","ol/proj","ol/loadingstrategy","ol/layer/Tile","ol/format","ol/source/TileWMS","ol/geom","ol/Object","ol/geom/Polygon","ol/extent"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Wfst=t(e.ol.style,e.ol.control,e.ol.interaction,e.ol.events.Event,e.ol.events.condition,e.ol.Observable,e.ol.layer.Vector,e.ol.layer.Base,e.ol.format.GeoJSON,e.ol.source.Vector,e.ol.proj,e.ol.loadingstrategy,e.ol.layer.Tile,e.ol.format,e.ol.source.TileWMS,e.ol.geom,e.ol.Object,e.ol.geom.Polygon,e.ol.extent)}(this,(function(e,t,s,o,i,n,r,a,l,c,d,h,u,p,m,g,f,y,v){"use strict";const _={1:"The view center is not defined",2:"The view resolution is not defined",3:"The view rotation is not defined",4:"`image` and `src` cannot be provided at the same time",5:"`imgSize` must be set when `image` is provided",7:"`format` must be set when `url` is set",8:"Unknown `serverType` configured",9:"`url` must be configured or set using `#setUrl()`",10:"The default `geometryFunction` can only handle `Point` geometries",11:"`options.featureTypes` must be an Array",12:"`options.geometryName` must also be provided when `options.bbox` is set",13:"Invalid corner",14:"Invalid color",15:"Tried to get a value for a key that does not exist in the cache",16:"Tried to set a value for a key that is used already",17:"`resolutions` must be sorted in descending order",18:"Either `origin` or `origins` must be configured, never both",19:"Number of `tileSizes` and `resolutions` must be equal",20:"Number of `origins` and `resolutions` must be equal",22:"Either `tileSize` or `tileSizes` must be configured, never both",24:"Invalid extent or geometry provided as `geometry`",25:"Cannot fit empty extent provided as `geometry`",26:"Features must have an id set",27:"Features must have an id set",28:'`renderMode` must be `"hybrid"` or `"vector"`',30:"The passed `feature` was already added to the source",31:"Tried to enqueue an `element` that was already added to the queue",32:"Transformation matrix cannot be inverted",33:"Invalid units",34:"Invalid geometry layout",36:"Unknown SRS type",37:"Unknown geometry type found",38:"`styleMapValue` has an unknown type",39:"Unknown geometry type",40:"Expected `feature` to have a geometry",41:"Expected an `ol/style/Style` or an array of `ol/style/Style.js`",42:"Question unknown, the answer is 42",43:"Expected `layers` to be an array or a `Collection`",47:"Expected `controls` to be an array or an `ol/Collection`",48:"Expected `interactions` to be an array or an `ol/Collection`",49:"Expected `overlays` to be an array or an `ol/Collection`",50:"`options.featureTypes` should be an Array",51:"Either `url` or `tileJSON` options must be provided",52:"Unknown `serverType` configured",53:"Unknown `tierSizeCalculation` configured",55:"The {-y} placeholder requires a tile grid with extent",56:"mapBrowserEvent must originate from a pointer event",57:"At least 2 conditions are required",59:"Invalid command found in the PBF",60:"Missing or invalid `size`",61:"Cannot determine IIIF Image API version from provided image information JSON",62:"A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`",64:"Layer opacity must be a number",66:"`forEachFeatureAtCoordinate` cannot be used on a WebGL layer if the hit detection logic has not been enabled. This is done by providing adequate shaders using the `hitVertexShader` and `hitFragmentShader` properties of `WebGLPointsLayerRenderer`",67:"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both",68:"A VectorTile source can only be rendered if it has a projection compatible with the view projection"};class b extends Error{constructor(e){const t=_[e];super(t),this.code=e,this.name="AssertionError",this.message=t}}var w=b;var E=class{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}},S="propertychange";var C=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}};function F(){}function L(e){for(const t in e)delete e[t]}var T=class extends C{constructor(e){super(),this.eventTarget_=e,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(e,t){if(!e||!t)return;const s=this.listeners_||(this.listeners_={}),o=s[e]||(s[e]=[]);o.includes(t)||o.push(t)}dispatchEvent(e){const t="string"==typeof e,s=t?e:e.type,o=this.listeners_&&this.listeners_[s];if(!o)return;const i=t?new E(e):e;i.target||(i.target=this.eventTarget_||this);const n=this.dispatching_||(this.dispatching_={}),r=this.pendingRemovals_||(this.pendingRemovals_={});let a;s in n||(n[s]=0,r[s]=0),++n[s];for(let e=0,t=o.length;e<t;++e)if(a="handleEvent"in o[e]?o[e].handleEvent(i):o[e].call(this,i),!1===a||i.propagationStopped){a=!1;break}if(0==--n[s]){let e=r[s];for(delete r[s];e--;)this.removeEventListener(s,F);delete n[s]}return a}disposeInternal(){this.listeners_&&L(this.listeners_)}getListeners(e){return this.listeners_&&this.listeners_[e]||void 0}hasListener(e){return!!this.listeners_&&(e?e in this.listeners_:Object.keys(this.listeners_).length>0)}removeEventListener(e,t){const s=this.listeners_&&this.listeners_[e];if(s){const o=s.indexOf(t);-1!==o&&(this.pendingRemovals_&&e in this.pendingRemovals_?(s[o]=F,++this.pendingRemovals_[e]):(s.splice(o,1),0===s.length&&delete this.listeners_[e]))}}},M="change";function k(e,t,s,o,i){if(o&&o!==e&&(s=s.bind(o)),i){const o=s;s=function(){e.removeEventListener(t,s),o.apply(this,arguments)}}const n={target:e,type:t,listener:s};return e.addEventListener(t,s),n}function A(e,t,s,o){return k(e,t,s,o,!0)}function P(e){e&&e.target&&(e.target.removeEventListener(e.type,e.listener),L(e))}class x extends T{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(M)}getRevision(){return this.revision_}onInternal(e,t){if(Array.isArray(e)){const s=e.length,o=new Array(s);for(let i=0;i<s;++i)o[i]=k(this,e[i],t);return o}return k(this,e,t)}onceInternal(e,t){let s;if(Array.isArray(e)){const o=e.length;s=new Array(o);for(let i=0;i<o;++i)s[i]=A(this,e[i],t)}else s=A(this,e,t);return t.ol_key=s,s}unInternal(e,t){const s=t.ol_key;if(s)!function(e){if(Array.isArray(e))for(let t=0,s=e.length;t<s;++t)P(e[t]);else P(e)}(s);else if(Array.isArray(e))for(let s=0,o=e.length;s<o;++s)this.removeEventListener(e[s],t);else this.removeEventListener(e,t)}}x.prototype.on,x.prototype.once,x.prototype.un;var N=x;let I=0;class O extends E{constructor(e,t,s){super(e),this.key=t,this.oldValue=s}}var G=class extends N{constructor(e){var t;super(),this.on,this.once,this.un,(t=this).ol_uid||(t.ol_uid=String(++I)),this.values_=null,void 0!==e&&this.setProperties(e)}get(e){let t;return this.values_&&this.values_.hasOwnProperty(e)&&(t=this.values_[e]),t}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}hasProperties(){return!!this.values_}notify(e,t){let s;s=`change:${e}`,this.hasListener(s)&&this.dispatchEvent(new O(s,e,t)),s=S,this.hasListener(s)&&this.dispatchEvent(new O(s,e,t))}addChangeListener(e,t){this.addEventListener(`change:${e}`,t)}removeChangeListener(e,t){this.removeEventListener(`change:${e}`,t)}set(e,t,s){const o=this.values_||(this.values_={});if(s)o[e]=t;else{const s=o[e];o[e]=t,s!==t&&this.notify(e,s)}}setProperties(e,t){for(const s in e)this.set(s,e[s],t)}applyProperties(e){e.values_&&Object.assign(this.values_||(this.values_={}),e.values_)}unset(e,t){if(this.values_&&e in this.values_){const s=this.values_[e];delete this.values_[e],function(e){let t;for(t in e)return!1;return!t}(this.values_)&&(this.values_=null),t||this.notify(e,s)}}},D="add",R="remove";const V="length";class U extends E{constructor(e,t,s){super(e),this.element=t,this.index=s}}var q=class extends G{constructor(e,t){if(super(),this.on,this.once,this.un,t=t||{},this.unique_=!!t.unique,this.array_=e||[],this.unique_)for(let e=0,t=this.array_.length;e<t;++e)this.assertUnique_(this.array_[e],e);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(e){for(let t=0,s=e.length;t<s;++t)this.push(e[t]);return this}forEach(e){const t=this.array_;for(let s=0,o=t.length;s<o;++s)e(t[s],s,t)}getArray(){return this.array_}item(e){return this.array_[e]}getLength(){return this.get(V)}insertAt(e,t){if(e<0||e>this.getLength())throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t),this.array_.splice(e,0,t),this.updateLength_(),this.dispatchEvent(new U(D,t,e))}pop(){return this.removeAt(this.getLength()-1)}push(e){this.unique_&&this.assertUnique_(e);const t=this.getLength();return this.insertAt(t,e),this.getLength()}remove(e){const t=this.array_;for(let s=0,o=t.length;s<o;++s)if(t[s]===e)return this.removeAt(s)}removeAt(e){if(e<0||e>=this.getLength())return;const t=this.array_[e];return this.array_.splice(e,1),this.updateLength_(),this.dispatchEvent(new U(R,t,e)),t}setAt(e,t){if(e>=this.getLength())return void this.insertAt(e,t);if(e<0)throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t,e);const s=this.array_[e];this.array_[e]=t,this.dispatchEvent(new U(R,s,e)),this.dispatchEvent(new U(D,t,e))}updateLength_(){this.set(V,this.array_.length)}assertUnique_(e,t){for(let s=0,o=this.array_.length;s<o;++s)if(this.array_[s]===e&&s!==t)throw new w(58)}};class j extends G{constructor(e){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),e)if("function"==typeof e.getSimplifiedGeometry){const t=e;this.setGeometry(t)}else{const t=e;this.setProperties(t)}}clone(){const e=new j(this.hasProperties()?this.getProperties():null);e.setGeometryName(this.getGeometryName());const t=this.getGeometry();t&&e.setGeometry(t.clone());const s=this.getStyle();return s&&e.setStyle(s),e}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(P(this.geometryChangeKey_),this.geometryChangeKey_=null);const e=this.getGeometry();e&&(this.geometryChangeKey_=k(e,M,this.handleGeometryChange_,this)),this.changed()}setGeometry(e){this.set(this.geometryName_,e)}setStyle(e){this.style_=e,this.styleFunction_=e?function(e){if("function"==typeof e)return e;{let t;if(Array.isArray(e))t=e;else{!function(e,t){if(!e)throw new w(t)}("function"==typeof e.getZIndex,41);t=[e]}return function(){return t}}}(e):void 0,this.changed()}setId(e){this.id_=e,this.changed()}setGeometryName(e){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=e,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}}var H=j;function z(e){let t=e.offsetWidth;const s=getComputedStyle(e);return t+=parseInt(s.marginLeft,10)+parseInt(s.marginRight,10),t}function B(e){let t=e.offsetHeight;const s=getComputedStyle(e);return t+=parseInt(s.marginTop,10)+parseInt(s.marginBottom,10),t}var $=2,W=3,K="postrender";const Z="element",J="map",Y="offset",X="position",Q="positioning";var ee=class extends G{constructor(e){super(),this.on,this.once,this.un,this.options=e,this.id=e.id,this.insertFirst=void 0===e.insertFirst||e.insertFirst,this.stopEvent=void 0===e.stopEvent||e.stopEvent,this.element=document.createElement("div"),this.element.className=void 0!==e.className?e.className:"ol-overlay-container ol-selectable",this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=!0===e.autoPan?{}:e.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(Z,this.handleElementChanged),this.addChangeListener(J,this.handleMapChanged),this.addChangeListener(Y,this.handleOffsetChanged),this.addChangeListener(X,this.handlePositionChanged),this.addChangeListener(Q,this.handlePositioningChanged),void 0!==e.element&&this.setElement(e.element),this.setOffset(void 0!==e.offset?e.offset:[0,0]),this.setPositioning(e.positioning||"top-left"),void 0!==e.position&&this.setPosition(e.position)}getElement(){return this.get(Z)}getId(){return this.id}getMap(){return this.get(J)||null}getOffset(){return this.get(Y)}getPosition(){return this.get(X)}getPositioning(){return this.get(Q)}handleElementChanged(){!function(e){for(;e.lastChild;)e.removeChild(e.lastChild)}(this.element);const e=this.getElement();e&&this.element.appendChild(e)}handleMapChanged(){var e;this.mapPostrenderListenerKey&&((e=this.element)&&e.parentNode&&e.parentNode.removeChild(e),P(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const t=this.getMap();if(t){this.mapPostrenderListenerKey=k(t,K,this.render,this),this.updatePixelPosition();const e=this.stopEvent?t.getOverlayContainerStopEvent():t.getOverlayContainer();this.insertFirst?e.insertBefore(this.element,e.childNodes[0]||null):e.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(e){this.set(Z,e)}setMap(e){this.set(J,e)}setOffset(e){this.set(Y,e)}setPosition(e){this.set(X,e)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(e){const t=this.getMap();if(!t||!t.getTargetElement()||!this.get(X))return;const s=this.getRect(t.getTargetElement(),t.getSize()),o=this.getElement(),i=this.getRect(o,[z(o),B(o)]),n=void 0===(e=e||{}).margin?20:e.margin;if(a=i,!((r=s)[0]<=a[0]&&a[2]<=r[2]&&r[1]<=a[1]&&a[3]<=r[3])){const o=i[0]-s[0],r=s[2]-i[2],a=i[1]-s[1],l=s[3]-i[3],c=[0,0];if(o<0?c[0]=o-n:r<0&&(c[0]=Math.abs(r)+n),a<0?c[1]=a-n:l<0&&(c[1]=Math.abs(l)+n),0!==c[0]||0!==c[1]){const s=t.getView().getCenterInternal(),o=t.getPixelFromCoordinateInternal(s);if(!o)return;const i=[o[0]+c[0],o[1]+c[1]],n=e.animation||{};t.getView().animateInternal({center:t.getCoordinateFromPixelInternal(i),duration:n.duration,easing:n.easing})}}var r,a}getRect(e,t){const s=e.getBoundingClientRect(),o=s.left+window.pageXOffset,i=s.top+window.pageYOffset;return[o,i,o+t[0],i+t[1]]}setPositioning(e){this.set(Q,e)}setVisible(e){this.rendered.visible!==e&&(this.element.style.display=e?"":"none",this.rendered.visible=e)}updatePixelPosition(){const e=this.getMap(),t=this.getPosition();if(!e||!e.isRendered()||!t)return void this.setVisible(!1);const s=e.getPixelFromCoordinate(t),o=e.getSize();this.updateRenderedPosition(s,o)}updateRenderedPosition(e,t){const s=this.element.style,o=this.getOffset(),i=this.getPositioning();this.setVisible(!0);let n="0%",r="0%";"bottom-right"==i||"center-right"==i||"top-right"==i?n="-100%":"bottom-center"!=i&&"center-center"!=i&&"top-center"!=i||(n="-50%"),"bottom-left"==i||"bottom-center"==i||"bottom-right"==i?r="-100%":"center-left"!=i&&"center-center"!=i&&"center-right"!=i||(r="-50%");const a=`translate(${n}, ${r}) translate(${Math.round(e[0]+o[0])+"px"}, ${Math.round(e[1]+o[1])+"px"})`;this.rendered.transform_!=a&&(this.rendered.transform_=a,s.transform=a)}getOptions(){return this.options}};function te(){}function se(){se.init.call(this)}function oe(e){return void 0===e._maxListeners?se.defaultMaxListeners:e._maxListeners}function ie(e,t,s,o){var i,n,r,a;if("function"!=typeof s)throw new TypeError('"listener" argument must be a function');if((n=e._events)?(n.newListener&&(e.emit("newListener",t,s.listener?s.listener:s),n=e._events),r=n[t]):(n=e._events=new te,e._eventsCount=0),r){if("function"==typeof r?r=n[t]=o?[s,r]:[r,s]:o?r.unshift(s):r.push(s),!r.warned&&(i=oe(e))&&i>0&&r.length>i){r.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=r.length,a=l,"function"==typeof console.warn?console.warn(a):console.log(a)}}else r=n[t]=s,++e._eventsCount;return e}function ne(e,t,s){var o=!1;function i(){e.removeListener(t,i),o||(o=!0,s.apply(e,arguments))}return i.listener=s,i}function re(e){var t=this._events;if(t){var s=t[e];if("function"==typeof s)return 1;if(s)return s.length}return 0}function ae(e,t){for(var s=new Array(t);t--;)s[t]=e[t];return s}te.prototype=Object.create(null),se.EventEmitter=se,se.usingDomains=!1,se.prototype.domain=void 0,se.prototype._events=void 0,se.prototype._maxListeners=void 0,se.defaultMaxListeners=10,se.init=function(){this.domain=null,se.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new te,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},se.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},se.prototype.getMaxListeners=function(){return oe(this)},se.prototype.emit=function(e){var t,s,o,i,n,r,a,l="error"===e;if(r=this._events)l=l&&null==r.error;else if(!l)return!1;if(a=this.domain,l){if(t=arguments[1],!a){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(s=r[e]))return!1;var d="function"==typeof s;switch(o=arguments.length){case 1:!function(e,t,s){if(t)e.call(s);else for(var o=e.length,i=ae(e,o),n=0;n<o;++n)i[n].call(s)}(s,d,this);break;case 2:!function(e,t,s,o){if(t)e.call(s,o);else for(var i=e.length,n=ae(e,i),r=0;r<i;++r)n[r].call(s,o)}(s,d,this,arguments[1]);break;case 3:!function(e,t,s,o,i){if(t)e.call(s,o,i);else for(var n=e.length,r=ae(e,n),a=0;a<n;++a)r[a].call(s,o,i)}(s,d,this,arguments[1],arguments[2]);break;case 4:!function(e,t,s,o,i,n){if(t)e.call(s,o,i,n);else for(var r=e.length,a=ae(e,r),l=0;l<r;++l)a[l].call(s,o,i,n)}(s,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(o-1),n=1;n<o;n++)i[n-1]=arguments[n];!function(e,t,s,o){if(t)e.apply(s,o);else for(var i=e.length,n=ae(e,i),r=0;r<i;++r)n[r].apply(s,o)}(s,d,this,i)}return!0},se.prototype.addListener=function(e,t){return ie(this,e,t,!1)},se.prototype.on=se.prototype.addListener,se.prototype.prependListener=function(e,t){return ie(this,e,t,!0)},se.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,ne(this,e,t)),this},se.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,ne(this,e,t)),this},se.prototype.removeListener=function(e,t){var s,o,i,n,r;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(o=this._events))return this;if(!(s=o[e]))return this;if(s===t||s.listener&&s.listener===t)0==--this._eventsCount?this._events=new te:(delete o[e],o.removeListener&&this.emit("removeListener",e,s.listener||t));else if("function"!=typeof s){for(i=-1,n=s.length;n-- >0;)if(s[n]===t||s[n].listener&&s[n].listener===t){r=s[n].listener,i=n;break}if(i<0)return this;if(1===s.length){if(s[0]=void 0,0==--this._eventsCount)return this._events=new te,this;delete o[e]}else!function(e,t){for(var s=t,o=s+1,i=e.length;o<i;s+=1,o+=1)e[s]=e[o];e.pop()}(s,i);o.removeListener&&this.emit("removeListener",e,r||t)}return this},se.prototype.off=function(e,t){return this.removeListener(e,t)},se.prototype.removeAllListeners=function(e){var t,s;if(!(s=this._events))return this;if(!s.removeListener)return 0===arguments.length?(this._events=new te,this._eventsCount=0):s[e]&&(0==--this._eventsCount?this._events=new te:delete s[e]),this;if(0===arguments.length){for(var o,i=Object.keys(s),n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=new te,this._eventsCount=0,this}if("function"==typeof(t=s[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},se.prototype.listeners=function(e){var t,s=this._events;return s&&(t=s[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),s=0;s<t.length;++s)t[s]=e[s].listener||e[s];return t}(t):[]},se.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):re.call(e,t)},se.prototype.listenerCount=re,se.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};let le=null;const ce=Object.freeze({el:null,animate:!0,animateClass:"fade",animateInClass:"show",appendTo:"body",backdrop:!0,keyboard:!0,title:!1,header:!0,content:!1,footer:!0,buttons:null,headerClose:!0,construct:!1,transition:300,backdropTransition:150}),de=function e(t){for(let s in t)Array.isArray(t[s])?t[s].forEach((t=>{e(t)})):null!==t[s]&&"object"==typeof t[s]&&Object.freeze(t[s]);return Object.freeze(t)}({dialog:[{text:"Cancel",value:!1,attr:{class:"btn btn-default","data-dismiss":"modal"}},{text:"OK",value:!0,attr:{class:"btn btn-primary","data-dismiss":"modal"}}],alert:[{text:"OK",attr:{class:"btn btn-primary","data-dismiss":"modal"}}],confirm:[{text:"Cancel",value:!1,attr:{class:"btn btn-default","data-dismiss":"modal"}},{text:"OK",value:!0,attr:{class:"btn btn-primary","data-dismiss":"modal"}}]}),he={container:'<div class="modal"></div>',dialog:'<div class="modal-dialog"></div>',content:'<div class="modal-content"></div>',header:'<div class="modal-header"></div>',headerClose:'<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>',body:'<div class="modal-body"></div>',footer:'<div class="modal-footer"></div>',backdrop:'<div class="modal-backdrop"></div>'};function ue(e,t,s){let o="data",i=e[o]||{};if(void 0===s){if(e[o]&&e[o][t])return e[o][t];var n=e.getAttribute(`${o}-${t}`);return void 0!==n?n:null}return i[t]=s,e[o]=i,e}function pe(e,t){return e.nodeName?e:(e=e.replace(/(\t|\n$)/g,""),le||(le=document.createElement("div")),le.innerHTML="",le.innerHTML=e,!0===t?le.childNodes:le.childNodes[0])}function me(e){let t=[e];for(;e.parentNode;)e=e.parentNode,t.push(e);return t}class ge extends se{static set templates(e){this._baseTemplates=e}static get templates(){return Object.assign({},he,ge._baseTemplates||{})}static set buttons(e){this._baseButtons=e}static get buttons(){return Object.assign({},de,ge._baseButtons||{})}static set options(e){this._baseOptions=e}static get options(){return Object.assign({},ce,ge._baseOptions||{})}static get version(){return"0.12.0"}static alert(e,t={}){let s=Object.assign({},ce,{title:e,content:!1,construct:!0,headerClose:!1,buttons:ge.buttons.alert},t);return new ge(s)}static confirm(e,t={}){let s=Object.assign({},ce,{title:e,content:!1,construct:!0,headerClose:!1,buttons:ge.buttons.confirm},t);return new ge(s)}constructor(e={}){if(super(),this.id=(65536*(1+Math.random())|0).toString(16)+(65536*(1+Math.random())|0).toString(16),this.el=null,this._html={},this._events={},this._visible=!1,this._pointerInContent=!1,this._options=Object.assign({},ge.options,e),this._templates=Object.assign({},ge.templates,e.templates||{}),this._html.appendTo=document.querySelector(this._options.appendTo),this._scrollbarWidth=function(){let e,t,s,o=document.createElement("div");return Object.assign(o.style,{visibility:"hidden",width:"100px"}),document.body.appendChild(o),s=o.offsetWidth,o.style.overflow="scroll",e=document.createElement("div"),e.style.width="100%",o.appendChild(e),t=s-e.offsetWidth,document.body.removeChild(o),t}(),null===this._options.buttons&&(this._options.buttons=ge.buttons.dialog),this._options.el){let e=this._options.el;if("string"==typeof this._options.el&&(e=document.querySelector(this._options.el),!e))throw new Error(`Selector: DOM Element ${this._options.el} not found.`);ue(e,"modal",this),this.el=e}else this._options.construct=!0;this._options.construct?this._render():this._mapDom()}_render(){let e=this._html,t=this._options,s=this._templates,o=!!t.animate&&t.animateClass;return e.container=pe(s.container),e.dialog=pe(s.dialog),e.content=pe(s.content),e.header=pe(s.header),e.headerClose=pe(s.headerClose),e.body=pe(s.body),e.footer=pe(s.footer),o&&e.container.classList.add(o),this._setHeader(),this._setContent(),this._setFooter(),this.el=e.container,e.dialog.appendChild(e.content),e.container.appendChild(e.dialog),this}_mapDom(){let e=this._html,t=this._options;return this.el.classList.contains(t.animateClass)&&(t.animate=!0),e.container=this.el,e.dialog=this.el.querySelector(".modal-dialog"),e.content=this.el.querySelector(".modal-content"),e.header=this.el.querySelector(".modal-header"),e.headerClose=this.el.querySelector(".modal-header .close"),e.body=this.el.querySelector(".modal-body"),e.footer=this.el.querySelector(".modal-footer"),this._setHeader(),this._setContent(),this._setFooter(),this}_setHeader(){let e=this._html,t=this._options;t.header&&e.header&&(t.title.nodeName?e.header.innerHTML=t.title.outerHTML:"string"==typeof t.title&&(e.header.innerHTML=`<h4 class="modal-title">${t.title}</h4>`),null===this.el&&e.headerClose&&t.headerClose&&e.header.appendChild(e.headerClose),t.construct&&e.content.appendChild(e.header))}_setContent(){let e=this._html,t=this._options;t.content&&e.body&&("string"==typeof t.content?e.body.innerHTML=t.content:e.body.innerHTML=t.content.outerHTML,t.construct&&e.content.appendChild(e.body))}_setFooter(){let e=this._html,t=this._options;t.footer&&e.footer&&(t.footer.nodeName?e.footer.ineerHTML=t.footer.outerHTML:"string"==typeof t.footer?e.footer.innerHTML=t.footer:e.footer.children.length||t.buttons.forEach((t=>{let s=document.createElement("button");ue(s,"button",t),s.innerHTML=t.text,s.setAttribute("type","button");for(let e in t.attr)s.setAttribute(e,t.attr[e]);e.footer.appendChild(s)})),t.construct&&e.content.appendChild(e.footer))}_setEvents(){this._options;let e=this._html;this._events.keydownHandler=this._handleKeydownEvent.bind(this),document.body.addEventListener("keydown",this._events.keydownHandler),this._events.mousedownHandler=this._handleMousedownEvent.bind(this),e.container.addEventListener("mousedown",this._events.mousedownHandler),this._events.clickHandler=this._handleClickEvent.bind(this),e.container.addEventListener("click",this._events.clickHandler),this._events.resizeHandler=this._handleResizeEvent.bind(this),window.addEventListener("resize",this._events.resizeHandler)}_handleMousedownEvent(e){this._pointerInContent=!1,me(e.target).every((e=>!e.classList||!e.classList.contains("modal-content")||(this._pointerInContent=!0,!1)))}_handleClickEvent(e){me(e.target).every((t=>"HTML"!==t.tagName&&((!0===this._options.backdrop||!t.classList.contains("modal"))&&(!t.classList.contains("modal-content")&&("modal"===t.getAttribute("data-dismiss")?(this.emit("dismiss",this,e,ue(e.target,"button")),this.hide(),!1):!(!this._pointerInContent&&t.classList.contains("modal"))||(this.emit("dismiss",this,e,null),this.hide(),!1)))))),this._pointerInContent=!1}_handleKeydownEvent(e){27===e.which&&this._options.keyboard&&(this.emit("dismiss",this,e,null),this.hide())}_handleResizeEvent(e){this._resize()}show(){let e=this._options,t=this._html;return this.emit("show",this),this._checkScrollbar(),this._setScrollbar(),document.body.classList.add("modal-open"),e.construct&&t.appendTo.appendChild(t.container),t.container.style.display="block",t.container.scrollTop=0,!1!==e.backdrop?(this.once("showBackdrop",(()=>{this._setEvents(),e.animate&&t.container.offsetWidth,t.container.classList.add(e.animateInClass),setTimeout((()=>{this._visible=!0,this.emit("shown",this)}),e.transition)})),this._backdrop()):(this._setEvents(),e.animate&&t.container.offsetWidth,t.container.classList.add(e.animateInClass),setTimeout((()=>{this._visible=!0,this.emit("shown",this)}),e.transition)),this._resize(),this}toggle(){this._visible?this.hide():this.show()}_resize(){var e=this._html.container.scrollHeight>document.documentElement.clientHeight;this._html.container.style.paddingLeft=!this.bodyIsOverflowing&&e?this._scrollbarWidth+"px":"",this._html.container.style.paddingRight=this.bodyIsOverflowing&&!e?this._scrollbarWidth+"px":""}_backdrop(){let e=this._html,t=this._templates,s=this._options,o=!!s.animate&&s.animateClass;e.backdrop=pe(t.backdrop),o&&e.backdrop.classList.add(o),e.appendTo.appendChild(e.backdrop),o&&e.backdrop.offsetWidth,e.backdrop.classList.add(s.animateInClass),setTimeout((()=>{this.emit("showBackdrop",this)}),this._options.backdropTransition)}hide(){let e=this._html,t=this._options,s=e.container.classList;if(this.emit("hide",this),s.remove(t.animateInClass),t.backdrop){e.backdrop.classList.remove(t.animateInClass)}return this._removeEvents(),setTimeout((()=>{document.body.classList.remove("modal-open"),document.body.style.paddingRight=this.originalBodyPad}),t.backdropTransition),setTimeout((()=>{t.backdrop&&e.backdrop.parentNode.removeChild(e.backdrop),e.container.style.display="none",t.construct&&e.container.parentNode.removeChild(e.container),this._visible=!1,this.emit("hidden",this)}),t.transition),this}_removeEvents(){this._events.keydownHandler&&document.body.removeEventListener("keydown",this._events.keydownHandler),this._html.container.removeEventListener("mousedown",this._events.mousedownHandler),this._html.container.removeEventListener("click",this._events.clickHandler),window.removeEventListener("resize",this._events.resizeHandler)}_checkScrollbar(){this.bodyIsOverflowing=document.body.clientWidth<window.innerWidth}_setScrollbar(){if(this.originalBodyPad=document.body.style.paddingRight||"",this.bodyIsOverflowing){let e=parseInt(this.originalBodyPad||0,10);document.body.style.paddingRight=e+this._scrollbarWidth+"px"}}}let fe={};const ye=new Set,ve=e=>"exceptions"in e?e.exceptions.map((e=>e.text)).join(","):"",_e=(e,t=null,s="")=>{if(ye.has(s))return;ye.add(s);let o=`<b>Error: ${e}</b>`;t&&(o+=`. ${t.message}`);const i=ge.alert(o,fe);i.show(),i.on("hidden",(()=>{ye.delete(s)}))},be={labels:{select:"Select",addElement:"Toggle Draw mode",editElement:"Edit feature",save:"Save",delete:"Delete",cancel:"Cancel",apply:"Apply changes",upload:"Upload",editMode:"Edit Mode",confirmDelete:"Are you sure to delete the feature?",geomTypeNotSupported:"Geometry not supported by layer",editFields:"Edit fields",editGeom:"Edit geometry",selectDrawType:"Geometry type to draw",uploadToLayer:"Upload file to selected layer",uploadFeatures:"Uploaded features to layer",validFeatures:"Valid geometries",invalidFeatures:"Invalid",loading:"Loading...",toggleVisibility:"Toggle layer visibility",close:"Close"},errors:{capabilities:"GeoServer Capabilities could not be downloaded.",wfst:"The GeoServer does not support Transactions",layer:"Could not get data from layer",layerNotFound:"Layer not found",layerNotVisible:"Layer is not visible",noValidGeometry:"No valid geometries found to add to this layer",geoserver:"Failed to get data from GeoServer",badFormat:"Unsupported format",badFile:"Error reading items from file",lockFeature:"Could not lock items on the GeoServer.",transaction:"Error when doing Transaction with GeoServer.",getFeatures:"Error getting elements from GeoServer."}},we={es:{labels:{select:"Seleccionar",addElement:"Modo dibujo",editElement:"Editar elemento",save:"Guardar",delete:"Eliminar",cancel:"Cancelar",apply:"Aplicar cambios",upload:"Subir",editMode:"Modo Edición",confirmDelete:"¿Estás seguro de borrar el elemento?",geomTypeNotSupported:"Geometría no compatible con la capa",editFields:"Editar campos",editGeom:"Editar geometría",selectDrawType:"Tipo de geometría para dibujar",uploadToLayer:"Subir archivo a la capa seleccionada",uploadFeatures:"Subida de elementos a la capa",validFeatures:"Válidas",invalidFeatures:"Invalidas",loading:"Cargando...",toggleVisibility:"Cambiar visibilidad de la capa",close:"Cerrar"},errors:{capabilities:"No se pudieron obtener las Capabilidades del GeoServer",wfst:"El GeoServer no tiene soporte a Transacciones",layer:"No se pudieron obtener datos de la capa",layerNotFound:"Capa no encontrada",layerNotVisible:"La capa no está visible",noValidGeometry:"No se encontraron geometrías válidas para agregar a esta capa",geoserver:"No se pudieron obtener datos desde el GeoServer",badFormat:"Formato no soportado",badFile:"Error al leer elementos del archivo",lockFeature:"No se pudieron bloquear elementos en el GeoServer.",transaction:"Error al hacer transacción con el GeoServer.",getFeatures:"Error al obtener elemento desde el GeoServer."}},en:be,zh:{labels:{select:"选择",addElement:"切换绘图类型",editElement:"编辑元素",save:"保存",delete:"删除",cancel:"取消",apply:"确认并应用改变",upload:"上传",editMode:"编辑模式",confirmDelete:"确认删除元素?",geomTypeNotSupported:"图层不支持该几何",editFields:"编辑区域",editGeom:"编辑几何",selectDrawType:"几何类型",uploadToLayer:"通过文件上传图层",uploadFeatures:"上传元素到图层",validFeatures:"合法的几何类型",invalidFeatures:"不合法",loading:"加载中...",toggleVisibility:"切换图层透明度",close:"关闭"},errors:{capabilities:"无法加载GeoServer服务所支持的能力.",wfst:"GeoServer不支持事务",layer:"无法从图层获得数据",layerNotFound:"Layer not found",layerNotVisible:"Layer is not visible",noValidGeometry:"不支持的几何类型无法加载到图层",geoserver:"无法从GeoServer获取数据",badFormat:"不支持的格式",badFile:"读取文件数据出错",lockFeature:"无法锁定GeoServer上的元素.",transaction:"GeoServer处理事务出错.",getFeatures:"从GeoServer获取元素出错."}}};let Ee=be;let Se;const Ce=(e=!0)=>{e?Se.classList.add("ol-wfst--tools-control--loading-show"):Se.classList.remove("ol-wfst--tools-control--loading-show")},Fe=(e,t,s=[])=>{const o=Object.getOwnPropertyDescriptors(t);for(let e of s)delete o[e];Object.defineProperties(e,o)},Le=(e,t=[e])=>{const s=Object.getPrototypeOf(e);return null===s?t:Le(s,[...t,s])},Te=(e,t,s=[])=>{var o;const i=null!==(o=((...e)=>{if(0===e.length)return;let t;const s=e.map((e=>Le(e)));for(;s.every((e=>e.length>0));){const e=s.map((e=>e.pop())),o=e[0];if(!e.every((e=>e===o)))break;t=o}return t})(...e))&&void 0!==o?o:Object.prototype,n=Object.create(i),r=Le(i);for(let t of e){let e=Le(t);for(let t=e.length-1;t>=0;t--){let o=e[t];-1===r.indexOf(o)&&(Fe(n,o,["constructor",...s]),r.push(o))}}return n.constructor=t,n},Me=e=>e.filter(((t,s)=>e.indexOf(t)==s)),ke=new Map,Ae=e=>ke.get(e),Pe=(e,t)=>{var s,o;const i=Me([...Object.getOwnPropertyNames(e),...Object.getOwnPropertyNames(t)]),n={};for(let r of i)n[r]=Me([...null!==(s=null==e?void 0:e[r])&&void 0!==s?s:[],...null!==(o=null==t?void 0:t[r])&&void 0!==o?o:[]]);return n},xe=(e,t)=>{var s,o,i,n;return{property:Pe(null!==(s=null==e?void 0:e.property)&&void 0!==s?s:{},null!==(o=null==t?void 0:t.property)&&void 0!==o?o:{}),method:Pe(null!==(i=null==e?void 0:e.method)&&void 0!==i?i:{},null!==(n=null==t?void 0:t.method)&&void 0!==n?n:{})}},Ne=new Map,Ie=(...e)=>{const t=((...e)=>{var t;const s=new Set,o=new Set([...e]);for(;o.size>0;)for(let e of o){const i=[...Le(e.prototype).map((e=>e.constructor)),...null!==(t=Ae(e))&&void 0!==t?t:[]].filter((e=>!s.has(e)));for(let e of i)o.add(e);s.add(e),o.delete(e)}return[...s]})(...e).map((e=>Ne.get(e))).filter((e=>!!e));return 0==t.length?{}:1==t.length?t[0]:t.reduce(((e,t)=>((e,t)=>{var s,o,i,n,r,a;return{class:Me([...null!==(s=null==e?void 0:e.class)&&void 0!==s?s:[],...null!==(o=null==t?void 0:t.class)&&void 0!==o?o:[]]),static:xe(null!==(i=null==e?void 0:e.static)&&void 0!==i?i:{},null!==(n=null==t?void 0:t.static)&&void 0!==n?n:{}),instance:xe(null!==(r=null==e?void 0:e.instance)&&void 0!==r?r:{},null!==(a=null==t?void 0:t.instance)&&void 0!==a?a:{})}})(e,t)))};function Oe(...e){var t,s,o;const i=e.map((e=>e.prototype));function n(...t){for(const s of e)Fe(this,new s(...t))}n.prototype=Te(i,n),Object.setPrototypeOf(n,Te(e,null,["prototype"]));let r=n;{const i=Ie(...e);for(let e of null!==(t=null==i?void 0:i.class)&&void 0!==t?t:[])r=e(r);Ge(null!==(s=null==i?void 0:i.static)&&void 0!==s?s:{},r),Ge(null!==(o=null==i?void 0:i.instance)&&void 0!==o?o:{},r.prototype)}var a,l;return a=r,l=e,ke.set(a,l),r}const Ge=(e,t)=>{const s=e.property,o=e.method;if(s)for(let e in s)for(let o of s[e])o(t,e);if(o)for(let e in o)for(let s of o[e])s(t,e,Object.getOwnPropertyDescriptor(t,e))};var De,Re;let Ve;!function(e){e.Point="Point",e.LineString="LineString",e.LinearRing="LinearRing",e.Polygon="Polygon",e.MultiPoint="MultiPoint",e.MultiLineString="MultiLineString",e.MultiPolygon="MultiPolygon",e.GeometryCollection="GeometryCollection",e.Circle="Circle"}(De||(De={})),function(e){e.Insert="insert",e.Delete="delete",e.Update="update"}(Re||(Re={}));let Ue=null,qe=null;var je;function He(e=null){qe=e}function ze(){return qe}!function(e){e.Edit="EDIT",e.Draw="DRAW"}(je||(je={}));const Be=new Set,$e={};function We(){return Ve}function Ke(e){Ue=e}function Ze(){return Ue}function Je(){return $e}function Ye(e){return Je()[e]}function Xe(e){Be.add(String(e.getId()))}function Qe(e){Be.delete(String(e.getId()))}function et(e){return Be.has(String(e.getId()))}class tt extends a{_init(){const e=this.getGeoserver();e.isLoaded()?this.getAndUpdateDescribeFeatureType():e.on("change:capabilities",(()=>{this.getAndUpdateDescribeFeatureType()}))}async getAndUpdateDescribeFeatureType(){const e=this.get(st.NAME),t=this.get(st.LABEL);try{const t=this.getGeoserver(),s=new URLSearchParams({service:"wfs",version:t.getAdvanced().describeFeatureTypeVersion,request:"DescribeFeatureType",typeName:e,outputFormat:"application/json",exceptions:"application/json"}),o=t.getUrl()+"?"+s.toString(),i=await fetch(o,{headers:t.getHeaders(),credentials:t.getCredentials()});if(!i.ok)throw new Error("");const n=await i.json();if(!n)throw new Error("");const r=n.targetNamespace,a=n.featureTypes[0].properties,l=a.find((e=>e.type.indexOf("gml:")>=0));n._parsed={namespace:r,properties:a,geomType:l.localType,geomField:l.name},this.set(st.DESCRIBEFEATURETYPE,n)}catch(e){throw console.error(e),new Error(`${Ee.errors.layer} "${t}"`)}}isVisibleByZoom(){return We().getView().getZoom()>this.getMinZoom()}async transactFeatures(e,t){return this.getGeoserver().transact(e,t,this.get(st.NAME))}async insertFeatures(e){return this.transactFeatures(Re.Insert,e)}async maybeLockFeature(e){const t=this.getGeoserver();return t.getUseLockFeature()&&t.hasLockFeature()?await t.lockFeature(e,this.get(st.NAME)):null}getGeoserver(){return this.get(st.GEOSERVER)}getDescribeFeatureType(){return this.get(st.DESCRIBEFEATURETYPE)}}var st;!function(e){e.NAME="name",e.LABEL="label",e.DESCRIBEFEATURETYPE="describeFeatureType",e.ISVISIBLE="isVisible",e.GEOSERVER="geoserver"}(st||(st={}));class ot extends c{urlParams=new URLSearchParams({SERVICE:"wfs",REQUEST:"GetFeature",OUTPUTFORMAT:"application/json",EXCEPTIONS:"application/json"});constructor(e){super({...e,format:new l,loader:async(t,s,o,i,n)=>{try{if(e.strategy==h.bbox){const s=d.transformExtent(t,o.getCode(),e.geoServerAdvanced.projection);this.urlParams.set("bbox",s.toString()+`,${e.geoServerAdvanced.projection}`)}const s=e.geoserverUrl+"?"+this.urlParams.toString(),n=await fetch(s,{headers:e.headers,credentials:e.credentials});if(!n.ok)throw new Error("");const r=await n.json();if(r.exceptions)throw new Error(ve(r));const a=this.getFormat().readFeatures(r,{featureProjection:o.getCode(),dataProjection:e.geoServerAdvanced.projection});a.forEach((t=>{t.set("_layerName_",e.name,!0)})),this.addFeatures(a),i(a)}catch(s){this.removeLoadedExtent(t),_e(Ee.errors.geoserver,s,e.name),n()}}}),this.urlParams.set("version",e.geoServerAdvanced.getFeatureVersion),this.urlParams.set("typename",e.name),this.urlParams.set("srsName",e.geoServerAdvanced.projection.toString())}}class it extends(Oe(tt,r)){_loadingCount=0;_loadedCount=0;beforeTransactFeature;constructor(e){super({name:e.name,label:e.label||e.name,minZoom:e.minZoom,...e}),e.beforeTransactFeature&&(this.beforeTransactFeature=e.beforeTransactFeature);const t=e.geoserver,s=new ot({name:e.name,geoserverUrl:t.getUrl(),geoServerAdvanced:t.getAdvanced(),...e.strategy&&{strategy:e.strategy},geoserverVendor:e.geoserverVendor});this._loadingCount=0,this._loadedCount=0,s.on("featuresloadstart",(()=>{this._loadingCount++,1===this._loadingCount&&this.isVisibleByZoom()&&Ce()})),s.on(["featuresloadend","featuresloaderror"],(()=>{this._loadedCount++,this._loadingCount===this._loadedCount&&(this._loadingCount=0,this._loadedCount=0,setTimeout((()=>{this.dispatchEvent("layerRendered")}),300))})),this.setSource(s);const o=e.geoserverVendor;Object.keys(o).forEach((e=>{s.urlParams.set(e,o[e])}))}refresh(){this.getSource().refresh()}setCustomParam(e,t=null,s=!0){const o=this.getSource();return null==t?o.urlParams.delete(e):o.urlParams.set(e,t),s&&this.refresh(),o.urlParams}}class nt extends m{constructor(e){super({url:e.geoserverUrl,serverType:"geoserver",params:{SERVICE:"wms",TILED:!0,LAYERS:e.name,EXCEPTIONS:"application/json",...e.geoserverVendor&&e.geoserverVendor},tileLoadFunction:async(t,s)=>{try{const i=await fetch(s,{headers:e.headers,credentials:e.credentials});if(!i.ok)throw new Error("");let n=await i.blob();if("application/json"==n.type){const e=await(o=n,new Promise((e=>{const t=new FileReader;t.onloadend=()=>e(JSON.parse(t.result)),t.readAsText(o)})));throw new Error(ve(e))}t.getImage().src=URL.createObjectURL(n),t.setState($)}catch(s){_e(Ee.errors.geoserver,s,e.name),t.setState(W)}var o},...e})}}class rt extends(Oe(tt,u)){_loadingCount=0;_loadedCount=0;beforeTransactFeature;_formatGeoJSON;constructor(e){super({name:e.name,label:e.label||e.name,minZoom:e.minZoom,...e}),e.beforeTransactFeature&&(this.beforeTransactFeature=e.beforeTransactFeature),this._formatGeoJSON=new p.GeoJSON;const t=e.geoserver,s=new nt({name:e.name,geoserverUrl:t.getUrl(),geoServerAdvanced:t.getAdvanced(),geoserverVendor:e.geoserverVendor});this._loadingCount=0,this._loadedCount=0,s.on("tileloadstart",(()=>{this._loadingCount++,1===this._loadingCount&&this.isVisibleByZoom()&&Ce()})),s.on(["tileloadend","tileloaderror"],(()=>{this._loadedCount++,this._loadingCount===this._loadedCount&&(this._loadingCount=0,this._loadedCount=0,setTimeout((()=>{this.dispatchEvent("layerRendered")}),300))})),this.setSource(s)}async _getFeaturesByClickEvent(e){const t=e.coordinate,s=We().getView(),o=s.getZoom()>10?10:5,i=this.getSource(),n=i["getFeatureInfoUrl"in i?"getFeatureInfoUrl":"getGetFeatureInfoUrl"](t,s.getResolution(),s.getProjection().getCode(),{INFO_FORMAT:"application/json",BUFFER:o,FEATURE_COUNT:1,EXCEPTIONS:"application/json"}),r=this.getGeoserver();try{const e=await fetch(n,{headers:r.getHeaders(),credentials:r.getCredentials()});if(!e.ok)throw new Error(`${Ee.errors.getFeatures} ${e.status}`);const t=await e.json();return this._formatGeoJSON.readFeatures(t)}catch(e){_e(e.message,e)}}refresh(){const e=this.getSource();e.refresh();const t=e.getParams();t.t=(new Date).getMilliseconds(),e.updateParams(t)}setCustomParam(e,t=null,s=!0){const o=this.getSource();return o.updateParams({[e]:t}),s&&this.refresh(),o.getParams()}}function at(e,t={},...s){if("function"==typeof e)return e(t,s);const o=null===e?new DocumentFragment:document.createElement(e);Object.entries(t||{}).forEach((([e,t])=>{void 0!==typeof t&&null!=t&&(e.startsWith("on")&&e.toLowerCase()in window?o.addEventListener(e.toLowerCase().substr(2),t):"className"===e?o.setAttribute("class",t.toString()):"htmlFor"===e?o.setAttribute("for",t.toString()):o.setAttribute(e,t.toString()))}));for(const e of s)e&&(Array.isArray(e)?o.append(...e):void 0===e.nodeType?o.innerHTML+=e:o.appendChild(e));return o}const lt=()=>{const e=document.querySelector(".ol-wfst--tools-control-btn.wfst--active");e&&e.classList.remove("wfst--active")};class ct extends N{_uploads;_uploadFormats;constructor(e,t){super(),this._uploads=e,this._uploadFormats=t}addLayerEl(e){const t=document.querySelector(".wfst--tools-control--select-layers"),s=e.get(st.NAME),o=at("input",{value:s,id:`wfst--${s}`,type:"radio",className:"ol-wfst--tools-control-input",name:"wfst--select-layer",...e===Ze()?{checked:"checked"}:{},onchange:t=>this._layerChangeHandler(t,e)}),i=at("div",{className:`wfst--layer-control \n ${e.getVisible()?"ol-wfst--visible-on":""}\n ${e===Ze()?"ol-wfst--selected-on":""}`,"data-layer":s},at("div",{className:"ol-wfst--tools-control-visible"},at("span",{className:"ol-wfst--tools-control-visible-btn ol-wfst--visible-btn-on",title:Ee.labels.toggleVisibility,onclick:e=>this._visibilityClickHandler(e)},at("img",{src:"data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e%3cpath d='M384 288q39 0 67.5 28.5t28.5 67.5-28.5 67.5-67.5 28.5-67.5-28.5-28.5-67.5 28.5-67.5 67.5-28.5zM384 544.5q66 0 113.25-47.25t47.25-113.25-47.25-113.25-113.25-47.25-113.25 47.25-47.25 113.25 47.25 113.25 113.25 47.25zM384 144q118.5 0 214.5 66t138 174q-42 108-138 174t-214.5 66-214.5-66-138-174q42-108 138-174t214.5-66z'%3e%3c/path%3e%3c/svg%3e"})),at("span",{className:"ol-wfst--tools-control-visible-btn ol-wfst--visible-btn-off",title:Ee.labels.toggleVisibility,onclick:e=>this._visibilityClickHandler(e)},at("img",{src:"data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e%3cpath d='M379.5 288h4.5q39 0 67.5 28.5t28.5 67.5v6zM241.5 313.5q-18 36-18 70.5 0 66 47.25 113.25t113.25 47.25q34.5 0 70.5-18l-49.5-49.5q-12 3-21 3-39 0-67.5-28.5t-28.5-67.5q0-9 3-21zM64.5 136.5l40.5-40.5 567 567-40.5 40.5q-7.5-7.5-47.25-46.5t-60.75-60q-64.5 27-139.5 27-118.5 0-214.5-66t-138-174q16.5-39 51.75-86.25t68.25-72.75q-18-18-50.25-51t-36.75-37.5zM384 223.5q-30 0-58.5 12l-69-69q58.5-22.5 127.5-22.5 118.5 0 213.75 66t137.25 174q-36 88.5-109.5 151.5l-93-93q12-28.5 12-58.5 0-66-47.25-113.25t-113.25-47.25z'%3e%3c/path%3e%3c/svg%3e"}))),at("label",{htmlFor:`wfst--${s}`},o,at("span",{title:e.getDescribeFeatureType()._parsed.geomType},e.get(st.LABEL))));return t.appendChild(i),e===Ze()&&o.dispatchEvent(new Event("change")),i}_changeStateSelect(e,t=null){const s=(e,t)=>{Array.from(o.options).forEach((s=>{s.selected=s.value===e,s.disabled="all"!==t&&!t.includes(s.value),s.title=s.disabled?Ee.labels.geomTypeNotSupported:""}))},o=document.querySelector(".wfst--tools-control--select-draw");let i;if(o){const n=e.getDescribeFeatureType()._parsed.geomType;t?i=o.value:n===De.GeometryCollection?(i=De.LineString,s(i,"all")):n===De.LinearRing?(i=De.LineString,s(i,[De.Circle,De.LinearRing,De.Polygon]),o.value=i):(i=n,s(i,[n]))}return i}_visibilityClickHandler(e){const t=e.currentTarget.closest(".wfst--layer-control"),s=t.dataset.layer;t.classList.toggle("ol-wfst--visible-on");const o=Je()[s];t.classList.contains("ol-wfst--visible-on")?o.setVisible(!0):o.setVisible(!1)}_layerChangeHandler(e,t){const s=e.currentTarget.closest(".wfst--layer-control"),o=document.querySelector(".ol-wfst--selected-on");o&&o.classList.remove("ol-wfst--selected-on"),s.classList.add("ol-wfst--selected-on"),Ke(t),this._changeStateSelect(t)}render(){return at(null,null,at("div",{className:"wfst--tools-control--head"},this._uploads&&at("div",null,at("input",{id:"ol-wfst--upload",type:"file",accept:this._uploadFormats,onchange:e=>this._uploads.process(e)}),at("label",{className:"ol-wfst--tools-control-btn ol-wfst--tools-control-btn-upload",htmlFor:"ol-wfst--upload",title:Ee.labels.uploadToLayer},at("img",{src:"data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'%3e%3cpath d='M240 352h-240v128h480v-128h-240zM448 416h-64v-32h64v32zM112 160l128-128 128 128h-80v160h-96v-160z'%3e%3c/path%3e%3c/svg%3e"}))),at("div",{className:"ol-wfst--tools-control-draw-cnt"},at("button",{className:"ol-wfst--tools-control-btn ol-wfst--tools-control-btn-draw",type:"button",title:Ee.labels.addElement,onclick:()=>{this.dispatchEvent("drawMode")}},at("img",{src:"data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e %3cpath d='M663 225l-58.5 58.5-120-120 58.5-58.5q9-9 22.5-9t22.5 9l75 75q9 9 9 22.5t-9 22.5zM96 552l354-354 120 120-354 354h-120v-120z'%3e%3c/path%3e%3c/svg%3e"})),at("select",{title:Ee.labels.selectDrawType,className:"wfst--tools-control--select-draw",onchange:e=>{const t=e.target.value;this._changeStateSelect(Ze(),t),this.dispatchEvent("changeGeom")}},[De.Point,De.MultiPoint,De.LineString,De.MultiLineString,De.Polygon,De.MultiPolygon,De.Circle].map((e=>at("option",{value:e},e)))))),at("div",{className:"wfst--tools-control--select-layers"}))}}let dt=new r({source:new c,zIndex:100});const ht=()=>dt;class ut extends N{_options;_formatWFS;_formatGeoJSON;_formatKml;_xs;_processUpload;constructor(e){super(),this._options=e,this._processUpload=e.processUpload,this._formatWFS=new p.WFS,this._formatGeoJSON=new p.GeoJSON,this._formatKml=new p.KML({extractStyles:!1,showPointNames:!1}),this._xs=new XMLSerializer}async process(e){const t=We().getView(),s=e.target.files[0];let o;if(!s)return;const i=s.name.split(".").pop().toLowerCase();try{if(this._processUpload&&(o=this._processUpload(s)),!o){const e=await this._fileReader(s);"geojson"===i||"json"===i?o=this._formatGeoJSON.readFeatures(e,{featureProjection:t.getProjection().getCode()}):"kml"===i?o=this._formatKml.readFeatures(e,{featureProjection:t.getProjection().getCode()}):_e(Ee.errors.badFormat)}let n=0,r=0;const a=[];for(let e of o)this._checkGeometry(e)||(e=this._fixGeometry(e)),e?(a.push(e),r++):n++;if(r){lt(),this.dispatchEvent(new c.VectorSourceEvent("loadedFeatures",null,a));const e=`\n ${Ee.labels.validFeatures}: ${r}<br>\n ${n?`${Ee.labels.invalidFeatures}: ${n}`:""}`;this._initModal(e,a)}else _e(Ee.errors.noValidGeometry);e.target.value=null}catch(e){_e(Ee.errors.badFile,e)}}async _fileReader(e){return new Promise(((t,s)=>{const o=new FileReader;o.addEventListener("load",(async e=>{const s=e.target.result;t(s)})),o.addEventListener("error",(e=>{console.error("Error"+e),s()})),o.readAsText(e)}))}_fixGeometry(e){const t=Ze().getDescribeFeatureType()._parsed.geomType;let s;switch(e.getGeometry().getType()){case De.Point:if(t===De.MultiPoint){const t=e.getGeometry().getCoordinates();s=new g.MultiPoint([t])}break;case De.LineString:if(t===De.MultiLineString){const t=e.getGeometry().getCoordinates();s=new g.MultiLineString([t])}break;case De.Polygon:if(t===De.MultiPolygon){const t=e.getGeometry().getCoordinates();s=new g.MultiPolygon([t])}break;default:s=null}return s?(e.setGeometry(s),e):null}_checkGeometry(e){const t=Ze().getDescribeFeatureType()._parsed.geomType,s=e.getGeometry().getType();return t===De.GeometryCollection||s===t}_initModal(e,t){const s=`\n <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">\n ${Ee.labels.cancel}\n </button>\n <button type="button" class="btn btn-sm btn-primary" data-action="save" data-dismiss="modal">\n ${Ee.labels.upload}\n </button>\n `;new ge({...this._options.modal,header:!0,headerClose:!1,title:Ee.labels.uploadFeatures+" "+Ze().get(st.NAME),content:e,backdrop:"static",footer:s}).show().on("dismiss",((e,s)=>{"save"===s.target.dataset.action?this.dispatchEvent(new c.VectorSourceEvent("addedFeatures",null,t)):ht().getSource().clear()}))}}const pt=(e,...t)=>(t.forEach((t=>{Object.keys(t).forEach((s=>{const o=t[s],i=e[s];e[s]=i&&o&&"object"==typeof i&&"object"==typeof o&&!Array.isArray(i)?pt(i,o):o}))})),e);class mt extends t.Control{constructor(e){super({element:at("div",{className:"ol-wfst--changes-control"},at("div",{className:"ol-wfst--changes-control-el"},at("div",{className:"ol-wfst--changes-control-id"},at("b",null,Ee.labels.editMode)," -"," ",at("i",null,String(e.getId()))),at("button",{type:"button",className:"btn btn-sm btn-secondary",onclick:()=>{this.dispatchEvent(new c.VectorSourceEvent("cancel",e))}},Ee.labels.cancel),at("button",{type:"button",className:"btn btn-sm btn-primary",onclick:()=>{this.dispatchEvent(new c.VectorSourceEvent("apply",e))}},Ee.labels.apply),at("button",{type:"button",className:"btn btn-sm btn-danger-outline",onclick:()=>{this.dispatchEvent(new c.VectorSourceEvent("delete",e))}},Ee.labels.delete)))})}}function gt(t){const s=e=>{let t=e.getGeometry();t instanceof g.GeometryCollection&&(t=t.getGeometries()[0]);const s=t.getCoordinates();let o=null;if(o=t instanceof g.Polygon||t instanceof g.MultiLineString?s.flat(1):t instanceof g.MultiPolygon?s.flat(2):s,o&&o.length)return new g.MultiPoint(o)};let o=t.getGeometry(),i=o.getType();switch(o instanceof g.GeometryCollection&&(o=o.getGeometries()[0],i=o.getType()),i){case De.Point:case De.MultiPoint:return ze()===je.Edit?[new e.Style({image:new e.Circle({radius:6,fill:new e.Fill({color:"#000000"})})}),new e.Style({image:new e.Circle({radius:4,fill:new e.Fill({color:"#ff0000"})})})]:[new e.Style({image:new e.Circle({radius:5,fill:new e.Fill({color:"#ff0000"})})}),new e.Style({image:new e.Circle({radius:2,fill:new e.Fill({color:"#000000"})})})];default:return ze()==je.Draw||ze()==je.Edit?[new e.Style({stroke:new e.Stroke({color:"rgba( 255, 0, 0, 1)",width:4}),fill:new e.Fill({color:"rgba(255, 0, 0, 0.7)"})}),new e.Style({image:new e.Circle({radius:4,fill:new e.Fill({color:"#ff0000"}),stroke:new e.Stroke({width:2,color:"rgba(5, 5, 5, 0.9)"})}),geometry:e=>s(e)}),new e.Style({stroke:new e.Stroke({color:"rgba(255, 255, 255, 0.7)",width:2})})]:[new e.Style({image:new e.Circle({radius:2,fill:new e.Fill({color:"#000000"})}),geometry:e=>s(e)}),new e.Style({stroke:new e.Stroke({color:"#ff0000",width:4}),fill:new e.Fill({color:"rgba(255, 0, 0, 0.7)"})})]}}class ft extends N{_options;_modal;_feature;constructor(e){super(),this._options=e;const t=`\n <button type="button" class="btn btn-sm btn-link btn-third" data-action="delete" data-dismiss="modal">\n ${Ee.labels.delete}\n </button>\n <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">\n ${Ee.labels.cancel}\n </button>\n <button type="button" class="btn btn-sm btn-primary" data-action="save" data-dismiss="modal">\n ${Ee.labels.save}\n </button>\n `;this._modal=new ge({...this._options,header:!0,headerClose:!0,title:"",content:"<div></div>",footer:t}),this._modal.on("dismiss",((e,t)=>{if("save"===t.target.dataset.action){e.el.querySelectorAll("input").forEach((e=>{const t=e.value,s=e.name;this._feature.set(s,t,!0)})),this._feature.changed(),Xe(this._feature),this.dispatchEvent(new c.VectorSourceEvent("save",this._feature))}else"delete"===t.target.dataset.action&&this.dispatchEvent(new c.VectorSourceEvent("delete",this._feature))}))}show(e){this._feature=e;const t=`${Ee.labels.editElement} ${e.getId()} `,s=e.getProperties(),o=Ye(e.get("_layerName_")).getDescribeFeatureType()._parsed.properties;let i='<form autocomplete="false">';Object.keys(s).forEach((e=>{const t=o.find((t=>t.name===e));if(t){let o;switch(t.type){case"xsd:string":default:o="text";break;case"xsd:number":case"xsd:int":o="number";break;case"xsd:date-time":o="datetime"}o&&(i+=`\n <div class="ol-wfst--input-field-container">\n <label class="ol-wfst--input-field-label" for="${e}">${e}</label>\n <input placeholder="NULL" class="ol-wfst--input-field-input" type="${o}" name="${e}" value="${s[e]||""}">\n </div>`)}})),i+="</form>",this._modal._html.body.innerHTML=i,this._modal._html.header.innerHTML=t,this._modal.show()}}var yt;!function(e){e.CAPABILITIES="capabilities",e.URL="url",e.HEADERS="headers",e.CREDENTIALS="credentials",e.ADVANCED="advanced",e.HASTRASNACTION="hasTransaction",e.HASLOCKFEATURE="hasLockFeature",e.HASDESCRIBEFEATURETYPE="hasDescribeFeatureType",e.USELOCKFEATURE="useLockFeature",e.ISLOADED="isLoaded"}(yt||(yt={}));class vt extends ee{constructor(e,t=null){super({id:e.getId(),position:t||v.getCenter(e.getGeometry().getExtent()),positioning:"center-center",offset:[0,-40],stopEvent:!0,element:at("div",null,at("div",{className:"ol-wfst--edit-button-cnt",onclick:()=>{this.dispatchEvent("editFields")}},at("button",{className:"ol-wfst--edit-button",type:"button",title:Ee.labels.editFields},at("img",{src:"data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='448' height='448' viewBox='0 0 448 448'%3e %3cpath d='M222 296l29-29-38-38-29 29v14h24v24h14zM332 116c-2.25-2.25-6-2-8.25 0.25l-87.5 87.5c-2.25 2.25-2.5 6-0.25 8.25s6 2 8.25-0.25l87.5-87.5c2.25-2.25 2.5-6 0.25-8.25zM352 264.5v47.5c0 39.75-32.25 72-72 72h-208c-39.75 0-72-32.25-72-72v-208c0-39.75 32.25-72 72-72h208c10 0 20 2 29.25 6.25 2.25 1 4 3.25 4.5 5.75 0.5 2.75-0.25 5.25-2.25 7.25l-12.25 12.25c-2.25 2.25-5.25 3-8 2-3.75-1-7.5-1.5-11.25-1.5h-208c-22 0-40 18-40 40v208c0 22 18 40 40 40h208c22 0 40-18 40-40v-31.5c0-2 0.75-4 2.25-5.5l16-16c2.5-2.5 5.75-3 8.75-1.75s5 4 5 7.25zM328 80l72 72-168 168h-72v-72zM439 113l-23 23-72-72 23-23c9.25-9.25 24.75-9.25 34 0l38 38c9.25 9.25 9.25 24.75 0 34z'%3e%3c/path%3e%3c/svg%3e",alt:Ee.labels.editFields}))),at("div",{className:"ol-wfst--edit-button-cnt",onclick:()=>{this.dispatchEvent("editGeom")}},at("button",{class:"ol-wfst--edit-button",type:"button",title:Ee.labels.editGeom},at("img",{src:"data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='541' height='512' viewBox='0 0 541 512'%3e %3cpath fill='black' d='M103.306 228.483l129.493-125.249c-17.662-4.272-31.226-18.148-34.98-35.663l-0.055-0.307-129.852 125.248c17.812 4.15 31.53 18.061 35.339 35.662l0.056 0.308z'%3e%3c/path%3e %3cpath fill='black' d='M459.052 393.010c-13.486-8.329-22.346-23.018-22.373-39.779v-0.004c-0.053-0.817-0.082-1.772-0.082-2.733s0.030-1.916 0.089-2.863l-0.007 0.13-149.852 71.94c9.598 8.565 15.611 20.969 15.611 34.779 0 0.014 0 0.029 0 0.043v-0.002c-0.048 5.164-0.94 10.104-2.544 14.711l0.098-0.322z'%3e%3c/path%3e %3cpath fill='black' d='M290.207 57.553c-0.009 15.55-7.606 29.324-19.289 37.819l-0.135 0.093 118.054 46.69c-0.216-1.608-0.346-3.48-0.36-5.379v-0.017c0.033-16.948 9.077-31.778 22.596-39.953l0.209-0.118-122.298-48.056c0.659 2.633 1.098 5.693 1.221 8.834l0.002 0.087z'%3e%3c/path%3e %3cpath fill='black' d='M241.36 410.132l-138.629-160.067c-4.734 17.421-18.861 30.61-36.472 33.911l-0.29 0.045 143.881 166.255c1.668-18.735 14.197-34.162 31.183-40.044l0.327-0.099z'%3e%3c/path%3e %3cpath fill='black' d='M243.446 115.105c-31.785 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.785 0 57.552 25.767 57.552 57.553v0c0 31.786-25.767 57.553-57.553 57.553v0zM243.446 21.582c-19.866 0-35.97 16.105-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c0-19.866-16.104-35.97-35.97-35.97v0z'%3e%3c/path%3e %3cpath fill='black' d='M483.224 410.78c-31.786 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.786 0 57.552 25.767 57.552 57.553v0c0 31.786-25.767 57.553-57.553 57.553v0zM483.224 317.257c-19.866 0-35.97 16.104-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c0-19.866-16.105-35.97-35.97-35.97v0z'%3e%3c/path%3e %3cpath fill='black' d='M57.553 295.531c-31.785 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.785 0 57.553 25.767 57.553 57.553v0c0 31.786-25.767 57.553-57.553 57.553v0zM57.553 202.008c-19.866 0-35.97 16.105-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c-0.041-19.835-16.13-35.898-35.97-35.898 0 0 0 0 0 0v0z'%3e%3c/path%3e %3cpath fill='black' d='M256.036 512.072c-31.786 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.786 0 57.553 25.767 57.553 57.553v0c0 31.786-25.767 57.553-57.553 57.553v0zM256.036 418.55c-19.866 0-35.97 16.104-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c0-19.866-16.105-35.97-35.97-35.97v0z'%3e%3c/path%3e %3cpath fill='black' d='M435.24 194.239c-31.786 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.786 0 57.553 25.767 57.553 57.553v0c0 31.785-25.767 57.553-57.553 57.553v0zM435.24 100.716c-19.866 0-35.97 16.105-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c0-19.866-16.105-35.97-35.97-35.97v0z'%3e%3c/path%3e%3c/svg%3e",alt:Ee.labels.editGeom}))))})}}const _t=document.createElement("div");class bt extends t.Control{_options;_i18n;_map;_view;_viewport;_initialized=!1;_layersControl;_overlay;_interactionWfsSelect;_interactionSelectModify;_collectionModify;_interactionModify;_interactionSnap;_interactionDraw;_keyClickWms;_keyRemove;_keySelect;_controlApplyDiscardChanges;_controlWidgetToolsDiv;_selectDraw;_currentZoom;_lastZoom;_editFeature;_editFeatureOriginal;_uploads;_editFields;constructor(e){super({target:null,element:_t,render:()=>{this._map||this._init()}}),((e="en",t=null)=>{e in we&&(Ee=we[e]),t&&(Ee={...Ee,...t})})(e.language,e.i18n);const t={layers:null,evtType:"singleclick",active:!0,showControl:!0,language:"en",uploadFormats:".geojson,.json,.kml",processUpload:null,modal:{animateClass:"fade",animateInClass:"show",transition:300,backdropTransition:150,templates:{dialog:'<div class="modal-dialog modal-dialog-centered"></div>',headerClose:`<button type="button" class="btn-close" data-dismiss="modal" aria-label="${Ee.labels.close}"><span aria-hidden="true">×</span></button>`}}};this._options=pt(t,e),Ke(this._options.layers[0]),this._controlWidgetToolsDiv=_t,this._controlWidgetToolsDiv.className="ol-wfst--tools-control",this._uploads=new ut(this._options),this._editFields=new ft(this._options.modal)}getLayers(){return Object.values(Je())}getLayerByName(e=""){const t=Je();return e&&e in t?t[e]:null}async _initMapAndLayers(){try{const e=this._options.layers;if(e.length){let t=0,s=0;e.forEach((e=>{e.getVisible()&&s++,e.on("layerRendered",(()=>{t++,t>=s&&(this._initialized||(this.dispatchEvent("load"),this._initialized=!0),Ce(!1))})),e.on("change:describeFeatureType",(()=>{const t=this._layersControl.addLayerEl(e);e.on("change:isVisible",(()=>{const s="ol-wfst--layer-not-visible";e.isVisibleByZoom()?t.classList.remove(s):t.classList.add(s)})),e.set(st.ISVISIBLE,this._currentZoom>e.getMinZoom()),this.dispatchEvent(new wt({type:"describeFeatureType",layer:e,data:e.getDescribeFeatureType()}))})),e._init(),this._map.addLayer(e),function(e){Object.assign($e,e)}({[e.get(st.NAME)]:e})})),this._createMapElements(this._options.showControl,this._options.active)}}catch(e){Ce(!1),_e(e.message,e)}}_init(){var e,t;this._map=super.getMap(),this._view=this._map.getView(),this._viewport=this._map.getViewport(),e=this._map,Ve=e,this._uploads.on("addedFeatures",(({features:e})=>{Ze().insertFeatures(e)})),this._uploads.on("loadedFeatures",(({features:e})=>{this.activateEditMode();const t=ht().getSource();t.addFeatures(e),this._view.fit(t.getExtent(),{size:this._map.getSize(),maxZoom:21,padding:[100,100,100,100]})})),this._editFields.on("save",(({feature:e})=>{this._collectionModify.remove(e)})),this._editFields.dispose("delete",(({feature:e})=>{this._deleteFeature(e,!0)})),this._addMapEvents(),t=this._options.modal,fe=t,this._controlWidgetToolsDiv.append((Se=document.createElement("div"),Se.className="ol-wfst--tools-control--loading",Se.innerHTML=Ee.labels.loading,Se)),this._initMapAndLayers()}async _createMapElements(e,t){this._prepareEditLayer(),this._addInteractions(),this._addInteractionHandlers(),e&&this._addMapControl(),this.activateEditMode(t)}_addInteractions(){const t=()=>{this._collectionModify=new q,this._interactionWfsSelect=new s.Select({hitTolerance:10,style:e=>gt(e),toggleCondition:i.never,filter:(e,t)=>ze()!==je.Edit&&t&&t instanceof it&&t===Ze()}),this._map.addInteraction(this._interactionWfsSelect),this._interactionWfsSelect.on("select",(({selected:e,deselected:t,mapBrowserEvent:s})=>{const o=s.coordinate;e.length&&e.forEach((e=>{if(!et(e)){const t=this._interactionWfsSelect.getLayer(e);t.getSource().removeFeature(e),this._addFeatureToEditMode(e,o,t.get(st.NAME))}})),t.length&&ze()!==je.Edit&&t.forEach((e=>{this._collectionModify.remove(e)}))}))},o=()=>{this._interactionSelectModify=new s.Select({style:e=>gt(e),layers:[ht()],toggleCondition:i.never,removeCondition:()=>ze()===je.Edit}),this._map.addInteraction(this._interactionSelectModify),this._collectionModify=this._interactionSelectModify.getFeatures(),this._keyClickWms=this._map.on(this._options.evtType,(async e=>{if(!this._map.hasFeatureAtPixel(e.pixel)&&ze()!==je.Edit){const t=Ze();if(!t.getVisible()||!t.isVisibleByZoom()||t instanceof it)return;const s=await t._getFeaturesByClickEvent(e);if(!s.length)return;this._addFeatureToEditMode(s[0],e.coordinate,t.get(st.NAME))}}))};this._options.layers.find((e=>e instanceof it))&&t(),this._options.layers.find((e=>e instanceof rt))&&o(),this._interactionModify=new s.Modify({style:()=>ze()===je.Edit?new e.Style({image:new e.Circle({radius:6,fill:new e.Fill({color:"#ff0000"}),stroke:new e.Stroke({width:2,color:"rgba(5, 5, 5, 0.9)"})})}):void 0,features:this._collectionModify,condition:e=>i.primaryAction(e)&&ze()===je.Edit}),this._map.addInteraction(this._interactionModify),this._interactionSnap=new s.Snap({source:ht().getSource()}),this._map.addInteraction(this._interactionSnap)}_prepareEditLayer(){this._map.addLayer(ht())}_addMapEvents(){(()=>{document.addEventListener("keydown",(({key:e})=>{if(!document.querySelector("input:focus")&&"Delete"===e){const e=this._collectionModify;e&&e.forEach((e=>{this._deleteFeature(e,!0)}))}}))})(),this._map.on("moveend",(()=>{if(this._currentZoom=this._view.getZoom(),this._currentZoom!==this._lastZoom){const e=Je();Object.keys(e).forEach((t=>{const s=e[t];this._currentZoom>s.getMinZoom()?s.get(st.ISVISIBLE)||s.set(st.ISVISIBLE,!0):s.get(st.ISVISIBLE)&&s.set(st.ISVISIBLE,!1)})),this._lastZoom=this._currentZoom}}))}_addInteractionHandlers(){this._interactionModify.on("modifyend",(e=>{Xe(e.features.item(0)),super.dispatchEvent(e)})),this._interactionModify.on("modifystart",(e=>{super.dispatchEvent(e)})),this._onDeselectFeatureEvent(),this._onRemoveFeatureEvent()}_addMapControl(){this._layersControl=new ct(this._options.showUpload?this._uploads:null,this._options.uploadFormats),this._layersControl.on("drawMode",(()=>{if(ze()===je.Draw)lt(),this.activateEditMode();else{Ze().isVisibleByZoom()?this.activateDrawMode(Ze()):_e(Ee.errors.layerNotVisible)}})),this._layersControl.on("changeGeom",(()=>{ze()===je.Draw&&this.activateDrawMode(Ze())}));const e=this._layersControl.render();this._selectDraw=e.querySelector(".wfst--tools-control--select-draw"),this._controlWidgetToolsDiv.append(e)}_deselectEditFeature(e){this._removeOverlayHelper(e)}_restoreFeatureToLayer(e,t){t=t||e.get("_layerName_");Je()[t].getSource().addFeature(e)}_removeFeatureFromTmpLayer(e){ht().getSource().removeFeature(e)}_onDeselectFeatureEvent(){const e=e=>{const t=e.get("_layerName_"),s=this._options.layers.find((e=>e.get(st.NAME)===t));s instanceof it&&this._interactionWfsSelect.getFeatures().remove(e),et(e)?s.transactFeatures(Re.Update,e):(s instanceof it&&this._restoreFeatureToLayer(e,t),this._removeFeatureFromTmpLayer(e))};this._keySelect=this._collectionModify.on("remove",(t=>{const s=t.element;this._deselectEditFeature(s),e(s),this._editModeOff()}))}_onRemoveFeatureEvent(){this._keyRemove=ht().getSource().on("removefeature",(e=>{const t=e.feature;if(!t.get("_delete_"))return;this._keySelect&&n.unByKey(this._keySelect);const s=t.get("_layerName_");this.getLayerByName(s).transactFeatures(Re.Delete,t),this._deselectEditFeature(t),this._editModeOff(),this._keySelect&&setTimeout((()=>{this._onDeselectFeatureEvent()}),150)}))}_editModeOn(e){this._editFeatureOriginal=e.clone(),He(je.Edit),ht().getSource().changed(),this._removeOverlayHelper(e),this._controlApplyDiscardChanges=new mt(e),this._controlApplyDiscardChanges.on("cancel",(({feature:e})=>{e.setGeometry(this._editFeatureOriginal.getGeometry()),Qe(e),this._collectionModify.remove(e)})),this._controlApplyDiscardChanges.on("apply",(({feature:e})=>{Ce(),this._collectionModify.remove(e)})),this._controlApplyDiscardChanges.on("delete",(({feature:e})=>{this._deleteFeature(e,!0)})),this._map.addControl(this._controlApplyDiscardChanges)}_editModeOff(){He(null),this._map.removeControl(this._controlApplyDiscardChanges)}_deleteFeature(e,t){const s=()=>{(Array.isArray(e)?e:[e]).forEach((e=>{e.set("_delete_",!0,!0),ht().getSource().removeFeature(e)})),this._collectionModify.clear();const t=e.get("_layerName_");this._options.layers.find((e=>e.get(st.NAME)===t))instanceof it&&this._interactionWfsSelect.getFeatures().remove(e)};if(t){ge.confirm(Ee.labels.confirmDelete,{...this._options.modal}).show().once("dismiss",(function(e,t,o){o&&o.value&&s()}))}else s()}_addFeatureToEditMode(e,t=null,s=null){if(this._collectionModify.getLength())return;s&&e.set("_layerName_",s);if((e?e.getProperties():"")&&e.getGeometry()){ht().getSource().addFeature(e),this._collectionModify.push(e);const o=new vt(e,t);o.on("editFields",(()=>{this._editFields.show(e)})),o.on("editGeom",(()=>{this._editModeOn(e)})),this._map.addOverlay(o);const i=Ye(s);i&&i.maybeLockFeature(e.getId())}}activateDrawMode(e){const t=e=>{this.activateEditMode(!1),this._interactionDraw&&this._map.removeInteraction(this._interactionDraw);const t=this._selectDraw.value;this._interactionDraw=new s.Draw({source:ht().getSource(),type:t,style:e=>gt(e),stopClick:!0}),this._map.addInteraction(this._interactionDraw),this._interactionDraw.on("drawstart",(e=>{super.dispatchEvent(e)})),this._interactionDraw.on("drawend",(t=>{const s=t.feature;e.transactFeatures(Re.Insert,s),super.dispatchEvent(t)}))};if(this._interactionDraw||e){if(e){if(!e.getVisible())return;(()=>{const e=document.querySelector(".ol-wfst--tools-control-btn-draw");e&&e.classList.add("wfst--active")})(),this._viewport.classList.add("draw-mode"),t(e)}else this._map.removeInteraction(this._interactionDraw),this._viewport.classList.remove("draw-mode");He(e?je.Draw:null)}}activateEditMode(e=!0){e?((()=>{const e=document.querySelector(".ol-wfst--tools-control-btn-edit");e&&e.classList.add("wfst--active")})(),this.activateDrawMode(!1)):this._collectionModify.clear(),this._interactionSelectModify&&this._interactionSelectModify.setActive(e),this._interactionModify.setActive(e),this._interactionWfsSelect&&this._interactionWfsSelect.setActive(e)}_removeOverlayHelper(e){const t=e.getId();if(!t)return;const s=this._map.getOverlayById(t);s&&this._map.removeOverlay(s)}}class wt extends o{data;layer;constructor(e){super(e.type),this.layer=e.layer,this.data=e.data}}var Et={WfsLayer:it,WmsLayer:rt,Geoserver:class extends f{_options;_countRequests;_insertFeatures;_updateFeatures;_deleteFeatures;_formatWFS;_formatGeoJSON;_formatKml;_xs;state_;constructor(e){super();const t={url:null,advanced:{getCapabilitiesVersion:"1.3.0",getFeatureVersion:"1.0.0",describeFeatureTypeVersion:"1.1.0",lockFeatureVersion:"1.1.0",wfsTransactionVersion:"1.1.0",projection:"EPSG:3857",lockFeatureParams:{expiry:5,lockId:"GeoServer",releaseAction:"SOME"}},headers:{},credentials:"same-origin",useLockFeature:!0};this._options=pt(t,e),this.setAdvanced(this._options.advanced),this.setHeaders(this._options.headers),this.setCredentials(this._options.credentials),this.setUrl(this._options.url),this.setUseLockFeature(this._options.useLockFeature),this._countRequests=0,this._insertFeatures=[],this._updateFeatures=[],this._deleteFeatures=[],this._formatWFS=new p.WFS,this._formatGeoJSON=new p.GeoJSON,this._formatKml=new p.KML({extractStyles:!1,showPointNames:!1}),this._xs=new XMLSerializer,this.getAndUpdateCapabilities(),this.on("change:capabilities",(()=>{this._checkGeoserverCapabilities()}))}getCapabilities(){return this.get(yt.CAPABILITIES)}setUrl(e,t=!1){this.set(yt.URL,e,t)}getUrl(){return this.get(yt.URL)}setHeaders(e={},t=!1){return this.set(yt.HEADERS,e,t)}getHeaders(){return this.get(yt.HEADERS)}setCredentials(e=null,t=!1){this.set(yt.CREDENTIALS,e,t)}getCredentials(){return this.get(yt.CREDENTIALS)}setAdvanced(e={},t=!1){this.set(yt.ADVANCED,e,t)}getAdvanced(){return this.get(yt.ADVANCED)}hasTransaction(){return this.get(yt.HASTRASNACTION)}hasLockFeature(){return this.get(yt.HASLOCKFEATURE)}getUseLockFeature(){return this.get(yt.USELOCKFEATURE)}setUseLockFeature(e,t=!1){this.set(yt.USELOCKFEATURE,e,t)}isLoaded(){return this.get(yt.ISLOADED)}getState(){return this.state_}async getAndUpdateCapabilities(){try{const e=new URLSearchParams({service:"wfs",version:this.getAdvanced().getCapabilitiesVersion,request:"GetCapabilities",exceptions:"application/json"}),t=this.getUrl()+"?"+e.toString(),s=await fetch(t,{headers:this.getHeaders(),credentials:this.getCredentials()});if(!s.ok)throw new Error("");const o=await s.text(),i=(new window.DOMParser).parseFromString(o,"text/xml");return this.set(yt.CAPABILITIES,i),this.state_=i?"ready":"error",i}catch(e){console.error(e);const t="string"==typeof e?e:Ee.errors.capabilities;_e(t,e)}}_checkGeoserverCapabilities(){const e=this.getCapabilities().getElementsByTagName("ows:Operation");if(Array.from(e).forEach((e=>{"Transaction"===e.getAttribute("name")?this.set(yt.HASTRASNACTION,!0):"LockFeature"===e.getAttribute("name")?this.set(yt.HASLOCKFEATURE,!0):"DescribeFeatureType"===e.getAttribute("name")&&this.set(yt.HASDESCRIBEFEATURETYPE,!0)})),!this.hasTransaction())throw Ee.errors.wfst}async transact(e,t,s){t=Array.isArray(t)?t:[t];const o=[],i=Ye(s);for(const s of t){let t=this._cloneFeature(s);const n=t.getGeometry();n instanceof g.GeometryCollection?this._transformGeoemtryCollectionToGeometries(t,n):n instanceof g.Circle&&this._transformCircleToPolygon(t,n),"beforeTransactFeature"in i&&"function"==typeof i.beforeTransactFeature&&(t=i.beforeTransactFeature(t,e)),t&&o.push(t)}if(!o.length)return _e(Ee.errors.noValidGeometry),!1;switch(e){case Re.Insert:this._insertFeatures=[...this._insertFeatures,...o];break;case Re.Update:this._updateFeatures=[...this._updateFeatures,...o];break;case Re.Delete:this._deleteFeatures=[...this._deleteFeatures,...o]}this._countRequests++;const n=this._countRequests;return new Promise(((o,r)=>{setTimeout((async()=>{try{if(n!==this._countRequests)return;let r=We().getView().getProjection().getCode();r="EPSG:4326"===r?"urn:x-ogc:def:crs:EPSG:4326":r;const a=i.getDescribeFeatureType()._parsed;if(!i)throw new Error(Ee.errors.layerNotFound);const l={featureNS:a.namespace,featureType:s,srsName:r,featurePrefix:null,nativeElements:null,version:this.getAdvanced().wfsTransactionVersion},c=this._formatWFS.writeTransaction(this._insertFeatures,this._updateFeatures,this._deleteFeatures,l);let d=this._xs.serializeToString(c);const h=a.geomType,u=a.geomField;if(h===De.GeometryCollection)if(e===Re.Insert)d=d.replace(/<geometry>/g,`<geometry><MultiGeometry xmlns="http://www.opengis.net/gml" srsName="${r}"><geometryMember>`),d=d.replace(/<\/geometry>/g,"</geometryMember></MultiGeometry></geometry>");else if(e===Re.Update){const e=`<MultiGeometry xmlns="http://www.opengis.net/gml" srsName="${r}"><geometryMember>`,t="</geometryMember></MultiGeometry>";d=d.replace(/(.*)(<Name>geometry<\/Name><Value>)(.*?)(<\/Value>)(.*)/g,`$1$2${e}$3${t}$4$5`)}d=e===Re.Insert?d.replace(/<(\/?)\bgeometry\b>/g,`<$1${u}>`):d.replace(/<Name>geometry<\/Name>/g,`<Name>${u}</Name>`),this.hasLockFeature&&this.getUseLockFeature()&&e!==Re.Insert&&(d=d.replace("</Transaction>",`<LockId>${this._options.advanced.lockFeatureParams.lockId}</LockId></Transaction>`));const p={"Content-Type":"text/xml",...this.getHeaders()},m=await fetch(this.getUrl(),{method:"POST",body:d,headers:p,credentials:this._options.credentials});if(!m.ok)throw new Error(Ee.errors.transaction+" "+m.status);const g=this._formatWFS.readTransactionResponse(await m.text());if(!Object.keys(g).length){const e=await m.text(),t=String(e).match(/<ows:ExceptionText>([\s\S]*?)<\/ows:ExceptionText>/);if(t)throw new Error(t[1])}if(e!==Re.Delete)for(const e of t)ht().getSource().removeFeature(e);Ye(s).refresh(),Ce(!1),this._insertFeatures=[],this._updateFeatures=[],this._deleteFeatures=[],this._countRequests=0,o(g)}catch(e){_e(e.message,e),Ce(!1),this._countRequests=0,r()}}),0)}))}_transformCircleToPolygon(e,t){const s=y.fromCircle(t);e.setGeometry(s)}_transformGeoemtryCollectionToGeometries(e,t){let s=t.getGeometries()[0];s instanceof g.Circle&&(s=y.fromCircle(s)),e.setGeometry(s)}_cloneFeature(e){Qe(e);const t=e.getProperties();delete t.boundedBy,delete t._layerName_;const s=new H(t);return s.setId(e.getId()),s}async lockFeature(e,t,s=0){const o=new URLSearchParams({service:"wfs",version:this.getAdvanced().lockFeatureVersion,request:"LockFeature",typeName:t,expiry:String(this._options.advanced.lockFeatureParams.expiry),LockId:this._options.advanced.lockFeatureParams.lockId,releaseAction:this._options.advanced.lockFeatureParams.releaseAction,exceptions:"application/json",featureid:`${e}`}),i=this.getUrl()+"?"+o.toString();try{const o=await fetch(i,{headers:this._options.headers,credentials:this._options.credentials});if(!o.ok)throw new Error(Ee.errors.lockFeature);const n=await o.text();try{const o=JSON.parse(n);if("exceptions"in o){const i=o.exceptions;"CannotLockAllFeatures"===i[0].code?s?_e(Ee.errors.lockFeature,i):this.lockFeature(e,t,1):_e(i[0].text,i)}}catch(e){}return n}catch(e){_e(e.message,e)}}}};return Object.assign(bt,Et),bt}));
2
2
  //# sourceMappingURL=ol-wfst.min.js.map