/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../../../core/Evented.js";import{destroyMaybe as i}from"../../../../core/maybe.js";import{syncAndInitial as r}from"../../../../core/reactiveUtils.js";import{property as o,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as a}from"../../../../core/support/UpdatingHandles.js";import{getGraphicEffectiveElevationInfo as n}from"../../../../support/elevationInfoUtils.js";import{getGraphicAttachmentOrigin as p}from"../manipulatorUtils.js";import{createGraphicGeometryUndoRecord as h}from"./undoRecords.js";import{GraphicState as c}from"../../layers/graphics/GraphicState.js";import{GraphicManipulator as d}from"../../../interactive/GraphicManipulator.js";import{EditGeometryOperations as m}from"../../../interactive/editGeometry/EditGeometryOperations.js";const g=Symbol();let l=class extends e{get operations(){return this._operations}get updating(){return this._updatingHandles.updating}get elevationInfo(){return n(this.graphic)}get visible(){return this._graphicState.displaying}get isDraped(){return this._graphicState.isDraped}get origin(){return p(this.view,this.graphic)}constructor(t){super(t),this._updatingHandles=new a}destroy(){this._operations=i(this._operations),this._updatingHandles.destroy()}initialize(){this._graphicState=new c({graphic:this.graphic}),this._graphicState.on("changed",()=>this.emit("committed")),this.addHandles(this.view.trackGraphicState(this._graphicState)),this.addHandles(this._updatingHandles.add(()=>this.graphic.geometry,t=>{const e=this._operations?.data.geometry;if(t!==e){if(!t||"multipoint"===t?.type||"extent"===t?.type)return i(this._operations),this.removeHandles(g),void(this._operations=null);if(this._operations?.trySetGeometry(t))this.emit("modified-externally");else{i(this._operations),this.removeHandles(g);const e=m.fromGeometry(t,this.view.state.viewingMode);this._operations=e,this.addHandles(e.data.on("change",()=>this.graphic.geometry=e.data.geometry),g)}}},r))}createManipulator(t){return new d({view:this.view,graphic:this.graphic,...t})}maskOccludee(){return this.view.maskOccludee(this.graphic)}endInteraction(){const t=this.graphic.geometry;"mesh"===t?.type&&this.graphic.notifyMeshTransformChanged()}toMap(t){return this.view.toMap(t,{include:[this.graphic]})}createUndoRecord(){const{graphic:{geometry:t}}=this;return h(t)}};t([o({constructOnly:!0})],l.prototype,"view",void 0),t([o({constructOnly:!0})],l.prototype,"graphic",void 0),t([o()],l.prototype,"_operations",void 0),t([o()],l.prototype,"operations",null),t([o()],l.prototype,"updating",null),l=t([s("esri.views.3d.interactive.editingTools.ManipulatedObject3DGraphic")],l);export{l as ManipulatedObject3DGraphic};
