qy-vue-plugins 0.1.36 → 0.2.0

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.
@@ -2932,7 +2932,7 @@ const Wn = /* @__PURE__ */ le(Zn), zn = {
2932
2932
  a?.value && (a.value?.off("click", v), a.value?.off("dblclick", f), a.value.getCanvas().style.cursor = "", a.value.getLayer("measure-point-layer") && (a.value.removeLayer("measure-point-layer"), a.value.removeSource("measure-point-source")), a.value.getLayer("measure-line-layer") && (a.value.removeLayer("measure-line-layer"), a.value.removeSource("measure-line-source")), a.value.getLayer("measure-fill-layer") && (a.value.removeLayer("measure-fill-layer"), a.value.removeSource("measure-fill-source")), a.value.getLayer("measure-label-layer") && (a.value.removeLayer("measure-label-layer"), a.value.removeSource("measure-label-source")), r.value = [], o.value = null, i.value = null, s.value = !1, M.value = 0, k.value = 0, a.value.getLayer("measure-label-layer") && a.value.removeLayer("measure-label-layer"), a.value.getSource("measure-label-source") && a.value.removeSource("measure-label-source"));
2933
2933
  }
2934
2934
  Bt(() => {
2935
- V(), y && y(), a?.value && (a.value.removeControl(p), a.value?.off("draw.create", u), a.value?.off("click", v), a.value?.off("dblclick", f));
2935
+ V(), y && y(), a?.value && (a.value?.removeControl(p), a.value?.off("draw.create", u), a.value?.off("click", v), a.value?.off("dblclick", f));
2936
2936
  });
2937
2937
  const M = Z(0), H = he(() => M.value < 1 ? `${(M.value * 1e3).toFixed(2)} 米` : `${M.value.toFixed(3)} 公里`), k = Z(0), Ut = he(() => k.value < 1 ? `${(k.value * 1e6).toFixed(2)} 平方米` : `${k.value.toFixed(3)} 平方公里`), Gt = he(() => l.value === "distance" ? H.value : Ut.value), Vt = he(() => l.value === "distance" ? "总长度: " : "总面积: ");
2938
2938
  return (I, g) => (z(), W($t, null, [
@@ -1 +1 @@
1
- "use strict";const p=require("vue"),oe=require("./_commonjsHelpers-DwGv2jUC.js"),At=require("./ProvideKeys-jy8dfV9u.js"),Ge=require("./EventKeys-BLmCVdTJ.js"),Ft=require("./constant-Bc8XErtI.js"),Dt=require("@turf/turf"),wt=require("@element-plus/icons-vue"),Rt=require("element-plus");function kt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Q=kt(Dt),R={CANVAS:"mapboxgl-canvas",CONTROL_BASE:"mapboxgl-ctrl",CONTROL_PREFIX:"mapboxgl-ctrl-",CONTROL_BUTTON:"mapbox-gl-draw_ctrl-draw-btn",CONTROL_BUTTON_LINE:"mapbox-gl-draw_line",CONTROL_BUTTON_POLYGON:"mapbox-gl-draw_polygon",CONTROL_BUTTON_POINT:"mapbox-gl-draw_point",CONTROL_BUTTON_TRASH:"mapbox-gl-draw_trash",CONTROL_BUTTON_COMBINE_FEATURES:"mapbox-gl-draw_combine",CONTROL_BUTTON_UNCOMBINE_FEATURES:"mapbox-gl-draw_uncombine",CONTROL_GROUP:"mapboxgl-ctrl-group",ATTRIBUTION:"mapboxgl-ctrl-attrib",ACTIVE_BUTTON:"active",BOX_SELECT:"mapbox-gl-draw_boxselect"},G={HOT:"mapbox-gl-draw-hot",COLD:"mapbox-gl-draw-cold"},I={ADD:"add",MOVE:"move",DRAG:"drag",POINTER:"pointer",NONE:"none"},k={POLYGON:"polygon",LINE:"line_string",POINT:"point"},g={FEATURE:"Feature",POLYGON:"Polygon",LINE_STRING:"LineString",POINT:"Point",FEATURE_COLLECTION:"FeatureCollection",MULTI_PREFIX:"Multi",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon"},v={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select"},D={CREATE:"draw.create",DELETE:"draw.delete",UPDATE:"draw.update",SELECTION_CHANGE:"draw.selectionchange",MODE_CHANGE:"draw.modechange",ACTIONABLE:"draw.actionable",RENDER:"draw.render",COMBINE_FEATURES:"draw.combine",UNCOMBINE_FEATURES:"draw.uncombine"},ie={MOVE:"move",CHANGE_PROPERTIES:"change_properties",CHANGE_COORDINATES:"change_coordinates"},P={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},b={ACTIVE:"true",INACTIVE:"false"},it=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],Ut=-90,Oe=-85,Vt=90,be=85,xt=-270,Bt=270,st=Object.freeze(Object.defineProperty({__proto__:null,LAT_MAX:Vt,LAT_MIN:Ut,LAT_RENDERED_MAX:be,LAT_RENDERED_MIN:Oe,LNG_MAX:Bt,LNG_MIN:xt,activeStates:b,classes:R,cursors:I,events:D,geojsonTypes:g,interactions:it,meta:P,modes:v,sources:G,types:k,updateActions:ie},Symbol.toStringTag,{value:"Module"}));function me(e){return function(t){const n=t.featureTarget;return!n||!n.properties?!1:n.properties.meta===e}}function at(e){return!e.originalEvent||!e.originalEvent.shiftKey?!1:e.originalEvent.button===0}function z(e){return!e.featureTarget||!e.featureTarget.properties?!1:e.featureTarget.properties.active===b.ACTIVE&&e.featureTarget.properties.meta===P.FEATURE}function De(e){return!e.featureTarget||!e.featureTarget.properties?!1:e.featureTarget.properties.active===b.INACTIVE&&e.featureTarget.properties.meta===P.FEATURE}function ye(e){return e.featureTarget===void 0}function we(e){return!e.featureTarget||!e.featureTarget.properties?!1:e.featureTarget.properties.meta===P.FEATURE}function se(e){const t=e.featureTarget;return!t||!t.properties?!1:t.properties.meta===P.VERTEX}function he(e){return e.originalEvent?e.originalEvent.shiftKey===!0:!1}function Ee(e){return e.key==="Escape"||e.keyCode===27}function ve(e){return e.key==="Enter"||e.keyCode===13}function Le(e){return e.key==="Backspace"||e.keyCode===8}function Ne(e){return e.key==="Delete"||e.keyCode===46}function ut(e){return e.key==="1"||e.keyCode===49}function lt(e){return e.key==="2"||e.keyCode===50}function ct(e){return e.key==="3"||e.keyCode===51}function dt(e){const t=e.key||String.fromCharCode(e.keyCode);return t>="0"&&t<="9"}function Gt(){return!0}const $t=Object.freeze(Object.defineProperty({__proto__:null,isActiveFeature:z,isBackspaceKey:Le,isDeleteKey:Ne,isDigit1Key:ut,isDigit2Key:lt,isDigit3Key:ct,isDigitKey:dt,isEnterKey:ve,isEscapeKey:Ee,isFeature:we,isInactiveFeature:De,isOfMetaType:me,isShiftDown:he,isShiftMousedown:at,isTrue:Gt,isVertex:se,noTarget:ye},Symbol.toStringTag,{value:"Module"}));var le={},te={},$e;function qt(){return $e||($e=1,te.RADIUS=6378137,te.FLATTENING=1/298.257223563,te.POLAR_RADIUS=63567523142e-4),te}var qe;function Jt(){if(qe)return le;qe=1;var e=qt();le.geometry=t,le.ring=r;function t(i){var s=0,l;switch(i.type){case"Polygon":return n(i.coordinates);case"MultiPolygon":for(l=0;l<i.coordinates.length;l++)s+=n(i.coordinates[l]);return s;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(l=0;l<i.geometries.length;l++)s+=t(i.geometries[l]);return s}}function n(i){var s=0;if(i&&i.length>0){s+=Math.abs(r(i[0]));for(var l=1;l<i.length;l++)s-=Math.abs(r(i[l]))}return s}function r(i){var s,l,c,a,h,E,u,d=0,f=i.length;if(f>2){for(u=0;u<f;u++)u===f-2?(a=f-2,h=f-1,E=0):u===f-1?(a=f-1,h=0,E=1):(a=u,h=u+1,E=u+2),s=i[a],l=i[h],c=i[E],d+=(o(c[0])-o(s[0]))*Math.sin(o(l[1]));d=d*e.RADIUS*e.RADIUS/2}return d}function o(i){return i*Math.PI/180}return le}var Kt=Jt();const Yt=oe.getDefaultExportFromCjs(Kt),Je={Point:0,LineString:1,MultiLineString:1,Polygon:2};function Xt(e,t){const n=Je[e.geometry.type]-Je[t.geometry.type];return n===0&&e.geometry.type===g.POLYGON?e.area-t.area:n}function ft(e){return e.map(t=>(t.geometry.type===g.POLYGON&&(t.area=Yt.geometry({type:g.FEATURE,property:{},geometry:t.geometry})),t)).sort(Xt).map(t=>(delete t.area,t))}function pt(e,t=0){return[[e.point.x-t,e.point.y-t],[e.point.x+t,e.point.y+t]]}function $(e){if(this._items={},this._nums={},this._length=e?e.length:0,!!e)for(let t=0,n=e.length;t<n;t++)this.add(e[t]),e[t]!==void 0&&(typeof e[t]=="string"?this._items[e[t]]=t:this._nums[e[t]]=t)}$.prototype.add=function(e){return this.has(e)?this:(this._length++,typeof e=="string"?this._items[e]=this._length:this._nums[e]=this._length,this)};$.prototype.delete=function(e){return this.has(e)===!1?this:(this._length--,delete this._items[e],delete this._nums[e],this)};$.prototype.has=function(e){return typeof e!="string"&&typeof e!="number"?!1:this._items[e]!==void 0||this._nums[e]!==void 0};$.prototype.values=function(){const e=[];return Object.keys(this._items).forEach(t=>{e.push({k:t,v:this._items[t]})}),Object.keys(this._nums).forEach(t=>{e.push({k:JSON.parse(t),v:this._nums[t]})}),e.sort((t,n)=>t.v-n.v).map(t=>t.k)};$.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};const Ht=[P.FEATURE,P.MIDPOINT,P.VERTEX],j={click:Zt,touch:Wt};function Zt(e,t,n){return ht(e,t,n,n.options.clickBuffer)}function Wt(e,t,n){return ht(e,t,n,n.options.touchBuffer)}function ht(e,t,n,r){if(n.map===null)return[];const o=e?pt(e,r):t,i={};n.options.styles&&(i.layers=n.options.styles.map(a=>a.id).filter(a=>n.map.getLayer(a)!=null));const s=n.map.queryRenderedFeatures(o,i).filter(a=>Ht.indexOf(a.properties.meta)!==-1),l=new $,c=[];return s.forEach(a=>{const h=a.properties.id;l.has(h)||(l.add(h),c.push(a))}),ft(c)}function pe(e,t){const n=j.click(e,null,t),r={mouse:I.NONE};return n[0]&&(r.mouse=n[0].properties.active===b.ACTIVE?I.MOVE:I.POINTER,r.feature=n[0].properties.meta),t.events.currentModeName().indexOf("draw")!==-1&&(r.mouse=I.ADD),t.ui.queueMapClasses(r),t.ui.updateMapClasses(),n[0]}function Re(e,t){const n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}const zt=4,Qt=12,jt=500;function Pe(e,t,n={}){const r=n.fineTolerance!=null?n.fineTolerance:zt,o=n.grossTolerance!=null?n.grossTolerance:Qt,i=n.interval!=null?n.interval:jt;e.point=e.point||t.point,e.time=e.time||t.time;const s=Re(e.point,t.point);return s<r||s<o&&t.time-e.time<i}const en=25,tn=250;function Ae(e,t,n={}){const r=n.tolerance!=null?n.tolerance:en,o=n.interval!=null?n.interval:tn;return e.point=e.point||t.point,e.time=e.time||t.time,Re(e.point,t.point)<r&&t.time-e.time<o}const Fe=function(e,t){const n={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},r={on(i,s,l){if(n[i]===void 0)throw new Error(`Invalid event type: ${i}`);n[i].push({selector:s,fn:l})},render(i){t.store.featureChanged(i)}},o=function(i,s){const l=n[i];let c=l.length;for(;c--;){const a=l[c];if(a.selector(s)){a.fn.call(r,s)||t.store.render(),t.ui.updateMapClasses();break}}};return e.start.call(r),{render:e.render,stop(){e.stop&&e.stop()},trash(){e.trash&&(e.trash(),t.store.render())},combineFeatures(){e.combineFeatures&&e.combineFeatures()},uncombineFeatures(){e.uncombineFeatures&&e.uncombineFeatures()},drag(i){o("drag",i)},click(i){o("click",i)},mousemove(i){o("mousemove",i)},mousedown(i){o("mousedown",i)},mouseup(i){o("mouseup",i)},mouseout(i){o("mouseout",i)},keydown(i){o("keydown",i)},keyup(i){o("keyup",i)},touchstart(i){o("touchstart",i)},touchmove(i){o("touchmove",i)},touchend(i){o("touchend",i)},tap(i){o("tap",i)}}};let nn=(e,t=21)=>(n=t)=>{let r="",o=n|0;for(;o--;)r+=e[Math.random()*e.length|0];return r};const rn=nn("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",32);function ke(){return rn()}const w=function(e,t){this.ctx=e,this.properties=t.properties||{},this.coordinates=t.geometry.coordinates,this.id=t.id||ke(),this.type=t.geometry.type};w.prototype.changed=function(){this.ctx.store.featureChanged(this.id)};w.prototype.incomingCoords=function(e){this.setCoordinates(e)};w.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()};w.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))};w.prototype.setProperty=function(e,t){this.properties[e]=t};w.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:g.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))};w.prototype.internal=function(e){const t={id:this.id,meta:P.FEATURE,"meta:type":this.type,active:b.INACTIVE,mode:e};if(this.ctx.options.userProperties)for(const n in this.properties)t[`user_${n}`]=this.properties[n];return{type:g.FEATURE,properties:t,geometry:{coordinates:this.getCoordinates(),type:this.type}}};const W=function(e,t){w.call(this,e,t)};W.prototype=Object.create(w.prototype);W.prototype.isValid=function(){return typeof this.coordinates[0]=="number"&&typeof this.coordinates[1]=="number"};W.prototype.updateCoordinate=function(e,t,n){arguments.length===3?this.coordinates=[t,n]:this.coordinates=[e,t],this.changed()};W.prototype.getCoordinate=function(){return this.getCoordinates()};const X=function(e,t){w.call(this,e,t)};X.prototype=Object.create(w.prototype);X.prototype.isValid=function(){return this.coordinates.length>1};X.prototype.addCoordinate=function(e,t,n){this.changed();const r=parseInt(e,10);this.coordinates.splice(r,0,[t,n])};X.prototype.getCoordinate=function(e){const t=parseInt(e,10);return JSON.parse(JSON.stringify(this.coordinates[t]))};X.prototype.removeCoordinate=function(e){this.changed(),this.coordinates.splice(parseInt(e,10),1)};X.prototype.updateCoordinate=function(e,t,n){const r=parseInt(e,10);this.coordinates[r]=[t,n],this.changed()};const x=function(e,t){w.call(this,e,t),this.coordinates=this.coordinates.map(n=>n.slice(0,-1))};x.prototype=Object.create(w.prototype);x.prototype.isValid=function(){return this.coordinates.length===0?!1:this.coordinates.every(e=>e.length>2)};x.prototype.incomingCoords=function(e){this.coordinates=e.map(t=>t.slice(0,-1)),this.changed()};x.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()};x.prototype.addCoordinate=function(e,t,n){this.changed();const r=e.split(".").map(i=>parseInt(i,10));this.coordinates[r[0]].splice(r[1],0,[t,n])};x.prototype.removeCoordinate=function(e){this.changed();const t=e.split(".").map(r=>parseInt(r,10)),n=this.coordinates[t[0]];n&&(n.splice(t[1],1),n.length<3&&this.coordinates.splice(t[0],1))};x.prototype.getCoordinate=function(e){const t=e.split(".").map(r=>parseInt(r,10)),n=this.coordinates[t[0]];return JSON.parse(JSON.stringify(n[t[1]]))};x.prototype.getCoordinates=function(){return this.coordinates.map(e=>e.concat([e[0]]))};x.prototype.updateCoordinate=function(e,t,n){this.changed();const r=e.split("."),o=parseInt(r[0],10),i=parseInt(r[1],10);this.coordinates[o]===void 0&&(this.coordinates[o]=[]),this.coordinates[o][i]=[t,n]};const on={MultiPoint:W,MultiLineString:X,MultiPolygon:x},Ce=(e,t,n,r,o)=>{const i=n.split("."),s=parseInt(i[0],10),l=i[1]?i.slice(1).join("."):null;return e[s][t](l,r,o)},F=function(e,t){if(w.call(this,e,t),delete this.coordinates,this.model=on[t.geometry.type],this.model===void 0)throw new TypeError(`${t.geometry.type} is not a valid type`);this.features=this._coordinatesToFeatures(t.geometry.coordinates)};F.prototype=Object.create(w.prototype);F.prototype._coordinatesToFeatures=function(e){const t=this.model.bind(this);return e.map(n=>new t(this.ctx,{id:ke(),type:g.FEATURE,properties:{},geometry:{coordinates:n,type:this.type.replace("Multi","")}}))};F.prototype.isValid=function(){return this.features.every(e=>e.isValid())};F.prototype.setCoordinates=function(e){this.features=this._coordinatesToFeatures(e),this.changed()};F.prototype.getCoordinate=function(e){return Ce(this.features,"getCoordinate",e)};F.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(e=>e.type===g.POLYGON?e.getCoordinates():e.coordinates)))};F.prototype.updateCoordinate=function(e,t,n){Ce(this.features,"updateCoordinate",e,t,n),this.changed()};F.prototype.addCoordinate=function(e,t,n){Ce(this.features,"addCoordinate",e,t,n),this.changed()};F.prototype.removeCoordinate=function(e){Ce(this.features,"removeCoordinate",e),this.changed()};F.prototype.getFeatures=function(){return this.features};function y(e){this.map=e.map,this.drawConfig=JSON.parse(JSON.stringify(e.options||{})),this._ctx=e}y.prototype.setSelected=function(e){return this._ctx.store.setSelected(e)};y.prototype.setSelectedCoordinates=function(e){this._ctx.store.setSelectedCoordinates(e),e.reduce((t,n)=>(t[n.feature_id]===void 0&&(t[n.feature_id]=!0,this._ctx.store.get(n.feature_id).changed()),t),{})};y.prototype.getSelected=function(){return this._ctx.store.getSelected()};y.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()};y.prototype.isSelected=function(e){return this._ctx.store.isSelected(e)};y.prototype.getFeature=function(e){return this._ctx.store.get(e)};y.prototype.select=function(e){return this._ctx.store.select(e)};y.prototype.deselect=function(e){return this._ctx.store.deselect(e)};y.prototype.deleteFeature=function(e,t={}){return this._ctx.store.delete(e,t)};y.prototype.addFeature=function(e,t={}){return this._ctx.store.add(e,t)};y.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()};y.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()};y.prototype.setActionableState=function(e={}){const t={trash:e.trash||!1,combineFeatures:e.combineFeatures||!1,uncombineFeatures:e.uncombineFeatures||!1};return this._ctx.events.actionable(t)};y.prototype.changeMode=function(e,t={},n={}){return this._ctx.events.changeMode(e,t,n)};y.prototype.fire=function(e,t){return this._ctx.events.fire(e,t)};y.prototype.updateUIClasses=function(e){return this._ctx.ui.queueMapClasses(e)};y.prototype.activateUIButton=function(e){return this._ctx.ui.setActiveButton(e)};y.prototype.featuresAt=function(e,t,n="click"){if(n!=="click"&&n!=="touch")throw new Error("invalid buffer type");return j[n](e,t,this._ctx)};y.prototype.newFeature=function(e){const t=e.geometry.type;return t===g.POINT?new W(this._ctx,e):t===g.LINE_STRING?new X(this._ctx,e):t===g.POLYGON?new x(this._ctx,e):new F(this._ctx,e)};y.prototype.isInstanceOf=function(e,t){if(e===g.POINT)return t instanceof W;if(e===g.LINE_STRING)return t instanceof X;if(e===g.POLYGON)return t instanceof x;if(e==="MultiFeature")return t instanceof F;throw new Error(`Unknown feature class: ${e}`)};y.prototype.doRender=function(e){return this._ctx.store.featureChanged(e)};y.prototype.onSetup=function(){};y.prototype.onDrag=function(){};y.prototype.onClick=function(){};y.prototype.onMouseMove=function(){};y.prototype.onMouseDown=function(){};y.prototype.onMouseUp=function(){};y.prototype.onMouseOut=function(){};y.prototype.onKeyUp=function(){};y.prototype.onKeyDown=function(){};y.prototype.onTouchStart=function(){};y.prototype.onTouchMove=function(){};y.prototype.onTouchEnd=function(){};y.prototype.onTap=function(){};y.prototype.onStop=function(){};y.prototype.onTrash=function(){};y.prototype.onCombineFeature=function(){};y.prototype.onUncombineFeature=function(){};y.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};const gt={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},sn=Object.keys(gt);function an(e){const t=Object.keys(e);return function(n,r={}){let o={};const i=t.reduce((l,c)=>(l[c]=e[c],l),new y(n));function s(l){return c=>i[l](o,c)}return{start(){o=i.onSetup(r),sn.forEach(l=>{const c=gt[l];let a=()=>!1;e[c]&&(a=()=>!0),this.on(l,a,s(c))})},stop(){i.onStop(o)},trash(){i.onTrash(o)},combineFeatures(){i.onCombineFeatures(o)},uncombineFeatures(){i.onUncombineFeatures(o)},render(l,c){i.toDisplayFeatures(o,l,c)}}}}function un(e){const t=Object.keys(e.options.modes).reduce((u,d)=>(u[d]=an(e.options.modes[d]),u),{});let n={},r={};const o={};let i=null,s=null;o.drag=function(u,d){d({point:u.point,time:new Date().getTime()})?(e.ui.queueMapClasses({mouse:I.DRAG}),s.drag(u)):u.originalEvent.stopPropagation()},o.mousedrag=function(u){o.drag(u,d=>!Pe(n,d))},o.touchdrag=function(u){o.drag(u,d=>!Ae(r,d))},o.mousemove=function(u){if((u.originalEvent.buttons!==void 0?u.originalEvent.buttons:u.originalEvent.which)===1)return o.mousedrag(u);const f=pe(u,e);u.featureTarget=f,s.mousemove(u)},o.mousedown=function(u){n={time:new Date().getTime(),point:u.point};const d=pe(u,e);u.featureTarget=d,s.mousedown(u)},o.mouseup=function(u){const d=pe(u,e);u.featureTarget=d,Pe(n,{point:u.point,time:new Date().getTime()})?s.click(u):s.mouseup(u)},o.mouseout=function(u){s.mouseout(u)},o.touchstart=function(u){if(!e.options.touchEnabled)return;r={time:new Date().getTime(),point:u.point};const d=j.touch(u,null,e)[0];u.featureTarget=d,s.touchstart(u)},o.touchmove=function(u){if(e.options.touchEnabled)return s.touchmove(u),o.touchdrag(u)},o.touchend=function(u){if(u.originalEvent.preventDefault(),!e.options.touchEnabled)return;const d=j.touch(u,null,e)[0];u.featureTarget=d,Ae(r,{time:new Date().getTime(),point:u.point})?s.tap(u):s.touchend(u)};const l=u=>{const d=Le(u),f=Ne(u),C=dt(u);return!(d||f||C)};o.keydown=function(u){(u.srcElement||u.target).classList.contains(R.CANVAS)&&((Le(u)||Ne(u))&&e.options.controls.trash?(u.preventDefault(),s.trash()):l(u)?s.keydown(u):ut(u)&&e.options.controls.point?c(v.DRAW_POINT):lt(u)&&e.options.controls.line_string?c(v.DRAW_LINE_STRING):ct(u)&&e.options.controls.polygon&&c(v.DRAW_POLYGON))},o.keyup=function(u){l(u)&&s.keyup(u)},o.zoomend=function(){e.store.changeZoom()},o.data=function(u){if(u.dataType==="style"){const{setup:d,map:f,options:C,store:L}=e;C.styles.some(B=>f.getLayer(B.id))||(d.addLayers(),L.setDirty(),L.render())}};function c(u,d,f={}){s.stop();const C=t[u];if(C===void 0)throw new Error(`${u} is not valid`);i=u;const L=C(e,d);s=Fe(L,e),f.silent||e.map.fire(D.MODE_CHANGE,{mode:u}),e.store.setDirty(),e.store.render()}const a={trash:!1,combineFeatures:!1,uncombineFeatures:!1};function h(u){let d=!1;Object.keys(u).forEach(f=>{if(a[f]===void 0)throw new Error("Invalid action type");a[f]!==u[f]&&(d=!0),a[f]=u[f]}),d&&e.map.fire(D.ACTIONABLE,{actions:a})}return{start(){i=e.options.defaultMode,s=Fe(t[i](e),e)},changeMode:c,actionable:h,currentModeName(){return i},currentModeRender(u,d){return s.render(u,d)},fire(u,d){e.map&&e.map.fire(u,d)},addEventListeners(){e.map.on("mousemove",o.mousemove),e.map.on("mousedown",o.mousedown),e.map.on("mouseup",o.mouseup),e.map.on("data",o.data),e.map.on("touchmove",o.touchmove),e.map.on("touchstart",o.touchstart),e.map.on("touchend",o.touchend),e.container.addEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",o.keydown),e.container.addEventListener("keyup",o.keyup))},removeEventListeners(){e.map.off("mousemove",o.mousemove),e.map.off("mousedown",o.mousedown),e.map.off("mouseup",o.mouseup),e.map.off("data",o.data),e.map.off("touchmove",o.touchmove),e.map.off("touchstart",o.touchstart),e.map.off("touchend",o.touchend),e.container.removeEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",o.keydown),e.container.removeEventListener("keyup",o.keyup))},trash(u){s.trash(u)},combineFeatures(){s.combineFeatures()},uncombineFeatures(){s.uncombineFeatures()},getMode(){return i}}}function ae(e){return[].concat(e).filter(t=>t!==void 0)}function ln(){const e=this;if(!(e.ctx.map&&e.ctx.map.getSource(G.HOT)!==void 0))return c();const n=e.ctx.events.currentModeName();e.ctx.ui.queueMapClasses({mode:n});let r=[],o=[];e.isDirty?o=e.getAllIds():(r=e.getChangedIds().filter(a=>e.get(a)!==void 0),o=e.sources.hot.filter(a=>a.properties.id&&r.indexOf(a.properties.id)===-1&&e.get(a.properties.id)!==void 0).map(a=>a.properties.id)),e.sources.hot=[];const i=e.sources.cold.length;e.sources.cold=e.isDirty?[]:e.sources.cold.filter(a=>{const h=a.properties.id||a.properties.parent;return r.indexOf(h)===-1});const s=i!==e.sources.cold.length||o.length>0;r.forEach(a=>l(a,"hot")),o.forEach(a=>l(a,"cold"));function l(a,h){const u=e.get(a).internal(n);e.ctx.events.currentModeRender(u,d=>{d.properties.mode=n,e.sources[h].push(d)})}s&&e.ctx.map.getSource(G.COLD).setData({type:g.FEATURE_COLLECTION,features:e.sources.cold}),e.ctx.map.getSource(G.HOT).setData({type:g.FEATURE_COLLECTION,features:e.sources.hot}),c();function c(){e.isDirty=!1,e.clearChangedIds()}}function _(e){this._features={},this._featureIds=new $,this._selectedFeatureIds=new $,this._selectedCoordinates=[],this._changedFeatureIds=new $,this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=e,this.sources={hot:[],cold:[]};let t;this.render=()=>{t||(t=requestAnimationFrame(()=>{t=null,ln.call(this),this._emitSelectionChange&&(this.ctx.events.fire(D.SELECTION_CHANGE,{features:this.getSelected().map(n=>n.toGeoJSON()),points:this.getSelectedCoordinates().map(n=>({type:g.FEATURE,properties:{},geometry:{type:g.POINT,coordinates:n.coordinates}}))}),this._emitSelectionChange=!1),this.ctx.events.fire(D.RENDER,{})}))},this.isDirty=!1}_.prototype.createRenderBatch=function(){const e=this.render;let t=0;return this.render=function(){t++},()=>{this.render=e,t>0&&this.render()}};_.prototype.setDirty=function(){return this.isDirty=!0,this};_.prototype.featureCreated=function(e,t={}){if(this._changedFeatureIds.add(e),(t.silent!=null?t.silent:this.ctx.options.suppressAPIEvents)!==!0){const r=this.get(e);this.ctx.events.fire(D.CREATE,{features:[r.toGeoJSON()]})}return this};_.prototype.featureChanged=function(e,t={}){return this._changedFeatureIds.add(e),(t.silent!=null?t.silent:this.ctx.options.suppressAPIEvents)!==!0&&this.ctx.events.fire(D.UPDATE,{action:t.action?t.action:ie.CHANGE_COORDINATES,features:[this.get(e).toGeoJSON()]}),this};_.prototype.getChangedIds=function(){return this._changedFeatureIds.values()};_.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this};_.prototype.getAllIds=function(){return this._featureIds.values()};_.prototype.add=function(e,t={}){return this._features[e.id]=e,this._featureIds.add(e.id),this.featureCreated(e.id,{silent:t.silent}),this};_.prototype.delete=function(e,t={}){const n=[];return ae(e).forEach(r=>{this._featureIds.has(r)&&(this._featureIds.delete(r),this._selectedFeatureIds.delete(r),t.silent||n.indexOf(this._features[r])===-1&&n.push(this._features[r].toGeoJSON()),delete this._features[r],this.isDirty=!0)}),n.length&&this.ctx.events.fire(D.DELETE,{features:n}),mt(this,t),this};_.prototype.get=function(e){return this._features[e]};_.prototype.getAll=function(){return Object.keys(this._features).map(e=>this._features[e])};_.prototype.select=function(e,t={}){return ae(e).forEach(n=>{this._selectedFeatureIds.has(n)||(this._selectedFeatureIds.add(n),this._changedFeatureIds.add(n),t.silent||(this._emitSelectionChange=!0))}),this};_.prototype.deselect=function(e,t={}){return ae(e).forEach(n=>{this._selectedFeatureIds.has(n)&&(this._selectedFeatureIds.delete(n),this._changedFeatureIds.add(n),t.silent||(this._emitSelectionChange=!0))}),mt(this,t),this};_.prototype.clearSelected=function(e={}){return this.deselect(this._selectedFeatureIds.values(),{silent:e.silent}),this};_.prototype.setSelected=function(e,t={}){return e=ae(e),this.deselect(this._selectedFeatureIds.values().filter(n=>e.indexOf(n)===-1),{silent:t.silent}),this.select(e.filter(n=>!this._selectedFeatureIds.has(n)),{silent:t.silent}),this};_.prototype.setSelectedCoordinates=function(e){return this._selectedCoordinates=e,this._emitSelectionChange=!0,this};_.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this};_.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()};_.prototype.getSelected=function(){return this.getSelectedIds().map(e=>this.get(e))};_.prototype.getSelectedCoordinates=function(){return this._selectedCoordinates.map(t=>({coordinates:this.get(t.feature_id).getCoordinate(t.coord_path)}))};_.prototype.isSelected=function(e){return this._selectedFeatureIds.has(e)};_.prototype.setFeatureProperty=function(e,t,n,r={}){this.get(e).setProperty(t,n),this.featureChanged(e,{silent:r.silent,action:ie.CHANGE_PROPERTIES})};function mt(e,t={}){const n=e._selectedCoordinates.filter(r=>e._selectedFeatureIds.has(r.feature_id));e._selectedCoordinates.length!==n.length&&!t.silent&&(e._emitSelectionChange=!0),e._selectedCoordinates=n}_.prototype.storeMapConfig=function(){it.forEach(e=>{this.ctx.map[e]&&(this._mapInitialConfig[e]=this.ctx.map[e].isEnabled())})};_.prototype.restoreMapConfig=function(){Object.keys(this._mapInitialConfig).forEach(e=>{this._mapInitialConfig[e]?this.ctx.map[e].enable():this.ctx.map[e].disable()})};_.prototype.getInitialConfigValue=function(e){return this._mapInitialConfig[e]!==void 0?this._mapInitialConfig[e]:!0};const cn=["mode","feature","mouse"];function dn(e){const t={};let n=null,r={mode:null,feature:null,mouse:null},o={mode:null,feature:null,mouse:null};function i(){s({mode:null,feature:null,mouse:null}),l()}function s(d){o=Object.assign(o,d)}function l(){if(!e.container)return;const d=[],f=[];cn.forEach(C=>{o[C]!==r[C]&&(d.push(`${C}-${r[C]}`),o[C]!==null&&f.push(`${C}-${o[C]}`))}),d.length>0&&e.container.classList.remove(...d),f.length>0&&e.container.classList.add(...f),r=Object.assign(r,o)}function c(d,f={}){const C=document.createElement("button");return C.className=`${R.CONTROL_BUTTON} ${f.className}`,C.setAttribute("title",f.title),f.container.appendChild(C),C.addEventListener("click",L=>{if(L.preventDefault(),L.stopPropagation(),L.target===n){a(),f.onDeactivate();return}h(d),f.onActivate()},!0),C}function a(){n&&(n.classList.remove(R.ACTIVE_BUTTON),n=null)}function h(d){a();const f=t[d];f&&f&&d!=="trash"&&(f.classList.add(R.ACTIVE_BUTTON),n=f)}function E(){const d=e.options.controls,f=document.createElement("div");return f.className=`${R.CONTROL_GROUP} ${R.CONTROL_BASE}`,d&&(d[k.POINT]&&(t[k.POINT]=c(k.POINT,{container:f,className:R.CONTROL_BUTTON_POINT,title:`Marker tool ${e.options.keybindings?"(1)":""}`,onActivate:()=>e.events.changeMode(v.DRAW_POINT),onDeactivate:()=>e.events.trash()})),d[k.LINE]&&(t[k.LINE]=c(k.LINE,{container:f,className:R.CONTROL_BUTTON_LINE,title:`LineString tool ${e.options.keybindings?"(2)":""}`,onActivate:()=>e.events.changeMode(v.DRAW_LINE_STRING),onDeactivate:()=>e.events.trash()})),d[k.POLYGON]&&(t[k.POLYGON]=c(k.POLYGON,{container:f,className:R.CONTROL_BUTTON_POLYGON,title:`Polygon tool ${e.options.keybindings?"(3)":""}`,onActivate:()=>e.events.changeMode(v.DRAW_POLYGON),onDeactivate:()=>e.events.trash()})),d.trash&&(t.trash=c("trash",{container:f,className:R.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:()=>{e.events.trash()}})),d.combine_features&&(t.combine_features=c("combineFeatures",{container:f,className:R.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:()=>{e.events.combineFeatures()}})),d.uncombine_features&&(t.uncombine_features=c("uncombineFeatures",{container:f,className:R.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:()=>{e.events.uncombineFeatures()}}))),f}function u(){Object.keys(t).forEach(d=>{const f=t[d];f.parentNode&&f.parentNode.removeChild(f),delete t[d]})}return{setActiveButton:h,queueMapClasses:s,updateMapClasses:l,clearMapClasses:i,addButtons:E,removeButtons:u}}function fn(e){let t=null,n=null;const r={onRemove(){return e.map.off("load",r.connect),clearInterval(n),r.removeLayers(),e.store.restoreMapConfig(),e.ui.removeButtons(),e.events.removeEventListeners(),e.ui.clearMapClasses(),e.boxZoomInitial&&e.map.boxZoom.enable(),e.map=null,e.container=null,e.store=null,t&&t.parentNode&&t.parentNode.removeChild(t),t=null,this},connect(){e.map.off("load",r.connect),clearInterval(n),r.addLayers(),e.store.storeMapConfig(),e.events.addEventListeners()},onAdd(o){if(e.map=o,e.events=un(e),e.ui=dn(e),e.container=o.getContainer(),e.store=new _(e),t=e.ui.addButtons(),e.options.boxSelect){e.boxZoomInitial=o.boxZoom.isEnabled(),o.boxZoom.disable();const i=o.dragPan.isEnabled();o.dragPan.disable(),o.dragPan.enable(),i||o.dragPan.disable()}return o.loaded()?r.connect():(o.on("load",r.connect),n=setInterval(()=>{o.loaded()&&r.connect()},16)),e.events.start(),t},addLayers(){e.map.addSource(G.COLD,{data:{type:g.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(G.HOT,{data:{type:g.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.options.styles.forEach(o=>{e.map.addLayer(o)}),e.store.setDirty(!0),e.store.render()},removeLayers(){e.options.styles.forEach(o=>{e.map.getLayer(o.id)&&e.map.removeLayer(o.id)}),e.map.getSource(G.COLD)&&e.map.removeSource(G.COLD),e.map.getSource(G.HOT)&&e.map.removeSource(G.HOT)}};return e.setup=r,r}const Te="#3bb2d0",ne="#fbb03b",Ke="#fff",yt=[{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"]],paint:{"fill-color":["case",["==",["get","active"],"true"],ne,Te],"fill-opacity":.1}},{id:"gl-draw-lines",type:"line",filter:["any",["==","$type","LineString"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["==",["get","active"],"true"],ne,Te],"line-dasharray":["case",["==",["get","active"],"true"],[.2,2],[2,0]],"line-width":2}},{id:"gl-draw-point-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":Ke}},{id:"gl-draw-point-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":["case",["==",["get","active"],"true"],ne,Te]}},{id:"gl-draw-vertex-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":Ke}},{id:"gl-draw-vertex-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":ne}},{id:"gl-draw-midpoint",type:"circle",filter:["all",["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":ne}}];function Z(e,t){this.x=e,this.y=t}Z.prototype={clone(){return new Z(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,n=e.y-this.y;return t*t+n*n},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const t=e[0]*this.x+e[1]*this.y,n=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=n,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),n=Math.sin(e),r=t*this.x-n*this.y,o=n*this.x+t*this.y;return this.x=r,this.y=o,this},_rotateAround(e,t){const n=Math.cos(e),r=Math.sin(e),o=t.x+n*(this.x-t.x)-r*(this.y-t.y),i=t.y+r*(this.x-t.x)+n*(this.y-t.y);return this.x=o,this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Z};Z.convert=function(e){if(e instanceof Z)return e;if(Array.isArray(e))return new Z(+e[0],+e[1]);if(e.x!==void 0&&e.y!==void 0)return new Z(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};function Ue(e,t){const n=t.getBoundingClientRect();return new Z(e.clientX-n.left-(t.clientLeft||0),e.clientY-n.top-(t.clientTop||0))}function ee(e,t,n,r){return{type:g.FEATURE,properties:{meta:P.VERTEX,parent:e,coord_path:n,active:r?b.ACTIVE:b.INACTIVE},geometry:{type:g.POINT,coordinates:t}}}function pn(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function Et(e,t,n){if(e!==null)for(var r,o,i,s,l,c,a,h=0,E=0,u,d=e.type,f=d==="FeatureCollection",C=d==="Feature",L=f?e.features.length:1,N=0;N<L;N++){a=f?e.features[N].geometry:C?e.geometry:e,u=a?a.type==="GeometryCollection":!1,l=u?a.geometries.length:1;for(var B=0;B<l;B++){var O=0,H=0;if(s=u?a.geometries[B]:a,s!==null){c=s.coordinates;var U=s.type;switch(h=0,U){case null:break;case"Point":if(t(c,E,N,O,H)===!1)return!1;E++,O++;break;case"LineString":case"MultiPoint":for(r=0;r<c.length;r++){if(t(c[r],E,N,O,H)===!1)return!1;E++,U==="MultiPoint"&&O++}U==="LineString"&&O++;break;case"Polygon":case"MultiLineString":for(r=0;r<c.length;r++){for(o=0;o<c[r].length-h;o++){if(t(c[r][o],E,N,O,H)===!1)return!1;E++}U==="MultiLineString"&&O++,U==="Polygon"&&H++}U==="Polygon"&&O++;break;case"MultiPolygon":for(r=0;r<c.length;r++){for(H=0,o=0;o<c[r].length;o++){for(i=0;i<c[r][o].length-h;i++){if(t(c[r][o][i],E,N,O,H)===!1)return!1;E++}H++}O++}break;case"GeometryCollection":for(r=0;r<s.geometries.length;r++)if(Et(s.geometries[r],t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function hn(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return vt(e);case"FeatureCollection":return gn(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Ve(e);default:throw new Error("unknown GeoJSON type")}}function vt(e){const t={type:"Feature"};return Object.keys(e).forEach(n=>{switch(n){case"type":case"properties":case"geometry":return;default:t[n]=e[n]}}),t.properties=Ct(e.properties),e.geometry==null?t.geometry=null:t.geometry=Ve(e.geometry),t}function Ct(e){const t={};return e&&Object.keys(e).forEach(n=>{const r=e[n];typeof r=="object"?r===null?t[n]=null:Array.isArray(r)?t[n]=r.map(o=>o):t[n]=Ct(r):t[n]=r}),t}function gn(e){const t={type:"FeatureCollection"};return Object.keys(e).forEach(n=>{switch(n){case"type":case"features":return;default:t[n]=e[n]}}),t.features=e.features.map(n=>vt(n)),t}function Ve(e){const t={type:e.type};return e.bbox&&(t.bbox=e.bbox),e.type==="GeometryCollection"?(t.geometries=e.geometries.map(n=>Ve(n)),t):(t.coordinates=St(e.coordinates),t)}function St(e){const t=e;return typeof t[0]!="object"?t.slice():t.map(n=>St(n))}function Ye(e,t={}){return Tt(e,"mercator",t)}function mn(e,t={}){return Tt(e,"wgs84",t)}function Tt(e,t,n={}){n=n||{};var r=n.mutate;if(!e)throw new Error("geojson is required");return Array.isArray(e)&&pn(e[0])?e=t==="mercator"?Xe(e):He(e):(r!==!0&&(e=hn(e)),Et(e,function(o){var i=t==="mercator"?Xe(o):He(o);o[0]=i[0],o[1]=i[1]})),e}function Xe(e){var t=Math.PI/180,n=6378137,r=20037508342789244e-9,o=Math.abs(e[0])<=180?e[0]:e[0]-yn(e[0])*360,i=[n*o*t,n*Math.log(Math.tan(Math.PI*.25+.5*e[1]*t))];return i[0]>r&&(i[0]=r),i[0]<-r&&(i[0]=-r),i[1]>r&&(i[1]=r),i[1]<-r&&(i[1]=-r),i}function He(e){var t=180/Math.PI,n=6378137;return[e[0]*t/n,(Math.PI*.5-2*Math.atan(Math.exp(-e[1]/n)))*t]}function yn(e){return e<0?-1:e>0?1:0}function _t(e,t,n){const r=t.geometry.coordinates,o=n.geometry.coordinates;if(r[1]>be||r[1]<Oe||o[1]>be||o[1]<Oe)return null;const i=Ye(r),s=Ye(o),l=E=>Number(E.toFixed(8)),c=(E,u)=>(E+u)/2,a=mn([c(i[0],s[0]),c(i[1],s[1])]),h=[l(a[0]),l(a[1])];return{type:g.FEATURE,properties:{meta:P.MIDPOINT,parent:e,lng:h[0],lat:h[1],coord_path:n.properties.coord_path},geometry:{type:g.POINT,coordinates:h}}}function Se(e,t={},n=null){const{type:r,coordinates:o}=e.geometry,i=e.properties&&e.properties.id;let s=[];r===g.POINT?s.push(ee(i,o,n,c(n))):r===g.POLYGON?o.forEach((h,E)=>{l(h,n!==null?`${n}.${E}`:String(E))}):r===g.LINE_STRING?l(o,n):r.indexOf(g.MULTI_PREFIX)===0&&a();function l(h,E){let u="",d=null;h.forEach((f,C)=>{const L=E!=null?`${E}.${C}`:String(C),N=ee(i,f,L,c(L));if(t.midpoints&&d){const O=_t(i,d,N);O&&s.push(O)}d=N;const B=JSON.stringify(f);u!==B&&s.push(N),C===0&&(u=B)})}function c(h){return t.selectedPaths?t.selectedPaths.indexOf(h)!==-1:!1}function a(){const h=r.replace(g.MULTI_PREFIX,"");o.forEach((E,u)=>{const d={type:g.FEATURE,properties:e.properties,geometry:{type:h,coordinates:E}};s=s.concat(Se(d,t,u))})}return s}const q={enable(e){setTimeout(()=>{!e.map||!e.map.doubleClickZoom||!e._ctx||!e._ctx.store||!e._ctx.store.getInitialConfigValue||e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable()},0)},disable(e){setTimeout(()=>{!e.map||!e.map.doubleClickZoom||e.map.doubleClickZoom.disable()},0)}},{LAT_MIN:ce,LAT_MAX:de,LAT_RENDERED_MIN:Ze,LAT_RENDERED_MAX:We,LNG_MIN:ze,LNG_MAX:Qe}=st;function En(e){const t={Point:0,LineString:1,Polygon:2,MultiPoint:1,MultiLineString:2,MultiPolygon:3}[e.geometry.type],n=[e.geometry.coordinates].flat(t),r=n.map(l=>l[0]),o=n.map(l=>l[1]),i=l=>Math.min.apply(null,l),s=l=>Math.max.apply(null,l);return[i(r),i(o),s(r),s(o)]}function xe(e,t){let n=ce,r=de,o=ce,i=de,s=Qe,l=ze;e.forEach(a=>{const h=En(a),E=h[1],u=h[3],d=h[0],f=h[2];E>n&&(n=E),u<r&&(r=u),u>o&&(o=u),E<i&&(i=E),d<s&&(s=d),f>l&&(l=f)});const c=t;return n+c.lat>We&&(c.lat=We-n),o+c.lat>de&&(c.lat=de-o),r+c.lat<Ze&&(c.lat=Ze-r),i+c.lat<ce&&(c.lat=ce-i),s+c.lng<=ze&&(c.lng+=Math.ceil(Math.abs(c.lng)/360)*360),l+c.lng>=Qe&&(c.lng-=Math.ceil(Math.abs(c.lng)/360)*360),c}function Be(e,t){const n=xe(e.map(r=>r.toGeoJSON()),t);e.forEach(r=>{const o=r.getCoordinates(),i=a=>{const h={lng:a[0]+n.lng,lat:a[1]+n.lat};return[h.lng,h.lat]},s=a=>a.map(h=>i(h)),l=a=>a.map(h=>s(h));let c;r.type===g.POINT?c=i(o):r.type===g.LINE_STRING||r.type===g.MULTI_POINT?c=o.map(i):r.type===g.POLYGON||r.type===g.MULTI_LINE_STRING?c=o.map(s):r.type===g.MULTI_POLYGON&&(c=o.map(l)),r.incomingCoords(c)})}const S={};S.onSetup=function(e){const t={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initialDragPanState:this.map.dragPan.isEnabled(),initiallySelectedFeatureIds:e.featureIds||[]};return this.setSelected(t.initiallySelectedFeatureIds.filter(n=>this.getFeature(n)!==void 0)),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),t};S.fireUpdate=function(){this.fire(D.UPDATE,{action:ie.MOVE,features:this.getSelected().map(e=>e.toGeoJSON())})};S.fireActionable=function(){const e=this.getSelected(),t=e.filter(i=>this.isInstanceOf("MultiFeature",i));let n=!1;if(e.length>1){n=!0;const i=e[0].type.replace("Multi","");e.forEach(s=>{s.type.replace("Multi","")!==i&&(n=!1)})}const r=t.length>0,o=e.length>0;this.setActionableState({combineFeatures:n,uncombineFeatures:r,trash:o})};S.getUniqueIds=function(e){return e.length?e.map(n=>n.properties.id).filter(n=>n!==void 0).reduce((n,r)=>(n.add(r),n),new $).values():[]};S.stopExtendedInteractions=function(e){e.boxSelectElement&&(e.boxSelectElement.parentNode&&e.boxSelectElement.parentNode.removeChild(e.boxSelectElement),e.boxSelectElement=null),(e.canDragMove||e.canBoxSelect)&&e.initialDragPanState===!0&&this.map.dragPan.enable(),e.boxSelecting=!1,e.canBoxSelect=!1,e.dragMoving=!1,e.canDragMove=!1};S.onStop=function(){q.enable(this)};S.onMouseMove=function(e,t){return we(t)&&e.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(e),!0};S.onMouseOut=function(e){return e.dragMoving?this.fireUpdate():!0};S.onTap=S.onClick=function(e,t){if(ye(t))return this.clickAnywhere(e,t);if(me(P.VERTEX)(t))return this.clickOnVertex(e,t);if(we(t))return this.clickOnFeature(e,t)};S.clickAnywhere=function(e){const t=this.getSelectedIds();t.length&&(this.clearSelectedFeatures(),t.forEach(n=>this.doRender(n))),q.enable(this),this.stopExtendedInteractions(e)};S.clickOnVertex=function(e,t){this.changeMode(v.DIRECT_SELECT,{featureId:t.featureTarget.properties.parent,coordPath:t.featureTarget.properties.coord_path,startPos:t.lngLat}),this.updateUIClasses({mouse:I.MOVE})};S.startOnActiveFeature=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),this.doRender(t.featureTarget.properties.id),e.canDragMove=!0,e.dragMoveLocation=t.lngLat};S.clickOnFeature=function(e,t){q.disable(this),this.stopExtendedInteractions(e);const n=he(t),r=this.getSelectedIds(),o=t.featureTarget.properties.id,i=this.isSelected(o);if(!n&&i&&this.getFeature(o).type!==g.POINT)return this.changeMode(v.DIRECT_SELECT,{featureId:o});i&&n?(this.deselect(o),this.updateUIClasses({mouse:I.POINTER}),r.length===1&&q.enable(this)):!i&&n?(this.select(o),this.updateUIClasses({mouse:I.MOVE})):!i&&!n&&(r.forEach(s=>this.doRender(s)),this.setSelected(o),this.updateUIClasses({mouse:I.MOVE})),this.doRender(o)};S.onMouseDown=function(e,t){if(e.initialDragPanState=this.map.dragPan.isEnabled(),z(t))return this.startOnActiveFeature(e,t);if(this.drawConfig.boxSelect&&at(t))return this.startBoxSelect(e,t)};S.startBoxSelect=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),e.boxSelectStartLocation=Ue(t.originalEvent,this.map.getContainer()),e.canBoxSelect=!0};S.onTouchStart=function(e,t){if(z(t))return this.startOnActiveFeature(e,t)};S.onDrag=function(e,t){if(e.canDragMove)return this.dragMove(e,t);if(this.drawConfig.boxSelect&&e.canBoxSelect)return this.whileBoxSelect(e,t)};S.whileBoxSelect=function(e,t){e.boxSelecting=!0,this.updateUIClasses({mouse:I.ADD}),e.boxSelectElement||(e.boxSelectElement=document.createElement("div"),e.boxSelectElement.classList.add(R.BOX_SELECT),this.map.getContainer().appendChild(e.boxSelectElement));const n=Ue(t.originalEvent,this.map.getContainer()),r=Math.min(e.boxSelectStartLocation.x,n.x),o=Math.max(e.boxSelectStartLocation.x,n.x),i=Math.min(e.boxSelectStartLocation.y,n.y),s=Math.max(e.boxSelectStartLocation.y,n.y),l=`translate(${r}px, ${i}px)`;e.boxSelectElement.style.transform=l,e.boxSelectElement.style.WebkitTransform=l,e.boxSelectElement.style.width=`${o-r}px`,e.boxSelectElement.style.height=`${s-i}px`};S.dragMove=function(e,t){e.dragMoving=!0,t.originalEvent.stopPropagation();const n={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};Be(this.getSelected(),n),e.dragMoveLocation=t.lngLat};S.onTouchEnd=S.onMouseUp=function(e,t){if(e.dragMoving)this.fireUpdate();else if(e.boxSelecting){const n=[e.boxSelectStartLocation,Ue(t.originalEvent,this.map.getContainer())],r=this.featuresAt(null,n,"click"),o=this.getUniqueIds(r).filter(i=>!this.isSelected(i));o.length&&(this.select(o),o.forEach(i=>this.doRender(i)),this.updateUIClasses({mouse:I.MOVE}))}this.stopExtendedInteractions(e)};S.toDisplayFeatures=function(e,t,n){t.properties.active=this.isSelected(t.properties.id)?b.ACTIVE:b.INACTIVE,n(t),this.fireActionable(),!(t.properties.active!==b.ACTIVE||t.geometry.type===g.POINT)&&Se(t).forEach(n)};S.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()};S.onCombineFeatures=function(){const e=this.getSelected();if(e.length===0||e.length<2)return;const t=[],n=[],r=e[0].type.replace("Multi","");for(let o=0;o<e.length;o++){const i=e[o];if(i.type.replace("Multi","")!==r)return;i.type.includes("Multi")?i.getCoordinates().forEach(s=>{t.push(s)}):t.push(i.getCoordinates()),n.push(i.toGeoJSON())}if(n.length>1){const o=this.newFeature({type:g.FEATURE,properties:n[0].properties,geometry:{type:`Multi${r}`,coordinates:t}});this.addFeature(o),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([o.id]),this.fire(D.COMBINE_FEATURES,{createdFeatures:[o.toGeoJSON()],deletedFeatures:n})}this.fireActionable()};S.onUncombineFeatures=function(){const e=this.getSelected();if(e.length===0)return;const t=[],n=[];for(let r=0;r<e.length;r++){const o=e[r];this.isInstanceOf("MultiFeature",o)&&(o.getFeatures().forEach(i=>{this.addFeature(i),i.properties=o.properties,t.push(i.toGeoJSON()),this.select([i.id])}),this.deleteFeature(o.id,{silent:!0}),n.push(o.toGeoJSON()))}t.length>1&&this.fire(D.UNCOMBINE_FEATURES,{createdFeatures:t,deletedFeatures:n}),this.fireActionable()};const It=me(P.VERTEX),Mt=me(P.MIDPOINT),T={};T.fireUpdate=function(){this.fire(D.UPDATE,{action:ie.CHANGE_COORDINATES,features:this.getSelected().map(e=>e.toGeoJSON())})};T.fireActionable=function(e){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:e.selectedCoordPaths.length>0})};T.startDragging=function(e,t){e.initialDragPanState==null&&(e.initialDragPanState=this.map.dragPan.isEnabled()),this.map.dragPan.disable(),e.canDragMove=!0,e.dragMoveLocation=t.lngLat};T.stopDragging=function(e){e.canDragMove&&e.initialDragPanState===!0&&this.map.dragPan.enable(),e.initialDragPanState=null,e.dragMoving=!1,e.canDragMove=!1,e.dragMoveLocation=null};T.onVertex=function(e,t){this.startDragging(e,t);const n=t.featureTarget.properties,r=e.selectedCoordPaths.indexOf(n.coord_path);!he(t)&&r===-1?e.selectedCoordPaths=[n.coord_path]:he(t)&&r===-1&&e.selectedCoordPaths.push(n.coord_path);const o=this.pathsToCoordinates(e.featureId,e.selectedCoordPaths);this.setSelectedCoordinates(o)};T.onMidpoint=function(e,t){this.startDragging(e,t);const n=t.featureTarget.properties;e.feature.addCoordinate(n.coord_path,n.lng,n.lat),this.fireUpdate(),e.selectedCoordPaths=[n.coord_path]};T.pathsToCoordinates=function(e,t){return t.map(n=>({feature_id:e,coord_path:n}))};T.onFeature=function(e,t){e.selectedCoordPaths.length===0?this.startDragging(e,t):this.stopDragging(e)};T.dragFeature=function(e,t,n){Be(this.getSelected(),n),e.dragMoveLocation=t.lngLat};T.dragVertex=function(e,t,n){const r=e.selectedCoordPaths.map(s=>e.feature.getCoordinate(s)),o=r.map(s=>({type:g.FEATURE,properties:{},geometry:{type:g.POINT,coordinates:s}})),i=xe(o,n);for(let s=0;s<r.length;s++){const l=r[s];e.feature.updateCoordinate(e.selectedCoordPaths[s],l[0]+i.lng,l[1]+i.lat)}};T.clickNoTarget=function(){this.changeMode(v.SIMPLE_SELECT)};T.clickInactive=function(){this.changeMode(v.SIMPLE_SELECT)};T.clickActiveFeature=function(e){e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed()};T.onSetup=function(e){const t=e.featureId,n=this.getFeature(t);if(!n)throw new Error("You must provide a featureId to enter direct_select mode");if(n.type===g.POINT)throw new TypeError("direct_select mode doesn't handle point features");const r={featureId:t,feature:n,dragMoveLocation:e.startPos||null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:e.coordPath?[e.coordPath]:[]};return this.setSelectedCoordinates(this.pathsToCoordinates(t,r.selectedCoordPaths)),this.setSelected(t),q.disable(this),this.setActionableState({trash:!0}),r};T.onStop=function(){q.enable(this),this.clearSelectedCoordinates()};T.toDisplayFeatures=function(e,t,n){e.featureId===t.properties.id?(t.properties.active=b.ACTIVE,n(t),Se(t,{map:this.map,midpoints:!0,selectedPaths:e.selectedCoordPaths}).forEach(n)):(t.properties.active=b.INACTIVE,n(t)),this.fireActionable(e)};T.onTrash=function(e){e.selectedCoordPaths.sort((t,n)=>n.localeCompare(t,"en",{numeric:!0})).forEach(t=>e.feature.removeCoordinate(t)),this.fireUpdate(),e.selectedCoordPaths=[],this.clearSelectedCoordinates(),this.fireActionable(e),e.feature.isValid()===!1&&(this.deleteFeature([e.featureId]),this.changeMode(v.SIMPLE_SELECT,{}))};T.onMouseMove=function(e,t){const n=z(t),r=It(t),o=Mt(t),i=e.selectedCoordPaths.length===0;return n&&i?this.updateUIClasses({mouse:I.MOVE}):r&&!i?this.updateUIClasses({mouse:I.MOVE}):this.updateUIClasses({mouse:I.NONE}),(r||n||o)&&e.dragMoving&&this.fireUpdate(),this.stopDragging(e),!0};T.onMouseOut=function(e){return e.dragMoving&&this.fireUpdate(),!0};T.onTouchStart=T.onMouseDown=function(e,t){if(It(t))return this.onVertex(e,t);if(z(t))return this.onFeature(e,t);if(Mt(t))return this.onMidpoint(e,t)};T.onDrag=function(e,t){if(e.canDragMove!==!0)return;e.dragMoving=!0,t.originalEvent.stopPropagation();const n={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};e.selectedCoordPaths.length>0?this.dragVertex(e,t,n):this.dragFeature(e,t,n),e.dragMoveLocation=t.lngLat};T.onClick=function(e,t){if(ye(t))return this.clickNoTarget(e,t);if(z(t))return this.clickActiveFeature(e,t);if(De(t))return this.clickInactive(e,t);this.stopDragging(e)};T.onTap=function(e,t){if(ye(t))return this.clickNoTarget(e,t);if(z(t))return this.clickActiveFeature(e,t);if(De(t))return this.clickInactive(e,t)};T.onTouchEnd=T.onMouseUp=function(e){e.dragMoving&&this.fireUpdate(),this.stopDragging(e)};const Y={};Y.onSetup=function(){const e=this.newFeature({type:g.FEATURE,properties:{},geometry:{type:g.POINT,coordinates:[]}});return this.addFeature(e),this.clearSelectedFeatures(),this.updateUIClasses({mouse:I.ADD}),this.activateUIButton(k.POINT),this.setActionableState({trash:!0}),{point:e}};Y.stopDrawingAndRemove=function(e){this.deleteFeature([e.point.id],{silent:!0}),this.changeMode(v.SIMPLE_SELECT)};Y.onTap=Y.onClick=function(e,t){this.updateUIClasses({mouse:I.MOVE}),e.point.updateCoordinate("",t.lngLat.lng,t.lngLat.lat),this.fire(D.CREATE,{features:[e.point.toGeoJSON()]}),this.changeMode(v.SIMPLE_SELECT,{featureIds:[e.point.id]})};Y.onStop=function(e){this.activateUIButton(),e.point.getCoordinate().length||this.deleteFeature([e.point.id],{silent:!0})};Y.toDisplayFeatures=function(e,t,n){const r=t.properties.id===e.point.id;if(t.properties.active=r?b.ACTIVE:b.INACTIVE,!r)return n(t)};Y.onTrash=Y.stopDrawingAndRemove;Y.onKeyUp=function(e,t){if(Ee(t)||ve(t))return this.stopDrawingAndRemove(e,t)};function ge(e,t){return e.lngLat?e.lngLat.lng===t[0]&&e.lngLat.lat===t[1]:!1}const J={};J.onSetup=function(){const e=this.newFeature({type:g.FEATURE,properties:{},geometry:{type:g.POLYGON,coordinates:[[]]}});return this.addFeature(e),this.clearSelectedFeatures(),q.disable(this),this.updateUIClasses({mouse:I.ADD}),this.activateUIButton(k.POLYGON),this.setActionableState({trash:!0}),{polygon:e,currentVertexPosition:0}};J.clickAnywhere=function(e,t){if(e.currentVertexPosition>0&&ge(t,e.polygon.coordinates[0][e.currentVertexPosition-1]))return this.changeMode(v.SIMPLE_SELECT,{featureIds:[e.polygon.id]});this.updateUIClasses({mouse:I.ADD}),e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition++,e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat)};J.clickOnVertex=function(e){return this.changeMode(v.SIMPLE_SELECT,{featureIds:[e.polygon.id]})};J.onMouseMove=function(e,t){e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),se(t)&&this.updateUIClasses({mouse:I.POINTER})};J.onTap=J.onClick=function(e,t){return se(t)?this.clickOnVertex(e,t):this.clickAnywhere(e,t)};J.onKeyUp=function(e,t){Ee(t)?(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(v.SIMPLE_SELECT)):ve(t)&&this.changeMode(v.SIMPLE_SELECT,{featureIds:[e.polygon.id]})};J.onStop=function(e){this.updateUIClasses({mouse:I.NONE}),q.enable(this),this.activateUIButton(),this.getFeature(e.polygon.id)!==void 0&&(e.polygon.removeCoordinate(`0.${e.currentVertexPosition}`),e.polygon.isValid()?this.fire(D.CREATE,{features:[e.polygon.toGeoJSON()]}):(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(v.SIMPLE_SELECT,{},{silent:!0})))};J.toDisplayFeatures=function(e,t,n){const r=t.properties.id===e.polygon.id;if(t.properties.active=r?b.ACTIVE:b.INACTIVE,!r)return n(t);if(t.geometry.coordinates.length===0)return;const o=t.geometry.coordinates[0].length;if(!(o<3)){if(t.properties.meta=P.FEATURE,n(ee(e.polygon.id,t.geometry.coordinates[0][0],"0.0",!1)),o>3){const i=t.geometry.coordinates[0].length-3;n(ee(e.polygon.id,t.geometry.coordinates[0][i],`0.${i}`,!1))}if(o<=4){const i=[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]];if(n({type:g.FEATURE,properties:t.properties,geometry:{coordinates:i,type:g.LINE_STRING}}),o===3)return}return n(t)}};J.onTrash=function(e){this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(v.SIMPLE_SELECT)};const K={};K.onSetup=function(e){e=e||{};const t=e.featureId;let n,r,o="forward";if(t){if(n=this.getFeature(t),!n)throw new Error("Could not find a feature with the provided featureId");let i=e.from;if(i&&i.type==="Feature"&&i.geometry&&i.geometry.type==="Point"&&(i=i.geometry),i&&i.type==="Point"&&i.coordinates&&i.coordinates.length===2&&(i=i.coordinates),!i||!Array.isArray(i))throw new Error("Please use the `from` property to indicate which point to continue the line from");const s=n.coordinates.length-1;if(n.coordinates[s][0]===i[0]&&n.coordinates[s][1]===i[1])r=s+1,n.addCoordinate(r,...n.coordinates[s]);else if(n.coordinates[0][0]===i[0]&&n.coordinates[0][1]===i[1])o="backwards",r=0,n.addCoordinate(r,...n.coordinates[0]);else throw new Error("`from` should match the point at either the start or the end of the provided LineString")}else n=this.newFeature({type:g.FEATURE,properties:{},geometry:{type:g.LINE_STRING,coordinates:[]}}),r=0,this.addFeature(n);return this.clearSelectedFeatures(),q.disable(this),this.updateUIClasses({mouse:I.ADD}),this.activateUIButton(k.LINE),this.setActionableState({trash:!0}),{line:n,currentVertexPosition:r,direction:o}};K.clickAnywhere=function(e,t){if(e.currentVertexPosition>0&&ge(t,e.line.coordinates[e.currentVertexPosition-1])||e.direction==="backwards"&&ge(t,e.line.coordinates[e.currentVertexPosition+1]))return this.changeMode(v.SIMPLE_SELECT,{featureIds:[e.line.id]});this.updateUIClasses({mouse:I.ADD}),e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),e.direction==="forward"?(e.currentVertexPosition++,e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat)):e.line.addCoordinate(0,t.lngLat.lng,t.lngLat.lat)};K.clickOnVertex=function(e){return this.changeMode(v.SIMPLE_SELECT,{featureIds:[e.line.id]})};K.onMouseMove=function(e,t){e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),se(t)&&this.updateUIClasses({mouse:I.POINTER})};K.onTap=K.onClick=function(e,t){if(se(t))return this.clickOnVertex(e,t);this.clickAnywhere(e,t)};K.onKeyUp=function(e,t){ve(t)?this.changeMode(v.SIMPLE_SELECT,{featureIds:[e.line.id]}):Ee(t)&&(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(v.SIMPLE_SELECT))};K.onStop=function(e){q.enable(this),this.activateUIButton(),this.getFeature(e.line.id)!==void 0&&(e.line.removeCoordinate(`${e.currentVertexPosition}`),e.line.isValid()?this.fire(D.CREATE,{features:[e.line.toGeoJSON()]}):(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(v.SIMPLE_SELECT,{},{silent:!0})))};K.onTrash=function(e){this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(v.SIMPLE_SELECT)};K.toDisplayFeatures=function(e,t,n){const r=t.properties.id===e.line.id;if(t.properties.active=r?b.ACTIVE:b.INACTIVE,!r)return n(t);t.geometry.coordinates.length<2||(t.properties.meta=P.FEATURE,n(ee(e.line.id,t.geometry.coordinates[e.direction==="forward"?t.geometry.coordinates.length-2:1],`${e.direction==="forward"?t.geometry.coordinates.length-2:1}`,!1)),n(t))};const Ot={simple_select:S,direct_select:T,draw_point:Y,draw_polygon:J,draw_line_string:K},vn={defaultMode:v.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:yt,modes:Ot,controls:{},userProperties:!1,suppressAPIEvents:!0},Cn={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},Sn={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function je(e,t){return e.map(n=>n.source?n:Object.assign({},n,{id:`${n.id}.${t}`,source:t==="hot"?G.HOT:G.COLD}))}function Tn(e={}){let t=Object.assign({},e);return e.controls||(t.controls={}),e.displayControlsDefault===!1?t.controls=Object.assign({},Sn,e.controls):t.controls=Object.assign({},Cn,e.controls),t=Object.assign({},vn,t),t.styles=je(t.styles,"cold").concat(je(t.styles,"hot")),t}var _e,et;function _n(){return et||(et=1,_e=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var r,o,i;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(i=Object.keys(t),r=i.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;o--!==0;){var s=i[o];if(!e(t[s],n[s]))return!1}return!0}return t!==t&&n!==n}),_e}var In=_n();const tt=oe.getDefaultExportFromCjs(In);var Ie,nt;function Mn(){if(nt)return Ie;nt=1,Ie=t;var e={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"};function t(n){if(!n||!n.type)return null;var r=e[n.type];if(!r)return null;if(r==="geometry")return{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:n}]};if(r==="feature")return{type:"FeatureCollection",features:[n]};if(r==="featurecollection")return n}return Ie}var On=Mn();const bn=oe.getDefaultExportFromCjs(On);function bt(e,t){return e.length!==t.length?!1:JSON.stringify(e.map(n=>n).sort())===JSON.stringify(t.map(n=>n).sort())}const Ln={Polygon:x,LineString:X,Point:W,MultiPolygon:F,MultiLineString:F,MultiPoint:F};function Nn(e,t){t.modes=v;const n=e.options.suppressAPIEvents!==void 0?!!e.options.suppressAPIEvents:!0;return t.getFeatureIdsAt=function(r){return j.click({point:r},null,e).map(i=>i.properties.id)},t.getSelectedIds=function(){return e.store.getSelectedIds()},t.getSelected=function(){return{type:g.FEATURE_COLLECTION,features:e.store.getSelectedIds().map(r=>e.store.get(r)).map(r=>r.toGeoJSON())}},t.getSelectedPoints=function(){return{type:g.FEATURE_COLLECTION,features:e.store.getSelectedCoordinates().map(r=>({type:g.FEATURE,properties:{},geometry:{type:g.POINT,coordinates:r.coordinates}}))}},t.set=function(r){if(r.type===void 0||r.type!==g.FEATURE_COLLECTION||!Array.isArray(r.features))throw new Error("Invalid FeatureCollection");const o=e.store.createRenderBatch();let i=e.store.getAllIds().slice();const s=t.add(r),l=new $(s);return i=i.filter(c=>!l.has(c)),i.length&&t.delete(i),o(),s},t.add=function(r){const i=JSON.parse(JSON.stringify(bn(r))).features.map(s=>{if(s.id=s.id||ke(),s.geometry===null)throw new Error("Invalid geometry: null");if(e.store.get(s.id)===void 0||e.store.get(s.id).type!==s.geometry.type){const l=Ln[s.geometry.type];if(l===void 0)throw new Error(`Invalid geometry type: ${s.geometry.type}.`);const c=new l(e,s);e.store.add(c,{silent:n})}else{const l=e.store.get(s.id),c=l.properties;l.properties=s.properties,tt(c,s.properties)||e.store.featureChanged(l.id,{silent:n}),tt(l.getCoordinates(),s.geometry.coordinates)||l.incomingCoords(s.geometry.coordinates)}return s.id});return e.store.render(),i},t.get=function(r){const o=e.store.get(r);if(o)return o.toGeoJSON()},t.getAll=function(){return{type:g.FEATURE_COLLECTION,features:e.store.getAll().map(r=>r.toGeoJSON())}},t.delete=function(r){return e.store.delete(r,{silent:n}),t.getMode()===v.DIRECT_SELECT&&!e.store.getSelectedIds().length?e.events.changeMode(v.SIMPLE_SELECT,void 0,{silent:n}):e.store.render(),t},t.deleteAll=function(){return e.store.delete(e.store.getAllIds(),{silent:n}),t.getMode()===v.DIRECT_SELECT?e.events.changeMode(v.SIMPLE_SELECT,void 0,{silent:n}):e.store.render(),t},t.changeMode=function(r,o={}){return r===v.SIMPLE_SELECT&&t.getMode()===v.SIMPLE_SELECT?(bt(o.featureIds||[],e.store.getSelectedIds())||(e.store.setSelected(o.featureIds,{silent:n}),e.store.render()),t):(r===v.DIRECT_SELECT&&t.getMode()===v.DIRECT_SELECT&&o.featureId===e.store.getSelectedIds()[0]||e.events.changeMode(r,o,{silent:n}),t)},t.getMode=function(){return e.events.getMode()},t.trash=function(){return e.events.trash({silent:n}),t},t.combineFeatures=function(){return e.events.combineFeatures({silent:n}),t},t.uncombineFeatures=function(){return e.events.uncombineFeatures({silent:n}),t},t.setFeatureProperty=function(r,o,i){return e.store.setFeatureProperty(r,o,i,{silent:n}),t},t}const Pn=Object.freeze(Object.defineProperty({__proto__:null,CommonSelectors:$t,ModeHandler:Fe,StringSet:$,constrainFeatureMovement:xe,createMidPoint:_t,createSupplementaryPoints:Se,createVertex:ee,doubleClickZoom:q,euclideanDistance:Re,featuresAt:j,getFeatureAtAndSetCursors:pe,isClick:Pe,isEventAtCoordinates:ge,isTap:Ae,mapEventToBoundingBox:pt,moveFeatures:Be,sortFeatures:ft,stringSetsAreEqual:bt,theme:yt,toDenseArray:ae},Symbol.toStringTag,{value:"Module"})),An=function(e,t){e=Tn(e);const n={options:e};t=Nn(n,t),n.api=t;const r=fn(n);return t.onAdd=r.onAdd,t.onRemove=r.onRemove,t.types=k,t.options=e,t};function re(e){An(e,this)}re.modes=Ot;re.constants=st;re.lib=Pn;var Me={exports:{}},rt;function Fn(){if(rt)return Me.exports;rt=1;var e=Me.exports={};return e.onSetup=function(){return this.setActionableState(),{}},e.toDisplayFeatures=function(t,n,r){r(n)},Me.exports}var Dn=Fn();const wn=oe.getDefaultExportFromCjs(Dn);var fe={},ot;function Rn(){if(ot)return fe;ot=1,Object.defineProperty(fe,"__esModule",{value:!0});var e={enable:function(r){setTimeout(function(){!r.map||!r.map.doubleClickZoom||!r._ctx||!r._ctx.store||!r._ctx.store.getInitialConfigValue||r._ctx.store.getInitialConfigValue("doubleClickZoom")&&r.map.doubleClickZoom.enable()},0)},disable:function(r){setTimeout(function(){!r.map||!r.map.doubleClickZoom||r.map.doubleClickZoom.disable()},0)}},t={onSetup:function(r){var o=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});return this.addFeature(o),this.clearSelectedFeatures(),e.disable(this),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:!0}),{rectangle:o}},onTap:function(r,o){r.startPoint&&this.onMouseMove(r,o),this.onClick(r,o)},onClick:function(r,o){r.startPoint&&r.startPoint[0]!==o.lngLat.lng&&r.startPoint[1]!==o.lngLat.lat&&(this.updateUIClasses({mouse:"pointer"}),r.endPoint=[o.lngLat.lng,o.lngLat.lat],this.changeMode("simple_select",{featuresId:r.rectangle.id}));var i=[o.lngLat.lng,o.lngLat.lat];r.startPoint=i},onMouseMove:function(r,o){r.startPoint&&(r.rectangle.updateCoordinate("0.0",r.startPoint[0],r.startPoint[1]),r.rectangle.updateCoordinate("0.1",o.lngLat.lng,r.startPoint[1]),r.rectangle.updateCoordinate("0.2",o.lngLat.lng,o.lngLat.lat),r.rectangle.updateCoordinate("0.3",r.startPoint[0],o.lngLat.lat),r.rectangle.updateCoordinate("0.4",r.startPoint[0],r.startPoint[1]))},onKeyUp:function(r,o){if(o.keyCode===27)return this.changeMode("simple_select")},onStop:function(r){e.enable(this),this.updateUIClasses({mouse:"none"}),this.activateUIButton(),this.getFeature(r.rectangle.id)!==void 0&&(r.rectangle.removeCoordinate("0.4"),r.rectangle.isValid()?this.map.fire("draw.create",{features:[r.rectangle.toGeoJSON()]}):(this.deleteFeature([r.rectangle.id],{silent:!0}),this.changeMode("simple_select",{},{silent:!0})))},toDisplayFeatures:function(r,o,i){var s=o.properties.id===r.rectangle.id;if(o.properties.active=s?"true":"false",!s)return i(o);if(r.startPoint)return i(o)},onTrash:function(r){this.deleteFeature([r.rectangle.id],{silent:!0}),this.changeMode("simple_select")}};return fe.default=t,fe}var kn=Rn();const Un=oe.getDefaultExportFromCjs(kn),Vn={key:0,class:"measure-info-panel"},xn={class:"measure-info-content"},Bn={class:"measure-label"},Gn={class:"measure-value"},$n={class:"qy-flex-row hiper-map-tools-bar"},qn=p.defineComponent({__name:"MapTools",props:{tools:{default:()=>["point","line","polygon","measure_distance","measure_area","clear_all"]}},setup(e){const t=p.inject("mapRootId"),n=p.ref(),r=p.ref([]),o=p.ref(null),i=p.ref(null),s=p.ref(!1),l=p.ref("distance"),c=M=>{switch(s.value&&M!=="measure_distance"&&M!=="clear_all"&&B(),n.value=M,M){case"point":h.changeMode("draw_point");break;case"line":h.changeMode("draw_line_string");break;case"polygon":h.changeMode("draw_polygon");break;case"measure_distance":h.changeMode("simple_select"),l.value="distance",d();break;case"measure_area":h.changeMode("simple_select"),l.value="area",d();break;case"clear_all":h.deleteAll(),B();break}},a=p.inject(At.mapInstanceKey),h=new re({userProperties:!0,displayControlsDefault:!1,modes:{...re.modes,draw_rectangle:Un,static:wn}});let E=null;E=Ge.mapLoadedBus.on(({mapRootId:M})=>{t!==M||!a?.value||(console.log("hiper-map-tools-bar mounted",a),a.value.addControl(h,"top-left"),a.value.on("draw.create",u))});function u(M){const m=h.getAll();if(!m.features.length)return;m.features=[m.features[0]];const A={point:{layerType:"symbol",config:{textColor:"rgba(0,0,0,1)",iconName:Ft.DefaultIcon}},line:{layerType:"line",config:{lineWidth:1,lineColor:"rgba(255, 0, 0, 1)",lineStyle:"solid"}},polygon:{layerType:"shape",config:{fillColor:"rgba(241, 131, 127, 1)",lineWidth:1}}}[n.value];A&&Ge.showLayerEditKeyBus.emit({mapRootId:t,e:new MouseEvent("click"),layer:{layerType:A.layerType,customLayerConfig:JSON.stringify(A.config),geoJSON:JSON.stringify(m),...n.value==="polygon"?{pid:""}:{}}}),h.deleteAll()}function d(){a?.value&&(s.value=!0,r.value=[],a.value.getCanvas().style.cursor="crosshair",a.value.on("click",C),a.value.on("dblclick",f))}function f(M){if(s.value){if(M.preventDefault(),l.value==="distance")r.value.length>=2&&L();else if(r.value.length>=3){const m=r.value[0],V=r.value[r.value.length-1];(m[0]!==V[0]||m[1]!==V[1])&&r.value.push(m),L()}a?.value?.off("click",C),a?.value?.off("dblclick",f),a?.value&&(a.value.getCanvas().style.cursor=""),s.value=!1}}function C(M){if(!s.value||!a?.value)return;M.originalEvent.stopPropagation();const m=[M.lngLat.lng,M.lngLat.lat];r.value.push(m),r.value.length===1?(l.value==="distance"?O.value=0:U.value=0,a.value.getSource("measure-point-source")?a.value.getSource("measure-point-source").setData({type:"Feature",properties:{},geometry:{type:"Point",coordinates:m}}):(a.value.addSource("measure-point-source",{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"Point",coordinates:m}}}),a.value.addLayer({id:"measure-point-layer",type:"circle",source:"measure-point-source",paint:{"circle-radius":5,"circle-color":"#16aaff"}}))):(a.value.getSource("measure-point-source")&&a.value.getSource("measure-point-source").setData({type:"FeatureCollection",features:r.value.map(V=>({type:"Feature",properties:{},geometry:{type:"Point",coordinates:V}}))}),L(),l.value==="area"&&r.value.length>=3&&(a.value.getCanvas().style.cursor="pointer"))}function L(){if(!a?.value||r.value.length<2)return;const M=Q.lineString(r.value);if(l.value==="distance"){const m=Q.length(M,{units:"kilometers"});O.value=m,m<1?`${(m*1e3).toFixed(2)}`:`${m.toFixed(3)}`;const V=Math.floor(r.value.length/2)-1;V<0?r.value[0]:r.value[V],N(M)}else if(r.value.length>=3){const m=[...r.value];m[0]!==m[m.length-1]&&m.push(m[0]);const V=Q.polygon([m]),A=Q.area(V)/1e6;U.value=A,A<1?`${(A*1e6).toFixed(2)}`:`${A.toFixed(3)}`;const ue=Q.centroid(V);N(M,ue.geometry.coordinates)}else N(M,M.geometry.coordinates[0])}function N(M,m,V){if(a?.value){if(a.value.getSource("measure-line-source")?a.value.getSource("measure-line-source").setData(M):(a.value.addSource("measure-line-source",{type:"geojson",data:M}),a.value.addLayer({id:"measure-line-layer",type:"line",source:"measure-line-source",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#16aaff","line-width":2,"line-dasharray":[2,1]}}),o.value="measure-line-layer"),l.value==="area"&&r.value.length>=3){const A=[...r.value];A[0]!==A[A.length-1]&&A.push(A[0]);const ue=Q.polygon([A]);a.value.getSource("measure-fill-source")?a.value.getSource("measure-fill-source").setData(ue):(a.value.addSource("measure-fill-source",{type:"geojson",data:ue}),a.value.addLayer({id:"measure-fill-layer",type:"fill",source:"measure-fill-source",paint:{"fill-color":"#16aaff","fill-opacity":.2,"fill-outline-color":"#16aaff"}},"measure-line-layer"))}a.value.getSource("measure-label-source")&&a.value.getLayer("measure-label-layer")&&(a.value.removeLayer("measure-label-layer"),a.value.removeSource("measure-label-source"),i.value=null)}}function B(){a?.value&&(a.value?.off("click",C),a.value?.off("dblclick",f),a.value.getCanvas().style.cursor="",a.value.getLayer("measure-point-layer")&&(a.value.removeLayer("measure-point-layer"),a.value.removeSource("measure-point-source")),a.value.getLayer("measure-line-layer")&&(a.value.removeLayer("measure-line-layer"),a.value.removeSource("measure-line-source")),a.value.getLayer("measure-fill-layer")&&(a.value.removeLayer("measure-fill-layer"),a.value.removeSource("measure-fill-source")),a.value.getLayer("measure-label-layer")&&(a.value.removeLayer("measure-label-layer"),a.value.removeSource("measure-label-source")),r.value=[],o.value=null,i.value=null,s.value=!1,O.value=0,U.value=0,a.value.getLayer("measure-label-layer")&&a.value.removeLayer("measure-label-layer"),a.value.getSource("measure-label-source")&&a.value.removeSource("measure-label-source"))}p.onUnmounted(()=>{B(),E&&E(),a?.value&&(a.value.removeControl(h),a.value?.off("draw.create",u),a.value?.off("click",C),a.value?.off("dblclick",f))});const O=p.ref(0),H=p.computed(()=>O.value<1?`${(O.value*1e3).toFixed(2)} 米`:`${O.value.toFixed(3)} 公里`),U=p.ref(0),Lt=p.computed(()=>U.value<1?`${(U.value*1e6).toFixed(2)} 平方米`:`${U.value.toFixed(3)} 平方公里`),Nt=p.computed(()=>l.value==="distance"?H.value:Lt.value),Pt=p.computed(()=>l.value==="distance"?"总长度: ":"总面积: ");return(M,m)=>(p.openBlock(),p.createElementBlock(p.Fragment,null,[s.value||r.value.length>0&&(n.value=="measure_distance"||n.value=="measure_area")?(p.openBlock(),p.createElementBlock("div",Vn,[p.createElementVNode("div",xn,[p.createElementVNode("span",Bn,p.toDisplayString(Pt.value),1),p.createElementVNode("span",Gn,p.toDisplayString(Nt.value),1),p.createVNode(p.unref(Rt.ElIcon),{style:{display:"block","margin-left":"10px",cursor:"pointer"},onClick:m[0]||(m[0]=V=>c("clear_all")),size:"20px"},{default:p.withCtx(()=>[p.createVNode(p.unref(wt.Close))]),_:1})])])):p.createCommentVNode("",!0),p.createElementVNode("div",$n,[e.tools.includes("point")?(p.openBlock(),p.createElementBlock("div",{key:0,title:"兴趣点",class:p.normalizeClass(["hiper-map-tools-btn",n.value=="point"?"active":null]),onClick:m[1]||(m[1]=()=>c("point"))},[...m[7]||(m[7]=[p.createElementVNode("span",{class:"qyuan icon-local-two"},null,-1)])],2)):p.createCommentVNode("",!0),e.tools.includes("line")?(p.openBlock(),p.createElementBlock("div",{key:1,title:"折线",class:p.normalizeClass(["hiper-map-tools-btn",n.value=="line"?"active":null]),onClick:m[2]||(m[2]=()=>c("line"))},[...m[8]||(m[8]=[p.createElementVNode("span",{class:"qyuan icon-whole-site-accelerator"},null,-1)])],2)):p.createCommentVNode("",!0),e.tools.includes("polygon")?(p.openBlock(),p.createElementBlock("div",{key:2,title:"多边形",class:p.normalizeClass(["hiper-map-tools-btn",n.value=="polygon"?"active":null]),onClick:m[3]||(m[3]=()=>c("polygon"))},[...m[9]||(m[9]=[p.createElementVNode("span",{class:"qyuan icon-anchor"},null,-1)])],2)):p.createCommentVNode("",!0),e.tools.includes("measure_distance")?(p.openBlock(),p.createElementBlock("div",{key:3,title:"测距",class:p.normalizeClass(["hiper-map-tools-btn",n.value=="measure_distance"?"active":null]),onClick:m[4]||(m[4]=()=>c("measure_distance"))},[...m[10]||(m[10]=[p.createElementVNode("span",{class:"qyuan icon-ruler"},null,-1)])],2)):p.createCommentVNode("",!0),e.tools.includes("measure_area")?(p.openBlock(),p.createElementBlock("div",{key:4,title:"测面",class:p.normalizeClass(["hiper-map-tools-btn",n.value=="measure_area"?"active":null]),onClick:m[5]||(m[5]=()=>c("measure_area"))},[...m[11]||(m[11]=[p.createElementVNode("span",{class:"qyuan icon-multi-triangular"},null,-1)])],2)):p.createCommentVNode("",!0),e.tools.includes("clear_all")?(p.openBlock(),p.createElementBlock("div",{key:5,title:"清除所有临时绘制图形",class:"hiper-map-tools-btn",style:{border:"none"},onClick:m[6]||(m[6]=()=>c("clear_all"))},[...m[12]||(m[12]=[p.createElementVNode("span",{class:"qyuan icon-clear"},null,-1)])])):p.createCommentVNode("",!0)])],64))}});exports._sfc_main=qn;
1
+ "use strict";const p=require("vue"),oe=require("./_commonjsHelpers-DwGv2jUC.js"),At=require("./ProvideKeys-jy8dfV9u.js"),Ge=require("./EventKeys-BLmCVdTJ.js"),Ft=require("./constant-Bc8XErtI.js"),Dt=require("@turf/turf"),wt=require("@element-plus/icons-vue"),Rt=require("element-plus");function kt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Q=kt(Dt),R={CANVAS:"mapboxgl-canvas",CONTROL_BASE:"mapboxgl-ctrl",CONTROL_PREFIX:"mapboxgl-ctrl-",CONTROL_BUTTON:"mapbox-gl-draw_ctrl-draw-btn",CONTROL_BUTTON_LINE:"mapbox-gl-draw_line",CONTROL_BUTTON_POLYGON:"mapbox-gl-draw_polygon",CONTROL_BUTTON_POINT:"mapbox-gl-draw_point",CONTROL_BUTTON_TRASH:"mapbox-gl-draw_trash",CONTROL_BUTTON_COMBINE_FEATURES:"mapbox-gl-draw_combine",CONTROL_BUTTON_UNCOMBINE_FEATURES:"mapbox-gl-draw_uncombine",CONTROL_GROUP:"mapboxgl-ctrl-group",ATTRIBUTION:"mapboxgl-ctrl-attrib",ACTIVE_BUTTON:"active",BOX_SELECT:"mapbox-gl-draw_boxselect"},G={HOT:"mapbox-gl-draw-hot",COLD:"mapbox-gl-draw-cold"},I={ADD:"add",MOVE:"move",DRAG:"drag",POINTER:"pointer",NONE:"none"},k={POLYGON:"polygon",LINE:"line_string",POINT:"point"},g={FEATURE:"Feature",POLYGON:"Polygon",LINE_STRING:"LineString",POINT:"Point",FEATURE_COLLECTION:"FeatureCollection",MULTI_PREFIX:"Multi",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon"},v={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select"},D={CREATE:"draw.create",DELETE:"draw.delete",UPDATE:"draw.update",SELECTION_CHANGE:"draw.selectionchange",MODE_CHANGE:"draw.modechange",ACTIONABLE:"draw.actionable",RENDER:"draw.render",COMBINE_FEATURES:"draw.combine",UNCOMBINE_FEATURES:"draw.uncombine"},ie={MOVE:"move",CHANGE_PROPERTIES:"change_properties",CHANGE_COORDINATES:"change_coordinates"},P={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},b={ACTIVE:"true",INACTIVE:"false"},it=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],Ut=-90,Oe=-85,Vt=90,be=85,xt=-270,Bt=270,st=Object.freeze(Object.defineProperty({__proto__:null,LAT_MAX:Vt,LAT_MIN:Ut,LAT_RENDERED_MAX:be,LAT_RENDERED_MIN:Oe,LNG_MAX:Bt,LNG_MIN:xt,activeStates:b,classes:R,cursors:I,events:D,geojsonTypes:g,interactions:it,meta:P,modes:v,sources:G,types:k,updateActions:ie},Symbol.toStringTag,{value:"Module"}));function me(e){return function(t){const n=t.featureTarget;return!n||!n.properties?!1:n.properties.meta===e}}function at(e){return!e.originalEvent||!e.originalEvent.shiftKey?!1:e.originalEvent.button===0}function z(e){return!e.featureTarget||!e.featureTarget.properties?!1:e.featureTarget.properties.active===b.ACTIVE&&e.featureTarget.properties.meta===P.FEATURE}function De(e){return!e.featureTarget||!e.featureTarget.properties?!1:e.featureTarget.properties.active===b.INACTIVE&&e.featureTarget.properties.meta===P.FEATURE}function ye(e){return e.featureTarget===void 0}function we(e){return!e.featureTarget||!e.featureTarget.properties?!1:e.featureTarget.properties.meta===P.FEATURE}function se(e){const t=e.featureTarget;return!t||!t.properties?!1:t.properties.meta===P.VERTEX}function he(e){return e.originalEvent?e.originalEvent.shiftKey===!0:!1}function Ee(e){return e.key==="Escape"||e.keyCode===27}function ve(e){return e.key==="Enter"||e.keyCode===13}function Le(e){return e.key==="Backspace"||e.keyCode===8}function Ne(e){return e.key==="Delete"||e.keyCode===46}function ut(e){return e.key==="1"||e.keyCode===49}function lt(e){return e.key==="2"||e.keyCode===50}function ct(e){return e.key==="3"||e.keyCode===51}function dt(e){const t=e.key||String.fromCharCode(e.keyCode);return t>="0"&&t<="9"}function Gt(){return!0}const $t=Object.freeze(Object.defineProperty({__proto__:null,isActiveFeature:z,isBackspaceKey:Le,isDeleteKey:Ne,isDigit1Key:ut,isDigit2Key:lt,isDigit3Key:ct,isDigitKey:dt,isEnterKey:ve,isEscapeKey:Ee,isFeature:we,isInactiveFeature:De,isOfMetaType:me,isShiftDown:he,isShiftMousedown:at,isTrue:Gt,isVertex:se,noTarget:ye},Symbol.toStringTag,{value:"Module"}));var le={},te={},$e;function qt(){return $e||($e=1,te.RADIUS=6378137,te.FLATTENING=1/298.257223563,te.POLAR_RADIUS=63567523142e-4),te}var qe;function Jt(){if(qe)return le;qe=1;var e=qt();le.geometry=t,le.ring=r;function t(i){var s=0,l;switch(i.type){case"Polygon":return n(i.coordinates);case"MultiPolygon":for(l=0;l<i.coordinates.length;l++)s+=n(i.coordinates[l]);return s;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(l=0;l<i.geometries.length;l++)s+=t(i.geometries[l]);return s}}function n(i){var s=0;if(i&&i.length>0){s+=Math.abs(r(i[0]));for(var l=1;l<i.length;l++)s-=Math.abs(r(i[l]))}return s}function r(i){var s,l,c,a,h,E,u,d=0,f=i.length;if(f>2){for(u=0;u<f;u++)u===f-2?(a=f-2,h=f-1,E=0):u===f-1?(a=f-1,h=0,E=1):(a=u,h=u+1,E=u+2),s=i[a],l=i[h],c=i[E],d+=(o(c[0])-o(s[0]))*Math.sin(o(l[1]));d=d*e.RADIUS*e.RADIUS/2}return d}function o(i){return i*Math.PI/180}return le}var Kt=Jt();const Yt=oe.getDefaultExportFromCjs(Kt),Je={Point:0,LineString:1,MultiLineString:1,Polygon:2};function Xt(e,t){const n=Je[e.geometry.type]-Je[t.geometry.type];return n===0&&e.geometry.type===g.POLYGON?e.area-t.area:n}function ft(e){return e.map(t=>(t.geometry.type===g.POLYGON&&(t.area=Yt.geometry({type:g.FEATURE,property:{},geometry:t.geometry})),t)).sort(Xt).map(t=>(delete t.area,t))}function pt(e,t=0){return[[e.point.x-t,e.point.y-t],[e.point.x+t,e.point.y+t]]}function $(e){if(this._items={},this._nums={},this._length=e?e.length:0,!!e)for(let t=0,n=e.length;t<n;t++)this.add(e[t]),e[t]!==void 0&&(typeof e[t]=="string"?this._items[e[t]]=t:this._nums[e[t]]=t)}$.prototype.add=function(e){return this.has(e)?this:(this._length++,typeof e=="string"?this._items[e]=this._length:this._nums[e]=this._length,this)};$.prototype.delete=function(e){return this.has(e)===!1?this:(this._length--,delete this._items[e],delete this._nums[e],this)};$.prototype.has=function(e){return typeof e!="string"&&typeof e!="number"?!1:this._items[e]!==void 0||this._nums[e]!==void 0};$.prototype.values=function(){const e=[];return Object.keys(this._items).forEach(t=>{e.push({k:t,v:this._items[t]})}),Object.keys(this._nums).forEach(t=>{e.push({k:JSON.parse(t),v:this._nums[t]})}),e.sort((t,n)=>t.v-n.v).map(t=>t.k)};$.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};const Ht=[P.FEATURE,P.MIDPOINT,P.VERTEX],j={click:Zt,touch:Wt};function Zt(e,t,n){return ht(e,t,n,n.options.clickBuffer)}function Wt(e,t,n){return ht(e,t,n,n.options.touchBuffer)}function ht(e,t,n,r){if(n.map===null)return[];const o=e?pt(e,r):t,i={};n.options.styles&&(i.layers=n.options.styles.map(a=>a.id).filter(a=>n.map.getLayer(a)!=null));const s=n.map.queryRenderedFeatures(o,i).filter(a=>Ht.indexOf(a.properties.meta)!==-1),l=new $,c=[];return s.forEach(a=>{const h=a.properties.id;l.has(h)||(l.add(h),c.push(a))}),ft(c)}function pe(e,t){const n=j.click(e,null,t),r={mouse:I.NONE};return n[0]&&(r.mouse=n[0].properties.active===b.ACTIVE?I.MOVE:I.POINTER,r.feature=n[0].properties.meta),t.events.currentModeName().indexOf("draw")!==-1&&(r.mouse=I.ADD),t.ui.queueMapClasses(r),t.ui.updateMapClasses(),n[0]}function Re(e,t){const n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}const zt=4,Qt=12,jt=500;function Pe(e,t,n={}){const r=n.fineTolerance!=null?n.fineTolerance:zt,o=n.grossTolerance!=null?n.grossTolerance:Qt,i=n.interval!=null?n.interval:jt;e.point=e.point||t.point,e.time=e.time||t.time;const s=Re(e.point,t.point);return s<r||s<o&&t.time-e.time<i}const en=25,tn=250;function Ae(e,t,n={}){const r=n.tolerance!=null?n.tolerance:en,o=n.interval!=null?n.interval:tn;return e.point=e.point||t.point,e.time=e.time||t.time,Re(e.point,t.point)<r&&t.time-e.time<o}const Fe=function(e,t){const n={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},r={on(i,s,l){if(n[i]===void 0)throw new Error(`Invalid event type: ${i}`);n[i].push({selector:s,fn:l})},render(i){t.store.featureChanged(i)}},o=function(i,s){const l=n[i];let c=l.length;for(;c--;){const a=l[c];if(a.selector(s)){a.fn.call(r,s)||t.store.render(),t.ui.updateMapClasses();break}}};return e.start.call(r),{render:e.render,stop(){e.stop&&e.stop()},trash(){e.trash&&(e.trash(),t.store.render())},combineFeatures(){e.combineFeatures&&e.combineFeatures()},uncombineFeatures(){e.uncombineFeatures&&e.uncombineFeatures()},drag(i){o("drag",i)},click(i){o("click",i)},mousemove(i){o("mousemove",i)},mousedown(i){o("mousedown",i)},mouseup(i){o("mouseup",i)},mouseout(i){o("mouseout",i)},keydown(i){o("keydown",i)},keyup(i){o("keyup",i)},touchstart(i){o("touchstart",i)},touchmove(i){o("touchmove",i)},touchend(i){o("touchend",i)},tap(i){o("tap",i)}}};let nn=(e,t=21)=>(n=t)=>{let r="",o=n|0;for(;o--;)r+=e[Math.random()*e.length|0];return r};const rn=nn("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",32);function ke(){return rn()}const w=function(e,t){this.ctx=e,this.properties=t.properties||{},this.coordinates=t.geometry.coordinates,this.id=t.id||ke(),this.type=t.geometry.type};w.prototype.changed=function(){this.ctx.store.featureChanged(this.id)};w.prototype.incomingCoords=function(e){this.setCoordinates(e)};w.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()};w.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))};w.prototype.setProperty=function(e,t){this.properties[e]=t};w.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:g.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))};w.prototype.internal=function(e){const t={id:this.id,meta:P.FEATURE,"meta:type":this.type,active:b.INACTIVE,mode:e};if(this.ctx.options.userProperties)for(const n in this.properties)t[`user_${n}`]=this.properties[n];return{type:g.FEATURE,properties:t,geometry:{coordinates:this.getCoordinates(),type:this.type}}};const W=function(e,t){w.call(this,e,t)};W.prototype=Object.create(w.prototype);W.prototype.isValid=function(){return typeof this.coordinates[0]=="number"&&typeof this.coordinates[1]=="number"};W.prototype.updateCoordinate=function(e,t,n){arguments.length===3?this.coordinates=[t,n]:this.coordinates=[e,t],this.changed()};W.prototype.getCoordinate=function(){return this.getCoordinates()};const X=function(e,t){w.call(this,e,t)};X.prototype=Object.create(w.prototype);X.prototype.isValid=function(){return this.coordinates.length>1};X.prototype.addCoordinate=function(e,t,n){this.changed();const r=parseInt(e,10);this.coordinates.splice(r,0,[t,n])};X.prototype.getCoordinate=function(e){const t=parseInt(e,10);return JSON.parse(JSON.stringify(this.coordinates[t]))};X.prototype.removeCoordinate=function(e){this.changed(),this.coordinates.splice(parseInt(e,10),1)};X.prototype.updateCoordinate=function(e,t,n){const r=parseInt(e,10);this.coordinates[r]=[t,n],this.changed()};const x=function(e,t){w.call(this,e,t),this.coordinates=this.coordinates.map(n=>n.slice(0,-1))};x.prototype=Object.create(w.prototype);x.prototype.isValid=function(){return this.coordinates.length===0?!1:this.coordinates.every(e=>e.length>2)};x.prototype.incomingCoords=function(e){this.coordinates=e.map(t=>t.slice(0,-1)),this.changed()};x.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()};x.prototype.addCoordinate=function(e,t,n){this.changed();const r=e.split(".").map(i=>parseInt(i,10));this.coordinates[r[0]].splice(r[1],0,[t,n])};x.prototype.removeCoordinate=function(e){this.changed();const t=e.split(".").map(r=>parseInt(r,10)),n=this.coordinates[t[0]];n&&(n.splice(t[1],1),n.length<3&&this.coordinates.splice(t[0],1))};x.prototype.getCoordinate=function(e){const t=e.split(".").map(r=>parseInt(r,10)),n=this.coordinates[t[0]];return JSON.parse(JSON.stringify(n[t[1]]))};x.prototype.getCoordinates=function(){return this.coordinates.map(e=>e.concat([e[0]]))};x.prototype.updateCoordinate=function(e,t,n){this.changed();const r=e.split("."),o=parseInt(r[0],10),i=parseInt(r[1],10);this.coordinates[o]===void 0&&(this.coordinates[o]=[]),this.coordinates[o][i]=[t,n]};const on={MultiPoint:W,MultiLineString:X,MultiPolygon:x},Ce=(e,t,n,r,o)=>{const i=n.split("."),s=parseInt(i[0],10),l=i[1]?i.slice(1).join("."):null;return e[s][t](l,r,o)},F=function(e,t){if(w.call(this,e,t),delete this.coordinates,this.model=on[t.geometry.type],this.model===void 0)throw new TypeError(`${t.geometry.type} is not a valid type`);this.features=this._coordinatesToFeatures(t.geometry.coordinates)};F.prototype=Object.create(w.prototype);F.prototype._coordinatesToFeatures=function(e){const t=this.model.bind(this);return e.map(n=>new t(this.ctx,{id:ke(),type:g.FEATURE,properties:{},geometry:{coordinates:n,type:this.type.replace("Multi","")}}))};F.prototype.isValid=function(){return this.features.every(e=>e.isValid())};F.prototype.setCoordinates=function(e){this.features=this._coordinatesToFeatures(e),this.changed()};F.prototype.getCoordinate=function(e){return Ce(this.features,"getCoordinate",e)};F.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(e=>e.type===g.POLYGON?e.getCoordinates():e.coordinates)))};F.prototype.updateCoordinate=function(e,t,n){Ce(this.features,"updateCoordinate",e,t,n),this.changed()};F.prototype.addCoordinate=function(e,t,n){Ce(this.features,"addCoordinate",e,t,n),this.changed()};F.prototype.removeCoordinate=function(e){Ce(this.features,"removeCoordinate",e),this.changed()};F.prototype.getFeatures=function(){return this.features};function y(e){this.map=e.map,this.drawConfig=JSON.parse(JSON.stringify(e.options||{})),this._ctx=e}y.prototype.setSelected=function(e){return this._ctx.store.setSelected(e)};y.prototype.setSelectedCoordinates=function(e){this._ctx.store.setSelectedCoordinates(e),e.reduce((t,n)=>(t[n.feature_id]===void 0&&(t[n.feature_id]=!0,this._ctx.store.get(n.feature_id).changed()),t),{})};y.prototype.getSelected=function(){return this._ctx.store.getSelected()};y.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()};y.prototype.isSelected=function(e){return this._ctx.store.isSelected(e)};y.prototype.getFeature=function(e){return this._ctx.store.get(e)};y.prototype.select=function(e){return this._ctx.store.select(e)};y.prototype.deselect=function(e){return this._ctx.store.deselect(e)};y.prototype.deleteFeature=function(e,t={}){return this._ctx.store.delete(e,t)};y.prototype.addFeature=function(e,t={}){return this._ctx.store.add(e,t)};y.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()};y.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()};y.prototype.setActionableState=function(e={}){const t={trash:e.trash||!1,combineFeatures:e.combineFeatures||!1,uncombineFeatures:e.uncombineFeatures||!1};return this._ctx.events.actionable(t)};y.prototype.changeMode=function(e,t={},n={}){return this._ctx.events.changeMode(e,t,n)};y.prototype.fire=function(e,t){return this._ctx.events.fire(e,t)};y.prototype.updateUIClasses=function(e){return this._ctx.ui.queueMapClasses(e)};y.prototype.activateUIButton=function(e){return this._ctx.ui.setActiveButton(e)};y.prototype.featuresAt=function(e,t,n="click"){if(n!=="click"&&n!=="touch")throw new Error("invalid buffer type");return j[n](e,t,this._ctx)};y.prototype.newFeature=function(e){const t=e.geometry.type;return t===g.POINT?new W(this._ctx,e):t===g.LINE_STRING?new X(this._ctx,e):t===g.POLYGON?new x(this._ctx,e):new F(this._ctx,e)};y.prototype.isInstanceOf=function(e,t){if(e===g.POINT)return t instanceof W;if(e===g.LINE_STRING)return t instanceof X;if(e===g.POLYGON)return t instanceof x;if(e==="MultiFeature")return t instanceof F;throw new Error(`Unknown feature class: ${e}`)};y.prototype.doRender=function(e){return this._ctx.store.featureChanged(e)};y.prototype.onSetup=function(){};y.prototype.onDrag=function(){};y.prototype.onClick=function(){};y.prototype.onMouseMove=function(){};y.prototype.onMouseDown=function(){};y.prototype.onMouseUp=function(){};y.prototype.onMouseOut=function(){};y.prototype.onKeyUp=function(){};y.prototype.onKeyDown=function(){};y.prototype.onTouchStart=function(){};y.prototype.onTouchMove=function(){};y.prototype.onTouchEnd=function(){};y.prototype.onTap=function(){};y.prototype.onStop=function(){};y.prototype.onTrash=function(){};y.prototype.onCombineFeature=function(){};y.prototype.onUncombineFeature=function(){};y.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};const gt={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},sn=Object.keys(gt);function an(e){const t=Object.keys(e);return function(n,r={}){let o={};const i=t.reduce((l,c)=>(l[c]=e[c],l),new y(n));function s(l){return c=>i[l](o,c)}return{start(){o=i.onSetup(r),sn.forEach(l=>{const c=gt[l];let a=()=>!1;e[c]&&(a=()=>!0),this.on(l,a,s(c))})},stop(){i.onStop(o)},trash(){i.onTrash(o)},combineFeatures(){i.onCombineFeatures(o)},uncombineFeatures(){i.onUncombineFeatures(o)},render(l,c){i.toDisplayFeatures(o,l,c)}}}}function un(e){const t=Object.keys(e.options.modes).reduce((u,d)=>(u[d]=an(e.options.modes[d]),u),{});let n={},r={};const o={};let i=null,s=null;o.drag=function(u,d){d({point:u.point,time:new Date().getTime()})?(e.ui.queueMapClasses({mouse:I.DRAG}),s.drag(u)):u.originalEvent.stopPropagation()},o.mousedrag=function(u){o.drag(u,d=>!Pe(n,d))},o.touchdrag=function(u){o.drag(u,d=>!Ae(r,d))},o.mousemove=function(u){if((u.originalEvent.buttons!==void 0?u.originalEvent.buttons:u.originalEvent.which)===1)return o.mousedrag(u);const f=pe(u,e);u.featureTarget=f,s.mousemove(u)},o.mousedown=function(u){n={time:new Date().getTime(),point:u.point};const d=pe(u,e);u.featureTarget=d,s.mousedown(u)},o.mouseup=function(u){const d=pe(u,e);u.featureTarget=d,Pe(n,{point:u.point,time:new Date().getTime()})?s.click(u):s.mouseup(u)},o.mouseout=function(u){s.mouseout(u)},o.touchstart=function(u){if(!e.options.touchEnabled)return;r={time:new Date().getTime(),point:u.point};const d=j.touch(u,null,e)[0];u.featureTarget=d,s.touchstart(u)},o.touchmove=function(u){if(e.options.touchEnabled)return s.touchmove(u),o.touchdrag(u)},o.touchend=function(u){if(u.originalEvent.preventDefault(),!e.options.touchEnabled)return;const d=j.touch(u,null,e)[0];u.featureTarget=d,Ae(r,{time:new Date().getTime(),point:u.point})?s.tap(u):s.touchend(u)};const l=u=>{const d=Le(u),f=Ne(u),C=dt(u);return!(d||f||C)};o.keydown=function(u){(u.srcElement||u.target).classList.contains(R.CANVAS)&&((Le(u)||Ne(u))&&e.options.controls.trash?(u.preventDefault(),s.trash()):l(u)?s.keydown(u):ut(u)&&e.options.controls.point?c(v.DRAW_POINT):lt(u)&&e.options.controls.line_string?c(v.DRAW_LINE_STRING):ct(u)&&e.options.controls.polygon&&c(v.DRAW_POLYGON))},o.keyup=function(u){l(u)&&s.keyup(u)},o.zoomend=function(){e.store.changeZoom()},o.data=function(u){if(u.dataType==="style"){const{setup:d,map:f,options:C,store:L}=e;C.styles.some(B=>f.getLayer(B.id))||(d.addLayers(),L.setDirty(),L.render())}};function c(u,d,f={}){s.stop();const C=t[u];if(C===void 0)throw new Error(`${u} is not valid`);i=u;const L=C(e,d);s=Fe(L,e),f.silent||e.map.fire(D.MODE_CHANGE,{mode:u}),e.store.setDirty(),e.store.render()}const a={trash:!1,combineFeatures:!1,uncombineFeatures:!1};function h(u){let d=!1;Object.keys(u).forEach(f=>{if(a[f]===void 0)throw new Error("Invalid action type");a[f]!==u[f]&&(d=!0),a[f]=u[f]}),d&&e.map.fire(D.ACTIONABLE,{actions:a})}return{start(){i=e.options.defaultMode,s=Fe(t[i](e),e)},changeMode:c,actionable:h,currentModeName(){return i},currentModeRender(u,d){return s.render(u,d)},fire(u,d){e.map&&e.map.fire(u,d)},addEventListeners(){e.map.on("mousemove",o.mousemove),e.map.on("mousedown",o.mousedown),e.map.on("mouseup",o.mouseup),e.map.on("data",o.data),e.map.on("touchmove",o.touchmove),e.map.on("touchstart",o.touchstart),e.map.on("touchend",o.touchend),e.container.addEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",o.keydown),e.container.addEventListener("keyup",o.keyup))},removeEventListeners(){e.map.off("mousemove",o.mousemove),e.map.off("mousedown",o.mousedown),e.map.off("mouseup",o.mouseup),e.map.off("data",o.data),e.map.off("touchmove",o.touchmove),e.map.off("touchstart",o.touchstart),e.map.off("touchend",o.touchend),e.container.removeEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",o.keydown),e.container.removeEventListener("keyup",o.keyup))},trash(u){s.trash(u)},combineFeatures(){s.combineFeatures()},uncombineFeatures(){s.uncombineFeatures()},getMode(){return i}}}function ae(e){return[].concat(e).filter(t=>t!==void 0)}function ln(){const e=this;if(!(e.ctx.map&&e.ctx.map.getSource(G.HOT)!==void 0))return c();const n=e.ctx.events.currentModeName();e.ctx.ui.queueMapClasses({mode:n});let r=[],o=[];e.isDirty?o=e.getAllIds():(r=e.getChangedIds().filter(a=>e.get(a)!==void 0),o=e.sources.hot.filter(a=>a.properties.id&&r.indexOf(a.properties.id)===-1&&e.get(a.properties.id)!==void 0).map(a=>a.properties.id)),e.sources.hot=[];const i=e.sources.cold.length;e.sources.cold=e.isDirty?[]:e.sources.cold.filter(a=>{const h=a.properties.id||a.properties.parent;return r.indexOf(h)===-1});const s=i!==e.sources.cold.length||o.length>0;r.forEach(a=>l(a,"hot")),o.forEach(a=>l(a,"cold"));function l(a,h){const u=e.get(a).internal(n);e.ctx.events.currentModeRender(u,d=>{d.properties.mode=n,e.sources[h].push(d)})}s&&e.ctx.map.getSource(G.COLD).setData({type:g.FEATURE_COLLECTION,features:e.sources.cold}),e.ctx.map.getSource(G.HOT).setData({type:g.FEATURE_COLLECTION,features:e.sources.hot}),c();function c(){e.isDirty=!1,e.clearChangedIds()}}function _(e){this._features={},this._featureIds=new $,this._selectedFeatureIds=new $,this._selectedCoordinates=[],this._changedFeatureIds=new $,this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=e,this.sources={hot:[],cold:[]};let t;this.render=()=>{t||(t=requestAnimationFrame(()=>{t=null,ln.call(this),this._emitSelectionChange&&(this.ctx.events.fire(D.SELECTION_CHANGE,{features:this.getSelected().map(n=>n.toGeoJSON()),points:this.getSelectedCoordinates().map(n=>({type:g.FEATURE,properties:{},geometry:{type:g.POINT,coordinates:n.coordinates}}))}),this._emitSelectionChange=!1),this.ctx.events.fire(D.RENDER,{})}))},this.isDirty=!1}_.prototype.createRenderBatch=function(){const e=this.render;let t=0;return this.render=function(){t++},()=>{this.render=e,t>0&&this.render()}};_.prototype.setDirty=function(){return this.isDirty=!0,this};_.prototype.featureCreated=function(e,t={}){if(this._changedFeatureIds.add(e),(t.silent!=null?t.silent:this.ctx.options.suppressAPIEvents)!==!0){const r=this.get(e);this.ctx.events.fire(D.CREATE,{features:[r.toGeoJSON()]})}return this};_.prototype.featureChanged=function(e,t={}){return this._changedFeatureIds.add(e),(t.silent!=null?t.silent:this.ctx.options.suppressAPIEvents)!==!0&&this.ctx.events.fire(D.UPDATE,{action:t.action?t.action:ie.CHANGE_COORDINATES,features:[this.get(e).toGeoJSON()]}),this};_.prototype.getChangedIds=function(){return this._changedFeatureIds.values()};_.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this};_.prototype.getAllIds=function(){return this._featureIds.values()};_.prototype.add=function(e,t={}){return this._features[e.id]=e,this._featureIds.add(e.id),this.featureCreated(e.id,{silent:t.silent}),this};_.prototype.delete=function(e,t={}){const n=[];return ae(e).forEach(r=>{this._featureIds.has(r)&&(this._featureIds.delete(r),this._selectedFeatureIds.delete(r),t.silent||n.indexOf(this._features[r])===-1&&n.push(this._features[r].toGeoJSON()),delete this._features[r],this.isDirty=!0)}),n.length&&this.ctx.events.fire(D.DELETE,{features:n}),mt(this,t),this};_.prototype.get=function(e){return this._features[e]};_.prototype.getAll=function(){return Object.keys(this._features).map(e=>this._features[e])};_.prototype.select=function(e,t={}){return ae(e).forEach(n=>{this._selectedFeatureIds.has(n)||(this._selectedFeatureIds.add(n),this._changedFeatureIds.add(n),t.silent||(this._emitSelectionChange=!0))}),this};_.prototype.deselect=function(e,t={}){return ae(e).forEach(n=>{this._selectedFeatureIds.has(n)&&(this._selectedFeatureIds.delete(n),this._changedFeatureIds.add(n),t.silent||(this._emitSelectionChange=!0))}),mt(this,t),this};_.prototype.clearSelected=function(e={}){return this.deselect(this._selectedFeatureIds.values(),{silent:e.silent}),this};_.prototype.setSelected=function(e,t={}){return e=ae(e),this.deselect(this._selectedFeatureIds.values().filter(n=>e.indexOf(n)===-1),{silent:t.silent}),this.select(e.filter(n=>!this._selectedFeatureIds.has(n)),{silent:t.silent}),this};_.prototype.setSelectedCoordinates=function(e){return this._selectedCoordinates=e,this._emitSelectionChange=!0,this};_.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this};_.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()};_.prototype.getSelected=function(){return this.getSelectedIds().map(e=>this.get(e))};_.prototype.getSelectedCoordinates=function(){return this._selectedCoordinates.map(t=>({coordinates:this.get(t.feature_id).getCoordinate(t.coord_path)}))};_.prototype.isSelected=function(e){return this._selectedFeatureIds.has(e)};_.prototype.setFeatureProperty=function(e,t,n,r={}){this.get(e).setProperty(t,n),this.featureChanged(e,{silent:r.silent,action:ie.CHANGE_PROPERTIES})};function mt(e,t={}){const n=e._selectedCoordinates.filter(r=>e._selectedFeatureIds.has(r.feature_id));e._selectedCoordinates.length!==n.length&&!t.silent&&(e._emitSelectionChange=!0),e._selectedCoordinates=n}_.prototype.storeMapConfig=function(){it.forEach(e=>{this.ctx.map[e]&&(this._mapInitialConfig[e]=this.ctx.map[e].isEnabled())})};_.prototype.restoreMapConfig=function(){Object.keys(this._mapInitialConfig).forEach(e=>{this._mapInitialConfig[e]?this.ctx.map[e].enable():this.ctx.map[e].disable()})};_.prototype.getInitialConfigValue=function(e){return this._mapInitialConfig[e]!==void 0?this._mapInitialConfig[e]:!0};const cn=["mode","feature","mouse"];function dn(e){const t={};let n=null,r={mode:null,feature:null,mouse:null},o={mode:null,feature:null,mouse:null};function i(){s({mode:null,feature:null,mouse:null}),l()}function s(d){o=Object.assign(o,d)}function l(){if(!e.container)return;const d=[],f=[];cn.forEach(C=>{o[C]!==r[C]&&(d.push(`${C}-${r[C]}`),o[C]!==null&&f.push(`${C}-${o[C]}`))}),d.length>0&&e.container.classList.remove(...d),f.length>0&&e.container.classList.add(...f),r=Object.assign(r,o)}function c(d,f={}){const C=document.createElement("button");return C.className=`${R.CONTROL_BUTTON} ${f.className}`,C.setAttribute("title",f.title),f.container.appendChild(C),C.addEventListener("click",L=>{if(L.preventDefault(),L.stopPropagation(),L.target===n){a(),f.onDeactivate();return}h(d),f.onActivate()},!0),C}function a(){n&&(n.classList.remove(R.ACTIVE_BUTTON),n=null)}function h(d){a();const f=t[d];f&&f&&d!=="trash"&&(f.classList.add(R.ACTIVE_BUTTON),n=f)}function E(){const d=e.options.controls,f=document.createElement("div");return f.className=`${R.CONTROL_GROUP} ${R.CONTROL_BASE}`,d&&(d[k.POINT]&&(t[k.POINT]=c(k.POINT,{container:f,className:R.CONTROL_BUTTON_POINT,title:`Marker tool ${e.options.keybindings?"(1)":""}`,onActivate:()=>e.events.changeMode(v.DRAW_POINT),onDeactivate:()=>e.events.trash()})),d[k.LINE]&&(t[k.LINE]=c(k.LINE,{container:f,className:R.CONTROL_BUTTON_LINE,title:`LineString tool ${e.options.keybindings?"(2)":""}`,onActivate:()=>e.events.changeMode(v.DRAW_LINE_STRING),onDeactivate:()=>e.events.trash()})),d[k.POLYGON]&&(t[k.POLYGON]=c(k.POLYGON,{container:f,className:R.CONTROL_BUTTON_POLYGON,title:`Polygon tool ${e.options.keybindings?"(3)":""}`,onActivate:()=>e.events.changeMode(v.DRAW_POLYGON),onDeactivate:()=>e.events.trash()})),d.trash&&(t.trash=c("trash",{container:f,className:R.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:()=>{e.events.trash()}})),d.combine_features&&(t.combine_features=c("combineFeatures",{container:f,className:R.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:()=>{e.events.combineFeatures()}})),d.uncombine_features&&(t.uncombine_features=c("uncombineFeatures",{container:f,className:R.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:()=>{e.events.uncombineFeatures()}}))),f}function u(){Object.keys(t).forEach(d=>{const f=t[d];f.parentNode&&f.parentNode.removeChild(f),delete t[d]})}return{setActiveButton:h,queueMapClasses:s,updateMapClasses:l,clearMapClasses:i,addButtons:E,removeButtons:u}}function fn(e){let t=null,n=null;const r={onRemove(){return e.map.off("load",r.connect),clearInterval(n),r.removeLayers(),e.store.restoreMapConfig(),e.ui.removeButtons(),e.events.removeEventListeners(),e.ui.clearMapClasses(),e.boxZoomInitial&&e.map.boxZoom.enable(),e.map=null,e.container=null,e.store=null,t&&t.parentNode&&t.parentNode.removeChild(t),t=null,this},connect(){e.map.off("load",r.connect),clearInterval(n),r.addLayers(),e.store.storeMapConfig(),e.events.addEventListeners()},onAdd(o){if(e.map=o,e.events=un(e),e.ui=dn(e),e.container=o.getContainer(),e.store=new _(e),t=e.ui.addButtons(),e.options.boxSelect){e.boxZoomInitial=o.boxZoom.isEnabled(),o.boxZoom.disable();const i=o.dragPan.isEnabled();o.dragPan.disable(),o.dragPan.enable(),i||o.dragPan.disable()}return o.loaded()?r.connect():(o.on("load",r.connect),n=setInterval(()=>{o.loaded()&&r.connect()},16)),e.events.start(),t},addLayers(){e.map.addSource(G.COLD,{data:{type:g.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(G.HOT,{data:{type:g.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.options.styles.forEach(o=>{e.map.addLayer(o)}),e.store.setDirty(!0),e.store.render()},removeLayers(){e.options.styles.forEach(o=>{e.map.getLayer(o.id)&&e.map.removeLayer(o.id)}),e.map.getSource(G.COLD)&&e.map.removeSource(G.COLD),e.map.getSource(G.HOT)&&e.map.removeSource(G.HOT)}};return e.setup=r,r}const Te="#3bb2d0",ne="#fbb03b",Ke="#fff",yt=[{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"]],paint:{"fill-color":["case",["==",["get","active"],"true"],ne,Te],"fill-opacity":.1}},{id:"gl-draw-lines",type:"line",filter:["any",["==","$type","LineString"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["==",["get","active"],"true"],ne,Te],"line-dasharray":["case",["==",["get","active"],"true"],[.2,2],[2,0]],"line-width":2}},{id:"gl-draw-point-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":Ke}},{id:"gl-draw-point-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":["case",["==",["get","active"],"true"],ne,Te]}},{id:"gl-draw-vertex-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":Ke}},{id:"gl-draw-vertex-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":ne}},{id:"gl-draw-midpoint",type:"circle",filter:["all",["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":ne}}];function Z(e,t){this.x=e,this.y=t}Z.prototype={clone(){return new Z(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,n=e.y-this.y;return t*t+n*n},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const t=e[0]*this.x+e[1]*this.y,n=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=n,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),n=Math.sin(e),r=t*this.x-n*this.y,o=n*this.x+t*this.y;return this.x=r,this.y=o,this},_rotateAround(e,t){const n=Math.cos(e),r=Math.sin(e),o=t.x+n*(this.x-t.x)-r*(this.y-t.y),i=t.y+r*(this.x-t.x)+n*(this.y-t.y);return this.x=o,this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Z};Z.convert=function(e){if(e instanceof Z)return e;if(Array.isArray(e))return new Z(+e[0],+e[1]);if(e.x!==void 0&&e.y!==void 0)return new Z(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};function Ue(e,t){const n=t.getBoundingClientRect();return new Z(e.clientX-n.left-(t.clientLeft||0),e.clientY-n.top-(t.clientTop||0))}function ee(e,t,n,r){return{type:g.FEATURE,properties:{meta:P.VERTEX,parent:e,coord_path:n,active:r?b.ACTIVE:b.INACTIVE},geometry:{type:g.POINT,coordinates:t}}}function pn(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function Et(e,t,n){if(e!==null)for(var r,o,i,s,l,c,a,h=0,E=0,u,d=e.type,f=d==="FeatureCollection",C=d==="Feature",L=f?e.features.length:1,N=0;N<L;N++){a=f?e.features[N].geometry:C?e.geometry:e,u=a?a.type==="GeometryCollection":!1,l=u?a.geometries.length:1;for(var B=0;B<l;B++){var O=0,H=0;if(s=u?a.geometries[B]:a,s!==null){c=s.coordinates;var U=s.type;switch(h=0,U){case null:break;case"Point":if(t(c,E,N,O,H)===!1)return!1;E++,O++;break;case"LineString":case"MultiPoint":for(r=0;r<c.length;r++){if(t(c[r],E,N,O,H)===!1)return!1;E++,U==="MultiPoint"&&O++}U==="LineString"&&O++;break;case"Polygon":case"MultiLineString":for(r=0;r<c.length;r++){for(o=0;o<c[r].length-h;o++){if(t(c[r][o],E,N,O,H)===!1)return!1;E++}U==="MultiLineString"&&O++,U==="Polygon"&&H++}U==="Polygon"&&O++;break;case"MultiPolygon":for(r=0;r<c.length;r++){for(H=0,o=0;o<c[r].length;o++){for(i=0;i<c[r][o].length-h;i++){if(t(c[r][o][i],E,N,O,H)===!1)return!1;E++}H++}O++}break;case"GeometryCollection":for(r=0;r<s.geometries.length;r++)if(Et(s.geometries[r],t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function hn(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return vt(e);case"FeatureCollection":return gn(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Ve(e);default:throw new Error("unknown GeoJSON type")}}function vt(e){const t={type:"Feature"};return Object.keys(e).forEach(n=>{switch(n){case"type":case"properties":case"geometry":return;default:t[n]=e[n]}}),t.properties=Ct(e.properties),e.geometry==null?t.geometry=null:t.geometry=Ve(e.geometry),t}function Ct(e){const t={};return e&&Object.keys(e).forEach(n=>{const r=e[n];typeof r=="object"?r===null?t[n]=null:Array.isArray(r)?t[n]=r.map(o=>o):t[n]=Ct(r):t[n]=r}),t}function gn(e){const t={type:"FeatureCollection"};return Object.keys(e).forEach(n=>{switch(n){case"type":case"features":return;default:t[n]=e[n]}}),t.features=e.features.map(n=>vt(n)),t}function Ve(e){const t={type:e.type};return e.bbox&&(t.bbox=e.bbox),e.type==="GeometryCollection"?(t.geometries=e.geometries.map(n=>Ve(n)),t):(t.coordinates=St(e.coordinates),t)}function St(e){const t=e;return typeof t[0]!="object"?t.slice():t.map(n=>St(n))}function Ye(e,t={}){return Tt(e,"mercator",t)}function mn(e,t={}){return Tt(e,"wgs84",t)}function Tt(e,t,n={}){n=n||{};var r=n.mutate;if(!e)throw new Error("geojson is required");return Array.isArray(e)&&pn(e[0])?e=t==="mercator"?Xe(e):He(e):(r!==!0&&(e=hn(e)),Et(e,function(o){var i=t==="mercator"?Xe(o):He(o);o[0]=i[0],o[1]=i[1]})),e}function Xe(e){var t=Math.PI/180,n=6378137,r=20037508342789244e-9,o=Math.abs(e[0])<=180?e[0]:e[0]-yn(e[0])*360,i=[n*o*t,n*Math.log(Math.tan(Math.PI*.25+.5*e[1]*t))];return i[0]>r&&(i[0]=r),i[0]<-r&&(i[0]=-r),i[1]>r&&(i[1]=r),i[1]<-r&&(i[1]=-r),i}function He(e){var t=180/Math.PI,n=6378137;return[e[0]*t/n,(Math.PI*.5-2*Math.atan(Math.exp(-e[1]/n)))*t]}function yn(e){return e<0?-1:e>0?1:0}function _t(e,t,n){const r=t.geometry.coordinates,o=n.geometry.coordinates;if(r[1]>be||r[1]<Oe||o[1]>be||o[1]<Oe)return null;const i=Ye(r),s=Ye(o),l=E=>Number(E.toFixed(8)),c=(E,u)=>(E+u)/2,a=mn([c(i[0],s[0]),c(i[1],s[1])]),h=[l(a[0]),l(a[1])];return{type:g.FEATURE,properties:{meta:P.MIDPOINT,parent:e,lng:h[0],lat:h[1],coord_path:n.properties.coord_path},geometry:{type:g.POINT,coordinates:h}}}function Se(e,t={},n=null){const{type:r,coordinates:o}=e.geometry,i=e.properties&&e.properties.id;let s=[];r===g.POINT?s.push(ee(i,o,n,c(n))):r===g.POLYGON?o.forEach((h,E)=>{l(h,n!==null?`${n}.${E}`:String(E))}):r===g.LINE_STRING?l(o,n):r.indexOf(g.MULTI_PREFIX)===0&&a();function l(h,E){let u="",d=null;h.forEach((f,C)=>{const L=E!=null?`${E}.${C}`:String(C),N=ee(i,f,L,c(L));if(t.midpoints&&d){const O=_t(i,d,N);O&&s.push(O)}d=N;const B=JSON.stringify(f);u!==B&&s.push(N),C===0&&(u=B)})}function c(h){return t.selectedPaths?t.selectedPaths.indexOf(h)!==-1:!1}function a(){const h=r.replace(g.MULTI_PREFIX,"");o.forEach((E,u)=>{const d={type:g.FEATURE,properties:e.properties,geometry:{type:h,coordinates:E}};s=s.concat(Se(d,t,u))})}return s}const q={enable(e){setTimeout(()=>{!e.map||!e.map.doubleClickZoom||!e._ctx||!e._ctx.store||!e._ctx.store.getInitialConfigValue||e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable()},0)},disable(e){setTimeout(()=>{!e.map||!e.map.doubleClickZoom||e.map.doubleClickZoom.disable()},0)}},{LAT_MIN:ce,LAT_MAX:de,LAT_RENDERED_MIN:Ze,LAT_RENDERED_MAX:We,LNG_MIN:ze,LNG_MAX:Qe}=st;function En(e){const t={Point:0,LineString:1,Polygon:2,MultiPoint:1,MultiLineString:2,MultiPolygon:3}[e.geometry.type],n=[e.geometry.coordinates].flat(t),r=n.map(l=>l[0]),o=n.map(l=>l[1]),i=l=>Math.min.apply(null,l),s=l=>Math.max.apply(null,l);return[i(r),i(o),s(r),s(o)]}function xe(e,t){let n=ce,r=de,o=ce,i=de,s=Qe,l=ze;e.forEach(a=>{const h=En(a),E=h[1],u=h[3],d=h[0],f=h[2];E>n&&(n=E),u<r&&(r=u),u>o&&(o=u),E<i&&(i=E),d<s&&(s=d),f>l&&(l=f)});const c=t;return n+c.lat>We&&(c.lat=We-n),o+c.lat>de&&(c.lat=de-o),r+c.lat<Ze&&(c.lat=Ze-r),i+c.lat<ce&&(c.lat=ce-i),s+c.lng<=ze&&(c.lng+=Math.ceil(Math.abs(c.lng)/360)*360),l+c.lng>=Qe&&(c.lng-=Math.ceil(Math.abs(c.lng)/360)*360),c}function Be(e,t){const n=xe(e.map(r=>r.toGeoJSON()),t);e.forEach(r=>{const o=r.getCoordinates(),i=a=>{const h={lng:a[0]+n.lng,lat:a[1]+n.lat};return[h.lng,h.lat]},s=a=>a.map(h=>i(h)),l=a=>a.map(h=>s(h));let c;r.type===g.POINT?c=i(o):r.type===g.LINE_STRING||r.type===g.MULTI_POINT?c=o.map(i):r.type===g.POLYGON||r.type===g.MULTI_LINE_STRING?c=o.map(s):r.type===g.MULTI_POLYGON&&(c=o.map(l)),r.incomingCoords(c)})}const S={};S.onSetup=function(e){const t={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initialDragPanState:this.map.dragPan.isEnabled(),initiallySelectedFeatureIds:e.featureIds||[]};return this.setSelected(t.initiallySelectedFeatureIds.filter(n=>this.getFeature(n)!==void 0)),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),t};S.fireUpdate=function(){this.fire(D.UPDATE,{action:ie.MOVE,features:this.getSelected().map(e=>e.toGeoJSON())})};S.fireActionable=function(){const e=this.getSelected(),t=e.filter(i=>this.isInstanceOf("MultiFeature",i));let n=!1;if(e.length>1){n=!0;const i=e[0].type.replace("Multi","");e.forEach(s=>{s.type.replace("Multi","")!==i&&(n=!1)})}const r=t.length>0,o=e.length>0;this.setActionableState({combineFeatures:n,uncombineFeatures:r,trash:o})};S.getUniqueIds=function(e){return e.length?e.map(n=>n.properties.id).filter(n=>n!==void 0).reduce((n,r)=>(n.add(r),n),new $).values():[]};S.stopExtendedInteractions=function(e){e.boxSelectElement&&(e.boxSelectElement.parentNode&&e.boxSelectElement.parentNode.removeChild(e.boxSelectElement),e.boxSelectElement=null),(e.canDragMove||e.canBoxSelect)&&e.initialDragPanState===!0&&this.map.dragPan.enable(),e.boxSelecting=!1,e.canBoxSelect=!1,e.dragMoving=!1,e.canDragMove=!1};S.onStop=function(){q.enable(this)};S.onMouseMove=function(e,t){return we(t)&&e.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(e),!0};S.onMouseOut=function(e){return e.dragMoving?this.fireUpdate():!0};S.onTap=S.onClick=function(e,t){if(ye(t))return this.clickAnywhere(e,t);if(me(P.VERTEX)(t))return this.clickOnVertex(e,t);if(we(t))return this.clickOnFeature(e,t)};S.clickAnywhere=function(e){const t=this.getSelectedIds();t.length&&(this.clearSelectedFeatures(),t.forEach(n=>this.doRender(n))),q.enable(this),this.stopExtendedInteractions(e)};S.clickOnVertex=function(e,t){this.changeMode(v.DIRECT_SELECT,{featureId:t.featureTarget.properties.parent,coordPath:t.featureTarget.properties.coord_path,startPos:t.lngLat}),this.updateUIClasses({mouse:I.MOVE})};S.startOnActiveFeature=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),this.doRender(t.featureTarget.properties.id),e.canDragMove=!0,e.dragMoveLocation=t.lngLat};S.clickOnFeature=function(e,t){q.disable(this),this.stopExtendedInteractions(e);const n=he(t),r=this.getSelectedIds(),o=t.featureTarget.properties.id,i=this.isSelected(o);if(!n&&i&&this.getFeature(o).type!==g.POINT)return this.changeMode(v.DIRECT_SELECT,{featureId:o});i&&n?(this.deselect(o),this.updateUIClasses({mouse:I.POINTER}),r.length===1&&q.enable(this)):!i&&n?(this.select(o),this.updateUIClasses({mouse:I.MOVE})):!i&&!n&&(r.forEach(s=>this.doRender(s)),this.setSelected(o),this.updateUIClasses({mouse:I.MOVE})),this.doRender(o)};S.onMouseDown=function(e,t){if(e.initialDragPanState=this.map.dragPan.isEnabled(),z(t))return this.startOnActiveFeature(e,t);if(this.drawConfig.boxSelect&&at(t))return this.startBoxSelect(e,t)};S.startBoxSelect=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),e.boxSelectStartLocation=Ue(t.originalEvent,this.map.getContainer()),e.canBoxSelect=!0};S.onTouchStart=function(e,t){if(z(t))return this.startOnActiveFeature(e,t)};S.onDrag=function(e,t){if(e.canDragMove)return this.dragMove(e,t);if(this.drawConfig.boxSelect&&e.canBoxSelect)return this.whileBoxSelect(e,t)};S.whileBoxSelect=function(e,t){e.boxSelecting=!0,this.updateUIClasses({mouse:I.ADD}),e.boxSelectElement||(e.boxSelectElement=document.createElement("div"),e.boxSelectElement.classList.add(R.BOX_SELECT),this.map.getContainer().appendChild(e.boxSelectElement));const n=Ue(t.originalEvent,this.map.getContainer()),r=Math.min(e.boxSelectStartLocation.x,n.x),o=Math.max(e.boxSelectStartLocation.x,n.x),i=Math.min(e.boxSelectStartLocation.y,n.y),s=Math.max(e.boxSelectStartLocation.y,n.y),l=`translate(${r}px, ${i}px)`;e.boxSelectElement.style.transform=l,e.boxSelectElement.style.WebkitTransform=l,e.boxSelectElement.style.width=`${o-r}px`,e.boxSelectElement.style.height=`${s-i}px`};S.dragMove=function(e,t){e.dragMoving=!0,t.originalEvent.stopPropagation();const n={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};Be(this.getSelected(),n),e.dragMoveLocation=t.lngLat};S.onTouchEnd=S.onMouseUp=function(e,t){if(e.dragMoving)this.fireUpdate();else if(e.boxSelecting){const n=[e.boxSelectStartLocation,Ue(t.originalEvent,this.map.getContainer())],r=this.featuresAt(null,n,"click"),o=this.getUniqueIds(r).filter(i=>!this.isSelected(i));o.length&&(this.select(o),o.forEach(i=>this.doRender(i)),this.updateUIClasses({mouse:I.MOVE}))}this.stopExtendedInteractions(e)};S.toDisplayFeatures=function(e,t,n){t.properties.active=this.isSelected(t.properties.id)?b.ACTIVE:b.INACTIVE,n(t),this.fireActionable(),!(t.properties.active!==b.ACTIVE||t.geometry.type===g.POINT)&&Se(t).forEach(n)};S.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()};S.onCombineFeatures=function(){const e=this.getSelected();if(e.length===0||e.length<2)return;const t=[],n=[],r=e[0].type.replace("Multi","");for(let o=0;o<e.length;o++){const i=e[o];if(i.type.replace("Multi","")!==r)return;i.type.includes("Multi")?i.getCoordinates().forEach(s=>{t.push(s)}):t.push(i.getCoordinates()),n.push(i.toGeoJSON())}if(n.length>1){const o=this.newFeature({type:g.FEATURE,properties:n[0].properties,geometry:{type:`Multi${r}`,coordinates:t}});this.addFeature(o),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([o.id]),this.fire(D.COMBINE_FEATURES,{createdFeatures:[o.toGeoJSON()],deletedFeatures:n})}this.fireActionable()};S.onUncombineFeatures=function(){const e=this.getSelected();if(e.length===0)return;const t=[],n=[];for(let r=0;r<e.length;r++){const o=e[r];this.isInstanceOf("MultiFeature",o)&&(o.getFeatures().forEach(i=>{this.addFeature(i),i.properties=o.properties,t.push(i.toGeoJSON()),this.select([i.id])}),this.deleteFeature(o.id,{silent:!0}),n.push(o.toGeoJSON()))}t.length>1&&this.fire(D.UNCOMBINE_FEATURES,{createdFeatures:t,deletedFeatures:n}),this.fireActionable()};const It=me(P.VERTEX),Mt=me(P.MIDPOINT),T={};T.fireUpdate=function(){this.fire(D.UPDATE,{action:ie.CHANGE_COORDINATES,features:this.getSelected().map(e=>e.toGeoJSON())})};T.fireActionable=function(e){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:e.selectedCoordPaths.length>0})};T.startDragging=function(e,t){e.initialDragPanState==null&&(e.initialDragPanState=this.map.dragPan.isEnabled()),this.map.dragPan.disable(),e.canDragMove=!0,e.dragMoveLocation=t.lngLat};T.stopDragging=function(e){e.canDragMove&&e.initialDragPanState===!0&&this.map.dragPan.enable(),e.initialDragPanState=null,e.dragMoving=!1,e.canDragMove=!1,e.dragMoveLocation=null};T.onVertex=function(e,t){this.startDragging(e,t);const n=t.featureTarget.properties,r=e.selectedCoordPaths.indexOf(n.coord_path);!he(t)&&r===-1?e.selectedCoordPaths=[n.coord_path]:he(t)&&r===-1&&e.selectedCoordPaths.push(n.coord_path);const o=this.pathsToCoordinates(e.featureId,e.selectedCoordPaths);this.setSelectedCoordinates(o)};T.onMidpoint=function(e,t){this.startDragging(e,t);const n=t.featureTarget.properties;e.feature.addCoordinate(n.coord_path,n.lng,n.lat),this.fireUpdate(),e.selectedCoordPaths=[n.coord_path]};T.pathsToCoordinates=function(e,t){return t.map(n=>({feature_id:e,coord_path:n}))};T.onFeature=function(e,t){e.selectedCoordPaths.length===0?this.startDragging(e,t):this.stopDragging(e)};T.dragFeature=function(e,t,n){Be(this.getSelected(),n),e.dragMoveLocation=t.lngLat};T.dragVertex=function(e,t,n){const r=e.selectedCoordPaths.map(s=>e.feature.getCoordinate(s)),o=r.map(s=>({type:g.FEATURE,properties:{},geometry:{type:g.POINT,coordinates:s}})),i=xe(o,n);for(let s=0;s<r.length;s++){const l=r[s];e.feature.updateCoordinate(e.selectedCoordPaths[s],l[0]+i.lng,l[1]+i.lat)}};T.clickNoTarget=function(){this.changeMode(v.SIMPLE_SELECT)};T.clickInactive=function(){this.changeMode(v.SIMPLE_SELECT)};T.clickActiveFeature=function(e){e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed()};T.onSetup=function(e){const t=e.featureId,n=this.getFeature(t);if(!n)throw new Error("You must provide a featureId to enter direct_select mode");if(n.type===g.POINT)throw new TypeError("direct_select mode doesn't handle point features");const r={featureId:t,feature:n,dragMoveLocation:e.startPos||null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:e.coordPath?[e.coordPath]:[]};return this.setSelectedCoordinates(this.pathsToCoordinates(t,r.selectedCoordPaths)),this.setSelected(t),q.disable(this),this.setActionableState({trash:!0}),r};T.onStop=function(){q.enable(this),this.clearSelectedCoordinates()};T.toDisplayFeatures=function(e,t,n){e.featureId===t.properties.id?(t.properties.active=b.ACTIVE,n(t),Se(t,{map:this.map,midpoints:!0,selectedPaths:e.selectedCoordPaths}).forEach(n)):(t.properties.active=b.INACTIVE,n(t)),this.fireActionable(e)};T.onTrash=function(e){e.selectedCoordPaths.sort((t,n)=>n.localeCompare(t,"en",{numeric:!0})).forEach(t=>e.feature.removeCoordinate(t)),this.fireUpdate(),e.selectedCoordPaths=[],this.clearSelectedCoordinates(),this.fireActionable(e),e.feature.isValid()===!1&&(this.deleteFeature([e.featureId]),this.changeMode(v.SIMPLE_SELECT,{}))};T.onMouseMove=function(e,t){const n=z(t),r=It(t),o=Mt(t),i=e.selectedCoordPaths.length===0;return n&&i?this.updateUIClasses({mouse:I.MOVE}):r&&!i?this.updateUIClasses({mouse:I.MOVE}):this.updateUIClasses({mouse:I.NONE}),(r||n||o)&&e.dragMoving&&this.fireUpdate(),this.stopDragging(e),!0};T.onMouseOut=function(e){return e.dragMoving&&this.fireUpdate(),!0};T.onTouchStart=T.onMouseDown=function(e,t){if(It(t))return this.onVertex(e,t);if(z(t))return this.onFeature(e,t);if(Mt(t))return this.onMidpoint(e,t)};T.onDrag=function(e,t){if(e.canDragMove!==!0)return;e.dragMoving=!0,t.originalEvent.stopPropagation();const n={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};e.selectedCoordPaths.length>0?this.dragVertex(e,t,n):this.dragFeature(e,t,n),e.dragMoveLocation=t.lngLat};T.onClick=function(e,t){if(ye(t))return this.clickNoTarget(e,t);if(z(t))return this.clickActiveFeature(e,t);if(De(t))return this.clickInactive(e,t);this.stopDragging(e)};T.onTap=function(e,t){if(ye(t))return this.clickNoTarget(e,t);if(z(t))return this.clickActiveFeature(e,t);if(De(t))return this.clickInactive(e,t)};T.onTouchEnd=T.onMouseUp=function(e){e.dragMoving&&this.fireUpdate(),this.stopDragging(e)};const Y={};Y.onSetup=function(){const e=this.newFeature({type:g.FEATURE,properties:{},geometry:{type:g.POINT,coordinates:[]}});return this.addFeature(e),this.clearSelectedFeatures(),this.updateUIClasses({mouse:I.ADD}),this.activateUIButton(k.POINT),this.setActionableState({trash:!0}),{point:e}};Y.stopDrawingAndRemove=function(e){this.deleteFeature([e.point.id],{silent:!0}),this.changeMode(v.SIMPLE_SELECT)};Y.onTap=Y.onClick=function(e,t){this.updateUIClasses({mouse:I.MOVE}),e.point.updateCoordinate("",t.lngLat.lng,t.lngLat.lat),this.fire(D.CREATE,{features:[e.point.toGeoJSON()]}),this.changeMode(v.SIMPLE_SELECT,{featureIds:[e.point.id]})};Y.onStop=function(e){this.activateUIButton(),e.point.getCoordinate().length||this.deleteFeature([e.point.id],{silent:!0})};Y.toDisplayFeatures=function(e,t,n){const r=t.properties.id===e.point.id;if(t.properties.active=r?b.ACTIVE:b.INACTIVE,!r)return n(t)};Y.onTrash=Y.stopDrawingAndRemove;Y.onKeyUp=function(e,t){if(Ee(t)||ve(t))return this.stopDrawingAndRemove(e,t)};function ge(e,t){return e.lngLat?e.lngLat.lng===t[0]&&e.lngLat.lat===t[1]:!1}const J={};J.onSetup=function(){const e=this.newFeature({type:g.FEATURE,properties:{},geometry:{type:g.POLYGON,coordinates:[[]]}});return this.addFeature(e),this.clearSelectedFeatures(),q.disable(this),this.updateUIClasses({mouse:I.ADD}),this.activateUIButton(k.POLYGON),this.setActionableState({trash:!0}),{polygon:e,currentVertexPosition:0}};J.clickAnywhere=function(e,t){if(e.currentVertexPosition>0&&ge(t,e.polygon.coordinates[0][e.currentVertexPosition-1]))return this.changeMode(v.SIMPLE_SELECT,{featureIds:[e.polygon.id]});this.updateUIClasses({mouse:I.ADD}),e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition++,e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat)};J.clickOnVertex=function(e){return this.changeMode(v.SIMPLE_SELECT,{featureIds:[e.polygon.id]})};J.onMouseMove=function(e,t){e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),se(t)&&this.updateUIClasses({mouse:I.POINTER})};J.onTap=J.onClick=function(e,t){return se(t)?this.clickOnVertex(e,t):this.clickAnywhere(e,t)};J.onKeyUp=function(e,t){Ee(t)?(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(v.SIMPLE_SELECT)):ve(t)&&this.changeMode(v.SIMPLE_SELECT,{featureIds:[e.polygon.id]})};J.onStop=function(e){this.updateUIClasses({mouse:I.NONE}),q.enable(this),this.activateUIButton(),this.getFeature(e.polygon.id)!==void 0&&(e.polygon.removeCoordinate(`0.${e.currentVertexPosition}`),e.polygon.isValid()?this.fire(D.CREATE,{features:[e.polygon.toGeoJSON()]}):(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(v.SIMPLE_SELECT,{},{silent:!0})))};J.toDisplayFeatures=function(e,t,n){const r=t.properties.id===e.polygon.id;if(t.properties.active=r?b.ACTIVE:b.INACTIVE,!r)return n(t);if(t.geometry.coordinates.length===0)return;const o=t.geometry.coordinates[0].length;if(!(o<3)){if(t.properties.meta=P.FEATURE,n(ee(e.polygon.id,t.geometry.coordinates[0][0],"0.0",!1)),o>3){const i=t.geometry.coordinates[0].length-3;n(ee(e.polygon.id,t.geometry.coordinates[0][i],`0.${i}`,!1))}if(o<=4){const i=[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]];if(n({type:g.FEATURE,properties:t.properties,geometry:{coordinates:i,type:g.LINE_STRING}}),o===3)return}return n(t)}};J.onTrash=function(e){this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(v.SIMPLE_SELECT)};const K={};K.onSetup=function(e){e=e||{};const t=e.featureId;let n,r,o="forward";if(t){if(n=this.getFeature(t),!n)throw new Error("Could not find a feature with the provided featureId");let i=e.from;if(i&&i.type==="Feature"&&i.geometry&&i.geometry.type==="Point"&&(i=i.geometry),i&&i.type==="Point"&&i.coordinates&&i.coordinates.length===2&&(i=i.coordinates),!i||!Array.isArray(i))throw new Error("Please use the `from` property to indicate which point to continue the line from");const s=n.coordinates.length-1;if(n.coordinates[s][0]===i[0]&&n.coordinates[s][1]===i[1])r=s+1,n.addCoordinate(r,...n.coordinates[s]);else if(n.coordinates[0][0]===i[0]&&n.coordinates[0][1]===i[1])o="backwards",r=0,n.addCoordinate(r,...n.coordinates[0]);else throw new Error("`from` should match the point at either the start or the end of the provided LineString")}else n=this.newFeature({type:g.FEATURE,properties:{},geometry:{type:g.LINE_STRING,coordinates:[]}}),r=0,this.addFeature(n);return this.clearSelectedFeatures(),q.disable(this),this.updateUIClasses({mouse:I.ADD}),this.activateUIButton(k.LINE),this.setActionableState({trash:!0}),{line:n,currentVertexPosition:r,direction:o}};K.clickAnywhere=function(e,t){if(e.currentVertexPosition>0&&ge(t,e.line.coordinates[e.currentVertexPosition-1])||e.direction==="backwards"&&ge(t,e.line.coordinates[e.currentVertexPosition+1]))return this.changeMode(v.SIMPLE_SELECT,{featureIds:[e.line.id]});this.updateUIClasses({mouse:I.ADD}),e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),e.direction==="forward"?(e.currentVertexPosition++,e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat)):e.line.addCoordinate(0,t.lngLat.lng,t.lngLat.lat)};K.clickOnVertex=function(e){return this.changeMode(v.SIMPLE_SELECT,{featureIds:[e.line.id]})};K.onMouseMove=function(e,t){e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),se(t)&&this.updateUIClasses({mouse:I.POINTER})};K.onTap=K.onClick=function(e,t){if(se(t))return this.clickOnVertex(e,t);this.clickAnywhere(e,t)};K.onKeyUp=function(e,t){ve(t)?this.changeMode(v.SIMPLE_SELECT,{featureIds:[e.line.id]}):Ee(t)&&(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(v.SIMPLE_SELECT))};K.onStop=function(e){q.enable(this),this.activateUIButton(),this.getFeature(e.line.id)!==void 0&&(e.line.removeCoordinate(`${e.currentVertexPosition}`),e.line.isValid()?this.fire(D.CREATE,{features:[e.line.toGeoJSON()]}):(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(v.SIMPLE_SELECT,{},{silent:!0})))};K.onTrash=function(e){this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(v.SIMPLE_SELECT)};K.toDisplayFeatures=function(e,t,n){const r=t.properties.id===e.line.id;if(t.properties.active=r?b.ACTIVE:b.INACTIVE,!r)return n(t);t.geometry.coordinates.length<2||(t.properties.meta=P.FEATURE,n(ee(e.line.id,t.geometry.coordinates[e.direction==="forward"?t.geometry.coordinates.length-2:1],`${e.direction==="forward"?t.geometry.coordinates.length-2:1}`,!1)),n(t))};const Ot={simple_select:S,direct_select:T,draw_point:Y,draw_polygon:J,draw_line_string:K},vn={defaultMode:v.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:yt,modes:Ot,controls:{},userProperties:!1,suppressAPIEvents:!0},Cn={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},Sn={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function je(e,t){return e.map(n=>n.source?n:Object.assign({},n,{id:`${n.id}.${t}`,source:t==="hot"?G.HOT:G.COLD}))}function Tn(e={}){let t=Object.assign({},e);return e.controls||(t.controls={}),e.displayControlsDefault===!1?t.controls=Object.assign({},Sn,e.controls):t.controls=Object.assign({},Cn,e.controls),t=Object.assign({},vn,t),t.styles=je(t.styles,"cold").concat(je(t.styles,"hot")),t}var _e,et;function _n(){return et||(et=1,_e=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var r,o,i;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(i=Object.keys(t),r=i.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;o--!==0;){var s=i[o];if(!e(t[s],n[s]))return!1}return!0}return t!==t&&n!==n}),_e}var In=_n();const tt=oe.getDefaultExportFromCjs(In);var Ie,nt;function Mn(){if(nt)return Ie;nt=1,Ie=t;var e={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"};function t(n){if(!n||!n.type)return null;var r=e[n.type];if(!r)return null;if(r==="geometry")return{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:n}]};if(r==="feature")return{type:"FeatureCollection",features:[n]};if(r==="featurecollection")return n}return Ie}var On=Mn();const bn=oe.getDefaultExportFromCjs(On);function bt(e,t){return e.length!==t.length?!1:JSON.stringify(e.map(n=>n).sort())===JSON.stringify(t.map(n=>n).sort())}const Ln={Polygon:x,LineString:X,Point:W,MultiPolygon:F,MultiLineString:F,MultiPoint:F};function Nn(e,t){t.modes=v;const n=e.options.suppressAPIEvents!==void 0?!!e.options.suppressAPIEvents:!0;return t.getFeatureIdsAt=function(r){return j.click({point:r},null,e).map(i=>i.properties.id)},t.getSelectedIds=function(){return e.store.getSelectedIds()},t.getSelected=function(){return{type:g.FEATURE_COLLECTION,features:e.store.getSelectedIds().map(r=>e.store.get(r)).map(r=>r.toGeoJSON())}},t.getSelectedPoints=function(){return{type:g.FEATURE_COLLECTION,features:e.store.getSelectedCoordinates().map(r=>({type:g.FEATURE,properties:{},geometry:{type:g.POINT,coordinates:r.coordinates}}))}},t.set=function(r){if(r.type===void 0||r.type!==g.FEATURE_COLLECTION||!Array.isArray(r.features))throw new Error("Invalid FeatureCollection");const o=e.store.createRenderBatch();let i=e.store.getAllIds().slice();const s=t.add(r),l=new $(s);return i=i.filter(c=>!l.has(c)),i.length&&t.delete(i),o(),s},t.add=function(r){const i=JSON.parse(JSON.stringify(bn(r))).features.map(s=>{if(s.id=s.id||ke(),s.geometry===null)throw new Error("Invalid geometry: null");if(e.store.get(s.id)===void 0||e.store.get(s.id).type!==s.geometry.type){const l=Ln[s.geometry.type];if(l===void 0)throw new Error(`Invalid geometry type: ${s.geometry.type}.`);const c=new l(e,s);e.store.add(c,{silent:n})}else{const l=e.store.get(s.id),c=l.properties;l.properties=s.properties,tt(c,s.properties)||e.store.featureChanged(l.id,{silent:n}),tt(l.getCoordinates(),s.geometry.coordinates)||l.incomingCoords(s.geometry.coordinates)}return s.id});return e.store.render(),i},t.get=function(r){const o=e.store.get(r);if(o)return o.toGeoJSON()},t.getAll=function(){return{type:g.FEATURE_COLLECTION,features:e.store.getAll().map(r=>r.toGeoJSON())}},t.delete=function(r){return e.store.delete(r,{silent:n}),t.getMode()===v.DIRECT_SELECT&&!e.store.getSelectedIds().length?e.events.changeMode(v.SIMPLE_SELECT,void 0,{silent:n}):e.store.render(),t},t.deleteAll=function(){return e.store.delete(e.store.getAllIds(),{silent:n}),t.getMode()===v.DIRECT_SELECT?e.events.changeMode(v.SIMPLE_SELECT,void 0,{silent:n}):e.store.render(),t},t.changeMode=function(r,o={}){return r===v.SIMPLE_SELECT&&t.getMode()===v.SIMPLE_SELECT?(bt(o.featureIds||[],e.store.getSelectedIds())||(e.store.setSelected(o.featureIds,{silent:n}),e.store.render()),t):(r===v.DIRECT_SELECT&&t.getMode()===v.DIRECT_SELECT&&o.featureId===e.store.getSelectedIds()[0]||e.events.changeMode(r,o,{silent:n}),t)},t.getMode=function(){return e.events.getMode()},t.trash=function(){return e.events.trash({silent:n}),t},t.combineFeatures=function(){return e.events.combineFeatures({silent:n}),t},t.uncombineFeatures=function(){return e.events.uncombineFeatures({silent:n}),t},t.setFeatureProperty=function(r,o,i){return e.store.setFeatureProperty(r,o,i,{silent:n}),t},t}const Pn=Object.freeze(Object.defineProperty({__proto__:null,CommonSelectors:$t,ModeHandler:Fe,StringSet:$,constrainFeatureMovement:xe,createMidPoint:_t,createSupplementaryPoints:Se,createVertex:ee,doubleClickZoom:q,euclideanDistance:Re,featuresAt:j,getFeatureAtAndSetCursors:pe,isClick:Pe,isEventAtCoordinates:ge,isTap:Ae,mapEventToBoundingBox:pt,moveFeatures:Be,sortFeatures:ft,stringSetsAreEqual:bt,theme:yt,toDenseArray:ae},Symbol.toStringTag,{value:"Module"})),An=function(e,t){e=Tn(e);const n={options:e};t=Nn(n,t),n.api=t;const r=fn(n);return t.onAdd=r.onAdd,t.onRemove=r.onRemove,t.types=k,t.options=e,t};function re(e){An(e,this)}re.modes=Ot;re.constants=st;re.lib=Pn;var Me={exports:{}},rt;function Fn(){if(rt)return Me.exports;rt=1;var e=Me.exports={};return e.onSetup=function(){return this.setActionableState(),{}},e.toDisplayFeatures=function(t,n,r){r(n)},Me.exports}var Dn=Fn();const wn=oe.getDefaultExportFromCjs(Dn);var fe={},ot;function Rn(){if(ot)return fe;ot=1,Object.defineProperty(fe,"__esModule",{value:!0});var e={enable:function(r){setTimeout(function(){!r.map||!r.map.doubleClickZoom||!r._ctx||!r._ctx.store||!r._ctx.store.getInitialConfigValue||r._ctx.store.getInitialConfigValue("doubleClickZoom")&&r.map.doubleClickZoom.enable()},0)},disable:function(r){setTimeout(function(){!r.map||!r.map.doubleClickZoom||r.map.doubleClickZoom.disable()},0)}},t={onSetup:function(r){var o=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});return this.addFeature(o),this.clearSelectedFeatures(),e.disable(this),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:!0}),{rectangle:o}},onTap:function(r,o){r.startPoint&&this.onMouseMove(r,o),this.onClick(r,o)},onClick:function(r,o){r.startPoint&&r.startPoint[0]!==o.lngLat.lng&&r.startPoint[1]!==o.lngLat.lat&&(this.updateUIClasses({mouse:"pointer"}),r.endPoint=[o.lngLat.lng,o.lngLat.lat],this.changeMode("simple_select",{featuresId:r.rectangle.id}));var i=[o.lngLat.lng,o.lngLat.lat];r.startPoint=i},onMouseMove:function(r,o){r.startPoint&&(r.rectangle.updateCoordinate("0.0",r.startPoint[0],r.startPoint[1]),r.rectangle.updateCoordinate("0.1",o.lngLat.lng,r.startPoint[1]),r.rectangle.updateCoordinate("0.2",o.lngLat.lng,o.lngLat.lat),r.rectangle.updateCoordinate("0.3",r.startPoint[0],o.lngLat.lat),r.rectangle.updateCoordinate("0.4",r.startPoint[0],r.startPoint[1]))},onKeyUp:function(r,o){if(o.keyCode===27)return this.changeMode("simple_select")},onStop:function(r){e.enable(this),this.updateUIClasses({mouse:"none"}),this.activateUIButton(),this.getFeature(r.rectangle.id)!==void 0&&(r.rectangle.removeCoordinate("0.4"),r.rectangle.isValid()?this.map.fire("draw.create",{features:[r.rectangle.toGeoJSON()]}):(this.deleteFeature([r.rectangle.id],{silent:!0}),this.changeMode("simple_select",{},{silent:!0})))},toDisplayFeatures:function(r,o,i){var s=o.properties.id===r.rectangle.id;if(o.properties.active=s?"true":"false",!s)return i(o);if(r.startPoint)return i(o)},onTrash:function(r){this.deleteFeature([r.rectangle.id],{silent:!0}),this.changeMode("simple_select")}};return fe.default=t,fe}var kn=Rn();const Un=oe.getDefaultExportFromCjs(kn),Vn={key:0,class:"measure-info-panel"},xn={class:"measure-info-content"},Bn={class:"measure-label"},Gn={class:"measure-value"},$n={class:"qy-flex-row hiper-map-tools-bar"},qn=p.defineComponent({__name:"MapTools",props:{tools:{default:()=>["point","line","polygon","measure_distance","measure_area","clear_all"]}},setup(e){const t=p.inject("mapRootId"),n=p.ref(),r=p.ref([]),o=p.ref(null),i=p.ref(null),s=p.ref(!1),l=p.ref("distance"),c=M=>{switch(s.value&&M!=="measure_distance"&&M!=="clear_all"&&B(),n.value=M,M){case"point":h.changeMode("draw_point");break;case"line":h.changeMode("draw_line_string");break;case"polygon":h.changeMode("draw_polygon");break;case"measure_distance":h.changeMode("simple_select"),l.value="distance",d();break;case"measure_area":h.changeMode("simple_select"),l.value="area",d();break;case"clear_all":h.deleteAll(),B();break}},a=p.inject(At.mapInstanceKey),h=new re({userProperties:!0,displayControlsDefault:!1,modes:{...re.modes,draw_rectangle:Un,static:wn}});let E=null;E=Ge.mapLoadedBus.on(({mapRootId:M})=>{t!==M||!a?.value||(console.log("hiper-map-tools-bar mounted",a),a.value.addControl(h,"top-left"),a.value.on("draw.create",u))});function u(M){const m=h.getAll();if(!m.features.length)return;m.features=[m.features[0]];const A={point:{layerType:"symbol",config:{textColor:"rgba(0,0,0,1)",iconName:Ft.DefaultIcon}},line:{layerType:"line",config:{lineWidth:1,lineColor:"rgba(255, 0, 0, 1)",lineStyle:"solid"}},polygon:{layerType:"shape",config:{fillColor:"rgba(241, 131, 127, 1)",lineWidth:1}}}[n.value];A&&Ge.showLayerEditKeyBus.emit({mapRootId:t,e:new MouseEvent("click"),layer:{layerType:A.layerType,customLayerConfig:JSON.stringify(A.config),geoJSON:JSON.stringify(m),...n.value==="polygon"?{pid:""}:{}}}),h.deleteAll()}function d(){a?.value&&(s.value=!0,r.value=[],a.value.getCanvas().style.cursor="crosshair",a.value.on("click",C),a.value.on("dblclick",f))}function f(M){if(s.value){if(M.preventDefault(),l.value==="distance")r.value.length>=2&&L();else if(r.value.length>=3){const m=r.value[0],V=r.value[r.value.length-1];(m[0]!==V[0]||m[1]!==V[1])&&r.value.push(m),L()}a?.value?.off("click",C),a?.value?.off("dblclick",f),a?.value&&(a.value.getCanvas().style.cursor=""),s.value=!1}}function C(M){if(!s.value||!a?.value)return;M.originalEvent.stopPropagation();const m=[M.lngLat.lng,M.lngLat.lat];r.value.push(m),r.value.length===1?(l.value==="distance"?O.value=0:U.value=0,a.value.getSource("measure-point-source")?a.value.getSource("measure-point-source").setData({type:"Feature",properties:{},geometry:{type:"Point",coordinates:m}}):(a.value.addSource("measure-point-source",{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"Point",coordinates:m}}}),a.value.addLayer({id:"measure-point-layer",type:"circle",source:"measure-point-source",paint:{"circle-radius":5,"circle-color":"#16aaff"}}))):(a.value.getSource("measure-point-source")&&a.value.getSource("measure-point-source").setData({type:"FeatureCollection",features:r.value.map(V=>({type:"Feature",properties:{},geometry:{type:"Point",coordinates:V}}))}),L(),l.value==="area"&&r.value.length>=3&&(a.value.getCanvas().style.cursor="pointer"))}function L(){if(!a?.value||r.value.length<2)return;const M=Q.lineString(r.value);if(l.value==="distance"){const m=Q.length(M,{units:"kilometers"});O.value=m,m<1?`${(m*1e3).toFixed(2)}`:`${m.toFixed(3)}`;const V=Math.floor(r.value.length/2)-1;V<0?r.value[0]:r.value[V],N(M)}else if(r.value.length>=3){const m=[...r.value];m[0]!==m[m.length-1]&&m.push(m[0]);const V=Q.polygon([m]),A=Q.area(V)/1e6;U.value=A,A<1?`${(A*1e6).toFixed(2)}`:`${A.toFixed(3)}`;const ue=Q.centroid(V);N(M,ue.geometry.coordinates)}else N(M,M.geometry.coordinates[0])}function N(M,m,V){if(a?.value){if(a.value.getSource("measure-line-source")?a.value.getSource("measure-line-source").setData(M):(a.value.addSource("measure-line-source",{type:"geojson",data:M}),a.value.addLayer({id:"measure-line-layer",type:"line",source:"measure-line-source",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#16aaff","line-width":2,"line-dasharray":[2,1]}}),o.value="measure-line-layer"),l.value==="area"&&r.value.length>=3){const A=[...r.value];A[0]!==A[A.length-1]&&A.push(A[0]);const ue=Q.polygon([A]);a.value.getSource("measure-fill-source")?a.value.getSource("measure-fill-source").setData(ue):(a.value.addSource("measure-fill-source",{type:"geojson",data:ue}),a.value.addLayer({id:"measure-fill-layer",type:"fill",source:"measure-fill-source",paint:{"fill-color":"#16aaff","fill-opacity":.2,"fill-outline-color":"#16aaff"}},"measure-line-layer"))}a.value.getSource("measure-label-source")&&a.value.getLayer("measure-label-layer")&&(a.value.removeLayer("measure-label-layer"),a.value.removeSource("measure-label-source"),i.value=null)}}function B(){a?.value&&(a.value?.off("click",C),a.value?.off("dblclick",f),a.value.getCanvas().style.cursor="",a.value.getLayer("measure-point-layer")&&(a.value.removeLayer("measure-point-layer"),a.value.removeSource("measure-point-source")),a.value.getLayer("measure-line-layer")&&(a.value.removeLayer("measure-line-layer"),a.value.removeSource("measure-line-source")),a.value.getLayer("measure-fill-layer")&&(a.value.removeLayer("measure-fill-layer"),a.value.removeSource("measure-fill-source")),a.value.getLayer("measure-label-layer")&&(a.value.removeLayer("measure-label-layer"),a.value.removeSource("measure-label-source")),r.value=[],o.value=null,i.value=null,s.value=!1,O.value=0,U.value=0,a.value.getLayer("measure-label-layer")&&a.value.removeLayer("measure-label-layer"),a.value.getSource("measure-label-source")&&a.value.removeSource("measure-label-source"))}p.onUnmounted(()=>{B(),E&&E(),a?.value&&(a.value?.removeControl(h),a.value?.off("draw.create",u),a.value?.off("click",C),a.value?.off("dblclick",f))});const O=p.ref(0),H=p.computed(()=>O.value<1?`${(O.value*1e3).toFixed(2)} 米`:`${O.value.toFixed(3)} 公里`),U=p.ref(0),Lt=p.computed(()=>U.value<1?`${(U.value*1e6).toFixed(2)} 平方米`:`${U.value.toFixed(3)} 平方公里`),Nt=p.computed(()=>l.value==="distance"?H.value:Lt.value),Pt=p.computed(()=>l.value==="distance"?"总长度: ":"总面积: ");return(M,m)=>(p.openBlock(),p.createElementBlock(p.Fragment,null,[s.value||r.value.length>0&&(n.value=="measure_distance"||n.value=="measure_area")?(p.openBlock(),p.createElementBlock("div",Vn,[p.createElementVNode("div",xn,[p.createElementVNode("span",Bn,p.toDisplayString(Pt.value),1),p.createElementVNode("span",Gn,p.toDisplayString(Nt.value),1),p.createVNode(p.unref(Rt.ElIcon),{style:{display:"block","margin-left":"10px",cursor:"pointer"},onClick:m[0]||(m[0]=V=>c("clear_all")),size:"20px"},{default:p.withCtx(()=>[p.createVNode(p.unref(wt.Close))]),_:1})])])):p.createCommentVNode("",!0),p.createElementVNode("div",$n,[e.tools.includes("point")?(p.openBlock(),p.createElementBlock("div",{key:0,title:"兴趣点",class:p.normalizeClass(["hiper-map-tools-btn",n.value=="point"?"active":null]),onClick:m[1]||(m[1]=()=>c("point"))},[...m[7]||(m[7]=[p.createElementVNode("span",{class:"qyuan icon-local-two"},null,-1)])],2)):p.createCommentVNode("",!0),e.tools.includes("line")?(p.openBlock(),p.createElementBlock("div",{key:1,title:"折线",class:p.normalizeClass(["hiper-map-tools-btn",n.value=="line"?"active":null]),onClick:m[2]||(m[2]=()=>c("line"))},[...m[8]||(m[8]=[p.createElementVNode("span",{class:"qyuan icon-whole-site-accelerator"},null,-1)])],2)):p.createCommentVNode("",!0),e.tools.includes("polygon")?(p.openBlock(),p.createElementBlock("div",{key:2,title:"多边形",class:p.normalizeClass(["hiper-map-tools-btn",n.value=="polygon"?"active":null]),onClick:m[3]||(m[3]=()=>c("polygon"))},[...m[9]||(m[9]=[p.createElementVNode("span",{class:"qyuan icon-anchor"},null,-1)])],2)):p.createCommentVNode("",!0),e.tools.includes("measure_distance")?(p.openBlock(),p.createElementBlock("div",{key:3,title:"测距",class:p.normalizeClass(["hiper-map-tools-btn",n.value=="measure_distance"?"active":null]),onClick:m[4]||(m[4]=()=>c("measure_distance"))},[...m[10]||(m[10]=[p.createElementVNode("span",{class:"qyuan icon-ruler"},null,-1)])],2)):p.createCommentVNode("",!0),e.tools.includes("measure_area")?(p.openBlock(),p.createElementBlock("div",{key:4,title:"测面",class:p.normalizeClass(["hiper-map-tools-btn",n.value=="measure_area"?"active":null]),onClick:m[5]||(m[5]=()=>c("measure_area"))},[...m[11]||(m[11]=[p.createElementVNode("span",{class:"qyuan icon-multi-triangular"},null,-1)])],2)):p.createCommentVNode("",!0),e.tools.includes("clear_all")?(p.openBlock(),p.createElementBlock("div",{key:5,title:"清除所有临时绘制图形",class:"hiper-map-tools-btn",style:{border:"none"},onClick:m[6]||(m[6]=()=>c("clear_all"))},[...m[12]||(m[12]=[p.createElementVNode("span",{class:"qyuan icon-clear"},null,-1)])])):p.createCommentVNode("",!0)])],64))}});exports._sfc_main=qn;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),se=require("../chunks/imageReview.vue_vue_type_style_index_0_lang-BrTPEr6_.js"),ce=require("../chunks/CreateData.vue_vue_type_script_setup_true_lang-DZJuz1uU.js"),de=require("./SortItem.cjs"),pe=require("../chunks/ReplaceSpeciesNameDialog.vue_vue_type_script_setup_true_lang-Crqsopo0.js"),fe=require("./FilterItem.cjs"),ye=require("../chunks/RenderFormItem.vue_vue_type_style_index_0_lang-aDfb1v1D.js"),he=require("../chunks/RenderFilterItem.vue_vue_type_script_setup_true_lang-Db7eSKlY.js"),q=require("../chunks/utils-DdJHKOsc.js"),n=require("element-plus"),v=require("@element-plus/icons-vue"),y=require("../chunks/ProvideKeys-BPenLFlD.js"),ve=require("../chunks/EventKeys-D78tN5KT.js"),ge=require("vuedraggable"),me=require("../chunks/_plugin-vue_export-helper-BHFhmbuH.js"),ke={class:"manage-table"},xe={class:"table-header"},Ce={class:"left"},Ee={class:"field-sort",style:{height:"50vh","min-height":"400px",overflow:"auto"}},Ve={class:"field-sort-header"},we={class:"menus-popover-sort"},Ne={class:"el-button el-button--primary is-plain",type:"primary",role:"button",style:{"border-radius":"var(--el-border-radius-base)",width:"95px"}},be={class:"right"},Be={class:"select_input_wrapper"},Fe={style:{width:"150px"}},De={class:"table-body"},Te={key:4,class:"latin-name"},Re=e.defineComponent({name:"ManageTable",__name:"manageTable",props:{fieldList:{},buildThumbUrl:{type:Function},onSortChange:{type:Function},saveData:{type:Function},records:{},dataType:{},category:{},layerName:{},projectId:{},researchStandard:{},customFields:{default:()=>[]},uploadFile:{type:Function},exportHandel:{type:Function},rowDataOptions:{type:Function},researchDataOptions:{type:Function},queryResearchDataOptions:{type:Function},deleteResearchDataOptions:{type:Function},deleteRowDataOptions:{type:Function},researchDataQuery:{type:Function},showMap:{type:Function}},setup(l,{expose:I}){const B=e.ref(!1);var x=e.ref({});const h=e.ref(""),m=e.ref({}),F=e.ref(),D=e.ref(),p=e.ref([]),s=e.ref([]),T=e.useTemplateRef("dataTableRef"),g=e.ref(!1),k=e.reactive({rowID:null,index:null}),L=()=>{l.showMap?l.showMap(e.toRaw(i.value)):n.ElMessage.warning("暂不支持地图查看")},H=(a,r,t,d)=>{g.value&&(k.rowID=a.id,k.index=r.getColumnIndex())},i=e.ref([]),K=a=>{i.value=a},R=e.computed(()=>[...p.value.map(a=>a.property),...s.value]),U=a=>{if(R.value.indexOf(a.property)>-1)return!0;if(!a.property&&a.propertyGroup)return R.value.indexOf(a.propertyGroup.join("_"))>-1},z=e.computed(()=>{const a=[];return u.value.forEach(r=>{r.property?s.value.indexOf(r.property)>-1&&a.push(r):r.propertyGroup&&s.value.indexOf(r.propertyGroup.join("_"))>-1&&a.push(r)}),[...p.value,...a]}),$=a=>a.unit?`${a.title}(${a.unit})`:a.title,A=(a,r)=>{if(a.extra)try{return JSON.parse(a.extra)[r]}catch{return""}return""},P=()=>{l.exportHandel?l.exportHandel(JSON.parse(JSON.stringify(i.value))):n.ElMessage.warning("暂不支持导出")},Q=a=>{try{F.value?.open(JSON.parse(a))}catch{}},J=a=>a.id;l.uploadFile&&e.provide(y.uploadFileKey,l.uploadFile),l.rowDataOptions&&e.provide(y.apiRowDataOptionsKey,l.rowDataOptions),l.researchDataOptions&&e.provide(y.apiResearchDataOptionsKey,l.researchDataOptions),l.queryResearchDataOptions&&e.provide(y.queryResearchDataOptionsKey,l.queryResearchDataOptions),e.provide(y.projectIdKey,l.projectId),e.provide(y.researchStandardKey,l.researchStandard),l.researchDataQuery&&e.provide(y.apiResearchDataQueryKey,l.researchDataQuery);const W=()=>{l.dataType=="row-data"?D.value?.showDialog(l.category,l.layerName):n.ElMessage.warning("暂不支持新增")},X=()=>{S()},S=()=>{console.log("filterForm.value",m.value),ve.filterEventBus.emit(m.value)},Y=()=>{if(i.value.length==0){n.ElMessage.warning("请先选择数据");return}var a=l.dataType=="row-data"?l.deleteRowDataOptions:l.deleteResearchDataOptions;a?n.ElMessageBox.confirm(`是否要删除这${i.value.length}条调查数据?`,"提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(()=>{a&&a({ids:i.value.map(r=>r.id)}).then(r=>{let t=0,d=new Set,o=0;Object.entries(r.data).forEach(([Oe,b])=>{(b.ykk_code||b.code)!=1e4?(t++,d.add(b.msg)):o++});let c=[];o>0&&c.push(`成功删除${o}条`),t>0&&(c.push(`失败${t}条`),c.push("失败原因:"+Array.from(d).join(",")+"。")),n.ElNotification({title:"提示",message:"共选择"+i.value.length+"条数据,"+c.join(","),type:"warning"})})}).catch(()=>{}):n.ElMessage.warning("暂不支持删除")},Z=()=>{if(l.dataType=="row-data"){if(["soilResearchCollect","waterResearchCollect","plantResearchCollect","fungusResearchCollect"].indexOf(l.category)>-1){n.ElMessage.warning("暂不支持复制");return}if(i.value.length==0){n.ElMessage.warning("请先选择数据");return}var a=l.dataType=="row-data"?l.rowDataOptions:l.researchDataOptions;a?n.ElMessageBox.confirm(`是否要复制这${i.value.length}条调查数据?`,"提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(async()=>{B.value=!0;for(let r=0;r<i.value.length;r++){const t=Object.assign({},i.value[r]);delete t.id,t.createDate=n.dayjs().unix(),a&&await a([t])}B.value=!1,n.ElMessage.success("复制成功")}).catch(()=>{}):n.ElMessage.warning("暂不支持复制")}else n.ElMessage.warning("暂不支持复制")},O=e.ref(),_=()=>{if(["vegetationResearchCollect","humanActivity","naturalDisaster"].indexOf(l.category)>-1){n.ElMessage.warning("暂不支持替换");return}if(i.value.length==0){n.ElMessage.warning("请先选择数据");return}if(l.dataType=="row-data"){O.value?.showDialog(l.category,i.value);return}else{n.ElMessage.warning("暂不支持替换");return}},j=e.ref(),ee=()=>{j.value?.showDialog(l.fieldList.filter(a=>a.sortAble),"createDate")},C=e.ref([]),te=a=>{if(a.length==0){C.value=[];return}else C.value=a},E=e.ref(),re=()=>{E.value?.showDialog(l.fieldList.filter(a=>a.filterAble))},ae=a=>{x.value=a},V=e.ref(!0),M=e.ref(!1),w=e.ref(!1),u=e.ref([]),le=a=>{if(a){const r=u.value.map(t=>t.property?t.property:t.propertyGroup?t.propertyGroup.join("_"):"xxx");r&&r.length>0&&(s.value=r)}else{const r=u.value.filter(t=>t.fixed).map(t=>t.property?t.property:t.propertyGroup?t.propertyGroup.join("_"):"xxx");s.value=r,G(s.value)}w.value=!1},G=a=>{let r=[];u.value.forEach(t=>{t.property?r.push({filedName:t.property,check:a.indexOf(t.property)!=-1}):r.push({filedName:(t.propertyGroup??[]).join("_"),check:a.indexOf((t.propertyGroup??[]).join("_"))!=-1})})},ne=a=>{const r=a.length;V.value=r===u.value.length,w.value=r>0&&r<u.value.length,G(a)},f=e.ref([]),oe=a=>{p.value.length=0,u.value.length=0,f.value.length=0,a.forEach(r=>{r?.fixed?p.value.push(r):u.value.push(r),r?.isQuickFilter&&f.value.push(r)}),console.log("quickFilterFields.value",f.value),f.value.length>0?h.value=f.value[0].property:h.value="",s.value=u.value.filter(r=>r.isShow&&!r.fixed).map(r=>r.property||(r.propertyGroup?r.propertyGroup.join("_"):""))},N=e.ref([]),ie=()=>{let a=[];u.value.forEach(r=>{a.push({filedName:r.property,check:s.value.indexOf(r.property)!=-1})})};e.watchEffect(()=>{console.log("customFields",l.customFields),oe(q.mergeCustomFormSubTable(l.fieldList,l.customFields,l.dataType))});const ue=()=>{i.value.length=0,T.value?.clearSelection()};return e.watch(()=>l.fieldList,a=>{ue(),E.value?.resetForm(),C.value=[],u.value=a.filter(t=>t.isShow&&!t.fixed).map(t=>({...t,property:t.property||(t.propertyGroup?t.propertyGroup.join("_"):"")}));const r=a.map(t=>t.property?t.property:t.propertyGroup?t.propertyGroup.join("_"):"");r&&r.length>0&&(s.value=r),console.log("displayFieldList.value",u.value),p.value=a.filter(t=>t.fixed).map(t=>({...t,property:t.property||(t.propertyGroup?t.propertyGroup.join("_"):"")})),console.log("fixedFieldList.value",p.value)},{immediate:!0}),e.watch(()=>l.customFields,()=>{l.customFields.forEach(a=>{a.fields.forEach(r=>{r.type=="custom"&&N.value.push(r.property)})}),console.log("allCustomField.value",N.value)},{immediate:!0}),I({showFields:s,fixedFieldList:p}),(a,r)=>(e.openBlock(),e.createElementBlock("div",ke,[e.createElementVNode("div",xe,[e.createElementVNode("div",Ce,[e.createVNode(e.unref(n.ElButton),{type:"primary",plain:"",onClick:P},{default:e.withCtx(()=>[...r[8]||(r[8]=[e.createElementVNode("i",{class:"icon bjh-export"},null,-1),e.createTextVNode("导出",-1)])]),_:1}),l.category!="photoResearch"?(e.openBlock(),e.createBlock(e.unref(n.ElButton),{key:0,type:"primary",plain:"",onClick:W},{default:e.withCtx(()=>[...r[9]||(r[9]=[e.createElementVNode("i",{class:"icon bjh-add"},null,-1),e.createTextVNode("增加 ",-1)])]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(n.ElButton),{type:"primary",plain:"",onClick:Y},{default:e.withCtx(()=>[...r[10]||(r[10]=[e.createElementVNode("i",{class:"icon bjh-delete"},null,-1),e.createTextVNode("删除",-1)])]),_:1}),e.createVNode(e.unref(n.ElButton),{type:"primary",plain:"",onClick:Z},{default:e.withCtx(()=>[...r[11]||(r[11]=[e.createElementVNode("i",{class:"icon bjh-copy"},null,-1),e.createTextVNode("复制",-1)])]),_:1}),e.createVNode(e.unref(n.ElButton),{type:"primary",plain:"",onClick:_},{default:e.withCtx(()=>[...r[12]||(r[12]=[e.createElementVNode("i",{class:"icon bjh-replace"},null,-1),e.createTextVNode("替换",-1)])]),_:1}),e.createVNode(e.unref(n.ElButton),{type:"primary",plain:"",onClick:ee},{default:e.withCtx(()=>[...r[13]||(r[13]=[e.createElementVNode("i",{class:"icon bjh-paixu2 active"},null,-1),e.createTextVNode("排序 ",-1)])]),_:1}),e.createVNode(e.unref(n.ElButton),{type:"primary",plain:"",onClick:re},{default:e.withCtx(()=>[e.createElementVNode("i",{class:e.normalizeClass(["icon",{"bjh-shaixuan2":Object.keys(e.unref(x)).length==0,"bjh-shaixuan1 active":Object.keys(e.unref(x)).length>0}])},null,2),r[14]||(r[14]=e.createTextVNode("筛选 ",-1))]),_:1}),e.createVNode(e.unref(n.ElPopover),{placement:"bottom",width:225,trigger:"click"},{reference:e.withCtx(()=>[e.createVNode(e.unref(n.ElButton),{size:"default",type:"primary",plain:"",style:{width:"95px"}},{default:e.withCtx(()=>[r[15]||(r[15]=e.createElementVNode("i",{class:"icon bjh-display"},null,-1)),r[16]||(r[16]=e.createTextVNode("显示",-1)),e.createVNode(e.unref(n.ElIcon),null,{default:e.withCtx(()=>[e.createVNode(e.unref(v.CaretBottom))]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",Ee,[e.createElementVNode("div",Ve,[e.createVNode(e.unref(n.ElCheckbox),{modelValue:V.value,"onUpdate:modelValue":r[0]||(r[0]=t=>V.value=t),indeterminate:w.value,onChange:le},{default:e.withCtx(()=>[...r[17]||(r[17]=[e.createTextVNode("全选",-1)])]),_:1},8,["modelValue","indeterminate"])]),e.createVNode(e.unref(n.ElCheckboxGroup),{modelValue:s.value,"onUpdate:modelValue":r[4]||(r[4]=t=>s.value=t),onChange:ne},{default:e.withCtx(()=>[e.createVNode(e.unref(ge),{modelValue:u.value,"onUpdate:modelValue":r[1]||(r[1]=t=>u.value=t),onStart:r[2]||(r[2]=t=>M.value=!0),onEnd:r[3]||(r[3]=t=>M.value=!1),"item-key":"title",onChange:ie,animation:400,"fallback-tolerance":100,"scroll-sensitivity":100},{item:e.withCtx(({element:t})=>[e.createElementVNode("div",we,[r[18]||(r[18]=e.createElementVNode("span",{class:"icon bjh-ketuodong"},null,-1)),t.property?(e.openBlock(),e.createBlock(e.unref(n.ElCheckbox),{key:0,value:t.property},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.title),1)]),_:2},1032,["value"])):(e.openBlock(),e.createBlock(e.unref(n.ElCheckbox),{key:1,value:t.propertyGroup.join("_")},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.title),1)]),_:2},1032,["value"]))])]),_:1},8,["modelValue"])]),_:1},8,["modelValue"])])]),_:1}),e.createElementVNode("label",Ne,[r[19]||(r[19]=e.createTextVNode(" 编辑 ",-1)),e.createVNode(e.unref(n.ElSwitch),{size:"small",modelValue:g.value,"onUpdate:modelValue":r[5]||(r[5]=t=>g.value=t)},null,8,["modelValue"])])]),e.createElementVNode("div",be,[e.createVNode(e.unref(n.ElButton),{onClick:L,type:"primary",plain:""},{default:e.withCtx(()=>[...r[20]||(r[20]=[e.createElementVNode("i",{class:"icon bjh-mapView"},null,-1),e.createTextVNode(" 地图查看",-1)])]),_:1}),e.createElementVNode("div",Be,[e.createVNode(e.unref(n.ElSelect),{modelValue:h.value,"onUpdate:modelValue":r[6]||(r[6]=t=>h.value=t),placeholder:"请选择筛选项",style:{width:"110px"}},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,t=>(e.openBlock(),e.createBlock(e.unref(n.ElOption),{label:t.title,value:t.property},null,8,["label","value"]))),256))]),_:1},8,["modelValue"]),e.createElementVNode("div",Fe,[(e.openBlock(),e.createBlock(he._sfc_main,{ref:"renderFilterRef",modelValue:m.value,"onUpdate:modelValue":r[7]||(r[7]=t=>m.value=t),field:f.value.find(t=>t.property==h.value),key:h.value,onChange:X},null,8,["modelValue","field"]))]),e.createVNode(e.unref(n.ElButton),{icon:e.unref(v.Search),onClick:S,type:"primary",plain:""},null,8,["icon"])])])]),e.createElementVNode("div",De,[e.createVNode(e.unref(n.ElTable),{ref_key:"dataTableRef",ref:T,onSortChange:l.onSortChange,"header-row-class-name":"table-header",data:l.records,border:!0,stripe:"","row-key":J,style:{width:"100%",height:"100%"},onCellClick:H,onSelectionChange:K},{default:e.withCtx(()=>[e.createVNode(e.unref(n.ElTableColumn),{type:"selection",width:"55","reserve-selection":!0}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(z.value,(t,d)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:t.property},[U(t)?(e.openBlock(),e.createBlock(e.unref(n.ElTableColumn),{key:0,fixed:t.fixed,sortable:t.sortAble,prop:t.property,label:$(t),width:t.width||150},{default:e.withCtx(({row:o})=>[g.value&&k.rowID===o.id&&k.index===d+1&&!t.disable?(e.openBlock(),e.createBlock(ye._sfc_main,{key:t.title+"-"+o.id,field:t,data:o,onChange:c=>l.saveData(c,o,t)},null,8,["field","data","onChange"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[N.value.indexOf(t.property)!==-1?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(A(o,t.property)),1)],64)):t.property==="imageList"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[o[t.property]&&o[t.property].length>10?(e.openBlock(),e.createBlock(e.unref(n.ElIcon),{key:0,size:"20",onClick:c=>g.value?null:Q(o[t.property]),color:"green"},{default:e.withCtx(()=>[e.createVNode(e.unref(v.Picture))]),_:1},8,["onClick"])):(e.openBlock(),e.createBlock(e.unref(n.ElIcon),{key:1,size:"20"},{default:e.withCtx(()=>[e.createVNode(e.unref(v.CirclePlus))]),_:1}))],64)):t.property==="voiceList"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[o[t.property]&&o[t.property].length>10?(e.openBlock(),e.createBlock(e.unref(n.ElIcon),{key:0,size:"20",color:"green"},{default:e.withCtx(()=>[...r[21]||(r[21]=[e.createElementVNode("i",{class:"icon bjh-audio_ico02"},null,-1)])]),_:1})):(e.openBlock(),e.createBlock(e.unref(n.ElIcon),{key:1,size:"20"},{default:e.withCtx(()=>[e.createVNode(e.unref(v.CirclePlus))]),_:1}))],64)):t.property==="quadratChart"?(e.openBlock(),e.createBlock(e.unref(n.ElIcon),{key:3,size:"20"},{default:e.withCtx(()=>[e.createVNode(e.unref(v.Calendar))]),_:1})):t.property==="latinName"?(e.openBlock(),e.createElementBlock("p",Te,e.toDisplayString(o[t.property]),1)):t.property==="previewImage"?(e.openBlock(),e.createBlock(e.unref(n.ElImage),{key:5,src:l.buildThumbUrl?l.buildThumbUrl(t.render?t.render(o[t.property],o,d):o[t.property]):"",fit:"cover","preview-src-list":[e.unref(q.buildOriginUrl)(t.render?t.render(o[t.property],o,d):o[t.property])],"preview-teleported":!0,lazy:!0,style:{width:"100px",height:"100px"}},null,8,["src","preview-src-list"])):t.propertyGroup?(e.openBlock(),e.createElementBlock(e.Fragment,{key:6},[e.createTextVNode(e.toDisplayString(t.propertyGroup.map(c=>o[c]).join("/")),1)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:7},[t.render?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(t.render(o[t.property],o,d)),1)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(o[t.property]),1)],64))],64))],64))]),_:2},1032,["fixed","sortable","prop","label","width"])):e.createCommentVNode("",!0)],64))),128))]),_:1},8,["onSortChange","data"])]),e.createVNode(se._sfc_main,{ref_key:"imageTagRef",ref:F},null,512),e.createVNode(ce._sfc_main,{ref_key:"createDataRef",ref:D},null,512),e.createVNode(pe._sfc_main,{ref_key:"replaceSpeciesNameDialogRef",ref:O},null,512),e.createVNode(de.default,{ref_key:"sortRef",ref:j,onCallback:te},null,512),e.createVNode(fe.default,{ref_key:"filterRef",ref:E,onCallback:ae},null,512)]))}}),Se=me._export_sfc(Re,[["__scopeId","data-v-3926206b"]]);exports.default=Se;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),se=require("../chunks/imageReview.vue_vue_type_style_index_0_lang-BrTPEr6_.js"),ce=require("../chunks/CreateData.vue_vue_type_script_setup_true_lang-DZJuz1uU.js"),de=require("./SortItem.cjs"),pe=require("../chunks/ReplaceSpeciesNameDialog.vue_vue_type_script_setup_true_lang-Crqsopo0.js"),fe=require("./FilterItem.cjs"),ye=require("../chunks/RenderFormItem.vue_vue_type_style_index_0_lang-aDfb1v1D.js"),he=require("../chunks/RenderFilterItem.vue_vue_type_script_setup_true_lang-Db7eSKlY.js"),q=require("../chunks/utils-DdJHKOsc.js"),n=require("element-plus"),v=require("@element-plus/icons-vue"),y=require("../chunks/ProvideKeys-BPenLFlD.js"),ve=require("../chunks/EventKeys-D78tN5KT.js"),ge=require("vuedraggable"),me=require("../chunks/_plugin-vue_export-helper-BHFhmbuH.js"),ke={class:"manage-table"},xe={class:"table-header"},Ce={class:"left"},Ee={class:"field-sort",style:{height:"50vh","min-height":"400px",overflow:"auto"}},Ve={class:"field-sort-header"},we={class:"menus-popover-sort"},Ne={class:"el-button el-button--primary is-plain",type:"primary",role:"button",style:{"border-radius":"var(--el-border-radius-base)",width:"95px"}},be={class:"right"},Be={class:"select_input_wrapper"},Fe={style:{width:"150px"}},De={class:"table-body"},Te={key:4,class:"latin-name"},Se=e.defineComponent({name:"ManageTable",__name:"manageTable",props:{fieldList:{},buildThumbUrl:{type:Function},onSortChange:{type:Function},saveData:{type:Function},records:{},dataType:{},category:{},layerName:{},projectId:{},researchStandard:{},customFields:{default:()=>[]},uploadFile:{type:Function},exportHandel:{type:Function},rowDataOptions:{type:Function},researchDataOptions:{type:Function},queryResearchDataOptions:{type:Function},deleteResearchDataOptions:{type:Function},deleteRowDataOptions:{type:Function},researchDataQuery:{type:Function},showMap:{type:Function}},setup(l,{expose:I}){const B=e.ref(!1);var x=e.ref({});const h=e.ref(""),m=e.ref({}),F=e.ref(),D=e.ref(),p=e.ref([]),s=e.ref([]),T=e.useTemplateRef("dataTableRef"),g=e.ref(!1),k=e.reactive({rowID:null,index:null}),L=()=>{l.showMap?l.showMap(e.toRaw(i.value)):n.ElMessage.warning("暂不支持地图查看")},H=(a,r,t,d)=>{g.value&&(k.rowID=a.id,k.index=r.getColumnIndex())},i=e.ref([]),K=a=>{i.value=a},S=e.computed(()=>[...p.value.map(a=>a.property),...s.value]),U=a=>{if(S.value.indexOf(a.property)>-1)return!0;if(!a.property&&a.propertyGroup)return S.value.indexOf(a.propertyGroup.join("_"))>-1},$=e.computed(()=>{const a=[];return u.value.forEach(r=>{r.property?s.value.indexOf(r.property)>-1&&a.push(r):r.propertyGroup&&s.value.indexOf(r.propertyGroup.join("_"))>-1&&a.push(r)}),[...p.value,...a]}),z=a=>a.unit?`${a.title}(${a.unit})`:a.title,A=(a,r)=>{if(a.extra)try{return JSON.parse(a.extra)[r]}catch{return""}return""},P=()=>{l.exportHandel?l.exportHandel(JSON.parse(JSON.stringify(i.value))):n.ElMessage.warning("暂不支持导出")},Q=a=>{try{F.value?.open(JSON.parse(a))}catch{}},J=a=>a.id;l.uploadFile&&e.provide(y.uploadFileKey,l.uploadFile),l.rowDataOptions&&e.provide(y.apiRowDataOptionsKey,l.rowDataOptions),l.researchDataOptions&&e.provide(y.apiResearchDataOptionsKey,l.researchDataOptions),l.queryResearchDataOptions&&e.provide(y.queryResearchDataOptionsKey,l.queryResearchDataOptions),e.provide(y.projectIdKey,l.projectId),e.provide(y.researchStandardKey,l.researchStandard),l.researchDataQuery&&e.provide(y.apiResearchDataQueryKey,l.researchDataQuery);const W=()=>{l.dataType=="row-data"?D.value?.showDialog(l.category,l.layerName):n.ElMessage.warning("暂不支持新增")},X=()=>{R()},R=()=>{console.log("filterForm.value",m.value),ve.filterEventBus.emit(m.value)},Y=()=>{if(i.value.length==0){n.ElMessage.warning("请先选择数据");return}var a=l.dataType=="row-data"?l.deleteRowDataOptions:l.deleteResearchDataOptions;a?n.ElMessageBox.confirm(`是否要删除这${i.value.length}条调查数据?`,"提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(()=>{a&&a({ids:i.value.map(r=>r.id)}).then(r=>{let t=0,d=new Set,o=0;Object.entries(r.data).forEach(([Oe,b])=>{(b.ykk_code||b.code)!=1e4?(t++,d.add(b.msg)):o++});let c=[];o>0&&c.push(`成功删除${o}条`),t>0&&(c.push(`失败${t}条`),c.push("失败原因:"+Array.from(d).join(",")+"。")),n.ElNotification({title:"提示",message:"共选择"+i.value.length+"条数据,"+c.join(","),type:"warning"})})}).catch(()=>{}):n.ElMessage.warning("暂不支持删除")},Z=()=>{if(l.dataType=="row-data"){if(["soilResearchCollect","waterResearchCollect","plantResearchCollect","fungusResearchCollect"].indexOf(l.category)>-1){n.ElMessage.warning("暂不支持复制");return}if(i.value.length==0){n.ElMessage.warning("请先选择数据");return}var a=l.dataType=="row-data"?l.rowDataOptions:l.researchDataOptions;a?n.ElMessageBox.confirm(`是否要复制这${i.value.length}条调查数据?`,"提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(async()=>{B.value=!0;for(let r=0;r<i.value.length;r++){const t=Object.assign({},i.value[r]);delete t.id,t.createDate=n.dayjs().unix(),a&&await a([t])}B.value=!1,n.ElMessage.success("复制成功")}).catch(()=>{}):n.ElMessage.warning("暂不支持复制")}else n.ElMessage.warning("暂不支持复制")},O=e.ref(),_=()=>{if(["vegetationResearchCollect","humanActivity","naturalDisaster"].indexOf(l.category)>-1){n.ElMessage.warning("暂不支持替换");return}if(i.value.length==0){n.ElMessage.warning("请先选择数据");return}if(l.dataType=="row-data"){O.value?.showDialog(l.category,i.value);return}else{n.ElMessage.warning("暂不支持替换");return}},j=e.ref(),ee=()=>{j.value?.showDialog(l.fieldList.filter(a=>a.sortAble),"createDate")},C=e.ref([]),te=a=>{if(a.length==0){C.value=[];return}else C.value=a},E=e.ref(),re=()=>{E.value?.showDialog(l.fieldList.filter(a=>a.filterAble))},ae=a=>{x.value=a},V=e.ref(!0),M=e.ref(!1),w=e.ref(!1),u=e.ref([]),le=a=>{if(a){const r=u.value.map(t=>t.property?t.property:t.propertyGroup?t.propertyGroup.join("_"):"xxx");r&&r.length>0&&(s.value=r)}else{const r=u.value.filter(t=>t.fixed).map(t=>t.property?t.property:t.propertyGroup?t.propertyGroup.join("_"):"xxx");s.value=r,G(s.value)}w.value=!1},G=a=>{let r=[];u.value.forEach(t=>{t.property?r.push({filedName:t.property,check:a.indexOf(t.property)!=-1}):r.push({filedName:(t.propertyGroup??[]).join("_"),check:a.indexOf((t.propertyGroup??[]).join("_"))!=-1})})},ne=a=>{const r=a.length;V.value=r===u.value.length,w.value=r>0&&r<u.value.length,G(a)},f=e.ref([]),oe=a=>{p.value.length=0,u.value.length=0,f.value.length=0,a.forEach(r=>{r?.fixed?p.value.push(r):u.value.push(r),r?.isQuickFilter&&f.value.push(r)}),console.log("quickFilterFields.value",f.value),f.value.length>0?h.value=f.value[0].property:h.value="",s.value=u.value.filter(r=>r.isShow&&!r.fixed).map(r=>r.property||(r.propertyGroup?r.propertyGroup.join("_"):""))},N=e.ref([]),ie=()=>{let a=[];u.value.forEach(r=>{a.push({filedName:r.property,check:s.value.indexOf(r.property)!=-1})})};e.watchEffect(()=>{console.log("customFields",l.customFields),oe(q.mergeCustomFormSubTable(l.fieldList,l.customFields,l.dataType))});const ue=()=>{i.value.length=0,T.value?.clearSelection()};return e.watch(()=>l.fieldList,a=>{ue(),E.value?.resetForm(),C.value=[],u.value=a.filter(t=>t.isShow&&!t.fixed).map(t=>({...t,property:t.property||(t.propertyGroup?t.propertyGroup.join("_"):"")}));const r=a.map(t=>t.property?t.property:t.propertyGroup?t.propertyGroup.join("_"):"");r&&r.length>0&&(s.value=r),console.log("displayFieldList.value",u.value),p.value=a.filter(t=>t.fixed).map(t=>({...t,property:t.property||(t.propertyGroup?t.propertyGroup.join("_"):"")})),console.log("fixedFieldList.value",p.value)},{immediate:!0}),e.watch(()=>l.customFields,()=>{l.customFields.forEach(a=>{a.fields.forEach(r=>{r.type=="custom"&&N.value.push(r.property)})}),console.log("allCustomField.value",N.value)},{immediate:!0}),I({showFields:s,fixedFieldList:p}),(a,r)=>(e.openBlock(),e.createElementBlock("div",ke,[e.createElementVNode("div",xe,[e.createElementVNode("div",Ce,[e.createVNode(e.unref(n.ElButton),{type:"primary",plain:"",onClick:P},{default:e.withCtx(()=>[...r[8]||(r[8]=[e.createElementVNode("i",{class:"icon bjh-export"},null,-1),e.createTextVNode("导出",-1)])]),_:1}),l.category!="photoResearch"?(e.openBlock(),e.createBlock(e.unref(n.ElButton),{key:0,type:"primary",plain:"",onClick:W},{default:e.withCtx(()=>[...r[9]||(r[9]=[e.createElementVNode("i",{class:"icon bjh-add"},null,-1),e.createTextVNode("增加 ",-1)])]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(n.ElButton),{type:"primary",plain:"",onClick:Y},{default:e.withCtx(()=>[...r[10]||(r[10]=[e.createElementVNode("i",{class:"icon bjh-delete"},null,-1),e.createTextVNode("删除",-1)])]),_:1}),e.createVNode(e.unref(n.ElButton),{type:"primary",plain:"",onClick:Z},{default:e.withCtx(()=>[...r[11]||(r[11]=[e.createElementVNode("i",{class:"icon bjh-copy"},null,-1),e.createTextVNode("复制",-1)])]),_:1}),e.createVNode(e.unref(n.ElButton),{type:"primary",plain:"",onClick:_},{default:e.withCtx(()=>[...r[12]||(r[12]=[e.createElementVNode("i",{class:"icon bjh-replace"},null,-1),e.createTextVNode("替换",-1)])]),_:1}),e.createVNode(e.unref(n.ElButton),{type:"primary",plain:"",onClick:ee},{default:e.withCtx(()=>[...r[13]||(r[13]=[e.createElementVNode("i",{class:"icon bjh-paixu2 active"},null,-1),e.createTextVNode("排序 ",-1)])]),_:1}),e.createVNode(e.unref(n.ElButton),{type:"primary",plain:"",onClick:re},{default:e.withCtx(()=>[e.createElementVNode("i",{class:e.normalizeClass(["icon",{"bjh-shaixuan2":Object.keys(e.unref(x)).length==0,"bjh-shaixuan1 active":Object.keys(e.unref(x)).length>0}])},null,2),r[14]||(r[14]=e.createTextVNode("筛选 ",-1))]),_:1}),e.createVNode(e.unref(n.ElPopover),{placement:"bottom",width:225,trigger:"click"},{reference:e.withCtx(()=>[e.createVNode(e.unref(n.ElButton),{size:"default",type:"primary",plain:"",style:{width:"95px"}},{default:e.withCtx(()=>[r[15]||(r[15]=e.createElementVNode("i",{class:"icon bjh-display"},null,-1)),r[16]||(r[16]=e.createTextVNode("显示",-1)),e.createVNode(e.unref(n.ElIcon),null,{default:e.withCtx(()=>[e.createVNode(e.unref(v.CaretBottom))]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",Ee,[e.createElementVNode("div",Ve,[e.createVNode(e.unref(n.ElCheckbox),{modelValue:V.value,"onUpdate:modelValue":r[0]||(r[0]=t=>V.value=t),indeterminate:w.value,onChange:le},{default:e.withCtx(()=>[...r[17]||(r[17]=[e.createTextVNode("全选",-1)])]),_:1},8,["modelValue","indeterminate"])]),e.createVNode(e.unref(n.ElCheckboxGroup),{modelValue:s.value,"onUpdate:modelValue":r[4]||(r[4]=t=>s.value=t),onChange:ne},{default:e.withCtx(()=>[e.createVNode(e.unref(ge),{modelValue:u.value,"onUpdate:modelValue":r[1]||(r[1]=t=>u.value=t),onStart:r[2]||(r[2]=t=>M.value=!0),onEnd:r[3]||(r[3]=t=>M.value=!1),"item-key":"title",onChange:ie,animation:400,"fallback-tolerance":100,"scroll-sensitivity":100},{item:e.withCtx(({element:t})=>[e.createElementVNode("div",we,[r[18]||(r[18]=e.createElementVNode("span",{class:"icon bjh-ketuodong"},null,-1)),t.property?(e.openBlock(),e.createBlock(e.unref(n.ElCheckbox),{key:0,value:t.property},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.title),1)]),_:2},1032,["value"])):(e.openBlock(),e.createBlock(e.unref(n.ElCheckbox),{key:1,value:t.propertyGroup.join("_")},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.title),1)]),_:2},1032,["value"]))])]),_:1},8,["modelValue"])]),_:1},8,["modelValue"])])]),_:1}),e.createElementVNode("label",Ne,[r[19]||(r[19]=e.createTextVNode(" 编辑 ",-1)),e.createVNode(e.unref(n.ElSwitch),{size:"small",modelValue:g.value,"onUpdate:modelValue":r[5]||(r[5]=t=>g.value=t)},null,8,["modelValue"])])]),e.createElementVNode("div",be,[e.createVNode(e.unref(n.ElButton),{onClick:L,type:"primary",plain:""},{default:e.withCtx(()=>[...r[20]||(r[20]=[e.createElementVNode("i",{class:"icon bjh-mapView"},null,-1),e.createTextVNode(" 地图查看",-1)])]),_:1}),e.createElementVNode("div",Be,[e.createVNode(e.unref(n.ElSelect),{modelValue:h.value,"onUpdate:modelValue":r[6]||(r[6]=t=>h.value=t),placeholder:"请选择筛选项",style:{width:"110px"}},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,t=>(e.openBlock(),e.createBlock(e.unref(n.ElOption),{label:t.title,value:t.property},null,8,["label","value"]))),256))]),_:1},8,["modelValue"]),e.createElementVNode("div",Fe,[(e.openBlock(),e.createBlock(he._sfc_main,{ref:"renderFilterRef",modelValue:m.value,"onUpdate:modelValue":r[7]||(r[7]=t=>m.value=t),field:f.value.find(t=>t.property==h.value),key:h.value,onChange:X},null,8,["modelValue","field"]))]),e.createVNode(e.unref(n.ElButton),{icon:e.unref(v.Search),onClick:R,type:"primary",plain:""},null,8,["icon"])])])]),e.createElementVNode("div",De,[e.createVNode(e.unref(n.ElTable),{ref_key:"dataTableRef",ref:T,onSortChange:l.onSortChange,"header-row-class-name":"table-header",data:l.records,border:!0,stripe:"","row-key":J,style:{width:"100%",height:"100%"},onCellClick:H,onSelectionChange:K},{default:e.withCtx(()=>[e.createVNode(e.unref(n.ElTableColumn),{type:"selection",width:"55","reserve-selection":!0}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList($.value,(t,d)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:t.property},[U(t)?(e.openBlock(),e.createBlock(e.unref(n.ElTableColumn),{key:0,fixed:t.fixed,sortable:t.sortAble,prop:t.property,label:z(t),width:t.width||150},{default:e.withCtx(({row:o})=>[g.value&&k.rowID===o.id&&k.index===d+1&&!t.disable?(e.openBlock(),e.createBlock(ye._sfc_main,{key:t.title+"-"+o.id,field:t,data:o,onChange:c=>l.saveData(c,o,t)},null,8,["field","data","onChange"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[N.value.indexOf(t.property)!==-1?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(A(o,t.property)),1)],64)):t.property==="imageList"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[o[t.property]&&o[t.property].length>10?(e.openBlock(),e.createBlock(e.unref(n.ElIcon),{key:0,size:"20",onClick:c=>g.value?null:Q(o[t.property]),color:"green"},{default:e.withCtx(()=>[e.createVNode(e.unref(v.Picture))]),_:1},8,["onClick"])):(e.openBlock(),e.createBlock(e.unref(n.ElIcon),{key:1,size:"20"},{default:e.withCtx(()=>[e.createVNode(e.unref(v.CirclePlus))]),_:1}))],64)):t.property==="voiceList"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[o[t.property]&&o[t.property].length>10?(e.openBlock(),e.createBlock(e.unref(n.ElIcon),{key:0,size:"20",color:"green"},{default:e.withCtx(()=>[...r[21]||(r[21]=[e.createElementVNode("i",{class:"icon bjh-audio_ico02"},null,-1)])]),_:1})):(e.openBlock(),e.createBlock(e.unref(n.ElIcon),{key:1,size:"20"},{default:e.withCtx(()=>[e.createVNode(e.unref(v.CirclePlus))]),_:1}))],64)):t.property==="quadratChart"?(e.openBlock(),e.createBlock(e.unref(n.ElIcon),{key:3,size:"20"},{default:e.withCtx(()=>[e.createVNode(e.unref(v.Calendar))]),_:1})):t.property==="latinName"?(e.openBlock(),e.createElementBlock("p",Te,e.toDisplayString(o[t.property]),1)):t.property==="previewImage"?(e.openBlock(),e.createBlock(e.unref(n.ElImage),{key:5,src:l.buildThumbUrl?l.buildThumbUrl(t.render?t.render(o[t.property],o,d):o[t.property]):"",fit:"cover","preview-src-list":[e.unref(q.buildOriginUrl)(t.render?t.render(o[t.property],o,d):o[t.property])],"preview-teleported":!0,lazy:!0,style:{width:"100px",height:"100px"}},null,8,["src","preview-src-list"])):t.propertyGroup?(e.openBlock(),e.createElementBlock(e.Fragment,{key:6},[e.createTextVNode(e.toDisplayString(t.propertyGroup.map(c=>o[c]).join("/")),1)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:7},[t.render?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(t.render(o[t.property],o,d)),1)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(o[t.property]),1)],64))],64))],64))]),_:2},1032,["fixed","sortable","prop","label","width"])):e.createCommentVNode("",!0)],64))),128)),e.renderSlot(a.$slots,"column-extra",{},void 0,!0)]),_:3},8,["onSortChange","data"])]),e.createVNode(se._sfc_main,{ref_key:"imageTagRef",ref:F},null,512),e.createVNode(ce._sfc_main,{ref_key:"createDataRef",ref:D},null,512),e.createVNode(pe._sfc_main,{ref_key:"replaceSpeciesNameDialogRef",ref:O},null,512),e.createVNode(de.default,{ref_key:"sortRef",ref:j,onCallback:te},null,512),e.createVNode(fe.default,{ref_key:"filterRef",ref:E,onCallback:ae},null,512)]))}}),Re=me._export_sfc(Se,[["__scopeId","data-v-2f1a0351"]]);exports.default=Re;