/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/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 l}from"../../core/accessorSupport/decorators.js";import{getPointerType as n}from"./support/drawToolUtils.js";let d=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),i=n(t);return null!==this.intersectionDistance(e,i)}return!1}intersectionDistance(t,e){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()],d.prototype,"_visualState",null),t([a({constructOnly:!0})],d.prototype,"renderer",void 0),t([a()],d.prototype,"managedHandle",void 0),t([a()],d.prototype,"consumesClicks",void 0),t([a()],d.prototype,"events",void 0),t([a()],d.prototype,"interactive",void 0),t([a()],d.prototype,"selectable",void 0),t([a()],d.prototype,"grabbable",null),t([a()],d.prototype,"grabbing",void 0),t([a()],d.prototype,"dragging",void 0),t([a()],d.prototype,"following",null),t([a()],d.prototype,"grabCursor",void 0),t([a()],d.prototype,"hovering",void 0),t([a()],d.prototype,"selected",void 0),t([a()],d.prototype,"cursor",void 0),d=t([l("esri.views.draw.DrawManipulator")],d);export{d as DrawManipulator};
