/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import"../../../core/has.js";import{EventedAccessor as t}from"../../../core/Evented.js";import{property as o,subclass as r}from"../../../core/accessorSupport/decorators.js";let s=class extends t{constructor(e){super(e),this.cancelled=!1,this.history={undo:[],redo:[]},this.type=null}get tool(){const{activeComponent:e}=this;if(!e)return null;switch(e.type){case"graphic-mover":case"move-3d":return"move";case"box":case"transform-3d":return"transform";case"reshape":case"reshape-3d":return"reshape";case"draw-2d":return"text"===e.graphicSymbol?.type?"text":e.geometryType;case"draw-3d":return e.geometryType}return null}addToHistory(e){this.history.redo=[],this.history.undo.push(e)}resetHistory(){this.history.redo=[],this.history.undo=[]}canUndo(){return this.history.undo.length>0}canRedo(){return this.history.redo.length>0}complete(){this._reset(),this.onEnd(),this.emit("complete")}cancel(){this.cancelled=!0,this.complete()}_reset(){this.activeComponent?.reset()}refreshComponent(){const e=this.activeComponent;e&&("box"!==e.type&&"reshape"!==e.type&&"graphic-mover"!==e.type||e.refresh())}set undo(e){this._set("undo",()=>{this.canUndo()&&e()})}set redo(e){this._set("redo",()=>{this.canRedo()&&e()})}};e([o()],s.prototype,"activeComponent",void 0),e([o()],s.prototype,"cancelled",void 0),e([o()],s.prototype,"history",void 0),e([o()],s.prototype,"tool",null),e([o()],s.prototype,"type",void 0),e([o()],s.prototype,"canUndo",null),e([o()],s.prototype,"canRedo",null),e([o()],s.prototype,"onEnd",void 0),e([o()],s.prototype,"undo",null),e([o()],s.prototype,"redo",null),e([o()],s.prototype,"toggleTool",void 0),e([o()],s.prototype,"addToSelection",void 0),e([o()],s.prototype,"removeFromSelection",void 0),s=e([r("esri.widgets.Sketch.support.OperationHandle")],s);let n=class extends s{};e([o()],n.prototype,"activeComponent",void 0),n=e([r("esri.widgets.Sketch.support.OperationHandle.CreateOperationHandle")],n);let p=class extends s{};e([o()],p.prototype,"activeComponent",void 0),p=e([r("esri.widgets.Sketch.support.OperationHandle.UpdateOperationHandle")],p);export{n as CreateOperationHandle,s as OperationHandle,p as UpdateOperationHandle};
