/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../../chunks/_rollupPluginBabelHelpers","../../../../../chunks/tslib.es6","../../../../../geometry","../../../../../Graphic","../../../../../core/handleUtils","../../../../../core/maybe","../../../../../core/accessorSupport/decorators/property","../../../../../core/arrayUtils","../../../../../core/has","../../../../../core/accessorSupport/ensureType","../../../../../core/accessorSupport/decorators/subclass","../../SnappingVisualizer2D","./symbols","../../../../draw/DrawGraphicTool","../../../../draw/DrawOperation","../../../../draw/drawSurfaces","../../../../../geometry/Point","../../../../../geometry/Multipoint"],(function(e,i,r,t,a,s,l,n,o,c,u,p,h,m,y,v,d,g,G){"use strict";function _(e,i){var r,t,a,s;return(null!=(r=null==(t=e.attributes)?void 0:t.displayOrder)?r:-1/0)-(null!=(a=null==(s=i.attributes)?void 0:s.displayOrder)?a:-1/0)}e.DrawGraphicTool2D=function(e){function r(i){var r;return(r=e.call(this,i)||this)._visualElementGraphics={outline:null,regularVertices:null,activeVertex:null},r.activeFillSymbol=null,r.type="draw-2d",r._visualElementSymbols={outline:l.unwrapOr(i.activeLineSymbol,m.outline),regularVertices:l.unwrapOr(i.regularVerticesSymbol,m.regularVertices),activeVertex:l.unwrapOr(i.activeVertexSymbol,m.activeVertex),fill:l.unwrap(i.activeFillSymbol)},r}i._inheritsLoose(r,e);var t=r.prototype;return t.normalizeCtorArgs=function(e){const i={...e};return delete i.activeFillSymbol,delete i.activeVertexSymbol,delete i.regularVerticesSymbol,delete i.activeLineSymbol,i},t.initializeGraphic=function(e){return l.isSome(this._visualElementSymbols.fill)&&(e.symbol=this._visualElementSymbols.fill),null},t.makeDrawOperation=function(){const e=this.view;return new v.DrawOperation({view:e,manipulators:this.manipulators,geometryType:y.geometryTypeToDrawOperationGeometryType(this.geometryType),drawingMode:this.mode,hasZ:this.hasZ,defaultZ:this.defaultZ,snapToSceneEnabled:this.snapToScene,drawSurface:new d.MapDrawSurface(e),hasM:!1,snappingManager:this.snappingManager,snappingVisualizer:new h.SnappingVisualizer2D(this.internalGraphicsLayer)})},t.onActiveVertexChanged=function(e){if("point"===this.geometryType)return null;const[i,r]=e,t=new g({x:i,y:r,spatialReference:this.view.spatialReference});return l.isSome(this._visualElementGraphics.activeVertex)?(this._visualElementGraphics.activeVertex.geometry=t,null):(this._visualElementGraphics.activeVertex=new a({geometry:t,symbol:this._visualElementSymbols.activeVertex,attributes:{displayOrder:2}}),this.internalGraphicsLayer.add(this._visualElementGraphics.activeVertex),this.internalGraphicsLayer.graphics.sort(_),s.makeHandle((()=>{l.isSome(this._visualElementGraphics.activeVertex)&&(this.internalGraphicsLayer.remove(this._visualElementGraphics.activeVertex),this._visualElementGraphics.activeVertex=l.destroyMaybe(this._visualElementGraphics.activeVertex))})))},t.onOutlineChanged=function(e){const i=e.clone();if("polyline"===i.type){const e=i.paths[i.paths.length-1];e.splice(0,e.length-2)}return l.isSome(this._visualElementGraphics.outline)?(this._visualElementGraphics.outline.geometry=i,null):(this._visualElementGraphics.outline=new a({geometry:i,symbol:this._visualElementSymbols.outline,attributes:{displayOrder:0}}),this.internalGraphicsLayer.add(this._visualElementGraphics.outline),this.internalGraphicsLayer.graphics.sort(_),s.makeHandle((()=>{l.isSome(this._visualElementGraphics.outline)&&(this.internalGraphicsLayer.remove(this._visualElementGraphics.outline),this._visualElementGraphics.outline=l.destroyMaybe(this._visualElementGraphics.outline))})))},t.onRegularVerticesChanged=function(e){const i=new G({points:e,spatialReference:this.view.spatialReference});return l.isSome(this._visualElementGraphics.regularVertices)?(this._visualElementGraphics.regularVertices.geometry=i,null):(this._visualElementGraphics.regularVertices=new a({geometry:i,symbol:this._visualElementSymbols.regularVertices,attributes:{displayOrder:1}}),this.internalGraphicsLayer.add(this._visualElementGraphics.regularVertices),this.internalGraphicsLayer.graphics.sort(_),s.makeHandle((()=>{l.isSome(this._visualElementGraphics.regularVertices)&&(this.internalGraphicsLayer.remove(this._visualElementGraphics.regularVertices),this._visualElementGraphics.regularVertices=l.destroyMaybe(this._visualElementGraphics.regularVertices))})))},r}(y.DrawGraphicTool),r.__decorate([n.property()],e.DrawGraphicTool2D.prototype,"activeFillSymbol",void 0),r.__decorate([n.property({readOnly:!0})],e.DrawGraphicTool2D.prototype,"type",void 0),r.__decorate([n.property({constructOnly:!0,nonNullable:!0})],e.DrawGraphicTool2D.prototype,"view",void 0),e.DrawGraphicTool2D=r.__decorate([p.subclass("esri.views.2d.interactive.draw.DrawGraphicTool2D")],e.DrawGraphicTool2D),Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
