@arcgis/core 4.26.0-next.20230211 → 4.26.0-next.20230213

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 (23) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{f8e4217dde2e16986c4c.js → 1770729d33e57bb2919a.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{ddc33f14bede99eeb9df.js → 722e06dc25299d5f11b0.js} +1 -1
  4. package/assets/esri/core/workers/chunks/8be68f08c270c62e38bb.js +1 -0
  5. package/assets/esri/core/workers/chunks/accb787c5c8ee7bfe35b.js +1 -0
  6. package/assets/esri/core/workers/chunks/{788932d9ea7314dc2bae.js → f28cd2654583aebe2c03.js} +1 -1
  7. package/layers/support/rasterFunctions/BaseRasterFunction.js +1 -1
  8. package/package.json +1 -1
  9. package/support/revision.js +1 -1
  10. package/symbols/support/styleUtils.js +1 -1
  11. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  12. package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
  13. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  14. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  15. package/views/interactive/snapping/featureSources/FeatureCollectionSnappingSource.js +1 -1
  16. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  17. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  18. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  19. package/views/interactive/snapping/snappingUtils.js +1 -1
  20. package/widgets/Editor/EditorViewModel.js +1 -1
  21. package/widgets/Histogram.js +1 -1
  22. package/assets/esri/core/workers/chunks/c83551bc496366301060.js +0 -1
  23. package/assets/esri/core/workers/chunks/f4e903b80243ee517abd.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Color.js";import"../../../core/has.js";import{destroyHandle as n}from"../../../core/handleUtils.js";import{isNone as i,isSome as t,unwrap as r}from"../../../core/maybe.js";import{h as a}from"../../../chunks/vec3.js";import{c as o}from"../../../chunks/vec3f64.js";import{projectVectorToVector as s}from"../../../geometry/projection.js";import{onTheGroundElevationInfo as l,absoluteHeightElevationInfo as p}from"../../../support/elevationInfoUtils.js";import{ExtendedLineVisualElement as d,ExtensionType as c}from"./visualElements/ExtendedLineVisualElement.js";import{ParallelLineVisualElement as m}from"./visualElements/ParallelLineVisualElement.js";import{PointVisualElement as g}from"./visualElements/PointVisualElement.js";import{RightAngleQuadVisualElement as u}from"./visualElements/RightAngleQuadVisualElement.js";import{DrapedRenderGroup as f}from"../layers/interfaces.js";import{RenderOccludedFlag as h}from"../webgl-engine/lib/Material.js";import{defaults as v}from"../../interactive/snapping/Settings.js";import{SnappingDomain as E}from"../../interactive/snapping/SnappingDomain.js";import{snappingPointToDehydratedPoint as S,createSnappingPoint as R}from"../../interactive/snapping/SnappingPoint.js";import{LineSegmentHintType as j}from"../../interactive/snapping/snappingUtils.js";import{SnappingVisualizer as w}from"../../interactive/snapping/SnappingVisualizer.js";import{LineSnappingHint as _}from"../../interactive/snapping/hints/LineSnappingHint.js";import{vectorToRender as H}from"../../interactive/support/viewUtils.js";class x extends w{sortUniqueHints(e){return e.sort(((e,n)=>(n instanceof _?n.length:0)-(e instanceof _?e.length:0)))}visualizeIntersectionPoint(i,t){const{spatialReference:r,view:a}=t;return n(new g({view:a,primitive:"circle",geometry:S(i.intersectionPoint,r),elevationInfo:i.isDraped?l:p,size:20,outlineSize:2,color:[0,0,0,0],outlineColor:e.toUnitRGBA(v.orange),pixelSnappingEnabled:!1}))}visualizePoint(i,t){const{view:r,spatialReference:a}=t,o=this._alignPoint(i.point,i.domain,t);return n(new g({view:r,primitive:"circle",geometry:S(o,a),elevationInfo:this._hintElevationInfo(i,t),size:20,outlineSize:2,color:[0,0,0,0],outlineColor:e.toUnitRGBA(v.orange),pixelSnappingEnabled:!1}))}visualizeLine(e,i){const{view:t,spatialReference:r}=i,a=this._alignPoint(e.lineStart,e.domain,i),o=this._alignPoint(e.lineEnd,e.domain,i);return n(this._createLineSegmentHint(e.type,a,o,r,this._hintElevationInfo(e,i),t,e.isDraped,e.fadeLeft,e.fadeRight))}visualizeParallelSign(i,t){const{view:r,spatialReference:o}=t,{isDraped:s}=i,l=this._hintElevationInfo(i,t),p=this._alignPoint(i.lineStart,i.domain,t),d=this._alignPoint(i.lineEnd,i.domain,t),c=P(p,o,l,r,s),g=P(d,o,l,r,s),u=a(g,c,g,.5),E=new m({view:r,attached:!1,offset:v.parallelLineHintOffset,length:v.parallelLineHintLength,width:v.parallelLineHintWidth,color:e.toUnitRGBA(v.orange),location:u,renderOccluded:s?h.OccludeAndTransparent:h.Opaque,isDraped:s,renderGroup:f.SnappingHint});return E.setDirectionFromPoints(c,u),E.attached=!0,n(E)}visualizeRightAngleQuad(i,t){const{view:r,spatialReference:a}=t,o=this._hintElevationInfo(i,t),{isDraped:s}=i,l=this._alignPoint(i.previousVertex,i.domain,t),p=this._alignPoint(i.centerVertex,i.domain,t),d=this._alignPoint(i.nextVertex,i.domain,t),c=P(l,a,o,r,s),m=P(p,a,o,r,s),g=P(d,a,o,r,s);return n(new u({view:r,attached:!0,color:e.toUnitRGBA(v.orange),renderOccluded:s?h.OccludeAndTransparent:h.Transparent,outlineRenderOccluded:s?h.OccludeAndTransparent:h.Opaque,outlineColor:e.toUnitRGBA(v.orange),outlineSize:v.rightAngleHintOutlineSize,size:v.rightAngleHintSize,isDraped:s,geometry:{previous:c,center:m,next:g},renderGroup:f.SnappingHint}))}_createLineSegmentHint(n,i,t,r,a,o,s=!1,l=!0,p=!0){const m=P(i,r,a,o,s),g=P(t,r,a,o,s),u=new d({view:o,extensionType:c.FADED,start:m,end:g,isDraped:s,color:e.toUnitRGBA(v.orange),renderOccluded:s?h.OccludeAndTransparent:h.Opaque,renderGroup:f.SnappingHint});switch(n){case j.TARGET:u.width=v.lineHintWidthTarget,u.fadedExtensions={start:0,end:v.lineHintFadedExtensions};break;case j.REFERENCE_EXTENSION:u.width=v.lineHintWidthReference,u.fadedExtensions={start:0,end:0};break;case j.REFERENCE:u.width=v.lineHintWidthReference,u.fadedExtensions={start:l?v.lineHintFadedExtensions:0,end:p?v.lineHintFadedExtensions:0}}return u.attached=!0,u}_alignPoint(e,n,t){const r=this._getSelfSnappingZ(n,t);return i(r)?e:R(e[0],e[1],r)}_hintElevationInfo(e,n){return t(this._getSelfSnappingZ(e.domain,n))?r(n.selfSnappingZ).elevationInfo:e.isDraped?l:p}_getSelfSnappingZ(e,{selfSnappingZ:n}){return e===E.SELF&&t(n)?n.value:null}}function P(e,n,i,t,r,a=o()){if(r){const i=t.spatialReference;s(e,n,a,i)}else H(e,n,i,t,a);return a}export{x as SnappingVisualizer3D};
5
+ import e from"../../../Color.js";import"../../../core/has.js";import{destroyHandle as n}from"../../../core/handleUtils.js";import{isNone as i,isSome as t,unwrap as r}from"../../../core/maybe.js";import{h as a}from"../../../chunks/vec3.js";import{c as o}from"../../../chunks/vec3f64.js";import{projectVectorToVector as s}from"../../../geometry/projection.js";import{onTheGroundElevationInfo as l,absoluteHeightElevationInfo as p}from"../../../support/elevationInfoUtils.js";import{ExtendedLineVisualElement as d,ExtensionType as c}from"./visualElements/ExtendedLineVisualElement.js";import{ParallelLineVisualElement as m}from"./visualElements/ParallelLineVisualElement.js";import{PointVisualElement as g}from"./visualElements/PointVisualElement.js";import{RightAngleQuadVisualElement as u}from"./visualElements/RightAngleQuadVisualElement.js";import{DrapedRenderGroup as f}from"../layers/interfaces.js";import{RenderOccludedFlag as h}from"../webgl-engine/lib/Material.js";import{defaults as v}from"../../interactive/snapping/Settings.js";import{SnappingDomain as E}from"../../interactive/snapping/SnappingDomain.js";import{snappingPointToDehydratedPoint as S,createSnappingPoint as R}from"../../interactive/snapping/SnappingPoint.js";import{LineSegmentHintType as j}from"../../interactive/snapping/snappingUtils.js";import{SnappingVisualizer as w}from"../../interactive/snapping/SnappingVisualizer.js";import{LineSnappingHint as _}from"../../interactive/snapping/hints/LineSnappingHint.js";import{vectorToRender as H}from"../../interactive/support/viewUtils.js";class x extends w{sortUniqueHints(e){return e.sort(((e,n)=>(n instanceof _?n.length:0)-(e instanceof _?e.length:0)))}visualizeIntersectionPoint(i,t){const{spatialReference:r,view:a}=t;return n(new g({view:a,primitive:"circle",geometry:S(i.intersectionPoint,r),elevationInfo:i.isDraped?l:p,size:20,outlineSize:2,color:[0,0,0,0],outlineColor:e.toUnitRGBA(v.orange),pixelSnappingEnabled:!1}))}visualizePoint(i,t){const{view:r,spatialReference:a}=t,o=this._alignPoint(i.point,i.domain,t);return n(new g({view:r,primitive:"circle",geometry:S(o,a),elevationInfo:this._hintElevationInfo(i,t),size:20,outlineSize:2,color:[0,0,0,0],outlineColor:e.toUnitRGBA(v.orange),pixelSnappingEnabled:!1}))}visualizeLine(e,i){const{view:t,spatialReference:r}=i,a=this._alignPoint(e.lineStart,e.domain,i),o=this._alignPoint(e.lineEnd,e.domain,i);return n(this._createLineSegmentHint(e.type,a,o,r,this._hintElevationInfo(e,i),t,e.isDraped,e.fadeLeft,e.fadeRight))}visualizeParallelSign(i,t){const{view:r,spatialReference:o}=t,{isDraped:s}=i,l=this._hintElevationInfo(i,t),p=this._alignPoint(i.lineStart,i.domain,t),d=this._alignPoint(i.lineEnd,i.domain,t),c=P(p,o,l,r,s),g=P(d,o,l,r,s),u=a(g,c,g,.5),E=new m({view:r,attached:!1,offset:v.parallelLineHintOffset,length:v.parallelLineHintLength,width:v.parallelLineHintWidth,color:e.toUnitRGBA(v.orange),location:u,renderOccluded:s?h.OccludeAndTransparent:h.Opaque,isDraped:s,renderGroup:f.SnappingHint});return E.setDirectionFromPoints(c,u),E.attached=!0,n(E)}visualizeRightAngleQuad(i,t){const{view:r,spatialReference:a}=t,o=this._hintElevationInfo(i,t),{isDraped:s}=i,l=this._alignPoint(i.previousVertex,i.domain,t),p=this._alignPoint(i.centerVertex,i.domain,t),d=this._alignPoint(i.nextVertex,i.domain,t),c=P(l,a,o,r,s),m=P(p,a,o,r,s),g=P(d,a,o,r,s);return n(new u({view:r,attached:!0,color:e.toUnitRGBA(v.orange),renderOccluded:s?h.OccludeAndTransparent:h.Transparent,outlineRenderOccluded:s?h.OccludeAndTransparent:h.Opaque,outlineColor:e.toUnitRGBA(v.orange),outlineSize:v.rightAngleHintOutlineSize,size:v.rightAngleHintSize,isDraped:s,geometry:{previous:c,center:m,next:g},renderGroup:f.SnappingHint}))}_createLineSegmentHint(n,i,t,r,a,o,s=!1,l=!0,p=!0){const m=P(i,r,a,o,s),g=P(t,r,a,o,s),u=new d({view:o,extensionType:c.FADED,start:m,end:g,isDraped:s,color:e.toUnitRGBA(v.orange),renderOccluded:s?h.OccludeAndTransparent:h.Opaque,renderGroup:f.SnappingHint});switch(n){case j.TARGET:u.width=v.lineHintWidthTarget,u.fadedExtensions={start:0,end:v.lineHintFadedExtensions};break;case j.REFERENCE_EXTENSION:u.width=v.lineHintWidthReference,u.fadedExtensions={start:0,end:0};break;case j.REFERENCE:u.width=v.lineHintWidthReference,u.fadedExtensions={start:l?v.lineHintFadedExtensions:0,end:p?v.lineHintFadedExtensions:0}}return u.attached=!0,u}_alignPoint(e,n,t){const r=this._getSelfSnappingZ(n,t);return i(r)?e:R(e[0],e[1],r)}_hintElevationInfo(e,n){return t(this._getSelfSnappingZ(e.domain,n))?r(n.selfSnappingZ).elevationInfo:e.isDraped?l:p}_getSelfSnappingZ(e,{selfSnappingZ:n}){return e===E.SELF&&t(n)?n.value:null}}function P(e,n,i,t,r,a=o()){if(r){const i=t.basemapTerrain.overlayManager.renderer.spatialReference;s(e,n,a,i)}else H(e,n,i,t,a);return a}export{x as SnappingVisualizer3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../geometry.js";import{removeUnordered as t}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import i from"../../../../../core/Evented.js";import{HandleOwner as a}from"../../../../../core/HandleOwner.js";import o from"../../../../../core/Handles.js";import{handlesGroup as n,destroyHandle as r}from"../../../../../core/handleUtils.js";import{destroyMaybe as s,isSome as l,isNone as p,unwrap as h,removeMaybe as d}from"../../../../../core/maybe.js";import{zeroMeters as u,scale as c,createLength as m}from"../../../../../core/quantityUtils.js";import{watch as g,when as _,initial as f}from"../../../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as v}from"../../../../../core/unitUtils.js";import{property as M}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import{subclass as y}from"../../../../../core/accessorSupport/decorators/subclass.js";import{I as x}from"../../../../../chunks/mat4f64.js";import{l as O,b,h as E,s as G,a as S,g as w}from"../../../../../chunks/vec3.js";import{f as V,c as I}from"../../../../../chunks/vec3f64.js";import T from"../../../../../geometry/Polyline.js";import{hasCompatibleTopology as A}from"../../../../../geometry/support/coordsUtils.js";import{projectPoint as H}from"../../../../../geometry/support/plane.js";import{sv3d as D}from"../../../../../geometry/support/vectorStacks.js";import{makeDehydratedPoint as L}from"../../../../../layers/graphics/dehydratedFeatures.js";import{getGraphicEffectiveElevationInfo as j}from"../../../../../support/elevationInfoUtils.js";import{isVolumetricSymbol as P}from"../../../../../symbols/support/utils.js";import{Manipulator3D as U}from"../../Manipulator3D.js";import{createManipulatorMaterial as N,createManipulatorOutlineMaterial as C,placeAtGraphic as R}from"../../manipulatorUtils.js";import{RenderObject as k}from"../../RenderObject.js";import{SegmentLabels3D as F}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as z}from"../../SnappingVisualizer3D.js";import{screenToRenderPlaneFromEvent as X,convertToMapCoordinates as Z,screenToMapXYAtLocation as Y,screenToMapXYForGraphicAtLocation as q}from"../dragEventPipeline3D.js";import{ManipulatorType as W}from"../ManipulatorType.js";import{canMoveZ as K}from"../manipulatorUtils.js";import{settings as B,colors as J}from"../settings.js";import{createVisualElements as Q}from"../visualElementUtils.js";import{DISC_RADIUS_SMALL as $}from"../manipulations/config.js";import{ManipulationType as ee,MoveManipulation as te}from"../manipulations/MoveManipulation.js";import{shapeOrientation as ie,axisConstrainedDragSign as ae}from"../manipulations/moveUtils.js";import{MoveXYGraphicManipulation as oe}from"../manipulations/MoveXYGraphicManipulation.js";import{createEdgeOffsetIntersectionPlane as ne,createEdgeOffsetOperation as re,edgeOffsetRotationMatrix as se,screenEdgeLengthSquared as le}from"./edgeOffsetUtils.js";import{OutlineVisualElement as pe}from"../../visualElements/OutlineVisualElement.js";import{GraphicState as he}from"../../../layers/graphics/GraphicState.js";import{createExtrudedTriangle as de,createSphereGeometry as ue}from"../../../webgl-engine/lib/GeometryUtil.js";import{MouseButton as ce}from"../../../../input/IViewEvents.js";import{sceneSnappingAtLocation as me,addMapDelta as ge,createManipulatorDragEventPipeline as _e,dragAtLocation as fe,addScreenDelta as ve}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as Me,ManipulatorStateCustomFlags as ye}from"../../../../interactive/interfaces.js";import{EditGeometryOperations as xe}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as Oe}from"../../../../interactive/editGeometry/interfaces.js";import{SnappingContext as be}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as Ee}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{ReshapeEdgeOffsetTooltipInfo as Ge}from"../../../../interactive/tooltip/ReshapeTooltipInfos.js";import{Tooltip as Se}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicZTooltipInfo as we,TranslateGraphicXYTooltipInfo as Ve,TranslateGraphicTooltipInfo as Ie,TranslateVertexZTooltipInfo as Te,TranslateVertexXYTooltipInfo as Ae,TranslateVertexTooltipInfo as He}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoAreaByElevationMode as De}from"../../../../support/automaticAreaMeasurementUtils.js";import{autoHorizontalDistanceByElevationModeBetweenPoints as Le,autoLengthByElevationMode as je}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistanceBetweenPoints as Pe,elevationOfPoint as Ue}from"../../../../support/euclideanLengthMeasurementUtils.js";import{geodesicDistance as Ne}from"../../../../support/geodesicLengthMeasurementUtils.js";import Ce from"../../../../../geometry/SpatialReference.js";let Re=class extends(i.EventedMixin(a)){constructor(e){super(e),this._vertexManipulatorMaterial=N(B.colorToVec4(B.reshapeManipulators.vertex.color),B.reshapeManipulators.vertex.renderOccluded),this._vertexManipulatorOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.vertex.outlineColor),B.reshapeManipulators.vertex.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.vertex.hoverOutlineColor),B.reshapeManipulators.vertex.renderOccluded),this._edgeManipulatorMaterial=N(B.colorToVec4(B.reshapeManipulators.edge.color),B.reshapeManipulators.edge.renderOccluded),this._edgeManipulatorOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.edge.outlineColor),B.reshapeManipulators.edge.renderOccluded),this._edgeOffsetManipulatorMaterial=N(B.colorToVec4(B.reshapeManipulators.edgeOffset.color),B.reshapeManipulators.edgeOffset.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=N(B.colorToVec4(B.reshapeManipulators.edgeOffset.hoverColor),B.reshapeManipulators.edgeOffset.renderOccluded,!1),this._selectedManipulatorMaterial=N(B.colorToVec4(B.reshapeManipulators.selected.color),B.reshapeManipulators.selected.renderOccluded),this._selectedManipulatorOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.selected.outlineColor),B.reshapeManipulators.selected.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.selected.hoverOutlineColor),B.reshapeManipulators.selected.renderOccluded),this._selectedIndex=0,this._manipulatorHandles=new o,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=qe.NONE,this.outputGeometry=null,this._vertexLaserLineVisualElement=null}initialize(){const{graphic:e,view:t}=this,i=this._graphicState=new he({graphic:e});this._tooltip=new Se({view:t}),this.addHandles([g((()=>i.displaying),(e=>{for(const t of this._manipulatorInfos)t.manipulator.available=e})),g((()=>({labels:this._segmentLabels,enabled:this._labelOptions.enabled,edgeOffsetEnabled:this.enableEdgeOffset})),(({labels:e,enabled:t,edgeOffsetEnabled:i})=>{l(e)&&(e.visible=t,e.edgeDistance=i?"far":"default")}),f),_((()=>!this._tooltipOptions.enabled),(()=>this._tooltip.clear()),f),this.view.trackGraphicState(i)])}destroy(){this._segmentLabels=s(this._segmentLabels),this._tooltip=s(this._tooltip),this._removeManipulators()}get inputGeometry(){return l(this._editGeometryOperations)?this._editGeometryOperations.data.geometry:null}set inputGeometry(e){this._recreateEditGeometryAndManipulators(e)}get updating(){return this.updatingHandles.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get graphic(){return this.tool.graphic}get enableZShape(){return this.tool.enableZShape}get enableZVertex(){return this.tool.enableZVertex}get enableMoveGraphic(){return this.tool.enableMoveGraphic}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}get _labelOptions(){return this.tool.labelOptions}get _tooltipOptions(){return this.tool.tooltipOptions}removeSelectedVertices(){const e=this._manipulatorInfos.filter((e=>e.manipulator.selected&&"vertex"===e.type));this._removeVertices(e)}onManipulatorSelectionChanged(){this.emit("manipulators-changed")}_removeManipulators(){this._manipulatorHandles.removeAll(),this._moveManipulation=s(this._moveManipulation),this._graphicMoveManipulation=s(this._graphicMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0}_createManipulators(e){if(p(this._editGeometryOperations))return;const t=j(this.graphic);for(const i of this._editGeometryOperations.data.components){const a=e?.byComponentIndex.get(i.index);for(const e of i.vertices){const i=a?.has(e.index);this._createVertexOrEdgeManipulator(e,t,i)}for(const e of i.edges)this._createVertexOrEdgeManipulator(e,t)}this._createGraphicMoveManipulation(),this._createMoveManipulation(t),this._createVisualElements()}get canRedo(){return l(this._editGeometryOperations)&&this._editGeometryOperations.canRedo}get canUndo(){return l(this._editGeometryOperations)&&this._editGeometryOperations.canUndo}redo(){if(p(this._editGeometryOperations))return null;const e=this._editGeometryOperations.redo();return l(e)&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),e}undo(){if(p(this._editGeometryOperations))return null;this.emit("undo");const e=this._editGeometryOperations.undo();return l(e)&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),e}_recreateManipulators(){this._removeManipulators(),this._tooltip.clear(),this._createManipulators()}_recreateEditGeometryAndManipulators(e){const t={byComponentIndex:new Map};if(l(e)&&l(this.inputGeometry)&&A(e,this.inputGeometry))for(const i of this._manipulatorInfos)if("vertex"===i.type&&i.manipulator.selected){const{index:e,component:{index:a}}=i.handle,{byComponentIndex:o}=t,n=o.get(a)||new Set;n.add(e),o.set(a,n)}this._removeManipulators(),this._tooltip.clear(),this._editGeometryOperations=s(this._editGeometryOperations),this._segmentLabels=s(this._segmentLabels),p(e)||(this._editGeometryOperations=xe.fromGeometry(e,this.view.state.viewingMode),this._createManipulators(t),this._segmentLabels=new F({context:{view:this.view,editGeometryOperations:this._editGeometryOperations,elevationInfo:j(this.graphic),labelOptions:this._labelOptions,graphic:this.graphic,graphicState:this._graphicState},visible:this._labelOptions.enabled}))}_perGraphicManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const a=[],o=this._manipulatorInfos.some((e=>"vertex"===e.type&&e.manipulator.selected)),n=e===We.SELECTED_OR_ALL&&o;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.grabbing||n&&!r.manipulator.selected||a.push(r),i++);if(0===a.length)return t;this._moveVertices(a,t);if(a.length===i){if(this._updateEventState(qe.MOVING),this.destroyed)return t;this.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,mover:this.graphic})}else{if(this._updateEventState(qe.RESHAPING),this.destroyed)return t;this.emit("reshape",{type:"reshape",mover:this.graphic})}return t}_isMultiVertexSelection(){return this._manipulatorInfos.reduce(((e,t)=>"vertex"===t.type&&t.manipulator.selected?e+1:e),0)>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(qe.RESHAPING),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:a}=e;if(!t&&!i&&!a)return;const o=[];for(const n of this._manipulatorInfos)"vertex"===n.type&&(n.manipulator.selected&&!n.manipulator.grabbing||n===e.info)&&o.push(n);this._moveVertices(o,e,Oe.ACCUMULATE_STEPS),this.emit("reshape",{type:"reshape",mover:this.graphic})}_updateEventState(e){if(e===this._reshapeEventState)return!1;switch(e){case qe.NONE:if(0!==this._numGrabbing||0!==this._numDragging)return!1;switch(this._reshapeEventState){case qe.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic});break;case qe.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic})}break;case qe.MOVING:switch(this._reshapeEventState){case qe.NONE:this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic});break;case qe.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic}),this.destroyed||this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic})}break;case qe.RESHAPING:switch(this._reshapeEventState){case qe.NONE:this.emit("reshape",{type:"reshape-start",mover:this.graphic});break;case qe.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic}),this.destroyed||this.emit("reshape",{type:"reshape-start",mover:this.graphic})}}if(this.destroyed)return!1;const t=this._reshapeEventState!==e;return this._reshapeEventState=e,t}_createGraphicMoveManipulation(){const{tool:e,view:t}=this,i=this._graphicState;if(this._graphicMoveManipulation=new oe({tool:e,view:t,graphicState:i}),this.enableMoveGraphic){let e=null;this._manipulatorHandles.add(this._graphicMoveManipulation.createDragPipeline(((t,i,a)=>{i.next((e=>this._trackNumDragging(e))).next((t=>("start"===t.action&&(e=h(this._editGeometryOperations).createUndoGroup()),t))).next((e=>this._perGraphicManipulatorDragAction(We.ALL,e))).next((e=>(this._updateTranslateGraphicTooltip(ee.XY,e),e))).next((t=>{"end"===t.action&&(this._tooltip.clear(),e=d(e))})),a.next((()=>this._onDragCancel(!0,(()=>e=d(e)))))}))),this._graphicMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(e,!1))))}else this._graphicMoveManipulation.forEachManipulator((e=>{e.grabbable=!1,e.cursor=null}));this._graphicMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add(e.events.on("immediate-click",(e=>{this._manipulatorInfos.some((e=>e.manipulator.selected))?this._clearSelection():this.emit("immediate-click",{...e,graphic:this.graphic}),e.stopPropagation()})))))}_createMoveManipulation(e){const{graphic:t,handles:i,tool:a,view:o}=this,n=this._graphicState;this._moveManipulation=new te({tool:a,view:o,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&K(t),snapToScene:!1,radius:te.radiusForSymbol(t.symbol)}),this._moveManipulation.forEachManipulator((e=>i.add([e.events.on("immediate-click",(i=>{this._moveManipulation.zManipulation.hasManipulator(e)||this._manipulatorInfos.some((e=>e.manipulator.selected))||this.emit("immediate-click",{...i,graphic:t}),i.stopPropagation()})),this._watchAndUpdateGrabState(e,!1)])));const r=e=>t=>{i.add(t.events.on("focus-changed",(({action:t})=>{"focus"===t&&this._tooltipOptions.enabled?this._updateTranslateTooltip(e):this._tooltip.clear()})))};this._moveManipulation.xyManipulation.forEachManipulator(r(ee.XY)),this._moveManipulation.xyAxisManipulation.forEachManipulator(r(ee.XY_AXIS)),this._moveManipulation.zManipulation.forEachManipulator(r(ee.Z)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const s=h(t.geometry).spatialReference;i.add([this._moveManipulation.createDragPipeline(((i,o,n,r,s)=>{const{snappingStep:l,cancelSnapping:p}=Ee({predicate:e=>!!e.info,snappingManager:a.snappingManager,snappingContext:new be({editGeometryOperations:h(this._editGeometryOperations),elevationInfo:e,pointer:s,excludeFeature:t,visualizer:new z}),updatingHandles:this.updatingHandles,useZ:!1});return r=r.next((e=>(this._onDragCancel(),e))).next(p),{steps:n=n.next((e=>this._trackNumDragging(e))).next((e=>{const t=this._manipulatorInfos.filter((e=>"vertex"===e.type&&e.manipulator.selected));return e.manipulatorType===W.TRANSLATE_XY&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:e})).next(me(this.view,e,t)).next(...l).next(ge()).next((e=>this._perGraphicManipulatorDragAction(We.SELECTED_OR_ALL,e))).next((e=>(this._updateTranslateTooltip(i,e),e))),cancel:r}}),e,s,t),g((()=>n.displaying),(()=>{this._updateMoveManipulationPosition()}),f),n.on("changed",(()=>this._updateMoveManipulationPosition())),g((()=>n.isDraped),(e=>{this._updateMoveManipulationPosition();const t="align-move-manipulation";e?i.add(this.view.elevationProvider.on("elevation-change",(()=>this._updateMoveManipulationPosition())),t):i.remove(t)}),f)])}_createVisualElements(){const{graphic:e,view:t}=this,i=Q({view:t,graphic:e,forEachManipulator:e=>{if(!this.destroyed){this._graphicMoveManipulation.forEachManipulator(e),this._moveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,W.TRANSLATE_XY)}},onManipulatorsChanged:e=>this.on("manipulators-changed",e)});l(i)&&(this._outlineVisualElement=i.visualElement instanceof pe?i.visualElement:null),l(this._outlineVisualElement)&&this._manipulatorHandles.add(this._outlineVisualElement.events.on("attachment-origin-changed",(()=>{this._graphicState.isDraped||this._updateMoveManipulationPosition()}))),this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(e,t=j(this.graphic)){const i=B.reshapeManipulators.edgeOffset,a=i.size/2,o=a+i.collisionPadding,r=a/o,s=r*Math.sqrt(3)/2;p(this._edgeOffsetManipulatorGeometryInside)&&(this._edgeOffsetManipulatorGeometryInside=de(this._edgeOffsetManipulatorMaterial,s,r/2,r/2,i.height,i.offset)),p(this._edgeOffsetManipulatorGeometryOutside)&&(this._edgeOffsetManipulatorGeometryOutside=de(this._edgeOffsetManipulatorMaterial,-s,r/2,r/2,i.height,-i.offset));const h=[new k(this._edgeOffsetManipulatorGeometryInside.instantiate(),Me.Unfocused),new k(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),Me.Focused),new k(this._edgeOffsetManipulatorGeometryOutside.instantiate(),Me.Unfocused),new k(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),Me.Focused)],d=new U({view:this.view,renderObjects:h,elevationInfo:"on-the-ground"!==t.mode||P(this.graphic.symbol)?{mode:"absolute-height",offset:0}:t,worldOriented:!1,focusMultiplier:1,radius:o,available:!(!this.graphic.visible||!this.graphic.layer?.visible),collisionType:{type:"disc",direction:V(0,0,1)},collisionPriority:1,metadata:{deleting:!1}}),u=new U({view:this.view,worldSized:!0,worldOriented:!1,available:!(!this.graphic.visible||!this.graphic.layer?.visible),collisionPriority:-10,cursor:this.enableMoveGraphic?"move":"default",metadata:{deleting:!1}}),c={manipulator:d,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:u,elevationInfo:t,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(c,i.minSquaredEdgeLength),this._updateEdgeOffsetManipulator(c);const m=[];for(const n of[c.handle.leftVertex,c.handle.rightVertex]){const e=this._getManipulatorInfoFromHandle(n);l(e)&&m.push(e.manipulator.events.on("location-update",(()=>this._updateEdgeOffsetManipulator(c))))}c.locationUpdateHandle=n(m),this._manipulatorHandles.add(c.locationUpdateHandle,d),this._manipulatorHandles.add([this._watchAndUpdateGrabState(d,!0),this._watchAndUpdateGrabState(u,!0)],d),this._manipulatorHandles.add(_e(d,this._createEdgeOffsetPipeline(c,t)),d),this._manipulatorHandles.add(_e(u,((e,i,a,o)=>{if("touch"===o){this._createEdgeOffsetPipeline(c,t)(e,i,a)}else if(this.enableMoveGraphic){const o=this.graphic,n=l(o.geometry)?o.geometry.spatialReference:null;i.next((e=>this._trackNumDragging(e))).next(fe(this.view,e.elevationAlignedLocation)).next(Y(this.view,e.elevationAlignedLocation,t,n,o)).next(ve()).next(ge()).next((e=>this._perGraphicManipulatorDragAction(We.ALL,e))).next((e=>(this._updateTranslateGraphicTooltip(ee.XY,e),e))).next((e=>{"end"===e.action&&this._tooltip.clear()})),a.next((()=>this._onDragCancel(!e.metadata.deleting)))}})),d);const g=e=>{this._manipulatorInfos.some((e=>e.manipulator.selected))?this._clearSelection():this.emit("immediate-click",{...e,graphic:this.graphic}),e.stopPropagation()};return this._manipulatorHandles.add([d.events.on("immediate-click",g),u.events.on("immediate-click",g),d.events.on("focus-changed",(({action:e})=>{const t=this._tooltipOptions;if("focus"===e&&t.enabled){const e=this._tooltip.info=new Ge({tooltipOptions:t});this._updateTooltipAreaOrTotalLength(e)}else this._tooltip.clear()}))],d),this._manipulatorInfos.push(c),this.manipulators.add(d),this.manipulators.add(u),this.emit("manipulators-changed"),c}_autoHideEdgeOffsetManipulator(e,t){const i=e.manipulator,a=e.edgeManipulator,o=()=>{e.visibilityHandle=d(e.visibilityHandle);const o=this._getManipulatorInfoFromHandle(e.handle.leftVertex),r=this._getManipulatorInfoFromHandle(e.handle.rightVertex),s=l(o)&&l(r)&&le(o.manipulator.renderLocation,r.manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!a.focused||s)&&(i.grabbable=!s,a.grabbable=!s,e.visibilityHandle=n([i.disableDisplay(),{remove:()=>{i.grabbable=!0,a.grabbable=this.enableMoveGraphic}}]))};this._manipulatorHandles.add([i.events.on("focus-changed",o),a.events.on("focus-changed",o),{remove:()=>{d(e.visibilityHandle),a.metadata.deleting=!0,this.manipulators.remove(a)}}],i),o()}_updateEdgeOffsetManipulator(e){this._updateManipulatorPosition(e);const{coordinateHelper:t}=h(this._editGeometryOperations).data,i=ne(this.view,e.manipulator.elevationAlignedLocation,re(t,e.handle,h(e.manipulator.elevationInfo))),a=this._getManipulatorInfoFromHandle(e.handle.leftVertex),o=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(p(a)||p(o))return;const n=a.manipulator.renderLocation,r=o.manipulator.renderLocation,s=l(i)?se(i,n,r):x;e.manipulator.modelTransform=s,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=s;const d=O(b(Xe,n,r))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-d,0,0],[d,0,0]]]}}_createEdgeOffsetPipeline(e,t){return(i,a,o)=>{this._clearSelection();const{step:n,cleanup:r}=this._initializeEdgeOffset(e,t);a.next((e=>this._trackNumDragging(e))).next(fe(this.view,i.elevationAlignedLocation)).next(n).next(X(this.view)).next(Z(this.view,h(this._editGeometryOperations).data.spatialReference)).next(ge()).next(this._applyComputeEdgeOffsetDistanceStep()).next(this._applyEdgeOffsetStep(e)).next(this._showEdgeOffsetTooltip()).next((e=>{"end"===e.action&&r()})),o.next((()=>{i.metadata.deleting||(r(),this._onDragCancel())}))}}_initializeEdgeOffset(e,t){const i=h(this._editGeometryOperations),a=re(i.data.coordinateHelper,e.handle,t),o=i.createUndoGroup(),s=ne(this.view,e.manipulator.elevationAlignedLocation,a);if(a.requiresSplitEdgeLeft){const t=this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftEdge);l(t)&&this._splitEdgeManipulator(t,1)}if(a.requiresSplitEdgeRight){const t=this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightEdge);l(t)&&this._splitEdgeManipulator(t,0)}const u=()=>new T({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:i.data.spatialReference}),c=new pe({view:this.view,isDraped:this._graphicState.isDraped,geometry:u(),elevationInfo:e.elevationInfo,width:B.visualElements.lineGraphics.outline.width,color:B.colorToVec4(J.main),attached:!0});let m;const _=()=>{this._cleanEdgeOffsetCollapsedEdges(e),m=d(m)},f=this.on("undo",_);return m=n([r(c),g((()=>this._graphicState.isDraped),(e=>c.isDraped=e)),this._graphicState.on("changed",(()=>c.geometry=u())),o,f]),{step:e=>p(a)||p(s)?(_(),null):{...e,operation:a,plane:s},cleanup:_}}_applyEdgeOffsetStep(e){return t=>{if(this.destroyed||p(t.operation))return t;this._updateEventState(qe.RESHAPING);const{mapDeltaX:i,mapDeltaY:a,mapDeltaZ:o}=t;return(i||a||o)&&(this._offsetEdge(e,t),this.emit("reshape",{type:"reshape",mover:this.graphic})),t}}_applyComputeEdgeOffsetDistanceStep(){return e=>{const{operation:t,mapEnd:i}=e;return p(t)||p(i)?e:("start"===e.action&&t.selectArrowFromStartPoint(i),{...e,signedDistance:t.signedDistanceToPoint(i)})}}_showEdgeOffsetTooltip(){return e=>{const{mapEnd:t,signedDistance:i,operation:a}=e,o=this._tooltip,n=this._tooltipOptions;if(!n.enabled||p(i))return o.clear(),e;let r=o.info;(p(r)||"reshape-edge-offset"!==r.type)&&(r=o.info=new Ge({tooltipOptions:n}));const{coordinateHelper:s}=h(this._editGeometryOperations).data;return r.distance="end"===e.action?u:Fe(this._graphicState.isDraped,i*a.selectedArrow,t,a.plane,s),this._updateTooltipAreaOrTotalLength(r),e}}_cleanEdgeOffsetCollapsedEdges(e){const t=e.handle.leftVertex.leftEdge?.leftVertex,i=e.handle.leftVertex,a=e.handle.rightVertex.rightEdge?.rightVertex,o=e.handle.rightVertex,n=h(this._editGeometryOperations).data.coordinateHelper,r=[];if(t&&n.distance(t.pos,i.pos)<Ze){const e=this._getManipulatorInfoFromHandle(i);l(e)&&r.push(e)}if(n.distance(i.pos,o.pos)<Ze||a&&n.distance(a.pos,o.pos)<Ze){const e=this._getManipulatorInfoFromHandle(o);l(e)&&r.push(e)}r.length&&this._removeVertices(r)}_computeVertexManipulatorSizeAndOutline(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}_createVertexOrEdgeManipulator(e,t=j(this.graphic),i=!1){if("edge"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(p(this._vertexManipulatorGeometry)||p(this._vertexManipulatorOutlineGeometry)){const{size:e,outlineSize:t}=this._computeVertexManipulatorSizeAndOutline(B.reshapeManipulators.vertex);this._vertexManipulatorGeometry=ue(this._vertexManipulatorMaterial,e,16,16),this._vertexManipulatorOutlineGeometry=ue(this._vertexManipulatorOutlineMaterial,t,16,16)}if(p(this._edgeManipulatorGeometry)||p(this._edgeManipulatorOutlineGeometry)){const{size:e,outlineSize:t}=this._computeVertexManipulatorSizeAndOutline(B.reshapeManipulators.edge);this._edgeManipulatorGeometry=ue(this._edgeManipulatorMaterial,e,16,16),this._edgeManipulatorOutlineGeometry=ue(this._edgeManipulatorOutlineMaterial,t,16,16)}const a=l(this.graphic.geometry)&&"point"===this.graphic.geometry.type?[]:[new k(this._vertexManipulatorGeometry.instantiate(),Ye.Vertex|Me.Unselected),new k(this._vertexManipulatorOutlineGeometry.instantiate(),Ye.Vertex|Me.Unfocused|Me.Unselected),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),Ye.Vertex|Me.Focused|Me.Unselected),new k(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),Me.Selected),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),Me.Selected|Me.Unfocused),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),Me.Selected|Me.Focused)];this.enableMidpoints&&a.push(new k(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),Ye.Edge|Me.Focused|Me.Unselected),new k(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),Ye.Edge|Me.Focused|Me.Unselected),new k(this._edgeManipulatorGeometry.instantiate(),Ye.Edge|Me.Unfocused|Me.Unselected),new k(this._edgeManipulatorOutlineGeometry.instantiate(),Ye.Edge|Me.Unfocused|Me.Unselected));const o=new U({view:this.view,renderObjects:a,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:!(!this.graphic.visible||!this.graphic.layer?.visible),metadata:{deleting:!1}});o.selected=i,this._setTypeSpecificManipulatorSettings(o,e,t);const r="edge"===e.type?{manipulator:o,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0}:{manipulator:o,handle:e,type:"vertex",selectedIndex:0};if(this._manipulatorInfos.push(r),this.manipulators.add(o),this._updateManipulatorPosition(r),"edge"===r.type){const e=[];for(const t of[r.handle.leftVertex,r.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(t);l(i)&&e.push(i.manipulator.events.on("location-update",(()=>this._updateManipulatorPosition(r))))}r.locationUpdateHandle=n(e),this._manipulatorHandles.add(r.locationUpdateHandle,o)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(o,!0),o);const s=_e(o,((e,i,a,o)=>{let n=null;const{snappingStep:s,cancelSnapping:l}=Ee({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new be({editGeometryOperations:h(this._editGeometryOperations),elevationInfo:t,pointer:o,excludeFeature:this.graphic,visualizer:new z}),updatingHandles:this.updatingHandles,useZ:!1});a=a.next((t=>(this._onDragCancel(!e.metadata.deleting,(()=>n=d(n))),t))).next(l),i.next((e=>this._trackNumDragging(e))).next((e=>{if("start"===e.action&&(n=h(this._editGeometryOperations).createUndoGroup()),"edge"===r.type){const t=this._splitEdgeManipulator(r);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:r,snapOrigin:r.handle.pos}})).next(fe(this.view,e.elevationAlignedLocation)).next(q(this.view,this.graphic,e.elevationAlignedLocation,e.location.spatialReference,this.graphic)).next(me(this.view,t,this.graphic)).next(...s).next(ge()).next((t=>{this._perVertexManipulatorDragAction(t),"end"===t.action&&(n=d(n)),this._updateTranslateVertexTooltip(e,ee.XY,t)}))}));return this._manipulatorHandles.add([s,o.events.on("immediate-click",(e=>this._manipulatorClickCallback(e,r))),o.events.on("select-changed",(()=>{r.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition()})),o.events.on("focus-changed",(({action:e})=>{"focus"===e&&"edge"!==r.type?this._updateTranslateVertexTooltip(o,ee.XY):this._tooltip.clear()}))],o),this.emit("manipulators-changed"),r}_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.outputGeometry=l(this._editGeometryOperations)?this._editGeometryOperations.data.geometry:null),l(this.tool.snappingManager)&&this.tool.snappingManager.doneSnapping(),this._tooltip.clear(),this._reshapeEventState){case qe.NONE:break;case qe.MOVING:this.emit("move",{type:"move",dx:0,dy:0,mover:this.graphic});break;case qe.RESHAPING:this.emit("reshape",{type:"reshape",mover:this.graphic})}t&&t(),this.destroyed||this._updateEventState(qe.NONE)}_setTypeSpecificManipulatorSettings(e,t,i){switch(t.type){case"vertex":e.state=Ye.Vertex,e.selectable=!0,e.cursor="move",e.collisionPriority=2,e.radius=B.reshapeManipulators.vertex.size/2+B.reshapeManipulators.vertex.collisionPadding,e.elevationInfo=i,e.interactive=l(this.graphic.geometry)&&"point"!==this.graphic.geometry.type;break;case"edge":e.state=Ye.Edge,e.selectable=!1,e.cursor="copy",e.collisionPriority=-1,e.radius=B.reshapeManipulators.edge.size/2+B.reshapeManipulators.edge.collisionPadding,e.elevationInfo="on-the-ground"!==i.mode||P(this.graphic.symbol)?{mode:"absolute-height",offset:0}:i}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",(i=>this._onGrabStateChanged(e,t,i.action,i.pointerType)))}_onGrabStateChanged(e,t,i,a="mouse"){if("start"===i)t&&this._updateSelection(e),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(qe.NONE),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==a||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach((e=>{e.manipulator.interactive=e.manipulator.grabbing||!this._numGrabbing&&l(this.graphic.geometry)&&"point"!==this.graphic.geometry.type,"edgeManipulator"in e&&(e.edgeManipulator.interactive=e.edgeManipulator.grabbing||!this._numGrabbing)})),this._graphicMoveManipulation.forEachManipulator((e=>{e.interactive=e.grabbing||!this._numGrabbing})))}_clearSelection(){for(const e of this._manipulatorInfos)e.manipulator.grabbing||(e.manipulator.selected=!1)}_updateSelection(e){e.grabbing&&!e.selected&&e.selectable&&(this._clearSelection(),e.selected=!0,this.emit("manipulators-changed"))}_removeManipulator(e){p(e)||(e.manipulator.metadata.deleting=!0,this.manipulators.remove(e.manipulator),this._manipulatorHandles.remove(e.manipulator),t(this._manipulatorInfos,e),this.emit("manipulators-changed"))}_getManipulatorInfoFromHandle(e){if(e)for(const t of this._manipulatorInfos)if(e===t.handle)return t;return null}_updateManipulatorPosition(e){if(p(e))return;const t=h(this._editGeometryOperations);if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,ze),e.manipulator.grabbing&&l(this._vertexLaserLineVisualElement)&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex),a=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(p(i)||p(a))return;const o=i.manipulator,n=a.manipulator;if(l(e.manipulator.elevationInfo)&&"on-the-ground"===e.manipulator.elevationInfo.mode){const i=o.location,a=n.location,r=.5,s=i.x+r*(a.x-i.x),l=i.y+r*(a.y-i.y),p=i.hasZ&&a.hasZ?0:void 0;e.manipulator.location=L(s,l,p,t.data.spatialReference)}else E(Xe,o.renderLocation,n.renderLocation,.5),e.manipulator.renderLocation=Xe}}_splitEdgeManipulator(e,t=.5){const i=h(this._editGeometryOperations),a=h(i.splitEdge(e.handle,t).createdVertex);e.locationUpdateHandle=d(e.locationUpdateHandle);const o=j(this.graphic);let n;this.enableEdgeOffset?(this._removeManipulator(e),n=this._createVertexOrEdgeManipulator(a)):(n=e,n.handle=a,n.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,o)),a.leftEdge&&this._createVertexOrEdgeManipulator(a.leftEdge),a.rightEdge&&this._createVertexOrEdgeManipulator(a.rightEdge),this.outputGeometry=i.data.geometry,this._updateManipulatorPosition(n),this.enableEdgeOffset||this._updateTranslateVertexTooltip(n.manipulator,ee.XY),this._updateSelection(e.manipulator);const r=this._updateEventState(qe.RESHAPING),s=i.data.coordinateHelper.vectorToArray(n.handle.pos),l=i.data.components.indexOf(a.component);return this.emit("vertex-add",{type:"vertex-add",vertices:[{coordinates:s,componentIndex:l,vertexIndex:h(a.index)}],added:s}),r&&this._updateEventState(qe.NONE),n}_updateMoveManipulationPosition(){const e=G(Xe,0,0,0);let t=0,i=!1,a=null,o=null;for(const n of this._manipulatorInfos)"vertex"===n.type&&(n.manipulator.selected?(t++,S(e,e,n.manipulator.renderLocation),p(a)||n.selectedIndex>a.selectedIndex?(o=a,a=n):(p(o)||n.selectedIndex>o.selectedIndex)&&(o=n)):i=!0);if(0===t){const e=this._graphicState.displaying&&this.enableMoveGraphic;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e,this._moveManipulation.zManipulation.available=e&&this.enableZShape&&K(this.graphic),this._moveManipulation.angle=ie(h(this.graphic.geometry)),this._moveManipulation.radius=te.radiusForSymbol(this.graphic.symbol)}else{const e=this._graphicState.displaying;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&K(this.graphic),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t;let i=0;if(l(a)){const e=a.handle.pos,t=l(o)?o.handle.pos:a.handle.leftEdge&&a.handle.leftEdge.leftVertex?a.handle.leftEdge.leftVertex.pos:null,n=p(o)&&a.handle.rightEdge&&a.handle.rightEdge.rightVertex?a.handle.rightEdge.rightVertex.pos:null;t&&n?this._moveManipulation.xyAxisManipulation.available=!1:t?i=ke(t,e):n&&(i=ke(e,n))}this._moveManipulation.angle=i,this._moveManipulation.radius=$}0!==t&&i?(w(e,e,1/t),ze.spatialReference=h(this._editGeometryOperations).data.spatialReference,ze.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,ze),this._moveManipulation.elevationAlignedLocation=ze):l(this._outlineVisualElement)&&!this._graphicState.isDraped&&l(this._outlineVisualElement.attachmentOrigin)?this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin:R(this.view,this._moveManipulation,this.graphic)}_removeVertices(e){const t=new Array,i=h(this._editGeometryOperations);for(const a of e)if("vertex"===a.type&&i.canRemoveVertex()){t.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftEdge)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightEdge));const e=i.removeVertices([a.handle]),o=h(e.removedVertices?.[0].createdEdge);o&&this._createVertexOrEdgeManipulator(o)}if(t.length>0){const e=t.map((e=>{const t=i.data.components.indexOf(e.component);return{coordinates:i.data.coordinateHelper.vectorToArray(e.pos),componentIndex:t,vertexIndex:h(e.index)}}));this.outputGeometry=i.data.geometry;const a=this._updateEventState(qe.RESHAPING);if(this.destroyed)return;if(this.emit("vertex-remove",{type:"vertex-remove",removed:e.map((e=>e.coordinates)),vertices:e}),this.destroyed)return;if(a&&(this._updateEventState(qe.NONE),this.destroyed))return;this._updateMoveManipulationPosition()}}_moveVertices(e,t,i=("start"===t.action?Oe.NEW_STEP:Oe.ACCUMULATE_STEPS)){const a=h(this._editGeometryOperations);a.moveVertices(e.map((e=>e.handle)),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i),this.outputGeometry=a.data.geometry;for(const o of e)this._updateManipulatorPosition(o)}_offsetEdge(e,t){if(p(t.operation)||p(t.signedDistance))return;const i=h(this._editGeometryOperations),a=t.operation.clone();a.distance=t.signedDistance,i.updateVertices([e.handle.leftVertex,e.handle.rightVertex],a),this.outputGeometry=i.data.geometry,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,e.button===ce.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===ce.Left&&this._splitEdgeManipulator(t),e.stopPropagation()}_updateTranslateTooltip(e,t){const i=this._manipulatorInfos.filter((e=>"vertex"===e.type&&e.manipulator.selected));1===i.length?this._updateTranslateVertexTooltip(i[0].manipulator,e,t):this._updateTranslateGraphicTooltip(e,t)}_updateTranslateGraphicTooltip(e,t){const i=this._tooltipOptions;if(!i.enabled)return;const a=this._graphicState.isDraped?"on-the-ground":"absolute-height";switch(e){case ee.XY:this._tooltip.info=new Ie({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,((e,t)=>Le(e,t,a)));break;case ee.XY_AXIS:this._tooltip.info=new Ve({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,((e,i)=>{const o=Le(e,i,a);return c(o,ae(t))}));break;case ee.Z:this._tooltip.info=new we({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,Pe)}}_updateTranslateVertexTooltip(e,t,i){const a=this._tooltipOptions;if(!a.enabled)return;let o;const n=this._graphicState.isDraped?"on-the-ground":"absolute-height";switch(t){case ee.XY:o=new He({tooltipOptions:a}),this._updateTranslateTooltipDistance(o,i,((e,t)=>Le(e,t,n))),this._updateTooltipAreaOrTotalLength(o);break;case ee.XY_AXIS:o=new Ae({tooltipOptions:a}),this._updateTranslateTooltipDistance(o,i,((e,t)=>{const a=Le(e,t,n);return c(a,ae(i))})),this._updateTooltipAreaOrTotalLength(o);break;case ee.Z:o=new Te({tooltipOptions:a}),this._updateTranslateTooltipDistance(o,i,Pe)}const r=Ue(e.elevationAlignedLocation);l(r)&&(o.elevation={mode:"absolute-height",...r}),this._tooltip.info=o}_updateTranslateTooltipDistance(e,t,i){if(l(t)&&"end"!==t.action){const{mapStart:a,mapEnd:o}=t,n=i(a,o);e.distance=l(n)?n:u}}_updateTooltipAreaOrTotalLength(e){const{geometry:t}=this.graphic;if(p(t))return;const i=this._graphicState.isDraped?"on-the-ground":"absolute-height";e.area="polygon"===t.type?De(t,i):null,e.totalLength="polyline"===t.type?je(t,i):null}get test(){return{segmentLabels:this._segmentLabels,tooltip:this._tooltip}}};function ke(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}function Fe(e,t,i,a,o){if(e){const e=o.toXYZ(o.pointToVector(i)),n=H(a,e,D.get()),r=Ne(n,e,o.spatialReference);if(l(r))return m(r.value*Math.sign(t),r.unit)}return m(t*v(i.spatialReference),"meters")}e([M()],Re.prototype,"_editGeometryOperations",void 0),e([M()],Re.prototype,"_segmentLabels",void 0),e([M({constructOnly:!0})],Re.prototype,"tool",void 0),e([M()],Re.prototype,"_tooltip",void 0),e([M()],Re.prototype,"inputGeometry",null),e([M()],Re.prototype,"outputGeometry",void 0),e([M({readOnly:!0})],Re.prototype,"updating",null),e([M()],Re.prototype,"manipulators",null),e([M()],Re.prototype,"view",null),e([M()],Re.prototype,"graphic",null),e([M()],Re.prototype,"enableZShape",null),e([M()],Re.prototype,"enableZVertex",null),e([M()],Re.prototype,"enableMoveGraphic",null),e([M()],Re.prototype,"enableMidpoints",null),e([M()],Re.prototype,"enableEdgeOffset",null),e([M()],Re.prototype,"_labelOptions",null),e([M()],Re.prototype,"_tooltipOptions",null),Re=e([y("esri.views.3d.interactive.editingTools.reshapeGraphic.ReshapeOperation")],Re);const ze=L(0,0,void 0,Ce.WGS84),Xe=I(),Ze=1e-6;var Ye,qe,We;!function(e){e.Vertex=ye.Custom1,e.Edge=ye.Custom2}(Ye||(Ye={})),function(e){e[e.NONE=0]="NONE",e[e.MOVING=1]="MOVING",e[e.RESHAPING=2]="RESHAPING"}(qe||(qe={})),function(e){e[e.ALL=0]="ALL",e[e.SELECTED_OR_ALL=1]="SELECTED_OR_ALL"}(We||(We={}));export{Re as ReshapeOperation};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../geometry.js";import{removeUnordered as t}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import i from"../../../../../core/Evented.js";import{HandleOwner as a}from"../../../../../core/HandleOwner.js";import o from"../../../../../core/Handles.js";import{handlesGroup as n,destroyHandle as r}from"../../../../../core/handleUtils.js";import{destroyMaybe as s,isSome as l,isNone as p,unwrap as h,removeMaybe as d}from"../../../../../core/maybe.js";import{zeroMeters as u,scale as c,createLength as m}from"../../../../../core/quantityUtils.js";import{watch as g,when as _,initial as f}from"../../../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as v}from"../../../../../core/unitUtils.js";import{property as M}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import{subclass as y}from"../../../../../core/accessorSupport/decorators/subclass.js";import{I as x}from"../../../../../chunks/mat4f64.js";import{l as O,b,h as E,s as G,a as S,g as w}from"../../../../../chunks/vec3.js";import{f as V,c as I}from"../../../../../chunks/vec3f64.js";import T from"../../../../../geometry/Polyline.js";import{hasCompatibleTopology as A}from"../../../../../geometry/support/coordsUtils.js";import{projectPoint as H}from"../../../../../geometry/support/plane.js";import{sv3d as D}from"../../../../../geometry/support/vectorStacks.js";import{makeDehydratedPoint as L}from"../../../../../layers/graphics/dehydratedFeatures.js";import{getGraphicEffectiveElevationInfo as j}from"../../../../../support/elevationInfoUtils.js";import{isVolumetricSymbol as P}from"../../../../../symbols/support/utils.js";import{Manipulator3D as U}from"../../Manipulator3D.js";import{createManipulatorMaterial as N,createManipulatorOutlineMaterial as C,placeAtGraphic as R}from"../../manipulatorUtils.js";import{RenderObject as k}from"../../RenderObject.js";import{SegmentLabels3D as F}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as z}from"../../SnappingVisualizer3D.js";import{screenToRenderPlaneFromEvent as X,convertToMapCoordinates as Z,screenToMapXYAtLocation as Y,screenToMapXYForGraphicAtLocation as q}from"../dragEventPipeline3D.js";import{ManipulatorType as W}from"../ManipulatorType.js";import{canMoveZ as K}from"../manipulatorUtils.js";import{settings as B,colors as J}from"../settings.js";import{createVisualElements as Q}from"../visualElementUtils.js";import{DISC_RADIUS_SMALL as $}from"../manipulations/config.js";import{ManipulationType as ee,MoveManipulation as te}from"../manipulations/MoveManipulation.js";import{shapeOrientation as ie,axisConstrainedDragSign as ae}from"../manipulations/moveUtils.js";import{MoveXYGraphicManipulation as oe}from"../manipulations/MoveXYGraphicManipulation.js";import{createEdgeOffsetIntersectionPlane as ne,createEdgeOffsetOperation as re,edgeOffsetRotationMatrix as se,screenEdgeLengthSquared as le}from"./edgeOffsetUtils.js";import{OutlineVisualElement as pe}from"../../visualElements/OutlineVisualElement.js";import{GraphicState as he}from"../../../layers/graphics/GraphicState.js";import{createExtrudedTriangle as de,createSphereGeometry as ue}from"../../../webgl-engine/lib/GeometryUtil.js";import{MouseButton as ce}from"../../../../input/IViewEvents.js";import{sceneSnappingAtLocation as me,addMapDelta as ge,createManipulatorDragEventPipeline as _e,dragAtLocation as fe,addScreenDelta as ve}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as Me,ManipulatorStateCustomFlags as ye}from"../../../../interactive/interfaces.js";import{EditGeometryOperations as xe}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as Oe}from"../../../../interactive/editGeometry/interfaces.js";import{SnappingContext as be}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as Ee}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{ReshapeEdgeOffsetTooltipInfo as Ge}from"../../../../interactive/tooltip/ReshapeTooltipInfos.js";import{Tooltip as Se}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicZTooltipInfo as we,TranslateGraphicXYTooltipInfo as Ve,TranslateGraphicTooltipInfo as Ie,TranslateVertexZTooltipInfo as Te,TranslateVertexXYTooltipInfo as Ae,TranslateVertexTooltipInfo as He}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoAreaByElevationMode as De}from"../../../../support/automaticAreaMeasurementUtils.js";import{autoHorizontalDistanceByElevationModeBetweenPoints as Le,autoLengthByElevationMode as je}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistanceBetweenPoints as Pe,elevationOfPoint as Ue}from"../../../../support/euclideanLengthMeasurementUtils.js";import{geodesicDistance as Ne}from"../../../../support/geodesicLengthMeasurementUtils.js";import Ce from"../../../../../geometry/SpatialReference.js";let Re=class extends(i.EventedMixin(a)){constructor(e){super(e),this._vertexManipulatorMaterial=N(B.colorToVec4(B.reshapeManipulators.vertex.color),B.reshapeManipulators.vertex.renderOccluded),this._vertexManipulatorOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.vertex.outlineColor),B.reshapeManipulators.vertex.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.vertex.hoverOutlineColor),B.reshapeManipulators.vertex.renderOccluded),this._edgeManipulatorMaterial=N(B.colorToVec4(B.reshapeManipulators.edge.color),B.reshapeManipulators.edge.renderOccluded),this._edgeManipulatorOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.edge.outlineColor),B.reshapeManipulators.edge.renderOccluded),this._edgeOffsetManipulatorMaterial=N(B.colorToVec4(B.reshapeManipulators.edgeOffset.color),B.reshapeManipulators.edgeOffset.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=N(B.colorToVec4(B.reshapeManipulators.edgeOffset.hoverColor),B.reshapeManipulators.edgeOffset.renderOccluded,!1),this._selectedManipulatorMaterial=N(B.colorToVec4(B.reshapeManipulators.selected.color),B.reshapeManipulators.selected.renderOccluded),this._selectedManipulatorOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.selected.outlineColor),B.reshapeManipulators.selected.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=C(B.colorToVec4(B.reshapeManipulators.selected.hoverOutlineColor),B.reshapeManipulators.selected.renderOccluded),this._selectedIndex=0,this._manipulatorHandles=new o,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=qe.NONE,this._removingManipulators=!1,this.outputGeometry=null,this._vertexLaserLineVisualElement=null}initialize(){const{graphic:e,view:t}=this,i=this._graphicState=new he({graphic:e});this._tooltip=new Se({view:t}),this.addHandles([g((()=>i.displaying),(e=>{for(const t of this._manipulatorInfos)t.manipulator.available=e})),g((()=>({labels:this._segmentLabels,enabled:this._labelOptions.enabled,edgeOffsetEnabled:this.enableEdgeOffset})),(({labels:e,enabled:t,edgeOffsetEnabled:i})=>{l(e)&&(e.visible=t,e.edgeDistance=i?"far":"default")}),f),_((()=>!this._tooltipOptions.enabled),(()=>this._tooltip.clear()),f),this.view.trackGraphicState(i)])}destroy(){this._segmentLabels=s(this._segmentLabels),this._tooltip=s(this._tooltip),this._removeManipulators()}get inputGeometry(){return l(this._editGeometryOperations)?this._editGeometryOperations.data.geometry:null}set inputGeometry(e){this._recreateEditGeometryAndManipulators(e)}get updating(){return this.updatingHandles.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get graphic(){return this.tool.graphic}get enableZShape(){return this.tool.enableZShape}get enableZVertex(){return this.tool.enableZVertex}get enableMoveGraphic(){return this.tool.enableMoveGraphic}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}get _labelOptions(){return this.tool.labelOptions}get _tooltipOptions(){return this.tool.tooltipOptions}removeSelectedVertices(){const e=this._manipulatorInfos.filter((e=>e.manipulator.selected&&"vertex"===e.type));this._removeVertices(e)}onManipulatorSelectionChanged(){this.emit("manipulators-changed")}_removeManipulators(){this._removingManipulators=!0,this._manipulatorHandles.removeAll(),this._moveManipulation=s(this._moveManipulation),this._graphicMoveManipulation=s(this._graphicMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._removingManipulators=!1}_createManipulators(e){if(p(this._editGeometryOperations))return;const t=j(this.graphic);for(const i of this._editGeometryOperations.data.components){const a=e?.byComponentIndex.get(i.index);for(const e of i.vertices){const i=a?.has(e.index);this._createVertexOrEdgeManipulator(e,t,i)}for(const e of i.edges)this._createVertexOrEdgeManipulator(e,t)}this._createGraphicMoveManipulation(),this._createMoveManipulation(t),this._createVisualElements()}get canRedo(){return l(this._editGeometryOperations)&&this._editGeometryOperations.canRedo}get canUndo(){return l(this._editGeometryOperations)&&this._editGeometryOperations.canUndo}redo(){if(p(this._editGeometryOperations))return null;const e=this._editGeometryOperations.redo();return l(e)&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),e}undo(){if(p(this._editGeometryOperations))return null;this.emit("undo");const e=this._editGeometryOperations.undo();return l(e)&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),e}_recreateManipulators(){this._removeManipulators(),this._tooltip.clear(),this._createManipulators()}_recreateEditGeometryAndManipulators(e){const t={byComponentIndex:new Map};if(l(e)&&l(this.inputGeometry)&&A(e,this.inputGeometry))for(const i of this._manipulatorInfos)if("vertex"===i.type&&i.manipulator.selected){const{index:e,component:{index:a}}=i.handle,{byComponentIndex:o}=t,n=o.get(a)||new Set;n.add(e),o.set(a,n)}this._removeManipulators(),this._tooltip.clear(),this._editGeometryOperations=s(this._editGeometryOperations),this._segmentLabels=s(this._segmentLabels),p(e)||(this._editGeometryOperations=xe.fromGeometry(e,this.view.state.viewingMode),this._createManipulators(t),this._segmentLabels=new F({context:{view:this.view,editGeometryOperations:this._editGeometryOperations,elevationInfo:j(this.graphic),labelOptions:this._labelOptions,graphic:this.graphic,graphicState:this._graphicState},visible:this._labelOptions.enabled}))}_perGraphicManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const a=[],o=this._manipulatorInfos.some((e=>"vertex"===e.type&&e.manipulator.selected)),n=e===We.SELECTED_OR_ALL&&o;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.grabbing||n&&!r.manipulator.selected||a.push(r),i++);if(0===a.length)return t;this._moveVertices(a,t);if(a.length===i){if(this._updateEventState(qe.MOVING),this.destroyed)return t;this.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,mover:this.graphic})}else{if(this._updateEventState(qe.RESHAPING),this.destroyed)return t;this.emit("reshape",{type:"reshape",mover:this.graphic})}return t}_isMultiVertexSelection(){return this._manipulatorInfos.reduce(((e,t)=>"vertex"===t.type&&t.manipulator.selected?e+1:e),0)>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(qe.RESHAPING),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:a}=e;if(!t&&!i&&!a)return;const o=[];for(const n of this._manipulatorInfos)"vertex"===n.type&&(n.manipulator.selected&&!n.manipulator.grabbing||n===e.info)&&o.push(n);this._moveVertices(o,e,Oe.ACCUMULATE_STEPS),this.emit("reshape",{type:"reshape",mover:this.graphic})}_updateEventState(e){if(e===this._reshapeEventState)return!1;switch(e){case qe.NONE:if(0!==this._numGrabbing||0!==this._numDragging)return!1;switch(this._reshapeEventState){case qe.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic});break;case qe.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic})}break;case qe.MOVING:switch(this._reshapeEventState){case qe.NONE:this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic});break;case qe.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic}),this.destroyed||this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic})}break;case qe.RESHAPING:switch(this._reshapeEventState){case qe.NONE:this.emit("reshape",{type:"reshape-start",mover:this.graphic});break;case qe.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic}),this.destroyed||this.emit("reshape",{type:"reshape-start",mover:this.graphic})}}if(this.destroyed)return!1;const t=this._reshapeEventState!==e;return this._reshapeEventState=e,t}_createGraphicMoveManipulation(){const{tool:e,view:t}=this,i=this._graphicState;if(this._graphicMoveManipulation=new oe({tool:e,view:t,graphicState:i}),this.enableMoveGraphic){let e=null;this._manipulatorHandles.add(this._graphicMoveManipulation.createDragPipeline(((t,i,a)=>{i.next((e=>this._trackNumDragging(e))).next((t=>("start"===t.action&&(e=h(this._editGeometryOperations).createUndoGroup()),t))).next((e=>this._perGraphicManipulatorDragAction(We.ALL,e))).next((e=>(this._updateTranslateGraphicTooltip(ee.XY,e),e))).next((t=>{"end"===t.action&&(this._tooltip.clear(),e=d(e))})),a.next((()=>this._onDragCancel(!0,(()=>e=d(e)))))}))),this._graphicMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(e,!1))))}else this._graphicMoveManipulation.forEachManipulator((e=>{e.grabbable=!1,e.cursor=null}));this._graphicMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add(e.events.on("immediate-click",(e=>{this._manipulatorInfos.some((e=>e.manipulator.selected))?this._clearSelection():this.emit("immediate-click",{...e,graphic:this.graphic}),e.stopPropagation()})))))}_createMoveManipulation(e){const{graphic:t,handles:i,tool:a,view:o}=this,n=this._graphicState;this._moveManipulation=new te({tool:a,view:o,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&K(t),snapToScene:!1,radius:te.radiusForSymbol(t.symbol)}),this._moveManipulation.forEachManipulator((e=>i.add([e.events.on("immediate-click",(i=>{this._moveManipulation.zManipulation.hasManipulator(e)||this._manipulatorInfos.some((e=>e.manipulator.selected))||this.emit("immediate-click",{...i,graphic:t}),i.stopPropagation()})),this._watchAndUpdateGrabState(e,!1)])));const r=e=>t=>{i.add(t.events.on("focus-changed",(({action:t})=>{"focus"===t&&this._tooltipOptions.enabled?this._updateTranslateTooltip(e):this._tooltip.clear()})))};this._moveManipulation.xyManipulation.forEachManipulator(r(ee.XY)),this._moveManipulation.xyAxisManipulation.forEachManipulator(r(ee.XY_AXIS)),this._moveManipulation.zManipulation.forEachManipulator(r(ee.Z)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const s=h(t.geometry).spatialReference;i.add([this._moveManipulation.createDragPipeline(((i,o,n,r,s)=>{const{snappingStep:l,cancelSnapping:p}=Ee({predicate:e=>!!e.info,snappingManager:a.snappingManager,snappingContext:new be({editGeometryOperations:h(this._editGeometryOperations),elevationInfo:e,pointer:s,excludeFeature:t,visualizer:new z}),updatingHandles:this.updatingHandles,useZ:!1});return r=r.next((e=>(this._onDragCancel(),e))).next(p),{steps:n=n.next((e=>this._trackNumDragging(e))).next((e=>{const t=this._manipulatorInfos.filter((e=>"vertex"===e.type&&e.manipulator.selected));return e.manipulatorType===W.TRANSLATE_XY&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:e})).next(me(this.view,e,t)).next(...l).next(ge()).next((e=>this._perGraphicManipulatorDragAction(We.SELECTED_OR_ALL,e))).next((e=>(this._updateTranslateTooltip(i,e),e))),cancel:r}}),e,s,t),g((()=>n.displaying),(()=>{this._updateMoveManipulationPosition()}),f),n.on("changed",(()=>this._updateMoveManipulationPosition())),g((()=>n.isDraped),(e=>{this._updateMoveManipulationPosition();const t="align-move-manipulation";e?i.add(this.view.elevationProvider.on("elevation-change",(()=>this._updateMoveManipulationPosition())),t):i.remove(t)}),f)])}_createVisualElements(){const{graphic:e,view:t}=this,i=Q({view:t,graphic:e,forEachManipulator:e=>{if(!this.destroyed){this._graphicMoveManipulation.forEachManipulator(e),this._moveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,W.TRANSLATE_XY)}},onManipulatorsChanged:e=>this.on("manipulators-changed",e)});l(i)&&(this._outlineVisualElement=i.visualElement instanceof pe?i.visualElement:null),l(this._outlineVisualElement)&&this._manipulatorHandles.add(this._outlineVisualElement.events.on("attachment-origin-changed",(()=>{this._graphicState.isDraped||this._updateMoveManipulationPosition()}))),this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(e,t=j(this.graphic)){const i=B.reshapeManipulators.edgeOffset,a=i.size/2,o=a+i.collisionPadding,r=a/o,s=r*Math.sqrt(3)/2;p(this._edgeOffsetManipulatorGeometryInside)&&(this._edgeOffsetManipulatorGeometryInside=de(this._edgeOffsetManipulatorMaterial,s,r/2,r/2,i.height,i.offset)),p(this._edgeOffsetManipulatorGeometryOutside)&&(this._edgeOffsetManipulatorGeometryOutside=de(this._edgeOffsetManipulatorMaterial,-s,r/2,r/2,i.height,-i.offset));const h=[new k(this._edgeOffsetManipulatorGeometryInside.instantiate(),Me.Unfocused),new k(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),Me.Focused),new k(this._edgeOffsetManipulatorGeometryOutside.instantiate(),Me.Unfocused),new k(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),Me.Focused)],d=new U({view:this.view,renderObjects:h,elevationInfo:"on-the-ground"!==t.mode||P(this.graphic.symbol)?{mode:"absolute-height",offset:0}:t,worldOriented:!1,focusMultiplier:1,radius:o,available:!(!this.graphic.visible||!this.graphic.layer?.visible),collisionType:{type:"disc",direction:V(0,0,1)},collisionPriority:1,metadata:{deleting:!1}}),u=new U({view:this.view,worldSized:!0,worldOriented:!1,available:!(!this.graphic.visible||!this.graphic.layer?.visible),collisionPriority:-10,cursor:this.enableMoveGraphic?"move":"default",metadata:{deleting:!1}}),c={manipulator:d,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:u,elevationInfo:t,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(c,i.minSquaredEdgeLength),this._updateEdgeOffsetManipulator(c);const m=[];for(const n of[c.handle.leftVertex,c.handle.rightVertex]){const e=this._getManipulatorInfoFromHandle(n);l(e)&&m.push(e.manipulator.events.on("location-update",(()=>this._updateEdgeOffsetManipulator(c))))}c.locationUpdateHandle=n(m),this._manipulatorHandles.add(c.locationUpdateHandle,d),this._manipulatorHandles.add([this._watchAndUpdateGrabState(d,!0),this._watchAndUpdateGrabState(u,!0)],d),this._manipulatorHandles.add(_e(d,this._createEdgeOffsetPipeline(c,t)),d),this._manipulatorHandles.add(_e(u,((e,i,a,o)=>{if("touch"===o){this._createEdgeOffsetPipeline(c,t)(e,i,a)}else if(this.enableMoveGraphic){const o=this.graphic,n=l(o.geometry)?o.geometry.spatialReference:null;i.next((e=>this._trackNumDragging(e))).next(fe(this.view,e.elevationAlignedLocation)).next(Y(this.view,e.elevationAlignedLocation,t,n,o)).next(ve()).next(ge()).next((e=>this._perGraphicManipulatorDragAction(We.ALL,e))).next((e=>(this._updateTranslateGraphicTooltip(ee.XY,e),e))).next((e=>{"end"===e.action&&this._tooltip.clear()})),a.next((()=>this._onDragCancel(!e.metadata.deleting)))}})),d);const g=e=>{this._manipulatorInfos.some((e=>e.manipulator.selected))?this._clearSelection():this.emit("immediate-click",{...e,graphic:this.graphic}),e.stopPropagation()};return this._manipulatorHandles.add([d.events.on("immediate-click",g),u.events.on("immediate-click",g),d.events.on("focus-changed",(({action:e})=>{const t=this._tooltipOptions;if("focus"===e&&t.enabled){const e=this._tooltip.info=new Ge({tooltipOptions:t});this._updateTooltipAreaOrTotalLength(e)}else this._tooltip.clear()}))],d),this._manipulatorInfos.push(c),this.manipulators.add(d),this.manipulators.add(u),this.emit("manipulators-changed"),c}_autoHideEdgeOffsetManipulator(e,t){const i=e.manipulator,a=e.edgeManipulator,o=()=>{e.visibilityHandle=d(e.visibilityHandle);const o=this._getManipulatorInfoFromHandle(e.handle.leftVertex),r=this._getManipulatorInfoFromHandle(e.handle.rightVertex),s=l(o)&&l(r)&&le(o.manipulator.renderLocation,r.manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!a.focused||s)&&(i.grabbable=!s,a.grabbable=!s,e.visibilityHandle=n([i.disableDisplay(),{remove:()=>{i.grabbable=!0,a.grabbable=this.enableMoveGraphic}}]))};this._manipulatorHandles.add([i.events.on("focus-changed",o),a.events.on("focus-changed",o),{remove:()=>{d(e.visibilityHandle),a.metadata.deleting=!0,this.manipulators.remove(a)}}],i),o()}_updateEdgeOffsetManipulator(e){this._updateManipulatorPosition(e);const{coordinateHelper:t}=h(this._editGeometryOperations).data,i=ne(this.view,e.manipulator.elevationAlignedLocation,re(t,e.handle,h(e.manipulator.elevationInfo))),a=this._getManipulatorInfoFromHandle(e.handle.leftVertex),o=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(p(a)||p(o))return;const n=a.manipulator.renderLocation,r=o.manipulator.renderLocation,s=l(i)?se(i,n,r):x;e.manipulator.modelTransform=s,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=s;const d=O(b(Xe,n,r))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-d,0,0],[d,0,0]]]}}_createEdgeOffsetPipeline(e,t){return(i,a,o)=>{this._clearSelection();const{step:n,cleanup:r}=this._initializeEdgeOffset(e,t);a.next((e=>this._trackNumDragging(e))).next(fe(this.view,i.elevationAlignedLocation)).next(n).next(X(this.view)).next(Z(this.view,h(this._editGeometryOperations).data.spatialReference)).next(ge()).next(this._applyComputeEdgeOffsetDistanceStep()).next(this._applyEdgeOffsetStep(e)).next(this._showEdgeOffsetTooltip()).next((e=>{"end"===e.action&&r()})),o.next((()=>{i.metadata.deleting||(r(),this._onDragCancel())}))}}_initializeEdgeOffset(e,t){const i=h(this._editGeometryOperations),a=re(i.data.coordinateHelper,e.handle,t),o=i.createUndoGroup(),s=ne(this.view,e.manipulator.elevationAlignedLocation,a);if(a.requiresSplitEdgeLeft){const t=this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftEdge);l(t)&&this._splitEdgeManipulator(t,1)}if(a.requiresSplitEdgeRight){const t=this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightEdge);l(t)&&this._splitEdgeManipulator(t,0)}const u=()=>new T({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:i.data.spatialReference}),c=new pe({view:this.view,isDraped:this._graphicState.isDraped,geometry:u(),elevationInfo:e.elevationInfo,width:B.visualElements.lineGraphics.outline.width,color:B.colorToVec4(J.main),attached:!0});let m;const _=()=>{this._cleanEdgeOffsetCollapsedEdges(e),m=d(m)},f=this.on("undo",_);return m=n([r(c),g((()=>this._graphicState.isDraped),(e=>c.isDraped=e)),this._graphicState.on("changed",(()=>c.geometry=u())),o,f]),{step:e=>p(a)||p(s)?(_(),null):{...e,operation:a,plane:s},cleanup:_}}_applyEdgeOffsetStep(e){return t=>{if(this.destroyed||p(t.operation))return t;this._updateEventState(qe.RESHAPING);const{mapDeltaX:i,mapDeltaY:a,mapDeltaZ:o}=t;return(i||a||o)&&(this._offsetEdge(e,t),this.emit("reshape",{type:"reshape",mover:this.graphic})),t}}_applyComputeEdgeOffsetDistanceStep(){return e=>{const{operation:t,mapEnd:i}=e;return p(t)||p(i)?e:("start"===e.action&&t.selectArrowFromStartPoint(i),{...e,signedDistance:t.signedDistanceToPoint(i)})}}_showEdgeOffsetTooltip(){return e=>{const{mapEnd:t,signedDistance:i,operation:a}=e,o=this._tooltip,n=this._tooltipOptions;if(!n.enabled||p(i))return o.clear(),e;let r=o.info;(p(r)||"reshape-edge-offset"!==r.type)&&(r=o.info=new Ge({tooltipOptions:n}));const{coordinateHelper:s}=h(this._editGeometryOperations).data;return r.distance="end"===e.action?u:Fe(this._graphicState.isDraped,i*a.selectedArrow,t,a.plane,s),this._updateTooltipAreaOrTotalLength(r),e}}_cleanEdgeOffsetCollapsedEdges(e){const t=e.handle.leftVertex.leftEdge?.leftVertex,i=e.handle.leftVertex,a=e.handle.rightVertex.rightEdge?.rightVertex,o=e.handle.rightVertex,n=h(this._editGeometryOperations).data.coordinateHelper,r=[];if(t&&n.distance(t.pos,i.pos)<Ze){const e=this._getManipulatorInfoFromHandle(i);l(e)&&r.push(e)}if(n.distance(i.pos,o.pos)<Ze||a&&n.distance(a.pos,o.pos)<Ze){const e=this._getManipulatorInfoFromHandle(o);l(e)&&r.push(e)}r.length&&this._removeVertices(r)}_computeVertexManipulatorSizeAndOutline(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}_createVertexOrEdgeManipulator(e,t=j(this.graphic),i=!1){if("edge"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(p(this._vertexManipulatorGeometry)||p(this._vertexManipulatorOutlineGeometry)){const{size:e,outlineSize:t}=this._computeVertexManipulatorSizeAndOutline(B.reshapeManipulators.vertex);this._vertexManipulatorGeometry=ue(this._vertexManipulatorMaterial,e,16,16),this._vertexManipulatorOutlineGeometry=ue(this._vertexManipulatorOutlineMaterial,t,16,16)}if(p(this._edgeManipulatorGeometry)||p(this._edgeManipulatorOutlineGeometry)){const{size:e,outlineSize:t}=this._computeVertexManipulatorSizeAndOutline(B.reshapeManipulators.edge);this._edgeManipulatorGeometry=ue(this._edgeManipulatorMaterial,e,16,16),this._edgeManipulatorOutlineGeometry=ue(this._edgeManipulatorOutlineMaterial,t,16,16)}const a=l(this.graphic.geometry)&&"point"===this.graphic.geometry.type?[]:[new k(this._vertexManipulatorGeometry.instantiate(),Ye.Vertex|Me.Unselected),new k(this._vertexManipulatorOutlineGeometry.instantiate(),Ye.Vertex|Me.Unfocused|Me.Unselected),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),Ye.Vertex|Me.Focused|Me.Unselected),new k(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),Me.Selected),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),Me.Selected|Me.Unfocused),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),Me.Selected|Me.Focused)];this.enableMidpoints&&a.push(new k(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),Ye.Edge|Me.Focused|Me.Unselected),new k(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),Ye.Edge|Me.Focused|Me.Unselected),new k(this._edgeManipulatorGeometry.instantiate(),Ye.Edge|Me.Unfocused|Me.Unselected),new k(this._edgeManipulatorOutlineGeometry.instantiate(),Ye.Edge|Me.Unfocused|Me.Unselected));const o=new U({view:this.view,renderObjects:a,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:!(!this.graphic.visible||!this.graphic.layer?.visible),metadata:{deleting:!1}});o.selected=i,this._setTypeSpecificManipulatorSettings(o,e,t);const r="edge"===e.type?{manipulator:o,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0}:{manipulator:o,handle:e,type:"vertex",selectedIndex:0};if(this._manipulatorInfos.push(r),this.manipulators.add(o),this._updateManipulatorPosition(r),"edge"===r.type){const e=[];for(const t of[r.handle.leftVertex,r.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(t);l(i)&&e.push(i.manipulator.events.on("location-update",(()=>this._updateManipulatorPosition(r))))}r.locationUpdateHandle=n(e),this._manipulatorHandles.add(r.locationUpdateHandle,o)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(o,!0),o);const s=_e(o,((e,i,a,o)=>{let n=null;const{snappingStep:s,cancelSnapping:l}=Ee({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new be({editGeometryOperations:h(this._editGeometryOperations),elevationInfo:t,pointer:o,excludeFeature:this.graphic,visualizer:new z}),updatingHandles:this.updatingHandles,useZ:!1});a=a.next((t=>(this._onDragCancel(!e.metadata.deleting,(()=>n=d(n))),t))).next(l),i.next((e=>this._trackNumDragging(e))).next((e=>{if("start"===e.action&&(n=h(this._editGeometryOperations).createUndoGroup()),"edge"===r.type){const t=this._splitEdgeManipulator(r);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:r,snapOrigin:r.handle.pos}})).next(fe(this.view,e.elevationAlignedLocation)).next(q(this.view,this.graphic,e.elevationAlignedLocation,e.location.spatialReference,this.graphic)).next(me(this.view,t,this.graphic)).next(...s).next(ge()).next((t=>{this._perVertexManipulatorDragAction(t),"end"===t.action&&(n=d(n)),this._updateTranslateVertexTooltip(e,ee.XY,t)}))}));return this._manipulatorHandles.add([s,o.events.on("immediate-click",(e=>this._manipulatorClickCallback(e,r))),o.events.on("select-changed",(()=>{r.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition()})),o.events.on("focus-changed",(({action:e})=>{"focus"===e&&"edge"!==r.type?this._updateTranslateVertexTooltip(o,ee.XY):this._tooltip.clear()}))],o),this.emit("manipulators-changed"),r}_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.outputGeometry=l(this._editGeometryOperations)?this._editGeometryOperations.data.geometry:null),l(this.tool.snappingManager)&&this.tool.snappingManager.doneSnapping(),this._tooltip.clear(),this._reshapeEventState){case qe.NONE:break;case qe.MOVING:this.emit("move",{type:"move",dx:0,dy:0,mover:this.graphic});break;case qe.RESHAPING:this.emit("reshape",{type:"reshape",mover:this.graphic})}t&&t(),this.destroyed||this._updateEventState(qe.NONE)}_setTypeSpecificManipulatorSettings(e,t,i){switch(t.type){case"vertex":e.state=Ye.Vertex,e.selectable=!0,e.cursor="move",e.collisionPriority=2,e.radius=B.reshapeManipulators.vertex.size/2+B.reshapeManipulators.vertex.collisionPadding,e.elevationInfo=i,e.interactive=l(this.graphic.geometry)&&"point"!==this.graphic.geometry.type;break;case"edge":e.state=Ye.Edge,e.selectable=!1,e.cursor="copy",e.collisionPriority=-1,e.radius=B.reshapeManipulators.edge.size/2+B.reshapeManipulators.edge.collisionPadding,e.elevationInfo="on-the-ground"!==i.mode||P(this.graphic.symbol)?{mode:"absolute-height",offset:0}:i}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",(i=>this._onGrabStateChanged(e,t,i.action,i.pointerType)))}_onGrabStateChanged(e,t,i,a="mouse"){if(!this._removingManipulators){if("start"===i)t&&this._updateSelection(e),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(qe.NONE),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==a||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach((e=>{e.manipulator.interactive=e.manipulator.grabbing||!this._numGrabbing&&l(this.graphic.geometry)&&"point"!==this.graphic.geometry.type,"edgeManipulator"in e&&(e.edgeManipulator.interactive=e.edgeManipulator.grabbing||!this._numGrabbing)})),this._graphicMoveManipulation.forEachManipulator((e=>{e.interactive=e.grabbing||!this._numGrabbing})))}}_clearSelection(){for(const e of this._manipulatorInfos)e.manipulator.grabbing||(e.manipulator.selected=!1)}_updateSelection(e){e.grabbing&&!e.selected&&e.selectable&&(this._clearSelection(),e.selected=!0,this.emit("manipulators-changed"))}_removeManipulator(e){p(e)||(e.manipulator.metadata.deleting=!0,this.manipulators.remove(e.manipulator),this._manipulatorHandles.remove(e.manipulator),t(this._manipulatorInfos,e),this.emit("manipulators-changed"))}_getManipulatorInfoFromHandle(e){if(e)for(const t of this._manipulatorInfos)if(e===t.handle)return t;return null}_updateManipulatorPosition(e){if(this._removingManipulators)return;if(p(e))return;const t=h(this._editGeometryOperations);if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,ze),e.manipulator.grabbing&&l(this._vertexLaserLineVisualElement)&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex),a=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(p(i)||p(a))return;const o=i.manipulator,n=a.manipulator;if(l(e.manipulator.elevationInfo)&&"on-the-ground"===e.manipulator.elevationInfo.mode){const i=o.location,a=n.location,r=.5,s=i.x+r*(a.x-i.x),l=i.y+r*(a.y-i.y),p=i.hasZ&&a.hasZ?0:void 0;e.manipulator.location=L(s,l,p,t.data.spatialReference)}else E(Xe,o.renderLocation,n.renderLocation,.5),e.manipulator.renderLocation=Xe}}_splitEdgeManipulator(e,t=.5){const i=h(this._editGeometryOperations),a=h(i.splitEdge(e.handle,t).createdVertex);e.locationUpdateHandle=d(e.locationUpdateHandle);const o=j(this.graphic);let n;this.enableEdgeOffset?(this._removeManipulator(e),n=this._createVertexOrEdgeManipulator(a)):(n=e,n.handle=a,n.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,o)),a.leftEdge&&this._createVertexOrEdgeManipulator(a.leftEdge),a.rightEdge&&this._createVertexOrEdgeManipulator(a.rightEdge),this.outputGeometry=i.data.geometry,this._updateManipulatorPosition(n),this.enableEdgeOffset||this._updateTranslateVertexTooltip(n.manipulator,ee.XY),this._updateSelection(e.manipulator);const r=this._updateEventState(qe.RESHAPING),s=i.data.coordinateHelper.vectorToArray(n.handle.pos),l=i.data.components.indexOf(a.component);return this.emit("vertex-add",{type:"vertex-add",vertices:[{coordinates:s,componentIndex:l,vertexIndex:h(a.index)}],added:s}),r&&this._updateEventState(qe.NONE),n}_updateMoveManipulationPosition(){if(this._removingManipulators)return;const e=G(Xe,0,0,0);let t=0,i=!1,a=null,o=null;for(const n of this._manipulatorInfos)"vertex"===n.type&&(n.manipulator.selected?(t++,S(e,e,n.manipulator.renderLocation),p(a)||n.selectedIndex>a.selectedIndex?(o=a,a=n):(p(o)||n.selectedIndex>o.selectedIndex)&&(o=n)):i=!0);if(0===t){const e=this._graphicState.displaying&&this.enableMoveGraphic;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e,this._moveManipulation.zManipulation.available=e&&this.enableZShape&&K(this.graphic),this._moveManipulation.angle=ie(h(this.graphic.geometry)),this._moveManipulation.radius=te.radiusForSymbol(this.graphic.symbol)}else{const e=this._graphicState.displaying;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&K(this.graphic),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t;let i=0;if(l(a)){const e=a.handle.pos,t=l(o)?o.handle.pos:a.handle.leftEdge&&a.handle.leftEdge.leftVertex?a.handle.leftEdge.leftVertex.pos:null,n=p(o)&&a.handle.rightEdge&&a.handle.rightEdge.rightVertex?a.handle.rightEdge.rightVertex.pos:null;t&&n?this._moveManipulation.xyAxisManipulation.available=!1:t?i=ke(t,e):n&&(i=ke(e,n))}this._moveManipulation.angle=i,this._moveManipulation.radius=$}0!==t&&i?(w(e,e,1/t),ze.spatialReference=h(this._editGeometryOperations).data.spatialReference,ze.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,ze),this._moveManipulation.elevationAlignedLocation=ze):l(this._outlineVisualElement)&&!this._graphicState.isDraped&&l(this._outlineVisualElement.attachmentOrigin)?this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin:R(this.view,this._moveManipulation,this.graphic)}_removeVertices(e){const t=new Array,i=h(this._editGeometryOperations);for(const a of e)if("vertex"===a.type&&i.canRemoveVertex()){t.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftEdge)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightEdge));const e=i.removeVertices([a.handle]),o=h(e.removedVertices?.[0].createdEdge);o&&this._createVertexOrEdgeManipulator(o)}if(t.length>0){const e=t.map((e=>{const t=i.data.components.indexOf(e.component);return{coordinates:i.data.coordinateHelper.vectorToArray(e.pos),componentIndex:t,vertexIndex:h(e.index)}}));this.outputGeometry=i.data.geometry;const a=this._updateEventState(qe.RESHAPING);if(this.destroyed)return;if(this.emit("vertex-remove",{type:"vertex-remove",removed:e.map((e=>e.coordinates)),vertices:e}),this.destroyed)return;if(a&&(this._updateEventState(qe.NONE),this.destroyed))return;this._updateMoveManipulationPosition()}}_moveVertices(e,t,i=("start"===t.action?Oe.NEW_STEP:Oe.ACCUMULATE_STEPS)){const a=h(this._editGeometryOperations);a.moveVertices(e.map((e=>e.handle)),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i),this.outputGeometry=a.data.geometry;for(const o of e)this._updateManipulatorPosition(o)}_offsetEdge(e,t){if(p(t.operation)||p(t.signedDistance))return;const i=h(this._editGeometryOperations),a=t.operation.clone();a.distance=t.signedDistance,i.updateVertices([e.handle.leftVertex,e.handle.rightVertex],a),this.outputGeometry=i.data.geometry,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,e.button===ce.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===ce.Left&&this._splitEdgeManipulator(t),e.stopPropagation()}_updateTranslateTooltip(e,t){const i=this._manipulatorInfos.filter((e=>"vertex"===e.type&&e.manipulator.selected));1===i.length?this._updateTranslateVertexTooltip(i[0].manipulator,e,t):this._updateTranslateGraphicTooltip(e,t)}_updateTranslateGraphicTooltip(e,t){const i=this._tooltipOptions;if(!i.enabled)return;const a=this._graphicState.isDraped?"on-the-ground":"absolute-height";switch(e){case ee.XY:this._tooltip.info=new Ie({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,((e,t)=>Le(e,t,a)));break;case ee.XY_AXIS:this._tooltip.info=new Ve({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,((e,i)=>{const o=Le(e,i,a);return c(o,ae(t))}));break;case ee.Z:this._tooltip.info=new we({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,Pe)}}_updateTranslateVertexTooltip(e,t,i){const a=this._tooltipOptions;if(!a.enabled)return;let o;const n=this._graphicState.isDraped?"on-the-ground":"absolute-height";switch(t){case ee.XY:o=new He({tooltipOptions:a}),this._updateTranslateTooltipDistance(o,i,((e,t)=>Le(e,t,n))),this._updateTooltipAreaOrTotalLength(o);break;case ee.XY_AXIS:o=new Ae({tooltipOptions:a}),this._updateTranslateTooltipDistance(o,i,((e,t)=>{const a=Le(e,t,n);return c(a,ae(i))})),this._updateTooltipAreaOrTotalLength(o);break;case ee.Z:o=new Te({tooltipOptions:a}),this._updateTranslateTooltipDistance(o,i,Pe)}const r=Ue(e.elevationAlignedLocation);l(r)&&(o.elevation={mode:"absolute-height",...r}),this._tooltip.info=o}_updateTranslateTooltipDistance(e,t,i){if(l(t)&&"end"!==t.action){const{mapStart:a,mapEnd:o}=t,n=i(a,o);e.distance=l(n)?n:u}}_updateTooltipAreaOrTotalLength(e){const{geometry:t}=this.graphic;if(p(t))return;const i=this._graphicState.isDraped?"on-the-ground":"absolute-height";e.area="polygon"===t.type?De(t,i):null,e.totalLength="polyline"===t.type?je(t,i):null}get test(){return{segmentLabels:this._segmentLabels,tooltip:this._tooltip}}};function ke(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}function Fe(e,t,i,a,o){if(e){const e=o.toXYZ(o.pointToVector(i)),n=H(a,e,D.get()),r=Ne(n,e,o.spatialReference);if(l(r))return m(r.value*Math.sign(t),r.unit)}return m(t*v(i.spatialReference),"meters")}e([M()],Re.prototype,"_editGeometryOperations",void 0),e([M()],Re.prototype,"_segmentLabels",void 0),e([M({constructOnly:!0})],Re.prototype,"tool",void 0),e([M()],Re.prototype,"_tooltip",void 0),e([M()],Re.prototype,"inputGeometry",null),e([M()],Re.prototype,"outputGeometry",void 0),e([M({readOnly:!0})],Re.prototype,"updating",null),e([M()],Re.prototype,"manipulators",null),e([M()],Re.prototype,"view",null),e([M()],Re.prototype,"graphic",null),e([M()],Re.prototype,"enableZShape",null),e([M()],Re.prototype,"enableZVertex",null),e([M()],Re.prototype,"enableMoveGraphic",null),e([M()],Re.prototype,"enableMidpoints",null),e([M()],Re.prototype,"enableEdgeOffset",null),e([M()],Re.prototype,"_labelOptions",null),e([M()],Re.prototype,"_tooltipOptions",null),Re=e([y("esri.views.3d.interactive.editingTools.reshapeGraphic.ReshapeOperation")],Re);const ze=L(0,0,void 0,Ce.WGS84),Xe=I(),Ze=1e-6;var Ye,qe,We;!function(e){e.Vertex=ye.Custom1,e.Edge=ye.Custom2}(Ye||(Ye={})),function(e){e[e.NONE=0]="NONE",e[e.MOVING=1]="MOVING",e[e.RESHAPING=2]="RESHAPING"}(qe||(qe={})),function(e){e[e.ALL=0]="ALL",e[e.SELECTED_OR_ALL=1]="SELECTED_OR_ALL"}(We||(We={}));export{Re as ReshapeOperation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{HandleOwner as t}from"../../../core/HandleOwner.js";import r from"../../../core/Handles.js";import{someMap as s}from"../../../core/MapUtils.js";import{isSome as o,isNone as a,unwrap as i}from"../../../core/maybe.js";import{eachAlwaysValues as n,throwIfAborted as c}from"../../../core/promiseUtils.js";import{sync as u,watch as p,syncAndInitial as l}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{o as g}from"../../../chunks/vec2.js";import{c as y}from"../../../chunks/vec3.js";import{c as S}from"../../../chunks/vec3f64.js";import{SnappingTypes as m}from"../../../layers/graphics/data/QueryEngineResult.js";import{absoluteHeightElevationInfo as f}from"../../../support/elevationInfoUtils.js";import{VerticalHalfPlaneConstraint as w}from"./SnappingConstraint.js";import{SnappingDomain as v}from"./SnappingDomain.js";import{anyMapPointToSnappingPoint as _}from"./SnappingPoint.js";import{sortCandidatesInPlace as j,screenDistance as C}from"./snappingUtils.js";import{EdgeSnappingCandidate as F}from"./candidates/EdgeSnappingCandidate.js";import{FeatureSnappingCandidate as x}from"./candidates/FeatureSnappingCandidate.js";import{RightAngleSnappingCandidate as b,OtherVertexType as R}from"./candidates/RightAngleSnappingCandidate.js";import{vectorToScreenPoint as L}from"../support/viewUtils.js";let M=class extends t{get updating(){return s(this.snappingSources,(({snappingSource:e})=>e.updating))||this.updatingHandles.updating}get snappingSources(){const e=this._get("snappingSources")||new Map,t=new Map;if(o(this.options)&&o(this.options.featureSources))for(const r of this.options.featureSources.items){const s=r.layer.uid,a=e.get(s);if(a){e.delete(s),t.set(s,a);continue}if(!r.layer.loaded){this.updatingHandles.addPromise(r.layer.load());continue}const i=this._createSourceInfo(r);o(i)&&t.set(s,i)}for(const[,r]of e)r.destroy();return t}constructor(e){super(e),this.options=null,this._domain=v.FEATURE,this._sourceModules={featureService:{module:null,loader:null},featureCollection:{module:null,loader:null},graphics:{module:null,loader:null},notes:{module:null,loader:null},scene:{module:null,loader:null}}}initialize(){this.updatingHandles.add((()=>this.snappingSources),(()=>this.notifyChange("updating")),u),o(this.view)&&this.handles.add([this.view.on("layerview-create",(e=>this._updateLayerView(e.layer,e.layerView))),this.view.on("layerview-destroy",(e=>this._updateLayerView(e.layer,null)))])}_updateLayerView(e,t){for(const[,r]of this.snappingSources)r.snappingSource.layerSource.layer===e&&(r.layerView=t)}destroy(){this._set("options",null);for(const[,e]of this.snappingSources)e.destroy()}async fetchCandidates(e,t,r,s){if(!(t&this._domain)||a(this.options)||!this.options.effectiveFeatureEnabled)return[];const u=[],p=this._computeScreenSizeDistanceParameters(e,r),l={distance:p,mode:i(this.view)?.type??"2d",point:e,coordinateHelper:r.coordinateHelper,types:this._types};for(const[,{snappingSource:a,layerView:i}]of this.snappingSources)!a.layerSource.enabled||o(i)&&i.suspended||u.push(a.fetchCandidates(l,s).then((e=>e.filter((e=>!this._candidateIsExcluded(a,e,r.excludeFeature))))));const d=(await n(u)).flat();return this._addRightAngleCandidates(d,e,p,r),c(s),j(e,d),d}_addRightAngleCandidates(e,t,r,s){const a=o(s.vertexHandle)?s.vertexHandle.rightEdge?.rightVertex?.pos:o(s.editGeometryOperations)&&"polygon"===s.editGeometryOperations.data.type?i(s.editGeometryOperations.data.components[0]?.getFirstVertex())?.pos:null,n=o(s.vertexHandle)?s.vertexHandle.leftEdge?.leftVertex?.pos:o(s.editGeometryOperations)?i(s.editGeometryOperations.data.components[0]?.getLastVertex())?.pos:null,{view:c}=this,u=_(a,c,s),p=_(n,c,s),l=e.length;for(let o=0;o<l;o++)this._addRightAngleCandidate(e[o],p,t,r,e),this._addRightAngleCandidate(e[o],u,t,r,e)}_addRightAngleCandidate(e,t,r,s,o){const i=e instanceof F,n=i&&g(e.constraint.start,e.constraint.end);if(a(t)||!i||n)return;const c=e.constraint.closestTo(t),u=(c[0]-r[0])/s.x,p=(c[1]-r[1])/s.y;if(u*u+p*p<=1){const r=new b({targetPoint:c,otherVertex:t,otherVertexType:R.NEXT,previousVertex:e.constraint.start,constraint:new w(t,c),objectId:e.objectId,isDraped:e.isDraped});o.push(r)}}_computeScreenSizeDistanceParameters(e,t){let r=o(this.options)?this.options.distance*("touch"===t.pointer?this.options.touchSensitivityMultiplier:1):0;return a(this.view)?{x:r,y:r,z:r,distance:r}:"2d"===this.view.type?(r*=this.view.resolution,{x:r,y:r,z:r,distance:r}):this._computeScreenSizeDistanceParameters3D(e,r,this.view,t)}_computeScreenSizeDistanceParameters3D(e,t,r,s){const{spatialReference:o}=s;r.renderCoordsHelper.toRenderCoords(e,o,E);const a=r.state.camera.computeScreenPixelSizeAt(E),i=a*r.renderCoordsHelper.unitInMeters/r.mapCoordsHelper.unitInMeters,n=t*i,c=L(e,o,f,r),u=c?V(c,e,i,0,0,r,s):0,p=c?V(c,e,0,i,0,r,s):0,l=c?V(c,e,0,0,i,r,s):0;return{x:0===u?0:n/u,y:0===p?0:n/p,z:0===l?0:n/l,distance:a*t}}get _types(){return m.EDGE|m.VERTEX}_candidateIsExcluded(e,t,r){if(a(r))return!1;const s=this._getCandidateObjectId(t);if(a(s))return!1;const o=e.layerSource.layer;return"graphics"===o.type?r.uid===s:r.sourceLayer===o&&(!(!r.attributes||!("objectIdField"in o))&&r.attributes[o.objectIdField]===s)}_getCandidateObjectId(e){return e instanceof x?e.objectId:null}_createSourceInfo(e){const t=this._createFeatureSnappingSourceType(e);if(a(t))return null;if("loading"in t)return this.updatingHandles.addPromise(t.loading.then((()=>{this.destroyed||this.notifyChange("snappingSources")}))),null;const r=o(this.view)?this.view.allLayerViews.find((t=>t.layer===e.layer)):null;return new H(t.source,r)}_createFeatureSnappingSourceType(e){switch(e.layer.type){case"feature":case"geojson":case"csv":case"oriented-imagery":case"subtype-group":case"wfs":return this._createFeatureSnappingSourceFeatureLayer(e);case"graphics":return this._createFeatureSnappingSourceGraphicsLayer(e);case"map-notes":return this._createFeatureSnappingSourceMapNotesLayer(e);case"scene":case"building-scene":return this._createFeatureSnappingSourceSceneLayer(e)}return null}_createFeatureSnappingSourceSceneLayer(e){const{view:t}=this;if(a(t)||"3d"!==t.type)return null;const r=this._getSourceModule("scene");return o(r.module)?{source:new r.module.SceneLayerSnappingSource({layerSource:e,view:t})}:{loading:r.loader}}_createFeatureSnappingSourceFeatureLayer(e){switch(e.layer.source?.type){case"feature-layer":case"oriented-imagery":{const t=this._getSourceModule("featureService");return o(t.module)?{source:new t.module.FeatureServiceSnappingSource({spatialReference:this.spatialReference,view:this.view,layerSource:e})}:{loading:t.loader}}case"memory":case"csv":case"geojson":case"wfs":{if("mesh"===e.layer.geometryType)return null;const t=this._getSourceModule("featureCollection");return o(t.module)?{source:new t.module.FeatureCollectionSnappingSource({layerSource:e,view:this.view})}:{loading:t.loader}}}return null}_createFeatureSnappingSourceGraphicsLayer(e){const t=this._getSourceModule("graphics");return o(t.module)?{source:new t.module.GraphicsSnappingSource({getGraphicsLayers:()=>[e.layer],spatialReference:this.spatialReference,view:this.view,layerSource:e})}:{loading:t.loader}}_createFeatureSnappingSourceMapNotesLayer(e){const t=this._getSourceModule("notes");return o(t.module)?{source:new t.module.GraphicsSnappingSource({getGraphicsLayers:()=>o(e.layer.sublayers)?e.layer.sublayers.toArray():[],spatialReference:this.spatialReference,view:this.view,layerSource:e})}:{loading:t.loader}}_getSourceModule(e){const t=this._sourceModules[e];if(a(t.loader)){const r=this._loadSourceModule(e).then((e=>{t.module=e}));return t.loader=r,{module:t.module,loader:r}}return{module:t.module,loader:t.loader}}_loadSourceModule(e){const t=this.updatingHandles;switch(e){case"featureService":return t.addPromise(import("./featureSources/FeatureServiceSnappingSource.js"));case"featureCollection":return t.addPromise(import("./featureSources/FeatureCollectionSnappingSource.js"));case"graphics":case"notes":return t.addPromise(import("./featureSources/GraphicsSnappingSource.js"));case"scene":return t.addPromise(import("./featureSources/SceneLayerSnappingSource.js"))}}};e([d({constructOnly:!0})],M.prototype,"spatialReference",void 0),e([d({constructOnly:!0})],M.prototype,"view",void 0),e([d()],M.prototype,"options",void 0),e([d({readOnly:!0})],M.prototype,"updating",null),e([d({readOnly:!0})],M.prototype,"snappingSources",null),M=e([h("esri.views.interactive.snapping.FeatureSnappingEngine")],M);class H{constructor(e,t){this.snappingSource=e,this.layerView=t,this.handles=new r;const s=this.snappingSource.layerSource.layer;if("refresh"in s){const t=s;this.handles.add(t.on("refresh",(()=>e.refresh())))}this.handles.add([p((()=>e.updating),(t=>e.layerSource.updating=t),l),p((()=>e.availability),(t=>e.layerSource.availability=t),l)])}destroy(){this.snappingSource.destroy(),this.handles.destroy()}}function V(e,t,r,s,o,a,{spatialReference:i}){const n=y(I,t);n[0]+=r,n[1]+=s,n[2]+=o;const c=L(n,i,f,a);return c?C(c,e):1/0}const E=S(),I=S();export{M as FeatureSnappingEngine};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{HandleOwner as t}from"../../../core/HandleOwner.js";import r from"../../../core/Handles.js";import{someMap as s}from"../../../core/MapUtils.js";import{isSome as o,isNone as a,unwrap as n}from"../../../core/maybe.js";import{eachAlwaysValues as i,throwIfAborted as c}from"../../../core/promiseUtils.js";import{sync as u,watch as p,syncAndInitial as l}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{o as g}from"../../../chunks/vec2.js";import{c as y}from"../../../chunks/vec3.js";import{c as S}from"../../../chunks/vec3f64.js";import{SnappingTypes as m}from"../../../layers/graphics/data/QueryEngineResult.js";import{absoluteHeightElevationInfo as f}from"../../../support/elevationInfoUtils.js";import{VerticalHalfPlaneConstraint as w}from"./SnappingConstraint.js";import{SnappingDomain as v}from"./SnappingDomain.js";import{anyMapPointToSnappingPoint as _}from"./SnappingPoint.js";import{sortCandidatesInPlace as j,screenDistance as C}from"./snappingUtils.js";import{DrapedEdgeSnappingCandidate as F}from"./candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as x}from"./candidates/EdgeSnappingCandidate.js";import{FeatureSnappingCandidate as b}from"./candidates/FeatureSnappingCandidate.js";import{RightAngleSnappingCandidate as R,OtherVertexType as L}from"./candidates/RightAngleSnappingCandidate.js";import{vectorToScreenPoint as M}from"../support/viewUtils.js";let E=class extends t{get updating(){return s(this.snappingSources,(({snappingSource:e})=>e.updating))||this.updatingHandles.updating}get snappingSources(){const e=this._get("snappingSources")||new Map,t=new Map;if(o(this.options)&&o(this.options.featureSources))for(const r of this.options.featureSources.items){const s=r.layer.uid,a=e.get(s);if(a){e.delete(s),t.set(s,a);continue}if(!r.layer.loaded){this.updatingHandles.addPromise(r.layer.load());continue}const n=this._createSourceInfo(r);o(n)&&t.set(s,n)}for(const[,r]of e)r.destroy();return t}constructor(e){super(e),this.options=null,this._domain=v.FEATURE,this._sourceModules={featureService:{module:null,loader:null},featureCollection:{module:null,loader:null},graphics:{module:null,loader:null},notes:{module:null,loader:null},scene:{module:null,loader:null}}}initialize(){this.updatingHandles.add((()=>this.snappingSources),(()=>this.notifyChange("updating")),u),o(this.view)&&this.handles.add([this.view.on("layerview-create",(e=>this._updateLayerView(e.layer,e.layerView))),this.view.on("layerview-destroy",(e=>this._updateLayerView(e.layer,null)))])}_updateLayerView(e,t){for(const[,r]of this.snappingSources)r.snappingSource.layerSource.layer===e&&(r.layerView=t)}destroy(){this._set("options",null);for(const[,e]of this.snappingSources)e.destroy()}async fetchCandidates(e,t,r,s){if(!(t&this._domain)||a(this.options)||!this.options.effectiveFeatureEnabled)return[];const u=[],p=this._computeScreenSizeDistanceParameters(e,r),l={distance:p,mode:n(this.view)?.type??"2d",point:e,coordinateHelper:r.coordinateHelper,types:this._types};for(const[,{snappingSource:a,layerView:n}]of this.snappingSources)!a.layerSource.enabled||o(n)&&n.suspended||u.push(a.fetchCandidates(l,s).then((e=>e.filter((e=>!this._candidateIsExcluded(a,e,r.excludeFeature))))));const d=(await i(u)).flat();return this._addRightAngleCandidates(d,e,p,r),c(s),j(e,d),d}_addRightAngleCandidates(e,t,r,s){const a=o(s.vertexHandle)?s.vertexHandle.rightEdge?.rightVertex?.pos:o(s.editGeometryOperations)&&"polygon"===s.editGeometryOperations.data.type?n(s.editGeometryOperations.data.components[0]?.getFirstVertex())?.pos:null,i=o(s.vertexHandle)?s.vertexHandle.leftEdge?.leftVertex?.pos:o(s.editGeometryOperations)?n(s.editGeometryOperations.data.components[0]?.getLastVertex())?.pos:null,{view:c}=this,u=_(a,c,s),p=_(i,c,s),l=e.length;for(let o=0;o<l;o++)this._addRightAngleCandidate(e[o],p,t,r,e),this._addRightAngleCandidate(e[o],u,t,r,e)}_addRightAngleCandidate(e,t,r,s,o){if(a(t)||!V(e))return;const n=e.constraint.closestTo(t),i=(n[0]-r[0])/s.x,c=(n[1]-r[1])/s.y;if(i*i+c*c<=1){const r=new R({targetPoint:n,otherVertex:t,otherVertexType:L.NEXT,previousVertex:e.constraint.start,constraint:new w(t,n),objectId:e.objectId,isDraped:e.isDraped});o.push(r)}}_computeScreenSizeDistanceParameters(e,t){let r=o(this.options)?this.options.distance*("touch"===t.pointer?this.options.touchSensitivityMultiplier:1):0;return a(this.view)?{x:r,y:r,z:r,distance:r}:"2d"===this.view.type?(r*=this.view.resolution,{x:r,y:r,z:r,distance:r}):this._computeScreenSizeDistanceParameters3D(e,r,this.view,t)}_computeScreenSizeDistanceParameters3D(e,t,r,s){const{spatialReference:o}=s;r.renderCoordsHelper.toRenderCoords(e,o,G);const a=r.state.camera.computeScreenPixelSizeAt(G),n=a*r.renderCoordsHelper.unitInMeters/r.mapCoordsHelper.unitInMeters,i=t*n,c=M(e,o,f,r),u=c?I(c,e,n,0,0,r,s):0,p=c?I(c,e,0,n,0,r,s):0,l=c?I(c,e,0,0,n,r,s):0;return{x:0===u?0:i/u,y:0===p?0:i/p,z:0===l?0:i/l,distance:a*t}}get _types(){return m.EDGE|m.VERTEX}_candidateIsExcluded(e,t,r){if(a(r))return!1;const s=this._getCandidateObjectId(t);if(a(s))return!1;const o=e.layerSource.layer;return"graphics"===o.type?r.uid===s:r.sourceLayer===o&&(!(!r.attributes||!("objectIdField"in o))&&r.attributes[o.objectIdField]===s)}_getCandidateObjectId(e){return e instanceof b?e.objectId:null}_createSourceInfo(e){const t=this._createFeatureSnappingSourceType(e);if(a(t))return null;if("loading"in t)return this.updatingHandles.addPromise(t.loading.then((()=>{this.destroyed||this.notifyChange("snappingSources")}))),null;const r=o(this.view)?this.view.allLayerViews.find((t=>t.layer===e.layer)):null;return new H(t.source,r)}_createFeatureSnappingSourceType(e){switch(e.layer.type){case"feature":case"geojson":case"csv":case"oriented-imagery":case"subtype-group":case"wfs":return this._createFeatureSnappingSourceFeatureLayer(e);case"graphics":return this._createFeatureSnappingSourceGraphicsLayer(e);case"map-notes":return this._createFeatureSnappingSourceMapNotesLayer(e);case"scene":case"building-scene":return this._createFeatureSnappingSourceSceneLayer(e)}return null}_createFeatureSnappingSourceSceneLayer(e){const{view:t}=this;if(a(t)||"3d"!==t.type)return null;const r=this._getSourceModule("scene");return o(r.module)?{source:new r.module.SceneLayerSnappingSource({layerSource:e,view:t})}:{loading:r.loader}}_createFeatureSnappingSourceFeatureLayer(e){switch(e.layer.source?.type){case"feature-layer":case"oriented-imagery":{const t=this._getSourceModule("featureService");return o(t.module)?{source:new t.module.FeatureServiceSnappingSource({spatialReference:this.spatialReference,view:this.view,layerSource:e})}:{loading:t.loader}}case"memory":case"csv":case"geojson":case"wfs":{if("mesh"===e.layer.geometryType)return null;const t=this._getSourceModule("featureCollection");return o(t.module)?{source:new t.module.FeatureCollectionSnappingSource({layerSource:e,view:this.view})}:{loading:t.loader}}}return null}_createFeatureSnappingSourceGraphicsLayer(e){const t=this._getSourceModule("graphics");return o(t.module)?{source:new t.module.GraphicsSnappingSource({getGraphicsLayers:()=>[e.layer],spatialReference:this.spatialReference,view:this.view,layerSource:e})}:{loading:t.loader}}_createFeatureSnappingSourceMapNotesLayer(e){const t=this._getSourceModule("notes");return o(t.module)?{source:new t.module.GraphicsSnappingSource({getGraphicsLayers:()=>o(e.layer.sublayers)?e.layer.sublayers.toArray():[],spatialReference:this.spatialReference,view:this.view,layerSource:e})}:{loading:t.loader}}_getSourceModule(e){const t=this._sourceModules[e];if(a(t.loader)){const r=this._loadSourceModule(e).then((e=>{t.module=e}));return t.loader=r,{module:t.module,loader:r}}return{module:t.module,loader:t.loader}}_loadSourceModule(e){const t=this.updatingHandles;switch(e){case"featureService":return t.addPromise(import("./featureSources/FeatureServiceSnappingSource.js"));case"featureCollection":return t.addPromise(import("./featureSources/FeatureCollectionSnappingSource.js"));case"graphics":case"notes":return t.addPromise(import("./featureSources/GraphicsSnappingSource.js"));case"scene":return t.addPromise(import("./featureSources/SceneLayerSnappingSource.js"))}}};e([d({constructOnly:!0})],E.prototype,"spatialReference",void 0),e([d({constructOnly:!0})],E.prototype,"view",void 0),e([d()],E.prototype,"options",void 0),e([d({readOnly:!0})],E.prototype,"updating",null),e([d({readOnly:!0})],E.prototype,"snappingSources",null),E=e([h("esri.views.interactive.snapping.FeatureSnappingEngine")],E);class H{constructor(e,t){this.snappingSource=e,this.layerView=t,this.handles=new r;const s=this.snappingSource.layerSource.layer;if("refresh"in s){const t=s;this.handles.add(t.on("refresh",(()=>e.refresh())))}this.handles.add([p((()=>e.updating),(t=>e.layerSource.updating=t),l),p((()=>e.availability),(t=>e.layerSource.availability=t),l)])}destroy(){this.snappingSource.destroy(),this.handles.destroy()}}function V(e){return(e instanceof x||e instanceof F)&&!g(e.constraint.start,e.constraint.end)}function I(e,t,r,s,o,a,{spatialReference:n}){const i=y(P,t);i[0]+=r,i[1]+=s,i[2]+=o;const c=M(i,n,f,a);return c?C(c,e):1/0}const G=S(),P=S();export{E as FeatureSnappingEngine};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{isSome as i,unwrap as r}from"../../../../core/maybe.js";import{throwIfAborted as n,whenOrAbort as o}from"../../../../core/promiseUtils.js";import{watch as a,initial as s}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{elevationContextAffectsAlignment as y}from"../../../../support/elevationInfoUtils.js";import{makeFilter as c,makeSnappingQuery as g}from"../snappingUtils.js";import{convertSnappingCandidate as u,makeGetGroundElevation as h}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as m}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as d}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as v}from"./symbologySnappingCandidates.js";let S=class extends t{get availability(){return 1}get updating(){return this.layerSource.updating}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,r=i(e)&&"3d"===e.type;if(!r||"subtype-group"===t.type)return m();const n=async(i,r)=>(await o(e.whenLayerView(t),r)).elevationAlignPointsInFeatures(i,r);return m(r,{elevationInfo:t.elevationInfo,alignPointsInFeatures:n,spatialReference:e.spatialReference})}get _snappingElevationFilter(){const{view:e}=this,t=i(e)&&"3d"===e.type&&"subtype-group"!==this.layerSource.layer.type;return d(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource;return i(e)&&"3d"===e.type&&"subtype-group"!==t.type?v(this._symbologySnappingSupported,(async(i,r)=>{const o=await e.whenLayerView(t);return n(r),o.queryForSymbologySnapping({candidates:i,spatialReference:e.spatialReference},r)})):v()}get _symbologySnappingSupported(){return i(this._layerView3D)&&this._layerView3D.symbologySnappingSupported}initialize(){const{view:e}=this,{layer:t}=this.layerSource;i(e)&&"3d"===e.type&&"subtype-group"!==t.type&&(e.whenLayerView(t).then((e=>this._layerView3D=e)),this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{const{elevationInfo:i}=t;y(e,i)&&this._snappingElevationAligner.notifyElevationSourceChange()})),a((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),s),a((()=>i(this._layerView3D)?this._layerView3D.processor?.renderer:null),(()=>this._symbologySnappingFetcher.notifySymbologyChange()),s)]))}constructor(e){super(e),this.view=null,this._layerView3D=null}refresh(){}async fetchCandidates(e,t){const{layer:i}=this.layerSource,o=i.source;if(!o?.querySnapping)return[];const a=c(i),s=g(e,r(this.view)?.type??"2d",a),p=await o.querySnapping(s,{signal:t});n(t);const l=await this._snappingElevationAligner.alignCandidates(p.candidates,t);n(t);const y=await this._symbologySnappingFetcher.fetch(l,t);n(t);const h=0===y.length?l:[...l,...y],m=this._snappingElevationFilter.filter(s,h),d=this._getGroundElevation;return m.map((e=>u(e,d)))}get _getGroundElevation(){return h(this.view)}};e([p({constructOnly:!0})],S.prototype,"layerSource",void 0),e([p({constructOnly:!0})],S.prototype,"view",void 0),e([p()],S.prototype,"_snappingElevationAligner",null),e([p()],S.prototype,"_snappingElevationFilter",null),e([p()],S.prototype,"_symbologySnappingFetcher",null),e([p()],S.prototype,"_layerView3D",void 0),e([p()],S.prototype,"_symbologySnappingSupported",null),e([p()],S.prototype,"_getGroundElevation",null),S=e([l("esri.views.interactive.snapping.featureSources.FeatureCollectionSnappingSource")],S);export{S as FeatureCollectionSnappingSource};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{isSome as i,toNullable as r,unwrap as o}from"../../../../core/maybe.js";import{throwIfAborted as n,whenOrAbort as a}from"../../../../core/promiseUtils.js";import{watch as s,initial as p,on as l}from"../../../../core/reactiveUtils.js";import{property as y}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{elevationContextAffectsAlignment as g}from"../../../../support/elevationInfoUtils.js";import{makeFilter as u,makeSnappingQuery as h}from"../snappingUtils.js";import{convertSnappingCandidate as m,makeGetGroundElevation as d}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as v}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as S}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as f}from"./symbologySnappingCandidates.js";let w=class extends t{get availability(){return 1}get updating(){return this.layerSource.updating}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,r=i(e)&&"3d"===e.type;if(!r||"subtype-group"===t.type)return v();const o=async(i,r)=>(await a(e.whenLayerView(t),r)).elevationAlignPointsInFeatures(i,r);return v(r,{elevationInfo:t.elevationInfo,alignPointsInFeatures:o,spatialReference:e.spatialReference})}get _snappingElevationFilter(){const{view:e}=this,t=i(e)&&"3d"===e.type&&"subtype-group"!==this.layerSource.layer.type;return S(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource;return i(e)&&"3d"===e.type&&"subtype-group"!==t.type?f(this._symbologySnappingSupported,(async(i,r)=>{const o=await e.whenLayerView(t);return n(r),o.queryForSymbologySnapping({candidates:i,spatialReference:e.spatialReference},r)})):f()}get _symbologySnappingSupported(){return i(this._layerView3D)&&this._layerView3D.symbologySnappingSupported}initialize(){const{view:e}=this,{layer:t}=this.layerSource;i(e)&&"3d"===e.type&&"subtype-group"!==t.type&&(e.whenLayerView(t).then((e=>this._layerView3D=e)),this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{const{elevationInfo:i}=t;g(e,i)&&this._snappingElevationAligner.notifyElevationSourceChange()})),s((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),p),s((()=>i(this._layerView3D)?this._layerView3D.processor?.renderer:null),(()=>this._symbologySnappingFetcher.notifySymbologyChange()),p),l((()=>r(this._layerView3D)?.layer),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))]))}constructor(e){super(e),this.view=null,this._layerView3D=null}refresh(){}async fetchCandidates(e,t){const{layer:i}=this.layerSource,r=i.source;if(!r?.querySnapping)return[];const a=u(i),s=h(e,o(this.view)?.type??"2d",a),p=await r.querySnapping(s,{signal:t});n(t);const l=await this._snappingElevationAligner.alignCandidates(p.candidates,t);n(t);const y=await this._symbologySnappingFetcher.fetch(l,t);n(t);const c=0===y.length?l:[...l,...y],g=this._snappingElevationFilter.filter(s,c),d=this._getGroundElevation;return g.map((e=>m(e,d)))}get _getGroundElevation(){return d(this.view)}};e([y({constructOnly:!0})],w.prototype,"layerSource",void 0),e([y({constructOnly:!0})],w.prototype,"view",void 0),e([y()],w.prototype,"_snappingElevationAligner",null),e([y()],w.prototype,"_snappingElevationFilter",null),e([y()],w.prototype,"_symbologySnappingFetcher",null),e([y()],w.prototype,"_layerView3D",void 0),e([y()],w.prototype,"_symbologySnappingSupported",null),e([y()],w.prototype,"_getGroundElevation",null),w=e([c("esri.views.interactive.snapping.featureSources.FeatureCollectionSnappingSource")],w);export{w as FeatureCollectionSnappingSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{HandleOwnerMixin as r}from"../../../../core/HandleOwner.js";import{destroyHandle as i}from"../../../../core/handleUtils.js";import{isSome as s,applySome as o,mapOr as n}from"../../../../core/maybe.js";import{throwIfAborted as a}from"../../../../core/promiseUtils.js";import{watch as l,initial as u,sync as p}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{ObservableValue as h}from"../../../../core/accessorSupport/tracking/ObservableValue.js";import{elevationContextAffectsAlignment as y}from"../../../../support/elevationInfoUtils.js";import{FeatureServiceTiles2D as g}from"../../../2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js";import{FeatureServiceTiles3D as f}from"../../../3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js";import{convertSnappingCandidate as m,makeGetGroundElevation as S}from"./queryEngineUtils.js";import{WorkerTileTreeDebugger as _}from"./WorkerTileTreeDebugger.js";import{FeatureServiceSnappingSourceWorkerHandle as v}from"./featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js";import{FeatureServiceTilesSimple as w}from"./featureServiceSource/FeatureServiceTilesSimple.js";import b from"../../../support/debugFlags.js";let I=class extends(r(t)){get _updateTilesParameters(){return{tiles:this._tilesOfInterest.tiles,tileInfo:this._tilesOfInterest.tileInfo,tileSize:this._tilesOfInterest.tileSize}}get updating(){return this._workerHandle?.updating||this.updatingHandles.updating}get configuration(){const{view:e}=this,t=s(e)?e.type:"2d";return{filter:this._layer.createQuery(),customParameters:this._layer.customParameters,viewType:t}}get availability(){return this._workerHandle?.availability??0}get _layer(){return this.layerSource.layer}constructor(e){super(e),this._workerHandle=null,this._debug=null}initialize(){let e;const t=this.view;if(s(t))switch(t.type){case"2d":this._tilesOfInterest=new g({view:t,layer:this._layer}),e=this._workerHandle=new v;break;case"3d":{const{resourceController:r}=t,i=this._layer,s=t.whenLayerView(i);this._tilesOfInterest=new f({view:t}),e=this._workerHandle=new v({schedule:e=>r.immediate.schedule(e),hasZ:this._layer.hasZ&&(this._layer.returnZ??!0),elevationAlignPointsInFeatures:async(e,t)=>{const r=await s;return a(t),r.elevationAlignPointsInFeatures(e,t)},queryForSymbologySnapping:async(e,t)=>{const r=await s;return a(t),r.queryForSymbologySnapping(e,t)}});const p=new h(null);s.then((e=>p.set(e))),this.addHandles([t.elevationProvider.on("elevation-change",(({context:t})=>{const{elevationInfo:r}=i;y(t,r)&&e.notifyElevationSourceChange()})),l((()=>i.elevationInfo),(()=>e.notifyElevationSourceChange()),u),l((()=>o(p.get(),(({processor:e})=>e?.renderer))),(()=>e.notifySymbologyChange()),u),l((()=>n(p.get(),!1,(e=>e.symbologySnappingSupported))),(t=>e.setSymbologySnappingSupported(t)),u)]);break}}else this._tilesOfInterest=new w({layer:this._layer}),e=this._workerHandle=new v;this.handles.add([i(e)]),e.setup({layer:this._layer,spatialReference:this.spatialReference,configuration:this.configuration},null),this.updatingHandles.add((()=>this._updateTilesParameters),(()=>e.updateTiles(this._updateTilesParameters,null)),u),this.handles.add([l((()=>this.configuration),(t=>e.configure(t,null)),p)]),s(t)&&this.handles.add(l((()=>b.FEATURE_SERVICE_SNAPPING_SOURCE_TILE_TREE_SHOW_TILES),(r=>{r&&!this._debug?(this._debug=new _({view:t,handle:e}),this.handles.add(i(this._debug),"debug")):!r&&this._debug&&this.handles.remove("debug")}),u)),this.handles.add(this.layerSource.layer.on("apply-edits",(t=>{e.applyEdits(t,null)})))}refresh(){this._workerHandle?.refresh(null)}async fetchCandidates(e,t){const{coordinateHelper:r,point:i}=e;this._tilesOfInterest.pointOfInterest=r.arrayToPoint(i);const s=this._getGroundElevation;return(await this._workerHandle.fetchCandidates({...e},t)).candidates.map((e=>m(e,s)))}getDebugInfo(e){return this._workerHandle.getDebugInfo(e)}get _getGroundElevation(){return S(this.view)}};e([c({constructOnly:!0})],I.prototype,"spatialReference",void 0),e([c({constructOnly:!0})],I.prototype,"layerSource",void 0),e([c({constructOnly:!0})],I.prototype,"view",void 0),e([c()],I.prototype,"_tilesOfInterest",void 0),e([c({readOnly:!0})],I.prototype,"_updateTilesParameters",null),e([c({readOnly:!0})],I.prototype,"updating",null),e([c({readOnly:!0})],I.prototype,"configuration",null),e([c({readOnly:!0})],I.prototype,"availability",null),e([c()],I.prototype,"_getGroundElevation",null),I=e([d("esri.views.interactive.snapping.featureSources.FeatureServiceSnappingSource")],I);export{I as FeatureServiceSnappingSource};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{HandleOwnerMixin as r}from"../../../../core/HandleOwner.js";import{destroyHandle as i}from"../../../../core/handleUtils.js";import{isSome as s,applySome as o,mapOr as a,toNullable as n}from"../../../../core/maybe.js";import{throwIfAborted as l,ignoreAbortErrors as u}from"../../../../core/promiseUtils.js";import{watch as p,on as c,initial as d,sync as h}from"../../../../core/reactiveUtils.js";import{property as y}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as g}from"../../../../core/accessorSupport/decorators/subclass.js";import{ObservableValue as f}from"../../../../core/accessorSupport/tracking/ObservableValue.js";import{elevationContextAffectsAlignment as m}from"../../../../support/elevationInfoUtils.js";import{FeatureServiceTiles2D as S}from"../../../2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js";import{FeatureServiceTiles3D as _}from"../../../3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js";import{convertSnappingCandidate as v,makeGetGroundElevation as w}from"./queryEngineUtils.js";import{WorkerTileTreeDebugger as b}from"./WorkerTileTreeDebugger.js";import{FeatureServiceSnappingSourceWorkerHandle as I}from"./featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js";import{FeatureServiceTilesSimple as j}from"./featureServiceSource/FeatureServiceTilesSimple.js";import O from"../../../support/debugFlags.js";let T=class extends(r(t)){get _updateTilesParameters(){return{tiles:this._tilesOfInterest.tiles,tileInfo:this._tilesOfInterest.tileInfo,tileSize:this._tilesOfInterest.tileSize}}get updating(){return this._workerHandle?.updating||this.updatingHandles.updating}get configuration(){const{view:e}=this,t=s(e)?e.type:"2d";return{filter:this._layer.createQuery(),customParameters:this._layer.customParameters,viewType:t}}get availability(){return this._workerHandle?.availability??0}get _layer(){return this.layerSource.layer}constructor(e){super(e),this._workerHandle=null,this._debug=null}initialize(){let e;const t=this.view;if(s(t))switch(t.type){case"2d":this._tilesOfInterest=new S({view:t,layer:this._layer}),e=this._workerHandle=new I;break;case"3d":{const{resourceController:r}=t,i=this._layer,s=t.whenLayerView(i);this._tilesOfInterest=new _({view:t}),e=this._workerHandle=new I({schedule:e=>r.immediate.schedule(e),hasZ:this._layer.hasZ&&(this._layer.returnZ??!0),elevationAlignPointsInFeatures:async(e,t)=>{const r=await s;return l(t),r.elevationAlignPointsInFeatures(e,t)},queryForSymbologySnapping:async(e,t)=>{const r=await s;return l(t),r.queryForSymbologySnapping(e,t)}});const h=new f(null);s.then((e=>h.set(e))),this.addHandles([t.elevationProvider.on("elevation-change",(({context:t})=>{const{elevationInfo:r}=i;m(t,r)&&u(e.notifyElevationSourceChange())})),p((()=>i.elevationInfo),(()=>u(e.notifyElevationSourceChange())),d),p((()=>o(h.get(),(({processor:e})=>e?.renderer))),(()=>u(e.notifySymbologyChange())),d),p((()=>a(h.get(),!1,(e=>e.symbologySnappingSupported))),(t=>u(e.setSymbologySnappingSupported(t))),d),c((()=>n(h.get())?.layer),["edits","apply-edits","graphic-update"],(()=>e.notifySymbologyChange()))]);break}}else this._tilesOfInterest=new j({layer:this._layer}),e=this._workerHandle=new I;this.handles.add([i(e)]),u(e.setup({layer:this._layer,spatialReference:this.spatialReference,configuration:this.configuration},null)),this.updatingHandles.add((()=>this._updateTilesParameters),(()=>u(e.updateTiles(this._updateTilesParameters,null))),d),this.handles.add([p((()=>this.configuration),(t=>u(e.configure(t,null))),h)]),s(t)&&this.handles.add(p((()=>O.FEATURE_SERVICE_SNAPPING_SOURCE_TILE_TREE_SHOW_TILES),(r=>{r&&!this._debug?(this._debug=new b({view:t,handle:e}),this.handles.add(i(this._debug),"debug")):!r&&this._debug&&this.handles.remove("debug")}),d)),this.handles.add(this.layerSource.layer.on("apply-edits",(t=>{u(e.applyEdits(t,null))})))}refresh(){this._workerHandle?.refresh(null)}async fetchCandidates(e,t){const{coordinateHelper:r,point:i}=e;this._tilesOfInterest.pointOfInterest=r.arrayToPoint(i);const s=this._getGroundElevation;return(await this._workerHandle.fetchCandidates({...e},t)).candidates.map((e=>v(e,s)))}getDebugInfo(e){return this._workerHandle.getDebugInfo(e)}get _getGroundElevation(){return w(this.view)}};e([y({constructOnly:!0})],T.prototype,"spatialReference",void 0),e([y({constructOnly:!0})],T.prototype,"layerSource",void 0),e([y({constructOnly:!0})],T.prototype,"view",void 0),e([y()],T.prototype,"_tilesOfInterest",void 0),e([y({readOnly:!0})],T.prototype,"_updateTilesParameters",null),e([y({readOnly:!0})],T.prototype,"updating",null),e([y({readOnly:!0})],T.prototype,"configuration",null),e([y({readOnly:!0})],T.prototype,"availability",null),e([y()],T.prototype,"_getGroundElevation",null),T=e([g("esri.views.interactive.snapping.featureSources.FeatureServiceSnappingSource")],T);export{T as FeatureServiceSnappingSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{removeUnordered as r}from"../../../../core/arrayUtils.js";import{createTask as s}from"../../../../core/asyncUtils.js";import{HandleOwnerMixin as o}from"../../../../core/HandleOwner.js";import{isSome as i,unwrap as n,isNone as a}from"../../../../core/maybe.js";import{eachAlwaysValues as p,throwIfAborted as l,whenOrAbort as c}from"../../../../core/promiseUtils.js";import{initial as d,watch as h}from"../../../../core/reactiveUtils.js";import{property as u}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as y}from"../../../../core/accessorSupport/decorators/subclass.js";import m from"../../../../geometry/Polygon.js";import{canProjectWithoutEngine as g,project as f,initializeProjection as _}from"../../../../geometry/projection.js";import{normalizeCentralMeridianForDisplay as v}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as S}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as w}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as j}from"../../../../layers/graphics/OptimizedFeature.js";import E from"../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as b}from"../../../../layers/graphics/data/QueryEngine.js";import{elevationContextAffectsAlignment as k}from"../../../../support/elevationInfoUtils.js";import{symbolHasExtrudeSymbolLayer as C}from"../../../../symbols/support/utils.js";import{sortCandidatesInPlace as F,makeSnappingQuery as A}from"../snappingUtils.js";import{convertSnappingCandidate as P,makeGetGroundElevation as R}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as G}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as I}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as O}from"./symbologySnappingCandidates.js";const U="graphics-collections";let x=class extends(o(t)){get updating(){return this.updatingHandles.updating}get _hasZ(){const e=this.view;return i(e)&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,r=i(e)&&"3d"===e.type;if(!r||"map-notes"===t.type)return G();const s=async(r,s)=>(await c(e.whenLayerView(t),s)).elevationAlignPointsInFeatures(r,s);return G(r,{elevationInfo:t.elevationInfo,alignPointsInFeatures:s,spatialReference:e.spatialReference})}get _snappingElevationFilter(){const{view:e}=this,t=i(e)&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type;return I(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource,r=i(e)&&"3d"===e.type,s=this._extrudedPolygonSymbolsCount>0;return r&&"map-notes"!==t.type&&s?O(s,(async(r,s)=>{const o=await e.whenLayerView(t);return l(s),o.queryForSymbologySnapping({candidates:r,spatialReference:e.spatialReference},s)})):O()}constructor(e){super(e),this.availability=1,this._sources={multipoint:null,point:null,polygon:null,polyline:null},this._loadedWkids=new Set,this._loadedWkts=new Set,this._pendingAdds=[],this._extrudedPolygonSymbolsCount=0}destroy(){for(const e of this._pendingAdds)e.task.abort();this._pendingAdds.length=0,this._mapSources((e=>this._destroySource(e)))}initialize(){this.updatingHandles.add((()=>this.getGraphicsLayers()),(e=>{this.updatingHandles.removeHandles(U);for(const t of e)this._addMany(t.graphics.toArray()),this.handles.add([t.on("graphic-update",(e=>this._onGraphicUpdate(e))),this.updatingHandles.addOnCollectionChange((()=>t.graphics),(e=>this._onGraphicsChanged(e)))],U)}),d);const{view:e}=this,{layer:t}=this.layerSource;i(e)&&"3d"===e.type&&"map-notes"!==t.type&&this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{k(e,t.elevationInfo)&&this._snappingElevationAligner.notifyElevationSourceChange()})),h((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),d)])}async fetchCandidates(e,t){const{point:r}=e,s=await p(this._mapSources((r=>this._fetchCandidatesForSource(r,e,t))));l(t);const o=this._getGroundElevation,i=s.flat().map((e=>P(e,o)));return F(r,i),i}get _getGroundElevation(){return R(this.view)}async _fetchCandidatesForSource(e,t,r){const s=A(t,n(this.view)?.type??"2d"),o=await e.queryEngine.executeQueryForSnapping(s,r);l(r);const i=await this._snappingElevationAligner.alignCandidates(o.candidates,r);l(r);const a=await this._symbologySnappingFetcher.fetch(i,r);l(r);const p=0===a.length?i:[...i,...a];return this._snappingElevationFilter.filter(s,p)}refresh(){}_onGraphicUpdate(e){if(this.getGraphicsLayers().some((t=>t.graphics.includes(e.graphic))))switch(e.property){case"geometry":case"visible":this._remove(e.graphic),this._addMany([e.graphic])}}_onGraphicsChanged(e){for(const t of e.removed)this._remove(t);this._addMany(e.added)}_addMany(e){const t=[],r=new Map;for(const s of e)a(s.geometry)||(this._needsInitializeProjection(s.geometry.spatialReference)?(t.push(s.geometry.spatialReference),r.set(s.uid,s)):this._add(s));this._createPendingAdd(t,r)}_createPendingAdd(e,t){if(!e.length)return;const o=s((async r=>{await _(e.map((e=>({source:e,dest:this.spatialReference}))),{signal:r}),this._markLoadedSpatialReferences(e);for(const[,e]of t)this._add(e)}));this.updatingHandles.addPromise(o.promise);const i={task:o,graphics:t},n=()=>r(this._pendingAdds,i);o.promise.then(n,n),this._pendingAdds.push(i)}_markLoadedSpatialReferences(e){for(const t of e)null!=t.wkid&&this._loadedWkids.add(t.wkid),null!=t.wkt&&this._loadedWkts.add(t.wkt)}_add(e){if(a(e.geometry)||!e.visible)return;let t=e.geometry;if("mesh"===t.type)return;"extent"===t.type&&(t=m.fromExtent(t));const r=this._ensureSource(t.type);if(a(r))return;const s=this._createOptimizedFeature(e.uid,t);a(s)||(r.featureStore.add(s),C(e.symbol)&&this._extrudedPolygonSymbolsCount++)}_needsInitializeProjection(e){return(null==e.wkid||!this._loadedWkids.has(e.wkid))&&((null==e.wkt||!this._loadedWkts.has(e.wkt))&&!g(e,this.spatialReference))}_createOptimizedFeature(e,t){const r=f(v(t),this.spatialReference);if(!r)return null;const s=this._ensureGeometryHasZ(r),o=w(s,this._hasZ,!1);return new j(o,{[z]:e},null,e)}_ensureGeometryHasZ(e){if(!this._hasZ)return e;const t=e=>{for(;e.length<3;)e.push(0)},r=e.clone();switch(r.hasZ=!0,r.type){case"point":r.z=r.z??0;break;case"multipoint":r.points.forEach(t);break;case"polyline":r.paths.forEach((e=>e.forEach(t)));break;case"polygon":r.rings.forEach((e=>e.forEach(t)))}return r}_ensureSource(e){const t=this._sources[e];if(i(t))return t;const r=this._createSource(e);return this._sources[e]=r,r}_createSource(e){const t=S.toJSON(e),r=this._hasZ,s=new E({geometryType:t,hasZ:r,hasM:!1});return{featureStore:s,queryEngine:new b({featureStore:s,fields:[{name:z,type:"esriFieldTypeOID",alias:z}],geometryType:t,hasM:!1,hasZ:r,objectIdField:z,spatialReference:this.spatialReference,scheduler:i(this.view)&&"3d"===this.view.type?this.view.resourceController.scheduler:null}),type:e}}_remove(e){this._mapSources((t=>this._removeFromSource(t,e)));for(const t of this._pendingAdds)t.graphics.delete(e.uid),0===t.graphics.size&&t.task.abort()}_removeFromSource(e,t){const r=t.uid;e.featureStore.has(r)&&(e.featureStore.removeById(t.uid),C(t.symbol)&&this._extrudedPolygonSymbolsCount--)}_destroySource(e){e.queryEngine.destroy(),this._sources[e.type]=null}_mapSources(e){const{point:t,polygon:r,polyline:s,multipoint:o}=this._sources,n=[];return i(t)&&n.push(e(t)),i(r)&&n.push(e(r)),i(s)&&n.push(e(s)),i(o)&&n.push(e(o)),n}};e([u()],x.prototype,"getGraphicsLayers",void 0),e([u({constructOnly:!0})],x.prototype,"layerSource",void 0),e([u({constructOnly:!0})],x.prototype,"spatialReference",void 0),e([u({constructOnly:!0})],x.prototype,"view",void 0),e([u({readOnly:!0})],x.prototype,"updating",null),e([u({readOnly:!0})],x.prototype,"availability",void 0),e([u()],x.prototype,"_hasZ",null),e([u()],x.prototype,"_snappingElevationAligner",null),e([u()],x.prototype,"_snappingElevationFilter",null),e([u()],x.prototype,"_symbologySnappingFetcher",null),e([u()],x.prototype,"_extrudedPolygonSymbolsCount",void 0),e([u()],x.prototype,"_getGroundElevation",null),x=e([y("esri.views.interactive.snapping.featureSources.GraphicsSnappingSource")],x);const z="OBJECTID";export{x as GraphicsSnappingSource};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{removeUnordered as o}from"../../../../core/arrayUtils.js";import{createTask as s}from"../../../../core/asyncUtils.js";import{HandleOwnerMixin as r}from"../../../../core/HandleOwner.js";import{isSome as i,unwrap as n,isNone as a}from"../../../../core/maybe.js";import{eachAlwaysValues as p,throwIfAborted as l,whenOrAbort as c}from"../../../../core/promiseUtils.js";import{initial as d,watch as h,on as u}from"../../../../core/reactiveUtils.js";import{property as y}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as m}from"../../../../core/accessorSupport/decorators/subclass.js";import g from"../../../../geometry/Polygon.js";import{canProjectWithoutEngine as f,project as _,initializeProjection as v}from"../../../../geometry/projection.js";import{normalizeCentralMeridianForDisplay as S}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as w}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as j}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as b}from"../../../../layers/graphics/OptimizedFeature.js";import E from"../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as k}from"../../../../layers/graphics/data/QueryEngine.js";import{elevationContextAffectsAlignment as C}from"../../../../support/elevationInfoUtils.js";import{symbolHasExtrudeSymbolLayer as F}from"../../../../symbols/support/utils.js";import{sortCandidatesInPlace as A,makeSnappingQuery as P}from"../snappingUtils.js";import{convertSnappingCandidate as R,makeGetGroundElevation as G}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as I}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as O}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as U}from"./symbologySnappingCandidates.js";const x="graphics-collections";let z=class extends(r(t)){get updating(){return this.updatingHandles.updating}get _hasZ(){const e=this.view;return i(e)&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,o=i(e)&&"3d"===e.type;if(!o||"map-notes"===t.type)return I();const s=async(o,s)=>(await c(e.whenLayerView(t),s)).elevationAlignPointsInFeatures(o,s);return I(o,{elevationInfo:t.elevationInfo,alignPointsInFeatures:s,spatialReference:e.spatialReference})}get _snappingElevationFilter(){const{view:e}=this,t=i(e)&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type;return O(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource,o=i(e)&&"3d"===e.type,s=this._extrudedPolygonSymbolsCount>0;return o&&"map-notes"!==t.type&&s?U(s,(async(o,s)=>{const r=await e.whenLayerView(t);return l(s),r.queryForSymbologySnapping({candidates:o,spatialReference:e.spatialReference},s)})):U()}constructor(e){super(e),this.availability=1,this._sources={multipoint:null,point:null,polygon:null,polyline:null},this._loadedWkids=new Set,this._loadedWkts=new Set,this._pendingAdds=[],this._extrudedPolygonSymbolsCount=0}destroy(){for(const e of this._pendingAdds)e.task.abort();this._pendingAdds.length=0,this._mapSources((e=>this._destroySource(e)))}initialize(){this.updatingHandles.add((()=>this.getGraphicsLayers()),(e=>{this.updatingHandles.removeHandles(x);for(const t of e)this._addMany(t.graphics.toArray()),this.handles.add([t.on("graphic-update",(e=>this._onGraphicUpdate(e))),this.updatingHandles.addOnCollectionChange((()=>t.graphics),(e=>this._onGraphicsChanged(e)))],x)}),d);const{view:e}=this,{layer:t}=this.layerSource;i(e)&&"3d"===e.type&&"map-notes"!==t.type&&this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{C(e,t.elevationInfo)&&this._snappingElevationAligner.notifyElevationSourceChange()})),h((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),d),u((()=>t),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))])}async fetchCandidates(e,t){const{point:o}=e,s=await p(this._mapSources((o=>this._fetchCandidatesForSource(o,e,t))));l(t);const r=this._getGroundElevation,i=s.flat().map((e=>R(e,r)));return A(o,i),i}get _getGroundElevation(){return G(this.view)}async _fetchCandidatesForSource(e,t,o){const s=P(t,n(this.view)?.type??"2d"),r=await e.queryEngine.executeQueryForSnapping(s,o);l(o);const i=await this._snappingElevationAligner.alignCandidates(r.candidates,o);l(o);const a=await this._symbologySnappingFetcher.fetch(i,o);l(o);const p=0===a.length?i:[...i,...a];return this._snappingElevationFilter.filter(s,p)}refresh(){}_onGraphicUpdate(e){if(this.getGraphicsLayers().some((t=>t.graphics.includes(e.graphic))))switch(e.property){case"geometry":case"visible":this._remove(e.graphic),this._addMany([e.graphic])}}_onGraphicsChanged(e){for(const t of e.removed)this._remove(t);this._addMany(e.added)}_addMany(e){const t=[],o=new Map;for(const s of e)a(s.geometry)||(this._needsInitializeProjection(s.geometry.spatialReference)?(t.push(s.geometry.spatialReference),o.set(s.uid,s)):this._add(s));this._createPendingAdd(t,o)}_createPendingAdd(e,t){if(!e.length)return;const r=s((async o=>{await v(e.map((e=>({source:e,dest:this.spatialReference}))),{signal:o}),this._markLoadedSpatialReferences(e);for(const[,e]of t)this._add(e)}));this.updatingHandles.addPromise(r.promise);const i={task:r,graphics:t},n=()=>o(this._pendingAdds,i);r.promise.then(n,n),this._pendingAdds.push(i)}_markLoadedSpatialReferences(e){for(const t of e)null!=t.wkid&&this._loadedWkids.add(t.wkid),null!=t.wkt&&this._loadedWkts.add(t.wkt)}_add(e){if(a(e.geometry)||!e.visible)return;let t=e.geometry;if("mesh"===t.type)return;"extent"===t.type&&(t=g.fromExtent(t));const o=this._ensureSource(t.type);if(a(o))return;const s=this._createOptimizedFeature(e.uid,t);a(s)||(o.featureStore.add(s),F(e.symbol)&&this._extrudedPolygonSymbolsCount++)}_needsInitializeProjection(e){return(null==e.wkid||!this._loadedWkids.has(e.wkid))&&((null==e.wkt||!this._loadedWkts.has(e.wkt))&&!f(e,this.spatialReference))}_createOptimizedFeature(e,t){const o=_(S(t),this.spatialReference);if(!o)return null;const s=this._ensureGeometryHasZ(o),r=j(s,this._hasZ,!1);return new b(r,{[H]:e},null,e)}_ensureGeometryHasZ(e){if(!this._hasZ)return e;const t=e=>{for(;e.length<3;)e.push(0)},o=e.clone();switch(o.hasZ=!0,o.type){case"point":o.z=o.z??0;break;case"multipoint":o.points.forEach(t);break;case"polyline":o.paths.forEach((e=>e.forEach(t)));break;case"polygon":o.rings.forEach((e=>e.forEach(t)))}return o}_ensureSource(e){const t=this._sources[e];if(i(t))return t;const o=this._createSource(e);return this._sources[e]=o,o}_createSource(e){const t=w.toJSON(e),o=this._hasZ,s=new E({geometryType:t,hasZ:o,hasM:!1});return{featureStore:s,queryEngine:new k({featureStore:s,fields:[{name:H,type:"esriFieldTypeOID",alias:H}],geometryType:t,hasM:!1,hasZ:o,objectIdField:H,spatialReference:this.spatialReference,scheduler:i(this.view)&&"3d"===this.view.type?this.view.resourceController.scheduler:null}),type:e}}_remove(e){this._mapSources((t=>this._removeFromSource(t,e)));for(const t of this._pendingAdds)t.graphics.delete(e.uid),0===t.graphics.size&&t.task.abort()}_removeFromSource(e,t){const o=t.uid;e.featureStore.has(o)&&(e.featureStore.removeById(t.uid),F(t.symbol)&&this._extrudedPolygonSymbolsCount--)}_destroySource(e){e.queryEngine.destroy(),this._sources[e.type]=null}_mapSources(e){const{point:t,polygon:o,polyline:s,multipoint:r}=this._sources,n=[];return i(t)&&n.push(e(t)),i(o)&&n.push(e(o)),i(s)&&n.push(e(s)),i(r)&&n.push(e(r)),n}};e([y()],z.prototype,"getGraphicsLayers",void 0),e([y({constructOnly:!0})],z.prototype,"layerSource",void 0),e([y({constructOnly:!0})],z.prototype,"spatialReference",void 0),e([y({constructOnly:!0})],z.prototype,"view",void 0),e([y({readOnly:!0})],z.prototype,"updating",null),e([y({readOnly:!0})],z.prototype,"availability",void 0),e([y()],z.prototype,"_hasZ",null),e([y()],z.prototype,"_snappingElevationAligner",null),e([y()],z.prototype,"_snappingElevationFilter",null),e([y()],z.prototype,"_symbologySnappingFetcher",null),e([y()],z.prototype,"_extrudedPolygonSymbolsCount",void 0),e([y()],z.prototype,"_getGroundElevation",null),z=e([m("esri.views.interactive.snapping.featureSources.GraphicsSnappingSource")],z);const H="OBJECTID";export{z as GraphicsSnappingSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Evented.js";import i from"../../../../../core/Handles.js";import{isSome as s}from"../../../../../core/maybe.js";import{createDeferred as r,throwIfAborted as n}from"../../../../../core/promiseUtils.js";import{watch as a,whenOnce as o,sync as l}from"../../../../../core/reactiveUtils.js";import{property as p}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import{subclass as d}from"../../../../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as u}from"../../../../../core/support/WatchUpdatingTracking.js";import c from"../../../../../geometry/SpatialReference.js";import h from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as f}from"../../../../../layers/graphics/data/QueryEngine.js";import g from"../../../../../layers/support/TileInfo.js";import m from"../../../../../rest/support/Query.js";import y from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as _}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as S}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as v}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as F}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as I}from"./FeatureServiceTileStore.js";let w=class extends t.EventedAccessor{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=r(),this._elevationAligner=_(),this._elevationFilter=S(),this._symbologyCandidatesFetcher=v(),this._handles=new i,this._updatingHandles=new u,this._editsUpdatingHandles=new u,this._pendingApplyEdits=new Map,this._alignPointsInFeatures=async(e,t)=>{const i={points:e},s=await this.remoteClient.invoke("alignElevation",i,{signal:t});return n(t),s},this._getSymbologyCandidates=async(e,t)=>{const i={candidates:e,spatialReference:this._spatialReference.toJSON()},s=await this.remoteClient.invoke("getSymbologyCandidates",i,{signal:t});return n(t),s}}get updating(){return this.updatingExcludingEdits||this._editsUpdatingHandles.updating||this._featureFetcher.updating}get updatingExcludingEdits(){return this._featureFetcher.updatingExcludingEdits||this._isInitializing||this._updatingHandles.updating}destroy(){this._featureFetcher.destroy(),this._queryEngine.destroy(),this._featureStore.clear(),this._handles.destroy()}async setup(e){const{geometryType:t,objectIdField:i,timeInfo:r,fields:n}=e.serviceInfo,{hasZ:o}=e,p=c.fromJSON(e.spatialReference);this._spatialReference=p,this._featureStore=new h({...e.serviceInfo,hasZ:o,hasM:!1}),this._queryEngine=new f({spatialReference:e.spatialReference,featureStore:this._featureStore,geometryType:t,fields:n,hasZ:o,hasM:!1,objectIdField:i,timeInfo:r}),this._featureFetcher=new F({store:new I({featureStore:this._featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:p,sourceSpatialReference:c.fromJSON(e.serviceInfo.spatialReference)});const d="3d"===e.configuration.viewType;return this._elevationAligner=_(d,{elevationInfo:s(e.elevationInfo)?y.fromJSON(e.elevationInfo):null,alignPointsInFeatures:this._alignPointsInFeatures,spatialReference:p}),this._elevationFilter=S(d),this._handles.add([a((()=>this._featureFetcher.availability),(e=>this.emit("notify-availability",{availability:e})),l),a((()=>this.updating),(()=>this._notifyUpdating()))]),this._whenSetup.resolve(),this._isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this._updatingHandles.addPromise(this._whenSetup.promise),this._updateFeatureFetcherConfiguration(e),{result:{}}}async fetchCandidates(e,t){await this._whenSetup.promise,n(t);const i=b(e),r=s(t)?t.signal:null,a=await this._queryEngine.executeQueryForSnapping(i,r);n(r);const o=await this._elevationAligner.alignCandidates(a.candidates,r);n(r);const l=await this._symbologyCandidatesFetcher.fetch(o,r);n(r);const p=0===l.length?o:o.concat(l);return{result:{candidates:this._elevationFilter.filter(i,p)}}}async updateTiles(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),n(t),this._featureFetcher.tileSize=e.tileSize,this._featureFetcher.tilesOfInterest=e.tiles,this._featureFetcher.tileInfo=s(e.tileInfo)?g.fromJSON(e.tileInfo):null,j}async refresh(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),n(t),this._featureFetcher.refresh(),j}async whenNotUpdating(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),n(t),await o((()=>!this.updatingExcludingEdits),t),n(t),j}async getDebugInfo(e,t){return n(t),{result:this._featureFetcher.debugInfo}}async beginApplyEdits(e,t){this._updatingHandles.addPromise(this._whenSetup.promise),n(t);const i=r();return this._pendingApplyEdits.set(e.id,i),this._featureFetcher.applyEdits(i.promise),this._editsUpdatingHandles.addPromise(i.promise),j}async endApplyEdits(e,t){const i=this._pendingApplyEdits.get(e.id);return i&&i.resolve(e.edits),n(t),j}async notifyElevationSourceChange(e,t){return this._elevationAligner.notifyElevationSourceChange(),j}async notifySymbologyChange(e,t){return j}async setSymbologySnappingSupported(e){return this._symbologyCandidatesFetcher=v(e,this._getSymbologyCandidates),j}_updateFeatureFetcherConfiguration(e){this._featureFetcher.filter=s(e.filter)?m.fromJSON(e.filter):null,this._featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};e([p({readOnly:!0})],w.prototype,"updating",null),e([p({readOnly:!0})],w.prototype,"updatingExcludingEdits",null),e([p()],w.prototype,"_isInitializing",void 0),w=e([d("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],w);const E=w;function b(e){return{point:e.point,mode:e.mode,distance:e.distance,types:e.types,query:s(e.filter)?e.filter:{where:"1=1"}}}const j={result:{}};export{E as default};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Evented.js";import i from"../../../../../core/Handles.js";import{isSome as s}from"../../../../../core/maybe.js";import{createDeferred as r,throwIfAborted as n}from"../../../../../core/promiseUtils.js";import{watch as a,whenOnce as o,sync as l}from"../../../../../core/reactiveUtils.js";import{property as d}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import{subclass as p}from"../../../../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as u}from"../../../../../core/support/WatchUpdatingTracking.js";import c from"../../../../../geometry/SpatialReference.js";import h from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as f}from"../../../../../layers/graphics/data/QueryEngine.js";import g from"../../../../../layers/support/TileInfo.js";import m from"../../../../../rest/support/Query.js";import y from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as _}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as S}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as v}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as F}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as I}from"./FeatureServiceTileStore.js";let w=class extends t.EventedAccessor{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=r(),this._elevationAligner=_(),this._elevationFilter=S(),this._symbologyCandidatesFetcher=v(),this._handles=new i,this._updatingHandles=new u,this._editsUpdatingHandles=new u,this._pendingApplyEdits=new Map,this._alignPointsInFeatures=async(e,t)=>{const i={points:e},s=await this.remoteClient.invoke("alignElevation",i,{signal:t});return n(t),s},this._getSymbologyCandidates=async(e,t)=>{const i={candidates:e,spatialReference:this._spatialReference.toJSON()},s=await this.remoteClient.invoke("getSymbologyCandidates",i,{signal:t});return n(t),s}}get updating(){return this.updatingExcludingEdits||this._editsUpdatingHandles.updating||this._featureFetcher.updating}get updatingExcludingEdits(){return this._featureFetcher.updatingExcludingEdits||this._isInitializing||this._updatingHandles.updating}destroy(){this._featureFetcher?.destroy(),this._queryEngine?.destroy(),this._featureStore?.clear(),this._handles?.destroy()}async setup(e){if(this.destroyed)return{result:{}};const{geometryType:t,objectIdField:i,timeInfo:r,fields:n}=e.serviceInfo,{hasZ:o}=e,d=c.fromJSON(e.spatialReference);this._spatialReference=d,this._featureStore=new h({...e.serviceInfo,hasZ:o,hasM:!1}),this._queryEngine=new f({spatialReference:e.spatialReference,featureStore:this._featureStore,geometryType:t,fields:n,hasZ:o,hasM:!1,objectIdField:i,timeInfo:r}),this._featureFetcher=new F({store:new I({featureStore:this._featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:d,sourceSpatialReference:c.fromJSON(e.serviceInfo.spatialReference)});const p="3d"===e.configuration.viewType;return this._elevationAligner=_(p,{elevationInfo:s(e.elevationInfo)?y.fromJSON(e.elevationInfo):null,alignPointsInFeatures:this._alignPointsInFeatures,spatialReference:d}),this._elevationFilter=S(p),this._handles.add([a((()=>this._featureFetcher.availability),(e=>this.emit("notify-availability",{availability:e})),l),a((()=>this.updating),(()=>this._notifyUpdating()))]),this._whenSetup.resolve(),this._isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this._updatingHandles.addPromise(this._whenSetup.promise),this._updateFeatureFetcherConfiguration(e),{result:{}}}async fetchCandidates(e,t){await this._whenSetup.promise,n(t);const i=E(e),r=s(t)?t.signal:null,a=await this._queryEngine.executeQueryForSnapping(i,r);n(r);const o=await this._elevationAligner.alignCandidates(a.candidates,r);n(r);const l=await this._symbologyCandidatesFetcher.fetch(o,r);n(r);const d=0===l.length?o:o.concat(l);return{result:{candidates:this._elevationFilter.filter(i,d)}}}async updateTiles(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),n(t),this._featureFetcher.tileSize=e.tileSize,this._featureFetcher.tilesOfInterest=e.tiles,this._featureFetcher.tileInfo=s(e.tileInfo)?g.fromJSON(e.tileInfo):null,j}async refresh(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),n(t),this._featureFetcher.refresh(),j}async whenNotUpdating(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),n(t),await o((()=>!this.updatingExcludingEdits),t),n(t),j}async getDebugInfo(e,t){return n(t),{result:this._featureFetcher.debugInfo}}async beginApplyEdits(e,t){this._updatingHandles.addPromise(this._whenSetup.promise),n(t);const i=r();return this._pendingApplyEdits.set(e.id,i),this._featureFetcher.applyEdits(i.promise),this._editsUpdatingHandles.addPromise(i.promise),j}async endApplyEdits(e,t){const i=this._pendingApplyEdits.get(e.id);return i&&i.resolve(e.edits),n(t),j}async notifyElevationSourceChange(e,t){return this._elevationAligner.notifyElevationSourceChange(),j}async notifySymbologyChange(e,t){return this._symbologyCandidatesFetcher.notifySymbologyChange(),j}async setSymbologySnappingSupported(e){return this._symbologyCandidatesFetcher=v(e,this._getSymbologyCandidates),j}_updateFeatureFetcherConfiguration(e){this._featureFetcher.filter=s(e.filter)?m.fromJSON(e.filter):null,this._featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};e([d({readOnly:!0})],w.prototype,"updating",null),e([d({readOnly:!0})],w.prototype,"updatingExcludingEdits",null),e([d()],w.prototype,"_isInitializing",void 0),w=e([p("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],w);const b=w;function E(e){return{point:e.point,mode:e.mode,distance:e.distance,types:e.types,query:s(e.filter)?e.filter:{where:"1=1"}}}const j={result:{}};export{b as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as e}from"../../../core/maybe.js";import{watch as t,syncAndInitial as n}from"../../../core/reactiveUtils.js";import{d as r}from"../../../chunks/vec3.js";import{makeDehydratedPoint as o}from"../../../layers/graphics/dehydratedFeatures.js";import{ViewEventPriorities as i}from"../../input/InputManager.js";import{SNAPPING_KEYS as s}from"../keybindings.js";import{anyMapPointToSnappingPoint as a}from"./SnappingPoint.js";function p(e,t){const n=e.length===t.length&&e[0]===t[0]&&e[1]===t[1];switch(e.length){case 2:return n;case 3:return n&&e[2]===t[2];case 4:return n&&e[2]===t[2]&&e[3]===t[3]}return!1}function c(e,t){const n=e.x-t.x,r=e.y-t.y;return n*n+r*r}function g(e,t){return Math.sqrt(c(e,t))}function u(e,t){t.sort(((t,n)=>r(t.targetPoint,e)-r(n.targetPoint,e)))}var E;function d({point:t,distance:n,types:r,coordinateHelper:{spatialReference:i}},s,a){return{point:o(t[0],t[1],t[2],i),mode:s,distance:n,types:r,query:e(a)?a.toJSON():{where:"1=1"}}}function f(e,t,n){return{left:a(e.leftVertex.pos,t,n),right:a(e.rightVertex.pos,t,n)}}function l(e){return e.createQuery()}function m(r,o=(()=>{})){const a=t((()=>({view:r.view,snappingOptions:r.snappingOptions})),(({view:t,snappingOptions:n})=>{const a="snapping-toggle";if(r.removeHandles(a),t&&e(n)){const e=[t.on("key-down",(e=>{e.key!==s.toggle||e.repeat||(n.enabledToggled=!0,o())}),i.TOOL),t.on("key-up",(e=>{e.key===s.toggle&&(n.enabledToggled=!1,o())}),i.TOOL)];r.addHandles(e,a)}}),n);r.addHandles(a)}!function(e){e[e.TARGET=0]="TARGET",e[e.REFERENCE=1]="REFERENCE",e[e.REFERENCE_EXTENSION=2]="REFERENCE_EXTENSION"}(E||(E={}));export{E as LineSegmentHintType,f as editEdgeToSnappingEdge,l as makeFilter,d as makeSnappingQuery,p as objectEqual,g as screenDistance,m as setupSnappingToggleHandles,u as sortCandidatesInPlace,c as squaredScreenDistance};
5
+ import{isSome as e}from"../../../core/maybe.js";import{watch as t,syncAndInitial as n}from"../../../core/reactiveUtils.js";import{d as o}from"../../../chunks/vec3.js";import{makeDehydratedPoint as r}from"../../../layers/graphics/dehydratedFeatures.js";import{ViewEventPriorities as i}from"../../input/InputManager.js";import{SNAPPING_KEYS as s}from"../keybindings.js";import{anyMapPointToSnappingPoint as a}from"./SnappingPoint.js";function p(e,t){const n=e.length===t.length&&e[0]===t[0]&&e[1]===t[1];switch(e.length){case 2:return n;case 3:return n&&e[2]===t[2];case 4:return n&&e[2]===t[2]&&e[3]===t[3]}return!1}function c(e,t){const n=e.x-t.x,o=e.y-t.y;return n*n+o*o}function g(e,t){return Math.sqrt(c(e,t))}function d(e,t){t.sort(((t,n)=>o(t.targetPoint,e)-o(n.targetPoint,e)))}var u;function l({point:t,distance:n,types:o,coordinateHelper:{spatialReference:i}},s,a){return{point:r(t[0],t[1],t[2],i.toJSON()),mode:s,distance:n,types:o,query:e(a)?a.toJSON():{where:"1=1"}}}function E(e,t,n){return{left:a(e.leftVertex.pos,t,n),right:a(e.rightVertex.pos,t,n)}}function f(e){return e.createQuery()}function m(o,r=(()=>{})){const a=t((()=>({view:o.view,snappingOptions:o.snappingOptions})),(({view:t,snappingOptions:n})=>{const a="snapping-toggle",p=i.TOOL;if(o.removeHandles(a),t&&e(n)){const e=[t.on("key-down",(e=>{e.key!==s.toggle||e.repeat||(n.enabledToggled=!0,r())}),p),t.on("key-up",(e=>{e.key===s.toggle&&(n.enabledToggled=!1,r())}),p),t.on("pointer-move",(e=>{const t=e.native.ctrlKey;n.enabledToggled!==t&&(n.enabledToggled=t,r())}),p)];o.addHandles(e,a)}}),n);o.addHandles(a)}!function(e){e[e.TARGET=0]="TARGET",e[e.REFERENCE=1]="REFERENCE",e[e.REFERENCE_EXTENSION=2]="REFERENCE_EXTENSION"}(u||(u={}));export{u as LineSegmentHintType,E as editEdgeToSnappingEdge,f as makeFilter,l as makeSnappingQuery,p as objectEqual,g as screenDistance,m as setupSnappingToggleHandles,d as sortCandidatesInPlace,c as squaredScreenDistance};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l,isSome as d}from"../../core/maybe.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{getEffectiveLayerCapabilities as k}from"../../layers/support/layerUtils.js";import g from"../Attachments/AttachmentsViewModel.js";import v from"./CreateFeaturesWorkflow.js";import b from"./CreateWorkflow.js";import{workflowDeprecation as _}from"./deprecationUtils.js";import W from"./UpdateWorkflow.js";import{whenEditorLayerView as C}from"./workflowUtils.js";import F from"../FeatureForm/FeatureFormViewModel.js";import E from"../FeatureTemplates/FeatureTemplatesViewModel.js";import I from"../Sketch/SketchViewModel.js";import O from"../Spinner/SpinnerViewModel.js";const U="esri.widgets.Editor.EditorViewModel",A=n.getLogger(U),V=["create","create-features","update"];function M(t,e,a){A.error(new i(t,e,a))}function j(t,e){return t?t.find((t=>t.layer===e)):void 0}let T=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.editableItems=new a,this.failures=[],this.attachmentsViewModel=new g({abilities:{editing:!0}}),this.featureFormViewModel=new F,this.featureTemplatesViewModel=new E,this.sketchViewModel=new I({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new O,this.pageStack=[],this.showDiscardPrompt=()=>Promise.resolve(),this._candidateCommitted=!1,this.back=async()=>{const t=this.activeWorkflow;if(t&&this.canGoBack){if(this.hasPendingEdits)try{await this.showDiscardPrompt()}catch(e){return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelWorkflow({force:!0})}},this.save=()=>{const{featureFormViewModel:t}=this;t.submit(),!t.submittable||t.validateContingencyConstraints(t.getValues(),{includeIncompleteViolations:!0}).length>0||this.activeWorkflow?.commit()},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.edits.feature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.handles.add([p((()=>{const t=this.view?.map?.editableLayers.filter((t=>t.visible)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)));return[t,a,this.layerInfos]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),u((()=>this.view?.map),(t=>{t.add(this._sketchGraphicsLayer)}),w),p((()=>this.editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this.editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...V]),this._set("allowedWorkflows",t)}get canCreate(){return this.editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this.editableItems.some((t=>t.supports.includes("update")||t.supports.includes("delete")||t.attachmentsOnUpdateEnabled))}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(A,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this.editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.pendingFeatures.length?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.pendingFeatures.length){const{template:e}=t.data.creationInfo;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{state:t,activeWorkflow:e}=this;return"editing-existing-feature"===t&&"update"===e?.type&&!1===e?.data.editableItem.attributeUpdatesEnabled}get canGoBack(){return d(this.activeWorkflow)&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&t.data.editableItem.supports.includes("delete")}get hasPendingEdits(){const{activeWorkflow:t}=this;return!!t&&("create"===t.type||"create-features"===t.type&&t.numPendingFeatures>0||"editing-existing-feature"===t.stepId&&t.data.edits.modified)}async startCreateWorkflowAtFeatureTypeSelection(){if(_(A,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(_(A,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(_(A,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?(await this._delete(t.data.edits.feature),await t.reset()):M("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this.editableItems.find((t=>t.layer===e))}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this.editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map?.editableLayers;if(!e||!r)return;const i=new Set(r),s=r?.filter((t=>{const e=k(t)?.operations;return!(!t.visible||!e?.supportsAdd||e?.supportsQuery)})),o=e.filter((t=>i.has(t.layer))),n=[];for(const a of o.reverse()){const{layer:t,suspended:e}=a;"subtype-group"===t.type?(await t.loadAll(),n.push(...t.sublayers.map((t=>this._makeEditableItemForLayer(t,e))))):n.push(this._makeEditableItemForLayer(t,e))}for(const a of s.reverse())"subtype-group"===a.type?(await a.loadAll(),n.push(...a.sublayers.map((t=>this._makeEditableItemForLayer(t,!1))))):n.push(this._makeEditableItemForLayer(a,!1));if(t.aborted)return;const l=this.editableItems;this.editableItems=new a(n),l.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&M("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return v.create(this,t,e,((t,e,a)=>this._applyEdits(t,e,a)),((t,e)=>this._addAttachments(t,e)))}_createCreateWorkflow(t){return b.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return W.create(this,t,((t,e)=>this._applyEdits(t,e)))}async _delete(t){const e=t?.sourceLayer;e&&"applyEdits"in e&&await this._applyEdits(e,{deleteFeatures:[t]})}_addAttachments(t,e){const a=[];return e?.forEach((e=>a.push(this._addAttachment(t,e.feature,e.attachment)))),Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;return await this._queueOperation((async()=>{if(k(t)?.operations.supportsQuery){const i=await C(this.view,t);return r=await t.applyEdits(e,a),await h((()=>!i.updating)),r}return r=await t.applyEdits(e,a),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{M("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=k(t),r=a?.operations,i=j(this.layerInfos,t),s=this.allowedWorkflows,o=s.includes("create")||s.includes("create-features"),n=s.includes("update"),l=t=>!i||!1!==i.enabled&&!1!==i[t],d=o&&!!r?.supportsAdd&&l("addEnabled"),p=n&&!!r?.supportsUpdate&&l("updateEnabled"),c=n&&!!r?.supportsDelete&&l("deleteEnabled"),u=[];e||(d&&u.push("create"),p&&u.push("update"),c&&u.push("delete"));const h=p&&(!i||!1!==i.attributeUpdatesEnabled),w=p&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),f=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:u,attributeUpdatesEnabled:h,geometryUpdatesEnabled:w,hasAttachments:f,attachmentsOnCreateEnabled:f&&o&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:f&&(!i||!1!==i.attachmentsOnUpdateEnabled)}}};t([f({readOnly:!0})],T.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],T.prototype,"_activityQueue",void 0),t([f({value:[...V]})],T.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],T.prototype,"canCreate",null),t([f({readOnly:!0})],T.prototype,"canUpdate",null),t([f()],T.prototype,"editableItems",void 0),t([f({readOnly:!0})],T.prototype,"failures",void 0),t([f()],T.prototype,"attachmentsViewModel",void 0),t([f()],T.prototype,"featureFormViewModel",void 0),t([f()],T.prototype,"featureTemplatesViewModel",void 0),t([f()],T.prototype,"labelOptions",null),t([f()],T.prototype,"layerInfos",null),t([f()],T.prototype,"sketchViewModel",void 0),t([f()],T.prototype,"snappingOptions",null),t([f()],T.prototype,"spinnerViewModel",void 0),t([f()],T.prototype,"state",null),t([f({readOnly:!0})],T.prototype,"syncing",null),t([f()],T.prototype,"updating",null),t([f()],T.prototype,"tooltipOptions",null),t([f()],T.prototype,"view",null),t([f()],T.prototype,"pageStack",void 0),t([f()],T.prototype,"showDiscardPrompt",void 0),t([f()],T.prototype,"_candidateCommitted",void 0),t([f()],T.prototype,"page",null),t([f()],T.prototype,"selectedTemplateItem",null),t([f()],T.prototype,"featureFormDisabled",null),t([f()],T.prototype,"canGoBack",null),t([f()],T.prototype,"shouldShowDeleteButton",null),t([f()],T.prototype,"hasPendingEdits",null),T=t([m(U)],T);const S=T;export{S as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l,isSome as d}from"../../core/maybe.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{getEffectiveLayerCapabilities as k}from"../../layers/support/layerUtils.js";import g from"../Attachments/AttachmentsViewModel.js";import v from"./CreateFeaturesWorkflow.js";import b from"./CreateWorkflow.js";import{workflowDeprecation as _}from"./deprecationUtils.js";import W from"./UpdateWorkflow.js";import{whenEditorLayerView as C}from"./workflowUtils.js";import F from"../FeatureForm/FeatureFormViewModel.js";import E from"../FeatureTemplates/FeatureTemplatesViewModel.js";import I from"../Sketch/SketchViewModel.js";import O from"../Spinner/SpinnerViewModel.js";const U="esri.widgets.Editor.EditorViewModel",A=n.getLogger(U),V=["create","create-features","update"];function M(t,e,a){A.error(new i(t,e,a))}function j(t,e){return t?t.find((t=>t.layer===e)):void 0}let T=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.editableItems=new a,this.failures=[],this.attachmentsViewModel=new g({abilities:{editing:!0}}),this.featureFormViewModel=new F,this.featureTemplatesViewModel=new E,this.sketchViewModel=new I({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new O,this.pageStack=[],this.showDiscardPrompt=()=>Promise.resolve(),this._candidateCommitted=!1,this.back=async()=>{const t=this.activeWorkflow;if(t&&this.canGoBack){if(this.hasPendingEdits)try{await this.showDiscardPrompt()}catch(e){return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelWorkflow({force:!0})}},this.save=()=>{const{featureFormViewModel:t}=this;t.submit(),!t.submittable||t.validateContingencyConstraints(t.getValues(),{includeIncompleteViolations:!0}).length>0||this.activeWorkflow?.commit()},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.edits.feature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.handles.add([p((()=>{const t=this.view?.map?.editableLayers.filter((t=>t.visible)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)));return[t,a,this.layerInfos]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),u((()=>this.view?.map),(t=>{t.add(this._sketchGraphicsLayer)}),w),p((()=>this.editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this.editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...V]),this._set("allowedWorkflows",t)}get canCreate(){return this.editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this.editableItems.some((t=>t.supports.includes("update")||t.supports.includes("delete")||t.attachmentsOnUpdateEnabled))}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(A,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this.editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.pendingFeatures.length?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.pendingFeatures.length){const{template:e}=t.data.creationInfo;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{state:t,activeWorkflow:e}=this;return"editing-existing-feature"===t&&"update"===e?.type&&!1===e?.data.editableItem.attributeUpdatesEnabled}get canGoBack(){return d(this.activeWorkflow)&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&t.data.editableItem.supports.includes("delete")}get hasPendingEdits(){const{activeWorkflow:t}=this;return!!t&&("create"===t.type||"create-features"===t.type&&t.numPendingFeatures>0||"editing-existing-feature"===t.stepId&&t.data.edits.modified)}async startCreateWorkflowAtFeatureTypeSelection(){if(_(A,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(_(A,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(_(A,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?(await this._delete(t.data.edits.feature),await t.reset()):M("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this.editableItems.find((t=>t.layer===e))}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this.editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map?.editableLayers;if(!e||!r)return;const i=new Set(r),s=r?.filter((t=>{const e=k(t)?.operations;return!(!t.visible||!e?.supportsAdd||e?.supportsQuery)})),o=e.filter((t=>i.has(t.layer))),n=[];for(const a of o.reverse()){const{layer:t,suspended:e}=a;"subtype-group"===t.type?(await t.loadAll(),n.push(...t.sublayers.slice().reverse().map((t=>this._makeEditableItemForLayer(t,e))))):n.push(this._makeEditableItemForLayer(t,e))}for(const a of s.reverse())"subtype-group"===a.type?(await a.loadAll(),n.push(...a.sublayers.map((t=>this._makeEditableItemForLayer(t,!1))))):n.push(this._makeEditableItemForLayer(a,!1));if(t.aborted)return;const l=this.editableItems;this.editableItems=new a(n),l.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&M("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return v.create(this,t,e,((t,e,a)=>this._applyEdits(t,e,a)),((t,e)=>this._addAttachments(t,e)))}_createCreateWorkflow(t){return b.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return W.create(this,t,((t,e)=>this._applyEdits(t,e)))}async _delete(t){const e=t?.sourceLayer;e&&"applyEdits"in e&&await this._applyEdits(e,{deleteFeatures:[t]})}_addAttachments(t,e){const a=[];return e?.forEach((e=>a.push(this._addAttachment(t,e.feature,e.attachment)))),Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;return await this._queueOperation((async()=>{if(k(t)?.operations.supportsQuery){const i=await C(this.view,t);return r=await t.applyEdits(e,a),await h((()=>!i.updating)),r}return r=await t.applyEdits(e,a),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{M("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=k(t),r=a?.operations,i=j(this.layerInfos,t),s=this.allowedWorkflows,o=s.includes("create")||s.includes("create-features"),n=s.includes("update"),l=t=>!i||!1!==i.enabled&&!1!==i[t],d=o&&!!r?.supportsAdd&&l("addEnabled"),p=n&&!!r?.supportsUpdate&&l("updateEnabled"),c=n&&!!r?.supportsDelete&&l("deleteEnabled"),u=[];e||(d&&u.push("create"),p&&u.push("update"),c&&u.push("delete"));const h=p&&(!i||!1!==i.attributeUpdatesEnabled),w=p&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),f=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:u,attributeUpdatesEnabled:h,geometryUpdatesEnabled:w,hasAttachments:f,attachmentsOnCreateEnabled:f&&o&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:f&&(!i||!1!==i.attachmentsOnUpdateEnabled)}}};t([f({readOnly:!0})],T.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],T.prototype,"_activityQueue",void 0),t([f({value:[...V]})],T.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],T.prototype,"canCreate",null),t([f({readOnly:!0})],T.prototype,"canUpdate",null),t([f()],T.prototype,"editableItems",void 0),t([f({readOnly:!0})],T.prototype,"failures",void 0),t([f()],T.prototype,"attachmentsViewModel",void 0),t([f()],T.prototype,"featureFormViewModel",void 0),t([f()],T.prototype,"featureTemplatesViewModel",void 0),t([f()],T.prototype,"labelOptions",null),t([f()],T.prototype,"layerInfos",null),t([f()],T.prototype,"sketchViewModel",void 0),t([f()],T.prototype,"snappingOptions",null),t([f()],T.prototype,"spinnerViewModel",void 0),t([f()],T.prototype,"state",null),t([f({readOnly:!0})],T.prototype,"syncing",null),t([f()],T.prototype,"updating",null),t([f()],T.prototype,"tooltipOptions",null),t([f()],T.prototype,"view",null),t([f()],T.prototype,"pageStack",void 0),t([f()],T.prototype,"showDiscardPrompt",void 0),t([f()],T.prototype,"_candidateCommitted",void 0),t([f()],T.prototype,"page",null),t([f()],T.prototype,"selectedTemplateItem",null),t([f()],T.prototype,"featureFormDisabled",null),t([f()],T.prototype,"canGoBack",null),t([f()],T.prototype,"shouldShowDeleteButton",null),t([f()],T.prototype,"hasPendingEdits",null),T=t([m(U)],T);const S=T;export{S as default};