@arcgis/core 5.2.0-next.51 → 5.2.0-next.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/chunks/GlowBlur.glsl.js +1 -1
  3. package/chunks/GlowComposite.glsl.js +1 -1
  4. package/chunks/Stars.glsl.js +7 -12
  5. package/config.js +1 -1
  6. package/kernel.js +1 -1
  7. package/package.json +1 -1
  8. package/rest/networks/support/TraverseAssociationsParameters.d.ts +26 -4
  9. package/support/revision.js +1 -1
  10. package/third-party-notices.txt +0 -66
  11. package/views/3d/analysis/LineOfSight/LineOfSightAuthoringUtils.js +1 -1
  12. package/views/3d/analysis/LineOfSight/LineOfSightPlacementController.js +1 -1
  13. package/views/3d/analysis/LineOfSight/LineOfSightRootPlugin.js +1 -1
  14. package/views/3d/analysis/LineOfSight/LineOfSightTargetPlugin.js +1 -1
  15. package/views/3d/analysis/LineOfSight/LineOfSightTool2.js +1 -1
  16. package/views/3d/analysis/LineOfSight/types.d.ts +28 -0
  17. package/views/3d/analysis/LineOfSightAnalysisView3D.d.ts +7 -7
  18. package/views/3d/interactive/editingTools/manipulations/Manipulation.js +1 -1
  19. package/views/3d/interactive/editingTools/manipulations/MoveManipulation.js +1 -1
  20. package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
  21. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  22. package/views/3d/interactive/editingTools/transform/ExtentTransformTool.js +1 -1
  23. package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
  24. package/views/3d/interactive/editingTools/transform/TransformTool3D.js +1 -1
  25. package/views/3d/support/hitTest.js +1 -1
  26. package/views/3d/webgl-engine/lib/CutFillComputation.js +1 -1
  27. package/views/SceneView.js +1 -1
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import o from"../../../../core/Accessor.js";import{isSome as e}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{when as i,syncAndInitial as n}from"../../../../core/reactiveUtils.js";import{property as a,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{absoluteHeightElevationInfo as r}from"../../../../support/elevationInfoUtils.js";import{createDrawTool as l}from"./lineOfSightPlacementUtils.js";import{createLineOfSightRootPluginConfiguration as d}from"./LineOfSightRootPlugin.js";import{Manipulator3D as p}from"../../interactive/Manipulator3D.js";const h=Symbol("hiddenManipulatorHandle");let u=class extends o{get active(){return!!this._drawTool?.active}get canRedo(){return this._drawTool?.canRedo??!1}get canUndo(){return this._drawTool?.canUndo??!1}get updating(){return this._drawTool?.updating??!1}get activeTooltipInfo(){return this._drawTool?.activeTooltipInfo??null}get tooltip(){return this._drawTool?.tooltip??null}constructor(t){super(t),this.visible=!0,this.placementElevationInfo=null,this._drawTool=null,this._renderer=null,this._sessionStartedWithValidAnalysis=!1}initialize(){this.addHandles([i(()=>!this.active,()=>{this.analysisViewData.cursorTarget=null},n)])}destroy(){this._destroyDrawTool()}get activeSnappingManager(){return this.active?this._drawTool?.snappingManager??null:null}get _snapToSceneEnabled(){const t=this._sourceElevationInfo?.mode;return"relative-to-ground"!==t&&"on-the-ground"!==t&&null}get _defaultElevationInfo(){return this.placementElevationInfo}get _sourceElevationInfo(){return this.placementElevationInfo??r}continue(){if(this._drawTool?.active)return;this._sessionStartedWithValidAnalysis=this.analysis.valid;const{drawTool:t,renderer:o}=this._createDrawTool();this._drawTool=t,this._renderer=o,this.view.addAndActivateTool(t),t.begin([d({analysis:this.analysis,analysisViewData:this.analysisViewData,defaultElevationInfo:this._defaultElevationInfo,sourceElevationInfo:this._sourceElevationInfo,view:this.view})])}stop(){this._destroyDrawTool()}redo(){this._drawTool?.redo()}undo(){this._drawTool?.undo()}get testInfo(){}_createDrawTool(){return l({analysis:this.analysis,analysisViewData:this.analysisViewData,view:this.view,getSnapToSceneEnabled:()=>this._snapToSceneEnabled,getSourceElevationInfo:()=>this._sourceElevationInfo,getVisible:()=>this.visible,onCancel:t=>{t!==this._drawTool||this._sessionStartedWithValidAnalysis||null!=this.analysis.observer||(this.analysis.clear(),this.analysisViewData.cursorTarget=null),this._destroyDrawTool(t)},onComplete:t=>this._destroyDrawTool(t),onManipulatorCountChange:t=>this._hideManipulatorOnAppearance(t),shouldPreventVertexAdd:this.shouldPreventVertexAdd})}_destroyDrawTool(t=this._drawTool){if(null==t)return;const o=t===this._drawTool;this.view.activeTool===t&&(this.view.activeTool=null),this.view.tools.includes(t)&&this.view.tools.remove(t),t.destroy(),o&&(this._drawTool=null,this._renderer=null,this._sessionStartedWithValidAnalysis=!1)}_hideManipulatorOnAppearance(t){t.removeHandles(h),t.addHandles(t.manipulators.toArray().map(t=>t instanceof p?t.disableDisplay():null).filter(e),h)}};t([a({constructOnly:!0})],u.prototype,"view",void 0),t([a({constructOnly:!0})],u.prototype,"analysis",void 0),t([a({constructOnly:!0})],u.prototype,"analysisViewData",void 0),t([a({constructOnly:!0})],u.prototype,"parent",void 0),t([a({constructOnly:!0})],u.prototype,"shouldPreventVertexAdd",void 0),t([a()],u.prototype,"visible",void 0),t([a()],u.prototype,"placementElevationInfo",void 0),t([a()],u.prototype,"active",null),t([a()],u.prototype,"canRedo",null),t([a()],u.prototype,"canUndo",null),t([a()],u.prototype,"updating",null),t([a()],u.prototype,"activeTooltipInfo",null),t([a()],u.prototype,"tooltip",null),t([a()],u.prototype,"_drawTool",void 0),t([a()],u.prototype,"_renderer",void 0),u=t([s("esri.views.3d.analysis.LineOfSight.LineOfSightPlacementController")],u);export{u as LineOfSightPlacementController};
2
+ import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import{isSome as o}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{when as i,syncAndInitial as n}from"../../../../core/reactiveUtils.js";import{property as a,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{absoluteHeightElevationInfo as s}from"../../../../support/elevationInfoUtils.js";import{createDrawTool as l}from"./lineOfSightPlacementUtils.js";import{createLineOfSightRootPluginConfiguration as d}from"./LineOfSightRootPlugin.js";import{Manipulator3D as p}from"../../interactive/Manipulator3D.js";const h=Symbol("hiddenManipulatorHandle");let c=class extends e{get active(){return!!this._drawTool?.active}get canRedo(){return this._drawTool?.canRedo??!1}get canUndo(){return this._drawTool?.canUndo??!1}get updating(){return this._drawTool?.updating??!1}get activeTooltipInfo(){return this._drawTool?.activeTooltipInfo??null}get tooltip(){return this._drawTool?.tooltip??null}constructor(t){super(t),this.visible=!0,this.observerPlacementElevationInfo=null,this.targetPlacementElevationInfo=null,this._drawTool=null,this._renderer=null,this._sessionStartedWithValidAnalysis=!1}initialize(){this.addHandles([i(()=>!this.active,()=>{this.analysisViewData.cursorTarget=null},n)])}destroy(){this._destroyDrawTool()}get activeSnappingManager(){return this.active?this._drawTool?.snappingManager??null:null}get _snapToSceneEnabled(){const t=this._effectiveElevationInfo.mode;return"relative-to-ground"!==t&&"on-the-ground"!==t&&null}get _placementElevationInfo(){return null==this.analysis.observer?this.observerPlacementElevationInfo:this.targetPlacementElevationInfo}get _effectiveElevationInfo(){return this._placementElevationInfo??s}continue(){if(this._drawTool?.active)return;this._sessionStartedWithValidAnalysis=this.analysis.valid;const{drawTool:t,renderer:e}=this._createDrawTool();this._drawTool=t,this._renderer=e,this.view.addAndActivateTool(t),t.begin([d({analysis:this.analysis,analysisViewData:this.analysisViewData,observerElevationInfo:this.observerPlacementElevationInfo,targetElevationInfo:this.targetPlacementElevationInfo,view:this.view})])}stop(){this._destroyDrawTool()}redo(){this._drawTool?.redo()}undo(){this._drawTool?.undo()}get testInfo(){}_createDrawTool(){return l({analysis:this.analysis,analysisViewData:this.analysisViewData,view:this.view,getSnapToSceneEnabled:()=>this._snapToSceneEnabled,getSourceElevationInfo:()=>this._effectiveElevationInfo,getVisible:()=>this.visible,onCancel:t=>{t!==this._drawTool||this._sessionStartedWithValidAnalysis||null!=this.analysis.observer||(this.analysis.clear(),this.analysisViewData.cursorTarget=null),this._destroyDrawTool(t)},onComplete:t=>this._destroyDrawTool(t),onManipulatorCountChange:t=>this._hideManipulatorOnAppearance(t),shouldPreventVertexAdd:this.shouldPreventVertexAdd})}_destroyDrawTool(t=this._drawTool){if(null==t)return;const e=t===this._drawTool;this.view.activeTool===t&&(this.view.activeTool=null),this.view.tools.includes(t)&&this.view.tools.remove(t),t.destroy(),e&&(this._drawTool=null,this._renderer=null,this._sessionStartedWithValidAnalysis=!1)}_hideManipulatorOnAppearance(t){t.removeHandles(h),t.addHandles(t.manipulators.toArray().map(t=>t instanceof p?t.disableDisplay():null).filter(o),h)}};t([a({constructOnly:!0})],c.prototype,"view",void 0),t([a({constructOnly:!0})],c.prototype,"analysis",void 0),t([a({constructOnly:!0})],c.prototype,"analysisViewData",void 0),t([a({constructOnly:!0})],c.prototype,"parent",void 0),t([a({constructOnly:!0})],c.prototype,"shouldPreventVertexAdd",void 0),t([a()],c.prototype,"visible",void 0),t([a()],c.prototype,"observerPlacementElevationInfo",void 0),t([a()],c.prototype,"targetPlacementElevationInfo",void 0),t([a()],c.prototype,"active",null),t([a()],c.prototype,"canRedo",null),t([a()],c.prototype,"canUndo",null),t([a()],c.prototype,"updating",null),t([a()],c.prototype,"activeTooltipInfo",null),t([a()],c.prototype,"tooltip",null),t([a()],c.prototype,"_drawTool",void 0),t([a()],c.prototype,"_renderer",void 0),c=t([r("esri.views.3d.analysis.LineOfSight.LineOfSightPlacementController")],c);export{c as LineOfSightPlacementController};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../../../analysis/LineOfSightAnalysisObserver.js";import i from"../../../../analysis/LineOfSightAnalysisTarget.js";import s from"../../../../core/Collection.js";import{destroyMaybe as n}from"../../../../core/maybe.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{isPoint as a,isMultipoint as l}from"../../../../geometry/support/typeUtils.js";import{updateLineOfSightItemFromAuthoredPoint as u}from"./LineOfSightAuthoringUtils.js";import{isLineOfSightObserverPlugin as h,createLineOfSightObserverPluginConfiguration as c}from"./LineOfSightObserverPlugin.js";import{isLineOfSightPlacementLeafPlugin as g}from"./LineOfSightPlacementLeafPlugin.js";import{LineOfSightRayIntersector as p}from"./LineOfSightRayIntersector.js";import{isLineOfSightTargetPlugin as m,createLineOfSightTargetPluginConfiguration as _}from"./LineOfSightTargetPlugin.js";import{PluginBase as f}from"../../../draw/plugins/PluginBase.js";let d=class extends f{constructor(){super(...arguments),this.defaultElevationInfo=null,this.sourceElevationInfo=null,this._intersector=null,this._downstreamPlugin=null,this._initialObserver=null,this._operationObserver=null,this._initialTargets=new s,this._operationTargets=new s}initialize(){this._intersector=new p({view:this.view})}destroy(){this._intersector=n(this._intersector)}start(t){super.start(t),this._initialObserver=this.analysis.observer,this._operationObserver=this._initialObserver,y(this._initialTargets,this.analysis.targets.toArray()),this._operationTargets.removeAll(),t.session.appendOrReplacePart(null,[]),this._syncAnalysisFromSession(),this._restartDownstreamPlugin()}beforeAttachPlugin(t){return{geometryType:"point",useStandaloneSession:!0}}beforeComplete(){return{downstreamPluginCompletionMode:"cancel"}}attachPlugin(t){this._downstreamPlugin=t}afterUndoRedo(){this._syncAnalysisFromSession(),this._restartDownstreamPlugin()}complete(){this._clearCursorTarget(),super.complete()}cancel(){this._clearCursorTarget()}detachPlugin(t,s){if(this._downstreamPlugin===t&&(this._downstreamPlugin=null),m(t)&&this._clearCursorTarget(),"complete"!==s)return void this._syncAnalysisFromSession();const n=this._context?.getSession(t)?.generatePreviewGeometry({includeAutomaticConnection:!1,geometryType:"point"});if(!n||!a(n))return this._syncAnalysisFromSession(),void this._restartDownstreamPlugin();this._truncateItemsToSession();const r=g(t)?t.preservedIntersection:null,o=!!g(t)&&t.usesSnappedAbsoluteHeight;if(h(t)){const i=t.observer??this._operationObserver??new e;if(!this._intersector||!u(this.view,i,this._intersector,n,{defaultElevationInfo:this.defaultElevationInfo,sourceElevationInfo:this.sourceElevationInfo,preservedIntersection:r,useSnappedAbsoluteHeight:o,preferPreservedIntersection:!0}))return this._syncAnalysisFromSession(),void this._restartDownstreamPlugin();this._operationObserver=i}else if(m(t)){const e=t.target??new i;if(!this._intersector||!u(this.view,e,this._intersector,n,{defaultElevationInfo:this.defaultElevationInfo,sourceElevationInfo:this.sourceElevationInfo,preservedIntersection:r,useSnappedAbsoluteHeight:o,preferPreservedIntersection:!0}))return this._syncAnalysisFromSession(),void this._restartDownstreamPlugin();this._operationTargets.add(e)}this._appendCommittedPoint(n),this._syncAnalysisFromSession(),this._restartDownstreamPlugin(),this._clearCursorTarget()}_appendCommittedPoint(t){const e=this._session;e&&(e.appendOrReplacePoint(null,t),e.appendOrReplacePart(null,[]),e.automaticRestart=!1,e.groupGeometryChanges())}_clearCursorTarget(){this.analysisViewData.cursorTarget=n(this.analysisViewData.cursorTarget)}_truncateItemsToSession(){const t=this._getCommittedPointCount();null==this._initialObserver&&0===t&&(this._operationObserver=null),this._operationTargets.splice(this._getCommittedOperationTargetCount(t))}_restartDownstreamPlugin(){const t=null==this.analysis.observer,e=t?this._createObserverPluginConfiguration():this._createTargetPluginConfiguration();t&&h(this._downstreamPlugin)||!t&&m(this._downstreamPlugin)||this._context?.requestBeginDownstreamPlugin(e,{cancelExisting:!0})}_createObserverPluginConfiguration(t=null){return c({observer:t,defaultCaptureMode:t?"grabbable-object":"capture-always",inputMapPosition:t?.position??null})}_createTargetPluginConfiguration(t=null){return _({analysis:this.analysis,analysisViewData:this.analysisViewData,defaultCaptureMode:t?"grabbable-object":"capture-always",defaultElevationInfo:this.defaultElevationInfo,inputMapPosition:t?.position??null,sourceElevationInfo:this.sourceElevationInfo,target:t,view:this.view})}_syncAnalysisFromSession(){const t=this._getCommittedPointCount(),e=this._getCommittedOperationTargetCount(t);this.analysis.observer=this._getActiveObserver(t),y(this.analysis.targets,this._initialTargets.toArray().concat(this._operationTargets.toArray().slice(0,e)))}_getActiveObserver(t){return null!=this._initialObserver?this._operationObserver??null:t>0?this._operationObserver:null}_getCommittedOperationTargetCount(t){return Math.max(0,t-(null!=this._initialObserver?0:Math.min(t,1)))}_getCommittedPointCount(){const t=this._session?.generatePreviewGeometry({includeAutomaticConnection:!1,geometryType:"multipoint"});return t&&l(t)?t.points.length:0}};function v(t){return{uniqueId:Symbol("line-of-sight-root-plugin"),kind:["multipart"],geometryType:"multipoint",hidden:!0,localizationKey:"line-of-sight-root",icon:"point",create:()=>new d(t)}}function y(t,e){let i=-1;for(let s=0;s<Math.min(t.length,e.length);s++)if(t.getItemAt(s)!==e[s]){i=s;break}if(-1===i){if(t.length===e.length)return;i=Math.min(t.length,e.length)}t.splice(i,t.length-i,...e.slice(i))}t([r({constructOnly:!0})],d.prototype,"analysis",void 0),t([r({constructOnly:!0})],d.prototype,"analysisViewData",void 0),t([r({constructOnly:!0})],d.prototype,"view",void 0),t([r({constructOnly:!0})],d.prototype,"defaultElevationInfo",void 0),t([r({constructOnly:!0})],d.prototype,"sourceElevationInfo",void 0),t([r()],d.prototype,"_intersector",void 0),t([r()],d.prototype,"_downstreamPlugin",void 0),d=t([o("esri.views.3d.analysis.LineOfSight.LineOfSightRootPlugin")],d);export{d as LineOfSightRootPlugin,v as createLineOfSightRootPluginConfiguration};
2
+ import{__decorate as t}from"tslib";import e from"../../../../analysis/LineOfSightAnalysisObserver.js";import i from"../../../../analysis/LineOfSightAnalysisTarget.js";import s from"../../../../core/Collection.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import{property as n,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{isPoint as a,isMultipoint as l}from"../../../../geometry/support/typeUtils.js";import{updateLineOfSightItemFromAuthoredPoint as u}from"./LineOfSightAuthoringUtils.js";import{isLineOfSightObserverPlugin as h,createLineOfSightObserverPluginConfiguration as g}from"./LineOfSightObserverPlugin.js";import{isLineOfSightPlacementLeafPlugin as c}from"./LineOfSightPlacementLeafPlugin.js";import{LineOfSightRayIntersector as p}from"./LineOfSightRayIntersector.js";import{isLineOfSightTargetPlugin as m,createLineOfSightTargetPluginConfiguration as _}from"./LineOfSightTargetPlugin.js";import{PluginBase as y}from"../../../draw/plugins/PluginBase.js";let v=class extends y{constructor(){super(...arguments),this.observerElevationInfo=null,this.targetElevationInfo=null,this._intersector=null,this._downstreamPlugin=null,this._initialObserver=null,this._operationObserver=null,this._initialTargets=new s,this._operationTargets=new s}initialize(){this._intersector=new p({view:this.view})}destroy(){this._intersector=r(this._intersector)}start(t){super.start(t),this._initialObserver=this.analysis.observer,this._operationObserver=this._initialObserver,f(this._initialTargets,this.analysis.targets.toArray()),this._operationTargets.removeAll(),t.session.appendOrReplacePart(null,[]),this._syncAnalysisFromSession(),this._restartDownstreamPlugin()}beforeAttachPlugin(t){return{geometryType:"point",useStandaloneSession:!0}}beforeComplete(){return{downstreamPluginCompletionMode:"cancel"}}attachPlugin(t){this._downstreamPlugin=t}afterUndoRedo(){this._syncAnalysisFromSession(),this._restartDownstreamPlugin()}complete(){this._clearCursorTarget(),super.complete()}cancel(){this._clearCursorTarget()}detachPlugin(t,s){if(this._downstreamPlugin===t&&(this._downstreamPlugin=null),m(t)&&this._clearCursorTarget(),"complete"!==s)return void this._syncAnalysisFromSession();const r=this._context?.getSession(t)?.generatePreviewGeometry({includeAutomaticConnection:!1,geometryType:"point"});if(!r||!a(r))return this._syncAnalysisFromSession(),void this._restartDownstreamPlugin();this._truncateItemsToSession();const n=c(t)?t.preservedIntersection:null,o=!!c(t)&&t.usesSnappedAbsoluteHeight;if(h(t)){const i=t.observer??this._operationObserver??new e;if(!this._intersector||!u(this.view,i,this._intersector,r,{elevationInfo:this.observerElevationInfo,preservedIntersection:n,useSnappedAbsoluteHeight:o,preferPreservedIntersection:!0}))return this._syncAnalysisFromSession(),void this._restartDownstreamPlugin();this._operationObserver=i}else if(m(t)){const e=t.target??new i;if(!this._intersector||!u(this.view,e,this._intersector,r,{elevationInfo:this.targetElevationInfo,preservedIntersection:n,useSnappedAbsoluteHeight:o,preferPreservedIntersection:!0}))return this._syncAnalysisFromSession(),void this._restartDownstreamPlugin();this._operationTargets.add(e)}this._appendCommittedPoint(r),this._syncAnalysisFromSession(),this._restartDownstreamPlugin(),this._clearCursorTarget()}_appendCommittedPoint(t){const e=this._session;e&&(e.appendOrReplacePoint(null,t),e.appendOrReplacePart(null,[]),e.automaticRestart=!1,e.groupGeometryChanges())}_clearCursorTarget(){this.analysisViewData.cursorTarget=r(this.analysisViewData.cursorTarget)}_truncateItemsToSession(){const t=this._getCommittedPointCount();null==this._initialObserver&&0===t&&(this._operationObserver=null),this._operationTargets.splice(this._getCommittedOperationTargetCount(t))}_restartDownstreamPlugin(){const t=null==this.analysis.observer,e=t?this._createObserverPluginConfiguration():this._createTargetPluginConfiguration();t&&h(this._downstreamPlugin)||!t&&m(this._downstreamPlugin)||this._context?.requestBeginDownstreamPlugin(e,{cancelExisting:!0})}_createObserverPluginConfiguration(t=null){return g({observer:t,defaultCaptureMode:t?"grabbable-object":"capture-always",inputMapPosition:t?.position??null})}_createTargetPluginConfiguration(t=null){return _({analysis:this.analysis,analysisViewData:this.analysisViewData,defaultCaptureMode:t?"grabbable-object":"capture-always",elevationInfo:this.targetElevationInfo,inputMapPosition:t?.position??null,target:t,view:this.view})}_syncAnalysisFromSession(){const t=this._getCommittedPointCount(),e=this._getCommittedOperationTargetCount(t);this.analysis.observer=this._getActiveObserver(t),f(this.analysis.targets,this._initialTargets.toArray().concat(this._operationTargets.toArray().slice(0,e)))}_getActiveObserver(t){return null!=this._initialObserver?this._operationObserver??null:t>0?this._operationObserver:null}_getCommittedOperationTargetCount(t){return Math.max(0,t-(null!=this._initialObserver?0:Math.min(t,1)))}_getCommittedPointCount(){const t=this._session?.generatePreviewGeometry({includeAutomaticConnection:!1,geometryType:"multipoint"});return t&&l(t)?t.points.length:0}};function d(t){return{uniqueId:Symbol("line-of-sight-root-plugin"),kind:["multipart"],geometryType:"multipoint",hidden:!0,localizationKey:"line-of-sight-root",icon:"point",create:()=>new v(t)}}function f(t,e){let i=-1;for(let s=0;s<Math.min(t.length,e.length);s++)if(t.getItemAt(s)!==e[s]){i=s;break}if(-1===i){if(t.length===e.length)return;i=Math.min(t.length,e.length)}t.splice(i,t.length-i,...e.slice(i))}t([n({constructOnly:!0})],v.prototype,"analysis",void 0),t([n({constructOnly:!0})],v.prototype,"analysisViewData",void 0),t([n({constructOnly:!0})],v.prototype,"view",void 0),t([n({constructOnly:!0})],v.prototype,"observerElevationInfo",void 0),t([n({constructOnly:!0})],v.prototype,"targetElevationInfo",void 0),t([n()],v.prototype,"_intersector",void 0),t([n()],v.prototype,"_downstreamPlugin",void 0),v=t([o("esri.views.3d.analysis.LineOfSight.LineOfSightRootPlugin")],v);export{v as LineOfSightRootPlugin,d as createLineOfSightRootPluginConfiguration};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../../../analysis/LineOfSightAnalysisTarget.js";import{destroyMaybe as i}from"../../../../core/maybe.js";import{watch as s,sync as o}from"../../../../core/reactiveUtils.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{updateLineOfSightItemFromIntersection as a,updateLineOfSightItemFromAuthoredPoint as l}from"./LineOfSightAuthoringUtils.js";import{LineOfSightRayIntersector as u}from"./LineOfSightRayIntersector.js";import{PluginBase as p}from"../../../draw/plugins/PluginBase.js";var c;const d=Symbol("line-of-sight-target-vertex"),h=Symbol("line-of-sight-target-plugin-marker");let v=class extends p{constructor(){super(...arguments),this[c]=!0,this.target=null,this.defaultElevationInfo=null,this.defaultCaptureMode="capture-always",this.inputMapPosition=null,this.preservedIntersection=null,this.sourceElevationInfo=null,this._interactiveHandle=null,this._intersector=null}static{c=h}initialize(){this._intersector=new u({view:this.view})}destroy(){this._intersector=i(this._intersector)}get usesSnappedAbsoluteHeight(){const t=this._interactiveHandle,e=t?.inputMapPosition,i=t?.outputMapPosition;return null!=e&&null!=i&&!e.equals(i)}start(t){super.start(t),this.preservedIntersection=null;const{positionOfLastUserInput:n,session:r}=t,u="grabbable-object"===this.defaultCaptureMode?this.inputMapPosition??this._interactiveHandle?.outputMapPosition??n:this.inputMapPosition??n;!u||"grabbable-object"!==this.defaultCaptureMode&&this._interactiveHandle||r.appendOrReplacePoint(d,u);let p="capture-always"===this.defaultCaptureMode&&null!=u;this._interactiveHandle&&this._clearCursorTarget(),this._interactiveHandle||(this._interactiveHandle=t.createInteractiveHandle({defaultCaptureMode:this.defaultCaptureMode,inputMapPosition:"grabbable-object"===this.defaultCaptureMode?u??void 0:void 0}),this.addHandles(s(()=>this._interactiveHandle?.outputMapPosition,t=>{if(!t||this._isComplete)return;const s=this.analysisViewData.cursorTarget??new e,o=this.usesSnappedAbsoluteHeight,n=this._interactiveHandle?.screenPosition,r=n&&this._intersector?this._intersector.getScreenPointIntersection(n):null;return this._session?.appendOrReplacePoint(d,t),p?(p=!1,void this._clearCursorTarget()):null!=r?(this.analysisViewData.cursorTarget=s,void a(this.view,s,r,{snappedMapPoint:t,defaultElevationInfo:this.defaultElevationInfo,sourceElevationInfo:this.sourceElevationInfo,useSnappedAbsoluteHeight:o})):null!=n&&null!=this.preservedIntersection?(this.analysisViewData.cursorTarget=s,void a(this.view,s,this.preservedIntersection,{snappedMapPoint:t,defaultElevationInfo:this.defaultElevationInfo,sourceElevationInfo:this.sourceElevationInfo,useSnappedAbsoluteHeight:o})):void(null==n&&this._intersector&&l(this.view,s,this._intersector,t,{defaultElevationInfo:this.defaultElevationInfo,sourceElevationInfo:this.sourceElevationInfo,preservedIntersection:this.preservedIntersection,useSnappedAbsoluteHeight:o,preferPreservedIntersection:!0})?this.analysisViewData.cursorTarget=s:this.analysisViewData.cursorTarget=i(this.analysisViewData.cursorTarget))},o),this._ownHandlesKey))}complete(){this._clearCursorTarget(),super.complete()}cancel(){this._clearCursorTarget()}_clearCursorTarget(){this.analysisViewData.cursorTarget=i(this.analysisViewData.cursorTarget)}};function f(t){return!!t&&h in t}function g(t){return{uniqueId:Symbol("line-of-sight-target-plugin"),kind:["vertex"],geometryType:"point",hidden:!0,localizationKey:"leaf-point-segment",icon:"point",create:()=>new v(t)}}t([n({constructOnly:!0})],v.prototype,"analysis",void 0),t([n({constructOnly:!0})],v.prototype,"analysisViewData",void 0),t([n({constructOnly:!0})],v.prototype,"view",void 0),t([n({constructOnly:!0})],v.prototype,"target",void 0),t([n({constructOnly:!0})],v.prototype,"defaultElevationInfo",void 0),t([n()],v.prototype,"defaultCaptureMode",void 0),t([n()],v.prototype,"inputMapPosition",void 0),t([n()],v.prototype,"preservedIntersection",void 0),t([n({constructOnly:!0})],v.prototype,"sourceElevationInfo",void 0),t([n()],v.prototype,"_interactiveHandle",void 0),t([n()],v.prototype,"_intersector",void 0),v=t([r("esri.views.3d.analysis.LineOfSight.LineOfSightTargetPlugin")],v);export{v as LineOfSightTargetPlugin,g as createLineOfSightTargetPluginConfiguration,f as isLineOfSightTargetPlugin,h as lineOfSightTargetPluginMarker};
2
+ import{__decorate as t}from"tslib";import e from"../../../../analysis/LineOfSightAnalysisTarget.js";import{destroyMaybe as i}from"../../../../core/maybe.js";import{watch as s,sync as r}from"../../../../core/reactiveUtils.js";import{property as o,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{updateLineOfSightItemFromIntersection as a,updateLineOfSightItemFromAuthoredPoint as l}from"./LineOfSightAuthoringUtils.js";import{LineOfSightRayIntersector as p}from"./LineOfSightRayIntersector.js";import{PluginBase as u}from"../../../draw/plugins/PluginBase.js";var c;const d=Symbol("line-of-sight-target-vertex"),h=Symbol("line-of-sight-target-plugin-marker");let v=class extends u{constructor(){super(...arguments),this[c]=!0,this.target=null,this.elevationInfo=null,this.defaultCaptureMode="capture-always",this.inputMapPosition=null,this.preservedIntersection=null,this._interactiveHandle=null,this._intersector=null}static{c=h}initialize(){this._intersector=new p({view:this.view})}destroy(){this._intersector=i(this._intersector)}get usesSnappedAbsoluteHeight(){const t=this._interactiveHandle,e=t?.inputMapPosition,i=t?.outputMapPosition;return null!=e&&null!=i&&!e.equals(i)}start(t){super.start(t),this.preservedIntersection=null;const{positionOfLastUserInput:o,session:n}=t,p="grabbable-object"===this.defaultCaptureMode?this.inputMapPosition??this._interactiveHandle?.outputMapPosition??o:this.inputMapPosition??o;!p||"grabbable-object"!==this.defaultCaptureMode&&this._interactiveHandle||n.appendOrReplacePoint(d,p);let u="capture-always"===this.defaultCaptureMode&&null!=p;this._interactiveHandle&&this._clearCursorTarget(),this._interactiveHandle||(this._interactiveHandle=t.createInteractiveHandle({defaultCaptureMode:this.defaultCaptureMode,inputMapPosition:"grabbable-object"===this.defaultCaptureMode?p??void 0:void 0}),this.addHandles(s(()=>this._interactiveHandle?.outputMapPosition,t=>{if(!t||this._isComplete)return;const s=this.analysisViewData.cursorTarget??new e,r=this.usesSnappedAbsoluteHeight,o=this._interactiveHandle?.screenPosition,n=o&&this._intersector?this._intersector.getScreenPointIntersection(o):null;return this._session?.appendOrReplacePoint(d,t),u?(u=!1,void this._clearCursorTarget()):null!=n?(this.analysisViewData.cursorTarget=s,void a(this.view,s,n,{snappedMapPoint:t,elevationInfo:this.elevationInfo,useSnappedAbsoluteHeight:r})):null!=o&&null!=this.preservedIntersection?(this.analysisViewData.cursorTarget=s,void a(this.view,s,this.preservedIntersection,{snappedMapPoint:t,elevationInfo:this.elevationInfo,useSnappedAbsoluteHeight:r})):void(null==o&&this._intersector&&l(this.view,s,this._intersector,t,{elevationInfo:this.elevationInfo,preservedIntersection:this.preservedIntersection,useSnappedAbsoluteHeight:r,preferPreservedIntersection:!0})?this.analysisViewData.cursorTarget=s:this.analysisViewData.cursorTarget=i(this.analysisViewData.cursorTarget))},r),this._ownHandlesKey))}complete(){this._clearCursorTarget(),super.complete()}cancel(){this._clearCursorTarget()}_clearCursorTarget(){this.analysisViewData.cursorTarget=i(this.analysisViewData.cursorTarget)}};function g(t){return!!t&&h in t}function y(t){return{uniqueId:Symbol("line-of-sight-target-plugin"),kind:["vertex"],geometryType:"point",hidden:!0,localizationKey:"leaf-point-segment",icon:"point",create:()=>new v(t)}}t([o({constructOnly:!0})],v.prototype,"analysis",void 0),t([o({constructOnly:!0})],v.prototype,"analysisViewData",void 0),t([o({constructOnly:!0})],v.prototype,"view",void 0),t([o({constructOnly:!0})],v.prototype,"target",void 0),t([o({constructOnly:!0})],v.prototype,"elevationInfo",void 0),t([o()],v.prototype,"defaultCaptureMode",void 0),t([o()],v.prototype,"inputMapPosition",void 0),t([o()],v.prototype,"preservedIntersection",void 0),t([o()],v.prototype,"_interactiveHandle",void 0),t([o()],v.prototype,"_intersector",void 0),v=t([n("esri.views.3d.analysis.LineOfSight.LineOfSightTargetPlugin")],v);export{v as LineOfSightTargetPlugin,y as createLineOfSightTargetPluginConfiguration,g as isLineOfSightTargetPlugin,h as lineOfSightTargetPluginMarker};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{makeHandle as e}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import{watch as i,syncAndInitial as s}from"../../../../core/reactiveUtils.js";import{property as o,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{LineOfSightPlacementController as n}from"./LineOfSightPlacementController.js";import{LineOfSightRayIntersector as r}from"./LineOfSightRayIntersector.js";import{LineOfSightReshapeTool3D as l}from"./LineOfSightReshapeTool3D.js";import{ExclusiveOperationManager as h}from"../../../analysis/ExclusiveOperationManager.js";import{ViewEventPriorities as c}from"../../../input/InputManager.js";import{AnalysisToolBase as p}from"../../../interactive/AnalysisToolBase.js";import{deactivevateTool as v}from"../../../interactive/interactiveToolUtils.js";import{sketchKeys as d}from"../../../interactive/keybindings.js";const y={ready:"ready",creating:"creating",created:"created"};let _=class extends p{constructor(t){super(t),this._operationManager=new h,this._syncingActiveTool=!1,this.analysisViewData=null,this.removeIncompleteOnCancel=!1,this._reshapeIntersector=new r({view:t.view}),this._reshapeTool=new l({analysis:t.analysis,analysisViewData:t.analysisViewData,intersector:this._reshapeIntersector,view:t.view}),this._placementController=new n({...t,parent:this,shouldPreventVertexAdd:(t,e)=>this._reshapeTool.hasManipulatorAt(t,e)})}get active(){return this._reshapeTool.active||this._placementController.active}get canRedo(){return this._activeUndoRedoComponent?.canRedo??!1}get canUndo(){return this._activeUndoRedoComponent?.canUndo??!1}get state(){return this._placementController.active?y.creating:null!=this.analysis.observer?.position?y.created:y.ready}get cursor(){return this._placementController.active?"crosshair":null}get updating(){return this._reshapeTool.updating||this._placementController.updating}initialize(){this.addHandles([this.view.on("key-down",t=>this._onKeyDown(t),c.WIDGET),i(()=>({editable:this.editable,interactive:this.analysisViewData.interactive,placementActive:this._placementController.active,valid:this.analysis.valid,visible:this.visible}),()=>this._syncActiveTool(),s),i(()=>this.state===y.created,t=>{t?this.finishToolCreation():this._set("created",!1)},s),i(()=>this.analysisViewData.visible,t=>{this.visible=t},s),i(()=>{const{analysis:t}=this,{observer:e,targets:i}=t;return{observer:e,observerPosition:e?.position,observerElevationInfo:e?.elevationInfo,observerFeature:e?.feature,targets:i.toArray().map(t=>[t,t.position,t.elevationInfo,t.feature])}},()=>this._syncItemsFromAnalysis(),s),i(()=>this.editable,t=>{this.analysisViewData.editable=t},s)])}destroy(){this._operationManager.destroy(),this._reshapeTool.stop(),this._placementController.stop(),this._reshapeTool.destroy(),this._placementController.destroy(),this._reshapeIntersector.destroy()}place(t){return this.analysisViewData.interactive=!0,this._operationManager.start("place",async(t,o)=>{const a=this.analysis.clone();let n=!1,r=!1;const l=()=>{if(!r){if(r=!0,this.stop(),!this.analysis.valid)return this.analysis.clear(),void t.reject();o.aborted||this.analysis.equals(a)?t.reject():t.resolve({})}};t.handles.push(e(()=>this.stop()),i(()=>this._placementController.active,t=>{t?n=!0:n&&l()},s)),this.continue()},t)}activate(){this.view.focus(),this.analysisViewData.interactive=!0,this._syncActiveTool(),this.analysis.valid||this._placementController.active||this.continue()}deactivate(){this.onDeactivate()}continue(){this.analysisViewData.interactive=!0,this._placementController.continue()}stop(){this._placementController.stop(),this._placementController.placementElevationInfo=null,this._syncActiveTool()}redo(){this._activeUndoRedoComponent?.redo()}undo(){this._activeUndoRedoComponent?.undo()}get testInfo(){}onEditableChange(){this.analysisViewData.editable=this.editable,this._reshapeTool.setEditableFlag(1,!0),this._reshapeTool.setEditableFlag(0,this.editable),this._syncActiveTool()}_hideReshapeTool(){this._reshapeTool.stop(),this._reshapeTool.visible=!1}_onKeyDown(t){const e=t.key;e===d.undo&&this.canUndo?(t.stopPropagation(),this.undo()):e===d.redo&&this.canRedo?(t.stopPropagation(),this.redo()):e===d.cancel&&!this.active&&this._reshapeTool.hasSelection&&this._reshapeTool.clearSelection()}get _activeUndoRedoComponent(){return this.analysisViewData.interactive?this._placementController.active||!this._canActivateReshapeTool?this._placementController.active?this._placementController:null:this._reshapeTool:null}get _canActivateReshapeTool(){return this.visible&&this.editable&&this.analysis.valid&&null!=this.analysis.observer?.position}_syncActiveTool(){if(!this._syncingActiveTool){this._syncingActiveTool=!0;try{const t=this.analysisViewData.interactive,e=this._canActivateReshapeTool;if(this._placementController.visible=this.visible&&t,this._reshapeTool.isParentToolInteracting=t&&this._placementController.active,!t)return this._placementController.stop(),this._hideReshapeTool(),this.analysisViewData.cursorTarget=null,void v(this.view,this);if(this._placementController.active)return this._reshapeTool.stop(),this._reshapeTool.visible=this.visible,void v(this.view,this);if(!e)return this._hideReshapeTool(),void v(this.view,this);if(this._reshapeTool.visible=!0,this.analysisViewData.cursorTarget=null,!this._reshapeTool.active&&!this._reshapeTool.hasSelection){const t=this.analysis.targets.at(-1);null!=t&&this._reshapeTool.applySelection({type:"target",target:t})}v(this.view,this)}finally{this._syncingActiveTool=!1}}}_syncItemsFromAnalysis(){this._syncActiveTool()}};t([o({constructOnly:!0})],_.prototype,"view",void 0),t([o({constructOnly:!0})],_.prototype,"analysis",void 0),t([o({constructOnly:!0})],_.prototype,"analysisViewData",void 0),t([o()],_.prototype,"active",null),t([o()],_.prototype,"canRedo",null),t([o()],_.prototype,"canUndo",null),t([o()],_.prototype,"state",null),t([o()],_.prototype,"cursor",null),t([o()],_.prototype,"updating",null),t([o()],_.prototype,"removeIncompleteOnCancel",void 0),t([o()],_.prototype,"_canActivateReshapeTool",null),_=t([a("esri.views.3d.analysis.LineOfSight.LineOfSightTool2")],_);export{_ as LineOfSightTool2};
2
+ import{__decorate as e}from"tslib";import{makeHandle as t}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import{watch as i,syncAndInitial as s}from"../../../../core/reactiveUtils.js";import{property as o,subclass as a}from"../../../../core/accessorSupport/decorators.js";import n from"../../../../symbols/support/ElevationInfo.js";import{LineOfSightPlacementController as r}from"./LineOfSightPlacementController.js";import{LineOfSightRayIntersector as l}from"./LineOfSightRayIntersector.js";import{LineOfSightReshapeTool3D as h}from"./LineOfSightReshapeTool3D.js";import{ExclusiveOperationManager as c}from"../../../analysis/ExclusiveOperationManager.js";import{ViewEventPriorities as p}from"../../../input/InputManager.js";import{AnalysisToolBase as v}from"../../../interactive/AnalysisToolBase.js";import{deactivevateTool as d}from"../../../interactive/interactiveToolUtils.js";import{sketchKeys as y}from"../../../interactive/keybindings.js";const _={ready:"ready",creating:"creating",created:"created"};let u=class extends v{constructor(e){super(e),this._operationManager=new c,this._syncingActiveTool=!1,this.analysisViewData=null,this.removeIncompleteOnCancel=!1,this._reshapeIntersector=new l({view:e.view}),this._reshapeTool=new h({analysis:e.analysis,analysisViewData:e.analysisViewData,intersector:this._reshapeIntersector,view:e.view}),this._placementController=new r({...e,parent:this,shouldPreventVertexAdd:(e,t)=>this._reshapeTool.hasManipulatorAt(e,t)})}get active(){return this._reshapeTool.active||this._placementController.active}get canRedo(){return this._activeUndoRedoComponent?.canRedo??!1}get canUndo(){return this._activeUndoRedoComponent?.canUndo??!1}get state(){return this._placementController.active?_.creating:null!=this.analysis.observer?.position?_.created:_.ready}get cursor(){return this._placementController.active?"crosshair":null}get updating(){return this._reshapeTool.updating||this._placementController.updating}initialize(){this.addHandles([this.view.on("key-down",e=>this._onKeyDown(e),p.WIDGET),i(()=>({editable:this.editable,interactive:this.analysisViewData.interactive,placementActive:this._placementController.active,valid:this.analysis.valid,visible:this.visible}),()=>this._syncActiveTool(),s),i(()=>this.state===_.created,e=>{e?this.finishToolCreation():this._set("created",!1)},s),i(()=>this.analysisViewData.visible,e=>{this.visible=e},s),i(()=>{const{analysis:e}=this,{observer:t,targets:i}=e;return{observer:t,observerPosition:t?.position,observerElevationInfo:t?.elevationInfo,observerFeature:t?.feature,targets:i.toArray().map(e=>[e,e.position,e.elevationInfo,e.feature])}},()=>this._syncItemsFromAnalysis(),s),i(()=>this.editable,e=>{this.analysisViewData.editable=e},s)])}destroy(){this._operationManager.destroy(),this._reshapeTool.stop(),this._placementController.stop(),this._reshapeTool.destroy(),this._placementController.destroy(),this._reshapeIntersector.destroy()}place(e){return this.analysisViewData.interactive=!0,this._operationManager.start("place",async(o,a)=>{const{elevationInfo:n}=e??{},r=n&&"observer"in n?n.observer:n,l=n&&"targets"in n?n.targets:n;this._placementController.observerPlacementElevationInfo=m(r),this._placementController.targetPlacementElevationInfo=m(l);const h=this.analysis.clone();let c=!1,p=!1;const v=()=>{if(!p){if(p=!0,this.stop(),!this.analysis.valid)return this.analysis.clear(),void o.reject();a.aborted||this.analysis.equals(h)?o.reject():o.resolve({})}};o.handles.push(t(()=>this.stop()),i(()=>this._placementController.active,e=>{e?c=!0:c&&v()},s)),this.continue()},e)}activate(){this.view.focus(),this.analysisViewData.interactive=!0,this._syncActiveTool(),this.analysis.valid||this._placementController.active||this.continue()}deactivate(){this.onDeactivate()}continue(){this.analysisViewData.interactive=!0,this._placementController.continue()}stop(){this._placementController.stop(),this._placementController.observerPlacementElevationInfo=null,this._placementController.targetPlacementElevationInfo=null,this._syncActiveTool()}redo(){this._activeUndoRedoComponent?.redo()}undo(){this._activeUndoRedoComponent?.undo()}get testInfo(){}onEditableChange(){this.analysisViewData.editable=this.editable,this._reshapeTool.setEditableFlag(1,!0),this._reshapeTool.setEditableFlag(0,this.editable),this._syncActiveTool()}_hideReshapeTool(){this._reshapeTool.stop(),this._reshapeTool.visible=!1}_onKeyDown(e){const t=e.key;t===y.undo&&this.canUndo?(e.stopPropagation(),this.undo()):t===y.redo&&this.canRedo?(e.stopPropagation(),this.redo()):t===y.cancel&&!this.active&&this._reshapeTool.hasSelection&&this._reshapeTool.clearSelection()}get _activeUndoRedoComponent(){return this.analysisViewData.interactive?this._placementController.active||!this._canActivateReshapeTool?this._placementController.active?this._placementController:null:this._reshapeTool:null}get _canActivateReshapeTool(){return this.visible&&this.editable&&this.analysis.valid&&null!=this.analysis.observer?.position}_syncActiveTool(){if(!this._syncingActiveTool){this._syncingActiveTool=!0;try{const e=this.analysisViewData.interactive,t=this._canActivateReshapeTool;if(this._placementController.visible=this.visible&&e,this._reshapeTool.isParentToolInteracting=e&&this._placementController.active,!e)return this._placementController.stop(),this._hideReshapeTool(),this.analysisViewData.cursorTarget=null,void d(this.view,this);if(this._placementController.active)return this._reshapeTool.stop(),this._reshapeTool.visible=this.visible,void d(this.view,this);if(!t)return this._hideReshapeTool(),void d(this.view,this);if(this._reshapeTool.visible=!0,this.analysisViewData.cursorTarget=null,!this._reshapeTool.active&&!this._reshapeTool.hasSelection){const e=this.analysis.targets.at(-1);null!=e&&this._reshapeTool.applySelection({type:"target",target:e})}d(this.view,this)}finally{this._syncingActiveTool=!1}}}_syncItemsFromAnalysis(){this._syncActiveTool()}};function m(e){if(null==e)return null;const{featureExpressionInfo:t,mode:i,offset:s,unit:o}=e;return new n({featureExpressionInfo:t,mode:i,offset:s,unit:o})}e([o({constructOnly:!0})],u.prototype,"view",void 0),e([o({constructOnly:!0})],u.prototype,"analysis",void 0),e([o({constructOnly:!0})],u.prototype,"analysisViewData",void 0),e([o()],u.prototype,"active",null),e([o()],u.prototype,"canRedo",null),e([o()],u.prototype,"canUndo",null),e([o()],u.prototype,"state",null),e([o()],u.prototype,"cursor",null),e([o()],u.prototype,"updating",null),e([o()],u.prototype,"removeIncompleteOnCancel",void 0),e([o()],u.prototype,"_canActivateReshapeTool",null),u=e([a("esri.views.3d.analysis.LineOfSight.LineOfSightTool2")],u);export{u as LineOfSightTool2};
@@ -3,6 +3,34 @@
3
3
  *
4
4
  * @since 5.0
5
5
  */
6
+ import type ElevationInfo from "../../../../symbols/support/ElevationInfo.js";
7
+ import type { AbortOptions } from "../../../../core/promiseUtils.js";
8
+ import type { ElevationInfoProperties } from "../../../../symbols/support/ElevationInfo.js";
9
+
10
+ /**
11
+ * Elevation information used when placing a line-of-sight analysis interactively.
12
+ *
13
+ * @since 5.2
14
+ */
15
+ export type LineOfSightPlacementElevationInfo = ElevationInfo | ElevationInfoProperties | {
16
+ observer: ElevationInfo | ElevationInfoProperties;
17
+ targets: ElevationInfo | ElevationInfoProperties;
18
+ };
19
+
20
+ /**
21
+ * Options for placing a line of sight analysis interactively.
22
+ *
23
+ * @since 5.2
24
+ */
25
+ export interface LineOfSightPlacementOptions extends AbortOptions {
26
+ /**
27
+ * Specifies how placed items are positioned on the vertical axis (z). A single elevation information object applies
28
+ * to both the observer and targets. Alternatively, separate elevation information can be provided for each.
29
+ *
30
+ * @since 5.2
31
+ */
32
+ elevationInfo?: LineOfSightPlacementElevationInfo | null;
33
+ }
6
34
 
7
35
  /** @since 5.0 */
8
36
  export interface LineOfSightPlacementResult {}
@@ -2,8 +2,7 @@ import type LineOfSightAnalysis from "../../../analysis/LineOfSightAnalysis.js";
2
2
  import type Collection from "../../../core/Collection.js";
3
3
  import type AnalysisView3D from "./AnalysisView3D.js";
4
4
  import type LineOfSightAnalysisResult from "./LineOfSightAnalysisResult.js";
5
- import type { AbortOptions } from "../../../core/promiseUtils.js";
6
- import type { LineOfSightPlacementResult } from "./LineOfSight/types.js";
5
+ import type { LineOfSightPlacementOptions, LineOfSightPlacementResult } from "./LineOfSight/types.js";
7
6
 
8
7
  /**
9
8
  * Represents the analysis view of a [LineOfSightAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/LineOfSightAnalysis/)
@@ -109,15 +108,16 @@ export default abstract class LineOfSightAnalysisView3D extends AnalysisView3D {
109
108
  * const abortController = new AbortController();
110
109
  *
111
110
  * try {
112
- * await analysisView.place({ signal: abortController.signal });
111
+ * await analysisView.place({
112
+ * elevationInfo: { mode: "relative-to-ground", offset: 2 },
113
+ * signal: abortController.signal
114
+ * });
113
115
  * } catch (error) {
114
- * if (error.name === "AbortError") {
115
- * console.log("Placement operation was cancelled.");
116
- * }
116
+ * // handle error
117
117
  * }
118
118
  *
119
119
  * // cancel the placement operation at some later point
120
120
  * abortController.abort();
121
121
  */
122
- place(options?: AbortOptions | null | undefined): Promise<LineOfSightPlacementResult>;
122
+ place(options?: LineOfSightPlacementOptions | null | undefined): Promise<LineOfSightPlacementResult>;
123
123
  }
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{Manipulator3D as a}from"../../Manipulator3D.js";class t{constructor(){this._available=!0}set location(a){this._forEachManipulator3D(t=>t.location=a)}set elevationAlignedLocation(a){this._forEachManipulator3D(t=>t.elevationAlignedLocation=a)}set elevationInfo(a){this._forEachManipulator3D(t=>t.elevationInfo=a)}get renderLocation(){let a;return this._forEachManipulator3D(t=>{a||(a=t.renderLocation)}),a}set renderLocation(a){this._forEachManipulator3D(t=>t.renderLocation=a)}get available(){return this._available}set available(a){this._available=a,this._forEachManipulator3D(t=>t.available=a)}get hovering(){return this.someManipulator(a=>a.hovering)}get grabbing(){return this.someManipulator(a=>a.grabbing)}get dragging(){return this.someManipulator(a=>a.dragging)}get selected(){return this.someManipulator(a=>a.selected)}hasManipulator(a){return this.someManipulator(t=>t===a)}someManipulator(a){let t=!1;return this.forEachManipulator(o=>{!t&&a(o)&&(t=!0)}),t}_forEachManipulator3D(t){this.forEachManipulator((o,e)=>{o instanceof a&&t(o,e)})}}export{t as Manipulation};
2
+ import{isSome as a}from"../../../../../core/arrayUtils.js";import{handlesGroup as t}from"../../../../../core/handleUtils.js";import{Manipulator3D as r}from"../../Manipulator3D.js";class i{constructor(){this._available=!0}set location(a){this._forEachManipulator3D(t=>t.location=a)}set elevationAlignedLocation(a){this._forEachManipulator3D(t=>t.elevationAlignedLocation=a)}set elevationInfo(a){this._forEachManipulator3D(t=>t.elevationInfo=a)}get renderLocation(){let a;return this._forEachManipulator3D(t=>{a||(a=t.renderLocation)}),a}set renderLocation(a){this._forEachManipulator3D(t=>t.renderLocation=a)}get available(){return this._available}set available(a){this._available=a,this._forEachManipulator3D(t=>t.available=a)}get hovering(){return this.someManipulator(a=>a.hovering)}get grabbing(){return this.someManipulator(a=>a.grabbing)}get dragging(){return this.someManipulator(a=>a.dragging)}get selected(){return this.someManipulator(a=>a.selected)}hasManipulator(a){return this.someManipulator(t=>t===a)}someManipulator(a){let t=!1;return this.forEachManipulator(r=>{!t&&a(r)&&(t=!0)}),t}hideManipulators(){return this._hideManipulators()}hideManipulatorsExceptGrabbedGroup(){return this._hideManipulators(this.mapManipulators((a,t)=>a.grabbing?t:null).filter(a))}_hideManipulators(a){const r=new Set(a);return t(this.mapManipulators((a,t)=>r.has(t)?null:a.disableDisplay?.()))}_forEachManipulator3D(a){this.forEachManipulator((t,i)=>{t instanceof r&&a(t,i)})}mapManipulators(a){const t=[];return this.forEachManipulator((r,i)=>{t.push(a(r,i))}),t}}export{i as Manipulation};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import i from"../../../../../core/Handles.js";import{handlesGroup as a}from"../../../../../core/handleUtils.js";import has from"../../../../../core/has.js";import{when as t}from"../../../../../core/reactiveUtils.js";import{discRadiusSmall as n,discRadius as e}from"./config.js";import{InteractiveManipulation as s}from"./InteractiveManipulation.js";import{MoveXYAxisManipulation as o}from"./MoveXYAxisManipulation.js";import{MoveXYDiscManipulation as l}from"./MoveXYDiscManipulation.js";import{MoveZManipulation as r}from"./MoveZManipulation.js";class p extends s{constructor(a){super(),this._handles=new i;const{tool:t,view:n,snapToScene:e,radius:s}=a;this._view=n,this.xyManipulation=new l({tool:t,view:n,snapToScene:e,radius:s}),this.xyAxisManipulation=new o({tool:t,view:n,radius:s}),this.zManipulation=new r({tool:t,view:n,radius:s}),this.xyManipulation.available=a.xyAvailable,this.xyAxisManipulation.available=a.xyAxisAvailable,this.zManipulation.available=a.zAvailable,this._autoHideXYAxis(),this.forEachManipulator(i=>this._handles.add(i.events.on("grab-changed",()=>this._updateManipulatorInteractivity())))}destroy(){this._handles.destroy(),this.xyManipulation.destroy(),this.xyAxisManipulation.destroy(),this.zManipulation.destroy()}createManipulatedObjectDragPipeline(i,t,n){return a([this.xyManipulation.createManipulatedObjectDragPipeline((a,t,n,e,s)=>i(0,a,t,n,e,s),t,n),this.xyAxisManipulation.createManipulatedObjectDragPipeline((a,t,n,e,s)=>i(1,a,t,n,e,s),t,n),this.zManipulation.createManipulatedObjectDragPipeline((a,t,n,e,s)=>i(2,a,t,n,e,s),t,n)])}createDragPipeline(i,t,n,e){return a([this.xyManipulation.createDragPipeline((a,t,n,e,s)=>i(0,a,t,n,e,s),t,n,e),this.xyAxisManipulation.createDragPipeline((a,t,n,e,s)=>i(1,a,t,n,e,s),t,n,e),this.zManipulation.createDragPipeline((a,t,n,e,s)=>i(2,a,t,n,e,s),n)])}set snapToScene(i){this.xyManipulation.snapToScene=i}set angle(i){this.xyAxisManipulation.angle=i}set radius(i){this.xyAxisManipulation.radius=i,this.xyManipulation.radius=i,this.zManipulation.radius=i}set displayScale(i){this.xyManipulation.displayScale=i,this.xyAxisManipulation.displayScale=i}forEachManipulator(i){this.xyManipulation.forEachManipulator(a=>i(a,1)),this.xyAxisManipulation.forEachManipulator(a=>i(a,1)),this.zManipulation.forEachManipulator(a=>i(a,0))}get _xyAxisVisible(){const i=this.xyManipulation.someManipulator(i=>i.focused)||this.xyAxisManipulation.someManipulator(i=>i.focused);return this._view.inputManager&&"touch"===this._view.inputManager.latestPointerInfo?.type||i}_autoHideXYAxis(){const i=this.xyAxisManipulation,a=this.xyManipulation;if(has("esri-mobile"))return;const n=[];a.forEachManipulator(i=>n.push(i)),i.forEachManipulator(i=>n.push(i));const e=()=>{const a=[];this._xyAxisVisible||i.forEachManipulator(i=>a.push(i.disableDisplay())),this._handles.remove(u),this._handles.add(a,u)};for(const t of n)this._handles.add(t.events.on("focus-changed",e));this._view.inputManager&&this._handles.add(t(()=>this._view.inputManager?.latestPointerInfo?.type,e)),e()}static radiusForSymbol(i){const a=null!=i&&"point-3d"===i.type&&i.symbolLayers;return!!a&&a.some(i=>"icon"===i.type)?n:e}}const u="disable-xy-axis-display";export{p as MoveManipulation};
2
+ import i from"../../../../../core/Handles.js";import{handlesGroup as a}from"../../../../../core/handleUtils.js";import has from"../../../../../core/has.js";import{when as t}from"../../../../../core/reactiveUtils.js";import{discRadiusSmall as n,discRadius as e}from"./config.js";import{InteractiveManipulation as s}from"./InteractiveManipulation.js";import{MoveXYAxisManipulation as o}from"./MoveXYAxisManipulation.js";import{MoveXYDiscManipulation as l}from"./MoveXYDiscManipulation.js";import{MoveZManipulation as r}from"./MoveZManipulation.js";class p extends s{constructor(a){super(),this._handles=new i;const{tool:t,view:n,snapToScene:e,radius:s}=a;this._view=n,this.xyManipulation=new l({tool:t,view:n,snapToScene:e,radius:s}),this.xyAxisManipulation=new o({tool:t,view:n,radius:s}),this.zManipulation=new r({tool:t,view:n,radius:s}),this.xyManipulation.available=a.xyAvailable,this.xyAxisManipulation.available=a.xyAxisAvailable,this.zManipulation.available=a.zAvailable,this._autoHideXYAxis(),this.forEachManipulator(i=>this._handles.add(i.events.on("grab-changed",()=>{this._updateManipulatorInteractivity(),this._updateManipulatorDisplay()})))}destroy(){this._handles.destroy(),this.xyManipulation.destroy(),this.xyAxisManipulation.destroy(),this.zManipulation.destroy()}createManipulatedObjectDragPipeline(i,t,n){return a([this.xyManipulation.createManipulatedObjectDragPipeline((a,t,n,e,s)=>i(0,a,t,n,e,s),t,n),this.xyAxisManipulation.createManipulatedObjectDragPipeline((a,t,n,e,s)=>i(1,a,t,n,e,s),t,n),this.zManipulation.createManipulatedObjectDragPipeline((a,t,n,e,s)=>i(2,a,t,n,e,s),t,n)])}createDragPipeline(i,t,n,e){return a([this.xyManipulation.createDragPipeline((a,t,n,e,s)=>i(0,a,t,n,e,s),t,n,e),this.xyAxisManipulation.createDragPipeline((a,t,n,e,s)=>i(1,a,t,n,e,s),t,n,e),this.zManipulation.createDragPipeline((a,t,n,e,s)=>i(2,a,t,n,e,s),n)])}set snapToScene(i){this.xyManipulation.snapToScene=i}set angle(i){this.xyAxisManipulation.angle=i}set radius(i){this.xyAxisManipulation.radius=i,this.xyManipulation.radius=i,this.zManipulation.radius=i}set displayScale(i){this.xyManipulation.displayScale=i,this.xyAxisManipulation.displayScale=i}forEachManipulator(i){this.xyManipulation.forEachManipulator(a=>i(a,1)),this.xyAxisManipulation.forEachManipulator(a=>i(a,1)),this.zManipulation.forEachManipulator(a=>i(a,0))}get _xyAxisVisible(){const i=this.xyManipulation.someManipulator(i=>i.focused)||this.xyAxisManipulation.someManipulator(i=>i.focused);return this._view.inputManager&&"touch"===this._view.inputManager.latestPointerInfo?.type||i}_autoHideXYAxis(){const i=this.xyAxisManipulation,a=this.xyManipulation;if(has("esri-mobile"))return;const n=[a,i].flatMap(i=>i.mapManipulators(i=>i)),e=()=>{const a=this._xyAxisVisible?null:i.hideManipulators();this._handles.remove(u),this._handles.add(a,u)};for(const t of n)this._handles.add(t.events.on("focus-changed",e));this._view.inputManager&&this._handles.add(t(()=>this._view.inputManager?.latestPointerInfo?.type,e)),e()}_updateManipulatorDisplay(){const i=this.grabbing?this.hideManipulatorsExceptGrabbedGroup():null;this._handles.remove(h),this._handles.add(i,h)}static radiusForSymbol(i){const a=null!=i&&"point-3d"===i.type&&i.symbolLayers;return!!a&&a.some(i=>"icon"===i.type)?n:e}}const u=Symbol("hideXyAxisManipulators"),h=Symbol("hideManipulatorsExceptGrabbedTypes");export{p as MoveManipulation};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{isSome as o}from"../../../../../core/arrayUtils.js";import e from"../../../../../core/Collection.js";import{EventEmitter as i}from"../../../../../core/Evented.js";import{makeHandle as n}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{destroyMaybe as s}from"../../../../../core/maybe.js";import{debounce as a}from"../../../../../core/promiseUtils.js";import{scale as l,zeroMeters as r}from"../../../../../core/quantity.js";import{watch as p,initial as c,syncAndInitial as h}from"../../../../../core/reactiveUtils.js";import{property as m,subclass as u}from"../../../../../core/accessorSupport/decorators.js";import{ensureType as d}from"../../../../../core/accessorSupport/ensureType.js";import{UpdatingHandles as v}from"../../../../../core/support/UpdatingHandles.js";import f from"../../../../../geometry/Point.js";import{makeDehydratedPoint as _}from"../../../../../layers/graphics/dehydratedPoint.js";import{getConvertedElevation as g}from"../../../../../support/elevationInfoUtils.js";import{SnappingVisualizer3D as M}from"../../SnappingVisualizer3D.js";import{orientation as b}from"../geometryUtils.js";import{manipulatedObjectGeometry as j}from"../manipulatedObjectUtils.js";import{canMoveZOperations as y}from"../manipulatorUtils.js";import{meshTransformFastUpdateHandles as T}from"../meshFastUpdateUtils.js";import{connectTooltipToManipulatedObject as w}from"../tooltipUtils3D.js";import{createVisualElements as I}from"../visualElementUtils.js";import{discRadius as S}from"../manipulations/config.js";import{MoveManipulation as H}from"../manipulations/MoveManipulation.js";import{axisConstrainedDragSign as x}from"../manipulations/moveUtils.js";import{MoveXYObjectManipulation as O}from"../manipulations/MoveXYObjectManipulation.js";import{isSupportedObject as P}from"./isSupportedObject.js";import{OutlineVisualElement as k}from"../../visualElements/OutlineVisualElement.js";import{createElevationUpdateHandle as D}from"../../../support/elevationUpdateUtils.js";import{dragManipulatedObjectMany as E,resetManipulatedObjectMany as U}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as A}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as R}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import z from"../../../../interactive/sketch/SketchOptions.js";import{SnappingContext as X}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as Y}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as C,enterInputModeIfAvailable as Z}from"../../../../interactive/tooltip/tooltipCommonUtils.js";import{MovePointTooltipInfo as F}from"../../../../interactive/tooltip/infos/MovePointTooltipInfo.js";import{TranslateTooltipInfo as G}from"../../../../interactive/tooltip/infos/TranslateTooltipInfo.js";import{TranslateXYTooltipInfo as V}from"../../../../interactive/tooltip/infos/TranslateXYTooltipInfo.js";import{TranslateZTooltipInfo as W}from"../../../../interactive/tooltip/infos/TranslateZTooltipInfo.js";import{verticalSignedDistanceBetweenPoints as B}from"../../../../support/euclideanLengthMeasurementUtils.js";import{GeometryWorkerHandle as N}from"../../../../support/GeometryWorkerHandle.js";class q{constructor(t){this.objects=t,this.type="move-start"}}class L{constructor(t,o,e){this.dx=t,this.dy=o,this.objects=e,this.type="move"}}class J{constructor(t){this.objects=t,this.type="move-stop"}}const K=Symbol("manipulators"),Q=Symbol("tooltips");let $=class extends A{constructor(t){super(t),this._infos=new Map,this.events=new i,this.objects=new e,this.enableZ=!0,this.sketchOptions=new z,this.type="move-3d",this._measurementWorker=new N({preloadGeodetic:!0}),this._latestTooltipInfo=null,this._translateTooltipInfo=null,this._translateXYTooltipInfo=null,this._translateZTooltipInfo=null,this._updatingHandles=new v,this._moveManipulation=null,this._updateMoveTooltipDistanceDebounced=a(this._updateMoveTooltipDistanceAsync.bind(this))}initialize(){const{view:t}=this;this.tooltip=C(()=>({view:t,options:this.sketchOptions.tooltips})),this.addHandles([this.objects.on("change",t=>{t.removed.forEach(t=>this.removeHandles(t)),this._updateObjectInfos(t),this._setupFastTransformUpdates(t.added),this._refreshManipulators()}),this.objects.on("change",()=>this._connectTooltips())]);const o=this.objects.toArray();this._updateObjectInfos({added:o,removed:[]}),this._setupFastTransformUpdates(o),this._refreshManipulators(),this._connectTooltips(),this.finishToolCreation()}destroy(){this.tooltip=s(this.tooltip),this._moveManipulation=s(this._moveManipulation),this._set("view",null),this._updatingHandles.destroy(),this._measurementWorker.destroy()}onInputEvent(t){if(!this.destroyed&&!Z(t,this.tooltip))return super.onInputEvent(t)}get updating(){return this._updatingHandles.updating}get _shouldShowMovePointTooltip(){const{objects:t}=this;if(1!==t.length)return!1;const o=j(t.at(0))?.type;return"point"===o||"mesh"===o}get activeTooltipInfo(){return this._shouldShowMovePointTooltip?this._movePointTooltipInfo:this._latestTooltipInfo}reset(){}_updateObjectInfos({added:t,removed:o}){for(const e of t){if(0!==P(e))continue;const t=new ot(e);this._infos.set(e,t)}for(const e of o)this._infos.delete(e)}_setupFastTransformUpdates(t){for(const o of t){const t=this._infos.get(o);this.addHandles(T(t.object),o)}}_refreshManipulators(){if(this.removeHandles(K),this._moveManipulation=s(this._moveManipulation),this.manipulators.removeAll(),0===this._infos.size)return;const t=Array.from(this._infos.values());this._createManipulators(t),this._createVisualElements(t),this._updateMoveManipulation(t)}_createManipulators(t){for(const o of t){const e=o.object;o.manipulationXY=new O({tool:this,view:this.view,object:e}),o.manipulationXY.forEachManipulator(t=>{this.addHandles([t.events.on("immediate-click",t=>{this.events.emit("immediate-click",{...t,object:e}),t.stopPropagation()}),t.events.on("grab-changed",({action:t})=>{"start"===t?this._showTooltip(0):this._hideTooltip()})],K)}),this.addHandles(o.manipulationXY.createDragPipeline((o,e,i,n)=>this._buildDragEventPipeline(t,0,o,e,i,n)),K)}this._createMoveManipulation(t)}_createMoveManipulation(t){const o=new H({tool:this,view:this.view,snapToScene:!1,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:!0,radius:1===t.length?H.radiusForSymbol(t[0].object.graphic?.symbol):S});this._moveManipulation=o,o.elevationInfo={mode:"absolute-height",offset:0},o.forEachManipulator(t=>{this.addHandles(t.events.on("immediate-click",e=>{const i=this.objects.at(0);!o.zManipulation.hasManipulator(t)&&1===this.objects.length&&i&&this.events.emit("immediate-click",{...e,object:i}),e.stopPropagation()}),K)});const e=t=>o=>{this.addHandles([o.events.on("focus-changed",({action:o})=>{"focus"===o?this._showTooltip(t):this._hideTooltip()}),o.events.on("grab-changed",()=>{this._latestTooltipInfo&&(this._latestTooltipInfo.distance=r)})],K)};this._moveManipulation.xyManipulation.forEachManipulator(e(0)),this._moveManipulation.xyAxisManipulation.forEachManipulator(e(1)),this._moveManipulation.zManipulation.forEachManipulator(e(2));const i=()=>this._updateMoveManipulation(t);for(const r of t){this.addHandles([r.object.on("committed",i),p(()=>r.object.visible,i)],K);const o=Symbol();this.addHandles(p(()=>r.object.isDraped,e=>{this._updateMoveManipulation(t),this.removeHandles(o),e&&this.addHandles(D({view:this.view,geometry:r.object.graphic?.geometry,elevationInfo:r.object.elevationInfo,onElevationChanges:()=>this._updateMoveManipulation(t)}),o)},c),K),this.addHandles(n(()=>this.removeHandles(o)),K)}const s=t[t.length-1];this.addHandles(s.object.on("committed",()=>this._updateMoveManipulationAngle(s)),K);const{object:a}=s,{operations:l}=a;if(l){const e=a.graphic;this.addHandles(o.createDragPipeline((o,e,i,n,s)=>this._buildDragEventPipeline(t,o,e,i,n,s),a.elevationInfo,l.data.spatialReference,e),K)}this._updateMoveManipulationAngle(s)}_createVisualElements(t){for(const o of t){const e=o.object,i=I({view:this.view,object:e,forEachManipulator:t=>{o.manipulationXY?.forEachManipulator(t),this._moveManipulation?.forEachManipulator(t)},onManipulatorsChanged:()=>n()});null!=i&&(o.geometryRepresentation=i.visualElement,o.geometryRepresentation instanceof k&&this.addHandles([o.geometryRepresentation.events.on("attachment-origin-changed",()=>{o.object.isDraped||this._updateMoveManipulation(t)}),p(()=>o.object.isDraped,()=>this._updateMoveManipulation(t))],K),this.addHandles(i,K))}}_updateMoveManipulationAngle(t){this._moveManipulation&&(this._moveManipulation.angle=b(j(t.object)))}_updateMoveManipulation(t){const o=_(0,0,0,this.view.spatialReference);let e=0,i=!1;const n=this._moveManipulation;if(n){for(const n of t){if(!n.object.visible)continue;this.enableZ&&y(n.object.operations,n.object.elevationInfo)&&(i=!0);const t=n.geometryRepresentation instanceof k&&!n.object.isDraped?n.geometryRepresentation.attachmentOrigin:n.object.origin;if(null!=t){const{x:i,y:n,z:s}=t;o.x+=i,o.y+=n,s&&(o.z??=0,o.z+=s),e++}}e>0?(o.x/=e,o.y/=e,o.z??=0,o.z/=e,n.location=o,n.xyManipulation.available=!0,n.xyAxisManipulation.available=!0,n.zManipulation.available=i):n.available=!1}}_buildDragEventPipeline(t,o,e,i,n,s){const a=[],l=[];let r=null,p=null;const c=()=>{for(const t of a)t.dragging=!1;a.length=0,l.length=0,r=null,p=null,this._moveManipulation&&(this._moveManipulation.interactive=!0)};if(1===t.length&&0===o){const o=t[0].object;({steps:i,cancel:n}=this._buildSnappingPipelineSteps(o,o.elevationInfo,i,n,s))}return n=n.next(t=>p?.(t)).next(()=>(l.length&&this.events.emit("move-stop",new J(l)),this.destroyed||c(),null)),{steps:i=i.next(o=>{if("start"===o.action){a.length=0,l.length=0;for(const o of t)o.dragging||!o.manipulationXY?.hasManipulator(e)&&o.manipulationXY?.grabbing||(a.push(o),l.push(o.object),o.dragging=!0);if(0!==l.length&&(this._moveManipulation&&(this._moveManipulation.interactive=!1),r=E(l),p=U(l),this._emitRecordUndo(),this.events.emit("move-start",new q(l)),this.destroyed))return null}return 0!==l.length?o:null}).next(t=>r?.(t)).next(t=>(this._updateMoveTooltip(o,t),t)).next(t=>{switch(t.action){case"start":case"update":if(t.translationX||t.translationY||t.translationZ){const o=this.view.toScreen(t.mapStart),e=this.view.toScreen(t.mapEnd);if(!o||!e)return null;const i=e.x-o.x,n=e.y-o.y;if(this.events.emit("move",new L(i,n,l)),this.destroyed)return null}break;case"end":if(this.events.emit("move-stop",new J(l)),this.destroyed)return null;c()}return null}),cancel:n}}_connectTooltips(){let t;if(this.removeHandles(Q),this._shouldShowMovePointTooltip){const o=this.objects.at(0),{events:e}=this;this._movePointTooltipInfo??=new F({viewType:this.view.type,sketchOptions:this.sketchOptions});const i={onBeforeUpdate:()=>this.endDrag(),onMoveStart:()=>{this._emitRecordUndo(),e.emit("move-start",new q([o]))},onMove:()=>e.emit("move",new L(0,0,[o])),onMoveStop:()=>e.emit("move-stop",new J([o])),onRotateStart:()=>{},onRotate:()=>{},onRotateStop:()=>{},onScaleStart:()=>{},onScale:()=>{},onScaleStop:()=>{}};t=w(this.tooltip,o,()=>({sketchOptions:this.sketchOptions,activeTooltipInfo:this._movePointTooltipInfo,callbacks:i}))}else t=p(()=>this.sketchOptions.tooltips.effectiveEnabled?this._latestTooltipInfo:null,t=>{this.tooltip.info=t},h);this.addHandles(t,Q)}_showTooltip(t){this._shouldShowMovePointTooltip||this._updateMoveTooltip(t)}_hideTooltip(){this._shouldShowMovePointTooltip||(this.tooltip?.clear(),this._latestTooltipInfo=null)}_updateMoveTooltip(t,o){if(this._shouldShowMovePointTooltip)return;const{sketchOptions:e}=this;switch(t){case 0:this._latestTooltipInfo=this._translateTooltipInfo??=new G({sketchOptions:e}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,o,(t,o)=>this._measurementWorker.autoDistance2DBetweenPoints(tt(t),tt(o))));break;case 1:this._latestTooltipInfo=this._translateXYTooltipInfo??=new V({sketchOptions:e}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,o,async(t,e)=>l(await this._measurementWorker.autoDistance2DBetweenPoints(tt(t),tt(e)),x(o))));break;case 2:this._latestTooltipInfo=this._translateZTooltipInfo??=new W({sketchOptions:e}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,o,B))}this._latestTooltipInfo.sketchOptions=e}async _updateMoveTooltipDistanceAsync(t,o,e){if(null!=o&&"end"!==o.action){const{mapStart:i,mapEnd:n}=o,s=await e(i,n);t.distance=s??r}else t.distance=r}_emitRecordUndo(){const t=this.objects.toArray().map(t=>t.createUndoRecord?.()).filter(o);t.length>0&&this.events.emit("record-undo",{updates:t})}_buildSnappingPipelineSteps(t,o,e,i,n){const s=j(t);if(null==s||"point"!==s.type&&"mesh"!==s.type)return{steps:e,cancel:i};const a=("point"===s.type?s:s.origin).clone(),l=new X({elevationInfo:o,pointer:n,editGeometryOperations:R.fromGeometry(a,this.view.state.viewingMode),visualizer:new M,excludeFeature:t.graphic}),r=this.snappingManager,{snappingStep:p,cancelSnapping:c}=Y({snappingContext:l,snappingManager:r,updatingHandles:this._updatingHandles});return i=i.next(c),{steps:e=e.next(o=>{a.z=g(this.view,a,t.elevationInfo,{mode:"absolute-height",offset:0});return{...o,snapOrigin:l.coordinateHelper.pointToVector(a)}}).next(...p),cancel:i}}get test(){}};t([m({constructOnly:!0,nonNullable:!0})],$.prototype,"view",void 0),t([m()],$.prototype,"objects",void 0),t([m({constructOnly:!0,nonNullable:!0})],$.prototype,"enableZ",void 0),t([m({constructOnly:!0,type:z})],$.prototype,"sketchOptions",void 0),t([m({constructOnly:!0})],$.prototype,"snappingManager",void 0),t([m()],$.prototype,"type",void 0),t([m()],$.prototype,"updating",null),t([m()],$.prototype,"_latestTooltipInfo",void 0),t([m()],$.prototype,"_shouldShowMovePointTooltip",null),t([m()],$.prototype,"activeTooltipInfo",null),$=t([u("esri.views.3d.interactive.editingTools.move.MoveTool3D")],$);const tt=d(f);class ot{constructor(t){this.object=t,this.geometryRepresentation=null,this.manipulationXY=null,this.dragging=!1}}export{L as MoveEvent,q as MoveStartEvent,J as MoveStopEvent,$ as MoveTool3D};
2
+ import{__decorate as t}from"tslib";import{isSome as o}from"../../../../../core/arrayUtils.js";import e from"../../../../../core/Collection.js";import{EventEmitter as i}from"../../../../../core/Evented.js";import{makeHandle as n}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{destroyMaybe as s}from"../../../../../core/maybe.js";import{debounce as a}from"../../../../../core/promiseUtils.js";import{scale as l,zeroMeters as r}from"../../../../../core/quantity.js";import{watch as p,initial as h,syncAndInitial as c}from"../../../../../core/reactiveUtils.js";import{property as u,subclass as m}from"../../../../../core/accessorSupport/decorators.js";import{ensureType as d}from"../../../../../core/accessorSupport/ensureType.js";import{UpdatingHandles as v}from"../../../../../core/support/UpdatingHandles.js";import f from"../../../../../geometry/Point.js";import{makeDehydratedPoint as _}from"../../../../../layers/graphics/dehydratedPoint.js";import{getConvertedElevation as g}from"../../../../../support/elevationInfoUtils.js";import{SnappingVisualizer3D as M}from"../../SnappingVisualizer3D.js";import{orientation as y}from"../geometryUtils.js";import{manipulatedObjectGeometry as b}from"../manipulatedObjectUtils.js";import{canMoveZOperations as j}from"../manipulatorUtils.js";import{meshTransformFastUpdateHandles as T}from"../meshFastUpdateUtils.js";import{connectTooltipToManipulatedObject as w}from"../tooltipUtils3D.js";import{createVisualElements as I}from"../visualElementUtils.js";import{discRadius as S}from"../manipulations/config.js";import{MoveManipulation as H}from"../manipulations/MoveManipulation.js";import{axisConstrainedDragSign as D}from"../manipulations/moveUtils.js";import{MoveXYObjectManipulation as x}from"../manipulations/MoveXYObjectManipulation.js";import{isSupportedObject as O}from"./isSupportedObject.js";import{OutlineVisualElement as P}from"../../visualElements/OutlineVisualElement.js";import{createElevationUpdateHandle as k}from"../../../support/elevationUpdateUtils.js";import{dragManipulatedObjectMany as E,resetManipulatedObjectMany as U}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as A}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as R}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import z from"../../../../interactive/sketch/SketchOptions.js";import{SnappingContext as X}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as Y}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as B,enterInputModeIfAvailable as C}from"../../../../interactive/tooltip/tooltipCommonUtils.js";import{MovePointTooltipInfo as Z}from"../../../../interactive/tooltip/infos/MovePointTooltipInfo.js";import{TranslateTooltipInfo as F}from"../../../../interactive/tooltip/infos/TranslateTooltipInfo.js";import{TranslateXYTooltipInfo as G}from"../../../../interactive/tooltip/infos/TranslateXYTooltipInfo.js";import{TranslateZTooltipInfo as V}from"../../../../interactive/tooltip/infos/TranslateZTooltipInfo.js";import{verticalSignedDistanceBetweenPoints as W}from"../../../../support/euclideanLengthMeasurementUtils.js";import{GeometryWorkerHandle as N}from"../../../../support/GeometryWorkerHandle.js";class q{constructor(t){this.objects=t,this.type="move-start"}}class L{constructor(t,o,e){this.dx=t,this.dy=o,this.objects=e,this.type="move"}}class J{constructor(t){this.objects=t,this.type="move-stop"}}const K=Symbol("manipulators"),Q=Symbol("tooltips"),$=Symbol("move-manipulator-display");let tt=class extends A{get _infos(){return Array.from(this._infosByType.values())}constructor(t){super(t),this._infosByType=new Map,this.events=new i,this.objects=new e,this.enableZ=!0,this.sketchOptions=new z,this.type="move-3d",this._measurementWorker=new N({preloadGeodetic:!0}),this._latestTooltipInfo=null,this._translateTooltipInfo=null,this._translateXYTooltipInfo=null,this._translateZTooltipInfo=null,this._updatingHandles=new v,this._moveManipulation=null,this._updateMoveTooltipDistanceDebounced=a(this._updateMoveTooltipDistanceAsync.bind(this))}initialize(){const{view:t}=this;this.tooltip=B(()=>({view:t,options:this.sketchOptions.tooltips})),this.addHandles([this.objects.on("change",t=>{t.removed.forEach(t=>this.removeHandles(t)),this._updateObjectInfos(t),this._setupFastTransformUpdates(t.added),this._refreshManipulators()}),this.objects.on("change",()=>this._connectTooltips())]);const o=this.objects.toArray();this._updateObjectInfos({added:o,removed:[]}),this._setupFastTransformUpdates(o),this._refreshManipulators(),this._connectTooltips(),this.finishToolCreation()}destroy(){this.tooltip=s(this.tooltip),this._moveManipulation=s(this._moveManipulation),this._set("view",null),this._updatingHandles.destroy(),this._measurementWorker.destroy()}onInputEvent(t){if(!this.destroyed&&!C(t,this.tooltip))return super.onInputEvent(t)}get updating(){return this._updatingHandles.updating}get _shouldShowMovePointTooltip(){const{objects:t}=this;if(1!==t.length)return!1;const o=b(t.at(0))?.type;return"point"===o||"mesh"===o}get activeTooltipInfo(){return this._shouldShowMovePointTooltip?this._movePointTooltipInfo:this._latestTooltipInfo}reset(){}_updateObjectInfos({added:t,removed:o}){for(const e of t){if(0!==O(e))continue;const t=new et(e);this._infosByType.set(e,t)}for(const e of o)this._infosByType.delete(e)}_setupFastTransformUpdates(t){for(const o of t){const t=this._infosByType.get(o);this.addHandles(T(t.object),o)}}_refreshManipulators(){if(this.removeHandles(K),this.removeHandles($),this._moveManipulation=s(this._moveManipulation),this.manipulators.removeAll(),0===this._infosByType.size)return;const t=this._infos;this._createManipulators(t),this._createVisualElements(t),this._updateMoveManipulation(t)}_createManipulators(t){for(const o of t){const e=o.object;o.manipulationXY=new x({tool:this,view:this.view,object:e}),o.manipulationXY.forEachManipulator(t=>{this.addHandles([t.events.on("immediate-click",t=>{this.events.emit("immediate-click",{...t,object:e}),t.stopPropagation()}),t.events.on("grab-changed",({action:t})=>{"start"===t?this._showTooltip(0):this._hideTooltip(),this._updateMoveManipulatorDisplay()})],K)}),this.addHandles(o.manipulationXY.createDragPipeline((o,e,i,n)=>this._buildDragEventPipeline(t,0,o,e,i,n)),K)}this._createMoveManipulation(t)}_updateMoveManipulatorDisplay(){const t=this._infos.some(t=>t.manipulationXY?.grabbing);this._moveManipulation&&(this._moveManipulation.interactive=!t),this.removeHandles($),t&&this._moveManipulation&&this.addHandles(this._moveManipulation.hideManipulators(),$)}_createMoveManipulation(t){const o=new H({tool:this,view:this.view,snapToScene:!1,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:!0,radius:1===t.length?H.radiusForSymbol(t[0].object.graphic?.symbol):S});this._moveManipulation=o,o.elevationInfo={mode:"absolute-height",offset:0},o.forEachManipulator(t=>{this.addHandles(t.events.on("immediate-click",e=>{const i=this.objects.at(0);!o.zManipulation.hasManipulator(t)&&1===this.objects.length&&i&&this.events.emit("immediate-click",{...e,object:i}),e.stopPropagation()}),K)});const e=t=>o=>{this.addHandles([o.events.on("focus-changed",({action:o})=>{"focus"===o?this._showTooltip(t):this._hideTooltip()}),o.events.on("grab-changed",()=>{this._latestTooltipInfo&&(this._latestTooltipInfo.distance=r)})],K)};this._moveManipulation.xyManipulation.forEachManipulator(e(0)),this._moveManipulation.xyAxisManipulation.forEachManipulator(e(1)),this._moveManipulation.zManipulation.forEachManipulator(e(2));const i=()=>this._updateMoveManipulation(t);for(const r of t){this.addHandles([r.object.on("committed",i),p(()=>r.object.visible,i)],K);const o=Symbol();this.addHandles(p(()=>r.object.isDraped,e=>{this._updateMoveManipulation(t),this.removeHandles(o),e&&this.addHandles(k({view:this.view,geometry:r.object.graphic?.geometry,elevationInfo:r.object.elevationInfo,onElevationChanges:()=>this._updateMoveManipulation(t)}),o)},h),K),this.addHandles(n(()=>this.removeHandles(o)),K)}const s=t[t.length-1];this.addHandles(s.object.on("committed",()=>this._updateMoveManipulationAngle(s)),K);const{object:a}=s,{operations:l}=a;if(l){const e=a.graphic;this.addHandles(o.createDragPipeline((o,e,i,n,s)=>this._buildDragEventPipeline(t,o,e,i,n,s),a.elevationInfo,l.data.spatialReference,e),K)}this._updateMoveManipulationAngle(s)}_createVisualElements(t){for(const o of t){const e=o.object,i=I({view:this.view,object:e,forEachManipulator:t=>{o.manipulationXY?.forEachManipulator(t),this._moveManipulation?.forEachManipulator(t)},onManipulatorsChanged:()=>n()});null!=i&&(o.geometryRepresentation=i.visualElement,o.geometryRepresentation instanceof P&&this.addHandles([o.geometryRepresentation.events.on("attachment-origin-changed",()=>{o.object.isDraped||this._updateMoveManipulation(t)}),p(()=>o.object.isDraped,()=>this._updateMoveManipulation(t))],K),this.addHandles(i,K))}}_updateMoveManipulationAngle(t){this._moveManipulation&&(this._moveManipulation.angle=y(b(t.object)))}_updateMoveManipulation(t){const o=_(0,0,0,this.view.spatialReference);let e=0,i=!1;const n=this._moveManipulation;if(n){for(const n of t){if(!n.object.visible)continue;this.enableZ&&j(n.object.operations,n.object.elevationInfo)&&(i=!0);const t=n.geometryRepresentation instanceof P&&!n.object.isDraped?n.geometryRepresentation.attachmentOrigin:n.object.origin;if(null!=t){const{x:i,y:n,z:s}=t;o.x+=i,o.y+=n,s&&(o.z??=0,o.z+=s),e++}}e>0?(o.x/=e,o.y/=e,o.z??=0,o.z/=e,n.location=o,n.xyManipulation.available=!0,n.xyAxisManipulation.available=!0,n.zManipulation.available=i):n.available=!1}}_buildDragEventPipeline(t,o,e,i,n,s){const a=[],l=[];let r=null,p=null;const h=()=>{for(const t of a)t.dragging=!1;a.length=0,l.length=0,r=null,p=null,this._updateMoveManipulatorDisplay()};if(1===t.length&&0===o){const o=t[0].object;({steps:i,cancel:n}=this._buildSnappingPipelineSteps(o,o.elevationInfo,i,n,s))}return n=n.next(t=>p?.(t)).next(()=>(l.length&&this.events.emit("move-stop",new J(l)),this.destroyed||h(),null)),{steps:i=i.next(o=>{if("start"===o.action){a.length=0,l.length=0;for(const o of t)o.dragging||!o.manipulationXY?.hasManipulator(e)&&o.manipulationXY?.grabbing||(a.push(o),l.push(o.object),o.dragging=!0);if(0!==l.length&&(this._moveManipulation&&(this._moveManipulation.interactive=!1),r=E(l),p=U(l),this._emitRecordUndo(),this.events.emit("move-start",new q(l)),this.destroyed))return null}return 0!==l.length?o:null}).next(t=>r?.(t)).next(t=>(this._updateMoveTooltip(o,t),t)).next(t=>{switch(t.action){case"start":case"update":if(t.translationX||t.translationY||t.translationZ){const o=this.view.toScreen(t.mapStart),e=this.view.toScreen(t.mapEnd);if(!o||!e)return null;const i=e.x-o.x,n=e.y-o.y;if(this.events.emit("move",new L(i,n,l)),this.destroyed)return null}break;case"end":if(this.events.emit("move-stop",new J(l)),this.destroyed)return null;h()}return null}),cancel:n}}_connectTooltips(){let t;if(this.removeHandles(Q),this._shouldShowMovePointTooltip){const o=this.objects.at(0),{events:e}=this;this._movePointTooltipInfo??=new Z({viewType:this.view.type,sketchOptions:this.sketchOptions});const i={onBeforeUpdate:()=>this.endDrag(),onMoveStart:()=>{this._emitRecordUndo(),e.emit("move-start",new q([o]))},onMove:()=>e.emit("move",new L(0,0,[o])),onMoveStop:()=>e.emit("move-stop",new J([o])),onRotateStart:()=>{},onRotate:()=>{},onRotateStop:()=>{},onScaleStart:()=>{},onScale:()=>{},onScaleStop:()=>{}};t=w(this.tooltip,o,()=>({sketchOptions:this.sketchOptions,activeTooltipInfo:this._movePointTooltipInfo,callbacks:i}))}else t=p(()=>this.sketchOptions.tooltips.effectiveEnabled?this._latestTooltipInfo:null,t=>{this.tooltip.info=t},c);this.addHandles(t,Q)}_showTooltip(t){this._shouldShowMovePointTooltip||this._updateMoveTooltip(t)}_hideTooltip(){this._shouldShowMovePointTooltip||(this.tooltip?.clear(),this._latestTooltipInfo=null)}_updateMoveTooltip(t,o){if(this._shouldShowMovePointTooltip)return;const{sketchOptions:e}=this;switch(t){case 0:this._latestTooltipInfo=this._translateTooltipInfo??=new F({sketchOptions:e}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,o,(t,o)=>this._measurementWorker.autoDistance2DBetweenPoints(ot(t),ot(o))));break;case 1:this._latestTooltipInfo=this._translateXYTooltipInfo??=new G({sketchOptions:e}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,o,async(t,e)=>l(await this._measurementWorker.autoDistance2DBetweenPoints(ot(t),ot(e)),D(o))));break;case 2:this._latestTooltipInfo=this._translateZTooltipInfo??=new V({sketchOptions:e}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,o,W))}this._latestTooltipInfo.sketchOptions=e}async _updateMoveTooltipDistanceAsync(t,o,e){if(null!=o&&"end"!==o.action){const{mapStart:i,mapEnd:n}=o,s=await e(i,n);t.distance=s??r}else t.distance=r}_emitRecordUndo(){const t=this.objects.toArray().map(t=>t.createUndoRecord?.()).filter(o);t.length>0&&this.events.emit("record-undo",{updates:t})}_buildSnappingPipelineSteps(t,o,e,i,n){const s=b(t);if(null==s||"point"!==s.type&&"mesh"!==s.type)return{steps:e,cancel:i};const a=("point"===s.type?s:s.origin).clone(),l=new X({elevationInfo:o,pointer:n,editGeometryOperations:R.fromGeometry(a,this.view.state.viewingMode),visualizer:new M,excludeFeature:t.graphic}),r=this.snappingManager,{snappingStep:p,cancelSnapping:h}=Y({snappingContext:l,snappingManager:r,updatingHandles:this._updatingHandles});return i=i.next(h),{steps:e=e.next(o=>{a.z=g(this.view,a,t.elevationInfo,{mode:"absolute-height",offset:0});return{...o,snapOrigin:l.coordinateHelper.pointToVector(a)}}).next(...p),cancel:i}}get test(){}};t([u({constructOnly:!0,nonNullable:!0})],tt.prototype,"view",void 0),t([u()],tt.prototype,"objects",void 0),t([u({constructOnly:!0,nonNullable:!0})],tt.prototype,"enableZ",void 0),t([u({constructOnly:!0,type:z})],tt.prototype,"sketchOptions",void 0),t([u({constructOnly:!0})],tt.prototype,"snappingManager",void 0),t([u()],tt.prototype,"type",void 0),t([u()],tt.prototype,"updating",null),t([u()],tt.prototype,"_latestTooltipInfo",void 0),t([u()],tt.prototype,"_shouldShowMovePointTooltip",null),t([u()],tt.prototype,"activeTooltipInfo",null),tt=t([m("esri.views.3d.interactive.editingTools.move.MoveTool3D")],tt);const ot=d(f);class et{constructor(t){this.object=t,this.geometryRepresentation=null,this.manipulationXY=null,this.dragging=!1}}export{L as MoveEvent,q as MoveStartEvent,J as MoveStopEvent,tt as MoveTool3D};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{removeUnordered as i}from"../../../../../core/arrayUtils.js";import{EventEmitter as n}from"../../../../../core/Evented.js";import a from"../../../../../core/Handles.js";import{handlesGroup as o,makeHandle as s,destroyHandle as r}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{destroyMaybe as l,removeMaybe as p}from"../../../../../core/maybe.js";import{watch as d,initial as h,on as u,syncAndInitial as c,when as m,sync as f}from"../../../../../core/reactiveUtils.js";import{property as g,subclass as _}from"../../../../../core/accessorSupport/decorators.js";import{IDENTITY as v}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{length as M,subtract as b,lerp as x,set as y,add as O,scale as j}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as E,create as I}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as S}from"../../../../../core/support/UpdatingHandles.js";import H from"../../../../../geometry/Point.js";import w from"../../../../../geometry/Polyline.js";import{projectPoint as V}from"../../../../../geometry/projectionUtils.js";import T from"../../../../../geometry/SpatialReference.js";import{makeDehydratedPoint as D}from"../../../../../layers/graphics/dehydratedPoint.js";import{getZForElevationMode as A}from"../../../../../support/elevationInfoUtils.js";import{isVolumetricSymbol as G}from"../../../../../symbols/support/utils.js";import{Manipulator3D as P}from"../../Manipulator3D.js";import{createManipulatorMaterial as k,createManipulatorOutlineMaterial as C,placeAtObject as U}from"../../manipulatorUtils.js";import{RenderObject as R}from"../../RenderObject.js";import{SegmentLabels3D as L}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as z}from"../../SnappingVisualizer3D.js";import{screenToMapXYAtLocation as F,screenToRenderPlaneFromEvent as B,convertToMapCoordinates as Z}from"../dragEventPipeline3D.js";import{orientation as W}from"../geometryUtils.js";import{canMoveZOperations as N}from"../manipulatorUtils.js";import{Settings as q}from"../settings.js";import{createVisualElements as X}from"../visualElementUtils.js";import{discRadiusSmall as Y}from"../manipulations/config.js";import{MoveManipulation as K}from"../manipulations/MoveManipulation.js";import{MoveXYObjectManipulation as J}from"../manipulations/MoveXYObjectManipulation.js";import{getMapPointAtEdgeOffsetManipulatorElevation as Q,createEdgeOffsetIntersectionPlane as $,createEdgeOffsetOperation as ee,edgeOffsetRotationMatrix as te,screenEdgeLengthSquared as ie,getDistanceInGeometrySR as ne}from"./edgeOffsetUtils.js";import{createTooltipInfos as ae,connectTooltipToManipulatedObject as oe,getUpdatedTranslateObjectTooltipInfo as se,getUpdatedEdgeOffsetTooltipInfo as re}from"./reshapeTooltipUtils3D.js";import{OutlineVisualElement as le}from"../../visualElements/OutlineVisualElement.js";import{createElevationUpdateHandle as pe}from"../../../support/elevationUpdateUtils.js";import{createExtrudedTriangle as de,createSphereGeometry as he}from"../../../webgl-engine/lib/GeometryUtil.js";import{mouseButtons as ue}from"../../../../input/mouseButtons.js";import{sceneSnappingAtLocation as ce,addMapDelta as me,createManipulatorDragEventPipeline as fe,dragAtLocation as ge,addScreenDelta as _e}from"../../../../interactive/dragEventPipeline.js";import{tooltipKeys as ve}from"../../../../interactive/keybindings.js";import{SnappingContext as Me}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as be}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as xe,enterInputModeIfAvailable as ye}from"../../../../interactive/tooltip/tooltipCommonUtils.js";import{GeometryWorkerHandle as Oe}from"../../../../support/GeometryWorkerHandle.js";const je=Symbol(),Ee=Symbol();let Ie=class extends t{get _operations(){return this.object.operations}constructor(e){super(e),this._selectedIndex=0,this._manipulatorHandles=new a,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=0,this._pendingEdgeOffsetInfo=null,this._updatingHandles=new S,this._recreatingManipulators=!1,this._settings=new q({getTheme:()=>this.view.effectiveTheme}),this.events=new n,this.activeTooltipInfo=null,this._measurementWorker=new Oe({preloadGeodetic:!0}),this._vertexLaserLineVisualElement=null,this._tooltipCallbacks={onBeforeReshape:()=>this.tool.endDrag(),onReshapeStart:()=>this._updateEventState(2),onReshape:()=>this.events.emit("reshape",{type:"reshape",object:this.object}),onReshapeStop:()=>this._updateEventState(0,{forceEnd:!0}),onMoveStart:()=>this._updateEventState(1),onMove:()=>this.events.emit("move",{type:"move",object:this.object,dx:0,dy:0}),onMoveStop:()=>this._updateEventState(0,{forceEnd:!0})}}initialize(){const{view:e}=this,t=this._settings.manipulators,i=t.vertex;this.tooltipInfos=ae(this._sketchOptions,e),this._vertexManipulatorMaterial=k(i.color.toUnitRGBA(),i.renderOccluded),this._vertexManipulatorOutlineMaterial=C(i.outlineColor.toUnitRGBA(),i.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=C(i.hoverOutlineColor.toUnitRGBA(),i.renderOccluded);const n=t.edge;this._edgeManipulatorMaterial=k(n.color.toUnitRGBA(),n.renderOccluded),this._edgeManipulatorOutlineMaterial=C(n.outlineColor.toUnitRGBA(),n.renderOccluded);const a=t.edgeOffset;this._edgeOffsetManipulatorMaterial=k(a.color.toUnitRGBA(),a.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=k(a.hoverColor.toUnitRGBA(),a.renderOccluded,!1);const o=t.selected;this._selectedManipulatorMaterial=k(o.color.toUnitRGBA(),o.renderOccluded),this._selectedManipulatorOutlineMaterial=C(o.outlineColor.toUnitRGBA(),o.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=C(o.hoverOutlineColor.toUnitRGBA(),o.renderOccluded),this.tooltip=xe(()=>({view:e,options:this._sketchOptions.tooltips})),this.addHandles([d(()=>{const e=this._settings.manipulators;return{vertexSettings:e.vertex,edgeSettings:e.edge,edgeOffsetSettings:e.edgeOffset,selectedSettings:e.selected}},({vertexSettings:e,edgeSettings:t,edgeOffsetSettings:i,selectedSettings:n})=>{e.applyColor(this._vertexManipulatorMaterial),e.applyOutline(this._vertexManipulatorOutlineMaterial),e.applyHoverOutline(this._vertexManipulatorHoverOutlineMaterial),t.applyColor(this._edgeManipulatorMaterial),t.applyOutline(this._edgeManipulatorOutlineMaterial),i.applyColor(this._edgeOffsetManipulatorMaterial),i.applyHover(this._edgeOffsetManipulatorHoverMaterial),n.applyColor(this._selectedManipulatorMaterial),n.applyOutline(this._selectedManipulatorOutlineMaterial),n.applyHoverOutline(this._selectedManipulatorHoverOutlineMaterial)}),d(()=>this.object.visible,e=>{for(const t of this._manipulatorInfos)t.manipulator.available=e,Te(t)&&(t.edgeManipulator.available=e)}),d(()=>this._numGrabbing+this._numDragging===0,e=>this._toggleAutoHideManipulators(e)),d(()=>({labels:this._segmentLabels,enabled:this._sketchOptions.labels.enabled,edgeOffsetEnabled:this.enableEdgeOffset}),({labels:e,enabled:t,edgeOffsetEnabled:i})=>{null!=e&&(e.visible=t,e.edgeDistance=i?"far":"default")},h),oe(this.tooltip,this.object,()=>this._tooltipsContext,this._updatingHandles),d(()=>this.tooltip.mode,(e,t)=>{"input"===t&&"input"!==e&&this._resetTooltip()}),u(()=>this._operations,"vertex-update",e=>this._updateManipulatorPositions(e.vertices),{onListenerAdd:()=>this._recreateManipulators()}),u(()=>this._operations?.data,"change",e=>{"undo"!==e.operation&&"redo"!==e.operation||this._recreateManipulators()})])}destroy(){this._removeManipulators(),this._updatingHandles.destroy(),this._segmentLabels=l(this._segmentLabels),this.tooltip=l(this.tooltip),this._measurementWorker.destroy()}get updating(){return this._updatingHandles.updating||!!this._segmentLabels?.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get object(){return this.tool.object}get enableZShape(){return this.tool.enableZShape}get enableDeleteVertices(){return this.tool.enableDeleteVertices}get enableZVertex(){return this.tool.enableZVertex}get autoHideManipulators(){return this.tool.autoHideManipulators}get enableMoveObject(){return this.tool.enableMoveObject}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}get _sketchOptions(){return this.tool.sketchOptions}get _accentColor(){return this.view.effectiveTheme.accentColor}enterInputModeIfAvailable(e){return"key-down"===e.type&&e.key===ve.enterInputMode&&("reshape-edge-offset"===this.activeTooltipInfo?.type?this._enterInputModeDuringEdgeOffset(e):!!ye(e,this.tooltip)&&(this.tool.endDrag(),!0))}removeSelectedVertices(){const e=this._manipulatorInfos.filter(e=>e.manipulator.selected&&"vertex"===e.type);return this._removeVertices(e),e.length}onManipulatorSelectionChanged(){this.events.emit("manipulators-changed")}clearSelection(){let e=!1;for(const t of this._manipulatorInfos)if(t.manipulator.selected){e=!0;break}e&&(this._clearSelection(),this._updateMoveManipulationPosition(),this.events.emit("manipulators-changed"))}selectManipulator(e){if(null==this._manipulatorInfos.find(t=>t.manipulator===e)||!e.selectable)return!1;let t=e.selected;for(const i of this._manipulatorInfos)if(i.manipulator!==e&&i.manipulator.selected){t=!1;break}return t||(this._clearSelection(),e.selected=!0,this._updateMoveManipulationPosition(),this.events.emit("manipulators-changed")),!0}_removeManipulators(){this._manipulatorHandles.removeAll(),this._moveManipulation=l(this._moveManipulation),this._objectMoveManipulation=l(this._objectMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0}_createManipulators(e){if(null==this._operations)return;const t=this.object.elevationInfo;for(const{vertices:i,segments:n,index:a}of this._operations.data.parts){const o=e?.byPartIndex.get(a);for(const e of i){const i=o?.has(e.index);this._createVertexOrEdgeManipulator(e,t,i)}for(const e of n)"line"===e.type&&this._createVertexOrEdgeManipulator(e,t)}this._createObjectMoveManipulation(),this._createMoveManipulation(t),this._createVisualElements()}recordUndo(e){this._operations?.recordUndo(e,!0)}get canRedo(){return this._operations?.canRedo??!1}get canUndo(){return this._operations?.canUndo??!1}redo(){return this._operations?.redo()}undo(){return this.events.emit("undo"),this._operations?.undo()}_recreateManipulators(){if(!this._recreatingManipulators){if(this._recreatingManipulators=!0,this._removeManipulators(),this._resetTooltip(),this._operations&&this._segmentLabels?.context?.editGeometryOperations===this._operations||(this._segmentLabels=l(this._segmentLabels)),this._createManipulators(),!this._segmentLabels&&this._operations){const e=this._sketchOptions.labels;this._segmentLabels=new L({context:{view:this.view,editGeometryOperations:this._operations,elevationInfo:this.object.elevationInfo,labelOptions:e},visible:e.enabled})}this._recreatingManipulators=!1}}_perObjectManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const n=[],a=this._manipulatorInfos.some(e=>"vertex"===e.type&&e.manipulator.selected),o=1===e&&a;for(const s of this._manipulatorInfos)"vertex"===s.type&&(s.manipulator.grabbing||o&&!s.manipulator.selected||n.push(s),i++);this._moveVertices(n,t);if(n.length===i){if(this._updateEventState(1),this.destroyed)return t;this.events.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,object:this.object})}else{if(this._updateEventState(2),this.destroyed)return t;this.events.emit("reshape",{type:"reshape",object:this.object})}return t}_toggleAutoHideManipulators(e){this.autoHideManipulators&&(e?this.removeHandles(je):this.tool.manipulators.forEach(({manipulator:e})=>{const t=e.disableDisplay?.();t&&this.addHandles(t,je)}))}_isMultiVertexSelection(){return this._manipulatorInfos.reduce((e,t)=>"vertex"===t.type&&t.manipulator.selected?e+1:e,0)>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(2),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:n}=e;if(!t&&!i&&!n)return;const a=[];for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.selected&&!o.manipulator.grabbing||o===e.info)&&a.push(o);this._moveVertices(a,e,1),this.events.emit("reshape",{type:"reshape",object:this.object})}_updateEventState(e,t={}){if(e===this._reshapeEventState)return!1;switch(e){case 0:if(!t.forceEnd&&(0!==this._numGrabbing||0!==this._numDragging))return!1;switch(this._reshapeEventState){case 1:this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape-stop",object:this.object})}break;case 1:switch(this._reshapeEventState){case 0:this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape-stop",object:this.object}),this.destroyed||this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object})}break;case 2:switch(this._reshapeEventState){case 0:this.events.emit("reshape",{type:"reshape-start",object:this.object});break;case 1:this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object}),this.destroyed||this.events.emit("reshape",{type:"reshape-start",object:this.object})}}if(this.destroyed)return!1;const i=this._reshapeEventState!==e;return this._reshapeEventState=e,i}_createObjectMoveManipulation(){const{tool:e,view:t,object:i,_operations:n}=this;if(n){if(this._objectMoveManipulation=new J({tool:e,view:t,object:i}),this.enableMoveObject){let e=null;this._manipulatorHandles.add(this._objectMoveManipulation.createDragPipeline((t,i,a)=>{i.next(e=>this._trackNumDragging(e)).next(t=>("start"===t.action&&(e=n.createUndoGroup()),t)).next(e=>this._perObjectManipulatorDragAction(0,e)).next(e=>(this._updateTranslateObjectTooltip(0,e),e)).next(t=>{"end"===t.action&&(this._resetTooltip(),e=p(e))}),a.next(()=>this._onDragCancel(!0,()=>e=p(e)))})),this._objectMoveManipulation.forEachManipulator(e=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(e,!1)))}else this._objectMoveManipulation.forEachManipulator(e=>{e.grabbable=!1,e.cursor=null});this._objectMoveManipulation.forEachManipulator(e=>this._manipulatorHandles.add(e.events.on("immediate-click",e=>{this._manipulatorInfos.some(e=>e.manipulator.selected)?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()})))}}_createMoveManipulation(e){const{object:t,tool:i,view:n,_operations:a}=this;if(!a)return;this._moveManipulation=new K({tool:i,view:n,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&N(t.operations,t.elevationInfo),snapToScene:!1,radius:K.radiusForSymbol(t.graphic?.symbol)}),this._moveManipulation.forEachManipulator(e=>this.addHandles([e.events.on("immediate-click",t=>{this._moveManipulation.zManipulation.hasManipulator(e)||this._manipulatorInfos.some(e=>e.manipulator.selected)||this.events.emit("immediate-click",{...t,object:this.object}),t.stopPropagation()}),this._watchAndUpdateGrabState(e,!1)]));const o=e=>t=>{this.addHandles([t.events.on("focus-changed",({action:t})=>{"focus"===t?this._updateTranslateTooltip(e):this._resetTooltip()})])};this._moveManipulation.xyManipulation.forEachManipulator(o(0)),this._moveManipulation.xyAxisManipulation.forEachManipulator(o(1)),this._moveManipulation.zManipulation.forEachManipulator(o(2)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const s=a.data.spatialReference;this.addHandles([this._moveManipulation.createDragPipeline((n,o,s,r,l)=>{const{snappingStep:p,cancelSnapping:d}=be({predicate:e=>!!e.info,snappingManager:i.snappingManager,snappingContext:new Me({editGeometryOperations:a,elevationInfo:e,pointer:l,excludeFeature:t.graphic,visualizer:new z}),updatingHandles:this._updatingHandles,useZ:!1});return r=r.next(e=>(this._onDragCancel(),e)).next(d),{steps:s=s.next(e=>this._trackNumDragging(e)).next(e=>{const t=this._manipulatorInfos.filter(e=>"vertex"===e.type&&e.manipulator.selected);return 1===e.manipulatorType&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:e}).next(ce(this.view,e,t.graphic??void 0)).next(...p).next(me()).next(e=>this._perObjectManipulatorDragAction(1,e)).next(e=>(this._updateTranslateTooltip(n,e),e)),cancel:r}},e,s,t.graphic),d(()=>t.visible,()=>this._updateMoveManipulationPosition(),h),t.on("committed",()=>{this._recreatingManipulators||this._updateMoveManipulationPosition()}),d(()=>t.isDraped,e=>{this._updateMoveManipulationPosition(),this.removeHandles(Ee),e&&this.addHandles(pe({view:this.view,geometry:t.graphic?.geometry,elevationInfo:t.elevationInfo,onElevationChanges:()=>this._updateMoveManipulationPosition()}),Ee)},h)])}_createVisualElements(){const{object:e,view:t}=this,i=X({view:t,object:e,forEachManipulator:e=>{if(!this.destroyed&&!this._recreatingManipulators){this._objectMoveManipulation.forEachManipulator(e),this._moveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,1)}},onManipulatorsChanged:e=>this.events.on("manipulators-changed",e)});null!=i&&(this._outlineVisualElement=i.visualElement instanceof le?i.visualElement:null);const n=this._outlineVisualElement;if(null!=n){const t=()=>{e.isDraped||this._updateMoveManipulationPosition()};this._manipulatorHandles.add(u(()=>n.events,"attachment-origin-changed",t,{onListenerAdd:t}))}this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(e,t=this.object.elevationInfo){const i=this.view,n=this._operations;if(e.part.vertices.length<=2||!n)return null;const a=n.data.spatialReference,s=this._settings.manipulators.edgeOffset,r=s.size/2,l=r+s.collisionPadding,p=r/l,d=p/2,h=p*Math.sqrt(3)/2,{height:u,offset:c}=s,m=this._edgeOffsetManipulatorMaterial;if(!this._edgeOffsetManipulatorGeometryInside){const e=de(m,h,d,d,u,c);this._edgeOffsetManipulatorGeometryInside=e}if(!this._edgeOffsetManipulatorGeometryOutside){const e=de(m,-h,d,d,u,-c);this._edgeOffsetManipulatorGeometryOutside=e}const f=[new R(this._edgeOffsetManipulatorGeometryInside.instantiate(),1),new R(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),2),new R(this._edgeOffsetManipulatorGeometryOutside.instantiate(),1),new R(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),2)],g=new P({view:i,renderObjects:f,elevationInfo:"on-the-ground"!==t.mode||G(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:t,worldOriented:!1,focusMultiplier:1,radius:l,available:this.object.visible,collisionType:{type:"disc",direction:E(0,0,1)},collisionPriority:1,metadata:{deleting:!1},location:Ve(a)}),_=new P({view:i,worldSized:!0,worldOriented:!1,available:this.object.visible,collisionPriority:-10,cursor:this.enableMoveObject?"move":"default",metadata:{deleting:!1},location:Ve(a)}),v={manipulator:g,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:_,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(v,s.minSquaredEdgeLength);const M=()=>this._updateEdgeOffsetManipulator(v);M(),v.locationUpdateHandle=o([e.leftVertex,e.rightVertex].map(e=>{const t=this._getManipulatorInfoFromHandle(e);return t?.manipulator.events.on("location-update",M)}));const b=e=>{this._manipulatorInfos.some(e=>e.manipulator.selected)?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()};return this._manipulatorHandles.add([v.locationUpdateHandle,this._watchAndUpdateGrabState(g,!0),this._watchAndUpdateGrabState(_,!0),fe(g,this._createEdgeOffsetPipeline(v,t,n)),fe(_,this._createEdgePipeline(v,t,n)),_.events.on("immediate-click",b),g.events.on("immediate-click",b),g.events.on("focus-changed",()=>this._resetTooltip()),g.events.on("grab-changed",({screenPoint:e,action:t})=>{v.grabMapPoint="start"===t?Q(e,this.view,this.object,v):null})],g),this._manipulatorInfos.push(v),this.manipulators.addMany([g,_]),this.events.emit("manipulators-changed"),v}_autoHideEdgeOffsetManipulator(e,t){const i=e.manipulator,n=e.edgeManipulator,a=()=>{e.visibilityHandle=p(e.visibilityHandle);const a=this._getManipulatorInfoFromHandle(e.handle.leftVertex),r=this._getManipulatorInfoFromHandle(e.handle.rightVertex),l=null!=a&&null!=r&&ie(a.manipulator.renderLocation,r.manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!n.focused||l)&&(i.grabbable=!l,n.grabbable=!l,e.visibilityHandle=o([i.disableDisplay(),s(()=>{i.grabbable=!0,n.grabbable=this.enableMoveObject})]))};this._manipulatorHandles.add([i.events.on("focus-changed",a),n.events.on("focus-changed",a),s(()=>{p(e.visibilityHandle),n.metadata.deleting=!0,this.manipulators.remove(n)})],i),a()}_updateEdgeOffsetManipulator(e){if(!this._operations)return;this._updateManipulatorPosition(e);const{coordinateHelper:t}=this._operations.data,i=$(this.view,e.manipulator.elevationAlignedLocation,ee(t,e.handle,e.manipulator.elevationInfo)),n=this._getManipulatorInfoFromHandle(e.handle.leftVertex),a=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==n||null==a)return;const o=n.manipulator.renderLocation,s=a.manipulator.renderLocation,r=null!=i?te(i,o,s):v;e.manipulator.modelTransform=r,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=r;const l=M(b(Ae,o,s))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-l,0,0],[l,0,0]]]}}_createEdgePipeline(e,t,i){return(n,a,o,s)=>{if("touch"===s){this._createEdgeOffsetPipeline(e,t,i)(n,a,o)}else if(this.enableMoveObject){const e=this.object.graphic,s=i.data.spatialReference,{elevationAlignedLocation:r}=n;a.next(e=>this._trackNumDragging(e)).next(ge(this.view,r)).next(F(this.view,r,t,s,e)).next(_e()).next(me()).next(e=>this._perObjectManipulatorDragAction(0,e)).next(e=>(this._updateTranslateObjectTooltip(0,e),e)).next(e=>{"end"===e.action&&this._resetTooltip()}),o.next(()=>this._onDragCancel(!n.metadata.deleting))}}}_createEdgeOffsetPipeline(e,t,i){return(n,a,o)=>{const s=this._pendingEdgeOffsetInfo;if(s?.manipulatorInfo===e&&"drag"!==s.mode)return void o.execute({action:"cancel"});this._clearSelection();const{initializeStep:r,cleanup:l}=this._initializeEdgeOffset(e,t,i,o),p=this._applyEdgeOffsetStep(e);a.next(e=>this._trackNumDragging(e)).next(ge(this.view,n.elevationAlignedLocation)).next(r).next(B(this.view)).next(Z(this.view,i.data.spatialReference)).next(me()).next(Se()).next(e=>this._pendingEdgeOffsetInfo?e:p(e)).next(e=>{"end"!==e.action||this._pendingEdgeOffsetInfo||l()}),o.next(()=>{this._exitEdgeOffsetInputMode(),n.metadata.deleting||(l(),this._onDragCancel())})}}_initializeEdgeOffset(e,t,i,n){const{view:a,object:s}=this,r=ee(i.data.coordinateHelper,e.handle,t),l=i.createUndoGroup(),d=$(a,e.manipulator.elevationAlignedLocation,r);let h;this._splitEdgesBeforeEdgeOffset(e,r),this._selectEdgeOffsetArrow(e,r);const u=()=>{this._cleanEdgeOffsetCollapsedEdges(e,i),h=p(h)},c=this.events.on("undo",u);return h=o([this._initializeEdgeOffsetVisualElement(e,s,t,i),l,c,this._connectEdgeOffsetTooltip(e,r,i,()=>{n.execute({action:"cancel"})})]),{initializeStep:e=>null==r||null==d?(u(),null):{...e,operation:r,plane:d},cleanup:u}}_initializeEdgeOffsetVisualElement(e,t,i,n){const a=()=>new w({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:n.data.spatialReference}),s=new le({view:this.view,isDraped:t.isDraped,geometry:a(),elevationInfo:i,width:this._settings.visualElements.lineObjects.outline.width,attached:!1,isDecoration:!0}),l=o([d(()=>({color:this._accentColor,draped:t.isDraped}),({color:e,draped:t})=>{s.color=e.toUnitRGBA(),s.isDraped=t},c),t.on("committed",()=>{s.geometry=a()}),r(s)]);return s.attached=!0,l}_applyEdgeOffsetStep(e){return t=>(this.destroyed||null==t.operation||!this._operations||(this._updateEventState(2),null==t.signedDistance?this._resetTooltip():((t.mapDeltaX||t.mapDeltaY||t.mapDeltaZ)&&(this._offsetEdge(e,t.operation,t.signedDistance),this.events.emit("reshape",{type:"reshape",object:this.object})),this._updateEdgeOffsetTooltip(t))),t)}_cleanEdgeOffsetCollapsedEdges(e,t){const i=e.handle.leftVertex.leftSegment?.leftVertex,n=e.handle.leftVertex,a=e.handle.rightVertex.rightSegment?.rightVertex,o=e.handle.rightVertex,s=t.data.coordinateHelper,r=this.view.pixelSizeAt(s.vectorToDehydratedPoint(n.pos),s.spatialReference),l=[];if(i&&s.distance(i.pos,n.pos)<Ge){const e=this._getManipulatorInfoFromHandle(n);null!=e&&l.push(e)}if(s.distance(n.pos,o.pos)<r||a&&s.distance(a.pos,o.pos)<Ge){const e=this._getManipulatorInfoFromHandle(o);null!=e&&l.push(e)}l.length&&this._removeVertices(l)}_enterInputModeDuringEdgeOffset(e){const t=this._findActiveEdgeOffsetManipulatorInfo();return!!t&&(!!ye(e,this.tooltip)&&(t.manipulator.dragging?(this._pendingEdgeOffsetInfo={manipulatorInfo:t,mode:"drag"},!0):(this._clearSelection(),this._pendingEdgeOffsetInfo={manipulatorInfo:t,mode:"hover"},this._connectEdgeOffsetTooltipOnHover(t),!0)))}_exitEdgeOffsetInputMode(){this.tooltip&&(this._pendingEdgeOffsetInfo=null,this._resetTooltip(),this.tooltip.exitInputMode())}_findActiveEdgeOffsetManipulatorInfo(){return this._manipulatorInfos.filter(Te).find(({manipulator:e})=>e.hovering||e.grabbing||e.dragging)}_connectEdgeOffsetTooltipOnHover(e){const{_operations:t,object:i}=this;if(!t)return;const{elevationInfo:n}=i,a=ee(t.data.coordinateHelper,e.handle,n);this._selectEdgeOffsetArrow(e,a),this.addHandles([this._initializeEdgeOffsetVisualElement(e,i,n,t),this._connectEdgeOffsetTooltip(e,a,t,()=>{this.removeHandles(a),this._exitEdgeOffsetInputMode()})],a)}_splitEdgesBeforeEdgeOffset(e,t){if(t.requiresSplitEdgeLeft){const t=this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftSegment);null!=t&&this._splitEdgeManipulator(t,1)}if(t.requiresSplitEdgeRight){const t=this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightSegment);null!=t&&this._splitEdgeManipulator(t,0)}}_selectEdgeOffsetArrow(e,t){const i=e.grabMapPoint??Q(this.view.inputManager?.latestPointerInfo?.location,this.view,this.object,e);i&&t.selectArrowFromStartPoint(i)}_connectEdgeOffsetTooltip(e,t,i,n){const a=()=>this.tooltipInfos.edgeOffset.distance.actual,s=a=>{n(),queueMicrotask(()=>{this.view.focus();const n=i.createUndoGroup();this._tooltipCallbacks.onReshapeStart?.(),this._splitEdgesBeforeEdgeOffset(e,t),this._offsetEdge(e,t,ne(a,e.manipulator.location,t,i)),this._tooltipCallbacks.onReshape?.(),this._tooltipCallbacks.onReshapeStop?.(),this._cleanEdgeOffsetCollapsedEdges(e,i),n.remove()})},r=()=>{const e=a();null!=e?s(e):n()};return o([m(()=>this.tooltip&&!this.tooltip.focused,()=>r(),f),this.tooltip.on("discard",n),this.tooltip.on("commit",e=>{"commit-and-exit"===e.type&&r()})])}_createVertexOrEdgeManipulator(e,t=this.object.elevationInfo,i=!1){const n=this.view,a=this._operations,s=this._settings;if(!a)return null;const r=a.data.type,l=a.data.spatialReference;if("line"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(null==this._vertexManipulatorGeometry||null==this._vertexManipulatorOutlineGeometry){const{size:e,outlineSize:t}=He(s.manipulators.vertex);this._vertexManipulatorGeometry=he(this._vertexManipulatorMaterial,e,16,16),this._vertexManipulatorOutlineGeometry=he(this._vertexManipulatorOutlineMaterial,t,16,16)}if(null==this._edgeManipulatorGeometry||null==this._edgeManipulatorOutlineGeometry){const{size:e,outlineSize:t}=He(s.manipulators.edge);this._edgeManipulatorGeometry=he(this._edgeManipulatorMaterial,e,16,16),this._edgeManipulatorOutlineGeometry=he(this._edgeManipulatorOutlineMaterial,t,16,16)}const d="point"===r||"mesh"===r?[]:[new R(this._vertexManipulatorGeometry.instantiate(),4|Pe),new R(this._vertexManipulatorOutlineGeometry.instantiate(),5|Pe),new R(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),6|Pe),new R(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),8),new R(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),9),new R(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),10)];this.enableMidpoints&&d.push(new R(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),6|ke),new R(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),6|ke),new R(this._edgeManipulatorGeometry.instantiate(),5|ke),new R(this._edgeManipulatorOutlineGeometry.instantiate(),5|ke));const h=()=>new P({view:n,renderObjects:d,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:this.object.visible,metadata:{deleting:!1},location:Ve(l)});let u=null;"vertex"===e.type&&(u=this.object.createReshapeManipulator?.({vertex:e,defaultCreate:h,elevationInfo:t,selected:i})??null),u??=h(),u.selected=i,this._setTypeSpecificManipulatorSettings(u,e,t);const c="vertex"===e.type?{manipulator:u,handle:e,type:"vertex",selectedIndex:0}:{manipulator:u,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0};if(this._manipulatorInfos.push(c),this.manipulators.add(u),this._updateManipulatorPosition(c),"edge"===c.type){const e=[];for(const t of[c.handle.leftVertex,c.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(t);null!=i&&e.push(i.manipulator.events.on("location-update",()=>this._updateManipulatorPosition(c)))}c.locationUpdateHandle=o(e),this._manipulatorHandles.add(c.locationUpdateHandle,u)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(u,!0),u);const m=fe(u,(e,i,o,s)=>{let r=null;const{snappingStep:d,cancelSnapping:h}=be({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new Me({editGeometryOperations:a,elevationInfo:t,pointer:s,excludeFeature:this.object.graphic,visualizer:new z}),updatingHandles:this._updatingHandles,useZ:this.tool.snapToScene});o.next(t=>(this._onDragCancel(!e.metadata.deleting,()=>r=p(r)),t)).next(h);const{elevationAlignedLocation:u}=e,m=this.object.graphic??void 0,f=this.tool.snapToScene?this._screenToSceneMapForVertexDrag(t,a,m):F(n,u,t,l,m);i.next(e=>this._trackNumDragging(e)).next(e=>{if("start"===e.action&&a&&(r=a.createUndoGroup()),"edge"===c.type){const t=this._splitEdgeManipulator(c);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:c,snapOrigin:c.handle.pos}}).next(ge(n,u)).next(f).next(ce(n,t,m)).next(...d).next(me()).next(e=>{this._perVertexManipulatorDragAction(e),"end"===e.action&&(r=p(r)),this._resetTooltip()})});return this._manipulatorHandles.add([m,u.events.on("immediate-click",e=>this._manipulatorClickCallback(e,c)),u.events.on("select-changed",()=>{c.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition(),this._resetTooltip()}),u.events.on("focus-changed",()=>{this._resetTooltip()})],u),this.events.emit("manipulators-changed"),c}_screenToSceneMapForVertexDrag(e,t,i){const{view:n}=this,{coordinateHelper:a,spatialReference:o}=t.data;let s=null;return t=>{if("start"===t.action&&(s=a.vectorToPoint(t.snapOrigin)),null==s)return null;const r=n.toMap(t.screenEnd,{exclude:i,excludeLabels:!0});return null==r?null:(r.z=A(r,n,e),V(r,r,o)?{...t,mapStart:s,mapEnd:r}:null)}}_trackNumDragging(e){switch(e.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return e}_onDragCancel(e=!0,t){switch(this._numDragging--,e&&this.undo(),this.tool.snappingManager?.doneSnapping(),this._resetTooltip(),this._reshapeEventState){case 0:break;case 1:this.events.emit("move",{type:"move",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape",object:this.object})}t?.(),this.destroyed||this._updateEventState(0)}_setTypeSpecificManipulatorSettings(e,t,i){const n=this._settings;switch(t.type){case"vertex":{e.selectable=!0,e.cursor="move",e.collisionPriority=2,e.elevationInfo=i;const t=this._operations?.data.type;if(e.interactive=null!=t&&"point"!==t&&"mesh"!==t,null==this.object.createReshapeManipulator){const{size:t,collisionPadding:i}=n.manipulators.vertex;e.radius=t/2+i,e.state=Pe}break}case"line":{e.state=ke,e.selectable=!1,e.cursor="copy",e.collisionPriority=2;const{size:t,collisionPadding:a}=n.manipulators.edge;e.radius=t/2+a,e.elevationInfo="on-the-ground"!==i.mode||G(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:i;break}}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",i=>{this._onGrabStateChanged(e,t,i.action,i.pointerType)})}_onGrabStateChanged(e,t,i,n="mouse"){if(!this._recreatingManipulators){if("start"===i)t&&this._updateSelection(e),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(0),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==n||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach(e=>{const{manipulator:t}=e,i=this._operations?.data.type;t.interactive=t.grabbing||!this._numGrabbing&&null!=i&&"point"!==i&&"mesh"!==i,Te(e)&&(e.edgeManipulator.interactive=e.edgeManipulator.grabbing||!this._numGrabbing)}),this._objectMoveManipulation.forEachManipulator(e=>{e.interactive=e.grabbing||!this._numGrabbing}))}}_clearSelection(){for(const e of this._manipulatorInfos)e.manipulator.grabbing||(e.manipulator.selected=!1);this._pendingEdgeOffsetInfo=null}_updateSelection(e){e.grabbing&&!e.selected&&e.selectable&&(this._clearSelection(),e.selected=!0,this.events.emit("manipulators-changed"))}_removeManipulator(e){null!=e&&(e.manipulator.metadata.deleting=!0,this.manipulators.remove(e.manipulator),this._manipulatorHandles.remove(e.manipulator),i(this._manipulatorInfos,e),this.events.emit("manipulators-changed"),this._resetTooltip())}_getManipulatorInfoFromHandle(e){return this._manipulatorInfos.find(t=>t.handle===e)}_updateManipulatorPositions(e){for(const t of e)this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(t))}_updateManipulatorPosition(e){const t=this._operations;if(null!=e&&t)if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,De),e.manipulator.grabbing&&null!=this._vertexLaserLineVisualElement&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex),n=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==i||null==n)return;const a=i.manipulator,o=n.manipulator;if("on-the-ground"===e.manipulator.elevationInfo?.mode){const i=a.location,n=o.location,s=.5,r=i.x+s*(n.x-i.x),l=i.y+s*(n.y-i.y),p=i.hasZ&&n.hasZ?0:void 0;e.manipulator.location=D(r,l,p,t.data.spatialReference)}else x(Ae,a.renderLocation,o.renderLocation,.5),e.manipulator.renderLocation=Ae}}_splitEdgeManipulator(e,t=.5){const i=this._operations,n=i.splitSegment(e.handle,t).createdVertex;e.locationUpdateHandle=p(e.locationUpdateHandle);const a=this.object.elevationInfo;let o;this.enableEdgeOffset?(this._removeManipulator(e),o=this._createVertexOrEdgeManipulator(n)):(o=e,o.handle=n,o.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,a)),"line"===n.leftSegment?.type&&this._createVertexOrEdgeManipulator(n.leftSegment),"line"===n.rightSegment?.type&&this._createVertexOrEdgeManipulator(n.rightSegment),this._updateManipulatorPosition(o),this.enableEdgeOffset||this._resetTooltip(),this._updateSelection(e.manipulator);const s=this._updateEventState(2),r=i.data.coordinateHelper.vectorToArray(o.handle.pos),l=i.data.parts.indexOf(n.part);return this.events.emit("vertex-add",{type:"vertex-add",object:this.object,vertices:[{coordinates:r,componentIndex:l,vertexIndex:n.index}],added:r}),s&&this._updateEventState(0),o}_updateMoveManipulationPosition(){const e=y(Ae,0,0,0);let t=0,i=!1,n=null,a=null;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.selected?(t++,O(e,e,r.manipulator.renderLocation),null==n||r.selectedIndex>n.selectedIndex?(a=n,n=r):(null==a||r.selectedIndex>a.selectedIndex)&&(a=r)):i=!0);const o=this.object,s=this._operations?.data.geometry;if(0===t){const e=o.visible&&this.enableMoveObject;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e,this._moveManipulation.zManipulation.available=e&&this.enableZShape&&N(this._operations,o.elevationInfo),this._moveManipulation.angle=W(s),this._moveManipulation.radius=K.radiusForSymbol(o.graphic?.symbol)}else{const e=o.visible;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&N(this._operations,this.object.elevationInfo),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t;let i=0;if(null!=n){const e=n.handle.pos,t=null!=a?a.handle.pos:n.handle.leftSegment?.leftVertex?n.handle.leftSegment.leftVertex.pos:null,o=null==a&&n.handle.rightSegment?.rightVertex?n.handle.rightSegment.rightVertex.pos:null;t&&o?this._moveManipulation.xyAxisManipulation.available=!1:t?i=we(t,e):o&&(i=we(e,o))}const s=n?.handle,r=s?o.getReshapeMoveConfig?.({vertex:s,numSelected:t})??null:null;switch(r?.xyAxisMode){case"all":this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e;break;case"hidden":this._moveManipulation.xyAxisManipulation.available=!1,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=!1}this._moveManipulation.angle=r?.angle??i,this._moveManipulation.radius=Y}0!==t&&i?(j(e,e,1/t),De.spatialReference=this._operations.data.spatialReference,De.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,De),this._moveManipulation.elevationAlignedLocation=De):null==this._outlineVisualElement||this.object.isDraped||null==this._outlineVisualElement.attachmentOrigin?U(this._moveManipulation,this.object):this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin}_removeVertices(e){const t=new Array,i=this._operations;if(!i)return;const n=e.filter(e=>"vertex"===e.type&&i.canRemoveVertex(e.handle.part));if(n.length>0){const e=this._createBeforeVertexRemoveEvent(n);if(this.events.emit("before-vertex-remove",e),e.defaultPrevented)return}for(const a of n){const e=a.handle.part;if(i.canRemoveVertex(e)){t.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftSegment)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightSegment));const n=i.removeVertices([a.handle]),o=n.removedVertices?.[0].createdSegment;o&&"line"===o.type?this._createVertexOrEdgeManipulator(o):this.enableEdgeOffset&&e.vertices.length<=2&&this._removeManipulator(this._getManipulatorInfoFromHandle(e.segments[0]))}}if(t.length>0){const e=t.map(e=>{const t=i.data.parts.indexOf(e.part);return{coordinates:i.data.coordinateHelper.vectorToArray(e.pos),componentIndex:t,vertexIndex:e.index}}),n=this._updateEventState(2);if(this.destroyed)return;if(this.events.emit("vertex-remove",{type:"vertex-remove",object:this.object,removed:e.map(e=>e.coordinates),vertices:e}),this.destroyed)return;if(n&&(this._updateEventState(0),this.destroyed))return;this._updateMoveManipulationPosition()}}_createBeforeVertexRemoveEvent(e){const t=this._operations,i=e.map(e=>{const i=t.data.parts.indexOf(e.handle.part);return{coordinates:t.data.coordinateHelper.vectorToArray(e.handle.pos),componentIndex:i,vertexIndex:e.handle.index}});let n=!1;return{type:"before-vertex-remove",object:this.object,removed:i.map(e=>e.coordinates),vertices:i,get defaultPrevented(){return n},preventDefault(){n=!0}}}_moveVertices(e,t,i=("start"===t.action?0:1)){const n=this._operations;if(n){e.length>0&&n.moveVertices(e.map(e=>e.handle),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i);for(const t of e)this._updateManipulatorPosition(t)}}_offsetEdge(e,t,i){if(!this._operations)return;const n=t.clone();n.distance=i,this._operations.updateVertices([e.handle.leftVertex,e.handle.rightVertex],n),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.leftVertex)),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.rightVertex))}_manipulatorClickCallback(e,t){e.shiftKey||this._clearSelection(),"vertex"===t.type&&(t.manipulator.selected=!t.manipulator.selected,this.enableDeleteVertices&&e.button===ue.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===ue.Left&&this._splitEdgeManipulator(t),e.stopPropagation()}_updateTranslateTooltip(e,t){null!=this._defaultTooltipInfo?this._resetTooltip():this._updateTranslateObjectTooltip(e,t)}_updateTranslateObjectTooltip(e,t){this._pendingEdgeOffsetInfo||(this.activeTooltipInfo=se(e,t,this._tooltipsContext,this._updatingHandles))}_updateEdgeOffsetTooltip(e){this._pendingEdgeOffsetInfo||(this.activeTooltipInfo=re(this.object,e,this._tooltipsContext,this._updatingHandles))}_resetTooltip(){const e=this.activeTooltipInfo;if(this._pendingEdgeOffsetInfo&&"reshape-edge-offset"===e?.type)return;let t=null;t=this._pendingEdgeOffsetInfo||null!=this._findActiveEdgeOffsetManipulatorInfo()?re(this.object,null,this._tooltipsContext,this._updatingHandles):this._defaultTooltipInfo,t!==e&&(null!=e&&null!=t&&"input"===this.tooltip.mode||(this.activeTooltipInfo=t))}get _defaultTooltipInfo(){const e=this._operations?.data.type;switch(e){case"multipoint":case"polyline":case"polygon":return this._selectedVertexManipulatorInfo?this.tooltipInfos.selectedVertex:null;case"point":case"mesh":return this.tooltipInfos.movePoint;default:return null}}get _selectedVertexManipulatorInfo(){const e=this._manipulatorInfos.filter(e=>"vertex"===e.type&&e.manipulator.selected);return 1===e.length?e[0]:null}get _tooltipsContext(){const{tooltipInfos:e,activeTooltipInfo:t}=this;return{sketchOptions:this._sketchOptions,tooltipInfos:e,activeTooltipInfo:t,selectedVertexManipulatorInfo:this._selectedVertexManipulatorInfo,callbacks:this._tooltipCallbacks,measurementWorker:this._measurementWorker}}get test(){}};function Se(){return e=>{const{operation:t,mapEnd:i}=e;return null==t||null==i?e:{...e,signedDistance:t.signedDistanceToPoint(i)}}}function He(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}function we(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}function Ve(e){return new H({x:0,y:0,z:0,spatialReference:e})}function Te(e){return"edge"===e.type&&"edgeManipulator"in e}e([g()],Ie.prototype,"_numGrabbing",void 0),e([g()],Ie.prototype,"_numDragging",void 0),e([g()],Ie.prototype,"_pendingEdgeOffsetInfo",void 0),e([g()],Ie.prototype,"_operations",null),e([g()],Ie.prototype,"_segmentLabels",void 0),e([g({constructOnly:!0})],Ie.prototype,"tool",void 0),e([g()],Ie.prototype,"tooltip",void 0),e([g()],Ie.prototype,"activeTooltipInfo",void 0),e([g({readOnly:!0})],Ie.prototype,"updating",null),e([g()],Ie.prototype,"manipulators",null),e([g()],Ie.prototype,"view",null),e([g()],Ie.prototype,"object",null),e([g()],Ie.prototype,"enableZShape",null),e([g()],Ie.prototype,"enableDeleteVertices",null),e([g()],Ie.prototype,"enableZVertex",null),e([g()],Ie.prototype,"autoHideManipulators",null),e([g()],Ie.prototype,"enableMoveObject",null),e([g()],Ie.prototype,"enableMidpoints",null),e([g()],Ie.prototype,"enableEdgeOffset",null),e([g()],Ie.prototype,"_sketchOptions",null),e([g()],Ie.prototype,"_accentColor",null),e([g()],Ie.prototype,"_tooltipsContext",null),Ie=e([_("esri.views.3d.interactive.editingTools.reshape.ReshapeOperation")],Ie);const De=D(0,0,void 0,T.WGS84),Ae=I(),Ge=1e-6,Pe=16,ke=32;export{Ie as ReshapeOperation};
2
+ import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{removeUnordered as i}from"../../../../../core/arrayUtils.js";import{EventEmitter as n}from"../../../../../core/Evented.js";import a from"../../../../../core/Handles.js";import{makeHandle as o,handlesGroup as s,destroyHandle as r}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{destroyMaybe as l,removeMaybe as p}from"../../../../../core/maybe.js";import{watch as h,initial as d,on as u,syncAndInitial as c,when as m,sync as f}from"../../../../../core/reactiveUtils.js";import{property as g,subclass as _}from"../../../../../core/accessorSupport/decorators.js";import{IDENTITY as v}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{length as M,subtract as b,lerp as x,set as y,add as O,scale as E}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as j,create as I}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as S}from"../../../../../core/support/UpdatingHandles.js";import H from"../../../../../geometry/Point.js";import w from"../../../../../geometry/Polyline.js";import{projectPoint as V}from"../../../../../geometry/projectionUtils.js";import D from"../../../../../geometry/SpatialReference.js";import{makeDehydratedPoint as T}from"../../../../../layers/graphics/dehydratedPoint.js";import{getZForElevationMode as A}from"../../../../../support/elevationInfoUtils.js";import{isVolumetricSymbol as G}from"../../../../../symbols/support/utils.js";import{Manipulator3D as C}from"../../Manipulator3D.js";import{createManipulatorMaterial as R,createManipulatorOutlineMaterial as P,placeAtObject as k}from"../../manipulatorUtils.js";import{RenderObject as U}from"../../RenderObject.js";import{SegmentLabels3D as L}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as z}from"../../SnappingVisualizer3D.js";import{screenToMapXYAtLocation as F,screenToRenderPlaneFromEvent as B,convertToMapCoordinates as Z}from"../dragEventPipeline3D.js";import{orientation as W}from"../geometryUtils.js";import{canMoveZOperations as N}from"../manipulatorUtils.js";import{Settings as q}from"../settings.js";import{createVisualElements as X}from"../visualElementUtils.js";import{discRadiusSmall as Y}from"../manipulations/config.js";import{MoveManipulation as K}from"../manipulations/MoveManipulation.js";import{MoveXYObjectManipulation as J}from"../manipulations/MoveXYObjectManipulation.js";import{getMapPointAtEdgeOffsetManipulatorElevation as Q,createEdgeOffsetIntersectionPlane as $,createEdgeOffsetOperation as ee,edgeOffsetRotationMatrix as te,screenEdgeLengthSquared as ie,getDistanceInGeometrySR as ne}from"./edgeOffsetUtils.js";import{createTooltipInfos as ae,connectTooltipToManipulatedObject as oe,getUpdatedTranslateObjectTooltipInfo as se,getUpdatedEdgeOffsetTooltipInfo as re}from"./reshapeTooltipUtils3D.js";import{OutlineVisualElement as le}from"../../visualElements/OutlineVisualElement.js";import{createElevationUpdateHandle as pe}from"../../../support/elevationUpdateUtils.js";import{createExtrudedTriangle as he,createSphereGeometry as de}from"../../../webgl-engine/lib/GeometryUtil.js";import{mouseButtons as ue}from"../../../../input/mouseButtons.js";import{sceneSnappingAtLocation as ce,addMapDelta as me,createManipulatorDragEventPipeline as fe,dragAtLocation as ge,addScreenDelta as _e}from"../../../../interactive/dragEventPipeline.js";import{tooltipKeys as ve}from"../../../../interactive/keybindings.js";import{SnappingContext as Me}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as be}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as xe,enterInputModeIfAvailable as ye}from"../../../../interactive/tooltip/tooltipCommonUtils.js";import{GeometryWorkerHandle as Oe}from"../../../../support/GeometryWorkerHandle.js";const Ee=Symbol(),je=Symbol(),Ie=Symbol(),Se=Symbol();let He=class extends t{get _movingManipulatorsHidden(){return this.hasHandles(Se)}get _operations(){return this.object.operations}constructor(e){super(e),this._selectedIndex=0,this._manipulatorHandles=new a,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=0,this._pendingEdgeOffsetInfo=null,this._updatingHandles=new S,this._recreatingManipulators=!1,this._settings=new q({getTheme:()=>this.view.effectiveTheme}),this.events=new n,this.activeTooltipInfo=null,this._measurementWorker=new Oe({preloadGeodetic:!0}),this._vertexLaserLineVisualElement=null,this._tooltipCallbacks={onBeforeReshape:()=>this.tool.endDrag(),onReshapeStart:()=>this._updateEventState(2),onReshape:()=>this.events.emit("reshape",{type:"reshape",object:this.object}),onReshapeStop:()=>this._updateEventState(0,{forceEnd:!0}),onMoveStart:()=>this._updateEventState(1),onMove:()=>this.events.emit("move",{type:"move",object:this.object,dx:0,dy:0}),onMoveStop:()=>this._updateEventState(0,{forceEnd:!0})}}initialize(){const{view:e}=this,t=this._settings.manipulators,i=t.vertex;this.tooltipInfos=ae(this._sketchOptions,e),this._vertexManipulatorMaterial=R(i.color.toUnitRGBA(),i.renderOccluded),this._vertexManipulatorOutlineMaterial=P(i.outlineColor.toUnitRGBA(),i.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=P(i.hoverOutlineColor.toUnitRGBA(),i.renderOccluded);const n=t.edge;this._edgeManipulatorMaterial=R(n.color.toUnitRGBA(),n.renderOccluded),this._edgeManipulatorOutlineMaterial=P(n.outlineColor.toUnitRGBA(),n.renderOccluded);const a=t.edgeOffset;this._edgeOffsetManipulatorMaterial=R(a.color.toUnitRGBA(),a.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=R(a.hoverColor.toUnitRGBA(),a.renderOccluded,!1);const o=t.selected;this._selectedManipulatorMaterial=R(o.color.toUnitRGBA(),o.renderOccluded),this._selectedManipulatorOutlineMaterial=P(o.outlineColor.toUnitRGBA(),o.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=P(o.hoverOutlineColor.toUnitRGBA(),o.renderOccluded),this.tooltip=xe(()=>({view:e,options:this._sketchOptions.tooltips})),this.addHandles([h(()=>{const e=this._settings.manipulators;return{vertexSettings:e.vertex,edgeSettings:e.edge,edgeOffsetSettings:e.edgeOffset,selectedSettings:e.selected}},({vertexSettings:e,edgeSettings:t,edgeOffsetSettings:i,selectedSettings:n})=>{e.applyColor(this._vertexManipulatorMaterial),e.applyOutline(this._vertexManipulatorOutlineMaterial),e.applyHoverOutline(this._vertexManipulatorHoverOutlineMaterial),t.applyColor(this._edgeManipulatorMaterial),t.applyOutline(this._edgeManipulatorOutlineMaterial),i.applyColor(this._edgeOffsetManipulatorMaterial),i.applyHover(this._edgeOffsetManipulatorHoverMaterial),n.applyColor(this._selectedManipulatorMaterial),n.applyOutline(this._selectedManipulatorOutlineMaterial),n.applyHoverOutline(this._selectedManipulatorHoverOutlineMaterial)}),h(()=>this.object.visible,e=>{for(const t of this._manipulatorInfos)t.manipulator.available=e,Ae(t)&&(t.edgeManipulator.available=e)}),h(()=>this._numGrabbing+this._numDragging===0,e=>this._toggleAutoHideManipulators(e)),h(()=>({labels:this._segmentLabels,enabled:this._sketchOptions.labels.enabled,edgeOffsetEnabled:this.enableEdgeOffset}),({labels:e,enabled:t,edgeOffsetEnabled:i})=>{null!=e&&(e.visible=t,e.edgeDistance=i?"far":"default")},d),oe(this.tooltip,this.object,()=>this._tooltipsContext,this._updatingHandles),h(()=>this.tooltip.mode,(e,t)=>{"input"===t&&"input"!==e&&this._resetTooltip()}),u(()=>this._operations,"vertex-update",e=>this._updateManipulatorPositions(e.vertices),{onListenerAdd:()=>this._recreateManipulators()}),u(()=>this._operations?.data,"change",e=>{"undo"!==e.operation&&"redo"!==e.operation||this._recreateManipulators()})])}destroy(){this._removeManipulators(),this._updatingHandles.destroy(),this._segmentLabels=l(this._segmentLabels),this.tooltip=l(this.tooltip),this._measurementWorker.destroy()}get updating(){return this._updatingHandles.updating||!!this._segmentLabels?.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get object(){return this.tool.object}get enableZShape(){return this.tool.enableZShape}get enableDeleteVertices(){return this.tool.enableDeleteVertices}get enableZVertex(){return this.tool.enableZVertex}get autoHideManipulators(){return this.tool.autoHideManipulators}get enableMoveObject(){return this.tool.enableMoveObject}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}get _sketchOptions(){return this.tool.sketchOptions}get _accentColor(){return this.view.effectiveTheme.accentColor}enterInputModeIfAvailable(e){return"key-down"===e.type&&e.key===ve.enterInputMode&&("reshape-edge-offset"===this.activeTooltipInfo?.type?this._enterInputModeDuringEdgeOffset(e):!!ye(e,this.tooltip)&&(this.tool.endDrag(),!0))}removeSelectedVertices(){const e=this._manipulatorInfos.filter(e=>e.manipulator.selected&&"vertex"===e.type);return this._removeVertices(e),e.length}onManipulatorSelectionChanged(){this.events.emit("manipulators-changed")}clearSelection(){let e=!1;for(const t of this._manipulatorInfos)if(t.manipulator.selected){e=!0;break}e&&(this._clearSelection(),this._updateMoveManipulationPosition(),this.events.emit("manipulators-changed"))}selectManipulator(e){if(null==this._manipulatorInfos.find(t=>t.manipulator===e)||!e.selectable)return!1;let t=e.selected;for(const i of this._manipulatorInfos)if(i.manipulator!==e&&i.manipulator.selected){t=!1;break}return t||(this._clearSelection(),e.selected=!0,this._updateMoveManipulationPosition(),this.events.emit("manipulators-changed")),!0}_removeManipulators(){this._manipulatorHandles.removeAll(),this.removeHandles(je),this.removeHandles(Se),this._moveManipulation=l(this._moveManipulation),this._objectMoveManipulation=l(this._objectMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0}_createManipulators(e){if(null==this._operations)return;const t=this.object.elevationInfo;for(const{vertices:i,segments:n,index:a}of this._operations.data.parts){const o=e?.byPartIndex.get(a);for(const e of i){const i=o?.has(e.index);this._createVertexOrEdgeManipulator(e,t,i)}for(const e of n)"line"===e.type&&this._createVertexOrEdgeManipulator(e,t)}this._createObjectMoveManipulation(),this._createMoveManipulation(t),this._createVisualElements()}recordUndo(e){this._operations?.recordUndo(e,!0)}get canRedo(){return this._operations?.canRedo??!1}get canUndo(){return this._operations?.canUndo??!1}redo(){return this._operations?.redo()}undo(){return this.events.emit("undo"),this._operations?.undo()}_recreateManipulators(){if(!this._recreatingManipulators){if(this._recreatingManipulators=!0,this._removeManipulators(),this._resetTooltip(),this._operations&&this._segmentLabels?.context?.editGeometryOperations===this._operations||(this._segmentLabels=l(this._segmentLabels)),this._createManipulators(),!this._segmentLabels&&this._operations){const e=this._sketchOptions.labels;this._segmentLabels=new L({context:{view:this.view,editGeometryOperations:this._operations,elevationInfo:this.object.elevationInfo,labelOptions:e},visible:e.enabled})}this._recreatingManipulators=!1}}_perObjectManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const n=[],a=1===e&&this._someVerticesSelected;for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.grabbing||a&&!o.manipulator.selected||n.push(o),i++);if(n.length===i){if(a||this._hideReshapeControls(),this._moveVertices(n,t),this._updateEventState(1),this.destroyed)return t;this.events.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,object:this.object})}else{if(this._moveVertices(n,t),this._updateEventState(2),this.destroyed)return t;this.events.emit("reshape",{type:"reshape",object:this.object})}return t}_hideReshapeControls(){this._movingManipulatorsHidden||this.addHandles([this._hideReshapeManipulators(),this._moveManipulation.hideManipulatorsExceptGrabbedGroup(),o(()=>this._forEachVertex(e=>this._updateManipulatorPosition(e)))],Se)}_showReshapeControls(){this.removeHandles(Se)}_shouldHideReshapeControlsOnGrab(e){return this._objectMoveManipulation.hasManipulator(e)||this._moveManipulation.hasManipulator(e)&&!this._someVerticesSelected}get _canShowReshapeControls(){return!this._objectMoveManipulation.grabbing&&(!this._moveManipulation.grabbing||this._someVerticesSelected)}_hideManipulatorsForEdgeOffset(e){const t=this._manipulatorInfos.filter(Ae).find(t=>t.manipulator===e||t.edgeManipulator===e);null!=t&&(this.removeHandles(je),this.addHandles([this._moveManipulation.hideManipulators(),this._hideReshapeManipulators(t)],je))}_hideReshapeManipulators(e){return s(this._manipulatorInfos.flatMap(t=>t===e?null:[t.manipulator.disableDisplay(),Ae(t)?t.edgeManipulator.disableDisplay():null]))}_toggleAutoHideManipulators(e){this.autoHideManipulators&&(e?this.removeHandles(Ee):this.tool.manipulators.forEach(({manipulator:e})=>{const t=e.disableDisplay?.();t&&this.addHandles(t,Ee)}))}_isMultiVertexSelection(){return this._manipulatorInfos.reduce((e,t)=>"vertex"===t.type&&t.manipulator.selected?e+1:e,0)>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(2),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:n}=e;if(!t&&!i&&!n)return;const a=[];this._forEachVertex(t=>{const{selected:i,grabbing:n}=t.manipulator;(i&&!n||t===e.info)&&a.push(t)}),this._moveVertices(a,e,1),this.events.emit("reshape",{type:"reshape",object:this.object})}_updateEventState(e,t={}){if(e===this._reshapeEventState)return!1;switch(e){case 0:if(!t.forceEnd&&(0!==this._numGrabbing||0!==this._numDragging))return!1;switch(this._reshapeEventState){case 1:this._showReshapeControls(),this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape-stop",object:this.object})}break;case 1:switch(this._reshapeEventState){case 0:this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape-stop",object:this.object}),this.destroyed||this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object})}break;case 2:switch(this._reshapeEventState){case 0:this.events.emit("reshape",{type:"reshape-start",object:this.object});break;case 1:this._showReshapeControls(),this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object}),this.destroyed||this.events.emit("reshape",{type:"reshape-start",object:this.object})}}if(this.destroyed)return!1;const i=this._reshapeEventState!==e;return this._reshapeEventState=e,i}_createObjectMoveManipulation(){const{tool:e,view:t,object:i,_operations:n}=this;if(n){if(this._objectMoveManipulation=new J({tool:e,view:t,object:i}),this.enableMoveObject){let e=null;this._manipulatorHandles.add(this._objectMoveManipulation.createDragPipeline((t,i,a)=>{i.next(e=>this._trackNumDragging(e)).next(t=>("start"===t.action&&(e=n.createUndoGroup()),t)).next(e=>this._perObjectManipulatorDragAction(0,e)).next(e=>(this._updateTranslateObjectTooltip(0,e),e)).next(t=>{"end"===t.action&&(this._showReshapeControls(),this._resetTooltip(),e=p(e))}),a.next(()=>this._onDragCancel(!0,()=>e=p(e)))})),this._objectMoveManipulation.forEachManipulator(e=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(e,!1)))}else this._objectMoveManipulation.forEachManipulator(e=>{e.grabbable=!1,e.cursor=null});this._objectMoveManipulation.forEachManipulator(e=>this._manipulatorHandles.add(e.events.on("immediate-click",e=>{this._manipulatorInfos.some(e=>e.manipulator.selected)?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()})))}}_createMoveManipulation(e){const{object:t,tool:i,view:n,_operations:a}=this;if(!a)return;this._moveManipulation=new K({tool:i,view:n,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&N(t.operations,t.elevationInfo),snapToScene:!1,radius:K.radiusForSymbol(t.graphic?.symbol)}),this._moveManipulation.forEachManipulator(e=>this.addHandles([e.events.on("immediate-click",t=>{this._moveManipulation.zManipulation.hasManipulator(e)||this._manipulatorInfos.some(e=>e.manipulator.selected)||this.events.emit("immediate-click",{...t,object:this.object}),t.stopPropagation()}),this._watchAndUpdateGrabState(e,!1)]));const o=e=>t=>{this.addHandles([t.events.on("focus-changed",({action:t})=>{"focus"===t?this._updateTranslateTooltip(e):this._resetTooltip()})])};this._moveManipulation.xyManipulation.forEachManipulator(o(0)),this._moveManipulation.xyAxisManipulation.forEachManipulator(o(1)),this._moveManipulation.zManipulation.forEachManipulator(o(2)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const s=a.data.spatialReference;this.addHandles([this._moveManipulation.createDragPipeline((n,o,s,r,l)=>{const{snappingStep:p,cancelSnapping:h}=be({predicate:e=>!!e.info,snappingManager:i.snappingManager,snappingContext:new Me({editGeometryOperations:a,elevationInfo:e,pointer:l,excludeFeature:t.graphic,visualizer:new z}),updatingHandles:this._updatingHandles,useZ:!1});return r=r.next(e=>(this._onDragCancel(),e)).next(h),{steps:s=s.next(e=>this._trackNumDragging(e)).next(e=>{const t=this._manipulatorInfos.filter(e=>"vertex"===e.type&&e.manipulator.selected);return 1===e.manipulatorType&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:e}).next(ce(this.view,e,t.graphic??void 0)).next(...p).next(me()).next(e=>this._perObjectManipulatorDragAction(1,e)).next(e=>("end"===e.action&&this._showReshapeControls(),this._updateTranslateTooltip(n,e),e)),cancel:r}},e,s,t.graphic),h(()=>t.visible,()=>this._updateMoveManipulationPosition(),d),t.on("committed",()=>{this._recreatingManipulators||this._updateMoveManipulationPosition()}),h(()=>t.isDraped,e=>{this._updateMoveManipulationPosition(),this.removeHandles(Ie),e&&this.addHandles(pe({view:this.view,geometry:t.graphic?.geometry,elevationInfo:t.elevationInfo,onElevationChanges:()=>this._updateMoveManipulationPosition()}),Ie)},d)])}_createVisualElements(){const{object:e,view:t}=this,i=X({view:t,object:e,forEachManipulator:e=>{if(!this.destroyed&&!this._recreatingManipulators){this._objectMoveManipulation.forEachManipulator(e),this._moveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,1)}},onManipulatorsChanged:e=>this.events.on("manipulators-changed",e)});null!=i&&(this._outlineVisualElement=i.visualElement instanceof le?i.visualElement:null);const n=this._outlineVisualElement;if(null!=n){const t=()=>{e.isDraped||this._updateMoveManipulationPosition()};this._manipulatorHandles.add(u(()=>n.events,"attachment-origin-changed",t,{onListenerAdd:t}))}this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(e,t=this.object.elevationInfo){const i=this.view,n=this._operations;if(e.part.vertices.length<=2||!n)return null;const a=n.data.spatialReference,o=this._settings.manipulators.edgeOffset,r=o.size/2,l=r+o.collisionPadding,p=r/l,h=p/2,d=p*Math.sqrt(3)/2,{height:u,offset:c}=o,m=this._edgeOffsetManipulatorMaterial;if(!this._edgeOffsetManipulatorGeometryInside){const e=he(m,d,h,h,u,c);this._edgeOffsetManipulatorGeometryInside=e}if(!this._edgeOffsetManipulatorGeometryOutside){const e=he(m,-d,h,h,u,-c);this._edgeOffsetManipulatorGeometryOutside=e}const f=[new U(this._edgeOffsetManipulatorGeometryInside.instantiate(),1),new U(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),2),new U(this._edgeOffsetManipulatorGeometryOutside.instantiate(),1),new U(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),2)],g=new C({view:i,renderObjects:f,elevationInfo:"on-the-ground"!==t.mode||G(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:t,worldOriented:!1,focusMultiplier:1,radius:l,available:this.object.visible,collisionType:{type:"disc",direction:j(0,0,1)},collisionPriority:1,metadata:{deleting:!1},location:Te(a)}),_=new C({view:i,worldSized:!0,worldOriented:!1,available:this.object.visible,collisionPriority:-10,cursor:this.enableMoveObject?"move":"default",metadata:{deleting:!1},location:Te(a)}),v={manipulator:g,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:_,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(v,o.minSquaredEdgeLength);const M=()=>this._updateEdgeOffsetManipulator(v);M(),v.locationUpdateHandle=s([e.leftVertex,e.rightVertex].map(e=>{const t=this._getManipulatorInfoFromHandle(e);return t?.manipulator.events.on("location-update",M)}));const b=e=>{this._manipulatorInfos.some(e=>e.manipulator.selected)?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()};return this._manipulatorHandles.add([v.locationUpdateHandle,this._watchAndUpdateGrabState(g,!0),this._watchAndUpdateGrabState(_,!0),fe(g,this._createEdgeOffsetPipeline(v,t,n)),fe(_,this._createEdgePipeline(v,t,n)),_.events.on("immediate-click",b),g.events.on("immediate-click",b),g.events.on("focus-changed",()=>this._resetTooltip()),g.events.on("grab-changed",({screenPoint:e,action:t})=>{v.grabMapPoint="start"===t?Q(e,this.view,this.object,v):null})],g),this._manipulatorInfos.push(v),this.manipulators.addMany([g,_]),this.events.emit("manipulators-changed"),v}_autoHideEdgeOffsetManipulator(e,t){const i=e.manipulator,n=e.edgeManipulator,a=()=>{e.visibilityHandle=p(e.visibilityHandle);const a=this._getManipulatorInfoFromHandle(e.handle.leftVertex),r=this._getManipulatorInfoFromHandle(e.handle.rightVertex),l=null!=a&&null!=r&&ie(a.manipulator.renderLocation,r.manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!n.focused||l)&&(i.grabbable=!l,n.grabbable=!l,e.visibilityHandle=s([i.disableDisplay(),o(()=>{i.grabbable=!0,n.grabbable=this.enableMoveObject})]))};this._manipulatorHandles.add([i.events.on("focus-changed",a),n.events.on("focus-changed",a),o(()=>{p(e.visibilityHandle),n.metadata.deleting=!0,this.manipulators.remove(n)})],i),a()}_updateEdgeOffsetManipulator(e){if(!this._operations)return;this._updateManipulatorPosition(e);const{coordinateHelper:t}=this._operations.data,i=$(this.view,e.manipulator.elevationAlignedLocation,ee(t,e.handle,e.manipulator.elevationInfo)),n=this._getManipulatorInfoFromHandle(e.handle.leftVertex),a=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==n||null==a)return;const o=n.manipulator.renderLocation,s=a.manipulator.renderLocation,r=null!=i?te(i,o,s):v;e.manipulator.modelTransform=r,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=r;const l=M(b(Ce,o,s))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-l,0,0],[l,0,0]]]}}_createEdgePipeline(e,t,i){return(n,a,o,s)=>{if("touch"===s){this._createEdgeOffsetPipeline(e,t,i)(n,a,o)}else if(this.enableMoveObject){const e=this.object.graphic,s=i.data.spatialReference,{elevationAlignedLocation:r}=n;a.next(e=>this._trackNumDragging(e)).next(ge(this.view,r)).next(F(this.view,r,t,s,e)).next(_e()).next(me()).next(e=>this._perObjectManipulatorDragAction(0,e)).next(e=>(this._updateTranslateObjectTooltip(0,e),e)).next(e=>{"end"===e.action&&(this._showReshapeControls(),this._resetTooltip())}),o.next(()=>this._onDragCancel(!n.metadata.deleting))}}}_createEdgeOffsetPipeline(e,t,i){return(n,a,o)=>{const s=this._pendingEdgeOffsetInfo;if(s?.manipulatorInfo===e&&"drag"!==s.mode)return void o.execute({action:"cancel"});this._clearSelection();const{initializeStep:r,cleanup:l}=this._initializeEdgeOffset(e,t,i,o),p=this._applyEdgeOffsetStep(e);a.next(e=>this._trackNumDragging(e)).next(ge(this.view,n.elevationAlignedLocation)).next(r).next(B(this.view)).next(Z(this.view,i.data.spatialReference)).next(me()).next(we()).next(e=>this._pendingEdgeOffsetInfo?e:p(e)).next(e=>{"end"!==e.action||this._pendingEdgeOffsetInfo||l()}),o.next(()=>{this._exitEdgeOffsetInputMode(),n.metadata.deleting||(l(),this._onDragCancel())})}}_initializeEdgeOffset(e,t,i,n){const{view:a,object:o}=this,r=ee(i.data.coordinateHelper,e.handle,t),l=i.createUndoGroup(),h=$(a,e.manipulator.elevationAlignedLocation,r);let d;this._splitEdgesBeforeEdgeOffset(e,r),this._selectEdgeOffsetArrow(e,r);const u=()=>{this._cleanEdgeOffsetCollapsedEdges(e,i),d=p(d)},c=this.events.on("undo",u);return d=s([this._initializeEdgeOffsetVisualElement(e,o,t,i),l,c,this._connectEdgeOffsetTooltip(e,r,i,()=>{n.execute({action:"cancel"})})]),{initializeStep:e=>null==r||null==h?(u(),null):{...e,operation:r,plane:h},cleanup:u}}_initializeEdgeOffsetVisualElement(e,t,i,n){const a=()=>new w({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:n.data.spatialReference}),o=new le({view:this.view,isDraped:t.isDraped,geometry:a(),elevationInfo:i,width:this._settings.visualElements.lineObjects.outline.width,attached:!1,isDecoration:!0}),l=s([h(()=>({color:this._accentColor,draped:t.isDraped}),({color:e,draped:t})=>{o.color=e.toUnitRGBA(),o.isDraped=t},c),t.on("committed",()=>{o.geometry=a()}),r(o)]);return o.attached=!0,l}_applyEdgeOffsetStep(e){return t=>(this.destroyed||null==t.operation||!this._operations||(this._updateEventState(2),null==t.signedDistance?this._resetTooltip():((t.mapDeltaX||t.mapDeltaY||t.mapDeltaZ)&&(this._offsetEdge(e,t.operation,t.signedDistance),this.events.emit("reshape",{type:"reshape",object:this.object})),this._updateEdgeOffsetTooltip(t))),t)}_cleanEdgeOffsetCollapsedEdges(e,t){const i=e.handle.leftVertex.leftSegment?.leftVertex,n=e.handle.leftVertex,a=e.handle.rightVertex.rightSegment?.rightVertex,o=e.handle.rightVertex,s=t.data.coordinateHelper,r=this.view.pixelSizeAt(s.vectorToDehydratedPoint(n.pos),s.spatialReference),l=[];if(i&&s.distance(i.pos,n.pos)<Re){const e=this._getManipulatorInfoFromHandle(n);null!=e&&l.push(e)}if(s.distance(n.pos,o.pos)<r||a&&s.distance(a.pos,o.pos)<Re){const e=this._getManipulatorInfoFromHandle(o);null!=e&&l.push(e)}l.length&&this._removeVertices(l)}_enterInputModeDuringEdgeOffset(e){const t=this._findActiveEdgeOffsetManipulatorInfo();return!!t&&(!!ye(e,this.tooltip)&&(t.manipulator.dragging?(this._pendingEdgeOffsetInfo={manipulatorInfo:t,mode:"drag"},!0):(this._clearSelection(),this._pendingEdgeOffsetInfo={manipulatorInfo:t,mode:"hover"},this._connectEdgeOffsetTooltipOnHover(t),!0)))}_exitEdgeOffsetInputMode(){this.tooltip&&(this._pendingEdgeOffsetInfo=null,this._resetTooltip(),this.tooltip.exitInputMode())}_findActiveEdgeOffsetManipulatorInfo(){return this._manipulatorInfos.filter(Ae).find(({manipulator:e})=>e.hovering||e.grabbing||e.dragging)}_connectEdgeOffsetTooltipOnHover(e){const{_operations:t,object:i}=this;if(!t)return;const{elevationInfo:n}=i,a=ee(t.data.coordinateHelper,e.handle,n);this._selectEdgeOffsetArrow(e,a),this.addHandles([this._initializeEdgeOffsetVisualElement(e,i,n,t),this._connectEdgeOffsetTooltip(e,a,t,()=>{this.removeHandles(a),this._exitEdgeOffsetInputMode()})],a)}_splitEdgesBeforeEdgeOffset(e,t){if(t.requiresSplitEdgeLeft){const t=this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftSegment);null!=t&&this._splitEdgeManipulator(t,1)}if(t.requiresSplitEdgeRight){const t=this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightSegment);null!=t&&this._splitEdgeManipulator(t,0)}}_selectEdgeOffsetArrow(e,t){const i=e.grabMapPoint??Q(this.view.inputManager?.latestPointerInfo?.location,this.view,this.object,e);i&&t.selectArrowFromStartPoint(i)}_connectEdgeOffsetTooltip(e,t,i,n){const a=()=>this.tooltipInfos.edgeOffset.distance.actual,o=a=>{n(),queueMicrotask(()=>{this.view.focus();const n=i.createUndoGroup();this._tooltipCallbacks.onReshapeStart?.(),this._splitEdgesBeforeEdgeOffset(e,t),this._offsetEdge(e,t,ne(a,e.manipulator.location,t,i)),this._tooltipCallbacks.onReshape?.(),this._tooltipCallbacks.onReshapeStop?.(),this._cleanEdgeOffsetCollapsedEdges(e,i),n.remove()})},r=()=>{const e=a();null!=e?o(e):n()};return s([m(()=>this.tooltip&&!this.tooltip.focused,()=>r(),f),this.tooltip.on("discard",n),this.tooltip.on("commit",e=>{"commit-and-exit"===e.type&&r()})])}_createVertexOrEdgeManipulator(e,t=this.object.elevationInfo,i=!1){const n=this.view,a=this._operations,o=this._settings;if(!a)return null;const r=a.data.type,l=a.data.spatialReference;if("line"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(null==this._vertexManipulatorGeometry||null==this._vertexManipulatorOutlineGeometry){const{size:e,outlineSize:t}=Ve(o.manipulators.vertex);this._vertexManipulatorGeometry=de(this._vertexManipulatorMaterial,e,16,16),this._vertexManipulatorOutlineGeometry=de(this._vertexManipulatorOutlineMaterial,t,16,16)}if(null==this._edgeManipulatorGeometry||null==this._edgeManipulatorOutlineGeometry){const{size:e,outlineSize:t}=Ve(o.manipulators.edge);this._edgeManipulatorGeometry=de(this._edgeManipulatorMaterial,e,16,16),this._edgeManipulatorOutlineGeometry=de(this._edgeManipulatorOutlineMaterial,t,16,16)}const h="point"===r||"mesh"===r?[]:[new U(this._vertexManipulatorGeometry.instantiate(),4|Pe),new U(this._vertexManipulatorOutlineGeometry.instantiate(),5|Pe),new U(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),6|Pe),new U(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),8),new U(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),9),new U(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),10)];this.enableMidpoints&&h.push(new U(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),6|ke),new U(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),6|ke),new U(this._edgeManipulatorGeometry.instantiate(),5|ke),new U(this._edgeManipulatorOutlineGeometry.instantiate(),5|ke));const d=()=>new C({view:n,renderObjects:h,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:this.object.visible,metadata:{deleting:!1},location:Te(l)});let u=null;"vertex"===e.type&&(u=this.object.createReshapeManipulator?.({vertex:e,defaultCreate:d,elevationInfo:t,selected:i})??null),u??=d(),u.selected=i,this._setTypeSpecificManipulatorSettings(u,e,t);const c="vertex"===e.type?{manipulator:u,handle:e,type:"vertex",selectedIndex:0}:{manipulator:u,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0};if(this._manipulatorInfos.push(c),this.manipulators.add(u),this._updateManipulatorPosition(c),"edge"===c.type){const e=[];for(const t of[c.handle.leftVertex,c.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(t);null!=i&&e.push(i.manipulator.events.on("location-update",()=>this._updateManipulatorPosition(c)))}c.locationUpdateHandle=s(e),this._manipulatorHandles.add(c.locationUpdateHandle,u)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(u,!0),u);const m=fe(u,(e,i,o,s)=>{let r=null;const{snappingStep:h,cancelSnapping:d}=be({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new Me({editGeometryOperations:a,elevationInfo:t,pointer:s,excludeFeature:this.object.graphic,visualizer:new z}),updatingHandles:this._updatingHandles,useZ:this.tool.snapToScene});o.next(t=>(this._onDragCancel(!e.metadata.deleting,()=>r=p(r)),t)).next(d);const{elevationAlignedLocation:u}=e,m=this.object.graphic??void 0,f=this.tool.snapToScene?this._screenToSceneMapForVertexDrag(t,a,m):F(n,u,t,l,m);i.next(e=>this._trackNumDragging(e)).next(e=>{if("start"===e.action&&a&&(r=a.createUndoGroup()),"edge"===c.type){const t=this._splitEdgeManipulator(c);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:c,snapOrigin:c.handle.pos}}).next(ge(n,u)).next(f).next(ce(n,t,m)).next(...h).next(me()).next(e=>{this._perVertexManipulatorDragAction(e),"end"===e.action&&(r=p(r)),this._resetTooltip()})});return this._manipulatorHandles.add([m,u.events.on("immediate-click",e=>this._manipulatorClickCallback(e,c)),u.events.on("select-changed",()=>{c.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition(),this._resetTooltip()}),u.events.on("focus-changed",()=>{this._resetTooltip()})],u),this.events.emit("manipulators-changed"),c}_screenToSceneMapForVertexDrag(e,t,i){const{view:n}=this,{coordinateHelper:a,spatialReference:o}=t.data;let s=null;return t=>{if("start"===t.action&&(s=a.vectorToPoint(t.snapOrigin)),null==s)return null;const r=n.toMap(t.screenEnd,{exclude:i,excludeLabels:!0});return null==r?null:(r.z=A(r,n,e),V(r,r,o)?{...t,mapStart:s,mapEnd:r}:null)}}_trackNumDragging(e){switch(e.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return e}_onDragCancel(e=!0,t){switch(this._numDragging--,e&&this.undo(),this.tool.snappingManager?.doneSnapping(),this._showReshapeControls(),this._resetTooltip(),this._reshapeEventState){case 0:break;case 1:this.events.emit("move",{type:"move",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape",object:this.object})}t?.(),this.destroyed||this._updateEventState(0)}_setTypeSpecificManipulatorSettings(e,t,i){const n=this._settings;switch(t.type){case"vertex":{e.selectable=!0,e.cursor="move",e.collisionPriority=2,e.elevationInfo=i;const t=this._operations?.data.type;if(e.interactive=null!=t&&"point"!==t&&"mesh"!==t,null==this.object.createReshapeManipulator){const{size:t,collisionPadding:i}=n.manipulators.vertex;e.radius=t/2+i,e.state=Pe}break}case"line":{e.state=ke,e.selectable=!1,e.cursor="copy",e.collisionPriority=2;const{size:t,collisionPadding:a}=n.manipulators.edge;e.radius=t/2+a,e.elevationInfo="on-the-ground"!==i.mode||G(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:i;break}}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",i=>{this._onGrabStateChanged(e,t,i.action,i.pointerType)})}_onGrabStateChanged(e,t,i,n="mouse"){if(!this._recreatingManipulators){if("start"===i)t&&this._updateSelection(e),this._numGrabbing++,this._shouldHideReshapeControlsOnGrab(e)&&this._hideReshapeControls(),this._hideManipulatorsForEdgeOffset(e);else if(this._numGrabbing--,this.removeHandles(je),this._updateEventState(0),this._canShowReshapeControls&&this._showReshapeControls(),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==n||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach(e=>{const{manipulator:t}=e,i=this._operations?.data.type;t.interactive=t.grabbing||!this._numGrabbing&&null!=i&&"point"!==i&&"mesh"!==i,Ae(e)&&(e.edgeManipulator.interactive=e.edgeManipulator.grabbing||!this._numGrabbing)}),this._objectMoveManipulation.forEachManipulator(e=>{e.interactive=e.grabbing||!this._numGrabbing}))}}_clearSelection(){for(const e of this._manipulatorInfos)e.manipulator.grabbing||(e.manipulator.selected=!1);this._pendingEdgeOffsetInfo=null}_updateSelection(e){e.grabbing&&!e.selected&&e.selectable&&(this._clearSelection(),e.selected=!0,this.events.emit("manipulators-changed"))}_removeManipulator(e){null!=e&&(e.manipulator.metadata.deleting=!0,this.manipulators.remove(e.manipulator),this._manipulatorHandles.remove(e.manipulator),i(this._manipulatorInfos,e),this.events.emit("manipulators-changed"),this._resetTooltip())}_getManipulatorInfoFromHandle(e){return this._manipulatorInfos.find(t=>t.handle===e)}_updateManipulatorPositions(e){if(!this._movingManipulatorsHidden)for(const t of e)this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(t))}_updateManipulatorPosition(e){const t=this._operations;if(null!=e&&t)if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,Ge),e.manipulator.grabbing&&null!=this._vertexLaserLineVisualElement&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex),n=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==i||null==n)return;const a=i.manipulator,o=n.manipulator;if("on-the-ground"===e.manipulator.elevationInfo?.mode){const i=a.location,n=o.location,s=.5,r=i.x+s*(n.x-i.x),l=i.y+s*(n.y-i.y),p=i.hasZ&&n.hasZ?0:void 0;e.manipulator.location=T(r,l,p,t.data.spatialReference)}else x(Ce,a.renderLocation,o.renderLocation,.5),e.manipulator.renderLocation=Ce}}_splitEdgeManipulator(e,t=.5){const i=this._operations,n=i.splitSegment(e.handle,t).createdVertex;e.locationUpdateHandle=p(e.locationUpdateHandle);const a=this.object.elevationInfo;let o;this.enableEdgeOffset?(this._removeManipulator(e),o=this._createVertexOrEdgeManipulator(n)):(o=e,o.handle=n,o.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,a)),"line"===n.leftSegment?.type&&this._createVertexOrEdgeManipulator(n.leftSegment),"line"===n.rightSegment?.type&&this._createVertexOrEdgeManipulator(n.rightSegment),this._updateManipulatorPosition(o),this.enableEdgeOffset||this._resetTooltip(),this._updateSelection(e.manipulator);const s=this._updateEventState(2),r=i.data.coordinateHelper.vectorToArray(o.handle.pos),l=i.data.parts.indexOf(n.part);return this.events.emit("vertex-add",{type:"vertex-add",object:this.object,vertices:[{coordinates:r,componentIndex:l,vertexIndex:n.index}],added:r}),s&&this._updateEventState(0),o}_updateMoveManipulationPosition(){const e=y(Ce,0,0,0);let t=0,i=!1,n=null,a=null;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.selected?(t++,O(e,e,r.manipulator.renderLocation),null==n||r.selectedIndex>n.selectedIndex?(a=n,n=r):(null==a||r.selectedIndex>a.selectedIndex)&&(a=r)):i=!0);const o=this.object,s=this._operations?.data.geometry;if(0===t){const e=o.visible&&this.enableMoveObject;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e,this._moveManipulation.zManipulation.available=e&&this.enableZShape&&N(this._operations,o.elevationInfo),this._moveManipulation.angle=W(s),this._moveManipulation.radius=K.radiusForSymbol(o.graphic?.symbol)}else{const e=o.visible;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&N(this._operations,this.object.elevationInfo),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t;let i=0;if(null!=n){const e=n.handle.pos,t=null!=a?a.handle.pos:n.handle.leftSegment?.leftVertex?n.handle.leftSegment.leftVertex.pos:null,o=null==a&&n.handle.rightSegment?.rightVertex?n.handle.rightSegment.rightVertex.pos:null;t&&o?this._moveManipulation.xyAxisManipulation.available=!1:t?i=De(t,e):o&&(i=De(e,o))}const s=n?.handle,r=s?o.getReshapeMoveConfig?.({vertex:s,numSelected:t})??null:null;switch(r?.xyAxisMode){case"all":this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e;break;case"hidden":this._moveManipulation.xyAxisManipulation.available=!1,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=!1}this._moveManipulation.angle=r?.angle??i,this._moveManipulation.radius=Y}0!==t&&i?(E(e,e,1/t),Ge.spatialReference=this._operations.data.spatialReference,Ge.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,Ge),this._moveManipulation.elevationAlignedLocation=Ge):null==this._outlineVisualElement||this.object.isDraped||null==this._outlineVisualElement.attachmentOrigin?k(this._moveManipulation,this.object):this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin}_removeVertices(e){const t=new Array,i=this._operations;if(!i)return;const n=e.filter(e=>"vertex"===e.type&&i.canRemoveVertex(e.handle.part));if(n.length>0){const e=this._createBeforeVertexRemoveEvent(n);if(this.events.emit("before-vertex-remove",e),e.defaultPrevented)return}for(const a of n){const e=a.handle.part;if(i.canRemoveVertex(e)){t.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftSegment)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightSegment));const n=i.removeVertices([a.handle]),o=n.removedVertices?.[0].createdSegment;o&&"line"===o.type?this._createVertexOrEdgeManipulator(o):this.enableEdgeOffset&&e.vertices.length<=2&&this._removeManipulator(this._getManipulatorInfoFromHandle(e.segments[0]))}}if(t.length>0){const e=t.map(e=>{const t=i.data.parts.indexOf(e.part);return{coordinates:i.data.coordinateHelper.vectorToArray(e.pos),componentIndex:t,vertexIndex:e.index}}),n=this._updateEventState(2);if(this.destroyed)return;if(this.events.emit("vertex-remove",{type:"vertex-remove",object:this.object,removed:e.map(e=>e.coordinates),vertices:e}),this.destroyed)return;if(n&&(this._updateEventState(0),this.destroyed))return;this._updateMoveManipulationPosition()}}_createBeforeVertexRemoveEvent(e){const t=this._operations,i=e.map(e=>{const i=t.data.parts.indexOf(e.handle.part);return{coordinates:t.data.coordinateHelper.vectorToArray(e.handle.pos),componentIndex:i,vertexIndex:e.handle.index}});let n=!1;return{type:"before-vertex-remove",object:this.object,removed:i.map(e=>e.coordinates),vertices:i,get defaultPrevented(){return n},preventDefault(){n=!0}}}_moveVertices(e,t,i=("start"===t.action?0:1)){const n=this._operations;if(n&&(e.length>0&&n.moveVertices(e.map(e=>e.handle),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i),!this._movingManipulatorsHidden))for(const a of e)this._updateManipulatorPosition(a)}_offsetEdge(e,t,i){if(!this._operations)return;const n=t.clone();n.distance=i,this._operations.updateVertices([e.handle.leftVertex,e.handle.rightVertex],n),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.leftVertex)),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.rightVertex))}_manipulatorClickCallback(e,t){e.shiftKey||this._clearSelection(),"vertex"===t.type&&(t.manipulator.selected=!t.manipulator.selected,this.enableDeleteVertices&&e.button===ue.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===ue.Left&&this._splitEdgeManipulator(t),e.stopPropagation()}_updateTranslateTooltip(e,t){null!=this._defaultTooltipInfo?this._resetTooltip():this._updateTranslateObjectTooltip(e,t)}_updateTranslateObjectTooltip(e,t){this._pendingEdgeOffsetInfo||(this.activeTooltipInfo=se(e,t,this._tooltipsContext,this._updatingHandles))}_updateEdgeOffsetTooltip(e){this._pendingEdgeOffsetInfo||(this.activeTooltipInfo=re(this.object,e,this._tooltipsContext,this._updatingHandles))}_resetTooltip(){const e=this.activeTooltipInfo;if(this._pendingEdgeOffsetInfo&&"reshape-edge-offset"===e?.type)return;let t=null;t=this._pendingEdgeOffsetInfo||null!=this._findActiveEdgeOffsetManipulatorInfo()?re(this.object,null,this._tooltipsContext,this._updatingHandles):this._defaultTooltipInfo,t!==e&&(null!=e&&null!=t&&"input"===this.tooltip.mode||(this.activeTooltipInfo=t))}get _defaultTooltipInfo(){const e=this._operations?.data.type;switch(e){case"multipoint":case"polyline":case"polygon":return this._selectedVertexManipulatorInfo?this.tooltipInfos.selectedVertex:null;case"point":case"mesh":return this.tooltipInfos.movePoint;default:return null}}get _selectedVertexManipulatorInfo(){const e=this._manipulatorInfos.filter(e=>"vertex"===e.type&&e.manipulator.selected);return 1===e.length?e[0]:null}get _someVerticesSelected(){return this._manipulatorInfos.some(e=>"vertex"===e.type&&e.manipulator.selected)}_forEachVertex(e){for(const t of this._manipulatorInfos)"vertex"===t.type&&e(t)}get _tooltipsContext(){const{tooltipInfos:e,activeTooltipInfo:t}=this;return{sketchOptions:this._sketchOptions,tooltipInfos:e,activeTooltipInfo:t,selectedVertexManipulatorInfo:this._selectedVertexManipulatorInfo,callbacks:this._tooltipCallbacks,measurementWorker:this._measurementWorker}}get test(){}};function we(){return e=>{const{operation:t,mapEnd:i}=e;return null==t||null==i?e:{...e,signedDistance:t.signedDistanceToPoint(i)}}}function Ve(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}function De(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}function Te(e){return new H({x:0,y:0,z:0,spatialReference:e})}function Ae(e){return"edge"===e.type&&"edgeManipulator"in e}e([g()],He.prototype,"_numGrabbing",void 0),e([g()],He.prototype,"_numDragging",void 0),e([g()],He.prototype,"_pendingEdgeOffsetInfo",void 0),e([g()],He.prototype,"_operations",null),e([g()],He.prototype,"_segmentLabels",void 0),e([g({constructOnly:!0})],He.prototype,"tool",void 0),e([g()],He.prototype,"tooltip",void 0),e([g()],He.prototype,"activeTooltipInfo",void 0),e([g({readOnly:!0})],He.prototype,"updating",null),e([g()],He.prototype,"manipulators",null),e([g()],He.prototype,"view",null),e([g()],He.prototype,"object",null),e([g()],He.prototype,"enableZShape",null),e([g()],He.prototype,"enableDeleteVertices",null),e([g()],He.prototype,"enableZVertex",null),e([g()],He.prototype,"autoHideManipulators",null),e([g()],He.prototype,"enableMoveObject",null),e([g()],He.prototype,"enableMidpoints",null),e([g()],He.prototype,"enableEdgeOffset",null),e([g()],He.prototype,"_sketchOptions",null),e([g()],He.prototype,"_accentColor",null),e([g()],He.prototype,"_tooltipsContext",null),He=e([_("esri.views.3d.interactive.editingTools.reshape.ReshapeOperation")],He);const Ge=T(0,0,void 0,D.WGS84),Ce=I(),Re=1e-6,Pe=16,ke=32;export{He as ReshapeOperation};