/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import{EventEmitter as i}from"../../core/Evented.js";import{watch as r,sync as o}from"../../core/reactiveUtils.js";import{createScreenPoint as s}from"../../core/screenUtils.js";import{property as a,subclass as n}from"../../core/accessorSupport/decorators.js";let l=class extends e{constructor(t){super(t),this._visualSymbol=Symbol("manipulator-visual"),this.renderer=null,this.managedHandle=null,this.consumesClicks=!1,this.events=new i,this.interactive=!0,this.selectable=!1,this.grabbing=!1,this.dragging=!1,this.grabCursor="grabbing",this.hovering=!1,this.selected=!1,this.cursor="crosshair"}initialize(){super.initialize(),this.addHandles([r(()=>[this.managedHandle?.role,this._visualState,this.managedHandle?.outputMapPosition],()=>{this._updateVisual()},o)])}destroy(){this.renderer?.removeVisual(this._visualSymbol)}get _visualState(){return this.grabbing||this.following?"active":this.selected||this.hovering?"focused":"idle"}get grabbable(){return!!this.managedHandle?.grabbable}get following(){return!!this.managedHandle?.following}get test(){return{visualState:this._visualState}}grabbableForEvent(t){if("x"in t&&"y"in t&&this.grabbable){const e=s(t.x,t.y);return null!==this.intersectionDistance(e)}return!1}intersectionDistance(t){return this.following?0:this.renderer?.hitTestVisualDistance(t,this._visualSymbol)}attach(){this._updateVisual()}detach(){this.renderer?.removeVisual(this._visualSymbol)}onElevationChange(){}onViewChange(){}_updateVisual(){const t=this.managedHandle;this.renderer?.addOrUpdateVisual(this._visualSymbol,{role:"secondary"===t?.role?"controlPoint":"cursor",geometry:t?.outputMapPosition,state:this._visualState})}};t([a()],l.prototype,"_visualState",null),t([a({constructOnly:!0})],l.prototype,"renderer",void 0),t([a()],l.prototype,"managedHandle",void 0),t([a()],l.prototype,"consumesClicks",void 0),t([a()],l.prototype,"events",void 0),t([a()],l.prototype,"interactive",void 0),t([a()],l.prototype,"selectable",void 0),t([a()],l.prototype,"grabbable",null),t([a()],l.prototype,"grabbing",void 0),t([a()],l.prototype,"dragging",void 0),t([a()],l.prototype,"following",null),t([a()],l.prototype,"grabCursor",void 0),t([a()],l.prototype,"hovering",void 0),t([a()],l.prototype,"selected",void 0),t([a()],l.prototype,"cursor",void 0),l=t([n("esri.views.draw.DrawManipulator")],l);export{l as DrawManipulator};
