Custom Gis Application with Arcgis Javascript API with modern layouting
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

97 lines
48 KiB

// All material copyright Esri, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.30/esri/copyright.txt for details.
//>>built
define("require ../../chunks/tslib.es6 ../../symbols ../../core/Collection ../../core/Error ../../core/Evented ../../core/has ../../core/Logger ../../core/maybe ../../core/promiseUtils ../../core/reactiveUtils ../../core/accessorSupport/decorators/property ../../core/RandomLCG ../../core/accessorSupport/decorators/subclass ../../geometry/ellipsoidUtils ../../geometry/projection ../../geometry/support/coordsUtils ../../geometry/support/spatialReferenceUtils ../../layers/GraphicsLayer ../../layers/support/layerUtils ../../views/3d/interactive/editingTools/isSupportedObjectUtils ../../views/3d/interactive/editingTools/move/isSupportedObject ../../views/3d/interactive/editingTools/reshape/isSupportedObject ../../views/3d/interactive/editingTools/transform/isSupportedGraphic ../../views/draw/support/layerUtils ../../views/input/InputManager ../../views/interactive/keybindings ../../views/interactive/sketch/SketchLabelOptions ../../views/interactive/sketch/SketchOptions ../../views/interactive/sketch/SketchTooltipOptions ../../views/interactive/sketch/SketchValueOptions ../../views/interactive/snapping/SnappingManager ../../views/interactive/snapping/SnappingOptions ../../views/interactive/snapping/snappingUtils ../../views/support/hitTestSelectUtils ../../views/support/screenUtils ./support/OperationHandle ../../symbols/SimpleMarkerSymbol ../../symbols/SimpleFillSymbol ../../symbols/SimpleLineSymbol ../../symbols/MeshSymbol3D ../../symbols/FillSymbol3DLayer".split(" "),
function(A,u,I,O,Z,r,ua,aa,D,N,B,v,va,ba,ca,J,P,da,ea,fa,F,ha,ia,ja,Q,z,w,ka,R,la,ma,S,T,na,oa,U,E,V,pa,qa,ra,sa){function ta(a){return"polygon"===a||"rectangle"===a||"circle"===a}function K(a,b){W("undo",a.history.undo,a.history.redo,b)}function L(a,b){W("redo",a.history.redo,a.history.undo,b)}function W(a,b,d,c){if(b=b.pop()){var f=b.updates,k=[];c.forEach((h,e)=>{e=f[e];null!=e&&("geometry"in e&&null!=e.geometry&&(k.push({geometry:h.geometry}),h.geometry=e.geometry),"symbol"in e&&null!=e.symbol&&
(k.push({symbol:h.symbol}),h.symbol=e.symbol),"undo"in e&&(k.push(e),e[a](h)))});d.push({updates:k})}}function C(a){return{updates:a.map(({geometry:b})=>"mesh"===b?.type?{geometry:b.cloneShallow()}:{geometry:b})}}function y(a){return"requireError"in a&&"aborted"===a.requireError}const M=a=>Object.freeze(Object.defineProperty({__proto__:null,default:a},Symbol.toStringTag,{value:"Module"})),X={defaultZ:0},G={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move"},enableMoveAllGraphics:!0,
enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0},tool:"transform"};r=class extends r.EventedAccessor{constructor(a){super(a);this._numUpdating=0;this._defaultSnappingManager=null;this._internalGraphicsLayer=new ea({listMode:"hide",internal:!0,title:"SVM Internal"});this._operationHandle=null;this._viewHandlesKey="viewHandles";this.activeVertexSymbol=this.activeLineSymbol=this.activeFillSymbol=null;this.allowDeleteKey=
!0;this.layer=null;this.pointSymbol=new V({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}});this.polygonSymbol=new pa({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}});this.polylineSymbol=new qa({color:[130,130,130,1],width:2});this.meshSymbol=new ra({symbolLayers:new O([new sa])});this.updateGraphics=new O;this.updateOnGraphicClick=!0;this.vertexSymbol=new V({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}});this.sketchOptions=
new R;this._originalPopupEnabled=this._viewReadyAbortController=this._moduleLoaderAbortController=null;this.defaultCreateOptions=X;this.defaultUpdateOptions=G;this.snappingOptions=a?.snappingManager?.options??a?.snappingOptions??new T}initialize(){this.addHandles([B.on(()=>this.view?.map?.layers,"change",a=>{a.removed.includes(this.layer)&&this.cancel()}),B.on(()=>this.layer?.graphics,"change",a=>{if(null!=this._operationHandle)for(const b of a.removed)this.updateGraphics.includes(b)&&(1<this.updateGraphics.length?
this._operationHandle.removeFromSelection(b):this._operationHandle.cancel())}),B.watch(()=>this.layer?.elevationInfo??null,a=>{a!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer.elevationInfo=a)},B.syncAndInitial),B.watch(()=>this.view,a=>{this._defaultSnappingManager=D.destroyMaybe(this._defaultSnappingManager);a&&(this.snappingManager||(this._defaultSnappingManager=new S.SnappingManager({view:a,options:this.snappingOptions})),"2d"===a.type?new Promise((b,d)=>
A(["../../views/2d/interactive/editingTools"],b,d)):"3d"===a.type&&(new Promise((b,d)=>A(["../../views/3d/interactive/editingTools"],b,d)),new Promise((b,d)=>A(["../../views/3d/layers/GraphicsLayerView3D"],c=>b(M(c)),d))))},B.syncAndInitial),B.watch(()=>this.view?.spatialReference,(a,b)=>{a&&b&&!a.equals(b)&&this.cancel()})]);na.setupSnappingToggleHandles(this)}destroy(){this.cancel();this._removeDefaultLayer();this._defaultSnappingManager=D.destroyMaybe(this._defaultSnappingManager);this._set("snappingManager",
null);this._set("view",null);this.emit("destroy")}get updating(){return 0<this._numUpdating||null!=this.snappingManager&&this.snappingManager.updating}get activeTool(){return this._operationHandle?.tool??null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return null==this.activeComponent||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):this.activeComponent.graphic}get defaultCreateOptions(){return this._get("defaultCreateOptions")}set defaultCreateOptions(a){this._set("defaultCreateOptions",
{...X,...a})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(a){this._set("defaultUpdateOptions",{...G,...a,reshapeOptions:{...G.reshapeOptions,...a?.reshapeOptions},highlightOptions:{...G.highlightOptions,...a?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(a){this.sketchOptions.labels=a}get snappingOptions(){return this.snappingManager?.options??this._get("snappingOptions")}set snappingOptions(a){null!=this._defaultSnappingManager&&
(this._defaultSnappingManager.options=a);this._set("snappingOptions",a)}get snappingManager(){this._isOverridden("snappingManager")&&this._get("snappingManager");return this._defaultSnappingManager}set snappingManager(a){a?(this._isOverridden("snappingManager")||(this._defaultSnappingManager=D.destroyMaybe(this._defaultSnappingManager)),this._override("snappingManager",a)):({view:a}=this,!this._defaultSnappingManager&&a&&(this._defaultSnappingManager=new S.SnappingManager({options:this.snappingOptions,
view:a})),this._clearOverride("snappingManager"))}get state(){const a=!(!this.view?.ready||!this.layer),b=this._operationHandle;return a&&b?"active":a?"ready":"disabled"}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(a){this.sketchOptions.tooltips=a}get valueOptions(){return this.sketchOptions.values}set valueOptions(a){this.sketchOptions.values=a}get view(){return this._get("view")}set view(a){const b=this._get("view");if(b){const {container:d,map:c}=b;d&&(b.cursor=null);
c?.remove(this._internalGraphicsLayer);this.removeHandles(this._viewHandlesKey);this.cancel()}this.removeHandles("view-ready");a&&this.addHandles(B.when(()=>a.ready,d=>{this.removeHandles(this._viewHandlesKey);d&&this.addHandles(this._generateViewHandles(a),this._viewHandlesKey)},B.syncAndInitial),"view-ready");this._set("view",a)}cancel(){this._moduleLoaderAbortController=D.abortMaybe(this._moduleLoaderAbortController);this._viewReadyAbortController=D.abortMaybe(this._viewReadyAbortController);this._operationHandle&&
this._operationHandle.cancel()}complete(){this._operationHandle&&this._operationHandle.complete()}delete(){const {state:a,updateGraphics:b}=this;if("active"===a&&b.length){const {activeTool:d,layer:c}=this,f=b.toArray();c.removeMany(f);this.cancel();this._emitDeleteEvent({graphics:f,tool:d})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const a=this.updateGraphics.map(b=>b.clone()).toArray();this.layer.addMany(a);this.emit("duplicate",{graphics:a,type:"duplicate"});return a}return[]}async create(a,
b){this.cancel();await this._waitViewReady();const {view:d,layer:c}=this;if(!d||"disabled"===this.state)throw c||this._logMissingLayer(),N.createAbortError();null!=d.activeTool&&(d.activeTool=null);if(a){Q.addUniqueLayer(d,this._internalGraphicsLayer);var f=await this._setupCreateOperation(a,b);null==f||this.destroyed?d.map.remove(this._internalGraphicsLayer):(f.on("complete",()=>{if(f===this._operationHandle){const k=this.createGraphic,h=this._operationHandle.cancelled;this._operationHandle.destroy();
this._operationHandle=null;this._set("createGraphic",null);this.view?.map&&this.view.map.remove(this._internalGraphicsLayer);f.cancelled||null==k||c.add(k);this.emit("create",{graphic:k,state:h?"cancel":"complete",tool:a,toolEventInfo:null,type:"create"})}}),this._operationHandle=f,d.ready&&d.focus())}else this._logError("sketch:missing-parameter","Missing parameter 'tool'.")}async place(a,b){return this.create("mesh",{mode:"click",hasZ:a.hasZ,geometryToPlace:a,...b})}async update(a,b){this.cancel();
await this._waitViewReady();const {layer:d,view:c,state:f}=this;if(!c||"disabled"===f)throw d||this._logMissingLayer(),N.createAbortError();null!=c.activeTool&&(c.activeTool=null);const k=Array.isArray(a)?a:[a];null!=a&&k?.length?k.some(h=>h.layer!==d?(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0):null==h.geometry?(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),
!0):!1)||(a=await this._setupUpdateOperation(k,b),this.destroyed||null==a||y(a)||(Q.addUniqueLayer(c,this._internalGraphicsLayer),this._setUpdateOperationHandle(a,b),this.emit("update",{graphics:k,state:"start",aborted:!1,tool:a.tool,toolEventInfo:null,type:"update"}))):this._logError("sketch:missing-parameter","Missing parameter 'graphics'.")}async _updateSpatialReference(a){const b=this.view;if(b){this._beginAsyncOperation();a=Array.isArray(a)?a:[a];for(const d of a)null==d.geometry||"mesh"===d.geometry.type||
da.equals(d.geometry.spatialReference,b.spatialReference)||(J.canProjectWithoutEngine(d.geometry.spatialReference,b.spatialReference)||J.isLoaded()||await J.load(),d.geometry=J.project(d.geometry,b.spatialReference));this._endAsyncOperation()}else this._logMissingView()}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._operationHandle?.toggleTool()}async _getFirstHit(a){var b=
this.view;if(!b)return this._logMissingView(),null;if("2d"===b.type){const c=[];b.map.allLayers.forEach(f=>{"vector-tile"!==f.type&&"imagery"!==f.type||c.push(f)});b=await b.hitTest(a,{exclude:c});return oa.findFirstGraphicHit(b.results)}const d=[b.map.ground];b.map.allLayers.forEach(c=>{fa.isIntegratedMeshLayer(c.type)&&d.push(c)});a=await b.hitTest(a,{exclude:d});if(0<a.results.length){const c=a.results[0];if(null!=c&&"graphic"===c.type&&c.graphic&&(!a.ground.mapPoint||1>b.map.ground.opacity||a.ground.distance-
(c.distance??0)>-Math.min(3*a.ground.distance,"global"===b.viewingMode?ca.getReferenceEllipsoid(b.renderCoordsHelper.spatialReference).radius/b.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY)))return c}return null}_generateViewHandles(a){return[a.on("immediate-click",async b=>{var d="active"===this.state&&"create"===this._operationHandle?.type;if("disabled"!==this.state&&!d&&this.updateOnGraphicClick){this._beginAsyncOperation();var c=await b.async(()=>this._getFirstHit(U.createScreenPointFromEvent(b)));
d=null;null!=c?(c=c.graphic,this.updateGraphics.includes(c)||c.layer===this.layer?(b.stopPropagation(),d=c):"2d"!==a.type||this._isComponentGraphic(c)||"active"!==this.state||this.cancel()):"active"===this.state&&this.cancel();null==d||this.updateGraphics.includes(d)||await this.update([d],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}});this._endAsyncOperation()}},z.ViewEventPriorities.WIDGET)]}async _setupCreateOperation(a,b){const d=this.view;if(!d)return this._logMissingView(),
null;a=await this._setupDrawGraphicTool(a,d,{hasZ:"3d"===d.type,...this.defaultCreateOptions,...b});if(null==a)return null;d.tools.add(a);d.activeTool=a;return this._setupCreateOperationHandle(a)}async _setupDrawGraphicTool(a,b,d){if("multipoint"===a&&"3d"===b.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView."),null;if(!b)return this._logMissingView(),null;const {cursor:c,defaultZ:f,hasZ:k,geometryToPlace:h,graphicProperties:e,mode:g,preserveAspectRatio:p}=
d;d="rectangle"===a||"circle"===a?"hybrid":"click";const m=p??"rectangle"!==a;a={centered:"rectangle"!==a&&!("circle"===a&&!m),cursor:c,defaultZ:f,forceUniformSize:m,graphicProperties:e,geometryToPlace:h,geometryType:a,graphicSymbol:this._getGraphicSymbolFromTool(a),hasZ:k,mode:g??d,snappingManager:this.snappingManager,snapToScene:!1,view:b};return"2d"===b.type?this._makeDrawGraphicTool2D(a):this._makeDrawGraphicTool3D(a)}async _makeDrawGraphicTool2D(a){const b=await this._requireModule(new Promise((d,
c)=>A(["../../views/2d/interactive/editingTools"],d,c)));return y(b)||this.destroyed?null:new b.module.DrawGraphicTool2D({...a,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:ta(a.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(a){const b=await this._requireModule(new Promise((c,f)=>A(["../../views/3d/interactive/editingTools"],c,f)));if(y(b)||this.destroyed)return null;
const {elevationInfo:d}=this.layer;return new b.module.DrawGraphicTool3D({...a,elevationInfo:d,snapToScene:!0,sketchOptions:this.sketchOptions})}_setupCreateOperationHandle(a){const b=this.view;if(!b)return this._logMissingView(),null;let d=null;const c=a.forceUniformSize,f=a.centered,k=[b.on("key-down",e=>{if(e.key===w.sketchKeys.pan)e.stopPropagation(),e.repeat||(a.enabled=!1);else if(e.key===w.sketchKeys.complete)e.stopPropagation(),a.completeCreateOperation();else if(e.key!==w.sketchKeys.vertexAdd||
e.repeat)e.key===w.sketchKeys.undo?(e.stopPropagation(),h.undo()):e.key===w.sketchKeys.redo?(e.stopPropagation(),h.redo()):e.key!==w.sketchKeys.constraint||"rectangle"!==a.geometryType&&"circle"!==a.geometryType||e.repeat?e.key!==w.sketchKeys.center||e.repeat||(a.centered=!f,e.stopPropagation()):(a.forceUniformSize=!c,e.stopPropagation());else{const g=a.drawOperation.geometryType;if("polyline"===g||"polygon"===g||"multipoint"===g)e.stopPropagation(),a.drawOperation.commitStagedVertex()}},z.ViewEventPriorities.WIDGET),
b.on("key-up",e=>{e.key===w.sketchKeys.pan?a.enabled=!0:e.key!==w.sketchKeys.constraint||"rectangle"!==a.geometryType&&"circle"!==a.geometryType?e.key===w.sketchKeys.center&&(a.centered=f,e.stopPropagation()):(a.forceUniformSize=c,e.stopPropagation())},z.ViewEventPriorities.WIDGET),a.on("vertex-add",e=>{d=null==d?"start":"active";switch(e.operation){case "apply":this.emit("create",{graphic:a.graphic,state:d,tool:this.activeTool,toolEventInfo:e,type:"create"});break;case "undo":this._emitUndoEvent({graphics:[a.graphic],
tool:a.geometryType});break;case "redo":this._emitRedoEvent({graphics:[a.graphic],tool:a.geometryType})}}),a.on("cursor-update",e=>{0<a.drawOperation.numCommittedVertices&&this.emit("create",{graphic:a.graphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:e.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),a.on("vertex-remove",e=>{switch(e.operation){case "apply":this.emit("create",{graphic:a.graphic,state:"active",tool:this.activeTool,toolEventInfo:e,type:"create"});
break;case "undo":this._emitUndoEvent({graphics:[a.graphic],tool:a.geometryType});break;case "redo":this._emitRedoEvent({graphics:[a.graphic],tool:a.geometryType})}}),a.on("complete",e=>{this._set("createGraphic",e.graphic);d="complete";e.aborted?h&&h.cancel():h&&h.complete()}),B.watch(()=>this._getGraphicSymbolFromTool(a.geometryType),e=>{a.graphicSymbol=e})],h=new E.CreateOperationHandle({activeComponent:a,tool:a.geometryType,type:"create",onEnd:()=>{k.forEach(e=>e.remove());k.length=0;b.tools?.remove(a)},
undo:()=>{a.canUndo&&a.undo()},redo:()=>{a.canRedo&&a.redo()},canUndo:()=>a.canUndo,canRedo:()=>a.canRedo});return h}_getGraphicSymbolFromTool(a){switch(a){case "point":case "multipoint":return this.pointSymbol;case "polyline":return this.polylineSymbol;case "circle":case "rectangle":case "polygon":return this.polygonSymbol;case "mesh":return this.meshSymbol}}async _setupUpdateOperation(a,b){const {layer:d,view:c}=this;if(!c)return this._logMissingView(),null;b={...this.defaultUpdateOptions,...b,
reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...b?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...b?.highlightOptions}};let f=b.tool??G.tool;for(var k of a)d.remove(k),d.add(k);if("3d"===c.type){if(0===a.length)return null;switch(f){case "move":return this._setupMove3DOperation(a,b,c,f);case "reshape":return 1<a.length?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(a[0],
b,c);case "transform":return this._setupGraphicTransform3DOperation(a,b,c)}}switch(f){case "move":return this._setupMove2DOperation(a,b,c);case "reshape":return 1<a.length?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(a,f,b,c);case "transform":return 1===a.length&&(k=a[0].geometry?.type,"point"===k||"multipoint"===k)&&(f="reshape"),this._setupTransformOrReshape2DOperation(a,f,b,c)}}async _setupMove3DOperation(a,
b,d,c,f=!1){var k=await this._requireModule(new Promise((l,x)=>A(["../../views/3d/interactive/editingTools"],l,x)));if(y(k))return k;const {ManipulatedObject3DGraphic:h,MoveTool3D:e}=k.module,g=new Map,p=()=>{g.forEach(l=>l.destroy());g.clear()};for(const l of a){k=new h({view:d,graphic:l});const x=ha.isSupportedObject(k);if(x!==F.SupportedObjectResult.SUPPORTED)return p(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${F.isSupportedObjectResultMessage(x)}).`),
null;g.set(l,k)}const m=new e({view:d,enableZ:b.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});d.tools.add(m);m.objects.addMany(Array.from(g.values()));f||this.updateGraphics.addMany(a);const q=[],n=new E.UpdateOperationHandle({activeComponent:m,tool:c,type:"update",onEnd:()=>{q.forEach(l=>l.remove());q.length=0;d.tools?.remove(m);m.destroyed||m.destroy();p()},undo:()=>{var l=this.view;null!=l&&m.hasGrabbedManipulators&&(l.activeTool=null);K(n,this.updateGraphics.toArray());
this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:c})},redo:()=>{L(n,this.updateGraphics.toArray());this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:c})},addToSelection:l=>{this.updateGraphics.push(l);const x=new h({view:d,graphic:l});g.set(l,x);m.objects.push(x);this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[l],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:l=>
{const x=this.updateGraphics.indexOf(l);n.history.undo.forEach(H=>H.updates.splice(x,1));n.history.redo.forEach(H=>H.updates.splice(x,1));this.updateGraphics.remove(l);this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[l],type:"selection-change"},type:"update"});if(0===this.updateGraphics.length)n.complete();else{var t=g.get(l);t&&(m.objects.remove(t),t.destroy(),g.delete(l))}},toggleTool:async()=>{if(1===this.updateGraphics.length&&
!1!==b.toggleToolOnClick&&"transform"===c){var l=this.updateGraphics.at(0);(l=await this._setupReshape3DOperation(l,b,d,!0))&&!y(l)&&(n.onEnd(),n.destroy(),this._setUpdateOperationHandle(l,b))}}});q.push(...this._getHandlesForComponent(n,b),d.on("immediate-click",l=>this._getCommonUpdateOperationClickHandlers(n,l,b),z.ViewEventPriorities.WIDGET),d.on("key-down",l=>{this._getCommonUpdateOperationKeyDownHandlers(n,l)},z.ViewEventPriorities.WIDGET));return n}_setupGraphicTransform3DOperation(a,b,d,c=
!1){if(1===a.length&&ja.isSupportedGraphic(a[0])===F.SupportedObjectResult.SUPPORTED){const f=a[0],k=f.geometry;if(null!=k&&("point"===k.type||"mesh"===k.type))return this._setupPointTransform3DOperation(f,b,d);if(null!=k&&("polygon"===k.type||"polyline"===k.type))return this._setupPolyTransform3DOperation(f,b,d,c)}return this._setupMove3DOperation(a,b,d,"transform",c)}async _setupPointTransform3DOperation(a,b,d){const {enableRotation:c,enableScaling:f,enableZ:k}=b,h=await this._requireModule(new Promise((l,
x)=>A(["../../views/3d/interactive/editingTools"],l,x)));if(y(h))return h;const {TransformTool3D:e,ManipulatedObject3DGraphic:g}=h.module,p=new g({graphic:a,view:d}),m=new e({object:p,view:d,enableRotation:c,enableScaling:f,enableZ:k,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});d.tools.add(m);this.updateGraphics.add(a);const q=[],n=new E.UpdateOperationHandle({activeComponent:m,tool:"transform",type:"update",onEnd:()=>{q.forEach(l=>l.remove());q.length=0;d.tools?.remove(m);
m.destroyed||m.destroy();p.destroy()},undo:()=>{var l=this.view;null!=l&&m.hasGrabbedManipulators&&(l.activeTool=null);K(n,this.updateGraphics.toArray());this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:"transform"})},redo:()=>{L(n,this.updateGraphics.toArray());this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:"transform"})},addToSelection:async l=>{this.updateGraphics.add(l);this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,
toolEventInfo:{added:[l],removed:[],type:"selection-change"},type:"update"});n.onEnd();n.destroy();l=await this._setupMove3DOperation(this.updateGraphics.toArray(),b,d,"transform",!0);y(l)||this._setUpdateOperationHandle(l,b)},removeFromSelection:l=>{this.updateGraphics.remove(l);this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[l],type:"selection-change"},type:"update"});n.complete()},toggleTool:()=>{}});q.push(...this._getHandlesForComponent(n,
b),d.on("immediate-click",l=>this._getCommonUpdateOperationClickHandlers(n,l,b),z.ViewEventPriorities.WIDGET),d.on("key-down",l=>{this._getCommonUpdateOperationKeyDownHandlers(n,l)},z.ViewEventPriorities.WIDGET));return n}async _setupPolyTransform3DOperation(a,b,d,c=!1){const {enableRotation:f,enableScaling:k,enableZ:h,preserveAspectRatio:e}=b;var g=await this._requireModule(new Promise((t,H)=>A(["../../views/3d/interactive/editingTools"],t,H)));if(y(g))return g;const {ManipulatedObject3DGraphic:p,
ExtentTransformTool:m}=g.module;g=this.view?.inputManager?.isModifierKeyDown(w.sketchKeys.constraint);const q=new p({view:d,graphic:a}),n=new m({object:q,view:d,enableRotation:f,enableScaling:k,enableZ:h,preserveAspectRatio:!!e!==!!g,sketchOptions:this.sketchOptions});d.tools.add(n);c||this.updateGraphics.add(a);const l=[],x=new E.UpdateOperationHandle({activeComponent:n,tool:"transform",type:"update",onEnd:()=>{l.forEach(t=>t.remove());l.length=0;d.tools?.remove(n);n.destroyed||n.destroy();q.destroy()},
canUndo:()=>n.canUndo,undo:()=>{n.undo();this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:"transform"})},canRedo:()=>n.canRedo,redo:()=>{n.redo();this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:"transform"})},addToSelection:async t=>{this.updateGraphics.add(t);this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[t],removed:[],type:"selection-change"},type:"update"});x.onEnd();x.destroy();t=
await this._setupMove3DOperation(this.updateGraphics.toArray(),b,d,"transform",!0);y(t)||this._setUpdateOperationHandle(t,b)},removeFromSelection:t=>{this.updateGraphics.remove(t);this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[t],type:"selection-change"},type:"update"});x.complete()},toggleTool:async()=>{if(1===this.updateGraphics.length&&!1!==b.toggleToolOnClick){var t=await this._setupReshape3DOperation(a,
b,d,!0);t&&!y(t)&&(x.onEnd(),x.destroy(),this._setUpdateOperationHandle(t,b))}}});l.push(...this._getHandlesForComponent(x,b),d.on("immediate-click",t=>this._getCommonUpdateOperationClickHandlers(x,t,b),z.ViewEventPriorities.WIDGET),d.on("key-down",t=>this._getCommonUpdateOperationKeyDownHandlers(x,t),z.ViewEventPriorities.WIDGET),d.on("key-down",t=>{t.key!==w.sketchKeys.constraint||t.repeat||(n.preserveAspectRatio=!n.preserveAspectRatio,t.stopPropagation())},z.ViewEventPriorities.WIDGET),d.on("key-up",
t=>{t.key===w.sketchKeys.constraint&&(n.preserveAspectRatio=!n.preserveAspectRatio,t.stopPropagation())},z.ViewEventPriorities.WIDGET));return x}async _setupMove2DOperation(a,b,d){this.updateGraphics.addMany(a);await this._updateSpatialReference(a);const c=await this._getGraphicMover(a,b,d);if(y(c))return c;const f=new E.UpdateOperationHandle({activeComponent:c,tool:"move",type:"update",onEnd:()=>{this._displayDefaultCursor();e.forEach(g=>g.remove());h.forEach(g=>g.remove());e=[];h=[];c.destroy();
this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const g=this.updateGraphics.toArray();K(f,g);f.refreshComponent();this._emitUndoEvent({graphics:g,tool:"move"})},redo:()=>{const g=this.updateGraphics.toArray();L(f,g);f.refreshComponent();this._emitRedoEvent({graphics:g,tool:"move"})},addToSelection:async g=>{await this._updateSpatialReference(g);this.updateGraphics.push(g);c.graphics=this.updateGraphics.toArray();this.emit("update",{graphics:this.updateGraphics.toArray(),
state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[g],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:g=>{const p=this.updateGraphics.indexOf(g);f.history.undo.forEach(q=>q.updates.splice(p,1));f.history.redo.forEach(q=>q.updates.splice(p,1));this.updateGraphics.remove(g);const m=this.updateGraphics.toArray();this.emit("update",{graphics:m,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[g],type:"selection-change"},type:"update"});
0===this.updateGraphics.length?f.complete():c.graphics=m}});let k=!1,h=[d.on("immediate-click",g=>this._getCommonUpdateOperationClickHandlers(f,g,b),z.ViewEventPriorities.WIDGET),d.on("key-down",g=>{this._getCommonUpdateOperationKeyDownHandlers(f,g);g.key!==w.sketchKeys.constraint||g.repeat||(k=!0,c.enableMoveAllGraphics=!c.enableMoveAllGraphics)},z.ViewEventPriorities.WIDGET),d.on("key-up",g=>{g.key===w.sketchKeys.constraint&&k&&(k=!1,c.enableMoveAllGraphics=!c.enableMoveAllGraphics)},z.ViewEventPriorities.WIDGET)],
e=this._getHandlesForComponent(f,b);return f}async _setupReshape3DOperation(a,b,d,c=!1){const f=await this._requireModule(new Promise((q,n)=>A(["../../views/3d/interactive/editingTools"],q,n)));if(y(f))return f;const {ManipulatedObject3DGraphic:k,ReshapeTool3D:h}=f.module,e=new k({view:d,graphic:a});a=ia.isSupportedObject(e);if(a!==F.SupportedObjectResult.SUPPORTED)return e.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${F.isSupportedObjectResultMessage(a)}).`),
null;a=b.reshapeOptions;const g=new h({view:d,object:e,enableZVertex:b.enableZ&&"move"===a?.vertexOperation,enableZShape:b.enableZ&&"move"===a?.shapeOperation,enableMoveObject:"move"===a?.shapeOperation||"move-xy"===a?.shapeOperation,enableMidpoints:"split"===a?.edgeOperation,enableEdgeOffset:"offset"===a?.edgeOperation,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});d.tools.add(g);c||this.updateGraphics.add(e.graphic);const p=[],m=new E.UpdateOperationHandle({activeComponent:g,
tool:"reshape",type:"update",onEnd:()=>{p.forEach(q=>q.remove());p.length=0;d.tools?.remove(g);g.destroyed||g.destroy();e.destroy()},canUndo:()=>g.canUndo,undo:()=>{g.undo();this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:"reshape"})},canRedo:()=>g.canRedo,redo:()=>{g.redo();this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:"reshape"})},addToSelection:async q=>{this.updateGraphics.add(q);this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,
tool:this.activeTool,toolEventInfo:{added:[q],removed:[],type:"selection-change"},type:"update"});m.onEnd();m.destroy();q=await this._setupMove3DOperation(this.updateGraphics.toArray(),b,d,"transform",!0);y(q)||this._setUpdateOperationHandle(q,b)},removeFromSelection:q=>{this.updateGraphics.remove(q);this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[q],type:"selection-change"},type:"update"});m.complete()},toggleTool:async()=>
{if(!1!==b.toggleToolOnClick){m.onEnd();m.destroy();var q=await this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),b,d,!0);y(q)||this._setUpdateOperationHandle(q,b)}}});p.push(...this._getHandlesForComponent(m,b),d.on("immediate-click",q=>this._getCommonUpdateOperationClickHandlers(m,q,b),z.ViewEventPriorities.WIDGET),d.on("key-down",q=>{this._getCommonUpdateOperationKeyDownHandlers(m,q)},z.ViewEventPriorities.WIDGET));return m}async _setupTransformOrReshape2DOperation(a,b,d,c){this.updateGraphics.addMany(a);
await this._updateSpatialReference(a);a="transform"===b?await this._getBox(a,d,c):await this._getReshape(a,d,c);if(y(a))return a;const f=new E.UpdateOperationHandle({activeComponent:a,type:"update",onEnd:()=>{h.forEach(e=>e.remove());k.forEach(e=>e.remove());h=[];k=[];f.activeComponent&&!f.activeComponent.destroyed&&f.activeComponent.destroy();this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{K(f,this.updateGraphics.toArray());f.refreshComponent();this._emitUndoEvent({graphics:this.updateGraphics.toArray(),
tool:f.tool})},redo:()=>{L(f,this.updateGraphics.toArray());f.refreshComponent();this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:f.tool})},addToSelection:async e=>{var g=f.activeComponent;if("reshape"===g?.type){g=[...this.updateGraphics,e];this.updateGraphics.removeAll();f.onEnd();f.destroy();g=await this._setupTransformOrReshape2DOperation(g,"transform",d,c);if(y(g))return;this._setUpdateOperationHandle(g,d)}else this.updateGraphics.add(e),g.graphics=this.updateGraphics.toArray(),
g.refresh(),f.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:async e=>{const g=this.updateGraphics.indexOf(e);f.history.undo.forEach(m=>m.updates.splice(g,1));f.history.redo.forEach(m=>m.updates.splice(g,1));this.updateGraphics.remove(e);const p=this.updateGraphics.toArray();if(0===p.length)f.complete();else{const m=p[0].geometry;
1!==p.length||null==m||"point"!==m.type&&"multipoint"!==m.type?f.activeComponent.graphics=p:f.toggleTool()}this.emit("update",{graphics:p,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(!(1<this.updateGraphics.length)){var e=this.updateGraphics.at(0),g=e.geometry;if(null==g||("reshape"!==f.tool||"point"!==g.type&&"multipoint"!==g.type)&&("transform"!==f.tool||"extent"!==g.type))g=null,"transform"===
f.tool?g=await this._getReshape([e],d,c):"reshape"===f.tool&&(g=await this._getBox([e],d,c)),y(g)||(f.activeComponent?.destroy(),f.activeComponent=g,f.activeComponent&&(h.forEach(p=>p.remove()),h=this._getHandlesForComponent(f,d)))}}});let k=[c.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(f,e,d),z.ViewEventPriorities.WIDGET),c.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(f,e);e.key===w.sketchKeys.constraint&&!e.repeat&&f&&(e=f.activeComponent)&&"box"===e.type&&
(e.preserveAspectRatio=!e.preserveAspectRatio)},z.ViewEventPriorities.WIDGET),c.on("key-up",e=>{e.key===w.sketchKeys.constraint&&f&&(e=f.activeComponent)&&"box"===e.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)},z.ViewEventPriorities.WIDGET)],h=this._getHandlesForComponent(f,d);return f}async _getGraphicMover(a,b,d){const {enableMoveAllGraphics:c,highlightOptions:f}=b;b=await this._requireModule(new Promise((k,h)=>A(["../../views/draw/support/GraphicMover"],e=>k(M(e)),h)));return y(b)?b:new b.module.default({enableMoveAllGraphics:c,
highlightsEnabled:!!f?.enabled,indicatorsEnabled:!1,graphics:a,view:d,callbacks:{onGraphicMoveStart:({dx:k,dy:h,graphic:e})=>{this._displayGrabbingCursor();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:k,dy:h,mover:e,type:"move-start"},type:"update"})},onGraphicMove:({dx:k,dy:h,graphic:e})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:k,dy:h,
mover:e,type:"move"},type:"update"}),onGraphicMoveStop:({dx:k,dy:h,graphic:e})=>{this._displayPointerCursor();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:k,dy:h,mover:e,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayPointerCursor(),onGraphicPointerOut:()=>this._displayDefaultCursor()}})}async _getBox(a,b,d){const {enableRotation:c,enableScaling:f,highlightOptions:k,preserveAspectRatio:h}=b;b=
await this._requireModule(new Promise((g,p)=>A(["../../views/draw/support/Box"],m=>g(M(m)),p)));if(y(b))return b;const e=this.view?.inputManager?.isModifierKeyDown(w.sketchKeys.constraint);return new b.module.default({graphics:a,enableRotation:c,enableScaling:f,highlightsEnabled:!!k?.enabled,preserveAspectRatio:!!h!==!!e,layer:this._internalGraphicsLayer,view:d,sketchOptions:this.sketchOptions,callbacks:{onMoveStart:g=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,
tool:this.activeTool,toolEventInfo:{...g},type:"update"}),onMove:g=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...g},type:"update"}),onMoveStop:g=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...g},type:"update"}),onScaleStart:g=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...g},
type:"update"}),onScale:g=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...g},type:"update"}),onScaleStop:g=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...g},type:"update"}),onRotateStart:g=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...g},type:"update"}),onRotate:g=>this.emit("update",
{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...g},type:"update"}),onRotateStop:g=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...g},type:"update"})}})}async _getReshape(a,b,d){const c="split"===b.reshapeOptions?.edgeOperation,f="move"===b.reshapeOptions?.shapeOperation;b=!!b.highlightOptions?.enabled;const k=await this._requireModule(new Promise((h,e)=>A(["../../views/draw/support/Reshape"],
g=>h(M(g)),e)));return y(k)?k:new k.module.default({enableMidpoints:c,enableMovement:f,graphic:a[0],highlightsEnabled:b,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,view:d,callbacks:{onReshapeStart:h=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...h},type:"update"}),onReshape:h=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,
tool:this.activeTool,toolEventInfo:{...h},type:"update"}),onReshapeStop:({mover:h,type:e})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:h,type:e},type:"update"}),onMoveStart:({dx:h,dy:e,mover:g,type:p})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:h,dy:e,mover:g,type:p},type:"update"}),onMove:({dx:h,dy:e,mover:g,type:p})=>this.emit("update",
{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:h,dy:e,mover:g,type:p},type:"update"}),onMoveStop:({dx:h,dy:e,mover:g,type:p})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:h,dy:e,mover:g,type:p},type:"update"}),onVertexAdd:({added:h,type:e,vertices:g})=>{h=h.map(p=>P.geometryToCoordinates(p.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",
aborted:!1,tool:this.activeTool,toolEventInfo:{added:h,vertices:g,type:e},type:"update"})},onVertexRemove:({removed:h,type:e,vertices:g})=>{h=h.map(p=>P.geometryToCoordinates(p.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:h,vertices:g,type:e},type:"update"})}}})}_getHandlesForComponent(a,b){const d=a.activeComponent;if(!d)return[];switch(d.type){case "graphic-mover":return[d.on("graphic-click",({graphic:c,
viewEvent:f})=>{f.native?.shiftKey&&(f.stopPropagation(),a.removeFromSelection(c))}),d.on("graphic-move-start",c=>a.addToHistory(C(c.allGraphics)))];case "box":return[d.on("graphic-click",c=>this._onTransformOrReshape2DGraphicClick(a,b,c)),d.on("move-start",c=>a.addToHistory(C(c.graphics))),d.on("rotate-start",c=>a.addToHistory(C(c.graphics))),d.on("scale-start",c=>a.addToHistory(C(c.graphics)))];case "reshape":return[d.on("graphic-click",c=>this._onTransformOrReshape2DGraphicClick(a,b,c)),d.on("move-start",
c=>a.addToHistory(C([c.mover]))),d.on("reshape-start",c=>a.addToHistory(C([c.graphic]))),d.on("vertex-add",c=>a.addToHistory(C([c.oldGraphic]))),d.on("vertex-remove",c=>a.addToHistory(C([c.oldGraphic])))];case "move-3d":return[d.events.on("record-undo",({updates:c})=>{a.addToHistory({updates:c})}),d.events.on("move-start",c=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:0<c.objects.length?c.objects[0].graphic:
null,type:"move-start"},type:"update"})}),d.events.on("move",c=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:c.dx,dy:c.dy,mover:0<c.objects.length?c.objects[0].graphic:null,type:"move"},type:"update"})}),d.events.on("move-stop",c=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:0<c.objects.length?c.objects[0].graphic:null,type:"move-stop"},
type:"update"})}),d.events.on("immediate-click",c=>{c.shiftKey?this._toggleSelection([c.object.graphic],a,b):a.toggleTool()})];case "transform-3d":return[d.events.on("record-undo",({updates:c})=>{a.addToHistory({updates:c})}),d.events.on("translate-start",c=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:c.object.graphic,dx:c.dxScreen,dy:c.dyScreen,type:"move-start"},type:"update"})}),d.events.on("translate-stop",c=>
{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:c.object.graphic,dx:c.dxScreen,dy:c.dyScreen,type:"move-stop"},type:"update"})}),d.events.on("rotate-start",c=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:c.object.graphic,angle:c.angle,type:"rotate-start"},type:"update"})}),d.events.on("rotate-stop",c=>{this.emit("update",{graphics:this.updateGraphics.toArray(),
state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:c.object.graphic,angle:c.angle,type:"rotate-stop"},type:"update"})}),d.events.on("scale-start",c=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:c.object.graphic,xScale:c.xScale,yScale:c.yScale,type:"scale-start"},type:"update"})}),d.events.on("scale-stop",c=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,
toolEventInfo:{mover:c.object.graphic,xScale:c.xScale,yScale:c.yScale,type:"scale-stop"},type:"update"})}),d.events.on("translate",c=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:c.object.graphic,dx:c.dxScreen,dy:c.dyScreen,type:"move"},type:"update"})}),d.events.on("rotate",c=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:c.object.graphic,
angle:c.angle,type:"rotate"},type:"update"})}),d.events.on("scale",c=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:c.object.graphic,xScale:c.xScale,yScale:c.yScale,type:"scale"},type:"update"})}),d.events.on("immediate-click",c=>{c.shiftKey?this._toggleSelection([c.object.graphic],a,b):a.toggleTool()})];case "reshape-3d":return[d.events.on("reshape",c=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",
aborted:!1,tool:this.activeTool,toolEventInfo:{...c,mover:c.object.graphic},type:"update"})}),d.events.on("move",c=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...c,mover:c.object.graphic},type:"update"})}),d.events.on("vertex-add",c=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:c,type:"update"})}),d.events.on("vertex-remove",c=>{this.emit("update",
{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:c,type:"update"})}),d.events.on("immediate-click",c=>{c.shiftKey?this._toggleSelection([c.object.graphic],a,b):a.toggleTool()})]}}_onTransformOrReshape2DGraphicClick(a,b,d){const {graphic:c,viewEvent:f}=d;if(f.native?.shiftKey&&c.layer===this.layer)return f.stopPropagation(),a.removeFromSelection(c);if(b.toggleToolOnClick)return f.stopPropagation(),a.toggleTool()}_setUpdateOperationHandle(a,b){this._operationHandle=
a;const d=this.view?.map;this._disablePopup(b);a.on("complete",()=>{if(a===this._operationHandle){const c=this.updateGraphics.toArray(),f=this._operationHandle.tool;this._operationHandle.destroy();this._operationHandle=null;this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray());this.updateGraphics.removeAll();d&&d.remove(this._internalGraphicsLayer);this._restorePopup(b);this.emit("update",{graphics:c,state:"complete",aborted:a.cancelled,tool:f,toolEventInfo:null,type:"update"})}})}async _getCommonUpdateOperationClickHandlers(a,
b,d){const c=U.createScreenPointFromEvent(b),f=await b.async(()=>this._getFirstHit(c));null==f?a.complete():b.native.shiftKey&&this._toggleSelection([f.graphic],a,d)?b.stopPropagation():this.updateGraphics.includes(f.graphic)?b.stopPropagation():a.complete()}_toggleSelection(a,b,d){const c=!!d.multipleSelectionEnabled;return a.some(f=>null==f?!1:c&&f.layer===this.layer?(this.updateGraphics.includes(f)?b.removeFromSelection(f):b.addToSelection(f),!0):!1)}_getCommonUpdateOperationKeyDownHandlers(a,
b){if(a){var d=b.key;d===w.sketchKeys.undo&&a.canUndo()?(b.stopPropagation(),a.undo()):d===w.sketchKeys.redo&&a.canRedo()?(b.stopPropagation(),a.redo()):d===w.sketchKeys.cancel?(b.stopPropagation(),a.cancel()):this.allowDeleteKey&&w.sketchKeys.delete.includes(d)&&this._onDeleteKey(b)}}_onDeleteKey(a){if(this._operationHandle&&"update"===this._operationHandle.type){var b=this.activeComponent,d=this.updateGraphics.toArray();null!=b&&("reshape"!==b.type||1===d.length&&"point"===d[0].geometry?.type)&&
(a.stopPropagation(),this.delete())}}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view?.map?.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=D.destroyMaybe(this._internalGraphicsLayer))}_isComponentGraphic(a){const {activeComponent:b}=this;return a&&null!=b?a.attributes?.esriSketchTool||"draw-2d"===b.type&&b.graphic===a||("box"===b.type||"reshape"===b.type)&&b.isUIGraphic(a):!1}_displayPointerCursor(){this.view?.container&&"pointer"!==this.view.cursor&&(this.view.cursor=
"pointer")}_displayGrabbingCursor(){this.view?.container&&"grabbing"!==this.view.cursor&&(this.view.cursor="grabbing")}_displayDefaultCursor(){this.view?.container&&null!==this.view.cursor&&(this.view.cursor=null)}_logError(a,b,d){aa.getLogger(this).error(new Z(a,b,d))}async _requireModule(a){const b=new AbortController;this._moduleLoaderAbortController=b;a=await a;return this._moduleLoaderAbortController!==b||b.signal.aborted?{requireError:"aborted"}:{module:a}}_emitUndoEvent(a){this.emit("undo",
{...a,type:"undo"})}_emitRedoEvent(a){this.emit("redo",{...a,type:"redo"})}_emitDeleteEvent(a){this.emit("delete",{...a,type:"delete"})}get test(){}wait(){return B.whenOnce(()=>!this.updating)}_beginAsyncOperation(){this._numUpdating+=1;this.notifyChange("updating")}_endAsyncOperation(){--this._numUpdating;this.notifyChange("updating")}_disablePopupEnabled(a){return"3d"!==this.view?.type||this.updateOnGraphicClick||(a?.toggleToolOnClick??!1)}_disablePopup(a){this._disablePopupEnabled(a)&&this.view&&
null==this._originalPopupEnabled&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(a){this._disablePopupEnabled(a)&&this.view&&null!=this._originalPopupEnabled&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){const a=this.view;a?(D.abortMaybe(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await N.whenOrAbort(B.whenOnce(()=>a?.ready),this._viewReadyAbortController.signal)):
this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",Y("view"))}_logMissingLayer(){this._logError("sketch:missing-property",Y("layer"))}};u.__decorate([v.property()],r.prototype,"_defaultSnappingManager",void 0);u.__decorate([v.property()],r.prototype,"updating",null);u.__decorate([v.property()],r.prototype,"_operationHandle",void 0);u.__decorate([v.property({readOnly:!0})],r.prototype,"activeTool",null);u.__decorate([v.property()],r.prototype,"activeFillSymbol",void 0);
u.__decorate([v.property()],r.prototype,"activeLineSymbol",void 0);u.__decorate([v.property()],r.prototype,"activeVertexSymbol",void 0);u.__decorate([v.property()],r.prototype,"allowDeleteKey",void 0);u.__decorate([v.property({readOnly:!0})],r.prototype,"createGraphic",null);u.__decorate([v.property()],r.prototype,"defaultCreateOptions",null);u.__decorate([v.property()],r.prototype,"defaultUpdateOptions",null);u.__decorate([v.property({type:ka,nonNullable:!0})],r.prototype,"labelOptions",null);u.__decorate([v.property()],
r.prototype,"layer",void 0);u.__decorate([v.property({types:I.symbolTypes})],r.prototype,"pointSymbol",void 0);u.__decorate([v.property({types:I.symbolTypes})],r.prototype,"polygonSymbol",void 0);u.__decorate([v.property({types:I.symbolTypes})],r.prototype,"polylineSymbol",void 0);u.__decorate([v.property()],r.prototype,"meshSymbol",void 0);u.__decorate([v.property({type:T,nonNullable:!0})],r.prototype,"snappingOptions",null);u.__decorate([v.property()],r.prototype,"snappingManager",null);u.__decorate([v.property({readOnly:!0})],
r.prototype,"state",null);u.__decorate([v.property({type:la,nonNullable:!0})],r.prototype,"tooltipOptions",null);u.__decorate([v.property({readOnly:!0})],r.prototype,"updateGraphics",void 0);u.__decorate([v.property()],r.prototype,"updateOnGraphicClick",void 0);u.__decorate([v.property({type:ma,nonNullable:!0})],r.prototype,"valueOptions",null);u.__decorate([v.property({types:I.symbolTypes})],r.prototype,"vertexSymbol",void 0);u.__decorate([v.property({value:null})],r.prototype,"view",null);u.__decorate([v.property({constructOnly:!0,
type:R})],r.prototype,"sketchOptions",void 0);r=u.__decorate([ba.subclass("esri.widgets.Sketch.SketchViewModel")],r);const Y=a=>`Property '${a}' is missing on SketchViewModel.`;return r});