@qaecy/cue-ui 0.0.46 → 0.0.48
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.
- package/36.js +1 -1
- package/396.js +1 -0
- package/399.js +1 -1
- package/4.js +1 -1
- package/560.js +1 -1
- package/613.js +1 -1
- package/7.js +1 -1
- package/719.js +1 -1
- package/724.js +1 -1
- package/773.js +1 -0
- package/791.js +1 -1
- package/799.js +1 -1
- package/839.js +1 -0
- package/855.js +1 -0
- package/872.js +1 -1
- package/879.js +1 -1
- package/911.js +1 -1
- package/931.js +1 -1
- package/944.js +1 -0
- package/README.md +49 -50
- package/common.js +1 -1
- package/index.js +1 -1
- package/main.js +1 -1
- package/package.json +1 -1
- package/styles.css +1 -1
- package/673.js +0 -1
- package/882.js +0 -1
- package/981.js +0 -1
package/872.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[872],{503(ae,Q,c){var O=c(6119);function D(b){var v=0;if(b&&b.length>0){v+=Math.abs(z(b[0]));for(var R=1;R<b.length;R++)v-=Math.abs(z(b[R]))}return v}function z(b){var v,R,p,a,h,C,F=0,B=b.length;if(B>2){for(C=0;C<B;C++)C===B-2?(p=B-2,a=B-1,h=0):C===B-1?(p=B-1,a=0,h=1):(p=C,a=C+1,h=C+2),v=b[p],R=b[a],F+=(s(b[h][0])-s(v[0]))*Math.sin(s(R[1]));F=F*O.RADIUS*O.RADIUS/2}return F}function s(b){return b*Math.PI/180}ae.exports.geometry=function m(b){var R,v=0;switch(b.type){case"Polygon":return D(b.coordinates);case"MultiPolygon":for(R=0;R<b.coordinates.length;R++)v+=D(b.coordinates[R]);return v;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(R=0;R<b.geometries.length;R++)v+=m(b.geometries[R]);return v}},ae.exports.ring=z},5341(ae){ae.exports=function c(O){if(!O||!O.type)return null;var m=Q[O.type];return m?"geometry"===m?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:O}]}:"feature"===m?{type:"FeatureCollection",features:[O]}:"featurecollection"===m?O:void 0:null};var Q={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"}},6756(ae,Q,c){"use strict";c.d(Q,{BK:()=>O,In:()=>S,Kz:()=>p,Mc:()=>h,U6:()=>D,g0:()=>C,g8:()=>z,r:()=>m,u9:()=>b});const O=["#2B5DE6","#1A2B50","#C5E045","#6FA8FF","#00C2E0","#5847EB","#008585","#4ADE80","#0F4C81","#8B5CF6","#FACC15","#FB923C","#F43F5E","#E879F9","#D97706","#334155","#64748B","#94A3B8","#C7D2FE","#F8FAFC"];function m(E){switch(E){case"primary":default:return"#2859e1";case"accent":return"#e2f552";case"tertiary":return"#ffffff"}}function D(E){switch(E){case"primary":default:return"#1744c2";case"accent":return"#b8cc3f";case"tertiary":return"#eeeeee"}}function z(E){const[w,U,k]=function s(E,w){if(void 0===E)return[];const k=window.getComputedStyle(E.nativeElement);return w.map(X=>k.getPropertyValue(X).trim()||"")}(E,["--cue-chart-text-color","--cue-chart-border-background-color","--chart-graph-edge-color"]);return{text:w,borderBackground:U,edgeColor:k}}const b={fontFamily:"Poppins, sans-serif",fontWeight:"normal",color:"#333"};function S(E){return E>=1e6?`${(E/1e6).toFixed(1)}m`:E>=1e3?`${(E/1e3).toFixed(0)}k`:E.toString()}function p(E,w,U,k){if(1===k)return E;const X=F(E),f=F(w),L=U/(k-1);return`rgb(${Math.round(X.r+(f.r-X.r)*L)}, ${Math.round(X.g+(f.g-X.g)*L)}, ${Math.round(X.b+(f.b-X.b)*L)})`}const h=(E,w)=>void 0===w?E:w.children??[];function C(E,w,U=.05,k="Other"){const X=E.reduce((x,T)=>x+B(T),0),f=[],L=[];if(E.forEach(x=>{let T,A;T=void 0===x.value&&Array.isArray(x.children)&&x.children.length>0?x.children.reduce((Z,J)=>Z+B(J),0):void 0!==x.value?x.value:0,Array.isArray(x.children)&&x.children.length>0&&(A=C(x.children,w,U,k));const W={...x,value:T,children:A};w&&X>0&&T/X<U?L.push(W):f.push(W)}),w&&L.length>0){const x=L.reduce((T,A)=>T+A.value,0);f.push({id:"__grouped_small__",name:k,value:x,children:L,isGroup:!0})}return f}function F(E){const w=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(E);return w?{r:parseInt(w[1],16),g:parseInt(w[2],16),b:parseInt(w[3],16)}:{r:0,g:0,b:0}}function B(E){return"number"==typeof E.value?E.value:Array.isArray(E.children)&&E.children.length>0?E.children.reduce((w,U)=>w+B(U),0):0}},4853(ae,Q,c){"use strict";c.d(Q,{H:()=>E});var O=c(7705),m=c(5802),D=c(7089),z=c(7023),s=c(5381),b=c(5971),v=c(3319),R=c(356),S=c(6279),p=c(5547);const a=()=>({position:"bottomleft"}),h=(w,U)=>U.label||w;function C(w,U){if(1&w){const k=p.RV6();p.j41(0,"cue-menu-item",4),p.bIt("click",function(){const f=m.eBV(k).$implicit;return m.Njj(f.action())}),p.EFF(1),p.k0s()}if(2&w){const k=U.$implicit;p.Y8G("selected",k.selected),p.R7$(),p.JRh(k.label)}}function F(w,U){if(1&w&&(p.j41(0,"cue-menu-wrap"),p.Z7z(1,C,2,2,"cue-menu-item",3,h),p.k0s()),2&w){const k=p.XpG();p.R7$(),p.Dyx(k.contextMenuItems())}}function B(w,U){if(1&w){const k=p.RV6();p.j41(0,"cue-button",5),p.bIt("click",function(f){const L=m.eBV(k).$implicit,x=p.XpG();return m.Njj(x.handleClick(f,L))}),p.nrm(1,"cue-button-icon",6),p.k0s()}if(2&w){const k=U.$implicit,X=p.XpG(),f=p.sdS(1);p.Y8G("cueTooltip",k.label)("variant",k.variant?k.variant:X.variant())("size",X.size())("cueContextMenu",f)("contextMenuData",p.lJ4(7,a))("cueContextEnabled",void 0!==k.contextMenuItems&&k.contextMenuItems.length>0),p.R7$(),p.Y8G("icon",k.icon)}}let E=(()=>{class w{items=O.hFB.required();noGap=(0,O.hFB)(!0);direction=(0,O.hFB)("row");size=(0,O.hFB)("xs");variant=(0,O.hFB)("tertiary");mouseEnter=(0,O.CGW)();mouseLeave=(0,O.CGW)();contextMenuItems=(0,m.vPA)([]);handleClick(k,X){k.stopPropagation(),X.contextMenuItems&&X.contextMenuItems.length>0?this.contextMenuItems.set(X.contextMenuItems):X.action&&(this.contextMenuItems.set([]),X.action())}static \u0275fac=function(X){return new(X||w)};static \u0275cmp=p.VBU({type:w,selectors:[["cue-entity-menu"]],inputs:{items:[1,"items"],noGap:[1,"noGap"],direction:[1,"direction"],size:[1,"size"],variant:[1,"variant"]},outputs:{mouseEnter:"mouseEnter",mouseLeave:"mouseLeave"},decls:5,vars:2,consts:[["contextMenu",""],["gap","s","justify","end",2,"width","100%",3,"mouseenter","mouseleave","direction","noGap"],["trigger","leftclick",3,"cueTooltip","variant","size","cueContextMenu","contextMenuData","cueContextEnabled"],[3,"selected"],[3,"click","selected"],["trigger","leftclick",3,"click","cueTooltip","variant","size","cueContextMenu","contextMenuData","cueContextEnabled"],[3,"icon"]],template:function(X,f){1&X&&(p.DNE(0,F,3,0,"ng-template",null,0,p.C5r),p.j41(2,"cue-flexcontainer",1),p.bIt("mouseenter",function(){return f.mouseEnter.emit()})("mouseleave",function(){return f.mouseLeave.emit()}),p.Z7z(3,B,2,8,"cue-button",2,h),p.k0s()),2&X&&(p.R7$(2),p.Y8G("direction",f.direction())("noGap",f.noGap()),p.R7$(),p.Dyx(f.items()))},dependencies:[s.n,b.$,D.d,v.a,z.Q,R.M,S.D],encapsulation:2,changeDetection:0})}return w})()},1024(ae,Q,c){"use strict";c.d(Q,{p:()=>D});var O=c(5547);const m=["*"];let D=(()=>{class z{static \u0275fac=function(v){return new(v||z)};static \u0275cmp=O.VBU({type:z,selectors:[["cue-key-val-list"]],ngContentSelectors:m,decls:2,vars:0,consts:[[1,"key-val-list"]],template:function(v,R){1&v&&(O.NAR(),O.rj2(0,"div",0),O.SdG(1),O.eux())},styles:[".key-val-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:var(--cue-grid-gap-s)}"]})}return z})()},9421(ae,Q,c){"use strict";c.d(Q,{F:()=>v});var O=c(7705),m=c(5802),D=c(2271),z=c(7335),s=c(2245),b=c(5547);let v=(()=>{class R{entityMenuDirective;size=(0,O.hFB)("m");key=O.hFB.required();val=O.geq.required();options=(0,O.hFB)([]);suffix=(0,O.hFB)("");valueChange=(0,O.CGW)();editModeEnabled=(0,m.vPA)(!1);valueChanged=(0,D.EW)(()=>this.val()!==this.newValue());newValue=(0,D.uu)(()=>this.val());labelSize=(0,D.EW)(()=>{switch(this.size()){case"s":return"xs";case"m":return"s";case"l":return"m";case"xl":return"l"}});onKeyPress(p){this.editModeEnabled()&&("Escape"===p.key?(this._reset(),p.stopPropagation()):"Enter"===p.key&&this._emitChange())}saveCancelMenu=(0,D.EW)(()=>{const p=[{icon:"close",label:"Cancel",action:()=>this._reset()}];return this.valueChanged()&&p.push({icon:"save",label:"Save",action:()=>this._emitChange()}),p});selectionChange(p){this.newValue.set(p?.toString()??"")}inputChange(p){this.newValue.set(p)}_emitChange(){this.valueChange.emit(this.newValue()),this.val.set(this.newValue()),this.editModeEnabled.set(!1)}_reset(){this.newValue.set(this.val()),this.editModeEnabled.set(!1)}static \u0275fac=function(a){return new(a||R)};static \u0275cmp=b.VBU({type:R,selectors:[["cue-key-val"]],viewQuery:function(a,h){if(1&a&&b.GBs(z.e,5),2&a){let C;b.mGM(C=b.lsd())&&(h.entityMenuDirective=C.first)}},hostBindings:function(a,h){1&a&&b.bIt("keydown",function(F){return h.onKeyPress(F)},b.EBC)},inputs:{size:[1,"size"],key:[1,"key"],val:[1,"val"],options:[1,"options"],suffix:[1,"suffix"]},outputs:{val:"valChange",valueChange:"valueChange"},decls:8,vars:5,consts:[[1,"key-val-container"],[3,"size"],[1,"value-content"]],template:function(a,h){1&a&&(b.j41(0,"dl",0)(1,"dt")(2,"cue-typography",1),b.EFF(3),b.k0s()(),b.j41(4,"dd")(5,"cue-typography",1)(6,"span",2),b.EFF(7),b.k0s()()()()),2&a&&(b.R7$(2),b.Y8G("size",h.labelSize()),b.R7$(),b.JRh(h.key()),b.R7$(2),b.Y8G("size",h.size()),b.R7$(2),b.Lme("",h.val()," ",h.suffix()))},dependencies:[s.Typography],styles:[".key-val-container[_ngcontent-%COMP%]{margin:0;display:flex;flex-direction:column;gap:var(--cue-grid-gap-s, 8px)}dt[_ngcontent-%COMP%], dd[_ngcontent-%COMP%]{margin:0}.read-mode-container[_ngcontent-%COMP%]{display:inline-flex;align-items:center;width:100%;position:relative}.read-mode-container.interactive[_ngcontent-%COMP%]:hover{cursor:pointer}.value-content[_ngcontent-%COMP%]{flex:1}[_nghost-%COMP%]{color:var(--cue-typography-text-color, inherit)}dt[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%], dd[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%], .value-content[_ngcontent-%COMP%]{color:var(--cue-typography-text-color, inherit)!important}dt[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%] div[_ngcontent-%COMP%], dd[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%] div[_ngcontent-%COMP%]{color:var(--cue-typography-text-color, inherit)!important}[_ngcontent-%COMP%]:deep(cue-svg-icon), [_ngcontent-%COMP%]:deep(cue-entity-menu cue-svg-icon){color:var(--cue-icon-color, inherit)!important}.dirty-indicator[_ngcontent-%COMP%]{opacity:.8;margin-left:4px;color:var(--cue-typography-text-color, inherit)!important;font-weight:700;font-size:.4em;transform:translateY(-1em)}"]})}return R})()},7517(ae,Q,c){"use strict";c.d(Q,{P:()=>C});var O=c(7705),m=c(2271),D=c(2245),z=c(1359),s=c(5381),b=c(5547),v=c(5802);const R=(F,B)=>B.category;function S(F,B){if(1&F){const E=b.RV6();b.j41(0,"cue-flexcontainer",1)(1,"cue-checkbox",2),b.bIt("checkedChange",function(){v.eBV(E);const U=b.XpG();return v.Njj(U.toggleAll())}),b.k0s()()}if(2&F){const E=b.XpG();b.R7$(),b.Y8G("checked",E.allVisible())}}function p(F,B){if(1&F&&(b.j41(0,"cue-typography",3),b.EFF(1),b.k0s()),2&F){const E=b.XpG().$implicit;b.R7$(),b.JRh(E.category)}}function a(F,B){if(1&F){const E=b.RV6();b.j41(0,"cue-flexcontainer",1)(1,"cue-checkbox",4),b.bIt("checkedChange",function(){const U=v.eBV(E).$implicit,k=b.XpG(2);return v.Njj(k.toggleSingle(U))}),b.k0s(),b.j41(2,"cue-typography",5),b.bIt("click",function(){const U=v.eBV(E).$implicit,k=b.XpG(2);return v.Njj(k.toggleSingle(U))}),b.EFF(3),b.k0s()()}if(2&F){const E=B.$implicit;b.R7$(),b.Y8G("checked",E.visible)("color",E.color),b.R7$(2),b.JRh(E.label)}}function h(F,B){if(1&F&&(b.nVh(0,p,2,1,"cue-typography",3),b.Z7z(1,a,4,3,"cue-flexcontainer",1,b.Vm6)),2&F){const E=B.$implicit;b.vxM(E.category?0:-1),b.R7$(),b.Dyx(E.items)}}let C=(()=>{class F{layers=(0,O.geq)([]);visibilityChange=(0,O.CGW)();layerChange=(0,O.CGW)();visibilityAll=(0,O.CGW)();showCheckAll=(0,m.EW)(()=>this.layers().length>1);allVisible=(0,m.EW)(()=>this.layers().every(E=>E.visible));groupedLayers=(0,m.EW)(()=>{const E=[];for(const w of this.layers()){const U=w.category,k=E.find(X=>X.category===U);k?k.items.push(w):E.push({category:U,items:[w]})}return E});toggleAll(){const E=this.allVisible(),w=this.layers().map(U=>(U.visible=!E,U));this.layers.update(()=>[...w]),this.visibilityAll.emit(E),this.emitChange()}toggleSingle(E){E.visible=!E.visible,this.layerChange.emit(E),this.layers.update(()=>[...this.layers()]),this.emitChange()}emitChange(){this.visibilityChange.emit(this.layers())}static \u0275fac=function(w){return new(w||F)};static \u0275cmp=b.VBU({type:F,selectors:[["cue-layer-legend"]],inputs:{layers:[1,"layers"]},outputs:{layers:"layersChange",visibilityChange:"visibilityChange",layerChange:"layerChange",visibilityAll:"visibilityAll"},decls:4,vars:1,consts:[["direction","column"],["align","center","justify","start",2,"width","100%"],["size","s",3,"checkedChange","checked"],["variant","label",2,"margin-top","4px","opacity","0.6"],["size","s",3,"checkedChange","checked","color"],[2,"cursor","pointer",3,"click"]],template:function(w,U){1&w&&(b.j41(0,"cue-flexcontainer",0),b.nVh(1,S,2,1,"cue-flexcontainer",1),b.Z7z(2,h,3,1,null,null,R),b.k0s()),2&w&&(b.R7$(),b.vxM(U.showCheckAll()?1:-1),b.R7$(),b.Dyx(U.groupedLayers()))},dependencies:[s.n,D.Typography,z.S],encapsulation:2,changeDetection:0})}return F})()},2843(ae,Q,c){"use strict";c.d(Q,{M:()=>Wn});var O={};c.r(O),c.d(O,{LAT_MAX:()=>U,LAT_MIN:()=>E,LAT_RENDERED_MAX:()=>k,LAT_RENDERED_MIN:()=>w,LNG_MAX:()=>f,LNG_MIN:()=>X,activeStates:()=>F,classes:()=>s,cursors:()=>v,events:()=>a,geojsonTypes:()=>S,interactions:()=>B,meta:()=>C,modes:()=>p,sources:()=>b,types:()=>R,updateActions:()=>h});var m={};c.r(m),c.d(m,{isActiveFeature:()=>T,isBackspaceKey:()=>he,isDeleteKey:()=>me,isDigit1Key:()=>ne,isDigit2Key:()=>ze,isDigit3Key:()=>De,isDigitKey:()=>ve,isEnterKey:()=>fe,isEscapeKey:()=>ye,isFeature:()=>Z,isInactiveFeature:()=>A,isOfMetaType:()=>L,isShiftDown:()=>oe,isShiftMousedown:()=>x,isTrue:()=>ct,isVertex:()=>J,noTarget:()=>W});var D={};c.r(D),c.d(D,{CommonSelectors:()=>m,ModeHandler:()=>nt,StringSet:()=>Ae,constrainFeatureMovement:()=>At,createMidPoint:()=>nn,createSupplementaryPoints:()=>wt,createVertex:()=>Ze,doubleClickZoom:()=>Ie,euclideanDistance:()=>qe,featuresAt:()=>Be,getFeatureAtAndSetCursors:()=>Xe,isClick:()=>et,isEventAtCoordinates:()=>mt,isTap:()=>tt,mapEventToBoundingBox:()=>He,moveFeatures:()=>Nt,sortFeatures:()=>dt,stringSetsAreEqual:()=>pn,theme:()=>Gt,toDenseArray:()=>pe});var z=c(5802);const s={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"},b={HOT:"mapbox-gl-draw-hot",COLD:"mapbox-gl-draw-cold"},v={ADD:"add",MOVE:"move",DRAG:"drag",POINTER:"pointer",NONE:"none"},R={POLYGON:"polygon",LINE:"line_string",POINT:"point"},S={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"},p={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select"},a={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"},h={MOVE:"move",CHANGE_PROPERTIES:"change_properties",CHANGE_COORDINATES:"change_coordinates"},C={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},F={ACTIVE:"true",INACTIVE:"false"},B=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],E=-90,w=-85,U=90,k=85,X=-270,f=270;function L(e){return function(t){const n=t.featureTarget;return!(!n||!n.properties)&&n.properties.meta===e}}function x(e){return!(!e.originalEvent||!e.originalEvent.shiftKey)&&0===e.originalEvent.button}function T(e){return!(!e.featureTarget||!e.featureTarget.properties)&&e.featureTarget.properties.active===F.ACTIVE&&e.featureTarget.properties.meta===C.FEATURE}function A(e){return!(!e.featureTarget||!e.featureTarget.properties)&&e.featureTarget.properties.active===F.INACTIVE&&e.featureTarget.properties.meta===C.FEATURE}function W(e){return void 0===e.featureTarget}function Z(e){return!(!e.featureTarget||!e.featureTarget.properties)&&e.featureTarget.properties.meta===C.FEATURE}function J(e){const t=e.featureTarget;return!(!t||!t.properties)&&t.properties.meta===C.VERTEX}function oe(e){return!!e.originalEvent&&!0===e.originalEvent.shiftKey}function ye(e){return"Escape"===e.key||27===e.keyCode}function fe(e){return"Enter"===e.key||13===e.keyCode}function he(e){return"Backspace"===e.key||8===e.keyCode}function me(e){return"Delete"===e.key||46===e.keyCode}function ne(e){return"1"===e.key||49===e.keyCode}function ze(e){return"2"===e.key||50===e.keyCode}function De(e){return"3"===e.key||51===e.keyCode}function ve(e){const t=e.key||String.fromCharCode(e.keyCode);return t>="0"&&t<="9"}function ct(){return!0}var Ke=c(503);const we={Point:0,LineString:1,MultiLineString:1,Polygon:2};function ut(e,t){const n=we[e.geometry.type]-we[t.geometry.type];return 0===n&&e.geometry.type===S.POLYGON?e.area-t.area:n}const dt=function _t(e){return e.map(t=>(t.geometry.type===S.POLYGON&&(t.area=Ke.geometry({type:S.FEATURE,property:{},geometry:t.geometry})),t)).sort(ut).map(t=>(delete t.area,t))},He=function je(e,t=0){return[[e.point.x-t,e.point.y-t],[e.point.x+t,e.point.y+t]]};function Re(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]),void 0!==e[t]&&("string"==typeof e[t]?this._items[e[t]]=t:this._nums[e[t]]=t)}Re.prototype.add=function(e){return this.has(e)||(this._length++,"string"==typeof e?this._items[e]=this._length:this._nums[e]=this._length),this},Re.prototype.delete=function(e){return!1===this.has(e)||(this._length--,delete this._items[e],delete this._nums[e]),this},Re.prototype.has=function(e){return!("string"!=typeof e&&"number"!=typeof e||void 0===this._items[e]&&void 0===this._nums[e])},Re.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)},Re.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};const Ae=Re,Qe=[C.FEATURE,C.MIDPOINT,C.VERTEX],Be={click:function vt(e,t,n){return ft(e,t,n,n.options.clickBuffer)},touch:function bt(e,t,n){return ft(e,t,n,n.options.touchBuffer)}};function ft(e,t,n,o){if(null===n.map)return[];const r=e?He(e,o):t,i={};n.options.styles&&(i.layers=n.options.styles.map(N=>N.id).filter(N=>null!=n.map.getLayer(N)));const d=n.map.queryRenderedFeatures(r,i).filter(N=>-1!==Qe.indexOf(N.properties.meta)),M=new Ae,g=[];return d.forEach(N=>{const K=N.properties.id;M.has(K)||(M.add(K),g.push(N))}),dt(g)}function Xe(e,t){const n=Be.click(e,null,t),o={mouse:v.NONE};return n[0]&&(o.mouse=n[0].properties.active===F.ACTIVE?v.MOVE:v.POINTER,o.feature=n[0].properties.meta),-1!==t.events.currentModeName().indexOf("draw")&&(o.mouse=v.ADD),t.ui.queueMapClasses(o),t.ui.updateMapClasses(),n[0]}function qe(e,t){const n=e.x-t.x,o=e.y-t.y;return Math.sqrt(n*n+o*o)}function et(e,t,n={}){const o=null!=n.fineTolerance?n.fineTolerance:4,r=null!=n.grossTolerance?n.grossTolerance:12,i=null!=n.interval?n.interval:500;e.point=e.point||t.point,e.time=e.time||t.time;const d=qe(e.point,t.point);return d<o||d<r&&t.time-e.time<i}function tt(e,t,n={}){const o=null!=n.tolerance?n.tolerance:25,r=null!=n.interval?n.interval:250;return e.point=e.point||t.point,e.time=e.time||t.time,qe(e.point,t.point)<o&&t.time-e.time<r}const nt=function(e,t){const n={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},o={on(i,d,M){if(void 0===n[i])throw new Error(`Invalid event type: ${i}`);n[i].push({selector:d,fn:M})},render(i){t.store.featureChanged(i)}},r=function(i,d){const M=n[i];let g=M.length;for(;g--;){const N=M[g];if(N.selector(d)){N.fn.call(o,d)||t.store.render(),t.ui.updateMapClasses();break}}};return e.start.call(o),{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){r("drag",i)},click(i){r("click",i)},mousemove(i){r("mousemove",i)},mousedown(i){r("mousedown",i)},mouseup(i){r("mouseup",i)},mouseout(i){r("mouseout",i)},keydown(i){r("keydown",i)},keyup(i){r("keyup",i)},touchstart(i){r("touchstart",i)},touchmove(i){r("touchmove",i)},touchend(i){r("touchend",i)},tap(i){r("tap",i)}}},I=((e,t=21)=>(n=t)=>{let o="",r=0|n;for(;r--;)o+=e[Math.random()*e.length|0];return o})("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",32);function l(){return I()}const u=function(e,t){this.ctx=e,this.properties=t.properties||{},this.coordinates=t.geometry.coordinates,this.id=t.id||l(),this.type=t.geometry.type};u.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},u.prototype.incomingCoords=function(e){this.setCoordinates(e)},u.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},u.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},u.prototype.setProperty=function(e,t){this.properties[e]=t},u.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:S.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},u.prototype.internal=function(e){const t={id:this.id,meta:C.FEATURE,"meta:type":this.type,active:F.INACTIVE,mode:e};if(this.ctx.options.userProperties)for(const n in this.properties)t[`user_${n}`]=this.properties[n];return{type:S.FEATURE,properties:t,geometry:{coordinates:this.getCoordinates(),type:this.type}}};const _=u,V=function(e,t){_.call(this,e,t)};(V.prototype=Object.create(_.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},V.prototype.updateCoordinate=function(e,t,n){this.coordinates=3===arguments.length?[t,n]:[e,t],this.changed()},V.prototype.getCoordinate=function(){return this.getCoordinates()};const Y=V,q=function(e,t){_.call(this,e,t)};(q.prototype=Object.create(_.prototype)).isValid=function(){return this.coordinates.length>1},q.prototype.addCoordinate=function(e,t,n){this.changed();const o=parseInt(e,10);this.coordinates.splice(o,0,[t,n])},q.prototype.getCoordinate=function(e){const t=parseInt(e,10);return JSON.parse(JSON.stringify(this.coordinates[t]))},q.prototype.removeCoordinate=function(e){this.changed(),this.coordinates.splice(parseInt(e,10),1)},q.prototype.updateCoordinate=function(e,t,n){const o=parseInt(e,10);this.coordinates[o]=[t,n],this.changed()};const le=q,ge=function(e,t){_.call(this,e,t),this.coordinates=this.coordinates.map(n=>n.slice(0,-1))};(ge.prototype=Object.create(_.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every(e=>e.length>2)},ge.prototype.incomingCoords=function(e){this.coordinates=e.map(t=>t.slice(0,-1)),this.changed()},ge.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},ge.prototype.addCoordinate=function(e,t,n){this.changed();const o=e.split(".").map(i=>parseInt(i,10));this.coordinates[o[0]].splice(o[1],0,[t,n])},ge.prototype.removeCoordinate=function(e){this.changed();const t=e.split(".").map(o=>parseInt(o,10)),n=this.coordinates[t[0]];n&&(n.splice(t[1],1),n.length<3&&this.coordinates.splice(t[0],1))},ge.prototype.getCoordinate=function(e){const t=e.split(".").map(o=>parseInt(o,10));return JSON.parse(JSON.stringify(this.coordinates[t[0]][t[1]]))},ge.prototype.getCoordinates=function(){return this.coordinates.map(e=>e.concat([e[0]]))},ge.prototype.updateCoordinate=function(e,t,n){this.changed();const o=e.split("."),r=parseInt(o[0],10),i=parseInt(o[1],10);void 0===this.coordinates[r]&&(this.coordinates[r]=[]),this.coordinates[r][i]=[t,n]};const se=ge,de={MultiPoint:Y,MultiLineString:le,MultiPolygon:se},_e=(e,t,n,o,r)=>{const i=n.split("."),d=parseInt(i[0],10),M=i[1]?i.slice(1).join("."):null;return e[d][t](M,o,r)},Ee=function(e,t){if(_.call(this,e,t),delete this.coordinates,this.model=de[t.geometry.type],void 0===this.model)throw new TypeError(`${t.geometry.type} is not a valid type`);this.features=this._coordinatesToFeatures(t.geometry.coordinates)};(Ee.prototype=Object.create(_.prototype))._coordinatesToFeatures=function(e){const t=this.model.bind(this);return e.map(n=>new t(this.ctx,{id:l(),type:S.FEATURE,properties:{},geometry:{coordinates:n,type:this.type.replace("Multi","")}}))},Ee.prototype.isValid=function(){return this.features.every(e=>e.isValid())},Ee.prototype.setCoordinates=function(e){this.features=this._coordinatesToFeatures(e),this.changed()},Ee.prototype.getCoordinate=function(e){return _e(this.features,"getCoordinate",e)},Ee.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(e=>e.type===S.POLYGON?e.getCoordinates():e.coordinates)))},Ee.prototype.updateCoordinate=function(e,t,n){_e(this.features,"updateCoordinate",e,t,n),this.changed()},Ee.prototype.addCoordinate=function(e,t,n){_e(this.features,"addCoordinate",e,t,n),this.changed()},Ee.prototype.removeCoordinate=function(e){_e(this.features,"removeCoordinate",e),this.changed()},Ee.prototype.getFeatures=function(){return this.features};const Ne=Ee;function H(e){this.map=e.map,this.drawConfig=JSON.parse(JSON.stringify(e.options||{})),this._ctx=e}H.prototype.setSelected=function(e){return this._ctx.store.setSelected(e)},H.prototype.setSelectedCoordinates=function(e){this._ctx.store.setSelectedCoordinates(e),e.reduce((t,n)=>(void 0===t[n.feature_id]&&(t[n.feature_id]=!0,this._ctx.store.get(n.feature_id).changed()),t),{})},H.prototype.getSelected=function(){return this._ctx.store.getSelected()},H.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},H.prototype.isSelected=function(e){return this._ctx.store.isSelected(e)},H.prototype.getFeature=function(e){return this._ctx.store.get(e)},H.prototype.select=function(e){return this._ctx.store.select(e)},H.prototype.deselect=function(e){return this._ctx.store.deselect(e)},H.prototype.deleteFeature=function(e,t={}){return this._ctx.store.delete(e,t)},H.prototype.addFeature=function(e,t={}){return this._ctx.store.add(e,t)},H.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},H.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},H.prototype.setActionableState=function(e={}){return this._ctx.events.actionable({trash:e.trash||!1,combineFeatures:e.combineFeatures||!1,uncombineFeatures:e.uncombineFeatures||!1})},H.prototype.changeMode=function(e,t={},n={}){return this._ctx.events.changeMode(e,t,n)},H.prototype.fire=function(e,t){return this._ctx.events.fire(e,t)},H.prototype.updateUIClasses=function(e){return this._ctx.ui.queueMapClasses(e)},H.prototype.activateUIButton=function(e){return this._ctx.ui.setActiveButton(e)},H.prototype.featuresAt=function(e,t,n="click"){if("click"!==n&&"touch"!==n)throw new Error("invalid buffer type");return Be[n](e,t,this._ctx)},H.prototype.newFeature=function(e){const t=e.geometry.type;return t===S.POINT?new Y(this._ctx,e):t===S.LINE_STRING?new le(this._ctx,e):t===S.POLYGON?new se(this._ctx,e):new Ne(this._ctx,e)},H.prototype.isInstanceOf=function(e,t){if(e===S.POINT)return t instanceof Y;if(e===S.LINE_STRING)return t instanceof le;if(e===S.POLYGON)return t instanceof se;if("MultiFeature"===e)return t instanceof Ne;throw new Error(`Unknown feature class: ${e}`)},H.prototype.doRender=function(e){return this._ctx.store.featureChanged(e)};const ee=H;H.prototype.onSetup=function(){},H.prototype.onDrag=function(){},H.prototype.onClick=function(){},H.prototype.onMouseMove=function(){},H.prototype.onMouseDown=function(){},H.prototype.onMouseUp=function(){},H.prototype.onMouseOut=function(){},H.prototype.onKeyUp=function(){},H.prototype.onKeyDown=function(){},H.prototype.onTouchStart=function(){},H.prototype.onTouchMove=function(){},H.prototype.onTouchEnd=function(){},H.prototype.onTap=function(){},H.prototype.onStop=function(){},H.prototype.onTrash=function(){},H.prototype.onCombineFeature=function(){},H.prototype.onUncombineFeature=function(){},H.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};const re={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},be=Object.keys(re);const pe=function Me(e){return[].concat(e).filter(t=>void 0!==t)};function ot(){const e=this;if(!e.ctx.map||void 0===e.ctx.map.getSource(b.HOT))return g();const n=e.ctx.events.currentModeName();e.ctx.ui.queueMapClasses({mode:n});let o=[],r=[];e.isDirty?r=e.getAllIds():(o=e.getChangedIds().filter(N=>void 0!==e.get(N)),r=e.sources.hot.filter(N=>N.properties.id&&-1===o.indexOf(N.properties.id)&&void 0!==e.get(N.properties.id)).map(N=>N.properties.id)),e.sources.hot=[];const i=e.sources.cold.length;e.sources.cold=e.isDirty?[]:e.sources.cold.filter(N=>-1===o.indexOf(N.properties.id||N.properties.parent));const d=i!==e.sources.cold.length||r.length>0;function M(N,K){const P=e.get(N).internal(n);e.ctx.events.currentModeRender(P,G=>{G.properties.mode=n,e.sources[K].push(G)})}function g(){e.isDirty=!1,e.clearChangedIds()}o.forEach(N=>M(N,"hot")),r.forEach(N=>M(N,"cold")),d&&e.ctx.map.getSource(b.COLD).setData({type:S.FEATURE_COLLECTION,features:e.sources.cold}),e.ctx.map.getSource(b.HOT).setData({type:S.FEATURE_COLLECTION,features:e.sources.hot}),g()}function ie(e){let t;this._features={},this._featureIds=new Ae,this._selectedFeatureIds=new Ae,this._selectedCoordinates=[],this._changedFeatureIds=new Ae,this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=e,this.sources={hot:[],cold:[]},this.render=()=>{t||(t=requestAnimationFrame(()=>{t=null,ot.call(this),this._emitSelectionChange&&(this.ctx.events.fire(a.SELECTION_CHANGE,{features:this.getSelected().map(n=>n.toGeoJSON()),points:this.getSelectedCoordinates().map(n=>({type:S.FEATURE,properties:{},geometry:{type:S.POINT,coordinates:n.coordinates}}))}),this._emitSelectionChange=!1),this.ctx.events.fire(a.RENDER,{})}))},this.isDirty=!1}function rt(e,t={}){const n=e._selectedCoordinates.filter(o=>e._selectedFeatureIds.has(o.feature_id));e._selectedCoordinates.length!==n.length&&!t.silent&&(e._emitSelectionChange=!0),e._selectedCoordinates=n}ie.prototype.createRenderBatch=function(){const e=this.render;let t=0;return this.render=function(){t++},()=>{this.render=e,t>0&&this.render()}},ie.prototype.setDirty=function(){return this.isDirty=!0,this},ie.prototype.featureCreated=function(e,t={}){if(this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)){const o=this.get(e);this.ctx.events.fire(a.CREATE,{features:[o.toGeoJSON()]})}return this},ie.prototype.featureChanged=function(e,t={}){return this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)&&this.ctx.events.fire(a.UPDATE,{action:t.action?t.action:h.CHANGE_COORDINATES,features:[this.get(e).toGeoJSON()]}),this},ie.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},ie.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},ie.prototype.getAllIds=function(){return this._featureIds.values()},ie.prototype.add=function(e,t={}){return this._features[e.id]=e,this._featureIds.add(e.id),this.featureCreated(e.id,{silent:t.silent}),this},ie.prototype.delete=function(e,t={}){const n=[];return pe(e).forEach(o=>{this._featureIds.has(o)&&(this._featureIds.delete(o),this._selectedFeatureIds.delete(o),t.silent||-1===n.indexOf(this._features[o])&&n.push(this._features[o].toGeoJSON()),delete this._features[o],this.isDirty=!0)}),n.length&&this.ctx.events.fire(a.DELETE,{features:n}),rt(this,t),this},ie.prototype.get=function(e){return this._features[e]},ie.prototype.getAll=function(){return Object.keys(this._features).map(e=>this._features[e])},ie.prototype.select=function(e,t={}){return pe(e).forEach(n=>{this._selectedFeatureIds.has(n)||(this._selectedFeatureIds.add(n),this._changedFeatureIds.add(n),t.silent||(this._emitSelectionChange=!0))}),this},ie.prototype.deselect=function(e,t={}){return pe(e).forEach(n=>{this._selectedFeatureIds.has(n)&&(this._selectedFeatureIds.delete(n),this._changedFeatureIds.add(n),t.silent||(this._emitSelectionChange=!0))}),rt(this,t),this},ie.prototype.clearSelected=function(e={}){return this.deselect(this._selectedFeatureIds.values(),{silent:e.silent}),this},ie.prototype.setSelected=function(e,t={}){return e=pe(e),this.deselect(this._selectedFeatureIds.values().filter(n=>-1===e.indexOf(n)),{silent:t.silent}),this.select(e.filter(n=>!this._selectedFeatureIds.has(n)),{silent:t.silent}),this},ie.prototype.setSelectedCoordinates=function(e){return this._selectedCoordinates=e,this._emitSelectionChange=!0,this},ie.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},ie.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},ie.prototype.getSelected=function(){return this.getSelectedIds().map(e=>this.get(e))},ie.prototype.getSelectedCoordinates=function(){return this._selectedCoordinates.map(t=>({coordinates:this.get(t.feature_id).getCoordinate(t.coord_path)}))},ie.prototype.isSelected=function(e){return this._selectedFeatureIds.has(e)},ie.prototype.setFeatureProperty=function(e,t,n,o={}){this.get(e).setProperty(t,n),this.featureChanged(e,{silent:o.silent,action:h.CHANGE_PROPERTIES})},ie.prototype.storeMapConfig=function(){B.forEach(e=>{this.ctx.map[e]&&(this._mapInitialConfig[e]=this.ctx.map[e].isEnabled())})},ie.prototype.restoreMapConfig=function(){Object.keys(this._mapInitialConfig).forEach(e=>{this._mapInitialConfig[e]?this.ctx.map[e].enable():this.ctx.map[e].disable()})},ie.prototype.getInitialConfigValue=function(e){return void 0===this._mapInitialConfig[e]||this._mapInitialConfig[e]};const it=["mode","feature","mouse"];function Bt(e){let t=null,n=null;const o={onRemove(){return e.map.off("load",o.connect),clearInterval(n),o.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",o.connect),clearInterval(n),o.addLayers(),e.store.storeMapConfig(),e.events.addEventListeners()},onAdd(r){if(e.map=r,e.events=function ke(e){const t=Object.keys(e.options.modes).reduce((P,G)=>(P[G]=function Se(e){const t=Object.keys(e);return function(n,o={}){let r={};const i=t.reduce((M,g)=>(M[g]=e[g],M),new ee(n));return{start(){r=i.onSetup(o),be.forEach(M=>{const g=re[M];let N=()=>!1;e[g]&&(N=()=>!0),this.on(M,N,function d(M){return g=>i[M](r,g)}(g))})},stop(){i.onStop(r)},trash(){i.onTrash(r)},combineFeatures(){i.onCombineFeatures(r)},uncombineFeatures(){i.onUncombineFeatures(r)},render(M,g){i.toDisplayFeatures(r,M,g)}}}}(e.options.modes[G]),P),{});let n={},o={};const r={};let i=null,d=null;r.drag=function(P,G){G({point:P.point,time:(new Date).getTime()})?(e.ui.queueMapClasses({mouse:v.DRAG}),d.drag(P)):P.originalEvent.stopPropagation()},r.mousedrag=function(P){r.drag(P,G=>!et(n,G))},r.touchdrag=function(P){r.drag(P,G=>!tt(o,G))},r.mousemove=function(P){if(1===(void 0!==P.originalEvent.buttons?P.originalEvent.buttons:P.originalEvent.which))return r.mousedrag(P);const $=Xe(P,e);P.featureTarget=$,d.mousemove(P)},r.mousedown=function(P){n={time:(new Date).getTime(),point:P.point};const G=Xe(P,e);P.featureTarget=G,d.mousedown(P)},r.mouseup=function(P){const G=Xe(P,e);P.featureTarget=G,et(n,{point:P.point,time:(new Date).getTime()})?d.click(P):d.mouseup(P)},r.mouseout=function(P){d.mouseout(P)},r.touchstart=function(P){if(!e.options.touchEnabled)return;o={time:(new Date).getTime(),point:P.point};const G=Be.touch(P,null,e)[0];P.featureTarget=G,d.touchstart(P)},r.touchmove=function(P){if(e.options.touchEnabled)return d.touchmove(P),r.touchdrag(P)},r.touchend=function(P){if(P.originalEvent.preventDefault(),!e.options.touchEnabled)return;const G=Be.touch(P,null,e)[0];P.featureTarget=G,tt(o,{time:(new Date).getTime(),point:P.point})?d.tap(P):d.touchend(P)};const M=P=>{const G=he(P),$=me(P),te=ve(P);return!(G||$||te)};function g(P,G,$={}){d.stop();const te=t[P];if(void 0===te)throw new Error(`${P} is not valid`);i=P;const Ce=te(e,G);d=nt(Ce,e),$.silent||e.map.fire(a.MODE_CHANGE,{mode:P}),e.store.setDirty(),e.store.render()}r.keydown=function(P){(P.srcElement||P.target).classList.contains(s.CANVAS)&&((he(P)||me(P))&&e.options.controls.trash?(P.preventDefault(),d.trash()):M(P)?d.keydown(P):ne(P)&&e.options.controls.point?g(p.DRAW_POINT):ze(P)&&e.options.controls.line_string?g(p.DRAW_LINE_STRING):De(P)&&e.options.controls.polygon&&g(p.DRAW_POLYGON))},r.keyup=function(P){M(P)&&d.keyup(P)},r.zoomend=function(){e.store.changeZoom()},r.data=function(P){if("style"===P.dataType){const{setup:G,map:$,options:te,store:Ce}=e;te.styles.some(Ve=>$.getLayer(Ve.id))||(G.addLayers(),Ce.setDirty(),Ce.render())}};const N={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return{start(){i=e.options.defaultMode,d=nt(t[i](e),e)},changeMode:g,actionable:function K(P){let G=!1;Object.keys(P).forEach($=>{if(void 0===N[$])throw new Error("Invalid action type");N[$]!==P[$]&&(G=!0),N[$]=P[$]}),G&&e.map.fire(a.ACTIONABLE,{actions:N})},currentModeName:()=>i,currentModeRender:(P,G)=>d.render(P,G),fire(P,G){e.map&&e.map.fire(P,G)},addEventListeners(){e.map.on("mousemove",r.mousemove),e.map.on("mousedown",r.mousedown),e.map.on("mouseup",r.mouseup),e.map.on("data",r.data),e.map.on("touchmove",r.touchmove),e.map.on("touchstart",r.touchstart),e.map.on("touchend",r.touchend),e.container.addEventListener("mouseout",r.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",r.keydown),e.container.addEventListener("keyup",r.keyup))},removeEventListeners(){e.map.off("mousemove",r.mousemove),e.map.off("mousedown",r.mousedown),e.map.off("mouseup",r.mouseup),e.map.off("data",r.data),e.map.off("touchmove",r.touchmove),e.map.off("touchstart",r.touchstart),e.map.off("touchend",r.touchend),e.container.removeEventListener("mouseout",r.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",r.keydown),e.container.removeEventListener("keyup",r.keyup))},trash(P){d.trash(P)},combineFeatures(){d.combineFeatures()},uncombineFeatures(){d.uncombineFeatures()},getMode:()=>i}}(e),e.ui=function It(e){const t={};let n=null,o={mode:null,feature:null,mouse:null},r={mode:null,feature:null,mouse:null};function d(G){r=Object.assign(r,G)}function M(){if(!e.container)return;const G=[],$=[];it.forEach(te=>{r[te]!==o[te]&&(G.push(`${te}-${o[te]}`),null!==r[te]&&$.push(`${te}-${r[te]}`))}),G.length>0&&e.container.classList.remove(...G),$.length>0&&e.container.classList.add(...$),o=Object.assign(o,r)}function g(G,$={}){const te=document.createElement("button");return te.className=`${s.CONTROL_BUTTON} ${$.className}`,te.setAttribute("title",$.title),$.container.appendChild(te),te.addEventListener("click",Ce=>{if(Ce.preventDefault(),Ce.stopPropagation(),Ce.target===n)return N(),void $.onDeactivate();K(G),$.onActivate()},!0),te}function N(){n&&(n.classList.remove(s.ACTIVE_BUTTON),n=null)}function K(G){N();const $=t[G];$&&$&&"trash"!==G&&($.classList.add(s.ACTIVE_BUTTON),n=$)}return{setActiveButton:K,queueMapClasses:d,updateMapClasses:M,clearMapClasses:function i(){d({mode:null,feature:null,mouse:null}),M()},addButtons:function j(){const G=e.options.controls,$=document.createElement("div");return $.className=`${s.CONTROL_GROUP} ${s.CONTROL_BASE}`,G&&(G[R.POINT]&&(t[R.POINT]=g(R.POINT,{container:$,className:s.CONTROL_BUTTON_POINT,title:"Marker tool "+(e.options.keybindings?"(1)":""),onActivate:()=>e.events.changeMode(p.DRAW_POINT),onDeactivate:()=>e.events.trash()})),G[R.LINE]&&(t[R.LINE]=g(R.LINE,{container:$,className:s.CONTROL_BUTTON_LINE,title:"LineString tool "+(e.options.keybindings?"(2)":""),onActivate:()=>e.events.changeMode(p.DRAW_LINE_STRING),onDeactivate:()=>e.events.trash()})),G[R.POLYGON]&&(t[R.POLYGON]=g(R.POLYGON,{container:$,className:s.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(e.options.keybindings?"(3)":""),onActivate:()=>e.events.changeMode(p.DRAW_POLYGON),onDeactivate:()=>e.events.trash()})),G.trash&&(t.trash=g("trash",{container:$,className:s.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:()=>{e.events.trash()}})),G.combine_features&&(t.combine_features=g("combineFeatures",{container:$,className:s.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:()=>{e.events.combineFeatures()}})),G.uncombine_features&&(t.uncombine_features=g("uncombineFeatures",{container:$,className:s.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:()=>{e.events.uncombineFeatures()}}))),$},removeButtons:function P(){Object.keys(t).forEach(G=>{const $=t[G];$.parentNode&&$.parentNode.removeChild($),delete t[G]})}}}(e),e.container=r.getContainer(),e.store=new ie(e),t=e.ui.addButtons(),e.options.boxSelect){e.boxZoomInitial=r.boxZoom.isEnabled(),r.boxZoom.disable();const i=r.dragPan.isEnabled();r.dragPan.disable(),r.dragPan.enable(),i||r.dragPan.disable()}return r.loaded()?o.connect():(r.on("load",o.connect),n=setInterval(()=>{r.loaded()&&o.connect()},16)),e.events.start(),t},addLayers(){e.map.addSource(b.COLD,{data:{type:S.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(b.HOT,{data:{type:S.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.options.styles.forEach(r=>{e.map.addLayer(r)}),e.store.setDirty(!0),e.store.render()},removeLayers(){e.options.styles.forEach(r=>{e.map.getLayer(r.id)&&e.map.removeLayer(r.id)}),e.map.getSource(b.COLD)&&e.map.removeSource(b.COLD),e.map.getSource(b.HOT)&&e.map.removeSource(b.HOT)}};return e.setup=o,o}const st="#3bb2d0",at="#fbb03b",Gt=[{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"]],paint:{"fill-color":["case",["==",["get","active"],"true"],at,st],"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"],at,st],"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":"#fff"}},{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"],at,st]}},{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":"#fff"}},{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":at}},{id:"gl-draw-midpoint",type:"circle",filter:["all",["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":at}}];function Ge(e,t){this.x=e,this.y=t}Ge.prototype={clone(){return new Ge(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 n=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,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=n*this.x+t*this.y;return this.x=t*this.x-n*this.y,this.y=r,this},_rotateAround(e,t){const n=Math.cos(e),o=Math.sin(e),i=t.y+o*(this.x-t.x)+n*(this.y-t.y);return this.x=t.x+n*(this.x-t.x)-o*(this.y-t.y),this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Ge},Ge.convert=function(e){if(e instanceof Ge)return e;if(Array.isArray(e))return new Ge(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new Ge(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};const Ot=function mn(e,t){const n=t.getBoundingClientRect();return new Ge(e.clientX-n.left-(t.clientLeft||0),e.clientY-n.top-(t.clientTop||0))};function Ze(e,t,n,o){return{type:S.FEATURE,properties:{meta:C.VERTEX,parent:e,coord_path:n,active:o?F.ACTIVE:F.INACTIVE},geometry:{type:S.POINT,coordinates:t}}}function lt(e,t,n){if(null!==e)for(var o,r,i,d,M,g,N,P,K=0,j=0,G=e.type,$="FeatureCollection"===G,te="Feature"===G,Ce=$?e.features.length:1,Te=0;Te<Ce;Te++){M=(P=!!(N=$?e.features[Te].geometry:te?e.geometry:e)&&"GeometryCollection"===N.type)?N.geometries.length:1;for(var Ve=0;Ve<M;Ve++){var Pe=0,We=0;if(null!==(d=P?N.geometries[Ve]:N)){g=d.coordinates;var Ue=d.type;switch(K=!n||"Polygon"!==Ue&&"MultiPolygon"!==Ue?0:1,Ue){case null:break;case"Point":if(!1===t(g,j,Te,Pe,We))return!1;j++,Pe++;break;case"LineString":case"MultiPoint":for(o=0;o<g.length;o++){if(!1===t(g[o],j,Te,Pe,We))return!1;j++,"MultiPoint"===Ue&&Pe++}"LineString"===Ue&&Pe++;break;case"Polygon":case"MultiLineString":for(o=0;o<g.length;o++){for(r=0;r<g[o].length-K;r++){if(!1===t(g[o][r],j,Te,Pe,We))return!1;j++}"MultiLineString"===Ue&&Pe++,"Polygon"===Ue&&We++}"Polygon"===Ue&&Pe++;break;case"MultiPolygon":for(o=0;o<g.length;o++){for(We=0,r=0;r<g[o].length;r++){for(i=0;i<g[o][r].length-K;i++){if(!1===t(g[o][r][i],j,Te,Pe,We))return!1;j++}We++}Pe++}break;case"GeometryCollection":for(o=0;o<d.geometries.length;o++)if(!1===lt(d.geometries[o],t,n))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Jt(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=Yt(e.properties),t.geometry=null==e.geometry?null:Dt(e.geometry),t}function Yt(e){const t={};return e&&Object.keys(e).forEach(n=>{const o=e[n];t[n]="object"==typeof o?null===o?null:Array.isArray(o)?o.map(r=>r):Yt(o):o}),t}function Dt(e){const t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(n=>Dt(n)),t):(t.coordinates=jt(e.coordinates),t)}function jt(e){const t=e;return"object"!=typeof t[0]?t.slice():t.map(n=>jt(n))}function Qt(e,t={}){return qt(e,"mercator",t)}function qt(e,t,n={}){var o=(n=n||{}).mutate;if(!e)throw new Error("geojson is required");return Array.isArray(e)&&function ht(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}(e[0])?e="mercator"===t?en(e):tn(e):(!0!==o&&(e=function Pn(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return Jt(e);case"FeatureCollection":return function Sn(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=>Jt(n)),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Dt(e);default:throw new Error("unknown GeoJSON type")}}(e)),lt(e,function(r){var i="mercator"===t?en(r):tn(r);r[0]=i[0],r[1]=i[1]})),e}function en(e){var t=Math.PI/180,n=6378137,o=20037508.342789244,r=Math.abs(e[0])<=180?e[0]:e[0]-360*function On(e){return e<0?-1:e>0?1:0}(e[0]),i=[n*r*t,n*Math.log(Math.tan(.25*Math.PI+.5*e[1]*t))];return i[0]>o&&(i[0]=o),i[0]<-o&&(i[0]=-o),i[1]>o&&(i[1]=o),i[1]<-o&&(i[1]=-o),i}function tn(e){var t=180/Math.PI,n=6378137;return[e[0]*t/n,(.5*Math.PI-2*Math.atan(Math.exp(-e[1]/n)))*t]}function nn(e,t,n){const o=t.geometry.coordinates,r=n.geometry.coordinates;if(o[1]>k||o[1]<w||r[1]>k||r[1]<w)return null;const i=Qt(o),d=Qt(r),M=j=>Number(j.toFixed(8)),g=(j,P)=>(j+P)/2,N=function In(e,t={}){return qt(e,"wgs84",t)}([g(i[0],d[0]),g(i[1],d[1])]),K=[M(N[0]),M(N[1])];return{type:S.FEATURE,properties:{meta:C.MIDPOINT,parent:e,lng:K[0],lat:K[1],coord_path:n.properties.coord_path},geometry:{type:S.POINT,coordinates:K}}}Math;const wt=function on(e,t={},n=null){const{type:o,coordinates:r}=e.geometry,i=e.properties&&e.properties.id;let d=[];function M(K,j){let P="",G=null;K.forEach(($,te)=>{const Ce=null!=j?`${j}.${te}`:String(te),Te=Ze(i,$,Ce,g(Ce));if(t.midpoints&&G){const Pe=nn(i,G,Te);Pe&&d.push(Pe)}G=Te;const Ve=JSON.stringify($);P!==Ve&&d.push(Te),0===te&&(P=Ve)})}function g(K){return!!t.selectedPaths&&-1!==t.selectedPaths.indexOf(K)}return o===S.POINT?d.push(Ze(i,r,n,g(n))):o===S.POLYGON?r.forEach((K,j)=>{M(K,null!==n?`${n}.${j}`:String(j))}):o===S.LINE_STRING?M(r,n):0===o.indexOf(S.MULTI_PREFIX)&&function N(){const K=o.replace(S.MULTI_PREFIX,"");r.forEach((j,P)=>{d=d.concat(on({type:S.FEATURE,properties:e.properties,geometry:{type:K,coordinates:j}},t,P))})}(),d},Ie={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:pt,LAT_MAX:gt,LAT_RENDERED_MIN:rn,LAT_RENDERED_MAX:sn,LNG_MIN:an,LNG_MAX:ln}=O;function At(e,t){let n=pt,o=gt,r=pt,i=gt,d=ln,M=an;e.forEach(N=>{const K=function Fn(e){const n=[e.geometry.coordinates].flat({Point:0,LineString:1,Polygon:2,MultiPoint:1,MultiLineString:2,MultiPolygon:3}[e.geometry.type]),o=n.map(M=>M[0]),r=n.map(M=>M[1]),i=M=>Math.min.apply(null,M),d=M=>Math.max.apply(null,M);return[i(o),i(r),d(o),d(r)]}(N),j=K[1],P=K[3],G=K[0],$=K[2];j>n&&(n=j),P<o&&(o=P),P>r&&(r=P),j<i&&(i=j),G<d&&(d=G),$>M&&(M=$)});const g=t;return n+g.lat>sn&&(g.lat=sn-n),r+g.lat>gt&&(g.lat=gt-r),o+g.lat<rn&&(g.lat=rn-o),i+g.lat<pt&&(g.lat=pt-i),d+g.lng<=an&&(g.lng+=360*Math.ceil(Math.abs(g.lng)/360)),M+g.lng>=ln&&(g.lng-=360*Math.ceil(Math.abs(g.lng)/360)),g}function Nt(e,t){const n=At(e.map(o=>o.toGeoJSON()),t);e.forEach(o=>{const r=o.getCoordinates(),i=N=>{const K={lng:N[0]+n.lng,lat:N[1]+n.lat};return[K.lng,K.lat]},d=N=>N.map(K=>i(K));let g;o.type===S.POINT?g=i(r):o.type===S.LINE_STRING||o.type===S.MULTI_POINT?g=r.map(i):o.type===S.POLYGON||o.type===S.MULTI_LINE_STRING?g=r.map(d):o.type===S.MULTI_POLYGON&&(g=r.map(N=>N.map(K=>d(K)))),o.incomingCoords(g)})}const ce={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=>void 0!==this.getFeature(n))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),t},fireUpdate:function(){this.fire(a.UPDATE,{action:h.MOVE,features:this.getSelected().map(e=>e.toGeoJSON())})},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(d=>{d.type.replace("Multi","")!==i&&(n=!1)})}this.setActionableState({combineFeatures:n,uncombineFeatures:t.length>0,trash:e.length>0})},getUniqueIds:function(e){return e.length?e.map(n=>n.properties.id).filter(n=>void 0!==n).reduce((n,o)=>(n.add(o),n),new Ae).values():[]},stopExtendedInteractions:function(e){e.boxSelectElement&&(e.boxSelectElement.parentNode&&e.boxSelectElement.parentNode.removeChild(e.boxSelectElement),e.boxSelectElement=null),(e.canDragMove||e.canBoxSelect)&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.boxSelecting=!1,e.canBoxSelect=!1,e.dragMoving=!1,e.canDragMove=!1},onStop:function(){Ie.enable(this)},onMouseMove:function(e,t){return Z(t)&&e.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(e),!0},onMouseOut:function(e){return!e.dragMoving||this.fireUpdate()}};ce.onTap=ce.onClick=function(e,t){return W(t)?this.clickAnywhere(e,t):L(C.VERTEX)(t)?this.clickOnVertex(e,t):Z(t)?this.clickOnFeature(e,t):void 0},ce.clickAnywhere=function(e){const t=this.getSelectedIds();t.length&&(this.clearSelectedFeatures(),t.forEach(n=>this.doRender(n))),Ie.enable(this),this.stopExtendedInteractions(e)},ce.clickOnVertex=function(e,t){this.changeMode(p.DIRECT_SELECT,{featureId:t.featureTarget.properties.parent,coordPath:t.featureTarget.properties.coord_path,startPos:t.lngLat}),this.updateUIClasses({mouse:v.MOVE})},ce.startOnActiveFeature=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),this.doRender(t.featureTarget.properties.id),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},ce.clickOnFeature=function(e,t){Ie.disable(this),this.stopExtendedInteractions(e);const n=oe(t),o=this.getSelectedIds(),r=t.featureTarget.properties.id,i=this.isSelected(r);if(!n&&i&&this.getFeature(r).type!==S.POINT)return this.changeMode(p.DIRECT_SELECT,{featureId:r});i&&n?(this.deselect(r),this.updateUIClasses({mouse:v.POINTER}),1===o.length&&Ie.enable(this)):!i&&n?(this.select(r),this.updateUIClasses({mouse:v.MOVE})):!i&&!n&&(o.forEach(d=>this.doRender(d)),this.setSelected(r),this.updateUIClasses({mouse:v.MOVE})),this.doRender(r)},ce.onMouseDown=function(e,t){return e.initialDragPanState=this.map.dragPan.isEnabled(),T(t)?this.startOnActiveFeature(e,t):this.drawConfig.boxSelect&&x(t)?this.startBoxSelect(e,t):void 0},ce.startBoxSelect=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),e.boxSelectStartLocation=Ot(t.originalEvent,this.map.getContainer()),e.canBoxSelect=!0},ce.onTouchStart=function(e,t){if(T(t))return this.startOnActiveFeature(e,t)},ce.onDrag=function(e,t){return e.canDragMove?this.dragMove(e,t):this.drawConfig.boxSelect&&e.canBoxSelect?this.whileBoxSelect(e,t):void 0},ce.whileBoxSelect=function(e,t){e.boxSelecting=!0,this.updateUIClasses({mouse:v.ADD}),e.boxSelectElement||(e.boxSelectElement=document.createElement("div"),e.boxSelectElement.classList.add(s.BOX_SELECT),this.map.getContainer().appendChild(e.boxSelectElement));const n=Ot(t.originalEvent,this.map.getContainer()),o=Math.min(e.boxSelectStartLocation.x,n.x),r=Math.max(e.boxSelectStartLocation.x,n.x),i=Math.min(e.boxSelectStartLocation.y,n.y),d=Math.max(e.boxSelectStartLocation.y,n.y),M=`translate(${o}px, ${i}px)`;e.boxSelectElement.style.transform=M,e.boxSelectElement.style.WebkitTransform=M,e.boxSelectElement.style.width=r-o+"px",e.boxSelectElement.style.height=d-i+"px"},ce.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};Nt(this.getSelected(),n),e.dragMoveLocation=t.lngLat},ce.onTouchEnd=ce.onMouseUp=function(e,t){if(e.dragMoving)this.fireUpdate();else if(e.boxSelecting){const n=[e.boxSelectStartLocation,Ot(t.originalEvent,this.map.getContainer())],o=this.featuresAt(null,n,"click"),r=this.getUniqueIds(o).filter(i=>!this.isSelected(i));r.length&&(this.select(r),r.forEach(i=>this.doRender(i)),this.updateUIClasses({mouse:v.MOVE}))}this.stopExtendedInteractions(e)},ce.toDisplayFeatures=function(e,t,n){t.properties.active=this.isSelected(t.properties.id)?F.ACTIVE:F.INACTIVE,n(t),this.fireActionable(),t.properties.active===F.ACTIVE&&t.geometry.type!==S.POINT&&wt(t).forEach(n)},ce.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},ce.onCombineFeatures=function(){const e=this.getSelected();if(0===e.length||e.length<2)return;const t=[],n=[],o=e[0].type.replace("Multi","");for(let r=0;r<e.length;r++){const i=e[r];if(i.type.replace("Multi","")!==o)return;i.type.includes("Multi")?i.getCoordinates().forEach(d=>{t.push(d)}):t.push(i.getCoordinates()),n.push(i.toGeoJSON())}if(n.length>1){const r=this.newFeature({type:S.FEATURE,properties:n[0].properties,geometry:{type:`Multi${o}`,coordinates:t}});this.addFeature(r),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([r.id]),this.fire(a.COMBINE_FEATURES,{createdFeatures:[r.toGeoJSON()],deletedFeatures:n})}this.fireActionable()},ce.onUncombineFeatures=function(){const e=this.getSelected();if(0===e.length)return;const t=[],n=[];for(let o=0;o<e.length;o++){const r=e[o];this.isInstanceOf("MultiFeature",r)&&(r.getFeatures().forEach(i=>{this.addFeature(i),i.properties=r.properties,t.push(i.toGeoJSON()),this.select([i.id])}),this.deleteFeature(r.id,{silent:!0}),n.push(r.toGeoJSON()))}t.length>1&&this.fire(a.UNCOMBINE_FEATURES,{createdFeatures:t,deletedFeatures:n}),this.fireActionable()};const xn=ce,cn=L(C.VERTEX),un=L(C.MIDPOINT),ue={fireUpdate:function(){this.fire(a.UPDATE,{action:h.CHANGE_COORDINATES,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(e){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:e.selectedCoordPaths.length>0})},startDragging:function(e,t){null==e.initialDragPanState&&(e.initialDragPanState=this.map.dragPan.isEnabled()),this.map.dragPan.disable(),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},stopDragging:function(e){e.canDragMove&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.initialDragPanState=null,e.dragMoving=!1,e.canDragMove=!1,e.dragMoveLocation=null},onVertex:function(e,t){this.startDragging(e,t);const n=t.featureTarget.properties,o=e.selectedCoordPaths.indexOf(n.coord_path);oe(t)||-1!==o?oe(t)&&-1===o&&e.selectedCoordPaths.push(n.coord_path):e.selectedCoordPaths=[n.coord_path];const r=this.pathsToCoordinates(e.featureId,e.selectedCoordPaths);this.setSelectedCoordinates(r)},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]},pathsToCoordinates:function(e,t){return t.map(n=>({feature_id:e,coord_path:n}))},onFeature:function(e,t){0===e.selectedCoordPaths.length?this.startDragging(e,t):this.stopDragging(e)},dragFeature:function(e,t,n){Nt(this.getSelected(),n),e.dragMoveLocation=t.lngLat},dragVertex:function(e,t,n){const o=e.selectedCoordPaths.map(d=>e.feature.getCoordinate(d)),i=At(o.map(d=>({type:S.FEATURE,properties:{},geometry:{type:S.POINT,coordinates:d}})),n);for(let d=0;d<o.length;d++){const M=o[d];e.feature.updateCoordinate(e.selectedCoordPaths[d],M[0]+i.lng,M[1]+i.lat)}},clickNoTarget:function(){this.changeMode(p.SIMPLE_SELECT)},clickInactive:function(){this.changeMode(p.SIMPLE_SELECT)},clickActiveFeature:function(e){e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed()},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===S.POINT)throw new TypeError("direct_select mode doesn't handle point features");const o={featureId:t,feature:n,dragMoveLocation:e.startPos||null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:e.coordPath?[e.coordPath]:[]};return this.setSelectedCoordinates(this.pathsToCoordinates(t,o.selectedCoordPaths)),this.setSelected(t),Ie.disable(this),this.setActionableState({trash:!0}),o},onStop:function(){Ie.enable(this),this.clearSelectedCoordinates()},toDisplayFeatures:function(e,t,n){e.featureId===t.properties.id?(t.properties.active=F.ACTIVE,n(t),wt(t,{map:this.map,midpoints:!0,selectedPaths:e.selectedCoordPaths}).forEach(n)):(t.properties.active=F.INACTIVE,n(t)),this.fireActionable(e)},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),!1===e.feature.isValid()&&(this.deleteFeature([e.featureId]),this.changeMode(p.SIMPLE_SELECT,{}))},onMouseMove:function(e,t){const n=T(t),o=cn(t),r=un(t),i=0===e.selectedCoordPaths.length;return this.updateUIClasses(n&&i||o&&!i?{mouse:v.MOVE}:{mouse:v.NONE}),(o||n||r)&&e.dragMoving&&this.fireUpdate(),this.stopDragging(e),!0},onMouseOut:function(e){return e.dragMoving&&this.fireUpdate(),!0}};ue.onTouchStart=ue.onMouseDown=function(e,t){return cn(t)?this.onVertex(e,t):T(t)?this.onFeature(e,t):un(t)?this.onMidpoint(e,t):void 0},ue.onDrag=function(e,t){if(!0!==e.canDragMove)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},ue.onClick=function(e,t){return W(t)?this.clickNoTarget(e,t):T(t)?this.clickActiveFeature(e,t):A(t)?this.clickInactive(e,t):void this.stopDragging(e)},ue.onTap=function(e,t){return W(t)?this.clickNoTarget(e,t):T(t)?this.clickActiveFeature(e,t):A(t)?this.clickInactive(e,t):void 0},ue.onTouchEnd=ue.onMouseUp=function(e){e.dragMoving&&this.fireUpdate(),this.stopDragging(e)};const Dn=ue,xe={onSetup:function(){const e=this.newFeature({type:S.FEATURE,properties:{},geometry:{type:S.POINT,coordinates:[]}});return this.addFeature(e),this.clearSelectedFeatures(),this.updateUIClasses({mouse:v.ADD}),this.activateUIButton(R.POINT),this.setActionableState({trash:!0}),{point:e}},stopDrawingAndRemove:function(e){this.deleteFeature([e.point.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT)}};xe.onTap=xe.onClick=function(e,t){this.updateUIClasses({mouse:v.MOVE}),e.point.updateCoordinate("",t.lngLat.lng,t.lngLat.lat),this.fire(a.CREATE,{features:[e.point.toGeoJSON()]}),this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.point.id]})},xe.onStop=function(e){this.activateUIButton(),e.point.getCoordinate().length||this.deleteFeature([e.point.id],{silent:!0})},xe.toDisplayFeatures=function(e,t,n){const o=t.properties.id===e.point.id;if(t.properties.active=o?F.ACTIVE:F.INACTIVE,!o)return n(t)},xe.onTrash=xe.stopDrawingAndRemove,xe.onKeyUp=function(e,t){if(ye(t)||fe(t))return this.stopDrawingAndRemove(e,t)};const wn=xe,mt=function An(e,t){return!!e.lngLat&&e.lngLat.lng===t[0]&&e.lngLat.lat===t[1]},Oe={onSetup:function(){const e=this.newFeature({type:S.FEATURE,properties:{},geometry:{type:S.POLYGON,coordinates:[[]]}});return this.addFeature(e),this.clearSelectedFeatures(),Ie.disable(this),this.updateUIClasses({mouse:v.ADD}),this.activateUIButton(R.POLYGON),this.setActionableState({trash:!0}),{polygon:e,currentVertexPosition:0}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&mt(t,e.polygon.coordinates[0][e.currentVertexPosition-1]))return this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.polygon.id]});this.updateUIClasses({mouse:v.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)},clickOnVertex:function(e){return this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},onMouseMove:function(e,t){e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),J(t)&&this.updateUIClasses({mouse:v.POINTER})}};Oe.onTap=Oe.onClick=function(e,t){return J(t)?this.clickOnVertex(e,t):this.clickAnywhere(e,t)},Oe.onKeyUp=function(e,t){ye(t)?(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT)):fe(t)&&this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},Oe.onStop=function(e){this.updateUIClasses({mouse:v.NONE}),Ie.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.polygon.id)&&(e.polygon.removeCoordinate(`0.${e.currentVertexPosition}`),e.polygon.isValid()?this.fire(a.CREATE,{features:[e.polygon.toGeoJSON()]}):(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT,{},{silent:!0})))},Oe.toDisplayFeatures=function(e,t,n){const o=t.properties.id===e.polygon.id;if(t.properties.active=o?F.ACTIVE:F.INACTIVE,!o)return n(t);if(0===t.geometry.coordinates.length)return;const r=t.geometry.coordinates[0].length;if(!(r<3)){if(t.properties.meta=C.FEATURE,n(Ze(e.polygon.id,t.geometry.coordinates[0][0],"0.0",!1)),r>3){const i=t.geometry.coordinates[0].length-3;n(Ze(e.polygon.id,t.geometry.coordinates[0][i],`0.${i}`,!1))}if(r<=4&&(n({type:S.FEATURE,properties:t.properties,geometry:{coordinates:[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]],type:S.LINE_STRING}}),3===r))return;return n(t)}},Oe.onTrash=function(e){this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT)};const Nn=Oe,Fe={onSetup:function(e){const t=(e=e||{}).featureId;let n,o,r="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&&"Feature"===i.type&&i.geometry&&"Point"===i.geometry.type&&(i=i.geometry),i&&"Point"===i.type&&i.coordinates&&2===i.coordinates.length&&(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 d=n.coordinates.length-1;if(n.coordinates[d][0]===i[0]&&n.coordinates[d][1]===i[1])o=d+1,n.addCoordinate(o,...n.coordinates[d]);else{if(n.coordinates[0][0]!==i[0]||n.coordinates[0][1]!==i[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");r="backwards",o=0,n.addCoordinate(o,...n.coordinates[0])}}else n=this.newFeature({type:S.FEATURE,properties:{},geometry:{type:S.LINE_STRING,coordinates:[]}}),o=0,this.addFeature(n);return this.clearSelectedFeatures(),Ie.disable(this),this.updateUIClasses({mouse:v.ADD}),this.activateUIButton(R.LINE),this.setActionableState({trash:!0}),{line:n,currentVertexPosition:o,direction:r}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&mt(t,e.line.coordinates[e.currentVertexPosition-1])||"backwards"===e.direction&&mt(t,e.line.coordinates[e.currentVertexPosition+1]))return this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.line.id]});this.updateUIClasses({mouse:v.ADD}),e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),"forward"===e.direction?(e.currentVertexPosition++,e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat)):e.line.addCoordinate(0,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.line.id]})},onMouseMove:function(e,t){e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),J(t)&&this.updateUIClasses({mouse:v.POINTER})}};Fe.onTap=Fe.onClick=function(e,t){if(J(t))return this.clickOnVertex(e,t);this.clickAnywhere(e,t)},Fe.onKeyUp=function(e,t){fe(t)?this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.line.id]}):ye(t)&&(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT))},Fe.onStop=function(e){Ie.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.line.id)&&(e.line.removeCoordinate(`${e.currentVertexPosition}`),e.line.isValid()?this.fire(a.CREATE,{features:[e.line.toGeoJSON()]}):(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT,{},{silent:!0})))},Fe.onTrash=function(e){this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT)},Fe.toDisplayFeatures=function(e,t,n){const o=t.properties.id===e.line.id;if(t.properties.active=o?F.ACTIVE:F.INACTIVE,!o)return n(t);t.geometry.coordinates.length<2||(t.properties.meta=C.FEATURE,n(Ze(e.line.id,t.geometry.coordinates["forward"===e.direction?t.geometry.coordinates.length-2:1],""+("forward"===e.direction?t.geometry.coordinates.length-2:1),!1)),n(t))};const dn={simple_select:xn,direct_select:Dn,draw_point:wn,draw_polygon:Nn,draw_line_string:Fe},Rn={defaultMode:p.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:Gt,modes:dn,controls:{},userProperties:!1,suppressAPIEvents:!0},Bn={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},kn={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function fn(e,t){return e.map(n=>n.source?n:Object.assign({},n,{id:`${n.id}.${t}`,source:"hot"===t?b.HOT:b.COLD}))}var hn=c(362),Vn=c(5341);function pn(e,t){return e.length===t.length&&JSON.stringify(e.map(n=>n).sort())===JSON.stringify(t.map(n=>n).sort())}const Un={Polygon:se,LineString:le,Point:Y,MultiPolygon:Ne,MultiLineString:Ne,MultiPoint:Ne};function yt(e){!function(e,t){e=function Gn(e={}){let t=Object.assign({},e);return e.controls||(t.controls={}),t.controls=Object.assign({},!1===e.displayControlsDefault?kn:Bn,e.controls),t=Object.assign({},Rn,t),t.styles=fn(t.styles,"cold").concat(fn(t.styles,"hot")),t}(e);const n={options:e};t=function zn(e,t){t.modes=p;const n=void 0===e.options.suppressAPIEvents||!!e.options.suppressAPIEvents;return t.getFeatureIdsAt=function(o){return Be.click({point:o},null,e).map(i=>i.properties.id)},t.getSelectedIds=function(){return e.store.getSelectedIds()},t.getSelected=function(){return{type:S.FEATURE_COLLECTION,features:e.store.getSelectedIds().map(o=>e.store.get(o)).map(o=>o.toGeoJSON())}},t.getSelectedPoints=function(){return{type:S.FEATURE_COLLECTION,features:e.store.getSelectedCoordinates().map(o=>({type:S.FEATURE,properties:{},geometry:{type:S.POINT,coordinates:o.coordinates}}))}},t.set=function(o){if(void 0===o.type||o.type!==S.FEATURE_COLLECTION||!Array.isArray(o.features))throw new Error("Invalid FeatureCollection");const r=e.store.createRenderBatch();let i=e.store.getAllIds().slice();const d=t.add(o),M=new Ae(d);return i=i.filter(g=>!M.has(g)),i.length&&t.delete(i),r(),d},t.add=function(o){const i=JSON.parse(JSON.stringify(Vn(o))).features.map(d=>{if(d.id=d.id||l(),null===d.geometry)throw new Error("Invalid geometry: null");if(void 0===e.store.get(d.id)||e.store.get(d.id).type!==d.geometry.type){const M=Un[d.geometry.type];if(void 0===M)throw new Error(`Invalid geometry type: ${d.geometry.type}.`);const g=new M(e,d);e.store.add(g,{silent:n})}else{const M=e.store.get(d.id),g=M.properties;M.properties=d.properties,hn(g,d.properties)||e.store.featureChanged(M.id,{silent:n}),hn(M.getCoordinates(),d.geometry.coordinates)||M.incomingCoords(d.geometry.coordinates)}return d.id});return e.store.render(),i},t.get=function(o){const r=e.store.get(o);if(r)return r.toGeoJSON()},t.getAll=function(){return{type:S.FEATURE_COLLECTION,features:e.store.getAll().map(o=>o.toGeoJSON())}},t.delete=function(o){return e.store.delete(o,{silent:n}),t.getMode()!==p.DIRECT_SELECT||e.store.getSelectedIds().length?e.store.render():e.events.changeMode(p.SIMPLE_SELECT,void 0,{silent:n}),t},t.deleteAll=function(){return e.store.delete(e.store.getAllIds(),{silent:n}),t.getMode()===p.DIRECT_SELECT?e.events.changeMode(p.SIMPLE_SELECT,void 0,{silent:n}):e.store.render(),t},t.changeMode=function(o,r={}){return o===p.SIMPLE_SELECT&&t.getMode()===p.SIMPLE_SELECT?(pn(r.featureIds||[],e.store.getSelectedIds())||(e.store.setSelected(r.featureIds,{silent:n}),e.store.render()),t):(o===p.DIRECT_SELECT&&t.getMode()===p.DIRECT_SELECT&&r.featureId===e.store.getSelectedIds()[0]||e.events.changeMode(o,r,{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(o,r,i){return e.store.setFeatureProperty(o,r,i,{silent:n}),t},t}(n,t),n.api=t;const o=Bt(n);t.onAdd=o.onAdd,t.onRemove=o.onRemove,t.types=R,t.options=e}(e,this)}yt.modes=dn,yt.constants=O,yt.lib=D;const gn=yt;let Wn=(()=>{class e{_draw;_map;_drawMode=(0,z.vPA)(!1);_settingDrawMode=!1;_eventListeners=[];_clearAfterFinish=!0;drawEvent=(0,z.vPA)(void 0);destroy(){this._cleanup()}initializeWithMap(n){this._map=n,this._initDrawControl(n)}setDrawMode(n,o){if(this._draw&&this._map&&!this._settingDrawMode){if(this._clearAfterFinish=o,this._settingDrawMode=!0,this._drawMode.set(n),n){this._draw.deleteAll(),this._draw.changeMode("draw_polygon");const r={type:"polygon",status:"started",coordinates:[],bbox:{minLng:0,minLat:0,maxLng:0,maxLat:0}};this.drawEvent.update(()=>r)}else this._draw.changeMode("simple_select"),this._draw.deleteAll();this._settingDrawMode=!1}}setClearAfterFinish(n){this._clearAfterFinish=n}getClearAfterFinish(){return this._clearAfterFinish}getDrawMode(){return this._drawMode()}clearDrawings(){this._draw&&this._draw.deleteAll()}getDrawInstance(){return this._draw}_initDrawControl(n){this._draw=new gn({displayControlsDefault:!1,modes:{...gn.modes}}),n.addControl(this._draw,"top-left");const o=document.querySelector(".mapbox-gl-draw_ctrl-draw-btn")?.parentElement;o&&(o.style.display="none");const r=M=>{const g=M.features[0];if("Polygon"===g.geometry.type){const N=g.geometry.coordinates[0],j={type:"polygon",status:"ended",coordinates:N,bbox:this._calculateBBox(N)};this.drawEvent.update(()=>j),this._drawMode.set(!1),this._clearAfterFinish&&this._draw?.deleteAll()}},i=M=>{const g=M.features[0];if("Polygon"===g.geometry.type){const N=g.geometry.coordinates[0],j={type:"polygon",status:"in-progress",coordinates:N,bbox:this._calculateBBox(N)};this.drawEvent.update(()=>j)}},d=()=>{if(this._drawMode()){const M=this._draw?.getAll();if(M?.features?.length){const g=M.features[0];if("Polygon"===g.geometry.type){const N=g.geometry.coordinates[0];if(N.length>2){const j={type:"polygon",status:"in-progress",coordinates:N,bbox:this._calculateBBox(N)};this.drawEvent.update(()=>j)}}}}};n.on("draw.create",r),n.on("draw.update",i),n.on("mousemove",d),this._eventListeners.push({event:"draw.create",handler:r}),this._eventListeners.push({event:"draw.update",handler:i}),this._eventListeners.push({event:"mousemove",handler:d})}_cleanup(){this._map&&(this._eventListeners.forEach(({event:n,handler:o})=>{this._map?.off(n,o)}),this._eventListeners=[],this._draw&&this._map._controls?.includes(this._draw)&&this._map.removeControl(this._draw)),this._draw=void 0,this._map=void 0,this.drawEvent.set(void 0)}_calculateBBox(n){return n.reduce((o,r)=>({minLng:Math.min(o.minLng,r[0]),minLat:Math.min(o.minLat,r[1]),maxLng:Math.max(o.maxLng,r[0]),maxLat:Math.max(o.maxLat,r[1])}),{minLng:1/0,minLat:1/0,maxLng:-1/0,maxLat:-1/0})}static \u0275fac=function(o){return new(o||e)};static \u0275prov=z.jDH({token:e,factory:e.\u0275fac})}return e})()},6986(ae,Q,c){"use strict";c.d(Q,{A4:()=>O,Jc:()=>v,Ln:()=>D,dx:()=>s,g8:()=>m,j5:()=>z,n7:()=>b});const O=12;function m(p,a,h){return{id:p,source:a,type:"circle",maxzoom:O,filter:["==",["get","_isCentroid"],!0],paint:{"circle-radius":6,"circle-color":["coalesce",["get","_color"],h],"circle-stroke-width":2,"circle-stroke-color":"white","circle-opacity":.8}}}function D(p,a,h,C){return function S(p,a,h,C,F){const B={id:p,source:C},E=F||h;switch(a){case"Point":case"MultiPoint":return[{...B,id:`${p}-clusters`,type:"circle",filter:["has","point_count"],paint:{"circle-color":E,"circle-radius":["step",["get","point_count"],15,100,20,750,25],"circle-stroke-width":2,"circle-stroke-color":"white","circle-opacity":.8}},{...B,id:`${p}-cluster-count`,type:"symbol",filter:["has","point_count"],layout:{"text-field":"{point_count_abbreviated}","text-font":["Poppins Medium","Arial Unicode MS Bold"],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#ffffff","text-halo-color":"rgba(0, 0, 0, 0.3)","text-halo-width":1}},{...B,id:`${p}-unclustered`,type:"circle",filter:["!",["has","point_count"]],paint:{"circle-radius":6,"circle-color":["coalesce",["get","_color"],h],"circle-stroke-width":2,"circle-stroke-color":"white","circle-opacity":.8}}];case"LineString":case"MultiLineString":return{...B,type:"line",paint:{"line-color":["coalesce",["get","_color"],h],"line-width":3,"line-opacity":.8},layout:{"line-join":"round","line-cap":"round"}};case"Polygon":case"MultiPolygon":return[{id:`${p}-fill`,source:C,type:"fill",paint:{"fill-color":["coalesce",["get","_color"],h],"fill-opacity":.3}},{id:`${p}-stroke`,source:C,type:"line",paint:{"line-color":["coalesce",["get","_color"],h],"line-width":2,"line-opacity":.8},layout:{"line-join":"round","line-cap":"round"}},{id:`${p}-labels`,source:C,type:"symbol",layout:{"text-field":["coalesce",["get","label"],""],"text-font":["Poppins Medium","Arial Unicode MS Bold"],"text-size":13,"text-anchor":"center","text-allow-overlap":!1},paint:{"text-color":"#333333","text-halo-color":"rgba(255, 255, 255, 0.9)","text-halo-width":2}}];default:return console.warn(`Unsupported geometry type: ${a}`),null}}(p,a,h,C,h)}function z(p){return"Polygon"===p||"MultiPolygon"===p}function s(p){return"LineString"===p||"MultiLineString"===p}function b(p,a){return a&&("Point"===p||"MultiPoint"===p)}function v(p,a){return b(p,a)?{cluster:!0,clusterMaxZoom:14,clusterRadius:50,clusterMinPoints:2}:{cluster:!1}}},3646(ae,Q,c){"use strict";c.d(Q,{B:()=>U});var O=c(467),m=c(5802),D=c(2271),z=c(4412),s=c(1413),b=c(2306),v=c(140);function E(k){let X=1/0,f=1/0,L=-1/0,x=-1/0;const T=k.features,A=Z=>{Z.length>=2&&(X=Math.min(X,Z[0]),f=Math.min(f,Z[1]),L=Math.max(L,Z[0]),x=Math.max(x,Z[1]))},W=(Z,J)=>{if(0===J)A(Z);else if(Array.isArray(Z))for(const oe of Z)W(oe,J-1)};for(const Z of T){const J=Z.geometry;switch(J.type){case"Point":W(J.coordinates,0);break;case"LineString":case"MultiPoint":W(J.coordinates,1);break;case"Polygon":case"MultiLineString":W(J.coordinates,2);break;case"MultiPolygon":W(J.coordinates,3);break;case"GeometryCollection":for(const oe of J.geometries){const he=E(new v.o([{type:"Feature",geometry:oe,properties:null}]));he&&(A([he[0],he[1]]),A([he[2],he[3]]))}}}return X===1/0?null:[X,f,L,x]}var w=c(6986);let U=(()=>{class k{_layers$=new z.t([]);_map;_sources={};_sourceLayers={};_sourceIds=[];_attachedListeners=[];_hoveredFeature=(0,m.vPA)(void 0);_layerGroups={};_layerClickable={};_pointLayerIds=new Set;_lineLayerIds=new Set;_processedClickEvents=new WeakSet;_clearHoverTimeout;_hoverSequence=0;layers=this._layers$.asObservable();layersSignal=(0,D.EW)(()=>this._layers$.getValue());clickedFeature=new s.B;hoveredFeature=new s.B;initializeWithMap(f){this._map=f,f.on("mousemove",L=>{const x=f.getCanvas();if(!x)return;const T=Object.keys(this._layerClickable).filter(W=>this._layerClickable[W]&&f.getLayer(W)),A=f.queryRenderedFeatures(L.point,{layers:T});x.style.cursor=A.length>0?"pointer":""})}getLayers(){return this._layers$.getValue()}setLayers(f){this._layers$.next([...f])}addLayer(f){const L=this._layers$.getValue(),x=L.findIndex(T=>T.id===f.id);x>=0?L[x]={...f}:L.push({...f}),this._layers$.next([...L])}removeLayer(f){const x=this._layers$.getValue().filter(T=>T.id!==f);this._layers$.next(x),this._deleteSourceIfExists(f.toString()),delete this._sources[f.toString()],delete this._sourceLayers[f.toString()],delete this._layerClickable[f.toString()],this._pointLayerIds.delete(f.toString()),this._lineLayerIds.delete(f.toString()),this._sourceIds=this._sourceIds.filter(T=>T!==f.toString())}toggleVisibility(f){const L=f.toString();if(this._layerGroups[L])return void this.toggleLayerGroupVisibility(L);const T=this._layers$.getValue().map(A=>{if(A.id===f){const W={...A,visible:!A.visible};return this._updateLayerVisibility(f.toString(),W.visible),W}return A});this._layers$.next(T)}setLayerVisibility(f,L){const x=f.toString();if(this._layerGroups[x]){if(this._map){const Z=L?"visible":"none";this._layerGroups[x].forEach(J=>{this._map.setLayoutProperty(J,"visibility",Z)})}}else this._updateLayerVisibility(x,L);const A=this._layers$.getValue().map(W=>W.id===f?{...W,visible:L}:W);this._layers$.next(A)}loadGeoJSONLayerGroup(f,L,x){var T=this;return(0,O.A)(function*(A,W,Z,J={}){const{cluster:oe=!1,zoomToFit:ye=!0,visible:fe=!0,label:he=A,color:me=T._extractColorFromLayer(Z[0])}=J;if(!T._map)return void console.warn("Map not initialized in LayerService");const ne=A;yield T._addSource(A,{type:"geojson",data:W,...(0,w.Jc)("Point",oe)});const ze=[];for(const ve of Z){ze.push(ve.id),T._layerClickable[ve.id]=!0,T._sourceLayers[ne]||(T._sourceLayers[ne]={layer:ve,clickable:!0});const Ke=ve.type;if("circle"===Ke||"symbol"===Ke)T._pointLayerIds.add(ve.id),T._map.addLayer(ve);else if("line"===Ke){T._lineLayerIds.add(ve.id);const we=T._getBeforePointLayerId();T._map.addLayer(ve,we)}else{const we=T._getBeforeLineLayerId()??T._getBeforePointLayerId();T._map.addLayer(ve,we)}T._map&&T._map.setLayoutProperty(ve.id,"visibility",fe?"visible":"none")}for(const ve of Z)T._setLayerEvents(ne,ve);T._layerGroups[A]=ze;const De=new b.ux(he,A);De.collection=W,De.color=me,De.visible=fe,T.addLayer(De),ye&&T.fitLayerBounds(A)}).apply(this,arguments)}toggleLayerGroupVisibility(f){const L=this._layerGroups[f];if(!L)return;const x=this.getLayer(f);if(!x)return;const T=!x.visible;if(this._map){const A=T?"visible":"none";L.forEach(W=>{this._map.setLayoutProperty(W,"visibility",A)})}this.updateLayer(f,{visible:T})}removeLayerGroup(f){const L=this._layerGroups[f];L&&(this._map&&(L.forEach(x=>{this._map.removeLayer(x),this._attachedListeners=this._attachedListeners.filter(T=>T!==f),delete this._layerClickable[x],this._pointLayerIds.delete(x),this._lineLayerIds.delete(x)}),this._deleteSourceIfExists(f)),delete this._sources[f],delete this._sourceLayers[f],this._sourceIds=this._sourceIds.filter(x=>x!==f),delete this._layerGroups[f],this.removeLayer(f))}loadGeoJSONLayer(f,L,x){var T=this;return(0,O.A)(function*(A,W,Z,J={}){const{cluster:oe=!0,zoomToFit:ye=!0,visible:fe=!0,label:he=A,color:me=T._extractColorFromLayer(Z)}=J;if(!T._map)return void console.warn("Map not initialized in LayerService");yield T._addSource(A,{type:"geojson",data:W,...(0,w.Jc)("Point",oe)},Z);const ne=new b.ux(he,A);ne.collection=W,ne.color=me,ne.visible=fe,T.addLayer(ne),T._updateLayerVisibility(A,fe),ye&&T.fitLayerBounds(A)}).apply(this,arguments)}_addSource(f,L,x){var T=this;return(0,O.A)(function*(A,W,Z,J=!0){T._map&&(T._sources[A]=W,T._deleteSourceIfExists(A),T._sourceIds.push(A),T._map.getSource(A)&&T._map.removeSource(A),T._map.addSource(A,W),Z&&T._addSourceLayer(A,Z,J))}).apply(this,arguments)}_getBeforePointLayerId(){if(!this._map||0===this._pointLayerIds.size)return;const f=this._map.getStyle()?.layers??[];for(const L of f)if(this._pointLayerIds.has(L.id))return L.id}_getBeforeLineLayerId(){if(!this._map||0===this._lineLayerIds.size)return;const f=this._map.getStyle()?.layers??[];for(const L of f)if(this._lineLayerIds.has(L.id))return L.id}_addSourceLayer(f,L,x=!0){if(!this._map)return;this._layerClickable[L.id]=x,this._sourceLayers[f]||(this._sourceLayers[f]={layer:L,clickable:x});const T=L.type;if("circle"===T||"symbol"===T)this._pointLayerIds.add(L.id),this._map.addLayer(L);else if("line"===T){this._lineLayerIds.add(L.id);const A=this._getBeforePointLayerId();this._map.addLayer(L,A)}else{const A=this._getBeforeLineLayerId()??this._getBeforePointLayerId();this._map.addLayer(L,A)}x&&this._setLayerEvents(f,L)}_updateLayerVisibility(f,L){if(!this._map)return;const x=this._sourceLayers[f];x&&this._map.setLayoutProperty(x.layer.id,"visibility",L?"visible":"none")}getLayer(f){return this._layers$.getValue().find(L=>L.id===f)}updateLayer(f,L){const T=this._layers$.getValue().map(A=>{if(A.id===f){const W={...A,...L};return void 0!==L.visible&&this._updateLayerVisibility(f.toString(),L.visible),W}return A});this._layers$.next(T)}toggleAllLayers(){const f=this._layers$.getValue(),x=!f.some(A=>A.visible),T=f.map(A=>(this._updateLayerVisibility(A.id.toString(),x),{...A,visible:x}));this._layers$.next(T)}getVisibleLayersCount(){return this._layers$.getValue().filter(f=>f.visible).length}getTotalLayersCount(){return this._layers$.getValue().length}hasLayer(f){return this._layers$.getValue().some(L=>L.id===f)}fitGeoJSONBounds(f,L=50,x=!0,T=19){this._fitGeoJSONBounds(f,L,x,T)}fitLayerBounds(f,L=50){const x=this._layers$.getValue().find(T=>T.id===f);!x||!x.collection||!this._map||("features"in x.collection?this._fitGeoJSONBounds(x.collection,L):console.warn("Layer collection is not a FeatureCollection, cannot fit bounds."))}fitAllVisibleLayers(f=50){const L=this._layers$.getValue().filter(W=>W.visible&&W.collection);if(0===L.length||!this._map)return;const x=L.flatMap(W=>{const Z=W.collection;return Z&&"features"in Z&&Array.isArray(Z.features)?Z.features:[]}),T=new v.o(x),A=E(T);A&&(T.bbox=A),this._fitGeoJSONBounds(T,f)}clearAllLayers(){if(this._map){for(const[f,L]of Object.entries(this._layerGroups))L.forEach(x=>{this._map.getLayer(x)&&this._map.removeLayer(x)}),this._map.getSource(f)&&this._map.removeSource(f);for(const f of this._sourceIds)this._layerGroups[f]||this._deleteSourceIfExists(f)}this._sourceIds=[],this._sourceLayers={},this._sources={},this._attachedListeners=[],this._layerGroups={},this._layerClickable={},this._layers$.next([])}reapplyLayers(){this._map&&(Object.keys(this._sources).forEach(f=>{this._deleteSourceIfExists(f),this._map.addSource(f,this._sources[f]);const L=this._sourceLayers[f];if(L){this._map.addLayer(L.layer);const x=this._layers$.getValue().find(T=>T.id===f);x&&this._updateLayerVisibility(f,x.visible)}}),this._reattachAllLayerEvents())}_extractColorFromLayer(f){if("paint"in f&&"object"==typeof f.paint){const L=f.paint;return L["circle-color"]||L["fill-color"]||L["line-color"]||""}return""}_fitGeoJSONBounds(f,L=50,x=!0,T=19){if(!this._map)return void console.warn("Map not initialized when trying to fit bounds");if(!f.features||0===f.features.length)return void console.warn("No features to fit bounds to");let A=f.bbox;if(!A){const W=E(f);if(!W)return void console.warn("Failed to calculate bbox for GeoJSON");f.bbox=W,A=W}if(A&&4===A.length)try{this._map.fitBounds([[A[0],A[1]],[A[2],A[3]]],{padding:L,maxZoom:T,animate:x})}catch(W){console.error("Error fitting bounds:",W)}}_deleteSourceIfExists(f){if(!this._map||!this._map.getSource(f))return;const x=this._layerGroups[f];if(x)x.forEach(T=>{this._map.getLayer(T)&&this._map.removeLayer(T)});else{const T=Object.values(this._sourceLayers).find(A=>"source"in A.layer&&A.layer.source===f);T&&this._map.getLayer(T.layer.id)&&(this._map.removeLayer(T.layer.id),this._attachedListeners=this._attachedListeners.filter(A=>A!==T.layer.id))}this._map.removeSource(f)}_setLayerEvents(f,L){if(!this._map)return;const x=L.id.endsWith("-fill"),T=L.id.endsWith("-stroke"),A=x?L.id.replace("-fill",""):T?L.id.replace("-stroke",""):L.id;if(x||T){const J=`${A}-stroke`;this._layerClickable[`${A}-fill`]=!0,this._layerClickable[J]=!0}if(!this._layerClickable[L.id])return;const W=[];if(x||T){const Z=`${A}-fill`,J=`${A}-stroke`;this._map.getLayer(Z)&&W.push(Z),this._map.getLayer(J)&&W.push(J)}else W.push(L.id);W.forEach(Z=>{this._attachedListeners.includes(Z)||(this._map.on("click",Z,J=>{if(!J.features||this._processedClickEvents.has(J.originalEvent))return;const oe=J.features[0],ye=oe.properties;if(ye&&!ye.cluster){const fe=this.getLayer(f)||this.getLayer(A)||this.getLayer(Z);if(fe){const he={...oe,geometry:oe.geometry};if(fe.collection&&"features"in fe.collection){const me=fe.collection.features.find(ne=>ne.geometry.type===oe.geometry?.type&&JSON.stringify(ne.properties)===JSON.stringify(oe.properties));me&&me.id&&(he.id=me.id)}this._processedClickEvents.add(J.originalEvent),this.clickedFeature.next({feature:he,event:J.originalEvent,layer:fe,lngLat:J.lngLat})}}}),this._map.on("mouseenter",Z,J=>{if(this._hoverSequence++,this._clearHoverTimeout&&(clearTimeout(this._clearHoverTimeout),this._clearHoverTimeout=void 0),!J.features)return;const oe=J.features[0],ye=oe.properties,fe={...oe,geometry:oe.geometry};if(ye&&!ye.cluster){const he=this.getLayer(f)||this.getLayer(A)||this.getLayer(Z);if(he){if(he.collection&&"features"in he.collection){const me=he.collection.features.find(ne=>ne.geometry.type===oe.geometry?.type&&JSON.stringify(ne.properties)===JSON.stringify(oe.properties));me&&me.id&&(fe.id=me.id)}this.hoveredFeature.next({feature:fe,event:J.originalEvent,layer:he,lngLat:J.lngLat})}this._hoveredFeature.set(fe)}}),this._map.on("mouseleave",Z,()=>{const J=this._hoverSequence;this._clearHoverTimeout=window.setTimeout(()=>{this._hoverSequence===J&&(this._hoveredFeature.set(void 0),this.hoveredFeature.next(void 0)),this._clearHoverTimeout=void 0},50)}),this._map.on("click",Z,J=>{if(!J.features)return;const oe=J.features[0].properties;if(oe&&oe.cluster){const ye=this._map?.getZoom();ye&&this._map?.flyTo({center:J.lngLat,zoom:ye+1})}}),this._attachedListeners.push(Z))})}_reattachAllLayerEvents(){this._attachedListeners=[],Object.keys(this._sourceLayers).forEach(f=>{const L=this._sourceLayers[f];L&&this._setLayerEvents(f,L.layer)})}static \u0275fac=function(L){return new(L||k)};static \u0275prov=m.jDH({token:k,factory:k.\u0275fac})}return k})()},8017(ae,Q,c){"use strict";c.d(Q,{T:()=>St});var O=c(467),m=c(5802),D=c(7705),z=c(2271),s=c(5547),b=c(9769),v=c(5970),R=c(6170),S=c(5949),p=c(2843),a=c(3646),h=c(9079),C=c(1413),F=c(2306),B=c(7089),E=c(9352),w=c(5381),U=c(5187),k=c(5971),X=c(3319);function f(y,I){if(1&y){const l=s.RV6();s.j41(0,"cue-button",5),s.nI1(1,"transloco"),s.bIt("click",function(){m.eBV(l);const _=s.XpG(2);return m.Njj(_.handleZoomFit())}),s.nrm(2,"cue-button-icon",9),s.k0s()}2&y&&s.Y8G("cueTooltip",s.bMT(1,1,"components.map.tooltipZoomFit"))}function L(y,I){if(1&y){const l=s.RV6();s.j41(0,"cue-flexcontainer",3)(1,"cue-button",5),s.nI1(2,"transloco"),s.bIt("click",function(){m.eBV(l);const _=s.XpG();return m.Njj(_.handleZoomOut())}),s.nrm(3,"cue-button-icon",6),s.k0s(),s.j41(4,"cue-button",5),s.nI1(5,"transloco"),s.bIt("click",function(){m.eBV(l);const _=s.XpG();return m.Njj(_.handleZoomIn())}),s.nrm(6,"cue-button-icon",7),s.k0s(),s.nVh(7,f,3,3,"cue-button",8),s.k0s()}if(2&y){const l=s.XpG();s.R7$(),s.Y8G("cueTooltip",s.bMT(2,3,"components.map.tooltipZoomOut")),s.R7$(3),s.Y8G("cueTooltip",s.bMT(5,5,"components.map.tooltipZoomIn")),s.R7$(3),s.vxM(l.displayZoomFit()?7:-1)}}function x(y,I){if(1&y){const l=s.RV6();s.j41(0,"cue-button",10),s.nI1(1,"transloco"),s.nI1(2,"transloco"),s.mxI("selectedChange",function(_){m.eBV(l);const V=s.XpG();return s.DH7(V.layersVisible,_)||(V.layersVisible=_),m.Njj(_)}),s.nrm(3,"cue-button-icon",11),s.k0s()}if(2&y){const l=s.XpG();s.AVh("border-left",l.options().displayZoom&&l.displayLayerToggle()),s.Y8G("cueTooltip",l.layersVisible()?s.bMT(1,6,"components.map.tooltipHideLayers"):s.bMT(2,8,"components.map.tooltipShowLayers"))("toggleButton",!0),s.R50("selected",l.layersVisible),s.R7$(3),s.Y8G("icon",l.layersVisible()?"layers-clear":"layers")}}function T(y,I){if(1&y){const l=s.RV6();s.j41(0,"cue-button",10),s.nI1(1,"transloco"),s.nI1(2,"transloco"),s.mxI("selectedChange",function(_){m.eBV(l);const V=s.XpG();return s.DH7(V.geoFenceDrawEnabled,_)||(V.geoFenceDrawEnabled=_),m.Njj(_)}),s.nrm(3,"cue-button-icon",12),s.k0s()}if(2&y){const l=s.XpG();s.AVh("border-left",l.options().displayGeofenceDraw),s.Y8G("cueTooltip",l.geoFenceDrawEnabled()?s.bMT(1,5,"components.map.tooltipEndDrawGeofence"):s.bMT(2,7,"components.map.tooltipDrawGeofence"))("toggleButton",!0),s.R50("selected",l.geoFenceDrawEnabled)}}let A=(()=>{class y{_service=(0,m.WQX)(S.u);layerService=(0,m.WQX)(a.B);mapLayers=(0,h.ot)(this.layerService.layers);options=(0,D.hFB)(new F.AA);zoom=(0,D.geq)(1);rotate=(0,D.CGW)();geoFenceDrawEnabled=(0,D.geq)(!1);layersVisible=(0,D.geq)(!1);hasLayers=(0,z.EW)(()=>void 0!==this.mapLayers()&&this.mapLayers().length>0);displayLayerToggle=(0,z.EW)(()=>this.options().displayLayerToggle&&this.hasLayers());displayZoomFit=(0,z.EW)(()=>this.options().displayZoom&&this.hasLayers());selectMenuPositions=(0,z.EW)(()=>"top"===this.options().position?"bottomleft":"topleft");handleZoomIn(){this._service.zoomIn()}handleZoomOut(){this._service.zoomOut()}handleZoomFit(){this._service.fitGeoJSONBBOX(void 0,.01)}static \u0275fac=function(u){return new(u||y)};static \u0275cmp=s.VBU({type:y,selectors:[["cue-map-toolbar"]],inputs:{options:[1,"options"],zoom:[1,"zoom"],geoFenceDrawEnabled:[1,"geoFenceDrawEnabled"],layersVisible:[1,"layersVisible"]},outputs:{zoom:"zoomChange",rotate:"rotate",geoFenceDrawEnabled:"geoFenceDrawEnabledChange",layersVisible:"layersVisibleChange"},decls:6,vars:4,consts:[["justify","center",1,"container"],[1,"toolbar",3,"padded"],["align","center"],["align","center","gap","s"],["size","xs","variant","ghost",3,"border-left","cueTooltip","toggleButton","selected"],["size","xs","variant","tertiary",3,"click","cueTooltip"],["icon","zoom-out"],["icon","zoom-in"],["size","xs","variant","tertiary",3,"cueTooltip"],["icon","zoom-fit"],["size","xs","variant","ghost",3,"selectedChange","cueTooltip","toggleButton","selected"],[3,"icon"],["icon","polygon"]],template:function(u,_){1&u&&(s.j41(0,"cue-flexcontainer",0)(1,"cue-card",1)(2,"cue-flexcontainer",2),s.nVh(3,L,8,7,"cue-flexcontainer",3),s.nVh(4,x,4,10,"cue-button",4),s.nVh(5,T,4,9,"cue-button",4),s.k0s()()()),2&u&&(s.R7$(),s.Y8G("padded",!1),s.R7$(2),s.vxM(_.options().displayZoom?3:-1),s.R7$(),s.vxM(_.displayLayerToggle()?4:-1),s.R7$(),s.vxM(_.options().displayGeofenceDraw?5:-1))},dependencies:[w.n,U.Z,k.$,X.a,B.d,E.Kj],styles:[".container[_ngcontent-%COMP%]{width:100%;pointer-events:none}.toolbar[_ngcontent-%COMP%]{pointer-events:all;padding:5px 10px}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return y})();var W=c(7023),Z=c(1024),J=c(9421);function oe(y,I){if(1&y&&s.nrm(0,"cue-key-val",1),2&y){const l=I.$implicit;s.Y8G("key",l.key)("val",l.val)}}let ye=(()=>{class y{props=(0,D.hFB)(null);keyVals=(0,z.EW)(()=>{const l=this.props();return l?Object.entries(l).map(([u,_])=>({key:u,val:String(_)})):[]});static \u0275fac=function(u){return new(u||y)};static \u0275cmp=s.VBU({type:y,selectors:[["cue-props-panel"]],inputs:{props:[1,"props"]},decls:4,vars:0,consts:[[2,"height","100%","overflow-y","auto"],[3,"key","val"]],template:function(u,_){1&u&&(s.j41(0,"cue-flexcontainer",0)(1,"cue-key-val-list"),s.Z7z(2,oe,1,2,"cue-key-val",1,s.Vm6),s.k0s()()),2&u&&(s.R7$(2),s.Dyx(_.keyVals()))},dependencies:[Z.p,J.F,w.n],encapsulation:2,changeDetection:0})}return y})();var fe=c(7517);let he=(()=>{class y{layerService=(0,m.WQX)(a.B);mapLayers=(0,h.ot)(this.layerService.layers);layerDefs=(0,z.EW)(()=>{const l=this.mapLayers();return l?l.map(u=>({label:u.label,color:u.color??"#000000",visible:u.visible,category:u.category})):[]});updateSingle(l){const u=this.mapLayers()?.find(_=>_.label===l.label);u&&this.layerService.toggleVisibility(u.id)}updateAll(l){const u=this.mapLayers();if(u)for(const _ of u)_.visible===l&&this.layerService.toggleVisibility(_.id)}static \u0275fac=function(u){return new(u||y)};static \u0275cmp=s.VBU({type:y,selectors:[["cue-layer-panel"]],decls:1,vars:1,consts:[[3,"layerChange","visibilityAll","layers"]],template:function(u,_){1&u&&(s.j41(0,"cue-layer-legend",0),s.bIt("layerChange",function(Y){return _.updateSingle(Y)})("visibilityAll",function(Y){return _.updateAll(Y)}),s.k0s()),2&u&&s.Y8G("layers",_.layerDefs())},dependencies:[b.MD,fe.P],encapsulation:2})}return y})();var me=c(140),ne=c(6986);function ve(y){const I=y.flatMap(l=>{const u=function De(y){switch(y.type){case"Point":return[y.coordinates[0],y.coordinates[1]];case"MultiPoint":{if(!y.coordinates.length)return null;const I=y.coordinates.reduce((l,u)=>[l[0]+u[0],l[1]+u[1]],[0,0]);return[I[0]/y.coordinates.length,I[1]/y.coordinates.length]}case"LineString":{if(!y.coordinates.length)return null;const I=Math.floor(y.coordinates.length/2);return[y.coordinates[I][0],y.coordinates[I][1]]}case"MultiLineString":{if(!y.coordinates.length||!y.coordinates[0].length)return null;const I=y.coordinates[0],l=Math.floor(I.length/2);return[I[l][0],I[l][1]]}case"Polygon":{if(!y.coordinates.length||!y.coordinates[0].length)return null;const I=y.coordinates[0],l=I.reduce((u,_)=>[u[0]+_[0],u[1]+_[1]],[0,0]);return[l[0]/I.length,l[1]/I.length]}case"MultiPolygon":{if(!y.coordinates.length||!y.coordinates[0]?.length||!y.coordinates[0][0]?.length)return null;const I=y.coordinates[0][0],l=I.reduce((u,_)=>[u[0]+_[0],u[1]+_[1]],[0,0]);return[l[0]/I.length,l[1]/I.length]}default:return null}}(l.geometry);return u?[{type:"Feature",id:l.id,geometry:{type:"Point",coordinates:u},properties:{...l.properties??{},_isCentroid:!0}}]:[]});return[...y,...I]}const ut=["rgba(255, 0, 0, 0.5)","rgba(0, 0, 255, 0.5)","rgba(0, 255, 0, 0.5)","rgba(255, 165, 0, 0.5)","rgba(128, 0, 128, 0.5)","rgba(255, 192, 203, 0.5)","rgba(255, 255, 0, 0.5)"];function _t(y){const I=y.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d\.]+))?\)/);if(I)return{r:parseInt(I[1]),g:parseInt(I[2]),b:parseInt(I[3]),a:I[4]?parseFloat(I[4]):1};const l=y.match(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/);if(l){const u=l[1];return{r:parseInt(3===u.length?u[0]+u[0]:u.slice(0,2),16),g:parseInt(3===u.length?u[1]+u[1]:u.slice(2,4),16),b:parseInt(3===u.length?u[2]+u[2]:u.slice(4,6),16),a:1}}return{r:0,g:0,b:0,a:1}}function je(y){if(0===y.length)return ut[0];if(1===y.length)return y[0].color;const I=y.map(se=>({...se,totalWeight:se.featureCount*se.weight})).sort((se,de)=>de.totalWeight-se.totalWeight),l=I.reduce((se,de)=>se+de.totalWeight,0),u=I[0];if(u.totalWeight/l>.6)return u.color;const _=I.slice(0,Math.min(3,I.length)),V=_.reduce((se,de)=>se+de.totalWeight,0);let Y=0,q=0,le=0,ge=0;for(const se of _){const de=_t(se.color),_e=se.totalWeight/V;Y+=de.r*_e,q+=de.g*_e,le+=de.b*_e,ge+=de.a*_e}return function dt(y,I,l,u=1){return u<1?`rgba(${Math.round(y)}, ${Math.round(I)}, ${Math.round(l)}, ${u})`:`rgb(${Math.round(y)}, ${Math.round(I)}, ${Math.round(l)})`}(Y,q,le,ge)}function He(y,I,l,u){if(!u||"Point"!==l&&"MultiPoint"!==l)return[{color:I,weight:1,featureCount:y.length}];const _=y.length;if(_<10)return[{color:I,weight:1,featureCount:_}];let V=0,Y=0,q=0;_>=750?(V=Math.floor(.1*_),Y=Math.floor(.3*_),q=_-V-Y):_>=100?(Y=Math.floor(.4*_),q=_-Y):(q=Math.floor(.8*_),Y=_-q);const le=[];return q>0&&le.push({color:I,weight:1,featureCount:q}),Y>0&&le.push({color:"#f28cb1",weight:2,featureCount:Y}),V>0&&le.push({color:"#e2f552",weight:3,featureCount:V}),le}function Qe(y,I,l,u,_,V){const Y=Array.isArray(u)?u:[u];(0,ne.j5)(_)?y.layerService.loadGeoJSONLayerGroup(I,l,Y,{cluster:!1,zoomToFit:V.zoomToFit,visible:V.visible,label:V.label,color:V.color}):Y.length>1||("Point"===_||"MultiPoint"===_)&&Array.isArray(Y)&&Y.length>1?y.layerService.loadGeoJSONLayerGroup(I,l,Y,{cluster:(0,ne.n7)(_,V.cluster),zoomToFit:V.zoomToFit,visible:V.visible,label:V.label,color:V.color}):y.loadGeoJSON(I,l,Y[0],(0,ne.n7)(_,V.cluster),V.zoomToFit)}var vt=c(6756),bt=c(356),ft=c(6279);const Xe=["map"],qe=y=>({position:"bottomleft",hoveredFeature:y}),Et=(y,I)=>I.label;function Mt(y,I){if(1&y){const l=s.RV6();s.j41(0,"cue-menu-item",6),s.bIt("click",function(_){const V=m.eBV(l).$implicit;return m.Njj(V.action(_))}),s.EFF(1),s.k0s()}if(2&y){const l=I.$implicit;s.R7$(),s.JRh(l.label)}}function Ct(y,I){if(1&y&&(s.j41(0,"cue-menu-wrap"),s.Z7z(1,Mt,2,1,"cue-menu-item",null,Et),s.k0s()),2&y){const l=s.XpG();s.R7$(),s.Dyx(l.contextMenuItems())}}function et(y,I){if(1&y&&(s.j41(0,"span"),s.EFF(1),s.k0s()),2&y){const l=s.XpG();s.R7$(),s.JRh(l.mapService.error())}}function Lt(y,I){if(1&y){const l=s.RV6();s.j41(0,"cue-map-toolbar",8),s.mxI("zoomChange",function(_){m.eBV(l);const V=s.XpG(2);return s.DH7(V.zoom,_)||(V.zoom=_),m.Njj(_)})("layersVisibleChange",function(_){m.eBV(l);const V=s.XpG(2);return s.DH7(V.layerPanelVisible,_)||(V.layerPanelVisible=_),m.Njj(_)})("geoFenceDrawEnabledChange",function(_){m.eBV(l);const V=s.XpG(2);return s.DH7(V.geoFenceDrawEnabled,_)||(V.geoFenceDrawEnabled=_),m.Njj(_)}),s.k0s()}if(2&y){const l=s.XpG(),u=s.XpG();s.Aen(u.toolbarStyle()),s.Y8G("options",l),s.R50("zoom",u.zoom)("layersVisible",u.layerPanelVisible)("geoFenceDrawEnabled",u.geoFenceDrawEnabled)}}function Tt(y,I){1&y&&s.nVh(0,Lt,1,6,"cue-map-toolbar",7),2&y&&s.vxM(I.hidden?-1:0)}function tt(y,I){1&y&&(s.j41(0,"cue-card",4),s.nrm(1,"cue-layer-panel"),s.k0s())}function Rt(y,I){1&y&&(s.j41(0,"cue-card",5),s.nrm(1,"cue-props-panel",9),s.k0s()),2&y&&(s.R7$(),s.Y8G("props",I))}function nt(y,I){if(1&y&&(s.j41(0,"div",11),s.EFF(1),s.k0s()),2&y){const l=I,u=s.XpG();s.xc7("left",l.x,"px")("top",l.y,"px"),s.R7$(),s.SpI(" ",u," ")}}function Pt(y,I){if(1&y&&s.nVh(0,nt,2,5,"div",10),2&y){let l;const u=s.XpG();s.vxM((l=u.hoveredTooltipPosition())?0:-1,l)}}let St=(()=>{class y{mapService=(0,m.WQX)(S.u);drawService=(0,m.WQX)(p.M);settings=(0,D.hFB)(new F.yY);center=(0,D.hFB)([8.5,47.4]);layerPanelVisible=(0,D.geq)(!1);zoom=(0,D.geq)(2);instruction=(0,D.geq)("Hello");layers=(0,D.hFB)([]);zoomToFit=(0,D.hFB)(!0);zoomToFitEachLayer=(0,D.hFB)(!1);splitLayersByGeometryType=(0,D.hFB)(!0);maxClickZoom=(0,D.hFB)(1/0);borderRadius=(0,D.hFB)("0");geoFenceDrawEnabled=(0,D.geq)(!1);contextMenuItemsBefore=(0,D.hFB)([]);contextMenuItemsAfter=(0,D.hFB)([]);immidiateDrawMode=(0,D.hFB)(void 0);hoverTooltipFn=(0,D.hFB)(null);mapReady=(0,D.CGW)();clickedMap=(0,D.CGW)();pannedMap=(0,D.CGW)();panningMap=(0,D.CGW)();zoomedMap=(0,D.CGW)();clickedFeature=(0,D.CGW)();hoveredFeature=(0,D.CGW)();drawEvent=(0,D.CGW)();layersSaturated=(0,z.EW)(()=>this.layers().map((l,u)=>{const _={...l};return _.color||(_.color=vt.BK[u]),_}));toolbarOptions=(0,z.EW)(()=>this.settings().toolbar);featureBeingHovered=(0,m.vPA)(void 0);lastClickedFeatureEvent=(0,m.vPA)(void 0);lastHoveredFeatureEvent=(0,m.vPA)(void 0);shownProperties=(0,m.vPA)(null);hoveredTooltipLabel=(0,z.EW)(()=>{const l=this.hoverTooltipFn();if(!l)return null;const u=this.lastHoveredFeatureEvent();return u?l(u.feature.properties??{})??null:null});hoveredTooltipPosition=(0,z.EW)(()=>{if(!this.hoveredTooltipLabel())return null;const l=this.lastHoveredFeatureEvent();if(!l)return null;const u=this.mapService.map;if(!u)return null;const _=u.project([l.lngLat.lng,l.lngLat.lat]);return{x:_.x,y:_.y}});_featureClickedThisTick=!1;_previousLayersHash=(0,m.vPA)("");_userHasInteracted=(0,m.vPA)(!1);toolbarStyle=(0,z.EW)(()=>{const l=this.toolbarOptions();return{position:"absolute",left:l.margin,right:l.margin,["top"===l.position?"top":"bottom"]:l.margin,"z-index":"10",display:"flex","justify-content":"center"}});contextMenuEnabled=(0,z.EW)(()=>{const l=this.contextMenuItems().length>0,u=this.featureBeingHovered(),_=this.lastClickedFeatureEvent();return l&&(void 0!==u||void 0!==_)});contextMenuItems=(0,z.EW)(()=>{const l=this.lastHoveredFeatureEvent(),u=this.lastClickedFeatureEvent(),V=(l?.feature||u?.feature)?.properties||null,Y=V?Object.fromEntries(Object.entries(V).filter(([_e])=>!_e.startsWith("_"))):null,q=l?.lngLat||u?.lngLat||null,ge=[...this.contextMenuItemsBefore()||[]],se=this.settings().contextMenu;Y&&Object.keys(Y).length>0&&se.showProperties&&ge.push({label:"Show properties",action:()=>{this.shownProperties.update(()=>Y)}}),q&&se.showFlyTo&&ge.push({label:"Fly to feature",action:()=>{this.mapService.flyTo([q.lng,q.lat],this.zoom())}});const de=this.contextMenuItemsAfter()||[];return[...ge,...de]});_mapContainer;_destroy$=new C.B;constructor(){this._subscribeToServiceOutputs(),this._setupEffects(),(0,s.mal)(()=>{this._destroy$.closed||this._tryInitializeMap()})}ngOnDestroy(){this._destroy$.next(),this._destroy$.complete(),this.drawService.destroy(),this.mapService.destroy()}_subscribeToServiceOutputs(){this.mapService.mapReady.pipe((0,h.pQ)()).subscribe(()=>this.mapReady.emit()),this.mapService.clickedMap.pipe((0,h.pQ)()).subscribe(l=>{this._featureClickedThisTick||(this.lastClickedFeatureEvent.update(()=>{}),this.lastHoveredFeatureEvent.update(()=>{}),this.featureBeingHovered.update(()=>{}),this.clickedMap.emit(l),this.shownProperties.update(()=>null))}),this.mapService.pannedMap.pipe((0,h.pQ)()).subscribe(l=>{this._userHasInteracted.set(!0),this.pannedMap.emit(l)}),this.mapService.panningMap.pipe((0,h.pQ)()).subscribe(l=>this.panningMap.emit(l)),this.mapService.zoomedMap.pipe((0,h.pQ)()).subscribe(l=>{this._userHasInteracted.set(!0),this.zoomedMap.emit(this.mapService.getZoom()??this.zoom())}),this.mapService.clickedFeature.pipe((0,h.pQ)()).subscribe(l=>{this._featureClickedThisTick=!0,queueMicrotask(()=>{this._featureClickedThisTick=!1}),this.lastClickedFeatureEvent.update(()=>l),this.clickedFeature.emit(l);const u=l.feature?.geometry?.type,_="Point"===u||"MultiPoint"===u,V=this.mapService.getZoom()??0,Y=this.contextMenuItems().length>0;_&&!Y&&V<this.maxClickZoom()&&this.mapService.zoomToCoordinate(l.lngLat)}),this.mapService.hoveredFeature.pipe((0,h.pQ)()).subscribe(l=>{this.featureBeingHovered.update(()=>l?.feature),this.lastHoveredFeatureEvent.update(()=>l),this.hoveredFeature.emit(l)})}_setupEffects(){var l=this;(0,m.QZP)(()=>{"polygon"===this.immidiateDrawMode()&&(this.geoFenceDrawEnabled.set(!0),setTimeout(()=>{this.drawService.setDrawMode(!0,this.settings().toolbar.clearGeofenceAfterDraw)},500))}),(0,m.QZP)(()=>this.mapService.flyTo(this.center(),this.zoom())),(0,m.QZP)(()=>{const _=this.settings()?.mapboxToken;_&&"string"==typeof _&&""!==_.trim()&&!this.mapService.isMapReady()&&this._tryInitializeMap()}),(0,m.QZP)(()=>{const u=this.geoFenceDrawEnabled();this.drawService.setDrawMode(u,this.settings().toolbar.clearGeofenceAfterDraw)}),(0,m.QZP)(()=>{const u=this.drawService.drawEvent();void 0!==u&&this.drawEvent.emit(u)}),(0,m.QZP)((0,O.A)(function*(){const u=l.layersSaturated();if(!u||0===u.length)return;const _=l._createLayersHash(u);if(_===l._previousLayersHash())return;l._previousLayersHash.set(_),yield l.mapService.waitForMapReady(),l.mapService.clearLayers();const Y=l.zoomToFitEachLayer();u.forEach((q,le)=>{!function Be(y,I,l,u,_,V,Y){const q=I.collection,le=I.color??ut[l];let ge;ge="geometries"in q?function Re(y){const I=y.geometries.map((u,_)=>({type:"Feature",geometry:u,properties:{},id:y.id?`${y.id}_${_}`:void 0})),l=new me.o(I);return l.id=y.id,l.bbox=y.bbox,l}(q):q;const se=function Ae(y){const I=[];return y.forEach(l=>{l.geometry&&"GeometryCollection"===l.geometry.type?l.geometry.geometries.forEach((u,_)=>{I.push({type:"Feature",geometry:u,properties:l.properties||{},id:l.id?`${l.id}_${_}`:void 0})}):I.push(l)}),I}(ge.features),de=new me.o(se);de.id=ge.id,de.bbox=ge.bbox;let _e=le;if(!V){const H=I.id.toString(),ee=se[0]?.geometry?.type||"Point";_e=je(He(se,le,ee,u));let be=Y(H,ee,_e,H),Se=de;const ke="Point"!==ee&&"MultiPoint"!==ee,Me=(0,ne.j5)(ee),pe=(0,ne.dx)(ee);if(u&&ke&&!Me&&!pe&&be){const ot=Array.isArray(be)?be:[be],ie=ve(se);Se=new me.o(ie),Se.id=de.id,Se.bbox=de.bbox,be=[(0,ne.g8)(`${H}-centroid`,H,_e),...ot.map(it=>({...it,minzoom:ne.A4}))]}return void(be&&Qe(y,H,Se,be,ee,{cluster:u,zoomToFit:_,visible:!0,label:I.label||I.id.toString(),color:_e}))}if(V){const H=new Set(se.map(re=>re.geometry.type)),ee=[];return H.forEach(re=>{const be=`${I.id.toString()}-${re}`,Se=se.filter(pe=>pe.geometry.type===re),ke=He(Se,le,re,u);ee.push(...ke);let Me=Y(be,re,le,be);if(Me){let pe=new me.o(Se);pe.id=de.id,pe.bbox=de.bbox;const ot="Point"!==re&&"MultiPoint"!==re,ie=(0,ne.j5)(re),rt=(0,ne.dx)(re);if(u&&ot&&!ie&&!rt){const it=Array.isArray(Me)?Me:[Me],It=ve(Se);pe=new me.o(It),pe.id=de.id,pe.bbox=de.bbox,Me=[(0,ne.g8)(`${be}-centroid`,be,le),...it.map(st=>({...st,minzoom:ne.A4}))]}Qe(y,be,pe,Me,re,{cluster:u,zoomToFit:_,visible:!0,label:H.size>1?`${I.label||I.id} (${re})`:`${I.label||I.id}`,color:le})}}),void(ee.length>0&&(_e=je(ee),y.layerService.getLayer(I.id.toString())&&y.layerService.updateLayer(I.id.toString(),{color:_e})))}const Ee=new Map;se.forEach(H=>{const ee=H.geometry.type;let re;re="Point"===ee||"MultiPoint"===ee?"Point":"LineString"===ee||"MultiLineString"===ee?"LineString":"Polygon"===ee||"MultiPolygon"===ee?"Polygon":ee,Ee.has(re)||Ee.set(re,[]),Ee.get(re).push(ee)});const Ne=[];Ee.forEach((H,ee)=>{const re=`${I.id.toString()}-${ee}`,be=se.filter(Me=>{const pe=Me.geometry.type;return"Point"===ee?"Point"===pe||"MultiPoint"===pe:"LineString"===ee?"LineString"===pe||"MultiLineString"===pe:"Polygon"===ee?"Polygon"===pe||"MultiPolygon"===pe:pe===ee}),Se=He(be,le,ee,u);Ne.push(...Se);const ke=Y(re,ee,le,re);if(ke){const Me=new me.o(be);Me.id=de.id,Me.bbox=de.bbox,Qe(y,re,Me,ke,ee,{cluster:u,zoomToFit:_,visible:!0,label:Ee.size>1?`${I.label||I.id} (${ee})`:`${I.label||I.id}`,color:le})}}),Ne.length>0&&(_e=je(Ne),y.layerService.getLayer(I.id.toString())&&y.layerService.updateLayer(I.id.toString(),{color:_e}))}(l.mapService,q,le,q.cluster,Y&&q.zoomToFit,l.splitLayersByGeometryType(),ne.Ln)}),l.zoomToFit()&&!Y&&!l._userHasInteracted()&&l.mapService.fitGeoJSONBBOX()}))}_tryInitializeMap(){if(this._destroy$.closed)return;const u=this.settings()?.mapboxToken,_=u&&"string"==typeof u&&""!==u.trim(),V=this._mapContainer,Y=!this.mapService.isMapReady();_&&V&&Y&&(this._userHasInteracted.set(!1),this.mapService.init(this._mapContainer.nativeElement,u,this.center(),this.zoom(),this.borderRadius()))}_createLayersHash(l){return l.map(u=>{const _=u.collection;let V=0;return _&&"FeatureCollection"===_.type&&"features"in _&&(V=Array.isArray(_.features)?_.features.length:0),`${u.id}|${u.label}|${u.visible}|${V}`}).join("::")}static \u0275fac=function(u){return new(u||y)};static \u0275cmp=s.VBU({type:y,selectors:[["cue-map"]],viewQuery:function(u,_){if(1&u&&s.GBs(Xe,5),2&u){let V;s.mGM(V=s.lsd())&&(_._mapContainer=V.first)}},hostAttrs:["data-component","cue-map-main"],inputs:{settings:[1,"settings"],center:[1,"center"],layerPanelVisible:[1,"layerPanelVisible"],zoom:[1,"zoom"],instruction:[1,"instruction"],layers:[1,"layers"],zoomToFit:[1,"zoomToFit"],zoomToFitEachLayer:[1,"zoomToFitEachLayer"],splitLayersByGeometryType:[1,"splitLayersByGeometryType"],maxClickZoom:[1,"maxClickZoom"],borderRadius:[1,"borderRadius"],geoFenceDrawEnabled:[1,"geoFenceDrawEnabled"],contextMenuItemsBefore:[1,"contextMenuItemsBefore"],contextMenuItemsAfter:[1,"contextMenuItemsAfter"],immidiateDrawMode:[1,"immidiateDrawMode"],hoverTooltipFn:[1,"hoverTooltipFn"]},outputs:{layerPanelVisible:"layerPanelVisibleChange",zoom:"zoomChange",instruction:"instructionChange",geoFenceDrawEnabled:"geoFenceDrawEnabledChange",mapReady:"mapReady",clickedMap:"clickedMap",pannedMap:"pannedMap",panningMap:"panningMap",zoomedMap:"zoomedMap",clickedFeature:"clickedFeature",hoveredFeature:"hoveredFeature",drawEvent:"drawEvent"},features:[s.Jv_([S.u,p.M,a.B])],decls:10,vars:10,consts:[["hoveringFeature",""],["map",""],["direction","row",1,"container"],["id","map","cueResized","","cueDarkMode","","trigger","leftclick",3,"darkModeChange","resized","cueContextMenu","contextMenuData","cueContextEnabled"],[1,"layer-panel"],[1,"props-panel"],[3,"click"],[3,"options","style","zoom","layersVisible","geoFenceDrawEnabled"],[3,"zoomChange","layersVisibleChange","geoFenceDrawEnabledChange","options","zoom","layersVisible","geoFenceDrawEnabled"],[3,"props"],[1,"hover-tooltip",3,"left","top"],[1,"hover-tooltip"]],template:function(u,_){if(1&u&&(s.DNE(0,Ct,3,0,"ng-template",null,0,s.C5r),s.j41(2,"cue-flexcontainer",2)(3,"div",3,1),s.bIt("darkModeChange",function(Y){return _.mapService.setDarkMode(Y)})("resized",function(){return _.mapService.onParentResize()}),s.k0s(),s.nVh(5,et,2,1,"span"),s.nVh(6,Tt,1,1),s.nVh(7,tt,2,0,"cue-card",4),s.nVh(8,Rt,2,1,"cue-card",5),s.nVh(9,Pt,1,1),s.k0s()),2&u){let V,Y,q;const le=s.sdS(1);s.R7$(3),s.Y8G("cueContextMenu",le)("contextMenuData",s.eq3(8,qe,_.lastHoveredFeatureEvent()))("cueContextEnabled",_.contextMenuEnabled()),s.R7$(2),s.vxM(_.mapService.error()?5:-1),s.R7$(),s.vxM((V=_.toolbarOptions())?6:-1,V),s.R7$(),s.vxM(_.layerPanelVisible()?7:-1),s.R7$(),s.vxM((Y=_.shownProperties())?8:-1,Y),s.R7$(),s.vxM((q=_.hoveredTooltipLabel())?9:-1,q)}},dependencies:[b.MD,v.C,R.R,A,W.Q,bt.M,ft.D,w.n,ye,he,U.Z],styles:["#map[_ngcontent-%COMP%]{flex:1;min-height:0;border-radius:inherit;overflow:hidden}[_nghost-%COMP%]{display:flex;flex-direction:column;position:relative;width:100%;height:100%;min-height:400px;min-width:200px;flex:1 1 auto;align-self:stretch;box-sizing:border-box;overflow:hidden;border-radius:var(--cue-card-border-radius, inherit)}.mapboxgl-canvas-container[_ngcontent-%COMP%], .mapboxgl-canvas[_ngcontent-%COMP%]{border-radius:inherit!important}.mapboxgl-map[_ngcontent-%COMP%]{border-radius:inherit!important;overflow:hidden!important}.container[_ngcontent-%COMP%]{position:relative;width:100%;flex:1;min-height:0;overflow:hidden;display:flex;flex-direction:column}.props-panel[_ngcontent-%COMP%]{position:absolute;top:8px;right:8px;bottom:8px;z-index:10}.layer-panel[_ngcontent-%COMP%]{position:absolute;top:10px;left:10px;z-index:10}cue-map-toolbar[_ngcontent-%COMP%]{position:absolute;left:0;right:0;bottom:0;z-index:10;display:flex;justify-content:center}.hover-tooltip[_ngcontent-%COMP%]{position:absolute;background:var(--cue-menu-background-color);color:var(--cue-menu-foreground-color);box-shadow:var(--cue-menu-box-shadow);border:1px solid var(--cue-menu-border-color);padding:3px 8px;border-radius:4px;font-family:var(--cue-font-family);font-size:.75rem;line-height:1.4;pointer-events:none;white-space:nowrap;z-index:20;transform:translate(-50%,calc(-100% - 8px))}"]})}return y})()},5949(ae,Q,c){"use strict";c.d(Q,{u:()=>R});var O=c(467),m=c(5802),D=c(2271),z=c(1413),s=c(3646),b=c(2843),v=c(9079);let R=(()=>{class S{_map;_mapContainer;_isInitializing=!1;_mapReadyPromiseResolve;_mapReady=new Promise(a=>{this._mapReadyPromiseResolve=a});_emittedReady=!1;_firstThemeReceived=!1;_hoveredFeature=(0,m.vPA)(void 0);_layerService=(0,m.WQX)(s.B);_drawService=(0,m.WQX)(b.M);mapboxToken=(0,m.vPA)("");center=(0,m.vPA)([8.5,47.4]);zoom=(0,m.vPA)(2);borderRadius=(0,m.vPA)("0");mapReady=new z.B;clickedMap=new z.B;pannedMap=new z.B;panningMap=new z.B;zoomedMap=new z.B;error=(0,m.vPA)("");get clickedFeature(){return this._layerService.clickedFeature}get hoveredFeature(){return this._layerService.hoveredFeature}get layers(){return this._layerService.layers}get layersSignal(){return this._layerService.layersSignal}get layerService(){return this._layerService}get drawService(){return this._drawService}get drawEvent(){return this._drawService.drawEvent}_darkMode=(0,m.vPA)(this._getSystemColorPreference());_styleId=(0,D.EW)(()=>this._darkMode()?"madsholten/clwjh4xeu00q601pnczm07jq6":"madsholten/clwjh6ug900q701pn6eor8p51");get map(){return this._map}constructor(){this._layerService.hoveredFeature.pipe((0,v.pQ)()).subscribe(a=>{this._hoveredFeature.set(a?.feature)}),(0,m.QZP)(()=>{this._styleId(),this._firstThemeReceived?void 0!==this._map&&this._updateStyle().catch(a=>{console.error("Failed to update map style:",a)}):this._firstThemeReceived=!0})}destroy(){if(this._layerService?.clearAllLayers(),this._drawService?.destroy(),this._map)try{this._map.remove()}catch(a){console.warn("Error removing map:",a)}this._map=void 0,this._mapContainer&&(this._mapContainer.innerHTML="",this._mapContainer=void 0),this._isInitializing=!1,this._emittedReady=!1,this._mapReady=new Promise(a=>{this._mapReadyPromiseResolve=a})}isMapReady(){return void 0!==this._map&&this._emittedReady&&!this._isInitializing}waitForMapReady(){var a=this;return(0,O.A)(function*(){return a._mapReady})()}init(a,h,C,F,B){var E=this;return(0,O.A)(function*(){if(h&&""!==h.trim())if(E._map||E._isInitializing)console.warn("MapService: Map is already initialized or currently initializing");else{E._isInitializing=!0,E.mapboxToken.set(h),E.center.set(C),E.zoom.set(F),E.borderRadius.set(B),E._mapContainer=a,E._mapContainer&&(E._mapContainer.innerHTML="");try{yield E._loadMapboxCSS();const w=yield c.e(247).then(c.t.bind(c,1247,23)),U=w.default||w;if(!U||"function"!=typeof U.Map)throw new Error("Mapbox GL JS not properly loaded");U.accessToken=E.mapboxToken(),E._map=new U.Map({container:a,style:E._getMapStyleURL(),center:E.center(),zoom:E.zoom()}),E._applyBorderRadius(a),E._initEventListeners(E._map)}catch(w){console.error("Failed to load mapbox-gl:",w),E.error.set("Failed to load map library. Please ensure mapbox-gl is installed.")}finally{E._isInitializing=!1}}else console.warn("MapService: Cannot initialize map without valid mapbox token")})()}loadGeoJSON(a,h,C){var F=this;return(0,O.A)(function*(B,E,w,U=!0,k=!0){return yield F._mapReady,F._layerService.loadGeoJSONLayer(B,E,w,{cluster:U,zoomToFit:k,visible:!0,label:B})}).apply(this,arguments)}fitGeoJSONBBOX(a){var h=this;return(0,O.A)(function*(C,F=50,B=!0,E=19){yield h._mapReady,C?h._layerService.fitGeoJSONBounds(C,F,B,E):h._layerService.fitAllVisibleLayers(F)}).apply(this,arguments)}jumpTo(a,h){this._map?.jumpTo({center:a,zoom:h??this.zoom()})}setDarkMode(a){this._darkMode.set(a)}zoomToCoordinate(a){const h=this._map?.getZoom();if(!h)return;const C=h+1;this._map?.flyTo({center:a,zoom:C})}getZoom(){return this._map?.getZoom()}flyTo(a,h,C){this._map?.flyTo({center:a,zoom:h??this.zoom(),essential:!0,padding:C})}zoomIn(){if(!this._map)return;const a=this._map.getZoom();this._map.flyTo({zoom:a+1})}zoomOut(){if(!this._map)return;const a=this._map.getZoom();this._map.flyTo({zoom:a-1})}clearLayers(){this._layerService.clearAllLayers()}getImage(){const a=this._map?.getCanvas();if(void 0!==a)return a.toDataURL("image/png")}onParentResize(){this._map?.resize()}_loadMapboxCSS(){return(0,O.A)(function*(){return new Promise((a,h)=>{if(document.querySelector('link[href*="mapbox-gl.css"]'))return void a();const C=document.createElement("link");C.rel="stylesheet",C.href="https://api.mapbox.com/mapbox-gl-js/v3.3.0/mapbox-gl.css",C.onload=()=>a(),C.onerror=()=>{const F=document.createElement("link");F.rel="stylesheet",F.href="node_modules/mapbox-gl/dist/mapbox-gl.css",F.onload=()=>a(),F.onerror=()=>h(new Error("Failed to load Mapbox CSS")),document.head.appendChild(F)},document.head.appendChild(C)})})()}_applyBorderRadius(a){const h=this.borderRadius();let C=h;if("0"===h){const B=a.closest("cue-map")?.parentElement;B&&(C=getComputedStyle(B).borderRadius||"0")}"0"!==C&&(a.style.borderRadius=C,a.style.overflow="hidden",setTimeout(()=>{const F=a.querySelector(".mapboxgl-canvas"),B=a.querySelector(".mapboxgl-canvas-container"),E=a.querySelector(".mapboxgl-map");F&&(F.style.borderRadius=C),B&&(B.style.borderRadius=C),E&&(E.style.borderRadius=C)},100))}_initEventListeners(a){a.on("click",h=>{void 0===this._hoveredFeature()&&this.clickedMap.next(h)}),a.on("drag",h=>{void 0===this._hoveredFeature()&&this.panningMap.next(h)}),a.on("dragend",h=>{void 0===this._hoveredFeature()&&this.pannedMap.next(h)}),a.on("zoomend",h=>{this.zoomedMap.next(h)}),a.on("load",()=>{this._emittedReady||(this._layerService.initializeWithMap(a),this._drawService.initializeWithMap(a),this._mapReadyPromiseResolve(),this.mapReady.next(),this._emittedReady=!0)}),a.on("error",h=>{this.error.set(h.error.message)})}_getMapStyleURL(){return`mapbox://styles/${this._styleId()}`}_updateStyle(){var a=this;return(0,O.A)(function*(){if(void 0===a._map)return;const h=a._map.getZoom(),C=a._map.getCenter();void 0!==a._mapContainer&&(yield a.init(a._mapContainer,a.mapboxToken(),C,h,a.borderRadius()),setTimeout(()=>{a._layerService.reapplyLayers(),a._map?.flyTo({center:C,zoom:h})},500))})()}_getSystemColorPreference(){return typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches}static \u0275fac=function(h){return new(h||S)};static \u0275prov=m.jDH({token:S,factory:S.\u0275fac})}return S})()},2306(ae,Q,c){"use strict";c.d(Q,{AA:()=>z,ux:()=>s,yY:()=>D});var O=c(140),m=c(8402);class D{mapboxToken;contextMenu={showProperties:!0,showFlyTo:!0};toolbar=new z}class z{hidden=!1;position="bottom";margin="20px";displayZoom=!0;displayGeofenceDraw=!1;displayLayerToggle=!0;clearGeofenceAfterDraw=!0}class s{label;id;collection=new O.o;color;visible=!0;cluster=!0;zoomToFit=!0;category;constructor(v,R=(0,m.A)()){this.label=v,this.id=R}}},8334(ae,Q,c){"use strict";c.d(Q,{o:()=>z});var O=c(7705),m=c(5547);const D=["*"];let z=(()=>{class s{label=O.hFB.required();active=(0,O.geq)(!1);static \u0275fac=function(R){return new(R||s)};static \u0275cmp=m.VBU({type:s,selectors:[["cue-tab"]],hostVars:1,hostBindings:function(R,S){2&R&&m.Avn("hidden",!S.active())},inputs:{label:[1,"label"],active:[1,"active"]},outputs:{active:"activeChange"},ngContentSelectors:D,decls:1,vars:0,template:function(R,S){1&R&&(m.NAR(),m.SdG(0))},styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0}[hidden][_nghost-%COMP%]{display:none!important}"]})}return s})()},6455(ae,Q,c){"use strict";c.d(Q,{t:()=>F});var O=c(7705),m=c(5802),D=c(2271),z=c(8334),s=c(5187),b=c(9769),v=c(5547);const R=["*"],S=(B,E)=>E.label();function p(B,E){if(1&B&&(v.j41(0,"cue-card",1),v.eu8(1,2),v.k0s()),2&B){const w=v.XpG(),U=v.sdS(3);v.Y8G("variant",w._cardVariant())("padded",!1),v.R7$(),v.Y8G("ngTemplateOutlet",U)}}function a(B,E){if(1&B&&v.eu8(0,2),2&B){v.XpG();const w=v.sdS(3);v.Y8G("ngTemplateOutlet",w)}}function h(B,E){if(1&B){const w=v.RV6();v.j41(0,"button",6),v.bIt("click",function(){const k=m.eBV(w).$index,X=v.XpG(2);return m.Njj(X.setActive(k))}),v.EFF(1),v.k0s()}if(2&B){const w=E.$implicit,U=E.$index,k=v.XpG(2);v.AVh("active",k.activeIndex()===U),v.R7$(),v.SpI(" ",w.label()," ")}}function C(B,E){if(1&B&&(v.j41(0,"div",3),v.Z7z(1,h,2,3,"button",4,S),v.k0s(),v.j41(3,"div",5),v.SdG(4),v.k0s()),2&B){const w=v.XpG();v.R7$(),v.Dyx(w.tabs())}}let F=(()=>{class B{tabs=(0,O.tEk)(z.o);activeIndex=(0,m.vPA)(0);variant=(0,O.hFB)("none");_cardVariant=(0,D.EW)(()=>"none"===this.variant()?"default":this.variant());constructor(){(0,m.QZP)(()=>{const w=this.tabs(),U=this.activeIndex();w.forEach((k,X)=>k.active.set(X===U))})}setActive(w){this.activeIndex.set(w)}static \u0275fac=function(U){return new(U||B)};static \u0275cmp=v.VBU({type:B,selectors:[["cue-tabs"]],contentQueries:function(U,k,X){1&U&&v.C6U(X,k.tabs,z.o,4),2&U&&v.NyB()},inputs:{variant:[1,"variant"]},ngContentSelectors:R,decls:4,vars:1,consts:[["inner",""],[2,"height","100%","width","100%","display","flex","flex-direction","column","overflow","hidden",3,"variant","padded"],[3,"ngTemplateOutlet"],[1,"tabs-header"],[1,"tab-button",3,"active"],[1,"tabs-content"],[1,"tab-button",3,"click"]],template:function(U,k){1&U&&(v.NAR(),v.nVh(0,p,2,3,"cue-card",1)(1,a,1,1,"ng-container",2),v.DNE(2,C,5,0,"ng-template",null,0,v.C5r)),2&U&&v.vxM("none"!==k.variant()?0:1)},dependencies:[s.Z,b.T3],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;box-sizing:border-box;border-radius:var(--cue-card-border-radius);border:1px solid var(--cue-card-border-color);background-color:var(--cue-default);color:var(--cue-defaultContrast);overflow:hidden}.tabs-header[_ngcontent-%COMP%]{display:flex;border-bottom:1px solid var(--cue-card-border-color);background-color:var(--background-color, var(--cue-default))}.tab-button[_ngcontent-%COMP%]{padding:10px 16px;background:none;border:none;border-bottom:2px solid transparent;cursor:pointer;color:inherit;font-family:var(--cue-font-family);font-size:var(--cue-font-s-size);line-height:var(--cue-font-s-line-height);opacity:.6;transition:opacity .15s,border-bottom-color .15s}.tab-button[_ngcontent-%COMP%]:hover{opacity:.9}.tab-button.active[_ngcontent-%COMP%]{border-bottom-color:currentColor;opacity:1;font-weight:500}.tabs-content[_ngcontent-%COMP%]{padding:var(--cue-card-padding-y) var(--cue-card-padding-x);flex:1;min-height:0;box-sizing:border-box;display:flex;flex-direction:column}"]})}return B})()},7335(ae,Q,c){"use strict";c.d(Q,{e:()=>R});var O=c(7705),m=c(5547),D=c(5802),z=c(8359),s=c(6939),b=c(63),v=c(4853);let R=(()=>{class S{_targetEl=(0,D.WQX)(m.aKT);_overlay=(0,D.WQX)(b.hJ);_overlayRef;_isOverlayHovered=!1;_subscriptions;display=(0,O.hFB)("on-hover");menuItems=O.hFB.required();menuEnabled=(0,O.hFB)(!0);onMouseEnter(){if("on-hover"===this.display()){if(!this.menuItems().length)return void this.removeOverlayMenu();this.appendOverlayMenu()}}onMouseLeave(){this._checkShouldRemoveOverlay()}appendOverlayMenu(){if(!this.menuItems().length||this._overlayRef)return;const a=this._overlay.create({positionStrategy:this._overlay.position().flexibleConnectedTo(this._targetEl).withPositions([{originX:"end",originY:"center",overlayX:"start",overlayY:"center",offsetX:2,offsetY:0}])});this._overlayRef=a;const h=window.getComputedStyle(this._targetEl.nativeElement).color;a.overlayElement.style.color=h;const C=new s.A8(v.H),F=a.attach(C);F.instance.items=this.menuItems,this._subscriptions&&this._subscriptions.unsubscribe(),this._subscriptions=new z.yU,this._subscriptions.add(F.instance.mouseEnter.subscribe(()=>{this._isOverlayHovered=!0})),this._subscriptions.add(F.instance.mouseLeave.subscribe(()=>{this._isOverlayHovered=!1,this._checkShouldRemoveOverlay()}))}removeOverlayMenu(){this._overlayRef&&(this._subscriptions&&(this._subscriptions.unsubscribe(),this._subscriptions=void 0),this._overlayRef.detach(),this._overlayRef.dispose(),this._overlayRef=void 0)}_checkShouldRemoveOverlay(){setTimeout(()=>{this._isOverlayHovered||this.removeOverlayMenu()},300)}static \u0275fac=function(h){return new(h||S)};static \u0275dir=m.FsC({type:S,selectors:[["","cueEntityMenu",""]],hostBindings:function(h,C){1&h&&m.bIt("mouseenter",function(){return C.onMouseEnter()})("mouseleave",function(){return C.onMouseLeave()})},inputs:{display:[1,"display"],menuItems:[1,"menuItems"],menuEnabled:[1,"menuEnabled"]}})}return S})()},140(ae,Q,c){"use strict";c.d(Q,{o:()=>O});class O{type="FeatureCollection";features=[];bbox;id;constructor(D=[]){this.features=D}addFeature(D){this.features.push(D)}removeFeature(D){return this.features.splice(D,1)[0]}getFeatureCount(){return this.features.length}clear(){this.features=[]}}},58(ae,Q,c){"use strict";function O(a){let h=0,C=-1,F=-1;for(let B=0;B<a.length;B++)if("("===a[B])h++,1===h&&(C=B+1);else if(")"===a[B]&&(h--,0===h)){F=B;break}return-1!==C&&-1!==F?a.substring(C,F):null}c.d(Q,{S:()=>S,n:()=>p});class m{x;y;z;constructor(h,C,F){this.x=h,this.y=C,this.z=F}}class D{points;constructor(h){this.points=h}}class z{lines;constructor(h){this.lines=h}}function S(a){if(a){if((a=a.trim().toUpperCase()).startsWith("POINT"))return function b(a){a=a.trim().toUpperCase();const C=O(a)?.split(" ")??[];return a.includes("POINT Z")?new m(parseFloat(C[0]),parseFloat(C[1]),parseFloat(C[2])):new m(parseFloat(C[0]),parseFloat(C[1]))}(a);if(a.startsWith("LINESTRING"))return function s(a){const h=O(a=a.trim().toUpperCase()),C=[];return h?.split(",").map(F=>F.trim().split(" ").map(B=>parseFloat(B))).map(F=>{C.push(new m(F[0],F[1],F[2]))}),new D(C)}(a);if(a.startsWith("POLYGON"))return function v(a){const h=O(a=a.trim().toUpperCase());if(!h)return new z([]);const C=h.match(/\(([^)]+)\)/g);if(!C)return new z([]);const F=C.map(B=>{const E=O(B);return E?E.split(",").map(w=>{const U=w.trim().split(" ");return U.length>=3?new m(parseFloat(U[0]),parseFloat(U[1]),parseFloat(U[2])):new m(parseFloat(U[0]),parseFloat(U[1]))}):[]});return new z(F)}(a)}}function p(a){if(a instanceof m)return{type:"Point",coordinates:void 0!==a.z?[a.x,a.y,a.z]:[a.x,a.y]};if(a instanceof D)return{type:"LineString",coordinates:a.points.map(h=>void 0!==h.z?[h.x,h.y,h.z]:[h.x,h.y])};if(a instanceof z)return{type:"Polygon",coordinates:a.lines.map(h=>h.map(C=>void 0!==C.z?[C.x,C.y,C.z]:[C.x,C.y]))};throw new Error("Unknown WKT type")}},362(ae){"use strict";ae.exports=function Q(c,O){if(c===O)return!0;if(c&&O&&"object"==typeof c&&"object"==typeof O){if(c.constructor!==O.constructor)return!1;var m,D,z;if(Array.isArray(c)){if((m=c.length)!=O.length)return!1;for(D=m;0!==D--;)if(!Q(c[D],O[D]))return!1;return!0}if(c.constructor===RegExp)return c.source===O.source&&c.flags===O.flags;if(c.valueOf!==Object.prototype.valueOf)return c.valueOf()===O.valueOf();if(c.toString!==Object.prototype.toString)return c.toString()===O.toString();if((m=(z=Object.keys(c)).length)!==Object.keys(O).length)return!1;for(D=m;0!==D--;)if(!Object.prototype.hasOwnProperty.call(O,z[D]))return!1;for(D=m;0!==D--;){var s=z[D];if(!Q(c[s],O[s]))return!1}return!0}return c!=c&&O!=O}},5332(ae,Q,c){"use strict";c.d(Q,{k:()=>z});for(var m=[],D=0;D<256;++D)m.push((D+256).toString(16).slice(1));function z(v,R=0){return(m[v[R+0]]+m[v[R+1]]+m[v[R+2]]+m[v[R+3]]+"-"+m[v[R+4]]+m[v[R+5]]+"-"+m[v[R+6]]+m[v[R+7]]+"-"+m[v[R+8]]+m[v[R+9]]+"-"+m[v[R+10]]+m[v[R+11]]+m[v[R+12]]+m[v[R+13]]+m[v[R+14]]+m[v[R+15]]).toLowerCase()}},8402(ae,Q,c){"use strict";c.d(Q,{A:()=>R});const m={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};var D,z=new Uint8Array(16);function s(){if(!D&&!(D=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return D(z)}var b=c(5332);const R=function v(S,p,a){if(m.randomUUID&&!p&&!S)return m.randomUUID();var h=(S=S||{}).random||(S.rng||s)();if(h[6]=15&h[6]|64,h[8]=63&h[8]|128,p){a=a||0;for(var C=0;C<16;++C)p[a+C]=h[C];return p}return(0,b.k)(h)}},6119(ae){ae.exports.RADIUS=6378137,ae.exports.FLATTENING=1/298.257223563,ae.exports.POLAR_RADIUS=6356752.3142}}]);
|
|
1
|
+
(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[872],{503(le,Q,c){var O=c(6119);function D(b){var v=0;if(b&&b.length>0){v+=Math.abs(z(b[0]));for(var R=1;R<b.length;R++)v-=Math.abs(z(b[R]))}return v}function z(b){var v,R,p,a,h,C,F=0,B=b.length;if(B>2){for(C=0;C<B;C++)C===B-2?(p=B-2,a=B-1,h=0):C===B-1?(p=B-1,a=0,h=1):(p=C,a=C+1,h=C+2),v=b[p],R=b[a],F+=(s(b[h][0])-s(v[0]))*Math.sin(s(R[1]));F=F*O.RADIUS*O.RADIUS/2}return F}function s(b){return b*Math.PI/180}le.exports.geometry=function m(b){var R,v=0;switch(b.type){case"Polygon":return D(b.coordinates);case"MultiPolygon":for(R=0;R<b.coordinates.length;R++)v+=D(b.coordinates[R]);return v;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(R=0;R<b.geometries.length;R++)v+=m(b.geometries[R]);return v}},le.exports.ring=z},5341(le){le.exports=function c(O){if(!O||!O.type)return null;var m=Q[O.type];return m?"geometry"===m?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:O}]}:"feature"===m?{type:"FeatureCollection",features:[O]}:"featurecollection"===m?O:void 0:null};var Q={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"}},6756(le,Q,c){"use strict";c.d(Q,{BK:()=>O,In:()=>S,Kz:()=>p,Mc:()=>h,U6:()=>D,g0:()=>C,g8:()=>z,r:()=>m,u9:()=>b});const O=["#2B5DE6","#1A2B50","#C5E045","#6FA8FF","#00C2E0","#5847EB","#008585","#4ADE80","#0F4C81","#8B5CF6","#FACC15","#FB923C","#F43F5E","#E879F9","#D97706","#334155","#64748B","#94A3B8","#C7D2FE","#F8FAFC"];function m(E){switch(E){case"primary":default:return"#2859e1";case"accent":return"#e2f552";case"tertiary":return"#ffffff"}}function D(E){switch(E){case"primary":default:return"#1744c2";case"accent":return"#b8cc3f";case"tertiary":return"#eeeeee"}}function z(E){const[w,U,k]=function s(E,w){if(void 0===E)return[];const k=window.getComputedStyle(E.nativeElement);return w.map(X=>k.getPropertyValue(X).trim()||"")}(E,["--cue-chart-text-color","--cue-chart-border-background-color","--chart-graph-edge-color"]);return{text:w,borderBackground:U,edgeColor:k}}const b={fontFamily:"Poppins, sans-serif",fontWeight:"normal",color:"#333"};function S(E){return E>=1e6?`${(E/1e6).toFixed(1)}m`:E>=1e3?`${(E/1e3).toFixed(0)}k`:E.toString()}function p(E,w,U,k){if(1===k)return E;const X=F(E),f=F(w),L=U/(k-1);return`rgb(${Math.round(X.r+(f.r-X.r)*L)}, ${Math.round(X.g+(f.g-X.g)*L)}, ${Math.round(X.b+(f.b-X.b)*L)})`}const h=(E,w)=>void 0===w?E:w.children??[];function C(E,w,U=.05,k="Other"){const X=E.reduce((x,T)=>x+B(T),0),f=[],L=[];if(E.forEach(x=>{let T,A;T=void 0===x.value&&Array.isArray(x.children)&&x.children.length>0?x.children.reduce((Z,J)=>Z+B(J),0):void 0!==x.value?x.value:0,Array.isArray(x.children)&&x.children.length>0&&(A=C(x.children,w,U,k));const W={...x,value:T,children:A};w&&X>0&&T/X<U?L.push(W):f.push(W)}),w&&L.length>0){const x=L.reduce((T,A)=>T+A.value,0);f.push({id:"__grouped_small__",name:k,value:x,children:L,isGroup:!0})}return f}function F(E){const w=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(E);return w?{r:parseInt(w[1],16),g:parseInt(w[2],16),b:parseInt(w[3],16)}:{r:0,g:0,b:0}}function B(E){return"number"==typeof E.value?E.value:Array.isArray(E.children)&&E.children.length>0?E.children.reduce((w,U)=>w+B(U),0):0}},4853(le,Q,c){"use strict";c.d(Q,{H:()=>E});var O=c(7705),m=c(5802),D=c(7089),z=c(7023),s=c(5381),b=c(5971),v=c(3319),R=c(356),S=c(6279),p=c(5547);const a=()=>({position:"bottomleft"}),h=(w,U)=>U.label||w;function C(w,U){if(1&w){const k=p.RV6();p.j41(0,"cue-menu-item",4),p.bIt("click",function(){const f=m.eBV(k).$implicit;return m.Njj(f.action())}),p.EFF(1),p.k0s()}if(2&w){const k=U.$implicit;p.Y8G("selected",k.selected),p.R7$(),p.JRh(k.label)}}function F(w,U){if(1&w&&(p.j41(0,"cue-menu-wrap"),p.Z7z(1,C,2,2,"cue-menu-item",3,h),p.k0s()),2&w){const k=p.XpG();p.R7$(),p.Dyx(k.contextMenuItems())}}function B(w,U){if(1&w){const k=p.RV6();p.j41(0,"cue-button",5),p.bIt("click",function(f){const L=m.eBV(k).$implicit,x=p.XpG();return m.Njj(x.handleClick(f,L))}),p.nrm(1,"cue-button-icon",6),p.k0s()}if(2&w){const k=U.$implicit,X=p.XpG(),f=p.sdS(1);p.Y8G("cueTooltip",k.label)("variant",k.variant?k.variant:X.variant())("size",X.size())("cueContextMenu",f)("contextMenuData",p.lJ4(7,a))("cueContextEnabled",void 0!==k.contextMenuItems&&k.contextMenuItems.length>0),p.R7$(),p.Y8G("icon",k.icon)}}let E=(()=>{class w{items=O.hFB.required();noGap=(0,O.hFB)(!0);direction=(0,O.hFB)("row");size=(0,O.hFB)("xs");variant=(0,O.hFB)("tertiary");mouseEnter=(0,O.CGW)();mouseLeave=(0,O.CGW)();contextMenuItems=(0,m.vPA)([]);handleClick(k,X){k.stopPropagation(),X.contextMenuItems&&X.contextMenuItems.length>0?this.contextMenuItems.set(X.contextMenuItems):X.action&&(this.contextMenuItems.set([]),X.action())}static \u0275fac=function(X){return new(X||w)};static \u0275cmp=p.VBU({type:w,selectors:[["cue-entity-menu"]],inputs:{items:[1,"items"],noGap:[1,"noGap"],direction:[1,"direction"],size:[1,"size"],variant:[1,"variant"]},outputs:{mouseEnter:"mouseEnter",mouseLeave:"mouseLeave"},decls:5,vars:2,consts:[["contextMenu",""],["gap","s","justify","end",2,"width","100%",3,"mouseenter","mouseleave","direction","noGap"],["trigger","leftclick",3,"cueTooltip","variant","size","cueContextMenu","contextMenuData","cueContextEnabled"],[3,"selected"],[3,"click","selected"],["trigger","leftclick",3,"click","cueTooltip","variant","size","cueContextMenu","contextMenuData","cueContextEnabled"],[3,"icon"]],template:function(X,f){1&X&&(p.DNE(0,F,3,0,"ng-template",null,0,p.C5r),p.j41(2,"cue-flexcontainer",1),p.bIt("mouseenter",function(){return f.mouseEnter.emit()})("mouseleave",function(){return f.mouseLeave.emit()}),p.Z7z(3,B,2,8,"cue-button",2,h),p.k0s()),2&X&&(p.R7$(2),p.Y8G("direction",f.direction())("noGap",f.noGap()),p.R7$(),p.Dyx(f.items()))},dependencies:[s.n,b.$,D.d,v.a,z.Q,R.M,S.D],encapsulation:2,changeDetection:0})}return w})()},1024(le,Q,c){"use strict";c.d(Q,{p:()=>D});var O=c(5547);const m=["*"];let D=(()=>{class z{static \u0275fac=function(v){return new(v||z)};static \u0275cmp=O.VBU({type:z,selectors:[["cue-key-val-list"]],ngContentSelectors:m,decls:2,vars:0,consts:[[1,"key-val-list"]],template:function(v,R){1&v&&(O.NAR(),O.rj2(0,"div",0),O.SdG(1),O.eux())},styles:[".key-val-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:var(--cue-grid-gap-s)}"]})}return z})()},9421(le,Q,c){"use strict";c.d(Q,{F:()=>v});var O=c(7705),m=c(5802),D=c(2271),z=c(7335),s=c(2245),b=c(5547);let v=(()=>{class R{entityMenuDirective;size=(0,O.hFB)("m");key=O.hFB.required();val=O.geq.required();options=(0,O.hFB)([]);suffix=(0,O.hFB)("");valueChange=(0,O.CGW)();editModeEnabled=(0,m.vPA)(!1);valueChanged=(0,D.EW)(()=>this.val()!==this.newValue());newValue=(0,D.uu)(()=>this.val());labelSize=(0,D.EW)(()=>{switch(this.size()){case"s":return"xs";case"m":return"s";case"l":return"m";case"xl":return"l"}});onKeyPress(p){this.editModeEnabled()&&("Escape"===p.key?(this._reset(),p.stopPropagation()):"Enter"===p.key&&this._emitChange())}saveCancelMenu=(0,D.EW)(()=>{const p=[{icon:"close",label:"Cancel",action:()=>this._reset()}];return this.valueChanged()&&p.push({icon:"save",label:"Save",action:()=>this._emitChange()}),p});selectionChange(p){this.newValue.set(p?.toString()??"")}inputChange(p){this.newValue.set(p)}_emitChange(){this.valueChange.emit(this.newValue()),this.val.set(this.newValue()),this.editModeEnabled.set(!1)}_reset(){this.newValue.set(this.val()),this.editModeEnabled.set(!1)}static \u0275fac=function(a){return new(a||R)};static \u0275cmp=b.VBU({type:R,selectors:[["cue-key-val"]],viewQuery:function(a,h){if(1&a&&b.GBs(z.e,5),2&a){let C;b.mGM(C=b.lsd())&&(h.entityMenuDirective=C.first)}},hostBindings:function(a,h){1&a&&b.bIt("keydown",function(F){return h.onKeyPress(F)},b.EBC)},inputs:{size:[1,"size"],key:[1,"key"],val:[1,"val"],options:[1,"options"],suffix:[1,"suffix"]},outputs:{val:"valChange",valueChange:"valueChange"},decls:8,vars:5,consts:[[1,"key-val-container"],[3,"size"],[1,"value-content"]],template:function(a,h){1&a&&(b.j41(0,"dl",0)(1,"dt")(2,"cue-typography",1),b.EFF(3),b.k0s()(),b.j41(4,"dd")(5,"cue-typography",1)(6,"span",2),b.EFF(7),b.k0s()()()()),2&a&&(b.R7$(2),b.Y8G("size",h.labelSize()),b.R7$(),b.JRh(h.key()),b.R7$(2),b.Y8G("size",h.size()),b.R7$(2),b.Lme("",h.val()," ",h.suffix()))},dependencies:[s.Typography],styles:[".key-val-container[_ngcontent-%COMP%]{margin:0;display:flex;flex-direction:column;gap:var(--cue-grid-gap-s, 8px)}dt[_ngcontent-%COMP%], dd[_ngcontent-%COMP%]{margin:0}.read-mode-container[_ngcontent-%COMP%]{display:inline-flex;align-items:center;width:100%;position:relative}.read-mode-container.interactive[_ngcontent-%COMP%]:hover{cursor:pointer}.value-content[_ngcontent-%COMP%]{flex:1}[_nghost-%COMP%]{color:var(--cue-typography-text-color, inherit)}dt[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%], dd[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%], .value-content[_ngcontent-%COMP%]{color:var(--cue-typography-text-color, inherit)!important}dt[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%] div[_ngcontent-%COMP%], dd[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%] div[_ngcontent-%COMP%]{color:var(--cue-typography-text-color, inherit)!important}[_ngcontent-%COMP%]:deep(cue-svg-icon), [_ngcontent-%COMP%]:deep(cue-entity-menu cue-svg-icon){color:var(--cue-icon-color, inherit)!important}.dirty-indicator[_ngcontent-%COMP%]{opacity:.8;margin-left:4px;color:var(--cue-typography-text-color, inherit)!important;font-weight:700;font-size:.4em;transform:translateY(-1em)}"]})}return R})()},7517(le,Q,c){"use strict";c.d(Q,{P:()=>C});var O=c(7705),m=c(2271),D=c(2245),z=c(1359),s=c(5381),b=c(5547),v=c(5802);const R=(F,B)=>B.category;function S(F,B){if(1&F){const E=b.RV6();b.j41(0,"cue-flexcontainer",1)(1,"cue-checkbox",2),b.bIt("checkedChange",function(){v.eBV(E);const U=b.XpG();return v.Njj(U.toggleAll())}),b.k0s()()}if(2&F){const E=b.XpG();b.R7$(),b.Y8G("checked",E.allVisible())}}function p(F,B){if(1&F&&(b.j41(0,"cue-typography",3),b.EFF(1),b.k0s()),2&F){const E=b.XpG().$implicit;b.R7$(),b.JRh(E.category)}}function a(F,B){if(1&F){const E=b.RV6();b.j41(0,"cue-flexcontainer",1)(1,"cue-checkbox",4),b.bIt("checkedChange",function(){const U=v.eBV(E).$implicit,k=b.XpG(2);return v.Njj(k.toggleSingle(U))}),b.k0s(),b.j41(2,"cue-typography",5),b.bIt("click",function(){const U=v.eBV(E).$implicit,k=b.XpG(2);return v.Njj(k.toggleSingle(U))}),b.EFF(3),b.k0s()()}if(2&F){const E=B.$implicit;b.R7$(),b.Y8G("checked",E.visible)("color",E.color),b.R7$(2),b.JRh(E.label)}}function h(F,B){if(1&F&&(b.nVh(0,p,2,1,"cue-typography",3),b.Z7z(1,a,4,3,"cue-flexcontainer",1,b.Vm6)),2&F){const E=B.$implicit;b.vxM(E.category?0:-1),b.R7$(),b.Dyx(E.items)}}let C=(()=>{class F{layers=(0,O.geq)([]);visibilityChange=(0,O.CGW)();layerChange=(0,O.CGW)();visibilityAll=(0,O.CGW)();showCheckAll=(0,m.EW)(()=>this.layers().length>1);allVisible=(0,m.EW)(()=>this.layers().every(E=>E.visible));groupedLayers=(0,m.EW)(()=>{const E=[];for(const w of this.layers()){const U=w.category,k=E.find(X=>X.category===U);k?k.items.push(w):E.push({category:U,items:[w]})}return E});toggleAll(){const E=this.allVisible(),w=this.layers().map(U=>(U.visible=!E,U));this.layers.update(()=>[...w]),this.visibilityAll.emit(E),this.emitChange()}toggleSingle(E){E.visible=!E.visible,this.layerChange.emit(E),this.layers.update(()=>[...this.layers()]),this.emitChange()}emitChange(){this.visibilityChange.emit(this.layers())}static \u0275fac=function(w){return new(w||F)};static \u0275cmp=b.VBU({type:F,selectors:[["cue-layer-legend"]],inputs:{layers:[1,"layers"]},outputs:{layers:"layersChange",visibilityChange:"visibilityChange",layerChange:"layerChange",visibilityAll:"visibilityAll"},decls:4,vars:1,consts:[["direction","column"],["align","center","justify","start",2,"width","100%"],["size","s",3,"checkedChange","checked"],["variant","label",2,"margin-top","4px","opacity","0.6"],["size","s",3,"checkedChange","checked","color"],[2,"cursor","pointer",3,"click"]],template:function(w,U){1&w&&(b.j41(0,"cue-flexcontainer",0),b.nVh(1,S,2,1,"cue-flexcontainer",1),b.Z7z(2,h,3,1,null,null,R),b.k0s()),2&w&&(b.R7$(),b.vxM(U.showCheckAll()?1:-1),b.R7$(),b.Dyx(U.groupedLayers()))},dependencies:[s.n,D.Typography,z.S],encapsulation:2,changeDetection:0})}return F})()},2843(le,Q,c){"use strict";c.d(Q,{M:()=>Wn});var O={};c.r(O),c.d(O,{LAT_MAX:()=>U,LAT_MIN:()=>E,LAT_RENDERED_MAX:()=>k,LAT_RENDERED_MIN:()=>w,LNG_MAX:()=>f,LNG_MIN:()=>X,activeStates:()=>F,classes:()=>s,cursors:()=>v,events:()=>a,geojsonTypes:()=>S,interactions:()=>B,meta:()=>C,modes:()=>p,sources:()=>b,types:()=>R,updateActions:()=>h});var m={};c.r(m),c.d(m,{isActiveFeature:()=>T,isBackspaceKey:()=>pe,isDeleteKey:()=>me,isDigit1Key:()=>te,isDigit2Key:()=>ze,isDigit3Key:()=>De,isDigitKey:()=>ve,isEnterKey:()=>he,isEscapeKey:()=>ye,isFeature:()=>Z,isInactiveFeature:()=>A,isOfMetaType:()=>L,isShiftDown:()=>oe,isShiftMousedown:()=>x,isTrue:()=>ct,isVertex:()=>J,noTarget:()=>W});var D={};c.r(D),c.d(D,{CommonSelectors:()=>m,ModeHandler:()=>nt,StringSet:()=>Ae,constrainFeatureMovement:()=>At,createMidPoint:()=>nn,createSupplementaryPoints:()=>wt,createVertex:()=>Ze,doubleClickZoom:()=>Ie,euclideanDistance:()=>qe,featuresAt:()=>Be,getFeatureAtAndSetCursors:()=>Xe,isClick:()=>et,isEventAtCoordinates:()=>mt,isTap:()=>tt,mapEventToBoundingBox:()=>He,moveFeatures:()=>Nt,sortFeatures:()=>dt,stringSetsAreEqual:()=>pn,theme:()=>Gt,toDenseArray:()=>ge});var z=c(5802);const s={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"},b={HOT:"mapbox-gl-draw-hot",COLD:"mapbox-gl-draw-cold"},v={ADD:"add",MOVE:"move",DRAG:"drag",POINTER:"pointer",NONE:"none"},R={POLYGON:"polygon",LINE:"line_string",POINT:"point"},S={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"},p={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select"},a={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"},h={MOVE:"move",CHANGE_PROPERTIES:"change_properties",CHANGE_COORDINATES:"change_coordinates"},C={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},F={ACTIVE:"true",INACTIVE:"false"},B=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],E=-90,w=-85,U=90,k=85,X=-270,f=270;function L(e){return function(t){const n=t.featureTarget;return!(!n||!n.properties)&&n.properties.meta===e}}function x(e){return!(!e.originalEvent||!e.originalEvent.shiftKey)&&0===e.originalEvent.button}function T(e){return!(!e.featureTarget||!e.featureTarget.properties)&&e.featureTarget.properties.active===F.ACTIVE&&e.featureTarget.properties.meta===C.FEATURE}function A(e){return!(!e.featureTarget||!e.featureTarget.properties)&&e.featureTarget.properties.active===F.INACTIVE&&e.featureTarget.properties.meta===C.FEATURE}function W(e){return void 0===e.featureTarget}function Z(e){return!(!e.featureTarget||!e.featureTarget.properties)&&e.featureTarget.properties.meta===C.FEATURE}function J(e){const t=e.featureTarget;return!(!t||!t.properties)&&t.properties.meta===C.VERTEX}function oe(e){return!!e.originalEvent&&!0===e.originalEvent.shiftKey}function ye(e){return"Escape"===e.key||27===e.keyCode}function he(e){return"Enter"===e.key||13===e.keyCode}function pe(e){return"Backspace"===e.key||8===e.keyCode}function me(e){return"Delete"===e.key||46===e.keyCode}function te(e){return"1"===e.key||49===e.keyCode}function ze(e){return"2"===e.key||50===e.keyCode}function De(e){return"3"===e.key||51===e.keyCode}function ve(e){const t=e.key||String.fromCharCode(e.keyCode);return t>="0"&&t<="9"}function ct(){return!0}var Ke=c(503);const we={Point:0,LineString:1,MultiLineString:1,Polygon:2};function ut(e,t){const n=we[e.geometry.type]-we[t.geometry.type];return 0===n&&e.geometry.type===S.POLYGON?e.area-t.area:n}const dt=function _t(e){return e.map(t=>(t.geometry.type===S.POLYGON&&(t.area=Ke.geometry({type:S.FEATURE,property:{},geometry:t.geometry})),t)).sort(ut).map(t=>(delete t.area,t))},He=function je(e,t=0){return[[e.point.x-t,e.point.y-t],[e.point.x+t,e.point.y+t]]};function Re(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]),void 0!==e[t]&&("string"==typeof e[t]?this._items[e[t]]=t:this._nums[e[t]]=t)}Re.prototype.add=function(e){return this.has(e)||(this._length++,"string"==typeof e?this._items[e]=this._length:this._nums[e]=this._length),this},Re.prototype.delete=function(e){return!1===this.has(e)||(this._length--,delete this._items[e],delete this._nums[e]),this},Re.prototype.has=function(e){return!("string"!=typeof e&&"number"!=typeof e||void 0===this._items[e]&&void 0===this._nums[e])},Re.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)},Re.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};const Ae=Re,Qe=[C.FEATURE,C.MIDPOINT,C.VERTEX],Be={click:function vt(e,t,n){return ft(e,t,n,n.options.clickBuffer)},touch:function bt(e,t,n){return ft(e,t,n,n.options.touchBuffer)}};function ft(e,t,n,o){if(null===n.map)return[];const r=e?He(e,o):t,i={};n.options.styles&&(i.layers=n.options.styles.map(N=>N.id).filter(N=>null!=n.map.getLayer(N)));const d=n.map.queryRenderedFeatures(r,i).filter(N=>-1!==Qe.indexOf(N.properties.meta)),M=new Ae,g=[];return d.forEach(N=>{const K=N.properties.id;M.has(K)||(M.add(K),g.push(N))}),dt(g)}function Xe(e,t){const n=Be.click(e,null,t),o={mouse:v.NONE};return n[0]&&(o.mouse=n[0].properties.active===F.ACTIVE?v.MOVE:v.POINTER,o.feature=n[0].properties.meta),-1!==t.events.currentModeName().indexOf("draw")&&(o.mouse=v.ADD),t.ui.queueMapClasses(o),t.ui.updateMapClasses(),n[0]}function qe(e,t){const n=e.x-t.x,o=e.y-t.y;return Math.sqrt(n*n+o*o)}function et(e,t,n={}){const o=null!=n.fineTolerance?n.fineTolerance:4,r=null!=n.grossTolerance?n.grossTolerance:12,i=null!=n.interval?n.interval:500;e.point=e.point||t.point,e.time=e.time||t.time;const d=qe(e.point,t.point);return d<o||d<r&&t.time-e.time<i}function tt(e,t,n={}){const o=null!=n.tolerance?n.tolerance:25,r=null!=n.interval?n.interval:250;return e.point=e.point||t.point,e.time=e.time||t.time,qe(e.point,t.point)<o&&t.time-e.time<r}const nt=function(e,t){const n={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},o={on(i,d,M){if(void 0===n[i])throw new Error(`Invalid event type: ${i}`);n[i].push({selector:d,fn:M})},render(i){t.store.featureChanged(i)}},r=function(i,d){const M=n[i];let g=M.length;for(;g--;){const N=M[g];if(N.selector(d)){N.fn.call(o,d)||t.store.render(),t.ui.updateMapClasses();break}}};return e.start.call(o),{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){r("drag",i)},click(i){r("click",i)},mousemove(i){r("mousemove",i)},mousedown(i){r("mousedown",i)},mouseup(i){r("mouseup",i)},mouseout(i){r("mouseout",i)},keydown(i){r("keydown",i)},keyup(i){r("keyup",i)},touchstart(i){r("touchstart",i)},touchmove(i){r("touchmove",i)},touchend(i){r("touchend",i)},tap(i){r("tap",i)}}},I=((e,t=21)=>(n=t)=>{let o="",r=0|n;for(;r--;)o+=e[Math.random()*e.length|0];return o})("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",32);function l(){return I()}const u=function(e,t){this.ctx=e,this.properties=t.properties||{},this.coordinates=t.geometry.coordinates,this.id=t.id||l(),this.type=t.geometry.type};u.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},u.prototype.incomingCoords=function(e){this.setCoordinates(e)},u.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},u.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},u.prototype.setProperty=function(e,t){this.properties[e]=t},u.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:S.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},u.prototype.internal=function(e){const t={id:this.id,meta:C.FEATURE,"meta:type":this.type,active:F.INACTIVE,mode:e};if(this.ctx.options.userProperties)for(const n in this.properties)t[`user_${n}`]=this.properties[n];return{type:S.FEATURE,properties:t,geometry:{coordinates:this.getCoordinates(),type:this.type}}};const _=u,V=function(e,t){_.call(this,e,t)};(V.prototype=Object.create(_.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},V.prototype.updateCoordinate=function(e,t,n){this.coordinates=3===arguments.length?[t,n]:[e,t],this.changed()},V.prototype.getCoordinate=function(){return this.getCoordinates()};const Y=V,re=function(e,t){_.call(this,e,t)};(re.prototype=Object.create(_.prototype)).isValid=function(){return this.coordinates.length>1},re.prototype.addCoordinate=function(e,t,n){this.changed();const o=parseInt(e,10);this.coordinates.splice(o,0,[t,n])},re.prototype.getCoordinate=function(e){const t=parseInt(e,10);return JSON.parse(JSON.stringify(this.coordinates[t]))},re.prototype.removeCoordinate=function(e){this.changed(),this.coordinates.splice(parseInt(e,10),1)},re.prototype.updateCoordinate=function(e,t,n){const o=parseInt(e,10);this.coordinates[o]=[t,n],this.changed()};const ne=re,fe=function(e,t){_.call(this,e,t),this.coordinates=this.coordinates.map(n=>n.slice(0,-1))};(fe.prototype=Object.create(_.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every(e=>e.length>2)},fe.prototype.incomingCoords=function(e){this.coordinates=e.map(t=>t.slice(0,-1)),this.changed()},fe.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},fe.prototype.addCoordinate=function(e,t,n){this.changed();const o=e.split(".").map(i=>parseInt(i,10));this.coordinates[o[0]].splice(o[1],0,[t,n])},fe.prototype.removeCoordinate=function(e){this.changed();const t=e.split(".").map(o=>parseInt(o,10)),n=this.coordinates[t[0]];n&&(n.splice(t[1],1),n.length<3&&this.coordinates.splice(t[0],1))},fe.prototype.getCoordinate=function(e){const t=e.split(".").map(o=>parseInt(o,10));return JSON.parse(JSON.stringify(this.coordinates[t[0]][t[1]]))},fe.prototype.getCoordinates=function(){return this.coordinates.map(e=>e.concat([e[0]]))},fe.prototype.updateCoordinate=function(e,t,n){this.changed();const o=e.split("."),r=parseInt(o[0],10),i=parseInt(o[1],10);void 0===this.coordinates[r]&&(this.coordinates[r]=[]),this.coordinates[r][i]=[t,n]};const ae=fe,de={MultiPoint:Y,MultiLineString:ne,MultiPolygon:ae},_e=(e,t,n,o,r)=>{const i=n.split("."),d=parseInt(i[0],10),M=i[1]?i.slice(1).join("."):null;return e[d][t](M,o,r)},Ee=function(e,t){if(_.call(this,e,t),delete this.coordinates,this.model=de[t.geometry.type],void 0===this.model)throw new TypeError(`${t.geometry.type} is not a valid type`);this.features=this._coordinatesToFeatures(t.geometry.coordinates)};(Ee.prototype=Object.create(_.prototype))._coordinatesToFeatures=function(e){const t=this.model.bind(this);return e.map(n=>new t(this.ctx,{id:l(),type:S.FEATURE,properties:{},geometry:{coordinates:n,type:this.type.replace("Multi","")}}))},Ee.prototype.isValid=function(){return this.features.every(e=>e.isValid())},Ee.prototype.setCoordinates=function(e){this.features=this._coordinatesToFeatures(e),this.changed()},Ee.prototype.getCoordinate=function(e){return _e(this.features,"getCoordinate",e)},Ee.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(e=>e.type===S.POLYGON?e.getCoordinates():e.coordinates)))},Ee.prototype.updateCoordinate=function(e,t,n){_e(this.features,"updateCoordinate",e,t,n),this.changed()},Ee.prototype.addCoordinate=function(e,t,n){_e(this.features,"addCoordinate",e,t,n),this.changed()},Ee.prototype.removeCoordinate=function(e){_e(this.features,"removeCoordinate",e),this.changed()},Ee.prototype.getFeatures=function(){return this.features};const Ne=Ee;function H(e){this.map=e.map,this.drawConfig=JSON.parse(JSON.stringify(e.options||{})),this._ctx=e}H.prototype.setSelected=function(e){return this._ctx.store.setSelected(e)},H.prototype.setSelectedCoordinates=function(e){this._ctx.store.setSelectedCoordinates(e),e.reduce((t,n)=>(void 0===t[n.feature_id]&&(t[n.feature_id]=!0,this._ctx.store.get(n.feature_id).changed()),t),{})},H.prototype.getSelected=function(){return this._ctx.store.getSelected()},H.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},H.prototype.isSelected=function(e){return this._ctx.store.isSelected(e)},H.prototype.getFeature=function(e){return this._ctx.store.get(e)},H.prototype.select=function(e){return this._ctx.store.select(e)},H.prototype.deselect=function(e){return this._ctx.store.deselect(e)},H.prototype.deleteFeature=function(e,t={}){return this._ctx.store.delete(e,t)},H.prototype.addFeature=function(e,t={}){return this._ctx.store.add(e,t)},H.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},H.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},H.prototype.setActionableState=function(e={}){return this._ctx.events.actionable({trash:e.trash||!1,combineFeatures:e.combineFeatures||!1,uncombineFeatures:e.uncombineFeatures||!1})},H.prototype.changeMode=function(e,t={},n={}){return this._ctx.events.changeMode(e,t,n)},H.prototype.fire=function(e,t){return this._ctx.events.fire(e,t)},H.prototype.updateUIClasses=function(e){return this._ctx.ui.queueMapClasses(e)},H.prototype.activateUIButton=function(e){return this._ctx.ui.setActiveButton(e)},H.prototype.featuresAt=function(e,t,n="click"){if("click"!==n&&"touch"!==n)throw new Error("invalid buffer type");return Be[n](e,t,this._ctx)},H.prototype.newFeature=function(e){const t=e.geometry.type;return t===S.POINT?new Y(this._ctx,e):t===S.LINE_STRING?new ne(this._ctx,e):t===S.POLYGON?new ae(this._ctx,e):new Ne(this._ctx,e)},H.prototype.isInstanceOf=function(e,t){if(e===S.POINT)return t instanceof Y;if(e===S.LINE_STRING)return t instanceof ne;if(e===S.POLYGON)return t instanceof ae;if("MultiFeature"===e)return t instanceof Ne;throw new Error(`Unknown feature class: ${e}`)},H.prototype.doRender=function(e){return this._ctx.store.featureChanged(e)};const q=H;H.prototype.onSetup=function(){},H.prototype.onDrag=function(){},H.prototype.onClick=function(){},H.prototype.onMouseMove=function(){},H.prototype.onMouseDown=function(){},H.prototype.onMouseUp=function(){},H.prototype.onMouseOut=function(){},H.prototype.onKeyUp=function(){},H.prototype.onKeyDown=function(){},H.prototype.onTouchStart=function(){},H.prototype.onTouchMove=function(){},H.prototype.onTouchEnd=function(){},H.prototype.onTap=function(){},H.prototype.onStop=function(){},H.prototype.onTrash=function(){},H.prototype.onCombineFeature=function(){},H.prototype.onUncombineFeature=function(){},H.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};const ie={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},be=Object.keys(ie);const ge=function Me(e){return[].concat(e).filter(t=>void 0!==t)};function ot(){const e=this;if(!e.ctx.map||void 0===e.ctx.map.getSource(b.HOT))return g();const n=e.ctx.events.currentModeName();e.ctx.ui.queueMapClasses({mode:n});let o=[],r=[];e.isDirty?r=e.getAllIds():(o=e.getChangedIds().filter(N=>void 0!==e.get(N)),r=e.sources.hot.filter(N=>N.properties.id&&-1===o.indexOf(N.properties.id)&&void 0!==e.get(N.properties.id)).map(N=>N.properties.id)),e.sources.hot=[];const i=e.sources.cold.length;e.sources.cold=e.isDirty?[]:e.sources.cold.filter(N=>-1===o.indexOf(N.properties.id||N.properties.parent));const d=i!==e.sources.cold.length||r.length>0;function M(N,K){const P=e.get(N).internal(n);e.ctx.events.currentModeRender(P,G=>{G.properties.mode=n,e.sources[K].push(G)})}function g(){e.isDirty=!1,e.clearChangedIds()}o.forEach(N=>M(N,"hot")),r.forEach(N=>M(N,"cold")),d&&e.ctx.map.getSource(b.COLD).setData({type:S.FEATURE_COLLECTION,features:e.sources.cold}),e.ctx.map.getSource(b.HOT).setData({type:S.FEATURE_COLLECTION,features:e.sources.hot}),g()}function se(e){let t;this._features={},this._featureIds=new Ae,this._selectedFeatureIds=new Ae,this._selectedCoordinates=[],this._changedFeatureIds=new Ae,this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=e,this.sources={hot:[],cold:[]},this.render=()=>{t||(t=requestAnimationFrame(()=>{t=null,ot.call(this),this._emitSelectionChange&&(this.ctx.events.fire(a.SELECTION_CHANGE,{features:this.getSelected().map(n=>n.toGeoJSON()),points:this.getSelectedCoordinates().map(n=>({type:S.FEATURE,properties:{},geometry:{type:S.POINT,coordinates:n.coordinates}}))}),this._emitSelectionChange=!1),this.ctx.events.fire(a.RENDER,{})}))},this.isDirty=!1}function rt(e,t={}){const n=e._selectedCoordinates.filter(o=>e._selectedFeatureIds.has(o.feature_id));e._selectedCoordinates.length!==n.length&&!t.silent&&(e._emitSelectionChange=!0),e._selectedCoordinates=n}se.prototype.createRenderBatch=function(){const e=this.render;let t=0;return this.render=function(){t++},()=>{this.render=e,t>0&&this.render()}},se.prototype.setDirty=function(){return this.isDirty=!0,this},se.prototype.featureCreated=function(e,t={}){if(this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)){const o=this.get(e);this.ctx.events.fire(a.CREATE,{features:[o.toGeoJSON()]})}return this},se.prototype.featureChanged=function(e,t={}){return this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)&&this.ctx.events.fire(a.UPDATE,{action:t.action?t.action:h.CHANGE_COORDINATES,features:[this.get(e).toGeoJSON()]}),this},se.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},se.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},se.prototype.getAllIds=function(){return this._featureIds.values()},se.prototype.add=function(e,t={}){return this._features[e.id]=e,this._featureIds.add(e.id),this.featureCreated(e.id,{silent:t.silent}),this},se.prototype.delete=function(e,t={}){const n=[];return ge(e).forEach(o=>{this._featureIds.has(o)&&(this._featureIds.delete(o),this._selectedFeatureIds.delete(o),t.silent||-1===n.indexOf(this._features[o])&&n.push(this._features[o].toGeoJSON()),delete this._features[o],this.isDirty=!0)}),n.length&&this.ctx.events.fire(a.DELETE,{features:n}),rt(this,t),this},se.prototype.get=function(e){return this._features[e]},se.prototype.getAll=function(){return Object.keys(this._features).map(e=>this._features[e])},se.prototype.select=function(e,t={}){return ge(e).forEach(n=>{this._selectedFeatureIds.has(n)||(this._selectedFeatureIds.add(n),this._changedFeatureIds.add(n),t.silent||(this._emitSelectionChange=!0))}),this},se.prototype.deselect=function(e,t={}){return ge(e).forEach(n=>{this._selectedFeatureIds.has(n)&&(this._selectedFeatureIds.delete(n),this._changedFeatureIds.add(n),t.silent||(this._emitSelectionChange=!0))}),rt(this,t),this},se.prototype.clearSelected=function(e={}){return this.deselect(this._selectedFeatureIds.values(),{silent:e.silent}),this},se.prototype.setSelected=function(e,t={}){return e=ge(e),this.deselect(this._selectedFeatureIds.values().filter(n=>-1===e.indexOf(n)),{silent:t.silent}),this.select(e.filter(n=>!this._selectedFeatureIds.has(n)),{silent:t.silent}),this},se.prototype.setSelectedCoordinates=function(e){return this._selectedCoordinates=e,this._emitSelectionChange=!0,this},se.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},se.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},se.prototype.getSelected=function(){return this.getSelectedIds().map(e=>this.get(e))},se.prototype.getSelectedCoordinates=function(){return this._selectedCoordinates.map(t=>({coordinates:this.get(t.feature_id).getCoordinate(t.coord_path)}))},se.prototype.isSelected=function(e){return this._selectedFeatureIds.has(e)},se.prototype.setFeatureProperty=function(e,t,n,o={}){this.get(e).setProperty(t,n),this.featureChanged(e,{silent:o.silent,action:h.CHANGE_PROPERTIES})},se.prototype.storeMapConfig=function(){B.forEach(e=>{this.ctx.map[e]&&(this._mapInitialConfig[e]=this.ctx.map[e].isEnabled())})},se.prototype.restoreMapConfig=function(){Object.keys(this._mapInitialConfig).forEach(e=>{this._mapInitialConfig[e]?this.ctx.map[e].enable():this.ctx.map[e].disable()})},se.prototype.getInitialConfigValue=function(e){return void 0===this._mapInitialConfig[e]||this._mapInitialConfig[e]};const it=["mode","feature","mouse"];function Bt(e){let t=null,n=null;const o={onRemove(){return e.map.off("load",o.connect),clearInterval(n),o.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",o.connect),clearInterval(n),o.addLayers(),e.store.storeMapConfig(),e.events.addEventListeners()},onAdd(r){if(e.map=r,e.events=function ke(e){const t=Object.keys(e.options.modes).reduce((P,G)=>(P[G]=function Se(e){const t=Object.keys(e);return function(n,o={}){let r={};const i=t.reduce((M,g)=>(M[g]=e[g],M),new q(n));return{start(){r=i.onSetup(o),be.forEach(M=>{const g=ie[M];let N=()=>!1;e[g]&&(N=()=>!0),this.on(M,N,function d(M){return g=>i[M](r,g)}(g))})},stop(){i.onStop(r)},trash(){i.onTrash(r)},combineFeatures(){i.onCombineFeatures(r)},uncombineFeatures(){i.onUncombineFeatures(r)},render(M,g){i.toDisplayFeatures(r,M,g)}}}}(e.options.modes[G]),P),{});let n={},o={};const r={};let i=null,d=null;r.drag=function(P,G){G({point:P.point,time:(new Date).getTime()})?(e.ui.queueMapClasses({mouse:v.DRAG}),d.drag(P)):P.originalEvent.stopPropagation()},r.mousedrag=function(P){r.drag(P,G=>!et(n,G))},r.touchdrag=function(P){r.drag(P,G=>!tt(o,G))},r.mousemove=function(P){if(1===(void 0!==P.originalEvent.buttons?P.originalEvent.buttons:P.originalEvent.which))return r.mousedrag(P);const $=Xe(P,e);P.featureTarget=$,d.mousemove(P)},r.mousedown=function(P){n={time:(new Date).getTime(),point:P.point};const G=Xe(P,e);P.featureTarget=G,d.mousedown(P)},r.mouseup=function(P){const G=Xe(P,e);P.featureTarget=G,et(n,{point:P.point,time:(new Date).getTime()})?d.click(P):d.mouseup(P)},r.mouseout=function(P){d.mouseout(P)},r.touchstart=function(P){if(!e.options.touchEnabled)return;o={time:(new Date).getTime(),point:P.point};const G=Be.touch(P,null,e)[0];P.featureTarget=G,d.touchstart(P)},r.touchmove=function(P){if(e.options.touchEnabled)return d.touchmove(P),r.touchdrag(P)},r.touchend=function(P){if(P.originalEvent.preventDefault(),!e.options.touchEnabled)return;const G=Be.touch(P,null,e)[0];P.featureTarget=G,tt(o,{time:(new Date).getTime(),point:P.point})?d.tap(P):d.touchend(P)};const M=P=>{const G=pe(P),$=me(P),ee=ve(P);return!(G||$||ee)};function g(P,G,$={}){d.stop();const ee=t[P];if(void 0===ee)throw new Error(`${P} is not valid`);i=P;const Ce=ee(e,G);d=nt(Ce,e),$.silent||e.map.fire(a.MODE_CHANGE,{mode:P}),e.store.setDirty(),e.store.render()}r.keydown=function(P){(P.srcElement||P.target).classList.contains(s.CANVAS)&&((pe(P)||me(P))&&e.options.controls.trash?(P.preventDefault(),d.trash()):M(P)?d.keydown(P):te(P)&&e.options.controls.point?g(p.DRAW_POINT):ze(P)&&e.options.controls.line_string?g(p.DRAW_LINE_STRING):De(P)&&e.options.controls.polygon&&g(p.DRAW_POLYGON))},r.keyup=function(P){M(P)&&d.keyup(P)},r.zoomend=function(){e.store.changeZoom()},r.data=function(P){if("style"===P.dataType){const{setup:G,map:$,options:ee,store:Ce}=e;ee.styles.some(Ve=>$.getLayer(Ve.id))||(G.addLayers(),Ce.setDirty(),Ce.render())}};const N={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return{start(){i=e.options.defaultMode,d=nt(t[i](e),e)},changeMode:g,actionable:function K(P){let G=!1;Object.keys(P).forEach($=>{if(void 0===N[$])throw new Error("Invalid action type");N[$]!==P[$]&&(G=!0),N[$]=P[$]}),G&&e.map.fire(a.ACTIONABLE,{actions:N})},currentModeName:()=>i,currentModeRender:(P,G)=>d.render(P,G),fire(P,G){e.map&&e.map.fire(P,G)},addEventListeners(){e.map.on("mousemove",r.mousemove),e.map.on("mousedown",r.mousedown),e.map.on("mouseup",r.mouseup),e.map.on("data",r.data),e.map.on("touchmove",r.touchmove),e.map.on("touchstart",r.touchstart),e.map.on("touchend",r.touchend),e.container.addEventListener("mouseout",r.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",r.keydown),e.container.addEventListener("keyup",r.keyup))},removeEventListeners(){e.map.off("mousemove",r.mousemove),e.map.off("mousedown",r.mousedown),e.map.off("mouseup",r.mouseup),e.map.off("data",r.data),e.map.off("touchmove",r.touchmove),e.map.off("touchstart",r.touchstart),e.map.off("touchend",r.touchend),e.container.removeEventListener("mouseout",r.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",r.keydown),e.container.removeEventListener("keyup",r.keyup))},trash(P){d.trash(P)},combineFeatures(){d.combineFeatures()},uncombineFeatures(){d.uncombineFeatures()},getMode:()=>i}}(e),e.ui=function It(e){const t={};let n=null,o={mode:null,feature:null,mouse:null},r={mode:null,feature:null,mouse:null};function d(G){r=Object.assign(r,G)}function M(){if(!e.container)return;const G=[],$=[];it.forEach(ee=>{r[ee]!==o[ee]&&(G.push(`${ee}-${o[ee]}`),null!==r[ee]&&$.push(`${ee}-${r[ee]}`))}),G.length>0&&e.container.classList.remove(...G),$.length>0&&e.container.classList.add(...$),o=Object.assign(o,r)}function g(G,$={}){const ee=document.createElement("button");return ee.className=`${s.CONTROL_BUTTON} ${$.className}`,ee.setAttribute("title",$.title),$.container.appendChild(ee),ee.addEventListener("click",Ce=>{if(Ce.preventDefault(),Ce.stopPropagation(),Ce.target===n)return N(),void $.onDeactivate();K(G),$.onActivate()},!0),ee}function N(){n&&(n.classList.remove(s.ACTIVE_BUTTON),n=null)}function K(G){N();const $=t[G];$&&$&&"trash"!==G&&($.classList.add(s.ACTIVE_BUTTON),n=$)}return{setActiveButton:K,queueMapClasses:d,updateMapClasses:M,clearMapClasses:function i(){d({mode:null,feature:null,mouse:null}),M()},addButtons:function j(){const G=e.options.controls,$=document.createElement("div");return $.className=`${s.CONTROL_GROUP} ${s.CONTROL_BASE}`,G&&(G[R.POINT]&&(t[R.POINT]=g(R.POINT,{container:$,className:s.CONTROL_BUTTON_POINT,title:"Marker tool "+(e.options.keybindings?"(1)":""),onActivate:()=>e.events.changeMode(p.DRAW_POINT),onDeactivate:()=>e.events.trash()})),G[R.LINE]&&(t[R.LINE]=g(R.LINE,{container:$,className:s.CONTROL_BUTTON_LINE,title:"LineString tool "+(e.options.keybindings?"(2)":""),onActivate:()=>e.events.changeMode(p.DRAW_LINE_STRING),onDeactivate:()=>e.events.trash()})),G[R.POLYGON]&&(t[R.POLYGON]=g(R.POLYGON,{container:$,className:s.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(e.options.keybindings?"(3)":""),onActivate:()=>e.events.changeMode(p.DRAW_POLYGON),onDeactivate:()=>e.events.trash()})),G.trash&&(t.trash=g("trash",{container:$,className:s.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:()=>{e.events.trash()}})),G.combine_features&&(t.combine_features=g("combineFeatures",{container:$,className:s.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:()=>{e.events.combineFeatures()}})),G.uncombine_features&&(t.uncombine_features=g("uncombineFeatures",{container:$,className:s.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:()=>{e.events.uncombineFeatures()}}))),$},removeButtons:function P(){Object.keys(t).forEach(G=>{const $=t[G];$.parentNode&&$.parentNode.removeChild($),delete t[G]})}}}(e),e.container=r.getContainer(),e.store=new se(e),t=e.ui.addButtons(),e.options.boxSelect){e.boxZoomInitial=r.boxZoom.isEnabled(),r.boxZoom.disable();const i=r.dragPan.isEnabled();r.dragPan.disable(),r.dragPan.enable(),i||r.dragPan.disable()}return r.loaded()?o.connect():(r.on("load",o.connect),n=setInterval(()=>{r.loaded()&&o.connect()},16)),e.events.start(),t},addLayers(){e.map.addSource(b.COLD,{data:{type:S.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(b.HOT,{data:{type:S.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.options.styles.forEach(r=>{e.map.addLayer(r)}),e.store.setDirty(!0),e.store.render()},removeLayers(){e.options.styles.forEach(r=>{e.map.getLayer(r.id)&&e.map.removeLayer(r.id)}),e.map.getSource(b.COLD)&&e.map.removeSource(b.COLD),e.map.getSource(b.HOT)&&e.map.removeSource(b.HOT)}};return e.setup=o,o}const st="#3bb2d0",at="#fbb03b",Gt=[{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"]],paint:{"fill-color":["case",["==",["get","active"],"true"],at,st],"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"],at,st],"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":"#fff"}},{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"],at,st]}},{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":"#fff"}},{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":at}},{id:"gl-draw-midpoint",type:"circle",filter:["all",["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":at}}];function Ge(e,t){this.x=e,this.y=t}Ge.prototype={clone(){return new Ge(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 n=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,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=n*this.x+t*this.y;return this.x=t*this.x-n*this.y,this.y=r,this},_rotateAround(e,t){const n=Math.cos(e),o=Math.sin(e),i=t.y+o*(this.x-t.x)+n*(this.y-t.y);return this.x=t.x+n*(this.x-t.x)-o*(this.y-t.y),this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Ge},Ge.convert=function(e){if(e instanceof Ge)return e;if(Array.isArray(e))return new Ge(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new Ge(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};const Ot=function mn(e,t){const n=t.getBoundingClientRect();return new Ge(e.clientX-n.left-(t.clientLeft||0),e.clientY-n.top-(t.clientTop||0))};function Ze(e,t,n,o){return{type:S.FEATURE,properties:{meta:C.VERTEX,parent:e,coord_path:n,active:o?F.ACTIVE:F.INACTIVE},geometry:{type:S.POINT,coordinates:t}}}function lt(e,t,n){if(null!==e)for(var o,r,i,d,M,g,N,P,K=0,j=0,G=e.type,$="FeatureCollection"===G,ee="Feature"===G,Ce=$?e.features.length:1,Te=0;Te<Ce;Te++){M=(P=!!(N=$?e.features[Te].geometry:ee?e.geometry:e)&&"GeometryCollection"===N.type)?N.geometries.length:1;for(var Ve=0;Ve<M;Ve++){var Pe=0,We=0;if(null!==(d=P?N.geometries[Ve]:N)){g=d.coordinates;var Ue=d.type;switch(K=!n||"Polygon"!==Ue&&"MultiPolygon"!==Ue?0:1,Ue){case null:break;case"Point":if(!1===t(g,j,Te,Pe,We))return!1;j++,Pe++;break;case"LineString":case"MultiPoint":for(o=0;o<g.length;o++){if(!1===t(g[o],j,Te,Pe,We))return!1;j++,"MultiPoint"===Ue&&Pe++}"LineString"===Ue&&Pe++;break;case"Polygon":case"MultiLineString":for(o=0;o<g.length;o++){for(r=0;r<g[o].length-K;r++){if(!1===t(g[o][r],j,Te,Pe,We))return!1;j++}"MultiLineString"===Ue&&Pe++,"Polygon"===Ue&&We++}"Polygon"===Ue&&Pe++;break;case"MultiPolygon":for(o=0;o<g.length;o++){for(We=0,r=0;r<g[o].length;r++){for(i=0;i<g[o][r].length-K;i++){if(!1===t(g[o][r][i],j,Te,Pe,We))return!1;j++}We++}Pe++}break;case"GeometryCollection":for(o=0;o<d.geometries.length;o++)if(!1===lt(d.geometries[o],t,n))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Jt(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=Yt(e.properties),t.geometry=null==e.geometry?null:Dt(e.geometry),t}function Yt(e){const t={};return e&&Object.keys(e).forEach(n=>{const o=e[n];t[n]="object"==typeof o?null===o?null:Array.isArray(o)?o.map(r=>r):Yt(o):o}),t}function Dt(e){const t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(n=>Dt(n)),t):(t.coordinates=jt(e.coordinates),t)}function jt(e){const t=e;return"object"!=typeof t[0]?t.slice():t.map(n=>jt(n))}function Qt(e,t={}){return qt(e,"mercator",t)}function qt(e,t,n={}){var o=(n=n||{}).mutate;if(!e)throw new Error("geojson is required");return Array.isArray(e)&&function ht(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}(e[0])?e="mercator"===t?en(e):tn(e):(!0!==o&&(e=function Pn(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return Jt(e);case"FeatureCollection":return function Sn(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=>Jt(n)),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Dt(e);default:throw new Error("unknown GeoJSON type")}}(e)),lt(e,function(r){var i="mercator"===t?en(r):tn(r);r[0]=i[0],r[1]=i[1]})),e}function en(e){var t=Math.PI/180,n=6378137,o=20037508.342789244,r=Math.abs(e[0])<=180?e[0]:e[0]-360*function On(e){return e<0?-1:e>0?1:0}(e[0]),i=[n*r*t,n*Math.log(Math.tan(.25*Math.PI+.5*e[1]*t))];return i[0]>o&&(i[0]=o),i[0]<-o&&(i[0]=-o),i[1]>o&&(i[1]=o),i[1]<-o&&(i[1]=-o),i}function tn(e){var t=180/Math.PI,n=6378137;return[e[0]*t/n,(.5*Math.PI-2*Math.atan(Math.exp(-e[1]/n)))*t]}function nn(e,t,n){const o=t.geometry.coordinates,r=n.geometry.coordinates;if(o[1]>k||o[1]<w||r[1]>k||r[1]<w)return null;const i=Qt(o),d=Qt(r),M=j=>Number(j.toFixed(8)),g=(j,P)=>(j+P)/2,N=function In(e,t={}){return qt(e,"wgs84",t)}([g(i[0],d[0]),g(i[1],d[1])]),K=[M(N[0]),M(N[1])];return{type:S.FEATURE,properties:{meta:C.MIDPOINT,parent:e,lng:K[0],lat:K[1],coord_path:n.properties.coord_path},geometry:{type:S.POINT,coordinates:K}}}Math;const wt=function on(e,t={},n=null){const{type:o,coordinates:r}=e.geometry,i=e.properties&&e.properties.id;let d=[];function M(K,j){let P="",G=null;K.forEach(($,ee)=>{const Ce=null!=j?`${j}.${ee}`:String(ee),Te=Ze(i,$,Ce,g(Ce));if(t.midpoints&&G){const Pe=nn(i,G,Te);Pe&&d.push(Pe)}G=Te;const Ve=JSON.stringify($);P!==Ve&&d.push(Te),0===ee&&(P=Ve)})}function g(K){return!!t.selectedPaths&&-1!==t.selectedPaths.indexOf(K)}return o===S.POINT?d.push(Ze(i,r,n,g(n))):o===S.POLYGON?r.forEach((K,j)=>{M(K,null!==n?`${n}.${j}`:String(j))}):o===S.LINE_STRING?M(r,n):0===o.indexOf(S.MULTI_PREFIX)&&function N(){const K=o.replace(S.MULTI_PREFIX,"");r.forEach((j,P)=>{d=d.concat(on({type:S.FEATURE,properties:e.properties,geometry:{type:K,coordinates:j}},t,P))})}(),d},Ie={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:pt,LAT_MAX:gt,LAT_RENDERED_MIN:rn,LAT_RENDERED_MAX:sn,LNG_MIN:an,LNG_MAX:ln}=O;function At(e,t){let n=pt,o=gt,r=pt,i=gt,d=ln,M=an;e.forEach(N=>{const K=function Fn(e){const n=[e.geometry.coordinates].flat({Point:0,LineString:1,Polygon:2,MultiPoint:1,MultiLineString:2,MultiPolygon:3}[e.geometry.type]),o=n.map(M=>M[0]),r=n.map(M=>M[1]),i=M=>Math.min.apply(null,M),d=M=>Math.max.apply(null,M);return[i(o),i(r),d(o),d(r)]}(N),j=K[1],P=K[3],G=K[0],$=K[2];j>n&&(n=j),P<o&&(o=P),P>r&&(r=P),j<i&&(i=j),G<d&&(d=G),$>M&&(M=$)});const g=t;return n+g.lat>sn&&(g.lat=sn-n),r+g.lat>gt&&(g.lat=gt-r),o+g.lat<rn&&(g.lat=rn-o),i+g.lat<pt&&(g.lat=pt-i),d+g.lng<=an&&(g.lng+=360*Math.ceil(Math.abs(g.lng)/360)),M+g.lng>=ln&&(g.lng-=360*Math.ceil(Math.abs(g.lng)/360)),g}function Nt(e,t){const n=At(e.map(o=>o.toGeoJSON()),t);e.forEach(o=>{const r=o.getCoordinates(),i=N=>{const K={lng:N[0]+n.lng,lat:N[1]+n.lat};return[K.lng,K.lat]},d=N=>N.map(K=>i(K));let g;o.type===S.POINT?g=i(r):o.type===S.LINE_STRING||o.type===S.MULTI_POINT?g=r.map(i):o.type===S.POLYGON||o.type===S.MULTI_LINE_STRING?g=r.map(d):o.type===S.MULTI_POLYGON&&(g=r.map(N=>N.map(K=>d(K)))),o.incomingCoords(g)})}const ce={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=>void 0!==this.getFeature(n))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),t},fireUpdate:function(){this.fire(a.UPDATE,{action:h.MOVE,features:this.getSelected().map(e=>e.toGeoJSON())})},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(d=>{d.type.replace("Multi","")!==i&&(n=!1)})}this.setActionableState({combineFeatures:n,uncombineFeatures:t.length>0,trash:e.length>0})},getUniqueIds:function(e){return e.length?e.map(n=>n.properties.id).filter(n=>void 0!==n).reduce((n,o)=>(n.add(o),n),new Ae).values():[]},stopExtendedInteractions:function(e){e.boxSelectElement&&(e.boxSelectElement.parentNode&&e.boxSelectElement.parentNode.removeChild(e.boxSelectElement),e.boxSelectElement=null),(e.canDragMove||e.canBoxSelect)&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.boxSelecting=!1,e.canBoxSelect=!1,e.dragMoving=!1,e.canDragMove=!1},onStop:function(){Ie.enable(this)},onMouseMove:function(e,t){return Z(t)&&e.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(e),!0},onMouseOut:function(e){return!e.dragMoving||this.fireUpdate()}};ce.onTap=ce.onClick=function(e,t){return W(t)?this.clickAnywhere(e,t):L(C.VERTEX)(t)?this.clickOnVertex(e,t):Z(t)?this.clickOnFeature(e,t):void 0},ce.clickAnywhere=function(e){const t=this.getSelectedIds();t.length&&(this.clearSelectedFeatures(),t.forEach(n=>this.doRender(n))),Ie.enable(this),this.stopExtendedInteractions(e)},ce.clickOnVertex=function(e,t){this.changeMode(p.DIRECT_SELECT,{featureId:t.featureTarget.properties.parent,coordPath:t.featureTarget.properties.coord_path,startPos:t.lngLat}),this.updateUIClasses({mouse:v.MOVE})},ce.startOnActiveFeature=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),this.doRender(t.featureTarget.properties.id),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},ce.clickOnFeature=function(e,t){Ie.disable(this),this.stopExtendedInteractions(e);const n=oe(t),o=this.getSelectedIds(),r=t.featureTarget.properties.id,i=this.isSelected(r);if(!n&&i&&this.getFeature(r).type!==S.POINT)return this.changeMode(p.DIRECT_SELECT,{featureId:r});i&&n?(this.deselect(r),this.updateUIClasses({mouse:v.POINTER}),1===o.length&&Ie.enable(this)):!i&&n?(this.select(r),this.updateUIClasses({mouse:v.MOVE})):!i&&!n&&(o.forEach(d=>this.doRender(d)),this.setSelected(r),this.updateUIClasses({mouse:v.MOVE})),this.doRender(r)},ce.onMouseDown=function(e,t){return e.initialDragPanState=this.map.dragPan.isEnabled(),T(t)?this.startOnActiveFeature(e,t):this.drawConfig.boxSelect&&x(t)?this.startBoxSelect(e,t):void 0},ce.startBoxSelect=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),e.boxSelectStartLocation=Ot(t.originalEvent,this.map.getContainer()),e.canBoxSelect=!0},ce.onTouchStart=function(e,t){if(T(t))return this.startOnActiveFeature(e,t)},ce.onDrag=function(e,t){return e.canDragMove?this.dragMove(e,t):this.drawConfig.boxSelect&&e.canBoxSelect?this.whileBoxSelect(e,t):void 0},ce.whileBoxSelect=function(e,t){e.boxSelecting=!0,this.updateUIClasses({mouse:v.ADD}),e.boxSelectElement||(e.boxSelectElement=document.createElement("div"),e.boxSelectElement.classList.add(s.BOX_SELECT),this.map.getContainer().appendChild(e.boxSelectElement));const n=Ot(t.originalEvent,this.map.getContainer()),o=Math.min(e.boxSelectStartLocation.x,n.x),r=Math.max(e.boxSelectStartLocation.x,n.x),i=Math.min(e.boxSelectStartLocation.y,n.y),d=Math.max(e.boxSelectStartLocation.y,n.y),M=`translate(${o}px, ${i}px)`;e.boxSelectElement.style.transform=M,e.boxSelectElement.style.WebkitTransform=M,e.boxSelectElement.style.width=r-o+"px",e.boxSelectElement.style.height=d-i+"px"},ce.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};Nt(this.getSelected(),n),e.dragMoveLocation=t.lngLat},ce.onTouchEnd=ce.onMouseUp=function(e,t){if(e.dragMoving)this.fireUpdate();else if(e.boxSelecting){const n=[e.boxSelectStartLocation,Ot(t.originalEvent,this.map.getContainer())],o=this.featuresAt(null,n,"click"),r=this.getUniqueIds(o).filter(i=>!this.isSelected(i));r.length&&(this.select(r),r.forEach(i=>this.doRender(i)),this.updateUIClasses({mouse:v.MOVE}))}this.stopExtendedInteractions(e)},ce.toDisplayFeatures=function(e,t,n){t.properties.active=this.isSelected(t.properties.id)?F.ACTIVE:F.INACTIVE,n(t),this.fireActionable(),t.properties.active===F.ACTIVE&&t.geometry.type!==S.POINT&&wt(t).forEach(n)},ce.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},ce.onCombineFeatures=function(){const e=this.getSelected();if(0===e.length||e.length<2)return;const t=[],n=[],o=e[0].type.replace("Multi","");for(let r=0;r<e.length;r++){const i=e[r];if(i.type.replace("Multi","")!==o)return;i.type.includes("Multi")?i.getCoordinates().forEach(d=>{t.push(d)}):t.push(i.getCoordinates()),n.push(i.toGeoJSON())}if(n.length>1){const r=this.newFeature({type:S.FEATURE,properties:n[0].properties,geometry:{type:`Multi${o}`,coordinates:t}});this.addFeature(r),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([r.id]),this.fire(a.COMBINE_FEATURES,{createdFeatures:[r.toGeoJSON()],deletedFeatures:n})}this.fireActionable()},ce.onUncombineFeatures=function(){const e=this.getSelected();if(0===e.length)return;const t=[],n=[];for(let o=0;o<e.length;o++){const r=e[o];this.isInstanceOf("MultiFeature",r)&&(r.getFeatures().forEach(i=>{this.addFeature(i),i.properties=r.properties,t.push(i.toGeoJSON()),this.select([i.id])}),this.deleteFeature(r.id,{silent:!0}),n.push(r.toGeoJSON()))}t.length>1&&this.fire(a.UNCOMBINE_FEATURES,{createdFeatures:t,deletedFeatures:n}),this.fireActionable()};const xn=ce,cn=L(C.VERTEX),un=L(C.MIDPOINT),ue={fireUpdate:function(){this.fire(a.UPDATE,{action:h.CHANGE_COORDINATES,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(e){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:e.selectedCoordPaths.length>0})},startDragging:function(e,t){null==e.initialDragPanState&&(e.initialDragPanState=this.map.dragPan.isEnabled()),this.map.dragPan.disable(),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},stopDragging:function(e){e.canDragMove&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.initialDragPanState=null,e.dragMoving=!1,e.canDragMove=!1,e.dragMoveLocation=null},onVertex:function(e,t){this.startDragging(e,t);const n=t.featureTarget.properties,o=e.selectedCoordPaths.indexOf(n.coord_path);oe(t)||-1!==o?oe(t)&&-1===o&&e.selectedCoordPaths.push(n.coord_path):e.selectedCoordPaths=[n.coord_path];const r=this.pathsToCoordinates(e.featureId,e.selectedCoordPaths);this.setSelectedCoordinates(r)},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]},pathsToCoordinates:function(e,t){return t.map(n=>({feature_id:e,coord_path:n}))},onFeature:function(e,t){0===e.selectedCoordPaths.length?this.startDragging(e,t):this.stopDragging(e)},dragFeature:function(e,t,n){Nt(this.getSelected(),n),e.dragMoveLocation=t.lngLat},dragVertex:function(e,t,n){const o=e.selectedCoordPaths.map(d=>e.feature.getCoordinate(d)),i=At(o.map(d=>({type:S.FEATURE,properties:{},geometry:{type:S.POINT,coordinates:d}})),n);for(let d=0;d<o.length;d++){const M=o[d];e.feature.updateCoordinate(e.selectedCoordPaths[d],M[0]+i.lng,M[1]+i.lat)}},clickNoTarget:function(){this.changeMode(p.SIMPLE_SELECT)},clickInactive:function(){this.changeMode(p.SIMPLE_SELECT)},clickActiveFeature:function(e){e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed()},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===S.POINT)throw new TypeError("direct_select mode doesn't handle point features");const o={featureId:t,feature:n,dragMoveLocation:e.startPos||null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:e.coordPath?[e.coordPath]:[]};return this.setSelectedCoordinates(this.pathsToCoordinates(t,o.selectedCoordPaths)),this.setSelected(t),Ie.disable(this),this.setActionableState({trash:!0}),o},onStop:function(){Ie.enable(this),this.clearSelectedCoordinates()},toDisplayFeatures:function(e,t,n){e.featureId===t.properties.id?(t.properties.active=F.ACTIVE,n(t),wt(t,{map:this.map,midpoints:!0,selectedPaths:e.selectedCoordPaths}).forEach(n)):(t.properties.active=F.INACTIVE,n(t)),this.fireActionable(e)},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),!1===e.feature.isValid()&&(this.deleteFeature([e.featureId]),this.changeMode(p.SIMPLE_SELECT,{}))},onMouseMove:function(e,t){const n=T(t),o=cn(t),r=un(t),i=0===e.selectedCoordPaths.length;return this.updateUIClasses(n&&i||o&&!i?{mouse:v.MOVE}:{mouse:v.NONE}),(o||n||r)&&e.dragMoving&&this.fireUpdate(),this.stopDragging(e),!0},onMouseOut:function(e){return e.dragMoving&&this.fireUpdate(),!0}};ue.onTouchStart=ue.onMouseDown=function(e,t){return cn(t)?this.onVertex(e,t):T(t)?this.onFeature(e,t):un(t)?this.onMidpoint(e,t):void 0},ue.onDrag=function(e,t){if(!0!==e.canDragMove)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},ue.onClick=function(e,t){return W(t)?this.clickNoTarget(e,t):T(t)?this.clickActiveFeature(e,t):A(t)?this.clickInactive(e,t):void this.stopDragging(e)},ue.onTap=function(e,t){return W(t)?this.clickNoTarget(e,t):T(t)?this.clickActiveFeature(e,t):A(t)?this.clickInactive(e,t):void 0},ue.onTouchEnd=ue.onMouseUp=function(e){e.dragMoving&&this.fireUpdate(),this.stopDragging(e)};const Dn=ue,xe={onSetup:function(){const e=this.newFeature({type:S.FEATURE,properties:{},geometry:{type:S.POINT,coordinates:[]}});return this.addFeature(e),this.clearSelectedFeatures(),this.updateUIClasses({mouse:v.ADD}),this.activateUIButton(R.POINT),this.setActionableState({trash:!0}),{point:e}},stopDrawingAndRemove:function(e){this.deleteFeature([e.point.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT)}};xe.onTap=xe.onClick=function(e,t){this.updateUIClasses({mouse:v.MOVE}),e.point.updateCoordinate("",t.lngLat.lng,t.lngLat.lat),this.fire(a.CREATE,{features:[e.point.toGeoJSON()]}),this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.point.id]})},xe.onStop=function(e){this.activateUIButton(),e.point.getCoordinate().length||this.deleteFeature([e.point.id],{silent:!0})},xe.toDisplayFeatures=function(e,t,n){const o=t.properties.id===e.point.id;if(t.properties.active=o?F.ACTIVE:F.INACTIVE,!o)return n(t)},xe.onTrash=xe.stopDrawingAndRemove,xe.onKeyUp=function(e,t){if(ye(t)||he(t))return this.stopDrawingAndRemove(e,t)};const wn=xe,mt=function An(e,t){return!!e.lngLat&&e.lngLat.lng===t[0]&&e.lngLat.lat===t[1]},Oe={onSetup:function(){const e=this.newFeature({type:S.FEATURE,properties:{},geometry:{type:S.POLYGON,coordinates:[[]]}});return this.addFeature(e),this.clearSelectedFeatures(),Ie.disable(this),this.updateUIClasses({mouse:v.ADD}),this.activateUIButton(R.POLYGON),this.setActionableState({trash:!0}),{polygon:e,currentVertexPosition:0}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&mt(t,e.polygon.coordinates[0][e.currentVertexPosition-1]))return this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.polygon.id]});this.updateUIClasses({mouse:v.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)},clickOnVertex:function(e){return this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},onMouseMove:function(e,t){e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),J(t)&&this.updateUIClasses({mouse:v.POINTER})}};Oe.onTap=Oe.onClick=function(e,t){return J(t)?this.clickOnVertex(e,t):this.clickAnywhere(e,t)},Oe.onKeyUp=function(e,t){ye(t)?(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT)):he(t)&&this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},Oe.onStop=function(e){this.updateUIClasses({mouse:v.NONE}),Ie.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.polygon.id)&&(e.polygon.removeCoordinate(`0.${e.currentVertexPosition}`),e.polygon.isValid()?this.fire(a.CREATE,{features:[e.polygon.toGeoJSON()]}):(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT,{},{silent:!0})))},Oe.toDisplayFeatures=function(e,t,n){const o=t.properties.id===e.polygon.id;if(t.properties.active=o?F.ACTIVE:F.INACTIVE,!o)return n(t);if(0===t.geometry.coordinates.length)return;const r=t.geometry.coordinates[0].length;if(!(r<3)){if(t.properties.meta=C.FEATURE,n(Ze(e.polygon.id,t.geometry.coordinates[0][0],"0.0",!1)),r>3){const i=t.geometry.coordinates[0].length-3;n(Ze(e.polygon.id,t.geometry.coordinates[0][i],`0.${i}`,!1))}if(r<=4&&(n({type:S.FEATURE,properties:t.properties,geometry:{coordinates:[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]],type:S.LINE_STRING}}),3===r))return;return n(t)}},Oe.onTrash=function(e){this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT)};const Nn=Oe,Fe={onSetup:function(e){const t=(e=e||{}).featureId;let n,o,r="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&&"Feature"===i.type&&i.geometry&&"Point"===i.geometry.type&&(i=i.geometry),i&&"Point"===i.type&&i.coordinates&&2===i.coordinates.length&&(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 d=n.coordinates.length-1;if(n.coordinates[d][0]===i[0]&&n.coordinates[d][1]===i[1])o=d+1,n.addCoordinate(o,...n.coordinates[d]);else{if(n.coordinates[0][0]!==i[0]||n.coordinates[0][1]!==i[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");r="backwards",o=0,n.addCoordinate(o,...n.coordinates[0])}}else n=this.newFeature({type:S.FEATURE,properties:{},geometry:{type:S.LINE_STRING,coordinates:[]}}),o=0,this.addFeature(n);return this.clearSelectedFeatures(),Ie.disable(this),this.updateUIClasses({mouse:v.ADD}),this.activateUIButton(R.LINE),this.setActionableState({trash:!0}),{line:n,currentVertexPosition:o,direction:r}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&mt(t,e.line.coordinates[e.currentVertexPosition-1])||"backwards"===e.direction&&mt(t,e.line.coordinates[e.currentVertexPosition+1]))return this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.line.id]});this.updateUIClasses({mouse:v.ADD}),e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),"forward"===e.direction?(e.currentVertexPosition++,e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat)):e.line.addCoordinate(0,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.line.id]})},onMouseMove:function(e,t){e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),J(t)&&this.updateUIClasses({mouse:v.POINTER})}};Fe.onTap=Fe.onClick=function(e,t){if(J(t))return this.clickOnVertex(e,t);this.clickAnywhere(e,t)},Fe.onKeyUp=function(e,t){he(t)?this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.line.id]}):ye(t)&&(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT))},Fe.onStop=function(e){Ie.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.line.id)&&(e.line.removeCoordinate(`${e.currentVertexPosition}`),e.line.isValid()?this.fire(a.CREATE,{features:[e.line.toGeoJSON()]}):(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT,{},{silent:!0})))},Fe.onTrash=function(e){this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT)},Fe.toDisplayFeatures=function(e,t,n){const o=t.properties.id===e.line.id;if(t.properties.active=o?F.ACTIVE:F.INACTIVE,!o)return n(t);t.geometry.coordinates.length<2||(t.properties.meta=C.FEATURE,n(Ze(e.line.id,t.geometry.coordinates["forward"===e.direction?t.geometry.coordinates.length-2:1],""+("forward"===e.direction?t.geometry.coordinates.length-2:1),!1)),n(t))};const dn={simple_select:xn,direct_select:Dn,draw_point:wn,draw_polygon:Nn,draw_line_string:Fe},Rn={defaultMode:p.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:Gt,modes:dn,controls:{},userProperties:!1,suppressAPIEvents:!0},Bn={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},kn={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function fn(e,t){return e.map(n=>n.source?n:Object.assign({},n,{id:`${n.id}.${t}`,source:"hot"===t?b.HOT:b.COLD}))}var hn=c(362),Vn=c(5341);function pn(e,t){return e.length===t.length&&JSON.stringify(e.map(n=>n).sort())===JSON.stringify(t.map(n=>n).sort())}const Un={Polygon:ae,LineString:ne,Point:Y,MultiPolygon:Ne,MultiLineString:Ne,MultiPoint:Ne};function yt(e){!function(e,t){e=function Gn(e={}){let t=Object.assign({},e);return e.controls||(t.controls={}),t.controls=Object.assign({},!1===e.displayControlsDefault?kn:Bn,e.controls),t=Object.assign({},Rn,t),t.styles=fn(t.styles,"cold").concat(fn(t.styles,"hot")),t}(e);const n={options:e};t=function zn(e,t){t.modes=p;const n=void 0===e.options.suppressAPIEvents||!!e.options.suppressAPIEvents;return t.getFeatureIdsAt=function(o){return Be.click({point:o},null,e).map(i=>i.properties.id)},t.getSelectedIds=function(){return e.store.getSelectedIds()},t.getSelected=function(){return{type:S.FEATURE_COLLECTION,features:e.store.getSelectedIds().map(o=>e.store.get(o)).map(o=>o.toGeoJSON())}},t.getSelectedPoints=function(){return{type:S.FEATURE_COLLECTION,features:e.store.getSelectedCoordinates().map(o=>({type:S.FEATURE,properties:{},geometry:{type:S.POINT,coordinates:o.coordinates}}))}},t.set=function(o){if(void 0===o.type||o.type!==S.FEATURE_COLLECTION||!Array.isArray(o.features))throw new Error("Invalid FeatureCollection");const r=e.store.createRenderBatch();let i=e.store.getAllIds().slice();const d=t.add(o),M=new Ae(d);return i=i.filter(g=>!M.has(g)),i.length&&t.delete(i),r(),d},t.add=function(o){const i=JSON.parse(JSON.stringify(Vn(o))).features.map(d=>{if(d.id=d.id||l(),null===d.geometry)throw new Error("Invalid geometry: null");if(void 0===e.store.get(d.id)||e.store.get(d.id).type!==d.geometry.type){const M=Un[d.geometry.type];if(void 0===M)throw new Error(`Invalid geometry type: ${d.geometry.type}.`);const g=new M(e,d);e.store.add(g,{silent:n})}else{const M=e.store.get(d.id),g=M.properties;M.properties=d.properties,hn(g,d.properties)||e.store.featureChanged(M.id,{silent:n}),hn(M.getCoordinates(),d.geometry.coordinates)||M.incomingCoords(d.geometry.coordinates)}return d.id});return e.store.render(),i},t.get=function(o){const r=e.store.get(o);if(r)return r.toGeoJSON()},t.getAll=function(){return{type:S.FEATURE_COLLECTION,features:e.store.getAll().map(o=>o.toGeoJSON())}},t.delete=function(o){return e.store.delete(o,{silent:n}),t.getMode()!==p.DIRECT_SELECT||e.store.getSelectedIds().length?e.store.render():e.events.changeMode(p.SIMPLE_SELECT,void 0,{silent:n}),t},t.deleteAll=function(){return e.store.delete(e.store.getAllIds(),{silent:n}),t.getMode()===p.DIRECT_SELECT?e.events.changeMode(p.SIMPLE_SELECT,void 0,{silent:n}):e.store.render(),t},t.changeMode=function(o,r={}){return o===p.SIMPLE_SELECT&&t.getMode()===p.SIMPLE_SELECT?(pn(r.featureIds||[],e.store.getSelectedIds())||(e.store.setSelected(r.featureIds,{silent:n}),e.store.render()),t):(o===p.DIRECT_SELECT&&t.getMode()===p.DIRECT_SELECT&&r.featureId===e.store.getSelectedIds()[0]||e.events.changeMode(o,r,{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(o,r,i){return e.store.setFeatureProperty(o,r,i,{silent:n}),t},t}(n,t),n.api=t;const o=Bt(n);t.onAdd=o.onAdd,t.onRemove=o.onRemove,t.types=R,t.options=e}(e,this)}yt.modes=dn,yt.constants=O,yt.lib=D;const gn=yt;let Wn=(()=>{class e{_draw;_map;_drawMode=(0,z.vPA)(!1);_settingDrawMode=!1;_eventListeners=[];_clearAfterFinish=!0;drawEvent=(0,z.vPA)(void 0);destroy(){this._cleanup()}initializeWithMap(n){this._map=n,this._initDrawControl(n)}setDrawMode(n,o){if(this._draw&&this._map&&!this._settingDrawMode){if(this._clearAfterFinish=o,this._settingDrawMode=!0,this._drawMode.set(n),n){this._draw.deleteAll(),this._draw.changeMode("draw_polygon");const r={type:"polygon",status:"started",coordinates:[],bbox:{minLng:0,minLat:0,maxLng:0,maxLat:0}};this.drawEvent.update(()=>r)}else this._draw.changeMode("simple_select"),this._draw.deleteAll();this._settingDrawMode=!1}}setClearAfterFinish(n){this._clearAfterFinish=n}getClearAfterFinish(){return this._clearAfterFinish}getDrawMode(){return this._drawMode()}clearDrawings(){this._draw&&this._draw.deleteAll()}getDrawInstance(){return this._draw}_initDrawControl(n){this._draw=new gn({displayControlsDefault:!1,modes:{...gn.modes}}),n.addControl(this._draw,"top-left");const o=document.querySelector(".mapbox-gl-draw_ctrl-draw-btn")?.parentElement;o&&(o.style.display="none");const r=M=>{const g=M.features[0];if("Polygon"===g.geometry.type){const N=g.geometry.coordinates[0],j={type:"polygon",status:"ended",coordinates:N,bbox:this._calculateBBox(N)};this.drawEvent.update(()=>j),this._drawMode.set(!1),this._clearAfterFinish&&this._draw?.deleteAll()}},i=M=>{const g=M.features[0];if("Polygon"===g.geometry.type){const N=g.geometry.coordinates[0],j={type:"polygon",status:"in-progress",coordinates:N,bbox:this._calculateBBox(N)};this.drawEvent.update(()=>j)}},d=()=>{if(this._drawMode()){const M=this._draw?.getAll();if(M?.features?.length){const g=M.features[0];if("Polygon"===g.geometry.type){const N=g.geometry.coordinates[0];if(N.length>2){const j={type:"polygon",status:"in-progress",coordinates:N,bbox:this._calculateBBox(N)};this.drawEvent.update(()=>j)}}}}};n.on("draw.create",r),n.on("draw.update",i),n.on("mousemove",d),this._eventListeners.push({event:"draw.create",handler:r}),this._eventListeners.push({event:"draw.update",handler:i}),this._eventListeners.push({event:"mousemove",handler:d})}_cleanup(){this._map&&(this._eventListeners.forEach(({event:n,handler:o})=>{this._map?.off(n,o)}),this._eventListeners=[],this._draw&&this._map._controls?.includes(this._draw)&&this._map.removeControl(this._draw)),this._draw=void 0,this._map=void 0,this.drawEvent.set(void 0)}_calculateBBox(n){return n.reduce((o,r)=>({minLng:Math.min(o.minLng,r[0]),minLat:Math.min(o.minLat,r[1]),maxLng:Math.max(o.maxLng,r[0]),maxLat:Math.max(o.maxLat,r[1])}),{minLng:1/0,minLat:1/0,maxLng:-1/0,maxLat:-1/0})}static \u0275fac=function(o){return new(o||e)};static \u0275prov=z.jDH({token:e,factory:e.\u0275fac})}return e})()},6986(le,Q,c){"use strict";c.d(Q,{A4:()=>O,Jc:()=>v,Ln:()=>D,dx:()=>s,g8:()=>m,j5:()=>z,n7:()=>b});const O=12;function m(p,a,h){return{id:p,source:a,type:"circle",maxzoom:O,filter:["==",["get","_isCentroid"],!0],paint:{"circle-radius":6,"circle-color":["coalesce",["get","_color"],h],"circle-stroke-width":2,"circle-stroke-color":"white","circle-opacity":.8}}}function D(p,a,h,C){return function S(p,a,h,C,F){const B={id:p,source:C},E=F||h;switch(a){case"Point":case"MultiPoint":return[{...B,id:`${p}-clusters`,type:"circle",filter:["has","point_count"],paint:{"circle-color":E,"circle-radius":["step",["get","point_count"],15,100,20,750,25],"circle-stroke-width":2,"circle-stroke-color":"white","circle-opacity":.8}},{...B,id:`${p}-cluster-count`,type:"symbol",filter:["has","point_count"],layout:{"text-field":"{point_count_abbreviated}","text-font":["Poppins Medium","Arial Unicode MS Bold"],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#ffffff","text-halo-color":"rgba(0, 0, 0, 0.3)","text-halo-width":1}},{...B,id:`${p}-unclustered`,type:"circle",filter:["!",["has","point_count"]],paint:{"circle-radius":6,"circle-color":["coalesce",["get","_color"],h],"circle-stroke-width":2,"circle-stroke-color":"white","circle-opacity":.8}}];case"LineString":case"MultiLineString":return{...B,type:"line",paint:{"line-color":["coalesce",["get","_color"],h],"line-width":3,"line-opacity":.8},layout:{"line-join":"round","line-cap":"round"}};case"Polygon":case"MultiPolygon":return[{id:`${p}-fill`,source:C,type:"fill",paint:{"fill-color":["coalesce",["get","_color"],h],"fill-opacity":.3}},{id:`${p}-stroke`,source:C,type:"line",paint:{"line-color":["coalesce",["get","_color"],h],"line-width":2,"line-opacity":.8},layout:{"line-join":"round","line-cap":"round"}},{id:`${p}-labels`,source:C,type:"symbol",layout:{"text-field":["coalesce",["get","label"],""],"text-font":["Poppins Medium","Arial Unicode MS Bold"],"text-size":13,"text-anchor":"center","text-allow-overlap":!1},paint:{"text-color":"#333333","text-halo-color":"rgba(255, 255, 255, 0.9)","text-halo-width":2}}];default:return console.warn(`Unsupported geometry type: ${a}`),null}}(p,a,h,C,h)}function z(p){return"Polygon"===p||"MultiPolygon"===p}function s(p){return"LineString"===p||"MultiLineString"===p}function b(p,a){return a&&("Point"===p||"MultiPoint"===p)}function v(p,a){return b(p,a)?{cluster:!0,clusterMaxZoom:14,clusterRadius:50,clusterMinPoints:2}:{cluster:!1}}},3646(le,Q,c){"use strict";c.d(Q,{B:()=>U});var O=c(467),m=c(5802),D=c(2271),z=c(4412),s=c(1413),b=c(2306),v=c(140);function E(k){let X=1/0,f=1/0,L=-1/0,x=-1/0;const T=k.features,A=Z=>{Z.length>=2&&(X=Math.min(X,Z[0]),f=Math.min(f,Z[1]),L=Math.max(L,Z[0]),x=Math.max(x,Z[1]))},W=(Z,J)=>{if(0===J)A(Z);else if(Array.isArray(Z))for(const oe of Z)W(oe,J-1)};for(const Z of T){const J=Z.geometry;switch(J.type){case"Point":W(J.coordinates,0);break;case"LineString":case"MultiPoint":W(J.coordinates,1);break;case"Polygon":case"MultiLineString":W(J.coordinates,2);break;case"MultiPolygon":W(J.coordinates,3);break;case"GeometryCollection":for(const oe of J.geometries){const pe=E(new v.o([{type:"Feature",geometry:oe,properties:null}]));pe&&(A([pe[0],pe[1]]),A([pe[2],pe[3]]))}}}return X===1/0?null:[X,f,L,x]}var w=c(6986);let U=(()=>{class k{_layers$=new z.t([]);_map;_sources={};_sourceLayers={};_sourceIds=[];_attachedListeners=[];_hoveredFeature=(0,m.vPA)(void 0);_layerGroups={};_layerClickable={};_pointLayerIds=new Set;_lineLayerIds=new Set;_processedClickEvents=new WeakSet;_clearHoverTimeout;_hoverSequence=0;layers=this._layers$.asObservable();layersSignal=(0,D.EW)(()=>this._layers$.getValue());clickedFeature=new s.B;hoveredFeature=new s.B;initializeWithMap(f){this._map=f,f.on("mousemove",L=>{const x=f.getCanvas();if(!x)return;const T=Object.keys(this._layerClickable).filter(W=>this._layerClickable[W]&&f.getLayer(W)),A=f.queryRenderedFeatures(L.point,{layers:T});x.style.cursor=A.length>0?"pointer":""})}getLayers(){return this._layers$.getValue()}setLayers(f){this._layers$.next([...f])}addLayer(f){const L=this._layers$.getValue(),x=L.findIndex(T=>T.id===f.id);x>=0?L[x]={...f}:L.push({...f}),this._layers$.next([...L])}removeLayer(f){const x=this._layers$.getValue().filter(T=>T.id!==f);this._layers$.next(x),this._deleteSourceIfExists(f.toString()),delete this._sources[f.toString()],delete this._sourceLayers[f.toString()],delete this._layerClickable[f.toString()],this._pointLayerIds.delete(f.toString()),this._lineLayerIds.delete(f.toString()),this._sourceIds=this._sourceIds.filter(T=>T!==f.toString())}toggleVisibility(f){const L=f.toString();if(this._layerGroups[L])return void this.toggleLayerGroupVisibility(L);const T=this._layers$.getValue().map(A=>{if(A.id===f){const W={...A,visible:!A.visible};return this._updateLayerVisibility(f.toString(),W.visible),W}return A});this._layers$.next(T)}setLayerVisibility(f,L){const x=f.toString();if(this._layerGroups[x]){if(this._map){const Z=L?"visible":"none";this._layerGroups[x].forEach(J=>{this._map.setLayoutProperty(J,"visibility",Z)})}}else this._updateLayerVisibility(x,L);const A=this._layers$.getValue().map(W=>W.id===f?{...W,visible:L}:W);this._layers$.next(A)}loadGeoJSONLayerGroup(f,L,x){var T=this;return(0,O.A)(function*(A,W,Z,J={}){const{cluster:oe=!1,zoomToFit:ye=!0,visible:he=!0,label:pe=A,color:me=T._extractColorFromLayer(Z[0])}=J;if(!T._map)return void console.warn("Map not initialized in LayerService");const te=A;yield T._addSource(A,{type:"geojson",data:W,...(0,w.Jc)("Point",oe)});const ze=[];for(const ve of Z){ze.push(ve.id),T._layerClickable[ve.id]=!0,T._sourceLayers[te]||(T._sourceLayers[te]={layer:ve,clickable:!0});const Ke=ve.type;if("circle"===Ke||"symbol"===Ke)T._pointLayerIds.add(ve.id),T._map.addLayer(ve);else if("line"===Ke){T._lineLayerIds.add(ve.id);const we=T._getBeforePointLayerId();T._map.addLayer(ve,we)}else{const we=T._getBeforeLineLayerId()??T._getBeforePointLayerId();T._map.addLayer(ve,we)}T._map&&T._map.setLayoutProperty(ve.id,"visibility",he?"visible":"none")}for(const ve of Z)T._setLayerEvents(te,ve);T._layerGroups[A]=ze;const De=new b.ux(pe,A);De.collection=W,De.color=me,De.visible=he,T.addLayer(De),ye&&T.fitLayerBounds(A)}).apply(this,arguments)}toggleLayerGroupVisibility(f){const L=this._layerGroups[f];if(!L)return;const x=this.getLayer(f);if(!x)return;const T=!x.visible;if(this._map){const A=T?"visible":"none";L.forEach(W=>{this._map.setLayoutProperty(W,"visibility",A)})}this.updateLayer(f,{visible:T})}removeLayerGroup(f){const L=this._layerGroups[f];L&&(this._map&&(L.forEach(x=>{this._map.removeLayer(x),this._attachedListeners=this._attachedListeners.filter(T=>T!==f),delete this._layerClickable[x],this._pointLayerIds.delete(x),this._lineLayerIds.delete(x)}),this._deleteSourceIfExists(f)),delete this._sources[f],delete this._sourceLayers[f],this._sourceIds=this._sourceIds.filter(x=>x!==f),delete this._layerGroups[f],this.removeLayer(f))}loadGeoJSONLayer(f,L,x){var T=this;return(0,O.A)(function*(A,W,Z,J={}){const{cluster:oe=!0,zoomToFit:ye=!0,visible:he=!0,label:pe=A,color:me=T._extractColorFromLayer(Z)}=J;if(!T._map)return void console.warn("Map not initialized in LayerService");yield T._addSource(A,{type:"geojson",data:W,...(0,w.Jc)("Point",oe)},Z);const te=new b.ux(pe,A);te.collection=W,te.color=me,te.visible=he,T.addLayer(te),T._updateLayerVisibility(A,he),ye&&T.fitLayerBounds(A)}).apply(this,arguments)}_addSource(f,L,x){var T=this;return(0,O.A)(function*(A,W,Z,J=!0){T._map&&(T._sources[A]=W,T._deleteSourceIfExists(A),T._sourceIds.push(A),T._map.getSource(A)&&T._map.removeSource(A),T._map.addSource(A,W),Z&&T._addSourceLayer(A,Z,J))}).apply(this,arguments)}_getBeforePointLayerId(){if(!this._map||0===this._pointLayerIds.size)return;const f=this._map.getStyle()?.layers??[];for(const L of f)if(this._pointLayerIds.has(L.id))return L.id}_getBeforeLineLayerId(){if(!this._map||0===this._lineLayerIds.size)return;const f=this._map.getStyle()?.layers??[];for(const L of f)if(this._lineLayerIds.has(L.id))return L.id}_addSourceLayer(f,L,x=!0){if(!this._map)return;this._layerClickable[L.id]=x,this._sourceLayers[f]||(this._sourceLayers[f]={layer:L,clickable:x});const T=L.type;if("circle"===T||"symbol"===T)this._pointLayerIds.add(L.id),this._map.addLayer(L);else if("line"===T){this._lineLayerIds.add(L.id);const A=this._getBeforePointLayerId();this._map.addLayer(L,A)}else{const A=this._getBeforeLineLayerId()??this._getBeforePointLayerId();this._map.addLayer(L,A)}x&&this._setLayerEvents(f,L)}_updateLayerVisibility(f,L){if(!this._map)return;const x=this._sourceLayers[f];x&&this._map.setLayoutProperty(x.layer.id,"visibility",L?"visible":"none")}getLayer(f){return this._layers$.getValue().find(L=>L.id===f)}updateLayer(f,L){const T=this._layers$.getValue().map(A=>{if(A.id===f){const W={...A,...L};return void 0!==L.visible&&this._updateLayerVisibility(f.toString(),L.visible),W}return A});this._layers$.next(T)}toggleAllLayers(){const f=this._layers$.getValue(),x=!f.some(A=>A.visible),T=f.map(A=>(this._updateLayerVisibility(A.id.toString(),x),{...A,visible:x}));this._layers$.next(T)}getVisibleLayersCount(){return this._layers$.getValue().filter(f=>f.visible).length}getTotalLayersCount(){return this._layers$.getValue().length}hasLayer(f){return this._layers$.getValue().some(L=>L.id===f)}fitGeoJSONBounds(f,L=50,x=!0,T=19){this._fitGeoJSONBounds(f,L,x,T)}fitLayerBounds(f,L=50){const x=this._layers$.getValue().find(T=>T.id===f);!x||!x.collection||!this._map||("features"in x.collection?this._fitGeoJSONBounds(x.collection,L):console.warn("Layer collection is not a FeatureCollection, cannot fit bounds."))}fitAllVisibleLayers(f=50){const L=this._layers$.getValue().filter(W=>W.visible&&W.collection);if(0===L.length||!this._map)return;const x=L.flatMap(W=>{const Z=W.collection;return Z&&"features"in Z&&Array.isArray(Z.features)?Z.features:[]}),T=new v.o(x),A=E(T);A&&(T.bbox=A),this._fitGeoJSONBounds(T,f)}clearAllLayers(){if(this._map){for(const[f,L]of Object.entries(this._layerGroups))L.forEach(x=>{this._map.getLayer(x)&&this._map.removeLayer(x)}),this._map.getSource(f)&&this._map.removeSource(f);for(const f of this._sourceIds)this._layerGroups[f]||this._deleteSourceIfExists(f)}this._sourceIds=[],this._sourceLayers={},this._sources={},this._attachedListeners=[],this._layerGroups={},this._layerClickable={},this._layers$.next([])}reapplyLayers(){this._map&&(Object.keys(this._sources).forEach(f=>{this._deleteSourceIfExists(f),this._map.addSource(f,this._sources[f]);const L=this._sourceLayers[f];if(L){this._map.addLayer(L.layer);const x=this._layers$.getValue().find(T=>T.id===f);x&&this._updateLayerVisibility(f,x.visible)}}),this._reattachAllLayerEvents())}_extractColorFromLayer(f){if("paint"in f&&"object"==typeof f.paint){const L=f.paint;return L["circle-color"]||L["fill-color"]||L["line-color"]||""}return""}_fitGeoJSONBounds(f,L=50,x=!0,T=19){if(!this._map)return void console.warn("Map not initialized when trying to fit bounds");if(!f.features||0===f.features.length)return void console.warn("No features to fit bounds to");let A=f.bbox;if(!A){const W=E(f);if(!W)return void console.warn("Failed to calculate bbox for GeoJSON");f.bbox=W,A=W}if(A&&4===A.length)try{this._map.fitBounds([[A[0],A[1]],[A[2],A[3]]],{padding:L,maxZoom:T,animate:x})}catch(W){console.error("Error fitting bounds:",W)}}_deleteSourceIfExists(f){if(!this._map||!this._map.getSource(f))return;const x=this._layerGroups[f];if(x)x.forEach(T=>{this._map.getLayer(T)&&this._map.removeLayer(T)});else{const T=Object.values(this._sourceLayers).find(A=>"source"in A.layer&&A.layer.source===f);T&&this._map.getLayer(T.layer.id)&&(this._map.removeLayer(T.layer.id),this._attachedListeners=this._attachedListeners.filter(A=>A!==T.layer.id))}this._map.removeSource(f)}_setLayerEvents(f,L){if(!this._map)return;const x=L.id.endsWith("-fill"),T=L.id.endsWith("-stroke"),A=x?L.id.replace("-fill",""):T?L.id.replace("-stroke",""):L.id;if(x||T){const J=`${A}-stroke`;this._layerClickable[`${A}-fill`]=!0,this._layerClickable[J]=!0}if(!this._layerClickable[L.id])return;const W=[];if(x||T){const Z=`${A}-fill`,J=`${A}-stroke`;this._map.getLayer(Z)&&W.push(Z),this._map.getLayer(J)&&W.push(J)}else W.push(L.id);W.forEach(Z=>{this._attachedListeners.includes(Z)||(this._map.on("click",Z,J=>{if(!J.features||this._processedClickEvents.has(J.originalEvent))return;const oe=J.features[0],ye=oe.properties;if(ye&&!ye.cluster){const he=this.getLayer(f)||this.getLayer(A)||this.getLayer(Z);if(he){const pe={...oe,geometry:oe.geometry};if(he.collection&&"features"in he.collection){const me=he.collection.features.find(te=>te.geometry.type===oe.geometry?.type&&JSON.stringify(te.properties)===JSON.stringify(oe.properties));me&&me.id&&(pe.id=me.id)}this._processedClickEvents.add(J.originalEvent),this.clickedFeature.next({feature:pe,event:J.originalEvent,layer:he,lngLat:J.lngLat})}}}),this._map.on("mouseenter",Z,J=>{if(this._hoverSequence++,this._clearHoverTimeout&&(clearTimeout(this._clearHoverTimeout),this._clearHoverTimeout=void 0),!J.features)return;const oe=J.features[0],ye=oe.properties,he={...oe,geometry:oe.geometry};if(ye&&!ye.cluster){const pe=this.getLayer(f)||this.getLayer(A)||this.getLayer(Z);if(pe){if(pe.collection&&"features"in pe.collection){const me=pe.collection.features.find(te=>te.geometry.type===oe.geometry?.type&&JSON.stringify(te.properties)===JSON.stringify(oe.properties));me&&me.id&&(he.id=me.id)}this.hoveredFeature.next({feature:he,event:J.originalEvent,layer:pe,lngLat:J.lngLat})}this._hoveredFeature.set(he)}}),this._map.on("mouseleave",Z,()=>{const J=this._hoverSequence;this._clearHoverTimeout=window.setTimeout(()=>{this._hoverSequence===J&&(this._hoveredFeature.set(void 0),this.hoveredFeature.next(void 0)),this._clearHoverTimeout=void 0},50)}),this._map.on("click",Z,J=>{if(!J.features)return;const oe=J.features[0].properties;if(oe&&oe.cluster){const ye=this._map?.getZoom();ye&&this._map?.flyTo({center:J.lngLat,zoom:ye+1})}}),this._attachedListeners.push(Z))})}_reattachAllLayerEvents(){this._attachedListeners=[],Object.keys(this._sourceLayers).forEach(f=>{const L=this._sourceLayers[f];L&&this._setLayerEvents(f,L.layer)})}static \u0275fac=function(L){return new(L||k)};static \u0275prov=m.jDH({token:k,factory:k.\u0275fac})}return k})()},8017(le,Q,c){"use strict";c.d(Q,{T:()=>St});var O=c(467),m=c(5802),D=c(7705),z=c(2271),s=c(5547),b=c(9769),v=c(5970),R=c(6170),S=c(5949),p=c(2843),a=c(3646),h=c(9079),C=c(1413),F=c(2306),B=c(7089),E=c(9352),w=c(5381),U=c(5187),k=c(5971),X=c(3319);function f(y,I){if(1&y){const l=s.RV6();s.j41(0,"cue-button",5),s.nI1(1,"transloco"),s.bIt("click",function(){m.eBV(l);const _=s.XpG(2);return m.Njj(_.handleZoomFit())}),s.nrm(2,"cue-button-icon",9),s.k0s()}2&y&&s.Y8G("cueTooltip",s.bMT(1,1,"components.map.tooltipZoomFit"))}function L(y,I){if(1&y){const l=s.RV6();s.j41(0,"cue-flexcontainer",3)(1,"cue-button",5),s.nI1(2,"transloco"),s.bIt("click",function(){m.eBV(l);const _=s.XpG();return m.Njj(_.handleZoomOut())}),s.nrm(3,"cue-button-icon",6),s.k0s(),s.j41(4,"cue-button",5),s.nI1(5,"transloco"),s.bIt("click",function(){m.eBV(l);const _=s.XpG();return m.Njj(_.handleZoomIn())}),s.nrm(6,"cue-button-icon",7),s.k0s(),s.nVh(7,f,3,3,"cue-button",8),s.k0s()}if(2&y){const l=s.XpG();s.R7$(),s.Y8G("cueTooltip",s.bMT(2,3,"components.map.tooltipZoomOut")),s.R7$(3),s.Y8G("cueTooltip",s.bMT(5,5,"components.map.tooltipZoomIn")),s.R7$(3),s.vxM(l.displayZoomFit()?7:-1)}}function x(y,I){if(1&y){const l=s.RV6();s.j41(0,"cue-button",10),s.nI1(1,"transloco"),s.nI1(2,"transloco"),s.mxI("selectedChange",function(_){m.eBV(l);const V=s.XpG();return s.DH7(V.layersVisible,_)||(V.layersVisible=_),m.Njj(_)}),s.nrm(3,"cue-button-icon",11),s.k0s()}if(2&y){const l=s.XpG();s.AVh("border-left",l.options().displayZoom&&l.displayLayerToggle()),s.Y8G("cueTooltip",l.layersVisible()?s.bMT(1,6,"components.map.tooltipHideLayers"):s.bMT(2,8,"components.map.tooltipShowLayers"))("toggleButton",!0),s.R50("selected",l.layersVisible),s.R7$(3),s.Y8G("icon",l.layersVisible()?"layers-clear":"layers")}}function T(y,I){if(1&y){const l=s.RV6();s.j41(0,"cue-button",10),s.nI1(1,"transloco"),s.nI1(2,"transloco"),s.mxI("selectedChange",function(_){m.eBV(l);const V=s.XpG();return s.DH7(V.geoFenceDrawEnabled,_)||(V.geoFenceDrawEnabled=_),m.Njj(_)}),s.nrm(3,"cue-button-icon",12),s.k0s()}if(2&y){const l=s.XpG();s.AVh("border-left",l.options().displayGeofenceDraw),s.Y8G("cueTooltip",l.geoFenceDrawEnabled()?s.bMT(1,5,"components.map.tooltipEndDrawGeofence"):s.bMT(2,7,"components.map.tooltipDrawGeofence"))("toggleButton",!0),s.R50("selected",l.geoFenceDrawEnabled)}}let A=(()=>{class y{_service=(0,m.WQX)(S.u);layerService=(0,m.WQX)(a.B);mapLayers=(0,h.ot)(this.layerService.layers);options=(0,D.hFB)(new F.AA);zoom=(0,D.geq)(1);rotate=(0,D.CGW)();geoFenceDrawEnabled=(0,D.geq)(!1);layersVisible=(0,D.geq)(!1);hasLayers=(0,z.EW)(()=>void 0!==this.mapLayers()&&this.mapLayers().length>0);displayLayerToggle=(0,z.EW)(()=>this.options().displayLayerToggle&&this.hasLayers());displayZoomFit=(0,z.EW)(()=>this.options().displayZoom&&this.hasLayers());selectMenuPositions=(0,z.EW)(()=>"top"===this.options().position?"bottomleft":"topleft");handleZoomIn(){this._service.zoomIn()}handleZoomOut(){this._service.zoomOut()}handleZoomFit(){this._service.fitGeoJSONBBOX(void 0,.01)}static \u0275fac=function(u){return new(u||y)};static \u0275cmp=s.VBU({type:y,selectors:[["cue-map-toolbar"]],inputs:{options:[1,"options"],zoom:[1,"zoom"],geoFenceDrawEnabled:[1,"geoFenceDrawEnabled"],layersVisible:[1,"layersVisible"]},outputs:{zoom:"zoomChange",rotate:"rotate",geoFenceDrawEnabled:"geoFenceDrawEnabledChange",layersVisible:"layersVisibleChange"},decls:6,vars:4,consts:[["justify","center",1,"container"],[1,"toolbar",3,"padded"],["align","center"],["align","center","gap","s"],["size","xs","variant","ghost",3,"border-left","cueTooltip","toggleButton","selected"],["size","xs","variant","tertiary",3,"click","cueTooltip"],["icon","zoom-out"],["icon","zoom-in"],["size","xs","variant","tertiary",3,"cueTooltip"],["icon","zoom-fit"],["size","xs","variant","ghost",3,"selectedChange","cueTooltip","toggleButton","selected"],[3,"icon"],["icon","polygon"]],template:function(u,_){1&u&&(s.j41(0,"cue-flexcontainer",0)(1,"cue-card",1)(2,"cue-flexcontainer",2),s.nVh(3,L,8,7,"cue-flexcontainer",3),s.nVh(4,x,4,10,"cue-button",4),s.nVh(5,T,4,9,"cue-button",4),s.k0s()()()),2&u&&(s.R7$(),s.Y8G("padded",!1),s.R7$(2),s.vxM(_.options().displayZoom?3:-1),s.R7$(),s.vxM(_.displayLayerToggle()?4:-1),s.R7$(),s.vxM(_.options().displayGeofenceDraw?5:-1))},dependencies:[w.n,U.Z,k.$,X.a,B.d,E.Kj],styles:[".container[_ngcontent-%COMP%]{width:100%;pointer-events:none}.toolbar[_ngcontent-%COMP%]{pointer-events:all;padding:5px 10px}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return y})();var W=c(7023),Z=c(1024),J=c(9421);function oe(y,I){if(1&y&&s.nrm(0,"cue-key-val",1),2&y){const l=I.$implicit;s.Y8G("key",l.key)("val",l.val)}}let ye=(()=>{class y{props=(0,D.hFB)(null);keyVals=(0,z.EW)(()=>{const l=this.props();return l?Object.entries(l).map(([u,_])=>({key:u,val:String(_)})):[]});static \u0275fac=function(u){return new(u||y)};static \u0275cmp=s.VBU({type:y,selectors:[["cue-props-panel"]],inputs:{props:[1,"props"]},decls:4,vars:0,consts:[[2,"height","100%","overflow-y","auto"],[3,"key","val"]],template:function(u,_){1&u&&(s.j41(0,"cue-flexcontainer",0)(1,"cue-key-val-list"),s.Z7z(2,oe,1,2,"cue-key-val",1,s.Vm6),s.k0s()()),2&u&&(s.R7$(2),s.Dyx(_.keyVals()))},dependencies:[Z.p,J.F,w.n],encapsulation:2,changeDetection:0})}return y})();var he=c(7517);let pe=(()=>{class y{layerService=(0,m.WQX)(a.B);mapLayers=(0,h.ot)(this.layerService.layers);layerDefs=(0,z.EW)(()=>{const l=this.mapLayers();return l?l.map(u=>({label:u.label,color:u.color??"#000000",visible:u.visible,category:u.category})):[]});updateSingle(l){const u=this.mapLayers()?.find(_=>_.label===l.label);u&&this.layerService.toggleVisibility(u.id)}updateAll(l){const u=this.mapLayers();if(u)for(const _ of u)_.visible===l&&this.layerService.toggleVisibility(_.id)}static \u0275fac=function(u){return new(u||y)};static \u0275cmp=s.VBU({type:y,selectors:[["cue-layer-panel"]],decls:1,vars:1,consts:[[3,"layerChange","visibilityAll","layers"]],template:function(u,_){1&u&&(s.j41(0,"cue-layer-legend",0),s.bIt("layerChange",function(Y){return _.updateSingle(Y)})("visibilityAll",function(Y){return _.updateAll(Y)}),s.k0s()),2&u&&s.Y8G("layers",_.layerDefs())},dependencies:[b.MD,he.P],encapsulation:2})}return y})();var me=c(140),te=c(6986);function ve(y){const I=y.flatMap(l=>{const u=function De(y){switch(y.type){case"Point":return[y.coordinates[0],y.coordinates[1]];case"MultiPoint":{if(!y.coordinates.length)return null;const I=y.coordinates.reduce((l,u)=>[l[0]+u[0],l[1]+u[1]],[0,0]);return[I[0]/y.coordinates.length,I[1]/y.coordinates.length]}case"LineString":{if(!y.coordinates.length)return null;const I=Math.floor(y.coordinates.length/2);return[y.coordinates[I][0],y.coordinates[I][1]]}case"MultiLineString":{if(!y.coordinates.length||!y.coordinates[0].length)return null;const I=y.coordinates[0],l=Math.floor(I.length/2);return[I[l][0],I[l][1]]}case"Polygon":{if(!y.coordinates.length||!y.coordinates[0].length)return null;const I=y.coordinates[0],l=I.reduce((u,_)=>[u[0]+_[0],u[1]+_[1]],[0,0]);return[l[0]/I.length,l[1]/I.length]}case"MultiPolygon":{if(!y.coordinates.length||!y.coordinates[0]?.length||!y.coordinates[0][0]?.length)return null;const I=y.coordinates[0][0],l=I.reduce((u,_)=>[u[0]+_[0],u[1]+_[1]],[0,0]);return[l[0]/I.length,l[1]/I.length]}default:return null}}(l.geometry);return u?[{type:"Feature",id:l.id,geometry:{type:"Point",coordinates:u},properties:{...l.properties??{},_isCentroid:!0}}]:[]});return[...y,...I]}const ut=["rgba(255, 0, 0, 0.5)","rgba(0, 0, 255, 0.5)","rgba(0, 255, 0, 0.5)","rgba(255, 165, 0, 0.5)","rgba(128, 0, 128, 0.5)","rgba(255, 192, 203, 0.5)","rgba(255, 255, 0, 0.5)"];function _t(y){const I=y.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d\.]+))?\)/);if(I)return{r:parseInt(I[1]),g:parseInt(I[2]),b:parseInt(I[3]),a:I[4]?parseFloat(I[4]):1};const l=y.match(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/);if(l){const u=l[1];return{r:parseInt(3===u.length?u[0]+u[0]:u.slice(0,2),16),g:parseInt(3===u.length?u[1]+u[1]:u.slice(2,4),16),b:parseInt(3===u.length?u[2]+u[2]:u.slice(4,6),16),a:1}}return{r:0,g:0,b:0,a:1}}function je(y){if(0===y.length)return ut[0];if(1===y.length)return y[0].color;const I=y.map(ae=>({...ae,totalWeight:ae.featureCount*ae.weight})).sort((ae,de)=>de.totalWeight-ae.totalWeight),l=I.reduce((ae,de)=>ae+de.totalWeight,0),u=I[0];if(u.totalWeight/l>.6)return u.color;const _=I.slice(0,Math.min(3,I.length)),V=_.reduce((ae,de)=>ae+de.totalWeight,0);let Y=0,re=0,ne=0,fe=0;for(const ae of _){const de=_t(ae.color),_e=ae.totalWeight/V;Y+=de.r*_e,re+=de.g*_e,ne+=de.b*_e,fe+=de.a*_e}return function dt(y,I,l,u=1){return u<1?`rgba(${Math.round(y)}, ${Math.round(I)}, ${Math.round(l)}, ${u})`:`rgb(${Math.round(y)}, ${Math.round(I)}, ${Math.round(l)})`}(Y,re,ne,fe)}function He(y,I,l,u){if(!u||"Point"!==l&&"MultiPoint"!==l)return[{color:I,weight:1,featureCount:y.length}];const _=y.length;if(_<10)return[{color:I,weight:1,featureCount:_}];let V=0,Y=0,re=0;_>=750?(V=Math.floor(.1*_),Y=Math.floor(.3*_),re=_-V-Y):_>=100?(Y=Math.floor(.4*_),re=_-Y):(re=Math.floor(.8*_),Y=_-re);const ne=[];return re>0&&ne.push({color:I,weight:1,featureCount:re}),Y>0&&ne.push({color:"#f28cb1",weight:2,featureCount:Y}),V>0&&ne.push({color:"#e2f552",weight:3,featureCount:V}),ne}function Qe(y,I,l,u,_,V){const Y=Array.isArray(u)?u:[u];(0,te.j5)(_)?y.layerService.loadGeoJSONLayerGroup(I,l,Y,{cluster:!1,zoomToFit:V.zoomToFit,visible:V.visible,label:V.label,color:V.color}):Y.length>1||("Point"===_||"MultiPoint"===_)&&Array.isArray(Y)&&Y.length>1?y.layerService.loadGeoJSONLayerGroup(I,l,Y,{cluster:(0,te.n7)(_,V.cluster),zoomToFit:V.zoomToFit,visible:V.visible,label:V.label,color:V.color}):y.loadGeoJSON(I,l,Y[0],(0,te.n7)(_,V.cluster),V.zoomToFit)}var vt=c(6756),bt=c(356),ft=c(6279);const Xe=["map"],qe=y=>({position:"bottomleft",hoveredFeature:y}),Et=(y,I)=>I.label;function Mt(y,I){if(1&y){const l=s.RV6();s.j41(0,"cue-menu-item",6),s.bIt("click",function(_){const V=m.eBV(l).$implicit;return m.Njj(V.action(_))}),s.EFF(1),s.k0s()}if(2&y){const l=I.$implicit;s.R7$(),s.JRh(l.label)}}function Ct(y,I){if(1&y&&(s.j41(0,"cue-menu-wrap"),s.Z7z(1,Mt,2,1,"cue-menu-item",null,Et),s.k0s()),2&y){const l=s.XpG();s.R7$(),s.Dyx(l.contextMenuItems())}}function et(y,I){if(1&y&&(s.j41(0,"span"),s.EFF(1),s.k0s()),2&y){const l=s.XpG();s.R7$(),s.JRh(l.mapService.error())}}function Lt(y,I){if(1&y){const l=s.RV6();s.j41(0,"cue-map-toolbar",8),s.mxI("zoomChange",function(_){m.eBV(l);const V=s.XpG(2);return s.DH7(V.zoom,_)||(V.zoom=_),m.Njj(_)})("layersVisibleChange",function(_){m.eBV(l);const V=s.XpG(2);return s.DH7(V.layerPanelVisible,_)||(V.layerPanelVisible=_),m.Njj(_)})("geoFenceDrawEnabledChange",function(_){m.eBV(l);const V=s.XpG(2);return s.DH7(V.geoFenceDrawEnabled,_)||(V.geoFenceDrawEnabled=_),m.Njj(_)}),s.k0s()}if(2&y){const l=s.XpG(),u=s.XpG();s.Aen(u.toolbarStyle()),s.Y8G("options",l),s.R50("zoom",u.zoom)("layersVisible",u.layerPanelVisible)("geoFenceDrawEnabled",u.geoFenceDrawEnabled)}}function Tt(y,I){1&y&&s.nVh(0,Lt,1,6,"cue-map-toolbar",7),2&y&&s.vxM(I.hidden?-1:0)}function tt(y,I){1&y&&(s.j41(0,"cue-card",4),s.nrm(1,"cue-layer-panel"),s.k0s())}function Rt(y,I){1&y&&(s.j41(0,"cue-card",5),s.nrm(1,"cue-props-panel",9),s.k0s()),2&y&&(s.R7$(),s.Y8G("props",I))}function nt(y,I){if(1&y&&(s.j41(0,"div",11),s.EFF(1),s.k0s()),2&y){const l=I,u=s.XpG();s.xc7("left",l.x,"px")("top",l.y,"px"),s.R7$(),s.SpI(" ",u," ")}}function Pt(y,I){if(1&y&&s.nVh(0,nt,2,5,"div",10),2&y){let l;const u=s.XpG();s.vxM((l=u.hoveredTooltipPosition())?0:-1,l)}}let St=(()=>{class y{mapService=(0,m.WQX)(S.u);drawService=(0,m.WQX)(p.M);settings=(0,D.hFB)(new F.yY);center=(0,D.hFB)([8.5,47.4]);layerPanelVisible=(0,D.geq)(!1);zoom=(0,D.geq)(2);instruction=(0,D.geq)("Hello");layers=(0,D.hFB)([]);zoomToFit=(0,D.hFB)(!0);zoomToFitEachLayer=(0,D.hFB)(!1);splitLayersByGeometryType=(0,D.hFB)(!0);maxClickZoom=(0,D.hFB)(1/0);borderRadius=(0,D.hFB)("0");geoFenceDrawEnabled=(0,D.geq)(!1);contextMenuItemsBefore=(0,D.hFB)([]);contextMenuItemsAfter=(0,D.hFB)([]);immidiateDrawMode=(0,D.hFB)(void 0);hoverTooltipFn=(0,D.hFB)(null);mapReady=(0,D.CGW)();clickedMap=(0,D.CGW)();pannedMap=(0,D.CGW)();panningMap=(0,D.CGW)();zoomedMap=(0,D.CGW)();clickedFeature=(0,D.CGW)();hoveredFeature=(0,D.CGW)();drawEvent=(0,D.CGW)();layersSaturated=(0,z.EW)(()=>this.layers().map((l,u)=>{const _={...l};return _.color||(_.color=vt.BK[u]),_}));toolbarOptions=(0,z.EW)(()=>this.settings().toolbar);featureBeingHovered=(0,m.vPA)(void 0);lastClickedFeatureEvent=(0,m.vPA)(void 0);lastHoveredFeatureEvent=(0,m.vPA)(void 0);shownProperties=(0,m.vPA)(null);hoveredTooltipLabel=(0,z.EW)(()=>{const l=this.hoverTooltipFn();if(!l)return null;const u=this.lastHoveredFeatureEvent();return u?l(u.feature.properties??{})??null:null});hoveredTooltipPosition=(0,z.EW)(()=>{if(!this.hoveredTooltipLabel())return null;const l=this.lastHoveredFeatureEvent();if(!l)return null;const u=this.mapService.map;if(!u)return null;const _=u.project([l.lngLat.lng,l.lngLat.lat]);return{x:_.x,y:_.y}});_featureClickedThisTick=!1;_previousLayersHash=(0,m.vPA)("");_userHasInteracted=(0,m.vPA)(!1);toolbarStyle=(0,z.EW)(()=>{const l=this.toolbarOptions();return{position:"absolute",left:l.margin,right:l.margin,["top"===l.position?"top":"bottom"]:l.margin,"z-index":"10",display:"flex","justify-content":"center"}});contextMenuEnabled=(0,z.EW)(()=>{const l=this.contextMenuItems().length>0,u=this.featureBeingHovered(),_=this.lastClickedFeatureEvent();return l&&(void 0!==u||void 0!==_)});contextMenuItems=(0,z.EW)(()=>{const l=this.lastHoveredFeatureEvent(),u=this.lastClickedFeatureEvent(),V=(l?.feature||u?.feature)?.properties||null,Y=V?Object.fromEntries(Object.entries(V).filter(([_e])=>!_e.startsWith("_"))):null,re=l?.lngLat||u?.lngLat||null,fe=[...this.contextMenuItemsBefore()||[]],ae=this.settings().contextMenu;Y&&Object.keys(Y).length>0&&ae.showProperties&&fe.push({label:"Show properties",action:()=>{this.shownProperties.update(()=>Y)}}),re&&ae.showFlyTo&&fe.push({label:"Fly to feature",action:()=>{this.mapService.flyTo([re.lng,re.lat],this.zoom())}});const de=this.contextMenuItemsAfter()||[];return[...fe,...de]});_mapContainer;_destroy$=new C.B;constructor(){this._subscribeToServiceOutputs(),this._setupEffects(),(0,s.mal)(()=>{this._destroy$.closed||this._tryInitializeMap()})}ngOnDestroy(){this._destroy$.next(),this._destroy$.complete(),this.drawService.destroy(),this.mapService.destroy()}_subscribeToServiceOutputs(){this.mapService.mapReady.pipe((0,h.pQ)()).subscribe(()=>this.mapReady.emit()),this.mapService.clickedMap.pipe((0,h.pQ)()).subscribe(l=>{this._featureClickedThisTick||(this.lastClickedFeatureEvent.update(()=>{}),this.lastHoveredFeatureEvent.update(()=>{}),this.featureBeingHovered.update(()=>{}),this.clickedMap.emit(l),this.shownProperties.update(()=>null))}),this.mapService.pannedMap.pipe((0,h.pQ)()).subscribe(l=>{this._userHasInteracted.set(!0),this.pannedMap.emit(l)}),this.mapService.panningMap.pipe((0,h.pQ)()).subscribe(l=>this.panningMap.emit(l)),this.mapService.zoomedMap.pipe((0,h.pQ)()).subscribe(l=>{this._userHasInteracted.set(!0),this.zoomedMap.emit(this.mapService.getZoom()??this.zoom())}),this.mapService.clickedFeature.pipe((0,h.pQ)()).subscribe(l=>{this._featureClickedThisTick=!0,queueMicrotask(()=>{this._featureClickedThisTick=!1}),this.lastClickedFeatureEvent.update(()=>l),this.clickedFeature.emit(l);const u=l.feature?.geometry?.type,_="Point"===u||"MultiPoint"===u,V=this.mapService.getZoom()??0,Y=this.contextMenuItems().length>0;_&&!Y&&V<this.maxClickZoom()&&this.mapService.zoomToCoordinate(l.lngLat)}),this.mapService.hoveredFeature.pipe((0,h.pQ)()).subscribe(l=>{this.featureBeingHovered.update(()=>l?.feature),this.lastHoveredFeatureEvent.update(()=>l),this.hoveredFeature.emit(l)})}_setupEffects(){var l=this;(0,m.QZP)(()=>{"polygon"===this.immidiateDrawMode()&&(this.geoFenceDrawEnabled.set(!0),setTimeout(()=>{this.drawService.setDrawMode(!0,this.settings().toolbar.clearGeofenceAfterDraw)},500))}),(0,m.QZP)(()=>this.mapService.flyTo(this.center(),this.zoom())),(0,m.QZP)(()=>{const _=this.settings()?.mapboxToken;_&&"string"==typeof _&&""!==_.trim()&&!this.mapService.isMapReady()&&this._tryInitializeMap()}),(0,m.QZP)(()=>{const u=this.geoFenceDrawEnabled();this.drawService.setDrawMode(u,this.settings().toolbar.clearGeofenceAfterDraw)}),(0,m.QZP)(()=>{const u=this.drawService.drawEvent();void 0!==u&&this.drawEvent.emit(u)}),(0,m.QZP)((0,O.A)(function*(){const u=l.layersSaturated();if(!u||0===u.length)return;const _=l._createLayersHash(u);if(_===l._previousLayersHash())return;l._previousLayersHash.set(_),yield l.mapService.waitForMapReady(),l.mapService.clearLayers();const Y=l.zoomToFitEachLayer();u.forEach((ne,fe)=>{!function Be(y,I,l,u,_,V,Y){const re=I.collection,ne=I.color??ut[l];let fe;fe="geometries"in re?function Re(y){const I=y.geometries.map((u,_)=>({type:"Feature",geometry:u,properties:{},id:y.id?`${y.id}_${_}`:void 0})),l=new me.o(I);return l.id=y.id,l.bbox=y.bbox,l}(re):re;const ae=function Ae(y){const I=[];return y.forEach(l=>{l.geometry&&"GeometryCollection"===l.geometry.type?l.geometry.geometries.forEach((u,_)=>{I.push({type:"Feature",geometry:u,properties:l.properties||{},id:l.id?`${l.id}_${_}`:void 0})}):I.push(l)}),I}(fe.features),de=new me.o(ae);de.id=fe.id,de.bbox=fe.bbox;let _e=ne;if(!V){const H=I.id.toString(),q=ae[0]?.geometry?.type||"Point";_e=je(He(ae,ne,q,u));let be=Y(H,q,_e,H),Se=de;const ke="Point"!==q&&"MultiPoint"!==q,Me=(0,te.j5)(q),ge=(0,te.dx)(q);if(u&&ke&&!Me&&!ge&&be){const ot=Array.isArray(be)?be:[be],se=ve(ae);Se=new me.o(se),Se.id=de.id,Se.bbox=de.bbox,be=[(0,te.g8)(`${H}-centroid`,H,_e),...ot.map(it=>({...it,minzoom:te.A4}))]}return void(be&&Qe(y,H,Se,be,q,{cluster:u,zoomToFit:_,visible:!0,label:I.label||I.id.toString(),color:_e}))}if(V){const H=new Set(ae.map(ie=>ie.geometry.type)),q=[];return H.forEach(ie=>{const be=`${I.id.toString()}-${ie}`,Se=ae.filter(ge=>ge.geometry.type===ie),ke=He(Se,ne,ie,u);q.push(...ke);let Me=Y(be,ie,ne,be);if(Me){let ge=new me.o(Se);ge.id=de.id,ge.bbox=de.bbox;const ot="Point"!==ie&&"MultiPoint"!==ie,se=(0,te.j5)(ie),rt=(0,te.dx)(ie);if(u&&ot&&!se&&!rt){const it=Array.isArray(Me)?Me:[Me],It=ve(Se);ge=new me.o(It),ge.id=de.id,ge.bbox=de.bbox,Me=[(0,te.g8)(`${be}-centroid`,be,ne),...it.map(st=>({...st,minzoom:te.A4}))]}Qe(y,be,ge,Me,ie,{cluster:u,zoomToFit:_,visible:!0,label:H.size>1?`${I.label||I.id} (${ie})`:`${I.label||I.id}`,color:ne})}}),void(q.length>0&&(_e=je(q),y.layerService.getLayer(I.id.toString())&&y.layerService.updateLayer(I.id.toString(),{color:_e})))}const Ee=new Map;ae.forEach(H=>{const q=H.geometry.type;let ie;ie="Point"===q||"MultiPoint"===q?"Point":"LineString"===q||"MultiLineString"===q?"LineString":"Polygon"===q||"MultiPolygon"===q?"Polygon":q,Ee.has(ie)||Ee.set(ie,[]),Ee.get(ie).push(q)});const Ne=[];Ee.forEach((H,q)=>{const ie=`${I.id.toString()}-${q}`,be=ae.filter(Me=>{const ge=Me.geometry.type;return"Point"===q?"Point"===ge||"MultiPoint"===ge:"LineString"===q?"LineString"===ge||"MultiLineString"===ge:"Polygon"===q?"Polygon"===ge||"MultiPolygon"===ge:ge===q}),Se=He(be,ne,q,u);Ne.push(...Se);const ke=Y(ie,q,ne,ie);if(ke){const Me=new me.o(be);Me.id=de.id,Me.bbox=de.bbox,Qe(y,ie,Me,ke,q,{cluster:u,zoomToFit:_,visible:!0,label:Ee.size>1?`${I.label||I.id} (${q})`:`${I.label||I.id}`,color:ne})}}),Ne.length>0&&(_e=je(Ne),y.layerService.getLayer(I.id.toString())&&y.layerService.updateLayer(I.id.toString(),{color:_e}))}(l.mapService,ne,fe,ne.cluster,Y&&ne.zoomToFit,l.splitLayersByGeometryType(),te.Ln)});const re=u.some(ne=>ne.zoomToFit);(l.zoomToFit()&&!Y&&!l._userHasInteracted()||re&&!Y)&&l.mapService.fitGeoJSONBBOX()}))}_tryInitializeMap(){if(this._destroy$.closed)return;const u=this.settings()?.mapboxToken,_=u&&"string"==typeof u&&""!==u.trim(),V=this._mapContainer,Y=!this.mapService.isMapReady();_&&V&&Y&&(this._userHasInteracted.set(!1),this.mapService.init(this._mapContainer.nativeElement,u,this.center(),this.zoom(),this.borderRadius()))}_createLayersHash(l){return l.map(u=>{const _=u.collection;let V=0;return _&&"FeatureCollection"===_.type&&"features"in _&&(V=Array.isArray(_.features)?_.features.length:0),`${u.id}|${u.label}|${u.visible}|${V}`}).join("::")}static \u0275fac=function(u){return new(u||y)};static \u0275cmp=s.VBU({type:y,selectors:[["cue-map"]],viewQuery:function(u,_){if(1&u&&s.GBs(Xe,5),2&u){let V;s.mGM(V=s.lsd())&&(_._mapContainer=V.first)}},hostAttrs:["data-component","cue-map-main"],inputs:{settings:[1,"settings"],center:[1,"center"],layerPanelVisible:[1,"layerPanelVisible"],zoom:[1,"zoom"],instruction:[1,"instruction"],layers:[1,"layers"],zoomToFit:[1,"zoomToFit"],zoomToFitEachLayer:[1,"zoomToFitEachLayer"],splitLayersByGeometryType:[1,"splitLayersByGeometryType"],maxClickZoom:[1,"maxClickZoom"],borderRadius:[1,"borderRadius"],geoFenceDrawEnabled:[1,"geoFenceDrawEnabled"],contextMenuItemsBefore:[1,"contextMenuItemsBefore"],contextMenuItemsAfter:[1,"contextMenuItemsAfter"],immidiateDrawMode:[1,"immidiateDrawMode"],hoverTooltipFn:[1,"hoverTooltipFn"]},outputs:{layerPanelVisible:"layerPanelVisibleChange",zoom:"zoomChange",instruction:"instructionChange",geoFenceDrawEnabled:"geoFenceDrawEnabledChange",mapReady:"mapReady",clickedMap:"clickedMap",pannedMap:"pannedMap",panningMap:"panningMap",zoomedMap:"zoomedMap",clickedFeature:"clickedFeature",hoveredFeature:"hoveredFeature",drawEvent:"drawEvent"},features:[s.Jv_([S.u,p.M,a.B])],decls:10,vars:10,consts:[["hoveringFeature",""],["map",""],["direction","row",1,"container"],["id","map","cueResized","","cueDarkMode","","trigger","leftclick",3,"darkModeChange","resized","cueContextMenu","contextMenuData","cueContextEnabled"],[1,"layer-panel"],[1,"props-panel"],[3,"click"],[3,"options","style","zoom","layersVisible","geoFenceDrawEnabled"],[3,"zoomChange","layersVisibleChange","geoFenceDrawEnabledChange","options","zoom","layersVisible","geoFenceDrawEnabled"],[3,"props"],[1,"hover-tooltip",3,"left","top"],[1,"hover-tooltip"]],template:function(u,_){if(1&u&&(s.DNE(0,Ct,3,0,"ng-template",null,0,s.C5r),s.j41(2,"cue-flexcontainer",2)(3,"div",3,1),s.bIt("darkModeChange",function(Y){return _.mapService.setDarkMode(Y)})("resized",function(){return _.mapService.onParentResize()}),s.k0s(),s.nVh(5,et,2,1,"span"),s.nVh(6,Tt,1,1),s.nVh(7,tt,2,0,"cue-card",4),s.nVh(8,Rt,2,1,"cue-card",5),s.nVh(9,Pt,1,1),s.k0s()),2&u){let V,Y,re;const ne=s.sdS(1);s.R7$(3),s.Y8G("cueContextMenu",ne)("contextMenuData",s.eq3(8,qe,_.lastHoveredFeatureEvent()))("cueContextEnabled",_.contextMenuEnabled()),s.R7$(2),s.vxM(_.mapService.error()?5:-1),s.R7$(),s.vxM((V=_.toolbarOptions())?6:-1,V),s.R7$(),s.vxM(_.layerPanelVisible()?7:-1),s.R7$(),s.vxM((Y=_.shownProperties())?8:-1,Y),s.R7$(),s.vxM((re=_.hoveredTooltipLabel())?9:-1,re)}},dependencies:[b.MD,v.C,R.R,A,W.Q,bt.M,ft.D,w.n,ye,pe,U.Z],styles:["#map[_ngcontent-%COMP%]{flex:1;min-height:0;border-radius:inherit;overflow:hidden}[_nghost-%COMP%]{display:flex;flex-direction:column;position:relative;width:100%;height:100%;min-height:400px;min-width:200px;flex:1 1 auto;align-self:stretch;box-sizing:border-box;overflow:hidden;border-radius:var(--cue-card-border-radius, inherit)}.mapboxgl-canvas-container[_ngcontent-%COMP%], .mapboxgl-canvas[_ngcontent-%COMP%]{border-radius:inherit!important}.mapboxgl-map[_ngcontent-%COMP%]{border-radius:inherit!important;overflow:hidden!important}.container[_ngcontent-%COMP%]{position:relative;width:100%;flex:1;min-height:0;overflow:hidden;display:flex;flex-direction:column}.props-panel[_ngcontent-%COMP%]{position:absolute;top:8px;right:8px;bottom:8px;z-index:10}.layer-panel[_ngcontent-%COMP%]{position:absolute;top:10px;left:10px;z-index:10}cue-map-toolbar[_ngcontent-%COMP%]{position:absolute;left:0;right:0;bottom:0;z-index:10;display:flex;justify-content:center}.hover-tooltip[_ngcontent-%COMP%]{position:absolute;background:var(--cue-menu-background-color);color:var(--cue-menu-foreground-color);box-shadow:var(--cue-menu-box-shadow);border:1px solid var(--cue-menu-border-color);padding:3px 8px;border-radius:4px;font-family:var(--cue-font-family);font-size:.75rem;line-height:1.4;pointer-events:none;white-space:nowrap;z-index:20;transform:translate(-50%,calc(-100% - 8px))}"]})}return y})()},5949(le,Q,c){"use strict";c.d(Q,{u:()=>R});var O=c(467),m=c(5802),D=c(2271),z=c(1413),s=c(3646),b=c(2843),v=c(9079);let R=(()=>{class S{_map;_mapContainer;_isInitializing=!1;_mapReadyPromiseResolve;_mapReady=new Promise(a=>{this._mapReadyPromiseResolve=a});_emittedReady=!1;_firstThemeReceived=!1;_hoveredFeature=(0,m.vPA)(void 0);_layerService=(0,m.WQX)(s.B);_drawService=(0,m.WQX)(b.M);mapboxToken=(0,m.vPA)("");center=(0,m.vPA)([8.5,47.4]);zoom=(0,m.vPA)(2);borderRadius=(0,m.vPA)("0");mapReady=new z.B;clickedMap=new z.B;pannedMap=new z.B;panningMap=new z.B;zoomedMap=new z.B;error=(0,m.vPA)("");get clickedFeature(){return this._layerService.clickedFeature}get hoveredFeature(){return this._layerService.hoveredFeature}get layers(){return this._layerService.layers}get layersSignal(){return this._layerService.layersSignal}get layerService(){return this._layerService}get drawService(){return this._drawService}get drawEvent(){return this._drawService.drawEvent}_darkMode=(0,m.vPA)(this._getSystemColorPreference());_styleId=(0,D.EW)(()=>this._darkMode()?"madsholten/clwjh4xeu00q601pnczm07jq6":"madsholten/clwjh6ug900q701pn6eor8p51");get map(){return this._map}constructor(){this._layerService.hoveredFeature.pipe((0,v.pQ)()).subscribe(a=>{this._hoveredFeature.set(a?.feature)}),(0,m.QZP)(()=>{this._styleId(),this._firstThemeReceived?void 0!==this._map&&this._updateStyle().catch(a=>{console.error("Failed to update map style:",a)}):this._firstThemeReceived=!0})}destroy(){if(this._layerService?.clearAllLayers(),this._drawService?.destroy(),this._map)try{this._map.remove()}catch(a){console.warn("Error removing map:",a)}this._map=void 0,this._mapContainer&&(this._mapContainer.innerHTML="",this._mapContainer=void 0),this._isInitializing=!1,this._emittedReady=!1,this._mapReady=new Promise(a=>{this._mapReadyPromiseResolve=a})}isMapReady(){return void 0!==this._map&&this._emittedReady&&!this._isInitializing}waitForMapReady(){var a=this;return(0,O.A)(function*(){return a._mapReady})()}init(a,h,C,F,B){var E=this;return(0,O.A)(function*(){if(h&&""!==h.trim())if(E._map||E._isInitializing)console.warn("MapService: Map is already initialized or currently initializing");else{E._isInitializing=!0,E.mapboxToken.set(h),E.center.set(C),E.zoom.set(F),E.borderRadius.set(B),E._mapContainer=a,E._mapContainer&&(E._mapContainer.innerHTML="");try{yield E._loadMapboxCSS();const w=yield c.e(247).then(c.t.bind(c,1247,23)),U=w.default||w;if(!U||"function"!=typeof U.Map)throw new Error("Mapbox GL JS not properly loaded");U.accessToken=E.mapboxToken(),E._map=new U.Map({container:a,style:E._getMapStyleURL(),center:E.center(),zoom:E.zoom()}),E._applyBorderRadius(a),E._initEventListeners(E._map)}catch(w){console.error("Failed to load mapbox-gl:",w),E.error.set("Failed to load map library. Please ensure mapbox-gl is installed.")}finally{E._isInitializing=!1}}else console.warn("MapService: Cannot initialize map without valid mapbox token")})()}loadGeoJSON(a,h,C){var F=this;return(0,O.A)(function*(B,E,w,U=!0,k=!0){return yield F._mapReady,F._layerService.loadGeoJSONLayer(B,E,w,{cluster:U,zoomToFit:k,visible:!0,label:B})}).apply(this,arguments)}fitGeoJSONBBOX(a){var h=this;return(0,O.A)(function*(C,F=50,B=!0,E=19){yield h._mapReady,C?h._layerService.fitGeoJSONBounds(C,F,B,E):h._layerService.fitAllVisibleLayers(F)}).apply(this,arguments)}jumpTo(a,h){this._map?.jumpTo({center:a,zoom:h??this.zoom()})}setDarkMode(a){this._darkMode.set(a)}zoomToCoordinate(a){const h=this._map?.getZoom();if(!h)return;const C=h+1;this._map?.flyTo({center:a,zoom:C})}getZoom(){return this._map?.getZoom()}flyTo(a,h,C){this._map?.flyTo({center:a,zoom:h??this.zoom(),essential:!0,padding:C})}zoomIn(){if(!this._map)return;const a=this._map.getZoom();this._map.flyTo({zoom:a+1})}zoomOut(){if(!this._map)return;const a=this._map.getZoom();this._map.flyTo({zoom:a-1})}clearLayers(){this._layerService.clearAllLayers()}getImage(){const a=this._map?.getCanvas();if(void 0!==a)return a.toDataURL("image/png")}onParentResize(){this._map?.resize()}_loadMapboxCSS(){return(0,O.A)(function*(){return new Promise((a,h)=>{if(document.querySelector('link[href*="mapbox-gl.css"]'))return void a();const C=document.createElement("link");C.rel="stylesheet",C.href="https://api.mapbox.com/mapbox-gl-js/v3.3.0/mapbox-gl.css",C.onload=()=>a(),C.onerror=()=>{const F=document.createElement("link");F.rel="stylesheet",F.href="node_modules/mapbox-gl/dist/mapbox-gl.css",F.onload=()=>a(),F.onerror=()=>h(new Error("Failed to load Mapbox CSS")),document.head.appendChild(F)},document.head.appendChild(C)})})()}_applyBorderRadius(a){const h=this.borderRadius();let C=h;if("0"===h){const B=a.closest("cue-map")?.parentElement;B&&(C=getComputedStyle(B).borderRadius||"0")}"0"!==C&&(a.style.borderRadius=C,a.style.overflow="hidden",setTimeout(()=>{const F=a.querySelector(".mapboxgl-canvas"),B=a.querySelector(".mapboxgl-canvas-container"),E=a.querySelector(".mapboxgl-map");F&&(F.style.borderRadius=C),B&&(B.style.borderRadius=C),E&&(E.style.borderRadius=C)},100))}_initEventListeners(a){a.on("click",h=>{void 0===this._hoveredFeature()&&this.clickedMap.next(h)}),a.on("drag",h=>{void 0===this._hoveredFeature()&&this.panningMap.next(h)}),a.on("dragend",h=>{void 0===this._hoveredFeature()&&this.pannedMap.next(h)}),a.on("zoomend",h=>{this.zoomedMap.next(h)}),a.on("load",()=>{this._emittedReady||(this._layerService.initializeWithMap(a),this._drawService.initializeWithMap(a),this._mapReadyPromiseResolve(),this.mapReady.next(),this._emittedReady=!0)}),a.on("error",h=>{this.error.set(h.error.message)})}_getMapStyleURL(){return`mapbox://styles/${this._styleId()}`}_updateStyle(){var a=this;return(0,O.A)(function*(){if(void 0===a._map)return;const h=a._map.getZoom(),C=a._map.getCenter();void 0!==a._mapContainer&&(yield a.init(a._mapContainer,a.mapboxToken(),C,h,a.borderRadius()),setTimeout(()=>{a._layerService.reapplyLayers(),a._map?.flyTo({center:C,zoom:h})},500))})()}_getSystemColorPreference(){return typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches}static \u0275fac=function(h){return new(h||S)};static \u0275prov=m.jDH({token:S,factory:S.\u0275fac})}return S})()},2306(le,Q,c){"use strict";c.d(Q,{AA:()=>z,ux:()=>s,yY:()=>D});var O=c(140),m=c(8402);class D{mapboxToken;contextMenu={showProperties:!0,showFlyTo:!0};toolbar=new z}class z{hidden=!1;position="bottom";margin="20px";displayZoom=!0;displayGeofenceDraw=!1;displayLayerToggle=!0;clearGeofenceAfterDraw=!0}class s{label;id;collection=new O.o;color;visible=!0;cluster=!0;zoomToFit=!0;category;constructor(v,R=(0,m.A)()){this.label=v,this.id=R}}},8334(le,Q,c){"use strict";c.d(Q,{o:()=>z});var O=c(7705),m=c(5547);const D=["*"];let z=(()=>{class s{label=O.hFB.required();active=(0,O.geq)(!1);static \u0275fac=function(R){return new(R||s)};static \u0275cmp=m.VBU({type:s,selectors:[["cue-tab"]],hostVars:1,hostBindings:function(R,S){2&R&&m.Avn("hidden",!S.active())},inputs:{label:[1,"label"],active:[1,"active"]},outputs:{active:"activeChange"},ngContentSelectors:D,decls:1,vars:0,template:function(R,S){1&R&&(m.NAR(),m.SdG(0))},styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0}[hidden][_nghost-%COMP%]{display:none!important}"]})}return s})()},6455(le,Q,c){"use strict";c.d(Q,{t:()=>F});var O=c(7705),m=c(5802),D=c(2271),z=c(8334),s=c(5187),b=c(9769),v=c(5547);const R=["*"],S=(B,E)=>E.label();function p(B,E){if(1&B&&(v.j41(0,"cue-card",1),v.eu8(1,2),v.k0s()),2&B){const w=v.XpG(),U=v.sdS(3);v.Y8G("variant",w._cardVariant())("padded",!1),v.R7$(),v.Y8G("ngTemplateOutlet",U)}}function a(B,E){if(1&B&&v.eu8(0,2),2&B){v.XpG();const w=v.sdS(3);v.Y8G("ngTemplateOutlet",w)}}function h(B,E){if(1&B){const w=v.RV6();v.j41(0,"button",6),v.bIt("click",function(){const k=m.eBV(w).$index,X=v.XpG(2);return m.Njj(X.setActive(k))}),v.EFF(1),v.k0s()}if(2&B){const w=E.$implicit,U=E.$index,k=v.XpG(2);v.AVh("active",k.activeIndex()===U),v.R7$(),v.SpI(" ",w.label()," ")}}function C(B,E){if(1&B&&(v.j41(0,"div",3),v.Z7z(1,h,2,3,"button",4,S),v.k0s(),v.j41(3,"div",5),v.SdG(4),v.k0s()),2&B){const w=v.XpG();v.R7$(),v.Dyx(w.tabs())}}let F=(()=>{class B{tabs=(0,O.tEk)(z.o);activeIndex=(0,m.vPA)(0);variant=(0,O.hFB)("none");_cardVariant=(0,D.EW)(()=>"none"===this.variant()?"default":this.variant());constructor(){(0,m.QZP)(()=>{const w=this.tabs(),U=this.activeIndex();w.forEach((k,X)=>k.active.set(X===U))})}setActive(w){this.activeIndex.set(w)}static \u0275fac=function(U){return new(U||B)};static \u0275cmp=v.VBU({type:B,selectors:[["cue-tabs"]],contentQueries:function(U,k,X){1&U&&v.C6U(X,k.tabs,z.o,4),2&U&&v.NyB()},inputs:{variant:[1,"variant"]},ngContentSelectors:R,decls:4,vars:1,consts:[["inner",""],[2,"height","100%","width","100%","display","flex","flex-direction","column","overflow","hidden",3,"variant","padded"],[3,"ngTemplateOutlet"],[1,"tabs-header"],[1,"tab-button",3,"active"],[1,"tabs-content"],[1,"tab-button",3,"click"]],template:function(U,k){1&U&&(v.NAR(),v.nVh(0,p,2,3,"cue-card",1)(1,a,1,1,"ng-container",2),v.DNE(2,C,5,0,"ng-template",null,0,v.C5r)),2&U&&v.vxM("none"!==k.variant()?0:1)},dependencies:[s.Z,b.T3],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;box-sizing:border-box;border-radius:var(--cue-card-border-radius);border:1px solid var(--cue-card-border-color);background-color:var(--cue-default);color:var(--cue-defaultContrast);overflow:hidden}.tabs-header[_ngcontent-%COMP%]{display:flex;border-bottom:1px solid var(--cue-card-border-color);background-color:var(--background-color, var(--cue-default))}.tab-button[_ngcontent-%COMP%]{padding:10px 16px;background:none;border:none;border-bottom:2px solid transparent;cursor:pointer;color:inherit;font-family:var(--cue-font-family);font-size:var(--cue-font-s-size);line-height:var(--cue-font-s-line-height);opacity:.6;transition:opacity .15s,border-bottom-color .15s}.tab-button[_ngcontent-%COMP%]:hover{opacity:.9}.tab-button.active[_ngcontent-%COMP%]{border-bottom-color:currentColor;opacity:1;font-weight:500}.tabs-content[_ngcontent-%COMP%]{padding:var(--cue-card-padding-y) var(--cue-card-padding-x);flex:1;min-height:0;box-sizing:border-box;display:flex;flex-direction:column}"]})}return B})()},7335(le,Q,c){"use strict";c.d(Q,{e:()=>R});var O=c(7705),m=c(5547),D=c(5802),z=c(8359),s=c(6939),b=c(63),v=c(4853);let R=(()=>{class S{_targetEl=(0,D.WQX)(m.aKT);_overlay=(0,D.WQX)(b.hJ);_overlayRef;_isOverlayHovered=!1;_subscriptions;display=(0,O.hFB)("on-hover");menuItems=O.hFB.required();menuEnabled=(0,O.hFB)(!0);onMouseEnter(){if("on-hover"===this.display()){if(!this.menuItems().length)return void this.removeOverlayMenu();this.appendOverlayMenu()}}onMouseLeave(){this._checkShouldRemoveOverlay()}appendOverlayMenu(){if(!this.menuItems().length||this._overlayRef)return;const a=this._overlay.create({positionStrategy:this._overlay.position().flexibleConnectedTo(this._targetEl).withPositions([{originX:"end",originY:"center",overlayX:"start",overlayY:"center",offsetX:2,offsetY:0}])});this._overlayRef=a;const h=window.getComputedStyle(this._targetEl.nativeElement).color;a.overlayElement.style.color=h;const C=new s.A8(v.H),F=a.attach(C);F.instance.items=this.menuItems,this._subscriptions&&this._subscriptions.unsubscribe(),this._subscriptions=new z.yU,this._subscriptions.add(F.instance.mouseEnter.subscribe(()=>{this._isOverlayHovered=!0})),this._subscriptions.add(F.instance.mouseLeave.subscribe(()=>{this._isOverlayHovered=!1,this._checkShouldRemoveOverlay()}))}removeOverlayMenu(){this._overlayRef&&(this._subscriptions&&(this._subscriptions.unsubscribe(),this._subscriptions=void 0),this._overlayRef.detach(),this._overlayRef.dispose(),this._overlayRef=void 0)}_checkShouldRemoveOverlay(){setTimeout(()=>{this._isOverlayHovered||this.removeOverlayMenu()},300)}static \u0275fac=function(h){return new(h||S)};static \u0275dir=m.FsC({type:S,selectors:[["","cueEntityMenu",""]],hostBindings:function(h,C){1&h&&m.bIt("mouseenter",function(){return C.onMouseEnter()})("mouseleave",function(){return C.onMouseLeave()})},inputs:{display:[1,"display"],menuItems:[1,"menuItems"],menuEnabled:[1,"menuEnabled"]}})}return S})()},140(le,Q,c){"use strict";c.d(Q,{o:()=>O});class O{type="FeatureCollection";features=[];bbox;id;constructor(D=[]){this.features=D}addFeature(D){this.features.push(D)}removeFeature(D){return this.features.splice(D,1)[0]}getFeatureCount(){return this.features.length}clear(){this.features=[]}}},58(le,Q,c){"use strict";function O(a){let h=0,C=-1,F=-1;for(let B=0;B<a.length;B++)if("("===a[B])h++,1===h&&(C=B+1);else if(")"===a[B]&&(h--,0===h)){F=B;break}return-1!==C&&-1!==F?a.substring(C,F):null}c.d(Q,{S:()=>S,n:()=>p});class m{x;y;z;constructor(h,C,F){this.x=h,this.y=C,this.z=F}}class D{points;constructor(h){this.points=h}}class z{lines;constructor(h){this.lines=h}}function S(a){if(a){if((a=a.trim().toUpperCase()).startsWith("POINT"))return function b(a){a=a.trim().toUpperCase();const C=O(a)?.split(" ")??[];return a.includes("POINT Z")?new m(parseFloat(C[0]),parseFloat(C[1]),parseFloat(C[2])):new m(parseFloat(C[0]),parseFloat(C[1]))}(a);if(a.startsWith("LINESTRING"))return function s(a){const h=O(a=a.trim().toUpperCase()),C=[];return h?.split(",").map(F=>F.trim().split(" ").map(B=>parseFloat(B))).map(F=>{C.push(new m(F[0],F[1],F[2]))}),new D(C)}(a);if(a.startsWith("POLYGON"))return function v(a){const h=O(a=a.trim().toUpperCase());if(!h)return new z([]);const C=h.match(/\(([^)]+)\)/g);if(!C)return new z([]);const F=C.map(B=>{const E=O(B);return E?E.split(",").map(w=>{const U=w.trim().split(" ");return U.length>=3?new m(parseFloat(U[0]),parseFloat(U[1]),parseFloat(U[2])):new m(parseFloat(U[0]),parseFloat(U[1]))}):[]});return new z(F)}(a)}}function p(a){if(a instanceof m)return{type:"Point",coordinates:void 0!==a.z?[a.x,a.y,a.z]:[a.x,a.y]};if(a instanceof D)return{type:"LineString",coordinates:a.points.map(h=>void 0!==h.z?[h.x,h.y,h.z]:[h.x,h.y])};if(a instanceof z)return{type:"Polygon",coordinates:a.lines.map(h=>h.map(C=>void 0!==C.z?[C.x,C.y,C.z]:[C.x,C.y]))};throw new Error("Unknown WKT type")}},362(le){"use strict";le.exports=function Q(c,O){if(c===O)return!0;if(c&&O&&"object"==typeof c&&"object"==typeof O){if(c.constructor!==O.constructor)return!1;var m,D,z;if(Array.isArray(c)){if((m=c.length)!=O.length)return!1;for(D=m;0!==D--;)if(!Q(c[D],O[D]))return!1;return!0}if(c.constructor===RegExp)return c.source===O.source&&c.flags===O.flags;if(c.valueOf!==Object.prototype.valueOf)return c.valueOf()===O.valueOf();if(c.toString!==Object.prototype.toString)return c.toString()===O.toString();if((m=(z=Object.keys(c)).length)!==Object.keys(O).length)return!1;for(D=m;0!==D--;)if(!Object.prototype.hasOwnProperty.call(O,z[D]))return!1;for(D=m;0!==D--;){var s=z[D];if(!Q(c[s],O[s]))return!1}return!0}return c!=c&&O!=O}},5332(le,Q,c){"use strict";c.d(Q,{k:()=>z});for(var m=[],D=0;D<256;++D)m.push((D+256).toString(16).slice(1));function z(v,R=0){return(m[v[R+0]]+m[v[R+1]]+m[v[R+2]]+m[v[R+3]]+"-"+m[v[R+4]]+m[v[R+5]]+"-"+m[v[R+6]]+m[v[R+7]]+"-"+m[v[R+8]]+m[v[R+9]]+"-"+m[v[R+10]]+m[v[R+11]]+m[v[R+12]]+m[v[R+13]]+m[v[R+14]]+m[v[R+15]]).toLowerCase()}},8402(le,Q,c){"use strict";c.d(Q,{A:()=>R});const m={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};var D,z=new Uint8Array(16);function s(){if(!D&&!(D=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return D(z)}var b=c(5332);const R=function v(S,p,a){if(m.randomUUID&&!p&&!S)return m.randomUUID();var h=(S=S||{}).random||(S.rng||s)();if(h[6]=15&h[6]|64,h[8]=63&h[8]|128,p){a=a||0;for(var C=0;C<16;++C)p[a+C]=h[C];return p}return(0,b.k)(h)}},6119(le){le.exports.RADIUS=6378137,le.exports.FLATTENING=1/298.257223563,le.exports.POLAR_RADIUS=6356752.3142}}]);
|