import{$ as Pt,A as dt,B as Z,C as k,D as L,E as j,F as _,G as ge,H as ut,I as gt,J as Pe,K as F,L as Q,M as U,N as mt,O as ft,P as pt,Q as me,R as _t,S as yt,T as v,U as Ct,V as B,W as xt,X as J,Y as Tt,Z as vt,_ as Et,a as b,aa as wt,b as st,ba as Lt,c as ae,ca as St,d as le,da as Ot,e as M,ea as q,f as G,fa as ee,g as N,ga as E,h as w,ha as fe,i as R,ia as te,j as ve,ja as we,k as nt,ka as Mt,l as Ee,la as Le,m as ot,ma as z,n as T,na as D,o as ce,p as rt,q as at,r as lt,s as he,t as ct,u as de,v as ht,w as ue,x as I,y as S,z as V}from"./chunk-MNVOJIXC.js";import{Aa as $,De as He,Id as Ye,Nc as qe,Qf as Je,Qg as tt,Rd as Ke,S as Re,Sd as We,Se as Xe,Te as $e,Ue as Ze,Wb as Be,Yg as it,_a as oe,af as Qe,ag as O,bb as je,cd as ze,dd as re,gb as Ue,mg as et,ng as A,wa as Ve,ya as ne}from"./chunk-SKPDQO4E.js";var Gt=`<ng-container>
	<div class="d-flex w-100 rnd-1 shadow-box-sm hover-secondary hover-border-secondary cursor-pointer b-1 bg-color-white"
		(click)="onClicked($event)" [ngClass]="{'b-invalid': invalid}">
		<div class="d-flex align-items-center justify-content-center px-2 py-2 b-r-1 me-2">
			<cds-icon shape="map-marker" class="text-secondary" style="width: 22px; height: 22px;"></cds-icon>
		</div>
		<div class="d-flex flex-column justify-content-center">
			<span class="text-sm text-italic color-gray">{{geoLocationText}}</span>
		</div>
	</div>
</ng-container>

<ng-template #typeSelectionTemplate let-modal>
	<div class="modal-header align-items-center">
		<div class="d-flex me-2 align-items-center">
			<cds-icon shape="map-marker" size="lg" class="text-primary opacity-25"></cds-icon>
		</div>
		<div class="d-flex flex-column flex-grow-1 justify-content-center">
			<span class="text-lg">{{'MAP.GEOLOCATION' | translate}}</span>
		</div>
	</div>
	<div class="modal-body">
		<div class="row mb-3">
			<div class="col-12">
				<span class="text-md">{{'MAP.GEOLOCATION_TYPE_SELECTION'|translate}}</span>
			</div>
		</div>
		<div class="row">
			<div class="col-6">
				<div (click)="modal.close(1)"
					class="d-flex flex-column align-items-center justify-content-center shadow-box-1 rounded-2 p-3 cursor-pointer hover-border-secondary hover-secondary mhs-10">
					<cds-icon shape="location-circle" style="width: 60px; height: 60px;" class="my-3 color-gray"></cds-icon>
					<span class="text-md fw-medium">{{'MAP.GEOLOCATION_CIRCLE'|translate}}</span>
				</div>
			</div>
			<div class="col-6">
				<div (click)="modal.close(2)"
					class="d-flex flex-column align-items-center justify-content-center shadow-box-1 rounded-2 p-3 cursor-pointer hover-border-secondary hover-secondary mhs-10">
					<cds-icon shape="location-polygon" style="width: 60px; height: 60px;" class="my-3 color-gray"></cds-icon>
					<span class="text-md fw-medium">{{'MAP.GEOLOCATION_POLYGON'|translate}}</span>
				</div>
			</div>
		</div>
	</div>
	<div class="modal-footer">
		<button class="btn btn-outline-primary" (click)="modal.dismiss()">{{'BUTTON.CANCEL' |
			translate}}</button>
	</div>
</ng-template>`;var It=`.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}
`;var kt=`<ng-container *ngIf="visible">
    <div class="modal-header align-items-center">
        <div class="d-flex me-2 align-items-center">
            <cds-icon shape="map-marker" size="lg" class="text-primary opacity-25"></cds-icon>
        </div>
        <div class="d-flex flex-column flex-grow-1 justify-content-center">
            <span class="text-lg">{{'MAP.GEOLOCATION' | translate}}</span>
            <ng-container *ngIf="selectionType">
                <span class="text-sm" *ngIf="selectionType=='Circle'">{{'MAP.GEOLOCATION_CIRCLE'|translate}}</span>
                <span class="text-sm" *ngIf="selectionType=='Polygon'">{{'MAP.GEOLOCATION_POLYGON'|translate}}</span>
            </ng-container>
        </div>
    </div>
    <div class="modal-body">
        <div class="row">
            <div class="col-12 mb-2">
                <label class="report-form-label">{{'MAP.GEOLOCATION_NAME'|translate}}</label>
                <input [(ngModel)]="geoLocationName" type="text" maxlength="128" class="form-control form-control-sm">
            </div>
        </div>
        <ng-container *ngIf="form">
            <form [formGroup]="form">
                <div class="row">
                    <div class="col-md-4 col-12">
                        <label class="report-form-label">{{'MAP.GEOLOCATION_LATITUDE'|translate}}</label>
                        <input [formControl]="form.get('latitude')" type="number"
                            [ngClass]="{'is-invalid': form.get('latitude').invalid}"
                            class="form-control form-control-sm">
                        <ng-template
                            *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('latitude')}">
                        </ng-template>
                    </div>
                    <div class="col-md-4 col-12">
                        <label class="report-form-label">{{'MAP.GEOLOCATION_LONGITUDE'|translate}}</label>
                        <input [formControl]="form.get('longitude')" type="number"
                            [ngClass]="{'is-invalid': form.get('longitude').invalid}"
                            class="form-control form-control-sm">
                        <ng-template
                            *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('longitude')}">
                        </ng-template>
                    </div>
                    <div class="col-md-4 col-12">
                        <label class="report-form-label">{{'MAP.GEOLOCATION_RADIUS'|translate}}</label>
                        <div class="input-group input-group-sm">
                            <input [formControl]="form.get('radius')" type="number"
                                [ngClass]="{'is-invalid': form.get('radius').invalid}"
                                class="form-control form-control-sm">                           
                                <span class="input-group-text">{{'MAP.GEOLOCATION_RADIUS_UNIT'|translate}}</span>
                        </div>
                        <ng-template
                            *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('radius')}">
                        </ng-template>
                    </div>
                </div>
            </form>
        </ng-container>
        <div class="row mt-2">
            <div class="col-12 mb-2 d-flex align-items-center">
                <div class="d-flex align-items-center" [hidden]="!drawed">
                    <div class="p-2 me-1 cursor-pointer color-error" (click)="onResetClicked($event)" nz-tooltip
                        *ngIf="drawed" nzTooltipTitle="{{'MAP.GEOLOCATION_DELETE_SELECTED' | translate}}">
                        <cds-icon shape="trash" class="cds-icon-20" solid></cds-icon>
                    </div>
                </div>
                <div class=" d-flex align-items-center color-primary ms-auto">
                    <div *ngIf="availableGeoLocationApi" class="p-2 me-1 cursor-pointer"
                        (click)="onCenterLocationClicked($event)" nz-tooltip
                        nzTooltipTitle="{{'MAP.GEOLOCATION_SELECT_LOCATION' | translate}}">
                        <cds-icon shape="map-marker" class="cds-icon-20" solid></cds-icon>
                    </div>
                    <div class="p-2 me-1 cursor-pointer" (click)="onCenterSelectedClicked($event)" nz-tooltip
                        *ngIf="drawed" nzTooltipTitle="{{'MAP.GEOLOCATION_CENTER_SELECTED' | translate}}">
                        <cds-icon shape="crosshairs" class="cds-icon-20" solid></cds-icon>
                    </div>
                    <div class="p-2 me-1 cursor-pointer" nz-tooltip [hidden]="form?.invalid"
                        nzTooltipTitle="{{'MAP.LOCATION_SHOW_GOOGLE_MAPS'| translate}}">
                        <a href="{{googleMapsUrl}}" target="_blank">
                            <cds-icon shape="google_maps" class="cds-icon-20" solid></cds-icon>
                        </a>
                    </div>
                </div>
            </div>
        </div>

        <div class="row mt-1">
            <div class="col-12">
                <div class="pos-relative" style="height: 480px;" [ngClass]="{'opacity-0': !visibleMap}">
                    <div class="map-container-absolute">
                        <div id="{{mapId}}" class="map-container"></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row mt-2">
            <div class="col-12">
                <div class="d-flex bg-color-success-tint rnd-1">
                    <div class="d-flex p-1 m-2 b-r-1">
                        <cds-icon shape="help" size="md" solid class="color-success opacity-50"></cds-icon>
                    </div>
                    <div class="d-flex flex-column flex-grow-1 justify-content-center">
                        <span
                            class="text-sm fw-medium">{{(drawed?'MAP.GEOLOCATION_DIRECTION_MODIFY':'MAP.GEOLOCATION_DIRECTION_DRAW')|translate}}</span>
                        <span class="text-sm"
                            *ngIf="selectionType=='Circle'">{{(drawed?'MAP.GEOLOCATION_MODIFY_CIRCLE_DIRECTION':'MAP.GEOLOCATION_DRAW_CIRCLE_DIRECTION')|translate}}</span>
                        <span class="text-sm"
                            *ngIf="selectionType=='Polygon'">{{(drawed?'MAP.GEOLOCATION_MODIFY_POLYGON_DIRECTION':'MAP.GEOLOCATION_DRAW_POLYGON_DIRECTION')|translate}}</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-outline-primary" (click)="onCancelClicked($event)">{{'BUTTON.CANCEL' |
            translate}}</button>
        <button class="btn btn-primary" (click)="onSaveClicked($event)"
            [disabled]="!drawed || form?.invalid">{{'BUTTON.OK' |
            translate}}</button>
    </div>
</ng-container>

<!-- FORM FIELD VALIDATION -->
<ng-template #controlValidationTemplate let-form let-control="control" let-isArray="isArray">
    <ng-container *ngIf="control.errors">
        <div class="invalid-feedback" style="display: initial;">
            <span
                *ngIf="control.errors.required">{{(isArray?'VALIDATION.MIN_ONE_SELECTED':'VALIDATION.REQUIRED')|translate}}</span>
            <span *ngIf="control.errors.ip">{{'VALIDATION.IP_V4_OR_V6'|translate}}</span>
            <span *ngIf="control.errors.numeric">{{'VALIDATION.POSITIVE_NUMBER'|translate}}</span>
            <span *ngIf="control.errors.minNumber" [translate]="'VALIDATION.MIN_VALUE'"
                [translateParams]="{min: control.errors.minNumber.refValues[1]}"></span>
            <span *ngIf="control.errors.maxNumber" [translate]="'VALIDATION.MAX_VALUE'"
                [translateParams]="{max: control.errors.maxNumber.refValues[1]}"></span>
            <span *ngIf="control.errors.unique">{{'VALIDATION.UNIQUE'|translate}}</span>
            <span *ngIf="control.errors.longitude">{{'VALIDATION.LOCATION_LONGITUDE'|translate}}</span>
            <span *ngIf="control.errors.latitude">{{'VALIDATION.LOCATION_LATITUTE'|translate}}</span>
        </div>
    </ng-container>
</ng-template>`;var Ft=`.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}.map-container-absolute{position:absolute;height:480px;left:0;right:0}.map-container{width:100%!important;height:100%;position:absolute;cursor:crosshair;border:1px solid #0a2a5a}.map-container::ng-deep .ol-attribution{font-size:.2rem!important}
`;var Oe=class h extends gt{constructor(e){super(),this.geometries_=e,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(N),this.changeEventsKeys_.length=0}listenGeometriesChange_(){let e=this.geometries_;for(let t=0,i=e.length;t<i;++t)this.changeEventsKeys_.push(G(e[t],M.CHANGE,this.changed,this))}clone(){let e=new h(Se(this.geometries_));return e.applyProperties(this),e}closestPointXY(e,t,i,s){if(s<rt(this.getExtent(),e,t))return s;let n=this.geometries_;for(let o=0,r=n.length;o<r;++o)s=n[o].closestPointXY(e,t,i,s);return s}containsXY(e,t){let i=this.geometries_;for(let s=0,n=i.length;s<n;++s)if(i[s].containsXY(e,t))return!0;return!1}computeExtent(e){lt(e);let t=this.geometries_;for(let i=0,s=t.length;i<s;++i)ct(e,t[i].getExtent());return e}getGeometries(){return Se(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let e=[],t=this.geometries_;for(let i=0,s=t.length;i<s;++i)t[i].getType()===this.getType()?e=e.concat(t[i].getGeometriesArrayRecursive()):e.push(t[i]);return e}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<this.simplifiedGeometryMaxMinSquaredTolerance)return this;let t=[],i=this.geometries_,s=!1;for(let n=0,o=i.length;n<o;++n){let r=i[n],a=r.getSimplifiedGeometry(e);t.push(a),a!==r&&(s=!0)}return s?new h(t):(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getType(){return"GeometryCollection"}intersectsExtent(e){let t=this.geometries_;for(let i=0,s=t.length;i<s;++i)if(t[i].intersectsExtent(e))return!0;return!1}isEmpty(){return this.geometries_.length===0}rotate(e,t){let i=this.geometries_;for(let s=0,n=i.length;s<n;++s)i[s].rotate(e,t);this.changed()}scale(e,t,i){i||(i=de(this.getExtent()));let s=this.geometries_;for(let n=0,o=s.length;n<o;++n)s[n].scale(e,t,i);this.changed()}setGeometries(e){this.setGeometriesArray(Se(e))}setGeometriesArray(e){this.unlistenGeometriesChange_(),this.geometries_=e,this.listenGeometriesChange_(),this.changed()}applyTransform(e){let t=this.geometries_;for(let i=0,s=t.length;i<s;++i)t[i].applyTransform(e);this.changed()}translate(e,t){let i=this.geometries_;for(let s=0,n=i.length;s<n;++s)i[s].translate(e,t);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}};function Se(h){return h.map(e=>e.clone())}var Dt=Oe;var pe={DRAWSTART:"drawstart",DRAWEND:"drawend",DRAWABORT:"drawabort"},Y=class extends b{constructor(e,t){super(e),this.feature=t}};function Zt(h,e){let t=[];for(let i=0;i<e.length;++i){let n=e[i].getGeometry();At(h,n,t)}return t}function _e(h,e){return Ee(h[0],h[1],e[0],e[1])}function K(h,e){let t=h.length;return e<0?h[e+t]:e>=t?h[e-t]:h[e]}function ye(h,e,t){let i,s;e<t?(i=e,s=t):(i=t,s=e);let n=Math.ceil(i),o=Math.floor(s);if(n>o){let a=W(h,i),l=W(h,s);return _e(a,l)}let r=0;if(i<n){let a=W(h,i),l=K(h,n);r+=_e(a,l)}if(o<s){let a=K(h,o),l=W(h,s);r+=_e(a,l)}for(let a=n;a<o-1;++a){let l=K(h,a),c=K(h,a+1);r+=_e(l,c)}return r}function At(h,e,t){if(e instanceof te){Ce(h,e.getCoordinates(),!1,t);return}if(e instanceof we){let i=e.getCoordinates();for(let s=0,n=i.length;s<n;++s)Ce(h,i[s],!1,t);return}if(e instanceof Q){let i=e.getCoordinates();for(let s=0,n=i.length;s<n;++s)Ce(h,i[s],!0,t);return}if(e instanceof Le){let i=e.getCoordinates();for(let s=0,n=i.length;s<n;++s){let o=i[s];for(let r=0,a=o.length;r<a;++r)Ce(h,o[r],!0,t)}return}if(e instanceof Dt){let i=e.getGeometries();for(let s=0;s<i.length;++s)At(h,i[s],t);return}}var Me={index:-1,endIndex:NaN};function Qt(h,e,t,i){let s=h[0],n=h[1],o=1/0,r=-1,a=NaN;for(let u=0;u<e.targets.length;++u){let d=e.targets[u],g=d.coordinates,m=1/0,f;for(let p=0;p<g.length-1;++p){let y=g[p],x=g[p+1],C=bt(s,n,y,x);C.squaredDistance<m&&(m=C.squaredDistance,f=p+C.along)}m<o&&(o=m,d.ring&&e.targetIndex===u&&(d.endIndex>d.startIndex?f<d.startIndex&&(f+=g.length):d.endIndex<d.startIndex&&f>d.startIndex&&(f-=g.length)),a=f,r=u)}let l=e.targets[r],c=l.ring;if(e.targetIndex===r&&c){let u=W(l.coordinates,a),d=t.getPixelFromCoordinate(u);V(d,e.startPx)>i&&(c=!1)}if(c){let u=l.coordinates,d=u.length,g=l.startIndex,m=a;if(g<m){let f=ye(u,g,m);ye(u,g,m-d)<f&&(a-=d)}else{let f=ye(u,g,m);ye(u,g,m+d)<f&&(a+=d)}}return Me.index=r,Me.endIndex=a,Me}function Ce(h,e,t,i){let s=h[0],n=h[1];for(let o=0,r=e.length-1;o<r;++o){let a=e[o],l=e[o+1],c=bt(s,n,a,l);if(c.squaredDistance===0){let u=o+c.along;i.push({coordinates:e,ring:t,startIndex:u,endIndex:u});return}}}var Ge={along:0,squaredDistance:0};function bt(h,e,t,i){let s=t[0],n=t[1],o=i[0],r=i[1],a=o-s,l=r-n,c=0,u=s,d=n;return(a!==0||l!==0)&&(c=nt(((h-s)*a+(e-n)*l)/(a*a+l*l),0,1),u+=a*c,d+=l*c),Ge.along=c,Ge.squaredDistance=ot(Ee(h,e,u,d),10),Ge}function W(h,e){let t=h.length,i=Math.floor(e),s=e-i;i>=t?i-=t:i<0&&(i+=t);let n=i+1;n>=t&&(n-=t);let o=h[i],r=o[0],a=o[1],l=h[n],c=l[0]-r,u=l[1]-a;return[r+c*s,a+u*s]}var Ie=class extends B{constructor(e){let t=e;t.stopDown||(t.stopDown=le),super(t),this.on,this.once,this.un,this.shouldHandle_=!1,this.downPx_=null,this.downTimeout_,this.lastDragTime_,this.pointerType_,this.freehand_=!1,this.source_=e.source?e.source:null,this.features_=e.features?e.features:null,this.snapTolerance_=e.snapTolerance?e.snapTolerance:12,this.type_=e.type,this.mode_=ei(this.type_),this.stopClick_=!!e.stopClick,this.minPoints_=e.minPoints?e.minPoints:this.mode_==="Polygon"?3:2,this.maxPoints_=this.mode_==="Circle"?2:e.maxPoints?e.maxPoints:1/0,this.finishCondition_=e.finishCondition?e.finishCondition:ae,this.geometryLayout_=e.geometryLayout?e.geometryLayout:"XY";let i=e.geometryFunction;if(!i){let s=this.mode_;if(s==="Circle")i=function(n,o,r){let a=o||new ee([NaN,NaN]),l=_(n[0],r),c=S(l,_(n[n.length-1],r));a.setCenterAndRadius(l,Math.sqrt(c),this.geometryLayout_);let u=L();return u&&a.transform(r,u),a};else{let n;s==="Point"?n=F:s==="LineString"?n=te:s==="Polygon"&&(n=Q),i=function(o,r,a){return r?s==="Polygon"?o[0].length?r.setCoordinates([o[0].concat([o[0][0]])],this.geometryLayout_):r.setCoordinates([],this.geometryLayout_):r.setCoordinates(o,this.geometryLayout_):r=new n(o,this.geometryLayout_),r}}}this.geometryFunction_=i,this.dragVertexDelay_=e.dragVertexDelay!==void 0?e.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=e.clickTolerance?e.clickTolerance*e.clickTolerance:36,this.overlay_=new q({source:new D({useSpatialIndex:!1,wrapX:e.wrapX?e.wrapX:!1}),style:e.style?e.style:Jt(),updateWhileInteracting:!0}),this.geometryName_=e.geometryName,this.condition_=e.condition?e.condition:Et,this.freehandCondition_,e.freehand?this.freehandCondition_=J:this.freehandCondition_=e.freehandCondition?e.freehandCondition:Pt,this.traceCondition_,this.setTrace(e.trace||!1),this.traceState_={active:!1},this.traceSource_=e.traceSource||e.source||null,this.addChangeListener(Ct.ACTIVE,this.updateState_)}setTrace(e){let t;e?e===!0?t=J:t=e:t=Tt,this.traceCondition_=t}setMap(e){super.setMap(e),this.updateState_()}getOverlay(){return this.overlay_}handleEvent(e){e.originalEvent.type===M.CONTEXTMENU&&e.originalEvent.preventDefault(),this.freehand_=this.mode_!=="Point"&&this.freehandCondition_(e);let t=e.type===v.POINTERMOVE,i=!0;return!this.freehand_&&this.lastDragTime_&&e.type===v.POINTERDRAG&&(Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=e.pixel,this.shouldHandle_=!this.freehand_,t=!0):this.lastDragTime_=void 0,this.shouldHandle_&&this.downTimeout_!==void 0&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)),this.freehand_&&e.type===v.POINTERDRAG&&this.sketchFeature_!==null?(this.addToDrawing_(e.coordinate),i=!1):this.freehand_&&e.type===v.POINTERDOWN?i=!1:t&&this.getPointerCount()<2?(i=e.type===v.POINTERMOVE,i&&this.freehand_?(this.handlePointerMove_(e),this.shouldHandle_&&e.originalEvent.preventDefault()):(e.originalEvent.pointerType==="mouse"||e.type===v.POINTERDRAG&&this.downTimeout_===void 0)&&this.handlePointerMove_(e)):e.type===v.DBLCLICK&&(i=!1),super.handleEvent(e)&&i}handleDownEvent(e){return this.shouldHandle_=!this.freehand_,this.freehand_?(this.downPx_=e.pixel,this.finishCoordinate_||this.startDrawing_(e.coordinate),!0):this.condition_(e)?(this.lastDragTime_=Date.now(),this.downTimeout_=setTimeout(()=>{this.handlePointerMove_(new yt(v.POINTERMOVE,e.map,e.originalEvent,!1,e.frameState))},this.dragVertexDelay_),this.downPx_=e.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(e){if(!this.traceSource_||!this.traceCondition_(e))return;if(this.traceState_.active){this.deactivateTrace_();return}let t=this.getMap(),i=t.getCoordinateFromPixel([e.pixel[0]-this.snapTolerance_,e.pixel[1]+this.snapTolerance_]),s=t.getCoordinateFromPixel([e.pixel[0]+this.snapTolerance_,e.pixel[1]-this.snapTolerance_]),n=T([i,s]),o=this.traceSource_.getFeaturesInExtent(n);if(o.length===0)return;let r=Zt(e.coordinate,o);r.length&&(this.traceState_={active:!0,startPx:e.pixel.slice(),targets:r,targetIndex:-1})}addOrRemoveTracedCoordinates_(e,t){let i=e.startIndex<=e.endIndex,s=e.startIndex<=t;i===s?i&&t>e.endIndex||!i&&t<e.endIndex?this.addTracedCoordinates_(e,e.endIndex,t):(i&&t<e.endIndex||!i&&t>e.endIndex)&&this.removeTracedCoordinates_(t,e.endIndex):(this.removeTracedCoordinates_(e.startIndex,e.endIndex),this.addTracedCoordinates_(e,e.startIndex,t))}removeTracedCoordinates_(e,t){if(e===t)return;let i=0;if(e<t){let s=Math.ceil(e),n=Math.floor(t);n===t&&(n-=1),i=n-s+1}else{let s=Math.floor(e),n=Math.ceil(t);n===t&&(n+=1),i=s-n+1}i>0&&this.removeLastPoints_(i)}addTracedCoordinates_(e,t,i){if(t===i)return;let s=[];if(t<i){let n=Math.ceil(t),o=Math.floor(i);o===i&&(o-=1);for(let r=n;r<=o;++r)s.push(K(e.coordinates,r))}else{let n=Math.floor(t),o=Math.ceil(i);o===i&&(o+=1);for(let r=n;r>=o;--r)s.push(K(e.coordinates,r))}s.length&&this.appendCoordinates(s)}updateTrace_(e){let t=this.traceState_;if(!t.active||t.targetIndex===-1&&V(t.startPx,e.pixel)<this.snapTolerance_)return;let i=Qt(e.coordinate,t,this.getMap(),this.snapTolerance_);if(t.targetIndex!==i.index){if(t.targetIndex!==-1){let a=t.targets[t.targetIndex];this.removeTracedCoordinates_(a.startIndex,a.endIndex)}let r=t.targets[i.index];this.addTracedCoordinates_(r,r.startIndex,i.endIndex)}else{let r=t.targets[t.targetIndex];this.addOrRemoveTracedCoordinates_(r,i.endIndex)}t.targetIndex=i.index;let s=t.targets[t.targetIndex];s.endIndex=i.endIndex;let n=W(s.coordinates,s.endIndex),o=this.getMap().getPixelFromCoordinate(n);e.coordinate=n,e.pixel=[Math.round(o[0]),Math.round(o[1])]}handleUpEvent(e){let t=!0;if(this.getPointerCount()===0){this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0),this.handlePointerMove_(e);let i=this.traceState_.active;if(this.toggleTraceState_(e),this.shouldHandle_){let s=!this.finishCoordinate_;s&&this.startDrawing_(e.coordinate),!s&&this.freehand_?this.finishDrawing():!this.freehand_&&(!s||this.mode_==="Point")&&(this.atFinish_(e.pixel,i)?this.finishCondition_(e)&&this.finishDrawing():this.addToDrawing_(e.coordinate)),t=!1}else this.freehand_&&this.abortDrawing()}return!t&&this.stopClick_&&e.preventDefault(),t}handlePointerMove_(e){if(this.pointerType_=e.originalEvent.pointerType,this.downPx_&&(!this.freehand_&&this.shouldHandle_||this.freehand_&&!this.shouldHandle_)){let t=this.downPx_,i=e.pixel,s=t[0]-i[0],n=t[1]-i[1],o=s*s+n*n;if(this.shouldHandle_=this.freehand_?o>this.squaredClickTolerance_:o<=this.squaredClickTolerance_,!this.shouldHandle_)return}if(!this.finishCoordinate_){this.createOrUpdateSketchPoint_(e.coordinate.slice());return}this.updateTrace_(e),this.modifyDrawing_(e.coordinate)}atFinish_(e,t){let i=!1;if(this.sketchFeature_){let s=!1,n=[this.finishCoordinate_],o=this.mode_;if(o==="Point")i=!0;else if(o==="Circle")i=this.sketchCoords_.length===2;else if(o==="LineString")s=!t&&this.sketchCoords_.length>this.minPoints_;else if(o==="Polygon"){let r=this.sketchCoords_;s=r[0].length>this.minPoints_,n=[r[0][0],r[0][r[0].length-2]],t?n=[r[0][0]]:n=[r[0][0],r[0][r[0].length-2]]}if(s){let r=this.getMap();for(let a=0,l=n.length;a<l;a++){let c=n[a],u=r.getPixelFromCoordinate(c),d=e[0]-u[0],g=e[1]-u[1],m=this.freehand_?1:this.snapTolerance_;if(i=Math.sqrt(d*d+g*g)<=m,i){this.finishCoordinate_=c;break}}}}return i}createOrUpdateSketchPoint_(e){this.sketchPoint_?this.sketchPoint_.getGeometry().setCoordinates(e):(this.sketchPoint_=new E(new F(e)),this.updateSketchFeatures_())}createOrUpdateCustomSketchLine_(e){this.sketchLine_||(this.sketchLine_=new E);let t=e.getLinearRing(0),i=this.sketchLine_.getGeometry();i?(i.setFlatCoordinates(t.getLayout(),t.getFlatCoordinates()),i.changed()):(i=new te(t.getFlatCoordinates(),t.getLayout()),this.sketchLine_.setGeometry(i))}startDrawing_(e){let t=this.getMap().getView().getProjection(),i=Pe(this.geometryLayout_);for(;e.length<i;)e.push(0);this.finishCoordinate_=e,this.mode_==="Point"?this.sketchCoords_=e.slice():this.mode_==="Polygon"?(this.sketchCoords_=[[e.slice(),e.slice()]],this.sketchLineCoords_=this.sketchCoords_[0]):this.sketchCoords_=[e.slice(),e.slice()],this.sketchLineCoords_&&(this.sketchLine_=new E(new te(this.sketchLineCoords_)));let s=this.geometryFunction_(this.sketchCoords_,void 0,t);this.sketchFeature_=new E,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(s),this.updateSketchFeatures_(),this.dispatchEvent(new Y(pe.DRAWSTART,this.sketchFeature_))}modifyDrawing_(e){let t=this.getMap(),i=this.sketchFeature_.getGeometry(),s=t.getView().getProjection(),n=Pe(this.geometryLayout_),o,r;for(;e.length<n;)e.push(0);this.mode_==="Point"?r=this.sketchCoords_:this.mode_==="Polygon"?(o=this.sketchCoords_[0],r=o[o.length-1],this.atFinish_(t.getPixelFromCoordinate(e))&&(e=this.finishCoordinate_.slice())):(o=this.sketchCoords_,r=o[o.length-1]),r[0]=e[0],r[1]=e[1],this.geometryFunction_(this.sketchCoords_,i,s),this.sketchPoint_&&this.sketchPoint_.getGeometry().setCoordinates(e),i.getType()==="Polygon"&&this.mode_!=="Polygon"?this.createOrUpdateCustomSketchLine_(i):this.sketchLineCoords_&&this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_),this.updateSketchFeatures_()}addToDrawing_(e){let t=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection(),s,n,o=this.mode_;return o==="LineString"||o==="Circle"?(this.finishCoordinate_=e.slice(),n=this.sketchCoords_,n.length>=this.maxPoints_&&(this.freehand_?n.pop():s=!0),n.push(e.slice()),this.geometryFunction_(n,t,i)):o==="Polygon"&&(n=this.sketchCoords_[0],n.length>=this.maxPoints_&&(this.freehand_?n.pop():s=!0),n.push(e.slice()),s&&(this.finishCoordinate_=n[0]),this.geometryFunction_(this.sketchCoords_,t,i)),this.createOrUpdateSketchPoint_(e.slice()),this.updateSketchFeatures_(),s?this.finishDrawing():this.sketchFeature_}removeLastPoints_(e){if(!this.sketchFeature_)return;let t=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection(),s=this.mode_;for(let n=0;n<e;++n){let o;if(s==="LineString"||s==="Circle"){if(o=this.sketchCoords_,o.splice(-2,1),o.length>=2){this.finishCoordinate_=o[o.length-2].slice();let r=this.finishCoordinate_.slice();o[o.length-1]=r,this.createOrUpdateSketchPoint_(r)}this.geometryFunction_(o,t,i),t.getType()==="Polygon"&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(t)}else if(s==="Polygon"){o=this.sketchCoords_[0],o.splice(-2,1);let r=this.sketchLine_.getGeometry();if(o.length>=2){let a=o[o.length-2].slice();o[o.length-1]=a,this.createOrUpdateSketchPoint_(a)}r.setCoordinates(o),this.geometryFunction_(this.sketchCoords_,t,i)}if(o.length===1){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){let e=this.abortDrawing_();if(!e)return null;let t=this.sketchCoords_,i=e.getGeometry(),s=this.getMap().getView().getProjection();return this.mode_==="LineString"?(t.pop(),this.geometryFunction_(t,i,s)):this.mode_==="Polygon"&&(t[0].pop(),this.geometryFunction_(t,i,s),t=i.getCoordinates()),this.type_==="MultiPoint"?e.setGeometry(new Mt([t])):this.type_==="MultiLineString"?e.setGeometry(new we([t])):this.type_==="MultiPolygon"&&e.setGeometry(new Le([t])),this.dispatchEvent(new Y(pe.DRAWEND,e)),this.features_&&this.features_.push(e),this.source_&&this.source_.addFeature(e),e}abortDrawing_(){this.finishCoordinate_=null;let e=this.sketchFeature_;return this.sketchFeature_=null,this.sketchPoint_=null,this.sketchLine_=null,this.overlay_.getSource().clear(!0),this.deactivateTrace_(),e}abortDrawing(){let e=this.abortDrawing_();e&&this.dispatchEvent(new Y(pe.DRAWABORT,e))}appendCoordinates(e){let t=this.mode_,i=!this.sketchFeature_;i&&this.startDrawing_(e[0]);let s;if(t==="LineString"||t==="Circle")s=this.sketchCoords_;else if(t==="Polygon")s=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[];else return;i&&s.shift(),s.pop();for(let o=0;o<e.length;o++)this.addToDrawing_(e[o]);let n=e[e.length-1];this.sketchFeature_=this.addToDrawing_(n),this.modifyDrawing_(n)}extend(e){let i=e.getGeometry();this.sketchFeature_=e,this.sketchCoords_=i.getCoordinates();let s=this.sketchCoords_[this.sketchCoords_.length-1];this.finishCoordinate_=s.slice(),this.sketchCoords_.push(s.slice()),this.sketchPoint_=new E(new F(s)),this.updateSketchFeatures_(),this.dispatchEvent(new Y(pe.DRAWSTART,this.sketchFeature_))}updateSketchFeatures_(){let e=[];this.sketchFeature_&&e.push(this.sketchFeature_),this.sketchLine_&&e.push(this.sketchLine_),this.sketchPoint_&&e.push(this.sketchPoint_);let t=this.overlay_.getSource();t.clear(!0),t.addFeatures(e)}updateState_(){let e=this.getMap(),t=this.getActive();(!e||!t)&&this.abortDrawing(),this.overlay_.setMap(t?e:null)}};function Jt(){let h=me();return function(e,t){return h[e.getGeometry().getType()]}}function ei(h){switch(h){case"Point":case"MultiPoint":return"Point";case"LineString":case"MultiLineString":return"LineString";case"Polygon":case"MultiPolygon":return"Polygon";case"Circle":return"Circle";default:throw new Error("Invalid type: "+h)}}var Nt=Ie;var Rt=0,ie=1,Vt=[0,0,0,0],H=[],ke={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"},se=class extends b{constructor(e,t,i){super(e),this.features=t,this.mapBrowserEvent=i}},Fe=class extends B{constructor(e){super(e),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=e.condition?e.condition:wt,this.defaultDeleteCondition_=function(i){return xt(i)&&vt(i)},this.deleteCondition_=e.deleteCondition?e.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=e.insertVertexCondition?e.insertVertexCondition:J,this.vertexFeature_=null,this.vertexSegments_=null,this.lastPixel_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new fe,this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new q({source:new D({useSpatialIndex:!1,wrapX:!!e.wrapX}),style:e.style?e.style:ii(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.SEGMENT_WRITERS_={Point:this.writePointGeometry_.bind(this),LineString:this.writeLineStringGeometry_.bind(this),LinearRing:this.writeLineStringGeometry_.bind(this),Polygon:this.writePolygonGeometry_.bind(this),MultiPoint:this.writeMultiPointGeometry_.bind(this),MultiLineString:this.writeMultiLineStringGeometry_.bind(this),MultiPolygon:this.writeMultiPolygonGeometry_.bind(this),Circle:this.writeCircleGeometry_.bind(this),GeometryCollection:this.writeGeometryCollectionGeometry_.bind(this)},this.source_=null,this.hitDetection_=null;let t;if(e.features?t=e.features:e.source&&(this.source_=e.source,t=new ve(this.source_.getFeatures()),this.source_.addEventListener(z.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(z.REMOVEFEATURE,this.handleSourceRemove_.bind(this))),!t)throw new Error("The modify interaction requires features, a source or a layer");e.hitDetection&&(this.hitDetection_=e.hitDetection),this.features_=t,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(R.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(R.REMOVE,this.handleFeatureRemove_.bind(this)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=e.snapToPointer===void 0?!this.hitDetection_:e.snapToPointer}addFeature_(e){let t=e.getGeometry();if(t){let s=this.SEGMENT_WRITERS_[t.getType()];s&&s(e,t)}let i=this.getMap();i&&i.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(this.lastPixel_,i),e.addEventListener(M.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(e,t){if(!this.featuresBeingModified_){this.featuresBeingModified_=new ve;let i=this.featuresBeingModified_.getArray();for(let s=0,n=t.length;s<n;++s){let o=t[s];for(let r=0,a=o.length;r<a;++r){let l=o[r].feature;l&&!i.includes(l)&&this.featuresBeingModified_.push(l)}}this.featuresBeingModified_.getLength()===0?this.featuresBeingModified_=null:this.dispatchEvent(new se(ke.MODIFYSTART,this.featuresBeingModified_,e))}}removeFeature_(e){this.removeFeatureSegmentData_(e),this.vertexFeature_&&this.features_.getLength()===0&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.removeEventListener(M.CHANGE,this.boundHandleFeatureChange_)}removeFeatureSegmentData_(e){let t=this.rBush_,i=[];t.forEach(function(s){e===s.feature&&i.push(s)});for(let s=i.length-1;s>=0;--s){let n=i[s];for(let o=this.dragSegments_.length-1;o>=0;--o)this.dragSegments_[o][0]===n&&this.dragSegments_.splice(o,1);t.remove(n)}}setActive(e){this.vertexFeature_&&!e&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(e)}setMap(e){this.overlay_.setMap(e),super.setMap(e)}getOverlay(){return this.overlay_}handleSourceAdd_(e){e.feature&&this.features_.push(e.feature)}handleSourceRemove_(e){e.feature&&this.features_.remove(e.feature)}handleFeatureAdd_(e){this.addFeature_(e.element)}handleFeatureChange_(e){if(!this.changingFeature_){let t=e.target;this.removeFeature_(t),this.addFeature_(t)}}handleFeatureRemove_(e){this.removeFeature_(e.element)}writePointGeometry_(e,t){let i=t.getCoordinates(),s={feature:e,geometry:t,segment:[i,i]};this.rBush_.insert(t.getExtent(),s)}writeMultiPointGeometry_(e,t){let i=t.getCoordinates();for(let s=0,n=i.length;s<n;++s){let o=i[s],r={feature:e,geometry:t,depth:[s],index:s,segment:[o,o]};this.rBush_.insert(t.getExtent(),r)}}writeLineStringGeometry_(e,t){let i=t.getCoordinates();for(let s=0,n=i.length-1;s<n;++s){let o=i.slice(s,s+2),r={feature:e,geometry:t,index:s,segment:o};this.rBush_.insert(T(o),r)}}writeMultiLineStringGeometry_(e,t){let i=t.getCoordinates();for(let s=0,n=i.length;s<n;++s){let o=i[s];for(let r=0,a=o.length-1;r<a;++r){let l=o.slice(r,r+2),c={feature:e,geometry:t,depth:[s],index:r,segment:l};this.rBush_.insert(T(l),c)}}}writePolygonGeometry_(e,t){let i=t.getCoordinates();for(let s=0,n=i.length;s<n;++s){let o=i[s];for(let r=0,a=o.length-1;r<a;++r){let l=o.slice(r,r+2),c={feature:e,geometry:t,depth:[s],index:r,segment:l};this.rBush_.insert(T(l),c)}}}writeMultiPolygonGeometry_(e,t){let i=t.getCoordinates();for(let s=0,n=i.length;s<n;++s){let o=i[s];for(let r=0,a=o.length;r<a;++r){let l=o[r];for(let c=0,u=l.length-1;c<u;++c){let d=l.slice(c,c+2),g={feature:e,geometry:t,depth:[r,s],index:c,segment:d};this.rBush_.insert(T(d),g)}}}}writeCircleGeometry_(e,t){let i=t.getCenter(),s={feature:e,geometry:t,index:Rt,segment:[i,i]},n={feature:e,geometry:t,index:ie,segment:[i,i]},o=[s,n];s.featureSegments=o,n.featureSegments=o,this.rBush_.insert(he(i),s);let r=t,a=L();if(a&&this.getMap()){let l=this.getMap().getView().getProjection();r=r.clone().transform(a,l),r=U(r).transform(l,a)}this.rBush_.insert(r.getExtent(),n)}writeGeometryCollectionGeometry_(e,t){let i=t.getGeometriesArray();for(let s=0;s<i.length;++s){let n=i[s],o=this.SEGMENT_WRITERS_[n.getType()];o(e,n)}}createOrUpdateVertexFeature_(e,t,i){let s=this.vertexFeature_;return s?s.getGeometry().setCoordinates(e):(s=new E(new F(e)),this.vertexFeature_=s,this.overlay_.getSource().addFeature(s)),s.set("features",t),s.set("geometries",i),s}handleEvent(e){if(!e.originalEvent)return!0;this.lastPointerEvent_=e;let t;return!e.map.getView().getInteracting()&&e.type==v.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(e),this.vertexFeature_&&this.deleteCondition_(e)&&(e.type!=v.SINGLECLICK||!this.ignoreNextSingleClick_?t=this.removePoint():t=!0),e.type==v.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(e)&&!t}handleDragEvent(e){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(e,this.dragSegments_);let t=[e.coordinate[0]+this.delta_[0],e.coordinate[1]+this.delta_[1]],i=[],s=[];for(let n=0,o=this.dragSegments_.length;n<o;++n){let r=this.dragSegments_[n],a=r[0],l=a.feature;i.includes(l)||i.push(l);let c=a.geometry;s.includes(c)||s.push(c);let u=a.depth,d,g=a.segment,m=r[1];for(;t.length<c.getStride();)t.push(g[m][t.length]);switch(c.getType()){case"Point":d=t,g[0]=t,g[1]=t;break;case"MultiPoint":d=c.getCoordinates(),d[a.index]=t,g[0]=t,g[1]=t;break;case"LineString":d=c.getCoordinates(),d[a.index+m]=t,g[m]=t;break;case"MultiLineString":d=c.getCoordinates(),d[u[0]][a.index+m]=t,g[m]=t;break;case"Polygon":d=c.getCoordinates(),d[u[0]][a.index+m]=t,g[m]=t;break;case"MultiPolygon":d=c.getCoordinates(),d[u[1]][u[0]][a.index+m]=t,g[m]=t;break;case"Circle":if(g[0]=t,g[1]=t,a.index===Rt)this.changingFeature_=!0,c.setCenter(t),this.changingFeature_=!1;else{this.changingFeature_=!0;let f=e.map.getView().getProjection(),p=V(_(c.getCenter(),f),_(t,f)),y=L();if(y){let x=c.clone().transform(y,f);x.setRadius(p),p=x.transform(f,y).getRadius()}c.setRadius(p),this.changingFeature_=!1}break;default:}d&&this.setGeometryCoordinates_(c,d)}this.createOrUpdateVertexFeature_(t,i,s)}handleDownEvent(e){if(!this.condition_(e))return!1;let t=e.coordinate;this.handlePointerAtPixel_(e.pixel,e.map,t),this.dragSegments_.length=0,this.featuresBeingModified_=null;let i=this.vertexFeature_;if(i){let s=e.map.getView().getProjection(),n=[],o=i.getGeometry().getCoordinates(),r=T([o]),a=this.rBush_.getInExtent(r),l={};a.sort(ti);for(let c=0,u=a.length;c<u;++c){let d=a[c],g=d.segment,m=w(d.geometry),f=d.depth;if(f&&(m+="-"+f.join("-")),l[m]||(l[m]=new Array(2)),d.geometry.getType()==="Circle"&&d.index===ie){let p=Ut(t,d,s);I(p,o)&&!l[m][0]&&(this.dragSegments_.push([d,0]),l[m][0]=d);continue}if(I(g[0],o)&&!l[m][0]){this.dragSegments_.push([d,0]),l[m][0]=d;continue}if(I(g[1],o)&&!l[m][1]){if(l[m][0]&&l[m][0].index===0){let p=d.geometry.getCoordinates();switch(d.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":p=p[f[1]];case"Polygon":if(d.index!==p[f[0]].length-2)continue;break;default:}}this.dragSegments_.push([d,1]),l[m][1]=d;continue}w(g)in this.vertexSegments_&&!l[m][0]&&!l[m][1]&&this.insertVertexCondition_(e)&&n.push(d)}n.length&&this.willModifyFeatures_(e,[n]);for(let c=n.length-1;c>=0;--c)this.insertVertex_(n[c],o)}return!!this.vertexFeature_}handleUpEvent(e){for(let t=this.dragSegments_.length-1;t>=0;--t){let i=this.dragSegments_[t][0],s=i.geometry;if(s.getType()==="Circle"){let n=s.getCenter(),o=i.featureSegments[0],r=i.featureSegments[1];o.segment[0]=n,o.segment[1]=n,r.segment[0]=n,r.segment[1]=n,this.rBush_.update(he(n),o);let a=s,l=L();if(l){let c=e.map.getView().getProjection();a=a.clone().transform(l,c),a=U(a).transform(c,l)}this.rBush_.update(a.getExtent(),r)}else this.rBush_.update(T(i.segment),i)}return this.featuresBeingModified_&&(this.dispatchEvent(new se(ke.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null),!1}handlePointerMove_(e){this.lastPixel_=e.pixel,this.handlePointerAtPixel_(e.pixel,e.map,e.coordinate)}handlePointerAtPixel_(e,t,i){let s=i||t.getCoordinateFromPixel(e),n=t.getView().getProjection(),o=function(l,c){return jt(s,l,n)-jt(s,c,n)},r,a;if(this.hitDetection_){let l=typeof this.hitDetection_=="object"?c=>c===this.hitDetection_:void 0;t.forEachFeatureAtPixel(e,(c,u,d)=>{d&&d.getType()==="Point"&&(d=new F(j(d.getCoordinates(),n)));let g=d||c.getGeometry();if(c instanceof E&&this.features_.getArray().includes(c)){a=g;let m=c.getGeometry().getFlatCoordinates().slice(0,2);r=[{feature:c,geometry:a,segment:[m,m]}]}return!0},{layerFilter:l})}if(!r){let l=ut(he(s,Vt),n),c=t.getView().getResolution()*this.pixelTolerance_,u=ge(ce(l,c,Vt),n);r=this.rBush_.getInExtent(u)}if(r&&r.length>0){let l=r.sort(o)[0],c=l.segment,u=Ut(s,l,n),d=t.getPixelFromCoordinate(u),g=V(e,d);if(a||g<=this.pixelTolerance_){let m={};if(m[w(c)]=!0,this.snapToPointer_||(this.delta_[0]=u[0]-s[0],this.delta_[1]=u[1]-s[1]),l.geometry.getType()==="Circle"&&l.index===ie)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(u,[l.feature],[l.geometry]);else{let f=t.getPixelFromCoordinate(c[0]),p=t.getPixelFromCoordinate(c[1]),y=S(d,f),x=S(d,p);g=Math.sqrt(Math.min(y,x)),this.snappedToVertex_=g<=this.pixelTolerance_,this.snappedToVertex_&&(u=y>x?c[1]:c[0]),this.createOrUpdateVertexFeature_(u,[l.feature],[l.geometry]);let C={};C[w(l.geometry)]=!0;for(let P=1,Kt=r.length;P<Kt;++P){let X=r[P].segment;if(I(c[0],X[0])&&I(c[1],X[1])||I(c[0],X[1])&&I(c[1],X[0])){let Ne=w(r[P].geometry);Ne in C||(C[Ne]=!0,m[w(X)]=!0)}else break}}this.vertexSegments_=m;return}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(e,t){let i=e.segment,s=e.feature,n=e.geometry,o=e.depth,r=e.index,a;for(;t.length<n.getStride();)t.push(0);switch(n.getType()){case"MultiLineString":a=n.getCoordinates(),a[o[0]].splice(r+1,0,t);break;case"Polygon":a=n.getCoordinates(),a[o[0]].splice(r+1,0,t);break;case"MultiPolygon":a=n.getCoordinates(),a[o[1]][o[0]].splice(r+1,0,t);break;case"LineString":a=n.getCoordinates(),a.splice(r+1,0,t);break;default:return}this.setGeometryCoordinates_(n,a);let l=this.rBush_;l.remove(e),this.updateSegmentIndices_(n,r,o,1);let c={segment:[i[0],t],feature:s,geometry:n,depth:o,index:r};l.insert(T(c.segment),c),this.dragSegments_.push([c,1]);let u={segment:[t,i[1]],feature:s,geometry:n,depth:o,index:r+1};l.insert(T(u.segment),u),this.dragSegments_.push([u,0]),this.ignoreNextSingleClick_=!0}removePoint(){if(this.lastPointerEvent_&&this.lastPointerEvent_.type!=v.POINTERDRAG){let e=this.lastPointerEvent_;this.willModifyFeatures_(e,this.dragSegments_);let t=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new se(ke.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null,t}return!1}removeVertex_(){let e=this.dragSegments_,t={},i=!1,s,n,o,r,a,l,c,u,d,g,m;for(a=e.length-1;a>=0;--a)o=e[a],g=o[0],m=w(g.feature),g.depth&&(m+="-"+g.depth.join("-")),m in t||(t[m]={}),o[1]===0?(t[m].right=g,t[m].index=g.index):o[1]==1&&(t[m].left=g,t[m].index=g.index+1);for(m in t){switch(d=t[m].right,c=t[m].left,l=t[m].index,u=l-1,c!==void 0?g=c:g=d,u<0&&(u=0),r=g.geometry,n=r.getCoordinates(),s=n,i=!1,r.getType()){case"MultiLineString":n[g.depth[0]].length>2&&(n[g.depth[0]].splice(l,1),i=!0);break;case"LineString":n.length>2&&(n.splice(l,1),i=!0);break;case"MultiPolygon":s=s[g.depth[1]];case"Polygon":s=s[g.depth[0]],s.length>4&&(l==s.length-1&&(l=0),s.splice(l,1),i=!0,l===0&&(s.pop(),s.push(s[0]),u=s.length-1));break;default:}if(i){this.setGeometryCoordinates_(r,n);let f=[];if(c!==void 0&&(this.rBush_.remove(c),f.push(c.segment[0])),d!==void 0&&(this.rBush_.remove(d),f.push(d.segment[1])),c!==void 0&&d!==void 0){let p={depth:g.depth,feature:g.feature,geometry:g.geometry,index:u,segment:f};this.rBush_.insert(T(p.segment),p)}this.updateSegmentIndices_(r,l,g.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.length=0}}return i}setGeometryCoordinates_(e,t){this.changingFeature_=!0,e.setCoordinates(t),this.changingFeature_=!1}updateSegmentIndices_(e,t,i,s){this.rBush_.forEachInExtent(e.getExtent(),function(n){n.geometry===e&&(i===void 0||n.depth===void 0||st(n.depth,i))&&n.index>t&&(n.index+=s)})}};function ti(h,e){return h.index-e.index}function jt(h,e,t){let i=e.geometry;if(i.getType()==="Circle"){let n=i;if(e.index===ie){let o=L();o&&(n=n.clone().transform(o,t));let r=S(n.getCenter(),_(h,t)),a=Math.sqrt(r)-n.getRadius();return a*a}}let s=_(h,t);return H[0]=_(e.segment[0],t),H[1]=_(e.segment[1],t),dt(s,H)}function Ut(h,e,t){let i=e.geometry;if(i.getType()==="Circle"&&e.index===ie){let n=i,o=L();return o&&(n=n.clone().transform(o,t)),j(n.getClosestPoint(_(h,t)),t)}let s=_(h,t);return H[0]=_(e.segment[0],t),H[1]=_(e.segment[1],t),j(ue(s,H),t)}function ii(){let h=me();return function(e,t){return h.Point}}var Bt=Fe;var qt={SNAP:"snap"},xe=class extends b{constructor(e,t){super(e),this.vertex=t.vertex,this.vertexPixel=t.vertexPixel,this.feature=t.feature,this.segment=t.segment}};function zt(h){return h.feature?h.feature:h.element?h.element:null}var De=[],Ae=class extends B{constructor(e){e=e||{};let t=e;t.handleDownEvent||(t.handleDownEvent=ae),t.stopDown||(t.stopDown=le),super(t),this.on,this.once,this.un,this.source_=e.source?e.source:null,this.vertex_=e.vertex!==void 0?e.vertex:!0,this.edge_=e.edge!==void 0?e.edge:!0,this.features_=e.features?e.features:null,this.featuresListenerKeys_=[],this.featureChangeListenerKeys_={},this.indexedFeaturesExtents_={},this.pendingFeatures_={},this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.rBush_=new fe,this.GEOMETRY_SEGMENTERS_={Point:this.segmentPointGeometry_.bind(this),LineString:this.segmentLineStringGeometry_.bind(this),LinearRing:this.segmentLineStringGeometry_.bind(this),Polygon:this.segmentPolygonGeometry_.bind(this),MultiPoint:this.segmentMultiPointGeometry_.bind(this),MultiLineString:this.segmentMultiLineStringGeometry_.bind(this),MultiPolygon:this.segmentMultiPolygonGeometry_.bind(this),GeometryCollection:this.segmentGeometryCollectionGeometry_.bind(this),Circle:this.segmentCircleGeometry_.bind(this)}}addFeature(e,t){t=t!==void 0?t:!0;let i=w(e),s=e.getGeometry();if(s){let n=this.GEOMETRY_SEGMENTERS_[s.getType()];if(n){this.indexedFeaturesExtents_[i]=s.getExtent(at());let o=[];if(n(o,s),o.length===1)this.rBush_.insert(T(o[0]),{feature:e,segment:o[0]});else if(o.length>1){let r=o.map(l=>T(l)),a=o.map(l=>({feature:e,segment:l}));this.rBush_.load(r,a)}}}t&&(this.featureChangeListenerKeys_[i]=G(e,M.CHANGE,this.handleFeatureChange_,this))}getFeatures_(){let e;return this.features_?e=this.features_:this.source_&&(e=this.source_.getFeatures()),e}handleEvent(e){let t=this.snapTo(e.pixel,e.coordinate,e.map);return t&&(e.coordinate=t.vertex.slice(0,2),e.pixel=t.vertexPixel,this.dispatchEvent(new xe(qt.SNAP,{vertex:e.coordinate,vertexPixel:e.pixel,feature:t.feature,segment:t.segment}))),super.handleEvent(e)}handleFeatureAdd_(e){let t=zt(e);t&&this.addFeature(t)}handleFeatureRemove_(e){let t=zt(e);t&&this.removeFeature(t)}handleFeatureChange_(e){let t=e.target;if(this.handlingDownUpSequence){let i=w(t);i in this.pendingFeatures_||(this.pendingFeatures_[i]=t)}else this.updateFeature_(t)}handleUpEvent(e){let t=Object.values(this.pendingFeatures_);return t.length&&(t.forEach(this.updateFeature_.bind(this)),this.pendingFeatures_={}),!1}removeFeature(e,t){let i=t!==void 0?t:!0,s=w(e),n=this.indexedFeaturesExtents_[s];if(n){let o=this.rBush_,r=[];o.forEachInExtent(n,function(a){e===a.feature&&r.push(a)});for(let a=r.length-1;a>=0;--a)o.remove(r[a])}i&&(N(this.featureChangeListenerKeys_[s]),delete this.featureChangeListenerKeys_[s])}setMap(e){let t=this.getMap(),i=this.featuresListenerKeys_,s=this.getFeatures_();t&&(i.forEach(N),i.length=0,this.rBush_.clear(),Object.values(this.featureChangeListenerKeys_).forEach(N),this.featureChangeListenerKeys_={}),super.setMap(e),e&&(this.features_?i.push(G(this.features_,R.ADD,this.handleFeatureAdd_,this),G(this.features_,R.REMOVE,this.handleFeatureRemove_,this)):this.source_&&i.push(G(this.source_,z.ADDFEATURE,this.handleFeatureAdd_,this),G(this.source_,z.REMOVEFEATURE,this.handleFeatureRemove_,this)),s.forEach(n=>this.addFeature(n)))}snapTo(e,t,i){let s=i.getView().getProjection(),n=_(t,s),o=ge(ce(T([n]),i.getView().getResolution()*this.pixelTolerance_),s),r=this.rBush_.getInExtent(o),a=r.length;if(a===0)return null;let l,c=1/0,u,d=null,g=this.pixelTolerance_*this.pixelTolerance_,m=()=>{if(l){let f=i.getPixelFromCoordinate(l);if(S(e,f)<=g)return{vertex:l,vertexPixel:[Math.round(f[0]),Math.round(f[1])],feature:u,segment:d}}return null};if(this.vertex_){for(let p=0;p<a;++p){let y=r[p];y.feature.getGeometry().getType()!=="Circle"&&y.segment.forEach(x=>{let C=_(x,s),P=S(n,C);P<c&&(l=x,c=P,u=y.feature)})}let f=m();if(f)return f}if(this.edge_){for(let p=0;p<a;++p){let y=null,x=r[p];if(x.feature.getGeometry().getType()==="Circle"){let C=x.feature.getGeometry(),P=L();P&&(C=C.clone().transform(P,s)),y=ht(n,C)}else{let[C,P]=x.segment;P&&(De[0]=_(C,s),De[1]=_(P,s),y=ue(n,De))}if(y){let C=S(n,y);C<c&&(l=j(y,s),d=x.feature.getGeometry().getType()==="Circle"?null:x.segment,c=C)}}let f=m();if(f)return f}return null}updateFeature_(e){this.removeFeature(e,!1),this.addFeature(e,!1)}segmentCircleGeometry_(e,t){let i=this.getMap().getView().getProjection(),s=t,n=L();n&&(s=s.clone().transform(n,i));let o=U(s);n&&o.transform(i,n);let r=o.getCoordinates()[0];for(let a=0,l=r.length-1;a<l;++a)e.push(r.slice(a,a+2))}segmentGeometryCollectionGeometry_(e,t){let i=t.getGeometriesArray();for(let s=0;s<i.length;++s){let n=this.GEOMETRY_SEGMENTERS_[i[s].getType()];n&&n(e,i[s])}}segmentLineStringGeometry_(e,t){let i=t.getCoordinates();for(let s=0,n=i.length-1;s<n;++s)e.push(i.slice(s,s+2))}segmentMultiLineStringGeometry_(e,t){let i=t.getCoordinates();for(let s=0,n=i.length;s<n;++s){let o=i[s];for(let r=0,a=o.length-1;r<a;++r)e.push(o.slice(r,r+2))}}segmentMultiPointGeometry_(e,t){t.getCoordinates().forEach(i=>{e.push([i])})}segmentMultiPolygonGeometry_(e,t){let i=t.getCoordinates();for(let s=0,n=i.length;s<n;++s){let o=i[s];for(let r=0,a=o.length;r<a;++r){let l=o[r];for(let c=0,u=l.length-1;c<u;++c)e.push(l.slice(c,c+2))}}}segmentPointGeometry_(e,t){e.push([t.getCoordinates()])}segmentPolygonGeometry_(e,t){let i=t.getCoordinates();for(let s=0,n=i.length;s<n;++s){let o=i[s];for(let r=0,a=o.length-1;r<a;++r)e.push(o.slice(r,r+2))}}},Yt=Ae;var si=function(h,e,t,i){var s=arguments.length,n=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(h,e,t,i);else for(var r=h.length-1;r>=0;r--)(o=h[r])&&(n=(s<3?o(n):s>3?o(e,t,n):o(e,t))||n);return s>3&&n&&Object.defineProperty(e,t,n),n},Te=class extends We{languageService;interactionService;formBuilder;type;geoLocation;visible=!1;visibleMap=!1;availableGeoLocationApi=!1;initialZoom=18;isEdit=!1;drawed=!1;mapId;geoLocationName=null;map;marker;circleGeom;form;googleMapsUrl;selectionType;mainVectorSource;interactionVectorSource;interactionDraw;interactionModify;polygonCoordinates;constructor(e,t,i){super(),this.languageService=e,this.interactionService=t,this.formBuilder=i,this.mapId="map-open-layer-map-"+Ye()}onModalInitialized(){switch(super.onModalInitialized(),this.type){case O.Circle:this.selectionType="Circle";break;case O.Polygon:this.selectionType="Polygon";break}Be(this.geoLocation)?(this.initialZoom=12,this.isEdit=!1):(this.geoLocationName=this.geoLocation.name||null,this.isEdit=!0),navigator&&navigator.geolocation&&(this.availableGeoLocationApi=!0),this.visible=!0,this.createForm()}onModalViewInitialized(){super.onModalViewInitialized(),setTimeout(()=>{this.createMap()},300)}createForm(){switch(this.selectionType){case"Circle":this.geoLocation&&this.setGooogleMapUrl(this.geoLocation.longitude,this.geoLocation.latitude),this.form=this.formBuilder.group({longitude:[this.geoLocation?this.geoLocation.longitude:null,[A.required(),A.longitude()]],latitude:[this.geoLocation?this.geoLocation.latitude:null,[A.required(),A.latitude()]],radius:[this.geoLocation?this.geoLocation.radius:null,[A.required()]]}),this.form.valueChanges.subscribe(e=>{if(this.form.valid)if(this.mainVectorSource&&this.mainVectorSource.getFeatures()&&this.mainVectorSource.getFeatures()[0])this.positionCircleFeature(e.longitude,e.latitude,e.radius);else{var t=Z([this.form.get("longitude").value,this.form.get("latitude").value]);this.circleGeom=new ee(t,this.form.get("radius").value),this.mainVectorSource.addFeature(new E(this.circleGeom)),this.interactionVectorSource.addFeature(new E(this.circleGeom)),this.setFeatureData(),this.drawed=!0,this.interactionDraw.setActive(!this.drawed),this.interactionModify.setActive(this.drawed)}});break;case"Polygon":break}}createMap(){var e=[],t=[32.853847589157375,39.92079225552399];if(this.isEdit)switch(this.selectionType){case"Circle":if(this.form.valid){t=[this.form.get("longitude").value,this.form.get("latitude").value];var i=Z([this.form.get("longitude").value,this.form.get("latitude").value]);this.circleGeom=new ee(i,this.form.get("radius").value),e=[new E(this.circleGeom)],this.drawed=!0}else this.setLocationToPosition();break;case"Polygon":if(this.geoLocation.points){let o=[];this.geoLocation.points.forEach(a=>{let l=[a.longitude,a.latitude];o.push(k(l,"EPSG:4326","EPSG:3857"))}),e=[new E(new Q([o]))];let r=e[0].getGeometry().getExtent();t=k(de(r),"EPSG:3857","EPSG:4326"),this.drawed=!0}else this.setLocationToPosition();break}this.map=new Lt({target:this.mapId,layers:[new Ot({source:new St})],view:new mt({center:Z(t),zoom:this.initialZoom})}),this.mainVectorSource=new D({features:e});var s=new q({source:this.mainVectorSource,style:[new _t({stroke:new pt({color:"rgba(0, 0, 255)",width:1}),fill:new ft({color:"rgba(0, 0, 255, 0.2)"})})]});this.map.addLayer(s),this.interactionVectorSource=new D({features:this.mainVectorSource.getFeatures()}),this.interactionDraw=new Nt({source:this.interactionVectorSource,type:this.selectionType}),this.interactionDraw.setActive(!this.drawed),this.map.addInteraction(this.interactionDraw),this.interactionDraw.on("drawstart",o=>{this.interactionVectorSource.clear()}),this.interactionDraw.on("drawend",o=>{this.mainVectorSource.addFeature(o.feature),this.setFeatureData(),this.interactionDraw.setActive(!1),this.interactionModify.setActive(!0)}),this.interactionModify=new Bt({source:this.interactionVectorSource}),this.interactionModify.setActive(this.drawed),this.map.addInteraction(this.interactionModify),this.interactionModify.on("modifystart",o=>{}),this.interactionModify.on("modifyend",o=>{this.setFeatureData()});var n=new Yt({source:s.getSource()});this.map.addInteraction(n),setTimeout(()=>{this.map.updateSize(),setTimeout(()=>{if(this.visibleMap=!0,!this.isEdit)this.setLocationToPosition();else switch(this.selectionType){case"Circle":this.form&&this.form.valid&&this.setFeatureData();break;case"Polygon":this.setFeatureData();break}},300)},200)}setFeatureData(){let e=this.mainVectorSource.getFeatures()[0];switch(e&&(this.drawed=!0),this.selectionType){case"Circle":let t=k(e.getGeometry().getCenter(),"EPSG:3857","EPSG:4326");this.positionCircleFeature(t[0],t[1],e.getGeometry().getRadius());break;case"Polygon":let i=[];e.getGeometry().getCoordinates()[0].forEach(s=>{i.push(k(s,"EPSG:3857","EPSG:4326"))}),this.polygonCoordinates=i;break}}positionCircleFeature(e,t,i,s=!1){this.mainVectorSource&&this.mainVectorSource.getFeatures()&&this.mainVectorSource.getFeatures()[0]&&this.mainVectorSource.getFeatures()[0].getGeometry().setCenterAndRadius(Z([e,t]),+i),this.form.get("longitude").setValue(e,{emitEvent:!1}),this.form.get("latitude").setValue(t,{emitEvent:!1}),this.form.get("radius").setValue(i,{emitEvent:!1}),s&&this.setCenterToPosition(e,t),this.setGooogleMapUrl(e,t)}setCenterToPosition(e,t){this.map.getView().setCenter(k([e,t],"EPSG:4326","EPSG:3857"))}setGooogleMapUrl(e,t){this.googleMapsUrl=tt.getGoogleMapsUrl(t,e)}setLocationToPosition(){this.availableGeoLocationApi&&navigator.geolocation.getCurrentPosition(e=>{this.map.getView().setCenter(k([e.coords.longitude,e.coords.latitude],"EPSG:4326","EPSG:3857")),this.map.getView().setZoom(16)},e=>{this.interactionService.showMessage("MAP.GEOLOCATION_SELECT_LOCATION_ERROR",null,qe.Error)})}resetSelection(){switch(this.mainVectorSource.clear(),this.interactionVectorSource.clear(),this.interactionModify.setActive(!1),this.interactionDraw.setActive(!0),this.drawed=!1,this.selectionType){case"Circle":this.form.reset();break;case"Polygon":break}}onSaveClicked(e){switch(this.selectionType){case"Circle":if(this.form.valid){let i={type:O.Circle};Object.assign(i,this.form.value),i.name=this.geoLocationName||"",this.closeModal(i)}break;case"Polygon":let t={type:O.Polygon,points:[]};this.polygonCoordinates.forEach(i=>{t.points.push({longitude:i[0],latitude:i[1]})}),t.name=this.geoLocationName||"",this.closeModal(t);break}}onCenterSelectedClicked(e){switch(this.selectionType){case"Circle":this.form.valid&&this.setCenterToPosition(this.form.value.longitude,this.form.value.latitude);case"Polygon":break}}onCenterLocationClicked(e){this.setLocationToPosition()}onResetClicked(e){this.resetSelection()}static ctorParameters=()=>[{type:Qe},{type:Je},{type:Xe}];static propDecorators={type:[{type:$}],geoLocation:[{type:$}]}};Te=si([ne({selector:"armon-geolocation-modal",template:kt,standalone:!0,imports:[je,$e,et,Ze,oe,Ue,it,re],styles:[Ft]})],Te);var ni=function(h,e,t,i){var s=arguments.length,n=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(h,e,t,i);else for(var r=h.length-1;r>=0;r--)(o=h[r])&&(n=(s<3?o(n):s>3?o(e,t,n):o(e,t))||n);return s>3&&n&&Object.defineProperty(e,t,n),n},oi={provide:He,useExisting:Re(()=>be),multi:!0},be=class{modalService;translateService;invalid;onChange;geoLocation;geoLocationText;typeSelectionTemplate;constructor(e,t){this.modalService=e,this.translateService=t}ngOnInit(){}ngAfterViewInit(){}ngOnDestroy(){}updateValue(){this.translateService.get(["MAP.GEOLOCATION_LONGITUDE","MAP.GEOLOCATION_LATITUDE","MAP.GEOLOCATION_RADIUS_UNIT","MAP.GEOLOCATION_SELECT","MAP.GEOLOCATION_POLYGON_COUNT"]).subscribe(e=>{if(this.geoLocation)if(this.geoLocation.name&&this.geoLocation.name.trim()!="")this.geoLocationText=this.geoLocation.name;else switch(this.geoLocation.type){case O.Circle:this.geoLocationText=e["MAP.GEOLOCATION_LATITUDE"]+": "+this.geoLocation.latitude+", "+e["MAP.GEOLOCATION_LONGITUDE"]+": "+this.geoLocation.longitude+" ("+this.geoLocation.radius+" "+e["MAP.GEOLOCATION_RADIUS_UNIT"]+")";break;case O.Polygon:this.geoLocationText=this.geoLocation.points.length-1+" "+e["MAP.GEOLOCATION_POLYGON_COUNT"];break}else this.geoLocationText=e["MAP.GEOLOCATION_SELECT"]}),this.onChange&&this.onChange(this.geoLocation?this.geoLocation:null)}writeValue(e){e?this.geoLocation=e:this.geoLocation=null,this.updateValue()}registerOnChange(e){this.onChange=e,this.updateValue()}registerOnTouched(e){}setDisabledState(e){}onClicked(e){this.geoLocation?this.showEditModal():this.showTypeSelectionModal()}showEditModal(e=null){this.modalService.open(Te,{settings:{size:"xl",centered:!0,scrollable:!0},props:{type:e||(this.geoLocation.type?this.geoLocation.type:O.Circle),geoLocation:this.geoLocation?this.geoLocation:null}}).result.then(t=>{this.geoLocation=t,this.updateValue()}).catch(t=>{})}showTypeSelectionModal(){this.modalService.openTemplate(this.typeSelectionTemplate,{settings:{size:"md",centered:!0}}).result.then(e=>{this.showEditModal(e)}).catch(e=>{})}static ctorParameters=()=>[{type:Ke},{type:ze}];static propDecorators={invalid:[{type:$}],typeSelectionTemplate:[{type:Ve,args:["typeSelectionTemplate"]}]}};be=ni([ne({selector:"armon-geolocation-control",providers:[oi],template:Gt,standalone:!0,imports:[oe,re],styles:[It]})],be);export{be as a};
