@arcgis/core 4.33.11 → 4.33.12

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 (88) hide show
  1. package/applications/KnowledgeStudio/reshape.d.ts +5 -0
  2. package/applications/KnowledgeStudio/reshape.js +5 -0
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/{1415d4e2f5f3193be004.js → 012dee84d97b71461397.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{342f61e784c9364a493b.js → 1ebff223f0f241686669.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{fdfb5d601d318d6a49f9.js → 2f2cb0348f36a5157293.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{cb16ba9512ae0a09c55d.js → 4ab87eea6345818de60f.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{e9aa1d9ded8a52a40c57.js → 5d74b754ee0140afbd22.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{d33a5d79f2163ad62b1d.js → 64aebb3780ac4c8bfdc7.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{c6cd8784a3e222eb2d4a.js → 8edd8ebca441d670380f.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{cf25f487fe4eb1579aee.js → 9128902b127d0ec70fe0.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{17c623db3d9a06a9b711.js → a5fab8d7d8403b4de682.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{bac5e1d50b69f0d94694.js → ad2a29aca4e5bcd545cc.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{9049c81445cc044286f1.js → bbb92d0ba6a34c7a7d1b.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{7b9d14cc4a466ef18d71.js → bfd51df0a44a05596061.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{3ca6f893fd58f5b17af5.js → c410b2b9d0645e9cea89.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{8008f5479f4d16964088.js → dded6853cebf2165cb37.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{db192728fa0ee08a776a.js → e7ca7ced4dfb04c81e84.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{0155e6806621f3588ffa.js → fe71a2ea7965e75ee881.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{71e1a8bd432947c66357.js → ffeda53fee883f8025ed.js} +1 -1
  21. package/assets/esri/themes/base/widgets/_VideoPlayer.scss +16 -2
  22. package/assets/esri/themes/dark/main.css +1 -1
  23. package/assets/esri/themes/light/main.css +1 -1
  24. package/assets/esri/themes/light/view.css +1 -1
  25. package/chunks/GeodeticDistanceCalculator-Ce-woMPw.js +1 -1
  26. package/chunks/MultiPathImpl.js +1 -1
  27. package/chunks/OperatorGeodesicBuffer.js +1 -1
  28. package/chunks/OperatorGeodeticArea.js +1 -1
  29. package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
  30. package/chunks/OperatorGeodeticLength.js +1 -1
  31. package/chunks/OperatorProximityGeodesic.js +1 -1
  32. package/chunks/OperatorShapePreservingLength.js +1 -1
  33. package/chunks/OperatorShapePreservingProject.js +1 -1
  34. package/chunks/Point2D.js +1 -1
  35. package/chunks/ProjectionTransformation.js +1 -1
  36. package/chunks/sphere.js +1 -1
  37. package/chunks/vec42.js +1 -1
  38. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  39. package/core/libs/gl-matrix-2/math/vec4.js +1 -1
  40. package/core/quantityFormatUtils.js +1 -1
  41. package/core/unitFormatUtils.js +1 -1
  42. package/geometry/coordinateFormatter.js +1 -1
  43. package/geometry/operators/gx/operatorAlphaShape.js +1 -1
  44. package/geometry/operators/gx/operatorPolygonSlicer.js +1 -1
  45. package/geometry/support/sphere.js +1 -1
  46. package/interfaces.d.ts +128 -0
  47. package/kernel.js +1 -1
  48. package/layers/knowledgeGraph/nodeMovementUtils.js +5 -0
  49. package/package.json +1 -1
  50. package/renderers/support/RasterSymbolizer.js +1 -1
  51. package/support/revision.js +1 -1
  52. package/symbols/support/previewSymbol3D.js +1 -1
  53. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  54. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  55. package/views/3d/camera/constraintUtils/distance.js +1 -1
  56. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  57. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  58. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  59. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  60. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  61. package/views/3d/state/utils/navigationUtils.js +1 -1
  62. package/views/3d/terrain/OverlayManager.js +1 -1
  63. package/views/3d/terrain/TerrainSurface.js +1 -1
  64. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  65. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  66. package/views/LinkChartView.js +1 -1
  67. package/views/draw/DrawOperation.js +1 -1
  68. package/views/draw/support/GraphicMover.js +1 -1
  69. package/views/draw/support/HighlightHelper.js +1 -1
  70. package/views/draw/support/Reshape.js +1 -1
  71. package/views/interactive/Tooltip.js +1 -1
  72. package/views/interactive/sketch/SketchLabelOptions.js +1 -1
  73. package/views/interactive/sketch/SketchOptions.js +1 -1
  74. package/views/interactive/sketch/SketchTooltipOptions.js +1 -1
  75. package/views/interactive/sketch/SketchTooltipVisibleElements.js +1 -1
  76. package/views/interactive/sketch/SketchValueOptions.js +1 -1
  77. package/views/interactive/sketch/Units.js +1 -1
  78. package/views/interactive/sketch/constraints.js +1 -1
  79. package/views/interactive/snapping/featureSources/FeatureCollectionSnappingSource.js +1 -1
  80. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  81. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  82. package/views/interactive/tooltip/fields/fields.js +1 -1
  83. package/views/interactive/tooltip/fields/parsingAndFormattingUtils.js +1 -1
  84. package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
  85. package/views/support/angularMeasurementUtils.js +1 -1
  86. package/widgets/VideoPlayer/components/PlayerActionsGroup.js +1 -1
  87. package/widgets/VideoPlayer/css.js +1 -1
  88. package/widgets/VideoPlayer.js +1 -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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{equalsMaybe as o,destroyMaybe as r}from"../../core/maybe.js";import{memoize as s}from"../../core/memoize.js";import{ignoreAbortErrors as a}from"../../core/promiseUtils.js";import p from"../../core/ReactiveSet.js";import{watch as c,syncAndInitial as l}from"../../core/reactiveUtils.js";import{createScreenPoint as d}from"../../core/screenUtils.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import{diff as m}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as y,pointNear as _}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as v}from"../../support/elevationInfoUtils.js";import{ViewingMode as f}from"../ViewingMode.js";import{defaultDrawingMode as x}from"./DrawingMode.js";import{DrawManipulator as C}from"./DrawManipulator.js";import{createCoordinateHelper as b}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as T,sceneSnappingAtLocation as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as P,Component as V}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as w}from"../interactive/editGeometry/EditGeometryOperations.js";import{isPoint as O}from"../interactive/sketch/constraints.js";import{pointToConstraintSpace as M,constraintSpaceToPoint as D,getPointConstraint as E,getPolylineOrPolygonConstraint as I}from"../interactive/sketch/constraintUtils.js";import H from"../interactive/sketch/SketchLabelOptions.js";import{SnappingContext as j}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as G}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as k}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as Z}from"../interactive/snapping/snappingUtils.js";const L="crosshair",U="progress",A=Symbol(),z=Symbol();let F=class extends(i.EventedMixin(e)){constructor(t){super(t),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new p,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new g,this._stagedPointerId=null,this.constraintsEnabled=!1,this.constraints=void 0,this._getPointConstraint=s(E),this._getPolylineOrPolygonConstraint=s(I),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new H,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.firstVertex=null,this.lastVertex=null,this.secondToLastVertex=null,null==t.elevationInfo&&(this.elevationInfo=v(!!t.hasZ))}initialize(){const{geometryType:t,view:e}=this,i=e.spatialReference,n="viewingMode"in e.state?e.state.viewingMode:f.Local,r="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=b(this.hasZ,this.hasM,i),this._editGeometryOperations=new w(new P(r,this.coordinateHelper),n),this._snappingOperation=new k({view:e}),this.addHandles([c((()=>({stagedPoint:this._snappingOperation.stagedPoint,constraint:this._constraint})),(({stagedPoint:t,constraint:e},i)=>{const{snappingOptions:n}=this;n&&(n.forceDisabled=null!=e&&O(e));if(null!=i&&t===i.stagedPoint&&e!==i.constraint)return this._onKeyboardBasedChange();this._processCursor(t??this._screenToMap(this._stagedScreenPoint))}),{equals:(t,e)=>t.stagedPoint===e.stagedPoint&&o(t.constraint,e.constraint)}),c((()=>this.view.viewpoint),((t,e)=>{t&&e&&m(t,e)&&this._onKeyboardBasedChange()}))]),this._activeComponent=new V(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const s=this.segmentLabels;null!=s&&(s.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions,automaticLengthMeasurementUtils:this.automaticLengthMeasurementUtils},this.addHandles(c((()=>this.labelOptions.enabled),(t=>{s.visible=t}),l))),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(t=>{const e=t.vertices.map((t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)}))),i=e.map((t=>t.coordinates)),n=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.getFirstVertex()?.pos)??null;y(n,this.firstVertex)||(this.firstVertex=n);const o=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.getLastVertex()?.pos)??null;y(o,this.lastVertex)||(this.lastVertex=o);const r=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.edges.at(-1)?.leftVertex?.pos)??null;switch(y(r,this.secondToLastVertex)||(this.secondToLastVertex=r),this._processCursor(this.cursorVertex),t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}})));const p=this._manipulator=new C({consumesClicks:!1,grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(p),p.grabbable="point"!==t&&"multipoint"!==t,this.addHandles([p.events.on("immediate-click",(t=>this._onImmediateClick(t))),p.events.on("immediate-double-click",(t=>this._onImmediateDoubleClick(t))),c((()=>this.drawingMode),(()=>{this.removeHandles(A),this.addHandles(this._createManipulatorDragPipeline(p),A)}),l),c((()=>({effectiveCursor:this.effectiveCursor})),(({effectiveCursor:t})=>{p.cursor=t}),l)]),Z(this,(()=>{const t=this.view.inputManager.latestPointerType??"mouse",e=this._getSnappingContext(t);if(null!=this.snappingManager){const t=this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,e);this._updatingHandles.addPromise(a(t))}}))}destroy(){r(this.segmentLabels),r(this._snappingOperation),this._editGeometryOperations=r(this._editGeometryOperations),this._updatingHandles.destroy()}get _isDragging(){const{_stagedPointerId:t,_manipulator:e}=this;return null!=t&&this._pointerDownStates.has(t)||e.grabbing||!e.interactive}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const t=this._updateAndGetEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==t}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((t=>this.coordinateHelper.vectorToArray(t.pos)))}get _constraint(){const{constraints:t,constraintsEnabled:e}=this;if(t&&e)switch(this.geometryType){case"point":case"multipoint":return this._getPointConstraint(t);case"polygon":case"polyline":return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,t)}}set drawingMode(t){this._set("drawingMode",t??x)}get effectiveCursor(){return this.loading?U:this._hideDefaultCursor?null:this.cursor||L}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get cursorVertex(){return this._get("cursorVertex")}get visualizationCursorVertex(){return"mouse"===this._stagedPointerType?this.cursorVertex:null}get committableVertex(){const{cursorVertex:t,lastVertex:e,firstVertex:i,geometryType:n}=this;return"polygon"===n&&_(t,i)||_(t,e)?null:t}get updating(){return this._updatingHandles.updating}get geometryIncludingUncommittedVertices(){const{committedVertices:t,committableVertex:e,coordinateHelper:i}=this,n=t.slice();return null!=e&&n.push(i.pointToArray(e)),n}cancel(){this.complete({aborted:!0})}commitStagedVertex(){this._snappingOperation.abort();const{committableVertex:t}=this;null!=t&&this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t))}complete(t){const e=t?.aborted||!1;this._snappingOperation.abort(),this.snappingManager?.doneSnapping();const{geometryType:i,numCommittedVertices:n}=this,o="multipoint"===i&&0===n||"polyline"===i&&n<2||"polygon"===i&&n<3;"segment"!==i&&"point"!==i||this.commitStagedVertex(),this._createOperationCompleted=!o,(this.isCompleted||e)&&(this._stagedScreenPoint=null,this._stagedPointerId=null,this._stagedPointerType=null,this._processCursor(null),this.emit("complete",{vertices:this.committedVertices.map(((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t}))),aborted:e,type:"complete"}))}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_processCursor(t){const e=n(this.cursorVertex),i=n(t),o=i&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(i)??i),r=this._snapToClosingVertex(o),s=this._applyConstraints(r);_(e,s)||(this._set("cursorVertex",s),this.segmentLabels?.set("stagedVertex",null!=s?this.coordinateHelper.pointToVector(s):null),null==s||"mouse"!==this._stagedPointerType?this.emit("cursor-remove"):this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(s)}],operation:"apply",type:"vertex-update"}))}_snapToClosingVertex(t){if(null==t||this._isDragging||"polygon"!==this.geometryType||this.numCommittedVertices<=2)return t;const e=this._mapToScreen(t);if(!e)return t;const i=this._activeComponent;return this._vertexWithinPointerDistance(i.vertices[0].pos,e)?this.firstVertex:this._vertexWithinPointerDistance(i.vertices.at(-1).pos,e)?this.lastVertex:t}_createManipulatorDragPipeline(t){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return T(t,((t,e,i,n)=>{const o="touch"===n&&this._snappingEnabled;if(this.isCompleted||!o)return;const{snappingStep:r,cancelSnapping:s}=G({predicate:()=>o,snappingManager:this.snappingManager,snappingContext:new j({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer,drawConstraints:this.constraints}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((t=>(o&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),t))).next(s),e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._processCursor(t.mapStart),("segment"===this.geometryType||o&&!this.numCommittedVertices)&&this.commitStagedVertex()),t))).next(S(this.view,this.elevationInfo)).next(...r).next((t=>(o&&(this._processCursor(t.mapEnd),"end"===t.action&&this.commitStagedVertex()),t))).next((t=>("end"===t.action&&("mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t)))}))}_createManipulatorDragPipelineFreehand(t){return T(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._snappingOperation.abort(),null==this.committableVertex&&this._processCursor(t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t}))}))}_createManipulatorDragPipelineHybrid(t){return T(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._snappingOperation.abort(),this.addHandles(this._editGeometryOperations.createUndoGroup(),z),this._processCursor(t.mapStart),this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),this.removeHandles(z),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t}))}))}get _drawAtFixedElevation(){const{constraintsEnabled:t,constraintZ:e,geometryType:i,numCommittedVertices:n}=this;return t?null!=e||"segment"===i&&n>0:("segment"===i||"polygon"===i)&&n>0}_updateAndGetEffectiveDrawSurface(){const{constraintsEnabled:t,coordinateHelper:e,drawSurface:i,elevationDrawSurface:n,snapToSceneEnabled:o}=this;if(null==n)return i;if(!this.hasZ)return n.defaultZ=null,n;const r=this.elevationInfo?.mode;let s=this.defaultZ,a=t||"absolute-height"===r;if(null!=o&&(a=o),"on-the-ground"===r&&(a=!1),this._drawAtFixedElevation){s=(t?this.constraintZ:null)??e.getZ(this._activeComponent.vertices[0].pos),a=!1}return a?i:(n.defaultZ=s,n)}_mapToScreen(t){return this._updateAndGetEffectiveDrawSurface()?.mapToScreen(t)}_onHold(t){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&this._processCursor(t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if(!("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging))try{const{drawingMode:e,geometryType:i}=this;this._stagedPointerType=t.pointerType,this._stagedScreenPoint=t.screenPoint;const n=this._screenToMap(t.screenPoint);if(null==n)return;if(null==n||"freehand"===e&&"point"!==i&&"multipoint"!==i)return;if(this._snappingEnabled&&null!=this.cursorVertex||this._processCursor(n),null==this.committableVertex)return void this.complete();this.commitStagedVertex(),"mouse"!==t.pointerType&&this._processCursor(null),("freehand"===e&&"multipoint"!==this.geometryType||"point"===i||"segment"===i&&2===this.numCommittedVertices||"segment"===i&&"hybrid"===e&&1===this.numCommittedVertices)&&this.complete()}finally{t.stopPropagation()}}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){const e=d(t.x,t.y);this._stagedScreenPoint=e,this._stagedPointerType=t.pointerType,this._stagedPointerId=t.pointerId,this._isDragging?this._snappingOperation.abort():(t.stopPropagation(),this._processCursorMovementRelativeToSurface(e,t.pointerType))}_onKeyboardBasedChange(){"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._isDragging?this._processCursorMovementRelativeToSurface(this._stagedScreenPoint,this._stagedPointerType):this._snappingOperation.abort()}_processCursorMovementRelativeToSurface(t,e){const i=this._snappingOperation,n=this._screenToMap(t),o=this._requiresScenePoint?this.drawSurface?.screenToMap(t):null;if(null==n)return this._hideDefaultCursor=!0,this._processCursor(null),void i.abort();this._hideDefaultCursor=!1;const r=this.snappingManager;if(null==r)return this._processCursor(n),void i.abort();const s=this._getSnappingContext(e);this._updatingHandles.addPromise(a(i.snap({point:n,scenePoint:o},r,s)))}_applyConstraints(t){const{_constraint:e,constraints:i}=this;if(!t||!i||!e)return t;const{context:n}=i,o=M(t,n),r=o?e.closestTo(o):void 0;if(!r)return t;const s=D(r,t,n),a="2d"===this.view.type||"absolute-height"!==n.elevationInfo.mode;return null!=s&&a&&null!=this.constraintZ&&this.hasZ&&(s.z=this.constraintZ),s}_screenToMap(t){return t?this._updateAndGetEffectiveDrawSurface()?.screenToMap(t):null}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),null==t)return null;const i=this._screenToMap(e.screenEnd);return null!=i?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return null!=n&&R(n,e,i)}_getSnappingContext(t){const e=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new j({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=e?{value:e,elevationInfo:this.elevationInfo}:null,drawConstraints:this.constraints})}};function R(t,e,i){const n=t.x-e.x,o=t.y-e.y;return n*n+o*o<=i}t([h()],F.prototype,"_hideDefaultCursor",void 0),t([h()],F.prototype,"_stagedPointerId",void 0),t([h()],F.prototype,"_isDragging",null),t([h()],F.prototype,"_snappingOperation",void 0),t([h()],F.prototype,"_snappingEnabled",null),t([h({constructOnly:!0})],F.prototype,"graphic",void 0),t([h()],F.prototype,"constraintsEnabled",void 0),t([h()],F.prototype,"constraints",void 0),t([h()],F.prototype,"_constraint",null),t([h()],F.prototype,"constraintZ",void 0),t([h()],F.prototype,"defaultZ",void 0),t([h()],F.prototype,"isDraped",void 0),t([h({constructOnly:!0})],F.prototype,"automaticLengthMeasurementUtils",void 0),t([h({value:x})],F.prototype,"drawingMode",null),t([h({constructOnly:!0})],F.prototype,"elevationDrawSurface",void 0),t([h({constructOnly:!0})],F.prototype,"elevationInfo",void 0),t([h({constructOnly:!0,type:H})],F.prototype,"labelOptions",void 0),t([h({constructOnly:!0})],F.prototype,"geometryType",void 0),t([h({constructOnly:!0})],F.prototype,"hasM",void 0),t([h({constructOnly:!0})],F.prototype,"hasZ",void 0),t([h()],F.prototype,"cursor",void 0),t([h()],F.prototype,"effectiveCursor",null),t([h()],F.prototype,"loading",void 0),t([h({constructOnly:!0})],F.prototype,"manipulators",void 0),t([h({constructOnly:!0})],F.prototype,"drawSurface",void 0),t([h({constructOnly:!0})],F.prototype,"segmentLabels",void 0),t([h({constructOnly:!0})],F.prototype,"snappingManager",void 0),t([h({constructOnly:!0})],F.prototype,"snappingVisualizer",void 0),t([h()],F.prototype,"snapToSceneEnabled",void 0),t([h({readOnly:!0})],F.prototype,"cursorVertex",null),t([h({readOnly:!0})],F.prototype,"visualizationCursorVertex",null),t([h()],F.prototype,"committableVertex",null),t([h()],F.prototype,"firstVertex",void 0),t([h()],F.prototype,"lastVertex",void 0),t([h()],F.prototype,"secondToLastVertex",void 0),t([h()],F.prototype,"updating",null),t([h({constructOnly:!0})],F.prototype,"view",void 0),F=t([u("esri.views.draw.DrawOperation")],F);export{F as DrawOperation,L as defaultCursor,U as defaultLoadingCursor};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{equalsMaybe as o,destroyMaybe as r}from"../../core/maybe.js";import{memoize as s}from"../../core/memoize.js";import{ignoreAbortErrors as a}from"../../core/promiseUtils.js";import p from"../../core/ReactiveSet.js";import{watch as c,syncAndInitial as l}from"../../core/reactiveUtils.js";import{createScreenPoint as d}from"../../core/screenUtils.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import{diff as m}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as y,pointNear as _}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as v}from"../../support/elevationInfoUtils.js";import{ViewingMode as f}from"../ViewingMode.js";import{defaultDrawingMode as x}from"./DrawingMode.js";import{DrawManipulator as C}from"./DrawManipulator.js";import{createCoordinateHelper as b}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as T,sceneSnappingAtLocation as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as P,Component as V}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as w}from"../interactive/editGeometry/EditGeometryOperations.js";import{isPoint as O}from"../interactive/sketch/constraints.js";import{getPointConstraint as M,getPolylineOrPolygonConstraint as D,pointToConstraintSpace as E,constraintSpaceToPoint as I}from"../interactive/sketch/constraintUtils.js";import H from"../interactive/sketch/SketchLabelOptions.js";import{SnappingContext as j}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as G}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as k}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as Z}from"../interactive/snapping/snappingUtils.js";const L="crosshair",U="progress",A=Symbol(),z=Symbol();let F=class extends(i.EventedMixin(e)){constructor(t){super(t),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new p,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new g,this._stagedPointerId=null,this.constraintsEnabled=!1,this.constraints=void 0,this._getPointConstraint=s(M),this._getPolylineOrPolygonConstraint=s(D),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new H,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.firstVertex=null,this.lastVertex=null,this.secondToLastVertex=null,null==t.elevationInfo&&(this.elevationInfo=v(!!t.hasZ))}initialize(){const{geometryType:t,view:e}=this,i=e.spatialReference,n="viewingMode"in e.state?e.state.viewingMode:f.Local,r="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=b(this.hasZ,this.hasM,i),this._editGeometryOperations=new w(new P(r,this.coordinateHelper),n),this._snappingOperation=new k({view:e}),this.addHandles([c((()=>({stagedPoint:this._snappingOperation.stagedPoint,constraint:this._constraint})),(({stagedPoint:t,constraint:e},i)=>{const{snappingOptions:n}=this;n&&(n.forceDisabled=null!=e&&O(e));if(null!=i&&t===i.stagedPoint&&e!==i.constraint)return this._onKeyboardBasedChange();this._processCursor(t??this._screenToMap(this._stagedScreenPoint))}),{equals:(t,e)=>t.stagedPoint===e.stagedPoint&&o(t.constraint,e.constraint)}),c((()=>this.view.viewpoint),((t,e)=>{t&&e&&m(t,e)&&this._onKeyboardBasedChange()}))]),this._activeComponent=new V(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const s=this.segmentLabels;null!=s&&(s.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions,automaticLengthMeasurementUtils:this.automaticLengthMeasurementUtils},this.addHandles(c((()=>this.labelOptions.enabled),(t=>{s.visible=t}),l))),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(t=>{const e=t.vertices.map((t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)}))),i=e.map((t=>t.coordinates)),n=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.getFirstVertex()?.pos)??null;y(n,this.firstVertex)||(this.firstVertex=n);const o=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.getLastVertex()?.pos)??null;y(o,this.lastVertex)||(this.lastVertex=o);const r=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.edges.at(-1)?.leftVertex?.pos)??null;switch(y(r,this.secondToLastVertex)||(this.secondToLastVertex=r),this._processCursor(this.cursorVertex),t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}})));const p=this._manipulator=new C({consumesClicks:!1,grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(p),p.grabbable="point"!==t&&"multipoint"!==t,this.addHandles([p.events.on("immediate-click",(t=>this._onImmediateClick(t))),p.events.on("immediate-double-click",(t=>this._onImmediateDoubleClick(t))),c((()=>this.drawingMode),(()=>{this.removeHandles(A),this.addHandles(this._createManipulatorDragPipeline(p),A)}),l),c((()=>({effectiveCursor:this.effectiveCursor})),(({effectiveCursor:t})=>{p.cursor=t}),l)]),Z(this,(()=>{const t=this.view.inputManager.latestPointerType??"mouse",e=this._getSnappingContext(t);if(null!=this.snappingManager){const t=this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,e);this._updatingHandles.addPromise(a(t))}}))}destroy(){r(this.segmentLabels),r(this._snappingOperation),this._editGeometryOperations=r(this._editGeometryOperations),this._updatingHandles.destroy()}get _isDragging(){const{_stagedPointerId:t,_manipulator:e}=this;return null!=t&&this._pointerDownStates.has(t)||e.grabbing||!e.interactive}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const t=this._updateAndGetEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==t}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((t=>this.coordinateHelper.vectorToArray(t.pos)))}get _constraint(){const{constraints:t,constraintsEnabled:e}=this;if(t&&e)switch(this.geometryType){case"point":case"multipoint":return this._getPointConstraint(t);case"polygon":case"polyline":return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,t)}}set drawingMode(t){this._set("drawingMode",t??x)}get effectiveCursor(){return this.loading?U:this._hideDefaultCursor?null:this.cursor||L}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get cursorVertex(){return this._get("cursorVertex")}get visualizationCursorVertex(){return"mouse"===this._stagedPointerType?this.cursorVertex:null}get committableVertex(){const{cursorVertex:t,lastVertex:e,firstVertex:i,geometryType:n}=this;return"polygon"===n&&_(t,i)||_(t,e)?null:t}get updating(){return this._updatingHandles.updating}get geometryIncludingUncommittedVertices(){const{committedVertices:t,committableVertex:e,coordinateHelper:i}=this,n=t.slice();return null!=e&&n.push(i.pointToArray(e)),n}cancel(){this.complete({aborted:!0})}commitStagedVertex(){this._snappingOperation.abort();const{committableVertex:t}=this;null!=t&&this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t))}complete(t){const e=t?.aborted||!1;this._snappingOperation.abort(),this.snappingManager?.doneSnapping();const{geometryType:i,numCommittedVertices:n}=this,o="multipoint"===i&&0===n||"polyline"===i&&n<2||"polygon"===i&&n<3;"segment"!==i&&"point"!==i||this.commitStagedVertex(),this._createOperationCompleted=!o,(this.isCompleted||e)&&(this._stagedScreenPoint=null,this._stagedPointerId=null,this._stagedPointerType=null,this._processCursor(null),this.emit("complete",{vertices:this.committedVertices.map(((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t}))),aborted:e,type:"complete"}))}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_processCursor(t){const e=n(this.cursorVertex),i=n(t),o=i&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(i)??i),r=this._snapToClosingVertex(o),s=this._applyConstraints(r);_(e,s)||(this._set("cursorVertex",s),this.segmentLabels?.set("stagedVertex",null!=s?this.coordinateHelper.pointToVector(s):null),null==s||"mouse"!==this._stagedPointerType?this.emit("cursor-remove"):this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(s)}],operation:"apply",type:"vertex-update"}))}_snapToClosingVertex(t){if(null==t||this._isDragging||"polygon"!==this.geometryType||this.numCommittedVertices<=2)return t;const e=this._mapToScreen(t);if(!e)return t;const i=this._activeComponent;return this._vertexWithinPointerDistance(i.vertices[0].pos,e)?this.firstVertex:this._vertexWithinPointerDistance(i.vertices.at(-1).pos,e)?this.lastVertex:t}_createManipulatorDragPipeline(t){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return T(t,((t,e,i,n)=>{const o="touch"===n&&this._snappingEnabled;if(this.isCompleted||!o)return;const{snappingStep:r,cancelSnapping:s}=G({predicate:()=>o,snappingManager:this.snappingManager,snappingContext:new j({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer,drawConstraints:this.constraints}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((t=>(o&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),t))).next(s),e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._processCursor(t.mapStart),("segment"===this.geometryType||o&&!this.numCommittedVertices)&&this.commitStagedVertex()),t))).next(S(this.view,this.elevationInfo)).next(...r).next((t=>(o&&(this._processCursor(t.mapEnd),"end"===t.action&&this.commitStagedVertex()),t))).next((t=>("end"===t.action&&("mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t)))}))}_createManipulatorDragPipelineFreehand(t){return T(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._snappingOperation.abort(),null==this.committableVertex&&this._processCursor(t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t}))}))}_createManipulatorDragPipelineHybrid(t){return T(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._snappingOperation.abort(),this.addHandles(this._editGeometryOperations.createUndoGroup(),z),this._processCursor(t.mapStart),this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),this.removeHandles(z),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t}))}))}get _drawAtFixedElevation(){const{constraintsEnabled:t,constraintZ:e,geometryType:i,numCommittedVertices:n}=this;return t?null!=e||"segment"===i&&n>0:("segment"===i||"polygon"===i)&&n>0}_updateAndGetEffectiveDrawSurface(){const{constraintsEnabled:t,coordinateHelper:e,drawSurface:i,elevationDrawSurface:n,snapToSceneEnabled:o}=this;if(null==n)return i;if(!this.hasZ)return n.defaultZ=null,n;const r=this.elevationInfo?.mode;let s=this.defaultZ,a=t||"absolute-height"===r;if(null!=o&&(a=o),"on-the-ground"===r&&(a=!1),this._drawAtFixedElevation){s=(t?this.constraintZ:null)??e.getZ(this._activeComponent.vertices[0].pos),a=!1}return a?i:(n.defaultZ=s,n)}_mapToScreen(t){return this._updateAndGetEffectiveDrawSurface()?.mapToScreen(t)}_onHold(t){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&this._processCursor(t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if(!("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging))try{const{drawingMode:e,geometryType:i}=this;this._stagedPointerType=t.pointerType,this._stagedScreenPoint=t.screenPoint;const n=this._screenToMap(t.screenPoint);if(null==n)return;if(null==n||"freehand"===e&&"point"!==i&&"multipoint"!==i)return;if(this._snappingEnabled&&null!=this.cursorVertex||this._processCursor(n),null==this.committableVertex)return void this.complete();this.commitStagedVertex(),"mouse"!==t.pointerType&&this._processCursor(null),("freehand"===e&&"multipoint"!==this.geometryType||"point"===i||"segment"===i&&2===this.numCommittedVertices||"segment"===i&&"hybrid"===e&&1===this.numCommittedVertices)&&this.complete()}finally{t.stopPropagation()}}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){const e=d(t.x,t.y);this._stagedScreenPoint=e,this._stagedPointerType=t.pointerType,this._stagedPointerId=t.pointerId,this._isDragging?this._snappingOperation.abort():(t.stopPropagation(),this._processCursorMovementRelativeToSurface(e,t.pointerType))}_onKeyboardBasedChange(){"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._isDragging?this._processCursorMovementRelativeToSurface(this._stagedScreenPoint,this._stagedPointerType):this._snappingOperation.abort()}_processCursorMovementRelativeToSurface(t,e){const i=this._snappingOperation,n=this._screenToMap(t),o=this._requiresScenePoint?this.drawSurface?.screenToMap(t):null;if(null==n)return this._hideDefaultCursor=!0,this._processCursor(null),void i.abort();this._hideDefaultCursor=!1;const r=this.snappingManager;if(null==r)return this._processCursor(n),void i.abort();const s=this._getSnappingContext(e);this._updatingHandles.addPromise(a(i.snap({point:n,scenePoint:o},r,s)))}_applyConstraints(t){const{_constraint:e,constraints:i}=this;if(!t||!i||!e)return t;const{context:n}=i,o=E(t,n),r=o?e.closestTo(o):void 0;if(!r)return t;const s=I(r,t,n),a="2d"===this.view.type||"absolute-height"!==n.elevationInfo.mode;return null!=s&&a&&null!=this.constraintZ&&this.hasZ&&(s.z=this.constraintZ),s}_screenToMap(t){return t?this._updateAndGetEffectiveDrawSurface()?.screenToMap(t):null}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),null==t)return null;const i=this._screenToMap(e.screenEnd);return null!=i?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return null!=n&&R(n,e,i)}_getSnappingContext(t){const e=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new j({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=e?{value:e,elevationInfo:this.elevationInfo}:null,drawConstraints:this.constraints})}};function R(t,e,i){const n=t.x-e.x,o=t.y-e.y;return n*n+o*o<=i}t([h()],F.prototype,"_hideDefaultCursor",void 0),t([h()],F.prototype,"_stagedPointerId",void 0),t([h()],F.prototype,"_isDragging",null),t([h()],F.prototype,"_snappingOperation",void 0),t([h()],F.prototype,"_snappingEnabled",null),t([h({constructOnly:!0})],F.prototype,"graphic",void 0),t([h()],F.prototype,"constraintsEnabled",void 0),t([h()],F.prototype,"constraints",void 0),t([h()],F.prototype,"_constraint",null),t([h()],F.prototype,"constraintZ",void 0),t([h()],F.prototype,"defaultZ",void 0),t([h()],F.prototype,"isDraped",void 0),t([h({constructOnly:!0})],F.prototype,"automaticLengthMeasurementUtils",void 0),t([h({value:x})],F.prototype,"drawingMode",null),t([h({constructOnly:!0})],F.prototype,"elevationDrawSurface",void 0),t([h({constructOnly:!0})],F.prototype,"elevationInfo",void 0),t([h({constructOnly:!0,type:H})],F.prototype,"labelOptions",void 0),t([h({constructOnly:!0})],F.prototype,"geometryType",void 0),t([h({constructOnly:!0})],F.prototype,"hasM",void 0),t([h({constructOnly:!0})],F.prototype,"hasZ",void 0),t([h()],F.prototype,"cursor",void 0),t([h()],F.prototype,"effectiveCursor",null),t([h()],F.prototype,"loading",void 0),t([h({constructOnly:!0})],F.prototype,"manipulators",void 0),t([h({constructOnly:!0})],F.prototype,"drawSurface",void 0),t([h({constructOnly:!0})],F.prototype,"segmentLabels",void 0),t([h({constructOnly:!0})],F.prototype,"snappingManager",void 0),t([h({constructOnly:!0})],F.prototype,"snappingVisualizer",void 0),t([h()],F.prototype,"snapToSceneEnabled",void 0),t([h({readOnly:!0})],F.prototype,"cursorVertex",null),t([h({readOnly:!0})],F.prototype,"visualizationCursorVertex",null),t([h()],F.prototype,"committableVertex",null),t([h()],F.prototype,"firstVertex",void 0),t([h()],F.prototype,"lastVertex",void 0),t([h()],F.prototype,"secondToLastVertex",void 0),t([h()],F.prototype,"updating",null),t([h({constructOnly:!0})],F.prototype,"view",void 0),F=t([u("esri.views.draw.DrawOperation")],F);export{F as DrawOperation,L as defaultCursor,U as defaultLoadingCursor};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as i}from"../../../chunks/tslib.es6.js";import t from"../../../core/Evented.js";import{clone as e}from"../../../core/lang.js";import{watch as s,when as r}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import o from"../../../layers/GraphicsLayer.js";import c from"../../../symbols/SimpleFillSymbol.js";import n from"../../../symbols/SimpleLineSymbol.js";import l from"../../../symbols/SimpleMarkerSymbol.js";import{cloneMove as p}from"./drawUtils.js";import d from"./HighlightHelper.js";import{addUniqueLayer as g,findLayerView as v}from"./layerUtils.js";import{GraphicClickEvent as m,GraphicDoubleClickEvent as _,GraphicPointerDownEvent as y,GraphicPointerUpEvent as u,GraphicPointerOutEvent as f,GraphicPointerOverEvent as G,GraphicMoveStartEvent as w,GraphicMoveEvent as b,GraphicMoveStopEvent as k}from"./input/GraphicMoverEvents.js";import{ViewEventPriorities as O}from"../../input/InputManager.js";import{GraphicManipulator as x}from"../../interactive/GraphicManipulator.js";import{createScreenPointFromEvent as H}from"../../support/screenUtils.js";const M="indicator-symbols";let E=class extends t.EventedAccessor{constructor(i){super(i),this._activeGraphic=null,this._dragEvent=null,this._hoverGraphic=null,this._indicators=[],this._initialDragGeometry=null,this._manipulators=[],this._layerViews=null,this.type="graphic-mover",this.callbacks={onGraphicClick(){},onGraphicDoubleClick(){},onGraphicMoveStart(){},onGraphicMove(){},onGraphicMoveStop(){},onGraphicPointerOver(){},onGraphicPointerOut(){},onGraphicPointerDown(){},onGraphicPointerUp(){}},this.enableMoveAllGraphics=!1,this.graphics=[],this.highlightName=null,this.highlightsEnabled=!1,this.indicatorsEnabled=!1,this._defaultLayer=new o({listMode:"hide",internal:!0,title:"GraphicMover highlight layer"}),this.layer=this._defaultLayer,this.view=null}initialize(){g(this.view,this.layer),this._highlightHelper=new d({view:this.view}),this.refresh(),this.addHandles([s((()=>this.graphics.length),(()=>this.refresh())),r((()=>this.view?.ready),(()=>{this.addHandles([this.view.on("immediate-click",(i=>this._clickHandler(i)),O.TOOL),this.view.on("double-click",(i=>this._doubleClickHandler(i)),O.TOOL),this.view.on("pointer-down",(i=>this._pointerDownHandler(i)),O.TOOL),this.view.on("pointer-move",(i=>this._pointerMoveHandler(i)),O.TOOL),this.view.on("pointer-up",(i=>this._pointerUpHandler(i)),O.TOOL),this.view.on("drag",(i=>this._dragHandler(i)),O.TOOL),this.view.on("key-down",(i=>this._keyDownHandler(i)),O.TOOL)])}),{once:!0,initial:!0}),s((()=>this.view),(i=>{this._highlightHelper.removeAll(),this._highlightHelper.view=i})),s((()=>[this.highlightsEnabled,this.highlightName]),(()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}))])}destroy(){this._removeIndicators(),this.view.map?.remove(this.layer),this._defaultLayer.destroy(),this.reset(),this._manipulators.forEach((i=>i.destroy())),this._manipulators=null}get state(){const i=this.view.ready,t=this.graphics.length>0,e=this._activeGraphic;return i&&t?e?"moving":"active":i?"ready":"disabled"}refresh(){this.reset(),this._setup()}reset(){this._activeGraphic=null,this._hoverGraphic=null,this._dragEvent=null,this._highlightHelper.removeAll()}updateGeometry(i,t){const e=this.graphics[i];e&&(e.set("geometry",t),this._setUpIndicators())}_setup(){this._setUpHighlights(),this._setUpIndicators(),this._setUpManipulators(),this._syncLayerViews()}_clickHandler(i){const t=this._findTargetGraphic(H(i));if(t){const e=new m(t,this.graphics.indexOf(t),i.x,i.y,i);this.emit("graphic-click",e),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(e)}}_doubleClickHandler(i){const t=this._findTargetGraphic(H(i));if(t){const e=new _(t,this.graphics.indexOf(t),i.x,i.y,i);this.emit("graphic-double-click",e),this.callbacks.onGraphicDoubleClick&&this.callbacks.onGraphicDoubleClick(e)}}_pointerDownHandler(i){const t=this._findTargetGraphic(H(i));if(t){this._activeGraphic=t;const{x:e,y:s}=i,r=new y(t,this.graphics.indexOf(t),e,s,i);this.emit("graphic-pointer-down",r),this.callbacks.onGraphicPointerDown&&this.callbacks.onGraphicPointerDown(r)}else this._activeGraphic=null}_pointerUpHandler(i){if(this._activeGraphic){const{x:t,y:e}=i,s=this.graphics.indexOf(this._activeGraphic),r=new u(this._activeGraphic,s,t,e,i);this.emit("graphic-pointer-up",r),this.callbacks.onGraphicPointerUp&&this.callbacks.onGraphicPointerUp(r)}}_pointerMoveHandler(i){if(this._dragEvent)return;const t=this._findTargetGraphic(H(i));if(t){const{x:e,y:s}=i;if(this._hoverGraphic){if(this._hoverGraphic===t)return;const r=this.graphics.indexOf(this._hoverGraphic),h=new f(this.graphics[r],r,e,s,i);this._hoverGraphic=null,this.emit("graphic-pointer-out",h),this.callbacks.onGraphicPointerOut&&this.callbacks.onGraphicPointerOut(h)}const r=this.graphics.indexOf(t),h=new G(t,r,e,s,i);return this._hoverGraphic=t,this.emit("graphic-pointer-over",h),void(this.callbacks.onGraphicPointerOver&&this.callbacks.onGraphicPointerOver(h))}if(this._hoverGraphic){const{x:t,y:e}=i,s=this.graphics.indexOf(this._hoverGraphic),r=new f(this.graphics[s],s,t,e,i);this._hoverGraphic=null,this.emit("graphic-pointer-out",r),this.callbacks.onGraphicPointerOut&&this.callbacks.onGraphicPointerOut(r)}}_dragHandler(i){if("start"!==i.action&&!this._dragEvent||!this._activeGraphic?.geometry)return;"start"===i.action&&this._removeIndicators(),i.stopPropagation();const{action:t,x:s,y:r}=i,h=this.graphics.indexOf(this._activeGraphic),a=this._dragEvent?s-this._dragEvent.x:0,o=this._dragEvent?r-this._dragEvent.y:0,c=s-i.origin.x,n=r-i.origin.y,l="start"===t?this._activeGraphic.geometry:this._initialDragGeometry,d=p(l,c,n,this.view);if(this._activeGraphic.geometry=d,this.enableMoveAllGraphics&&this.graphics.forEach((i=>{i!==this._activeGraphic&&(i.geometry=p(i.geometry,a,o,this.view))})),this._dragEvent=i,"start"===t){this._initialDragGeometry=e(l);const t=new w(this._activeGraphic,this.graphics,h,s,r,a,o,c,n,i);this.emit("graphic-move-start",t),this.callbacks.onGraphicMoveStart&&this.callbacks.onGraphicMoveStart(t),t.defaultPrevented&&this._activeGraphic.set("geometry",l)}else if("update"===t){const t=new b(this._activeGraphic,this.graphics,h,s,r,a,o,c,n,i);this.emit("graphic-move",t),this.callbacks.onGraphicMove&&this.callbacks.onGraphicMove(t),t.defaultPrevented&&(this._activeGraphic.geometry=l)}else{const t=new k(this._activeGraphic,this.graphics,h,s,r,a,o,c,n,i);this._dragEvent=null,this._activeGraphic=null,this._setUpIndicators(),this.emit("graphic-move-stop",t),this.callbacks.onGraphicMoveStop&&this.callbacks.onGraphicMoveStop(t),t.defaultPrevented&&(this.graphics[h].set("geometry",this._initialDragGeometry),this._setUpIndicators()),this._initialDragGeometry=null}}_keyDownHandler(i){"a"!==i.key&&"d"!==i.key&&"n"!==i.key||"moving"!==this.state||i.stopPropagation()}_findTargetGraphic(i){const t=this.view.toMap(i),e=this.graphics;let s=null,r=Number.MAX_VALUE;this._syncLayerViews();const h=this._layerViews.flatMap((i=>"graphicsViews"in i?Array.from(i.graphicsViews(),(i=>i.hitTest(t))).flat():i.graphicsView.hitTest(t))).filter((i=>e.includes(i))).sort(((i,t)=>e.indexOf(i)-e.indexOf(t)));return h.length?h[0]:(this._manipulators.forEach((t=>{const e=t.intersectionDistance(i);null!=e&&e<r&&(r=e,s=t.graphic)})),s)}_syncLayerViews(){this._layerViews=[];const i=new Set;for(const t of this.graphics){const e=v(this.view,t.layer);e&&i.add(e)}this._layerViews=[...i]}_setUpManipulators(){const{graphics:i,view:t}=this;this._manipulators.forEach((i=>i.destroy())),this._manipulators=i.length?i.map((i=>new x({graphic:i,view:t}))):[]}_setUpHighlights(){this.highlightsEnabled&&this.graphics.length&&this._highlightHelper.add(this.graphics,this.highlightName)}_setUpIndicators(){if(this._removeIndicators(),this.indicatorsEnabled){for(const i of this.graphics){const t=i.clone();t.symbol=U(i),this._indicators.push(t),this.addHandles(s((()=>i.symbol),(()=>this._setUpIndicators())),M)}this.layer.addMany(this._indicators)}}_removeIndicators(){this.removeHandles(M),this._indicators.length&&(this.layer.removeMany(this._indicators),this._indicators.forEach((i=>i.destroy())),this._indicators=[])}};function U(i){const t=12;if(null==i.symbol)return null;switch(i.symbol.type){case"cim":return new l({style:"circle",size:t,color:[0,0,0,0],outline:{color:[255,127,0,1],width:1}});case"picture-marker":{const{xoffset:t,yoffset:e,height:s,width:r}=i.symbol,h=s===r?r:Math.max(s,r);return new l({xoffset:t,yoffset:e,size:h,style:"square",color:[0,0,0,0],outline:{color:[255,127,0,1],width:1}})}case"simple-marker":{const{xoffset:t,yoffset:e,size:s,style:r}=i.symbol;return new l({xoffset:t,yoffset:e,style:"circle"===r?"circle":"square",size:s+2,color:[0,0,0,0],outline:{color:[255,127,0,1],width:1}})}case"simple-fill":return new c({color:[0,0,0,0],outline:{style:"dash",color:[255,127,0,1],width:1}});case"simple-line":return new n({color:[255,127,0,1],style:"dash",width:1});case"text":{const{xoffset:e,yoffset:s}=i.symbol;return new l({xoffset:e,yoffset:s,size:t,color:[0,0,0,0],outline:{color:[255,127,0,1],width:1}})}default:return null}}i([h()],E.prototype,"_activeGraphic",void 0),i([h({readOnly:!0})],E.prototype,"type",void 0),i([h()],E.prototype,"callbacks",void 0),i([h()],E.prototype,"enableMoveAllGraphics",void 0),i([h()],E.prototype,"graphics",void 0),i([h()],E.prototype,"highlightName",void 0),i([h()],E.prototype,"highlightsEnabled",void 0),i([h()],E.prototype,"indicatorsEnabled",void 0),i([h()],E.prototype,"_defaultLayer",void 0),i([h()],E.prototype,"layer",void 0),i([h({readOnly:!0})],E.prototype,"state",null),i([h()],E.prototype,"view",void 0),E=i([a("esri.views.draw.support.GraphicMover")],E);export{E as default};
5
+ import{_ as i}from"../../../chunks/tslib.es6.js";import t from"../../../core/Evented.js";import{clone as e}from"../../../core/lang.js";import{watch as s,when as r}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import o from"../../../layers/GraphicsLayer.js";import c from"../../../symbols/SimpleFillSymbol.js";import n from"../../../symbols/SimpleLineSymbol.js";import l from"../../../symbols/SimpleMarkerSymbol.js";import{cloneMove as p}from"./drawUtils.js";import d from"./HighlightHelper.js";import{addUniqueLayer as g,findLayerView as v}from"./layerUtils.js";import{GraphicClickEvent as m,GraphicDoubleClickEvent as _,GraphicPointerDownEvent as y,GraphicPointerUpEvent as u,GraphicPointerOutEvent as f,GraphicPointerOverEvent as G,GraphicMoveStartEvent as w,GraphicMoveEvent as b,GraphicMoveStopEvent as k}from"./input/GraphicMoverEvents.js";import{ViewEventPriorities as O}from"../../input/InputManager.js";import{GraphicManipulator as x}from"../../interactive/GraphicManipulator.js";import{createScreenPointFromEvent as H}from"../../support/screenUtils.js";const M="indicator-symbols";let E=class extends t.EventedAccessor{constructor(i){super(i),this._activeGraphic=null,this._dragEvent=null,this._hoverGraphic=null,this._indicators=[],this._initialDragGeometry=null,this._manipulators=[],this._layerViews=null,this.type="graphic-mover",this.callbacks={onGraphicClick(){},onGraphicDoubleClick(){},onGraphicMoveStart(){},onGraphicMove(){},onGraphicMoveStop(){},onGraphicPointerOver(){},onGraphicPointerOut(){},onGraphicPointerDown(){},onGraphicPointerUp(){}},this.enableMoveAllGraphics=!1,this.graphics=[],this.highlightName=null,this.highlightsEnabled=!1,this.indicatorsEnabled=!1,this._defaultLayer=new o({listMode:"hide",internal:!0,title:"GraphicMover highlight layer"}),this.layer=this._defaultLayer,this.view=null}initialize(){g(this.view,this.layer),this._highlightHelper=new d({view:this.view}),this.refresh(),this.addHandles([s((()=>this.graphics.length),(()=>this.refresh())),r((()=>this.view?.ready),(()=>{this.addHandles([this.view.on("immediate-click",(i=>this._clickHandler(i)),O.TOOL),this.view.on("double-click",(i=>this._doubleClickHandler(i)),O.TOOL),this.view.on("pointer-down",(i=>this._pointerDownHandler(i)),O.TOOL),this.view.on("pointer-move",(i=>this._pointerMoveHandler(i)),O.TOOL),this.view.on("pointer-up",(i=>this._pointerUpHandler(i)),O.TOOL),this.view.on("drag",(i=>this._dragHandler(i)),O.TOOL),this.view.on("key-down",(i=>this._keyDownHandler(i)),O.TOOL)])}),{once:!0,initial:!0}),s((()=>this.view),(i=>{this._highlightHelper.removeAll(),this._highlightHelper.view=i})),s((()=>[this.highlightsEnabled,this.highlightName]),(()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}))])}destroy(){this._removeIndicators(),this.view.map?.remove(this.layer),this._defaultLayer.destroy(),this.reset(),this._manipulators.forEach((i=>i.destroy())),this._manipulators=null}get state(){const i=this.view.ready,t=this.graphics.length>0,e=this._activeGraphic;return i&&t?e?"moving":"active":i?"ready":"disabled"}refresh(){this.reset(),this._setup()}reset(){this._activeGraphic=null,this._hoverGraphic=null,this._dragEvent=null,this._highlightHelper.removeAll()}updateGeometry(i,t){const e=this.graphics[i];e&&(e.set("geometry",t),this._setUpIndicators())}_setup(){this._setUpHighlights(),this._setUpIndicators(),this._setUpManipulators(),this._syncLayerViews()}_clickHandler(i){const t=this._findTargetGraphic(H(i));if(t){const e=new m(t,this.graphics.indexOf(t),i.x,i.y,i);this.emit("graphic-click",e),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(e)}}_doubleClickHandler(i){const t=this._findTargetGraphic(H(i));if(t){const e=new _(t,this.graphics.indexOf(t),i.x,i.y,i);this.emit("graphic-double-click",e),this.callbacks.onGraphicDoubleClick&&this.callbacks.onGraphicDoubleClick(e)}}_pointerDownHandler(i){const t=this._findTargetGraphic(H(i));if(t){this._activeGraphic=t;const{x:e,y:s}=i,r=new y(t,this.graphics.indexOf(t),e,s,i);this.emit("graphic-pointer-down",r),this.callbacks.onGraphicPointerDown&&this.callbacks.onGraphicPointerDown(r)}else this._activeGraphic=null}_pointerUpHandler(i){if(this._activeGraphic){const{x:t,y:e}=i,s=this.graphics.indexOf(this._activeGraphic),r=new u(this._activeGraphic,s,t,e,i);this.emit("graphic-pointer-up",r),this.callbacks.onGraphicPointerUp&&this.callbacks.onGraphicPointerUp(r)}}_pointerMoveHandler(i){if(this._dragEvent)return;const t=this._findTargetGraphic(H(i));if(t){const{x:e,y:s}=i;if(this._hoverGraphic){if(this._hoverGraphic===t)return;const r=this.graphics.indexOf(this._hoverGraphic),h=new f(this.graphics[r],r,e,s,i);this._hoverGraphic=null,this.emit("graphic-pointer-out",h),this.callbacks.onGraphicPointerOut&&this.callbacks.onGraphicPointerOut(h)}const r=this.graphics.indexOf(t),h=new G(t,r,e,s,i);return this._hoverGraphic=t,this.emit("graphic-pointer-over",h),void(this.callbacks.onGraphicPointerOver&&this.callbacks.onGraphicPointerOver(h))}if(this._hoverGraphic){const{x:t,y:e}=i,s=this.graphics.indexOf(this._hoverGraphic),r=new f(this.graphics[s],s,t,e,i);this._hoverGraphic=null,this.emit("graphic-pointer-out",r),this.callbacks.onGraphicPointerOut&&this.callbacks.onGraphicPointerOut(r)}}_dragHandler(i){if("start"!==i.action&&!this._dragEvent||!this._activeGraphic?.geometry)return;"start"===i.action&&this._removeIndicators(),i.stopPropagation();const{action:t,x:s,y:r}=i,h=this.graphics.indexOf(this._activeGraphic),a=this._dragEvent?s-this._dragEvent.x:0,o=this._dragEvent?r-this._dragEvent.y:0,c=s-i.origin.x,n=r-i.origin.y,l="start"===t?this._activeGraphic.geometry:this._initialDragGeometry,d=p(l,c,n,this.view);if(this._activeGraphic.geometry=d,this.enableMoveAllGraphics&&this.graphics.forEach((i=>{i!==this._activeGraphic&&(i.geometry=p(i.geometry,a,o,this.view))})),this._dragEvent=i,"start"===t){this._initialDragGeometry=e(l);const t=new w(this._activeGraphic,this.graphics,h,s,r,a,o,c,n,i);this.emit("graphic-move-start",t),this.callbacks.onGraphicMoveStart&&this.callbacks.onGraphicMoveStart(t),t.defaultPrevented&&this._activeGraphic.set("geometry",l)}else if("update"===t){const t=new b(this._activeGraphic,this.graphics,h,s,r,a,o,c,n,i);this.emit("graphic-move",t),this.callbacks.onGraphicMove&&this.callbacks.onGraphicMove(t),t.defaultPrevented&&(this._activeGraphic.geometry=l)}else{const t=new k(this._activeGraphic,this.graphics,h,s,r,a,o,c,n,i);this._dragEvent=null,this._activeGraphic=null,this._setUpIndicators(),this.emit("graphic-move-stop",t),this.callbacks.onGraphicMoveStop&&this.callbacks.onGraphicMoveStop(t),t.defaultPrevented&&(this.graphics[h].set("geometry",this._initialDragGeometry),this._setUpIndicators()),this._initialDragGeometry=null}}_keyDownHandler(i){"a"!==i.key&&"d"!==i.key&&"n"!==i.key||"moving"!==this.state||i.stopPropagation()}_findTargetGraphic(i){const t=this.view.toMap(i),e=this.graphics;let s=null,r=Number.MAX_VALUE;this._syncLayerViews();const h=this._layerViews.flatMap((i=>"graphicsViews"in i?Array.from(i.graphicsViews(),(i=>i.hitTest(t))).flat():i.graphicsView.hitTest(t))).filter((i=>e.includes(i))).sort(((i,t)=>e.indexOf(i)-e.indexOf(t)));return h.length?h[0]:(this._manipulators.forEach((t=>{const e=t.intersectionDistance(i);null!=e&&e<r&&(r=e,s=t.graphic)})),s)}_syncLayerViews(){this._layerViews=[];const i=new Set;for(const t of this.graphics){const e=v(this.view,t.layer);e&&i.add(e)}this._layerViews=[...i]}_setUpManipulators(){const{graphics:i,view:t}=this;this._manipulators.forEach((i=>i.destroy())),this._manipulators=i.length?i.map((i=>new x({graphic:i,view:t}))):[]}_setUpHighlights(){this.highlightsEnabled&&this.graphics.length&&this._highlightHelper.add(this.graphics,this.highlightName)}_setUpIndicators(){if(this._removeIndicators(),this.indicatorsEnabled){for(const i of this.graphics){const t=i.clone();t.symbol=U(i),this._indicators.push(t),this.addHandles(s((()=>i.symbol),(()=>this._setUpIndicators())),M)}this.layer.addMany(this._indicators)}}_removeIndicators(){this.removeHandles(M),this._indicators.length&&(this.layer.removeMany(this._indicators),this._indicators.forEach((i=>i.destroy())),this._indicators=[])}};function U(i){const t=12;if(null==i.symbol)return null;switch(i.symbol.type){case"cim":return new l({style:"circle",size:t,color:[0,0,0,0],outline:{color:[255,127,0,1],width:1}});case"picture-marker":{const{xoffset:t,yoffset:e,height:s,width:r}=i.symbol,h=s===r?r:Math.max(s,r);return new l({xoffset:t,yoffset:e,size:h,style:"square",color:[0,0,0,0],outline:{color:[255,127,0,1],width:1}})}case"simple-marker":{const{xoffset:t,yoffset:e,size:s,style:r}=i.symbol;return new l({xoffset:t,yoffset:e,style:"circle"===r?"circle":"square",size:s+2,color:[0,0,0,0],outline:{color:[255,127,0,1],width:1}})}case"simple-fill":return new c({color:[0,0,0,0],outline:{style:"dash",color:[255,127,0,1],width:1}});case"simple-line":return new n({color:[255,127,0,1],style:"dash",width:1});case"text":{const{xoffset:e,yoffset:s}=i.symbol;return new l({xoffset:e,yoffset:s,size:t,color:[0,0,0,0],outline:{color:[255,127,0,1],width:1}})}default:return null}}i([h()],E.prototype,"_activeGraphic",void 0),i([h({readOnly:!0})],E.prototype,"type",void 0),i([h()],E.prototype,"callbacks",void 0),i([h()],E.prototype,"enableMoveAllGraphics",void 0),i([h()],E.prototype,"graphics",void 0),i([h()],E.prototype,"highlightName",void 0),i([h()],E.prototype,"highlightsEnabled",void 0),i([h()],E.prototype,"indicatorsEnabled",void 0),i([h()],E.prototype,"_defaultLayer",void 0),i([h()],E.prototype,"layer",void 0),i([h({readOnly:!0})],E.prototype,"state",null),i([h()],E.prototype,"view",void 0),E=i([a("esri.views.draw.support.GraphicMover")],E);const j=E;export{j 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{findLayerView as o}from"./layerUtils.js";import{defaultHighlightName as s}from"../../support/HighlightDefaults.js";import{highlightsSupported as h}from"../../support/layerViewUtils.js";let a=class extends r{constructor(e){super(e),this._layerViewCache=new Map,this.highlightName=s,this.view=null}add(e,r){const t=!e||Array.isArray(e)?e:[e];if(!t?.length)return;const i=r??this.highlightName;t.forEach((e=>this._highlight(e,i)))}getKeyForFeature(e){const r=e.getObjectId();return null!=r?`oid:${r}`:`uid:${e.uid}`}remove(e){const r=!e||Array.isArray(e)?e:[e];r?.length&&r.forEach((e=>e&&this._removeHighlight(this.getKeyForFeature(e))))}removeByKey(e){e?.forEach((e=>e&&this._removeHighlight(e)))}removeAll(){this.removeAllHandles()}update(e,r){this.remove(e),this.add(e,r)}_highlight(e,r){const t=e.layer??e.sourceLayer;if(!t)return;const i=this._layerViewCache.get(t);if(i)return void this.addHandles(i.highlight(e,{name:r}),this.getKeyForFeature(e));const s=o(this.view,t);h(s)&&(this._layerViewCache.set(t,s),this.addHandles(s.highlight(e,{name:r}),this.getKeyForFeature(e)))}_removeHighlight(e){this.removeHandles(e)}};e([t()],a.prototype,"_layerViewCache",void 0),e([t()],a.prototype,"highlightName",void 0),e([t()],a.prototype,"view",void 0),a=e([i("esri.views.draw.support.HighlightHelper")],a);export{a as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{findLayerView as o}from"./layerUtils.js";import{defaultHighlightName as s}from"../../support/HighlightDefaults.js";import{highlightsSupported as h}from"../../support/layerViewUtils.js";let a=class extends r{constructor(e){super(e),this._layerViewCache=new Map,this.highlightName=s,this.view=null}add(e,r){const t=!e||Array.isArray(e)?e:[e];if(!t?.length)return;const i=r??this.highlightName;t.forEach((e=>this._highlight(e,i)))}getKeyForFeature(e){const r=e.getObjectId();return null!=r?`oid:${r}`:`uid:${e.uid}`}remove(e){const r=!e||Array.isArray(e)?e:[e];r?.length&&r.forEach((e=>e&&this._removeHighlight(this.getKeyForFeature(e))))}removeByKey(e){e?.forEach((e=>e&&this._removeHighlight(e)))}removeAll(){this.removeAllHandles()}update(e,r){this.remove(e),this.add(e,r)}_highlight(e,r){const t=e.layer??e.sourceLayer;if(!t)return;const i=this._layerViewCache.get(t);if(i)return void this.addHandles(i.highlight(e,{name:r}),this.getKeyForFeature(e));const s=o(this.view,t);h(s)&&(this._layerViewCache.set(t,s),this.addHandles(s.highlight(e,{name:r}),this.getKeyForFeature(e)))}_removeHighlight(e){this.removeHandles(e)}};e([t()],a.prototype,"_layerViewCache",void 0),e([t()],a.prototype,"highlightName",void 0),e([t()],a.prototype,"view",void 0),a=e([i("esri.views.draw.support.HighlightHelper")],a);const l=a;export{l 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import r from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as h,assertIsSome as a,abortMaybe as p}from"../../../core/maybe.js";import{pausable as c,when as l,watch as d,initial as m,sync as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Point.js";import u from"../../../geometry/Polyline.js";import{closeRingsAndFixWinding as f,getMidpoint as x,geometryToCoordinates as G}from"../../../geometry/support/coordsUtils.js";import M from"../../../layers/GraphicsLayer.js";import b from"../../../symbols/SimpleMarkerSymbol.js";import{ViewingMode as V}from"../../ViewingMode.js";import{SnappingVisualizer2D as w}from"../../2d/interactive/SnappingVisualizer2D.js";import{ConnectedReshapeManager as S}from"./ConnectedReshapeManager.js";import{cloneMove as E}from"./drawUtils.js";import I from"./GraphicMover.js";import O from"./HighlightHelper.js";import{addUniqueLayer as k,isConnectedReshapeSupportedLayer as C}from"./layerUtils.js";import{createTooltipInfos as T,connectTooltip as R,updateTranslateTooltipInfo as H,updateTranslateVertexTooltipInfo as j}from"./reshapeTooltipUtils.js";import{settings as A}from"./settings.js";import{ViewEventPriorities as U}from"../../input/InputManager.js";import{createCoordinateHelper as L}from"../../interactive/coordinateHelper.js";import{sketchKeys as P}from"../../interactive/keybindings.js";import{EditGeometryOperations as z}from"../../interactive/editGeometry/EditGeometryOperations.js";import D from"../../interactive/sketch/SketchOptions.js";import{SnappingContext as F}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as N,enterInputModeIfAvailable as Z}from"../../interactive/tooltip/tooltipCommonUtils.js";class X{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-start"}}class Y{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape"}}class K{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-stop"}}class q{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-start"}}class B{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move"}}class J{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-stop"}}class Q{constructor(e){this.added=e,this.type="vertex-select"}}class W{constructor(e){this.removed=e,this.type="vertex-deselect"}}class ${constructor(e,t,i,s){this.added=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class ee{constructor(e,t,i,s){this.removed=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const te=A.reshapeGraphics,ie={vertices:{default:new b({style:"circle",size:te.vertex.size,color:te.vertex.color,outline:{color:te.vertex.outlineColor,width:1}}),hover:new b({style:"circle",size:te.vertex.hoverSize,color:te.vertex.hoverColor,outline:{color:te.vertex.hoverOutlineColor,width:1}}),selected:new b({style:"circle",size:te.selected.size,color:te.selected.color,outline:{color:te.selected.outlineColor,width:1}})},midpoints:{default:new b({style:"circle",size:te.midpoint.size,color:te.midpoint.color,outline:{color:te.midpoint.outlineColor,width:1}}),hover:new b({style:"circle",size:te.midpoint.size,color:te.midpoint.color,outline:{color:te.midpoint.outlineColor,width:1}})}};let se=class extends r.EventedAccessor{constructor(e){super(e),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._connectedReshapeManager=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this.tooltip=null,this.activeTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.connectedReshapeProviders=[],this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new b({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=new s,this.snappingManager=null,this.symbols=ie,this.sketchOptions=new D,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new O({view:e}),this._setup(),this._updateHandlesOnExternalGeometryChange=c((()=>this.graphic?.geometry),(e=>{if(!e)return;const t=new Set(this.selectedVertices.map((e=>e.attributes?.pointIndex)));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter((e=>t.has(e.attributes.pointIndex))).forEach((e=>this._addToSelection(e)));const{enableMovement:i,_mover:s,graphic:o,midpointGraphics:r,vertexGraphics:n}=this,h=n.concat(r).items;i&&h.push(o),s?.set("graphics",h)}),v),this.tooltip=N((()=>({view:e,options:this.sketchOptions.tooltips}))),this.tooltipInfos=T(this.sketchOptions),this.addHandles([l((()=>e?.ready),(()=>{const{layer:e,view:t}=this;k(t,e),this.addHandles(t.on("key-down",(e=>this._keyDownHandler(e)),U.TOOL))}),{once:!0,initial:!0}),d((()=>this.graphic),(()=>this.refresh())),d((()=>this.layer),((e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()})),d((()=>[this.highlightsEnabled,this.highlightName]),(()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()})),d((()=>this.enableMidpoints),(()=>this.refresh())),R(this.tooltip,(()=>this._tooltipsContext)),d((()=>this.view.effectiveTheme.accentColor),(()=>this._updateSymbolsForTheme()),m),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._connectedReshapeManager=h(this._connectedReshapeManager),this.tooltip=h(this.tooltip)}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??L(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _selectedVertex(){return 1===this.selectedVertices.length?this.selectedVertices.at(0):void 0}get _tooltipsContext(){const{automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,sketchOptions:i,activeTooltipInfo:s,graphic:o}=this;return{sketchOptions:i,activeTooltipInfo:s,graphic:o,selectedVertex:this._selectedVertex,automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,updateGeometry:(e,t,i,s,o)=>{this._setUpGeometryHelper();const r=e===this.graphic;r?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(e);const n=!0;if(this._syncGeometryAfterVertexMove(e,t,s,o,n),r){const{view:e}=this,s=e.toScreen(i),o=e.toScreen(t),r=(o?.x??0)-(s?.x??0),n=(o?.y??0)-(s?.y??0);this._emitMoveEvent(r,n),this._emitMoveStopEvent(r,n)}else this._emitReshapeEvent(e),this._emitReshapeStopEvent(e);this._editGeometryOperations=h(this._editGeometryOperations)}}}get state(){const e=this.view.ready,t=!(!this.graphic||!this.layer);return e&&t?"active":e?"ready":"disabled"}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){const{selectedVertices:e}=this;e.length&&this._removeVertices(e)}_setup(){const{graphic:e,layer:t}=this;if(!t||null==e?.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&f(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._setupConnectedReshapeManager()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(null==e||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new u({paths:[e.points],spatialReference:e.spatialReference}):e;this._editGeometryOperations=z.fromGeometry(t,V.Local)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new M({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer);const i=this._editGeometryOperations;a(i),this._snappingContext=new F({editGeometryOperations:i,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new w(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=h(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this.selectedVertices.removeAll(),this._updateTooltip()}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach((e=>e.destroy())),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach((e=>e.destroy())),this.vertexGraphics.removeAll()}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type)){const t=oe(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];return e?.forEach(((e,r)=>{e.forEach(((e,n)=>{o.push(new t({geometry:this._coordinateHelper.arrayToPoint(e),symbol:s?.vertices?.default,attributes:{...i,pathIndex:r,pointIndex:n}}))}))})),o}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];for(let r=0;r<e.length;r++){const n=e[r];for(let e=0;e<n.length;e++){const h=(e+1)%n.length;if("polyline"===this.graphic.geometry?.type&&0===h)continue;const a=n[e],p=n[h],c=this._getMidpoint(a,p);o.push(new t({geometry:c,symbol:s.midpoints.default,attributes:{...i,pathIndex:r,pointIndexStart:e,pointIndexEnd:h}}))}}return o}_updateSymbolsForTheme(){const e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",e),hover:this.symbols.vertices.hover?.clone().set("color",e)},midpoints:{...this.symbols.midpoints}};for(const t of this.vertexGraphics)this._isSelected(t)?t.symbol=this.symbols.vertices.selected:this._hoverGraphic===t?t.symbol=this.symbols.vertices.hover:t.symbol=this.symbols.vertices.default}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map((({geometry:e})=>({x:e.x,y:e.y})));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&r.push(t),this._mover=new I({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_setupConnectedReshapeManager(){const{connectedReshapeProviders:e}=this;0!==e.length&&(this._connectedReshapeManager=new S({providerFactories:e,view:this.view}))}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick?.(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e,o=this._connectedReshapeManager,r=o?he(this.graphic):null;if(s===this.graphic){const{geometry:n}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),r&&o?.startFeatureMove([r]),void(null!=n&&"point"===n.type&&this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)})))}const{selectedVertices:n}=this;if(!n.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),r&&o?.startVertexMove(r,ae(n)),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)}))}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)}));else if("point"===n.type)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}));else if("polyline"===n.type||"polygon"===n.type){const t=oe(n);this._updateVertexGraphicLocations(t);const{dxMap:o,dyMap:r}=pe(i,s,this.view);this._connectedReshapeManager?.translate(o,r,0),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,(()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o))),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._connectedReshapeManager?.finish(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const{_coordinateHelper:t}=this;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes;i.geometry=t.arrayToPoint(e[s][o])}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,r=e[i];t.geometry=this._getMidpoint(r[s],r[o])}}_getMidpoint(e,t){const{_coordinateHelper:i}=this,s=i.arrayToVector(e),o=i.arrayToVector(t),r=i.toXYZ(s),n=i.toXYZ(o),[h,a,p]=x(r,n),c=i.hasM()?0:void 0;return new g({x:h,y:a,z:p,m:c,spatialReference:i.spatialReference})}_getVertexFromEditGeometry(e){const[t,i]=re(e);return a(this._editGeometryOperations),this._editGeometryOperations.data.components[t].vertices[i]}_onHandleMove(e,t,s,o,r){p(this._snappingTask);const n=this._snappingContext;if(!n)return;const h=e.geometry,a="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!a){const o=this.snappingManager;this._stagedVertex=o.update({point:h,context:n}),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,a),r(),this._snappingTask=i((async i=>{const p=await o.snap({point:h,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,a),r())}))}else{const i=null!=this._stagedVertex?new g(this._stagedVertex):h;this._syncGeometryAfterVertexMove(e,i,t,s,a),r()}}_syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations?.data.geometry;if(r)if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t);else{const{_coordinateHelper:n}=this,[h,a]=re(e);let p=G(r);const c=p[h].length-1,l=n.pointToArray(t);p[h][a]=l,"polygon"===r.type&&(0===a?p[h][c]=l:a===c&&(p[h][0]=l)),this._isVertex(e)&&(p=this._moveRelatedCoordinates(p,e,l),p=this._moveSelectedHandleCoordinates(p,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(p)),this._updateGraphicGeometry(r.clone());const d=n.pointToVector(t),m=this._getVertexFromEditGeometry(e),v=n.getZ(d),y=d[0]-m.pos[0],_=d[1]-m.pos[1],g=null!=v?v-m.pos[2]:0;this._editGeometryOperations?.moveVertices([m],y,_,g),this._connectedReshapeManager?.translate(y,_,g),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i){const{relatedGraphicIndices:s}=t.attributes;for(const o of s){const s=this.vertexGraphics.at(o),{pathIndex:r,pointIndex:n}=s.attributes;e[r][n]=i,s.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:h}=r.attributes,a=E(r.geometry,i,s,this.view),p=G(a),c=e[t].length-1;e[t][n]=p,r.geometry=a,o&&(0===n?e[t][c]=p:n===c&&(e[t][0]=p));for(const i of h){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=p,t.geometry=a}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._hoverGraphic=t;const i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.view.cursor="default",this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:h,pointIndexEnd:a}=e.attributes,p=G(e.geometry),c=0===a?h+1:a,l=G(o);return l[n].splice(c,0,p),e.attributes={...t,pathIndex:n,pointIndex:c,relatedGraphicIndices:[]},r.push({coordinates:l[n][c],componentIndex:n,vertexIndex:c}),this._updateGraphicGeometry(o),r}_addToSelection(e){const t=ne(e);for(const i of t)i.symbol=this.symbols.vertices.selected,this.selectedVertices.add(i),this._updateTooltip(i);this._emitSelectEvent(t)}_removeFromSelection(e,t){const{vertices:i}=this.symbols,s=t?i.hover:i.default;this.selectedVertices.remove(e),e.symbol=s,this._emitDeselectEvent([e]),this._updateTooltip()}_clearSelection(){const e=this.selectedVertices.toArray();if(e.length>0){for(const t of e)t.set("symbol",this.symbols.vertices.default);this.selectedVertices.removeAll(),this._emitDeselectEvent(e),this._updateTooltip()}}_keyDownHandler(e){null==this._activeOperationInfo&&Z(e,this.tooltip)||P.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const t=this.graphic.geometry;if(null==t||"polygon"!==t.type&&"polyline"!==t.type)return;if("polygon"===t.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;const i=this.graphic.clone(),s=t.clone();let o=G(s);const r=[],n=ne(e);for(const h of n){const{x:e,y:t}=h.geometry;for(let i=0;i<o.length;i++){const s=o[i];for(let n=0;n<s.length;n++){const[h,a]=s[n];e===h&&t===a&&(r.push({coordinates:o[i][n],componentIndex:i,vertexIndex:n}),o[i].splice(Number(n),1))}}}if("polygon"===s.type)o=o.filter((e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)})),s.rings=o;else{for(const e of o)1===e.length&&o.splice(o.indexOf(e),1);s.paths=o}this._updateGraphicGeometry(s),this.refresh(),this._emitVertexRemoveEvent(n,i,r)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){this.view.cursor=this._isMidpoint(e)?"copy":"move"}_updateTooltip(e,t){let i=null;const{graphic:s,view:o,tooltipInfos:r}=this,n=s?.geometry;"point"===n?.type?i=r.movePoint:this._selectedVertex?i=r.selectedVertex:e===this.graphic?(i=r.translateGraphic,H(i,o,this._tooltipsContext,t)):e&&this.selectedVertices.length>1&&(i=r.translateVertices,j(i,o,n,this._tooltipsContext,t)),this.activeTooltipInfo=i}_updateGraphicGeometry(e){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=e,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(e,t){const i=new q(this.graphic,e,t);this.emit("move-start",i),this.callbacks.onMoveStart?.(i)}_emitMoveEvent(e,t){const i=new B(this.graphic,e,t);this.emit("move",i),this.callbacks.onMove?.(i)}_emitMoveStopEvent(e,t){if(null==e||null==t){const i=this._activeOperationInfo;if(!i)return;e=i.totalDx,t=i.totalDy}const i=new J(this.graphic,e,t);this.emit("move-stop",i),this.callbacks.onMoveStop?.(i)}_emitReshapeStartEvent(e){const t=new X(this.graphic,e,this.selectedVertices.toArray());this.emit("reshape-start",t),this.callbacks.onReshapeStart?.(t)}_emitReshapeEvent(e){const t=new Y(this.graphic,e,this.selectedVertices.toArray());this.emit("reshape",t),this.callbacks.onReshape?.(t)}_emitReshapeStopEvent(e){const t=new K(this.graphic,e,this.selectedVertices.toArray());this.emit("reshape-stop",t),this.callbacks.onReshapeStop?.(t)}_emitSelectEvent(e){const t=new Q(e);this.emit("select",t),this.callbacks.onVertexSelect?.(t)}_emitDeselectEvent(e){const t=new W(e);this.emit("deselect",t),this.callbacks.onVertexDeselect?.(t)}_emitVertexAddEvent(e,t,i){const s=new $(e,this.graphic,t,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd?.(s)}_emitVertexRemoveEvent(e,t,i){const s=new ee(e,this.graphic,t,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove?.(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};function oe(e){const t=G(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}function re({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}function ne(e){return e instanceof t?[e]:[...e]}function he(e){const t=e.sourceLayer??e.layer;return C(t)?{graphic:e,layer:t}:null}function ae(e){return e.toArray().map((e=>({pathIndex:e.attributes.pathIndex,vertexIndex:e.attributes.pointIndex})))}function pe(e,t,i){const s=i.state.inverseTransform;return{dxMap:s[0]*e+s[2]*t,dyMap:s[1]*e+s[3]*t}}e([y()],se.prototype,"_activeOperationInfo",void 0),e([y()],se.prototype,"_connectedReshapeManager",void 0),e([y()],se.prototype,"_coordinateHelper",null),e([y()],se.prototype,"_editGeometryOperations",void 0),e([y()],se.prototype,"tooltip",void 0),e([y()],se.prototype,"tooltipInfos",void 0),e([y()],se.prototype,"activeTooltipInfo",void 0),e([y({constructOnly:!0})],se.prototype,"automaticAreaMeasurementUtils",void 0),e([y({constructOnly:!0})],se.prototype,"automaticLengthMeasurementUtils",void 0),e([y()],se.prototype,"_selectedVertex",null),e([y()],se.prototype,"_tooltipsContext",null),e([y()],se.prototype,"callbacks",void 0),e([y()],se.prototype,"connectedReshapeProviders",void 0),e([y()],se.prototype,"enableMidpoints",void 0),e([y()],se.prototype,"enableMovement",void 0),e([y()],se.prototype,"enableVertices",void 0),e([y()],se.prototype,"graphic",void 0),e([y()],se.prototype,"highlightName",void 0),e([y()],se.prototype,"highlightsEnabled",void 0),e([y()],se.prototype,"layer",void 0),e([y({readOnly:!0})],se.prototype,"midpointGraphics",void 0),e([y()],se.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],se.prototype,"selectedVertices",void 0),e([y()],se.prototype,"snappingManager",void 0),e([y({readOnly:!0})],se.prototype,"state",null),e([y()],se.prototype,"symbols",void 0),e([y({type:D})],se.prototype,"sketchOptions",void 0),e([y({readOnly:!0})],se.prototype,"type",void 0),e([y({readOnly:!0})],se.prototype,"vertexGraphics",void 0),e([y()],se.prototype,"view",void 0),se=e([_("esri.views.draw.support.Reshape")],se);const ce=se;export{ce as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import r from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as h,assertIsSome as a,abortMaybe as p}from"../../../core/maybe.js";import{pausable as c,when as l,watch as d,initial as m,sync as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Point.js";import u from"../../../geometry/Polyline.js";import{closeRingsAndFixWinding as f,getMidpoint as x,geometryToCoordinates as G}from"../../../geometry/support/coordsUtils.js";import M from"../../../layers/GraphicsLayer.js";import b from"../../../symbols/SimpleMarkerSymbol.js";import{ViewingMode as V}from"../../ViewingMode.js";import{SnappingVisualizer2D as w}from"../../2d/interactive/SnappingVisualizer2D.js";import{ConnectedReshapeManager as S}from"./ConnectedReshapeManager.js";import{cloneMove as E}from"./drawUtils.js";import I from"./GraphicMover.js";import O from"./HighlightHelper.js";import{addUniqueLayer as k,isConnectedReshapeSupportedLayer as C}from"./layerUtils.js";import{createTooltipInfos as T,connectTooltip as R,updateTranslateTooltipInfo as H,updateTranslateVertexTooltipInfo as j}from"./reshapeTooltipUtils.js";import{settings as A}from"./settings.js";import{ViewEventPriorities as U}from"../../input/InputManager.js";import{createCoordinateHelper as L}from"../../interactive/coordinateHelper.js";import{sketchKeys as P}from"../../interactive/keybindings.js";import{EditGeometryOperations as z}from"../../interactive/editGeometry/EditGeometryOperations.js";import D from"../../interactive/sketch/SketchOptions.js";import{SnappingContext as F}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as N,enterInputModeIfAvailable as Z}from"../../interactive/tooltip/tooltipCommonUtils.js";class X{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-start"}}class Y{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape"}}class K{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-stop"}}class q{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-start"}}class B{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move"}}class J{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-stop"}}class Q{constructor(e){this.added=e,this.type="vertex-select"}}class W{constructor(e){this.removed=e,this.type="vertex-deselect"}}class ${constructor(e,t,i,s){this.added=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class ee{constructor(e,t,i,s){this.removed=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const te=A.reshapeGraphics,ie={vertices:{default:new b({style:"circle",size:te.vertex.size,color:te.vertex.color,outline:{color:te.vertex.outlineColor,width:1}}),hover:new b({style:"circle",size:te.vertex.hoverSize,color:te.vertex.hoverColor,outline:{color:te.vertex.hoverOutlineColor,width:1}}),selected:new b({style:"circle",size:te.selected.size,color:te.selected.color,outline:{color:te.selected.outlineColor,width:1}})},midpoints:{default:new b({style:"circle",size:te.midpoint.size,color:te.midpoint.color,outline:{color:te.midpoint.outlineColor,width:1}}),hover:new b({style:"circle",size:te.midpoint.size,color:te.midpoint.color,outline:{color:te.midpoint.outlineColor,width:1}})}};let se=class extends r.EventedAccessor{constructor(e){super(e),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._connectedReshapeManager=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this.tooltip=null,this.activeTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.connectedReshapeProviders=null,this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new b({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=new s,this.snappingManager=null,this.symbols=ie,this.sketchOptions=new D,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new O({view:e}),this._setup(),this._updateHandlesOnExternalGeometryChange=c((()=>this.graphic?.geometry),(e=>{if(!e)return;const t=new Set(this.selectedVertices.map((e=>e.attributes?.pointIndex)));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter((e=>t.has(e.attributes.pointIndex))).forEach((e=>this._addToSelection(e)));const{enableMovement:i,_mover:s,graphic:o,midpointGraphics:r,vertexGraphics:n}=this,h=n.concat(r).items;i&&h.push(o),s?.set("graphics",h)}),v),this.tooltip=N((()=>({view:e,options:this.sketchOptions.tooltips}))),this.tooltipInfos=T(this.sketchOptions),this.addHandles([l((()=>e?.ready),(()=>{const{layer:e,view:t}=this;k(t,e),this.addHandles(t.on("key-down",(e=>this._keyDownHandler(e)),U.TOOL))}),{once:!0,initial:!0}),d((()=>this.graphic),(()=>this.refresh())),d((()=>this.layer),((e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()})),d((()=>[this.highlightsEnabled,this.highlightName]),(()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()})),d((()=>this.enableMidpoints),(()=>this.refresh())),R(this.tooltip,(()=>this._tooltipsContext)),d((()=>this.view.effectiveTheme.accentColor),(()=>this._updateSymbolsForTheme()),m),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._connectedReshapeManager=h(this._connectedReshapeManager),this.tooltip=h(this.tooltip)}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??L(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _selectedVertex(){return 1===this.selectedVertices.length?this.selectedVertices.at(0):void 0}get _tooltipsContext(){const{automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,sketchOptions:i,activeTooltipInfo:s,graphic:o}=this;return{sketchOptions:i,activeTooltipInfo:s,graphic:o,selectedVertex:this._selectedVertex,automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,updateGeometry:(e,t,i,s,o)=>{this._setUpGeometryHelper();const r=e===this.graphic;r?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(e);const n=!0;if(this._syncGeometryAfterVertexMove(e,t,s,o,n),r){const{view:e}=this,s=e.toScreen(i),o=e.toScreen(t),r=(o?.x??0)-(s?.x??0),n=(o?.y??0)-(s?.y??0);this._emitMoveEvent(r,n),this._emitMoveStopEvent(r,n)}else this._emitReshapeEvent(e),this._emitReshapeStopEvent(e);this._editGeometryOperations=h(this._editGeometryOperations)}}}get state(){const e=this.view.ready,t=!(!this.graphic||!this.layer);return e&&t?"active":e?"ready":"disabled"}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){const{selectedVertices:e}=this;e.length&&this._removeVertices(e)}_setup(){const{graphic:e,layer:t}=this;if(!t||null==e?.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&f(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._setupConnectedReshapeManager()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(null==e||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new u({paths:[e.points],spatialReference:e.spatialReference}):e;this._editGeometryOperations=z.fromGeometry(t,V.Local)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new M({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer);const i=this._editGeometryOperations;a(i),this._snappingContext=new F({editGeometryOperations:i,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new w(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=h(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this.selectedVertices.removeAll(),this._updateTooltip()}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach((e=>e.destroy())),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach((e=>e.destroy())),this.vertexGraphics.removeAll()}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type)){const t=oe(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];return e?.forEach(((e,r)=>{e.forEach(((e,n)=>{o.push(new t({geometry:this._coordinateHelper.arrayToPoint(e),symbol:s?.vertices?.default,attributes:{...i,pathIndex:r,pointIndex:n}}))}))})),o}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];for(let r=0;r<e.length;r++){const n=e[r];for(let e=0;e<n.length;e++){const h=(e+1)%n.length;if("polyline"===this.graphic.geometry?.type&&0===h)continue;const a=n[e],p=n[h],c=this._getMidpoint(a,p);o.push(new t({geometry:c,symbol:s.midpoints.default,attributes:{...i,pathIndex:r,pointIndexStart:e,pointIndexEnd:h}}))}}return o}_updateSymbolsForTheme(){const e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",e),hover:this.symbols.vertices.hover?.clone().set("color",e)},midpoints:{...this.symbols.midpoints}};for(const t of this.vertexGraphics)this._isSelected(t)?t.symbol=this.symbols.vertices.selected:this._hoverGraphic===t?t.symbol=this.symbols.vertices.hover:t.symbol=this.symbols.vertices.default}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map((({geometry:e})=>({x:e.x,y:e.y})));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&r.push(t),this._mover=new I({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_setupConnectedReshapeManager(){const{connectedReshapeProviders:e}=this;null!=e&&0!==e.length&&(this._connectedReshapeManager=new S({providerFactories:e,view:this.view}))}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick?.(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e,o=this._connectedReshapeManager,r=o?he(this.graphic):null;if(s===this.graphic){const{geometry:n}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),r&&o?.startFeatureMove([r]),void(null!=n&&"point"===n.type&&this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)})))}const{selectedVertices:n}=this;if(!n.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),r&&o?.startVertexMove(r,ae(n)),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)}))}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)}));else if("point"===n.type)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}));else if("polyline"===n.type||"polygon"===n.type){const t=oe(n);this._updateVertexGraphicLocations(t);const{dxMap:o,dyMap:r}=pe(i,s,this.view);this._connectedReshapeManager?.translate(o,r,0),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,(()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o))),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._connectedReshapeManager?.finish(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const{_coordinateHelper:t}=this;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes;i.geometry=t.arrayToPoint(e[s][o])}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,r=e[i];t.geometry=this._getMidpoint(r[s],r[o])}}_getMidpoint(e,t){const{_coordinateHelper:i}=this,s=i.arrayToVector(e),o=i.arrayToVector(t),r=i.toXYZ(s),n=i.toXYZ(o),[h,a,p]=x(r,n),c=i.hasM()?0:void 0;return new g({x:h,y:a,z:p,m:c,spatialReference:i.spatialReference})}_getVertexFromEditGeometry(e){a(this._editGeometryOperations);const[t,i]=re(e);return this._editGeometryOperations.data.components[t].vertices[i]}_onHandleMove(e,t,s,o,r){p(this._snappingTask);const n=this._snappingContext;if(!n)return;const h=e.geometry,a="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!a){const o=this.snappingManager;this._stagedVertex=o.update({point:h,context:n}),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,a),r(),this._snappingTask=i((async i=>{const p=await o.snap({point:h,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,a),r())}))}else{const i=null!=this._stagedVertex?new g(this._stagedVertex):h;this._syncGeometryAfterVertexMove(e,i,t,s,a),r()}}_syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations?.data.geometry;if(!r)return;const{_coordinateHelper:n}=this,h=n.pointToVector(t),a=this._getVertexFromEditGeometry(e),p=n.getZ(h),c=h[0]-a.pos[0],l=h[1]-a.pos[1],d=null!=p?p-a.pos[2]:0;if(this._editGeometryOperations?.moveVertices([a],c,l,d),this._connectedReshapeManager?.translate(c,l,d),"point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t);else{const[h,a]=re(e);let p=G(r);const c=p[h].length-1,l=n.pointToArray(t);p[h][a]=l,"polygon"===r.type&&(0===a?p[h][c]=l:a===c&&(p[h][0]=l)),this._isVertex(e)&&(p=this._moveRelatedCoordinates(p,e,l),p=this._moveSelectedHandleCoordinates(p,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(p)),this._updateGraphicGeometry(r.clone()),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i){const{relatedGraphicIndices:s}=t.attributes;for(const o of s){const s=this.vertexGraphics.at(o),{pathIndex:r,pointIndex:n}=s.attributes;e[r][n]=i,s.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:h}=r.attributes,a=E(r.geometry,i,s,this.view),p=G(a),c=e[t].length-1;e[t][n]=p,r.geometry=a,o&&(0===n?e[t][c]=p:n===c&&(e[t][0]=p));for(const i of h){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=p,t.geometry=a}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._hoverGraphic=t;const i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.view.cursor="default",this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:h,pointIndexEnd:a}=e.attributes,p=G(e.geometry),c=0===a?h+1:a,l=G(o);return l[n].splice(c,0,p),e.attributes={...t,pathIndex:n,pointIndex:c,relatedGraphicIndices:[]},r.push({coordinates:l[n][c],componentIndex:n,vertexIndex:c}),this._updateGraphicGeometry(o),r}_addToSelection(e){const t=ne(e);for(const i of t)i.symbol=this.symbols.vertices.selected,this.selectedVertices.add(i),this._updateTooltip(i);this._emitSelectEvent(t)}_removeFromSelection(e,t){const{vertices:i}=this.symbols,s=t?i.hover:i.default;this.selectedVertices.remove(e),e.symbol=s,this._emitDeselectEvent([e]),this._updateTooltip()}_clearSelection(){const e=this.selectedVertices.toArray();if(e.length>0){for(const t of e)t.set("symbol",this.symbols.vertices.default);this.selectedVertices.removeAll(),this._emitDeselectEvent(e),this._updateTooltip()}}_keyDownHandler(e){null==this._activeOperationInfo&&Z(e,this.tooltip)||P.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const t=this.graphic.geometry;if(null==t||"polygon"!==t.type&&"polyline"!==t.type)return;if("polygon"===t.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;const i=this.graphic.clone(),s=t.clone();let o=G(s);const r=[],n=ne(e);for(const h of n){const{x:e,y:t}=h.geometry;for(let i=0;i<o.length;i++){const s=o[i];for(let n=0;n<s.length;n++){const[h,a]=s[n];e===h&&t===a&&(r.push({coordinates:o[i][n],componentIndex:i,vertexIndex:n}),o[i].splice(Number(n),1))}}}if("polygon"===s.type)o=o.filter((e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)})),s.rings=o;else{for(const e of o)1===e.length&&o.splice(o.indexOf(e),1);s.paths=o}this._updateGraphicGeometry(s),this.refresh(),this._emitVertexRemoveEvent(n,i,r)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){this.view.cursor=this._isMidpoint(e)?"copy":"move"}_updateTooltip(e,t){let i=null;const{graphic:s,view:o,tooltipInfos:r}=this,n=s?.geometry;"point"===n?.type?i=r.movePoint:this._selectedVertex?i=r.selectedVertex:e===this.graphic?(i=r.translateGraphic,H(i,o,this._tooltipsContext,t)):e&&this.selectedVertices.length>1&&(i=r.translateVertices,j(i,o,n,this._tooltipsContext,t)),this.activeTooltipInfo=i}_updateGraphicGeometry(e){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=e,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(e,t){const i=new q(this.graphic,e,t);this.emit("move-start",i),this.callbacks.onMoveStart?.(i)}_emitMoveEvent(e,t){const i=new B(this.graphic,e,t);this.emit("move",i),this.callbacks.onMove?.(i)}_emitMoveStopEvent(e,t){if(null==e||null==t){const i=this._activeOperationInfo;if(!i)return;e=i.totalDx,t=i.totalDy}const i=new J(this.graphic,e,t);this.emit("move-stop",i),this.callbacks.onMoveStop?.(i)}_emitReshapeStartEvent(e){const t=new X(this.graphic,e,this.selectedVertices.toArray());this.emit("reshape-start",t),this.callbacks.onReshapeStart?.(t)}_emitReshapeEvent(e){const t=new Y(this.graphic,e,this.selectedVertices.toArray());this.emit("reshape",t),this.callbacks.onReshape?.(t)}_emitReshapeStopEvent(e){const t=new K(this.graphic,e,this.selectedVertices.toArray());this.emit("reshape-stop",t),this.callbacks.onReshapeStop?.(t)}_emitSelectEvent(e){const t=new Q(e);this.emit("select",t),this.callbacks.onVertexSelect?.(t)}_emitDeselectEvent(e){const t=new W(e);this.emit("deselect",t),this.callbacks.onVertexDeselect?.(t)}_emitVertexAddEvent(e,t,i){const s=new $(e,this.graphic,t,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd?.(s)}_emitVertexRemoveEvent(e,t,i){const s=new ee(e,this.graphic,t,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove?.(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};function oe(e){const t=G(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}function re({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}function ne(e){return e instanceof t?[e]:[...e]}function he(e){const t=e.sourceLayer??e.layer;return C(t)?{graphic:e,layer:t}:null}function ae(e){return e.toArray().map((e=>({pathIndex:e.attributes.pathIndex,vertexIndex:e.attributes.pointIndex})))}function pe(e,t,i){const s=i.state.inverseTransform;return{dxMap:s[0]*e+s[2]*t,dyMap:s[1]*e+s[3]*t}}e([y()],se.prototype,"_activeOperationInfo",void 0),e([y()],se.prototype,"_connectedReshapeManager",void 0),e([y()],se.prototype,"_coordinateHelper",null),e([y()],se.prototype,"_editGeometryOperations",void 0),e([y()],se.prototype,"tooltip",void 0),e([y()],se.prototype,"tooltipInfos",void 0),e([y()],se.prototype,"activeTooltipInfo",void 0),e([y({constructOnly:!0})],se.prototype,"automaticAreaMeasurementUtils",void 0),e([y({constructOnly:!0})],se.prototype,"automaticLengthMeasurementUtils",void 0),e([y()],se.prototype,"_selectedVertex",null),e([y()],se.prototype,"_tooltipsContext",null),e([y()],se.prototype,"callbacks",void 0),e([y()],se.prototype,"connectedReshapeProviders",void 0),e([y()],se.prototype,"enableMidpoints",void 0),e([y()],se.prototype,"enableMovement",void 0),e([y()],se.prototype,"enableVertices",void 0),e([y()],se.prototype,"graphic",void 0),e([y()],se.prototype,"highlightName",void 0),e([y()],se.prototype,"highlightsEnabled",void 0),e([y()],se.prototype,"layer",void 0),e([y({readOnly:!0})],se.prototype,"midpointGraphics",void 0),e([y()],se.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],se.prototype,"selectedVertices",void 0),e([y()],se.prototype,"snappingManager",void 0),e([y({readOnly:!0})],se.prototype,"state",null),e([y()],se.prototype,"symbols",void 0),e([y({type:D})],se.prototype,"sketchOptions",void 0),e([y({readOnly:!0})],se.prototype,"type",void 0),e([y({readOnly:!0})],se.prototype,"vertexGraphics",void 0),e([y()],se.prototype,"view",void 0),se=e([_("esri.views.draw.support.Reshape")],se);const ce=se;export{ce 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Evented.js";import{on as o}from"../../core/events.js";import{destroyMaybe as n}from"../../core/maybe.js";import{watch as i,when as s,syncAndInitial as r,initial as c,sync as l}from"../../core/reactiveUtils.js";import{cloneScreenPoint as a,createScreenPoint as p}from"../../core/screenUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{setCalciteModeClass as f}from"../../support/modeUtils.js";import{base as d}from"./tooltip/css.js";import{tooltipContentFactory as m}from"./tooltip/content/tooltipContentFactory.js";import{isRTL as v}from"../../widgets/support/widgetUtils.js";const y={base:`${d}`,ltr:`${d}--ltr`,rtl:`${d}--rtl`,debug:`${d}--debug`},g=20,_=16,C="bottom-end";let b=class extends e.EventedAccessor{constructor(t){super(t),this.info=null,this.options=null,this.position=null,this.content=null,this._focused=!1,this.outerContainer=document.createElement("div"),this.debug=!1,this._lastPosition=null,this._rtl=!1,this._prevXY=[0,0]}initialize(){const{outerContainer:t}=this;this.addHandles([i((()=>this.view.overlay?.surface),(e=>{t.remove(),e?.appendChild(t),this._rtl=v(e)}),r),i((()=>this.info),((e,o)=>{if(null!=this.content&&null!=e&&null!=o&&e.type===o.type)this.content.info=e;else{n(this.content);const o=m(this,e);o?(this.content=o,o.container&&t.appendChild(o.container),this.exitInputMode()):this.content=null}}),r),i((()=>({container:this.outerContainer,style:this._outerContainerStyle})),(({container:t,style:e})=>{Object.assign(t.style,e)}),c),i((()=>({outerContainer:this.outerContainer,placement:this.effectivePlacement,effectiveOffset:this._effectiveOffset,rtl:this._rtl,debug:this.debug})),(({outerContainer:t,placement:e,effectiveOffset:o,rtl:n,debug:i})=>{const{classList:s}=t;s.add(y.base),s.toggle(y.rtl,n),s.toggle(y.ltr,!n),s.toggle(y.debug,i),this.outerContainer.style.setProperty("--offset",`${o}px`),f(t),w(t,e)}),c),s((()=>"feedback"===this.mode),(()=>{this.position=null,this._clearOverride("effectivePlacement")}),l),o(this.outerContainer,"paste",(t=>{this.emit("paste",t)})),o(this.outerContainer,["focusin","focusout"],(()=>{this._focused=this.content?.container?.contains(document.activeElement)??!1}))])}destroy(){this.info=null,this.content=n(this.content),this.outerContainer.remove()}get mode(){return this.content?.mode??"feedback"}get focused(){return this._focused}get visible(){return"none"!==this._outerContainerStyle.display}get contentContainer(){return this.content?.container}get effectivePlacement(){const t=this.options?.placement;return"auto"===t?"bottom-end":t??C}get _screenPoint(){const{inputManager:t}=this.view;return t?.multiTouchActive?null:t?.latestPointerLocation}get _effectiveOffset(){return this.options?.offset??g}get _outerContainerStyle(){const t=this.position??this._screenPoint;if(this._lastPosition=a(t),null!=t&&null!=this.content){return{display:"block",transform:`translate(${Math.round(t.x)}px, ${Math.round(t.y)}px)`}}return{display:"none",transform:"none"}}clear(){this.info=null}async enterInputMode(t){const e=this.position??this._lastPosition??this._screenPoint,o=this.position=a(e),{effectivePlacement:n}=this;this._override("effectivePlacement",n);const i=()=>{o&&(this.position=j(this.contentContainer,o,this._effectiveOffset,this.view),Object.assign(this.outerContainer.style,this._outerContainerStyle))};await(this.content?.enterInputMode(t,i))}async exitInputMode(t){await(this.content?.exitInputMode(t))}onDragStart(t,e){this._prevXY=[t,e]}onDrag(t,e){const o=t-this._prevXY[0],n=e-this._prevXY[1];this._prevXY=[t,e];const{position:i}=this;if(i){const{view:s}=this,r=t-s.position[0],c=e-s.position[1];if(r<0||r>s.width||c<0||c>s.height-_)return;this.position=p(i.x+o,i.y+n)}}onDragEnd(){this._prevXY=[0,0]}};function j(t,e,o,n){if(!t||!n.container)return e;const i=t.getBoundingClientRect(),{left:s,top:r}=n.container.getBoundingClientRect();let{x:c,y:l}=e;const a=i.left-s-o;a<0&&(c-=a);const u=i.right-s+o-n.width;u>0&&(c-=u);const h=i.top-r-o;h<0&&(l-=h);const f=i.bottom-r+o-n.height;return f>0&&(l-=f),p(c,l)}t([u({nonNullable:!0})],b.prototype,"view",void 0),t([u()],b.prototype,"info",void 0),t([u()],b.prototype,"options",void 0),t([u()],b.prototype,"position",void 0),t([u()],b.prototype,"content",void 0),t([u({readOnly:!0})],b.prototype,"mode",null),t([u()],b.prototype,"_focused",void 0),t([u({readOnly:!0})],b.prototype,"focused",null),t([u({readOnly:!0})],b.prototype,"outerContainer",void 0),t([u({readOnly:!0})],b.prototype,"contentContainer",null),t([u({readOnly:!0})],b.prototype,"effectivePlacement",null),t([u()],b.prototype,"debug",void 0),t([u()],b.prototype,"_lastPosition",void 0),t([u()],b.prototype,"_screenPoint",null),t([u()],b.prototype,"_rtl",void 0),t([u()],b.prototype,"_effectiveOffset",null),t([u()],b.prototype,"_outerContainerStyle",null),b=t([h("esri.views.interactive.Tooltip")],b);const P=["top","bottom","leading","trailing"].flatMap((t=>[O(`${t}-start`),O(t),O(`${t}-end`)]));function O(t){return`${y.base}--${t}`}function w({classList:t},e){P.forEach((e=>t.remove(e))),t.add(O(e))}export{b as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Evented.js";import{on as o}from"../../core/events.js";import{destroyMaybe as n}from"../../core/maybe.js";import{watch as i,when as s,syncAndInitial as r,initial as c,sync as l}from"../../core/reactiveUtils.js";import{cloneScreenPoint as a,createScreenPoint as p}from"../../core/screenUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{setCalciteModeClass as f}from"../../support/modeUtils.js";import{base as d}from"./tooltip/css.js";import{tooltipContentFactory as m}from"./tooltip/content/tooltipContentFactory.js";import{isRTL as v}from"../../widgets/support/widgetUtils.js";const y={base:`${d}`,ltr:`${d}--ltr`,rtl:`${d}--rtl`,debug:`${d}--debug`},g=20,_=16,C="bottom-end";let b=class extends e.EventedAccessor{constructor(t){super(t),this.info=null,this.options=null,this.position=null,this.content=null,this._focused=!1,this.outerContainer=document.createElement("div"),this.debug=!1,this._lastPosition=null,this._rtl=!1,this._prevXY=[0,0]}initialize(){const{outerContainer:t}=this;this.addHandles([i((()=>this.view.overlay?.surface),(e=>{t.remove(),e?.appendChild(t),this._rtl=v(e)}),r),i((()=>this.info),((e,o)=>{if(null!=this.content&&null!=e&&null!=o&&e.type===o.type)this.content.info=e;else{n(this.content);const o=m(this,e);o?(this.content=o,o.container&&t.appendChild(o.container),this.exitInputMode()):this.content=null}}),r),i((()=>({container:this.outerContainer,style:this._outerContainerStyle})),(({container:t,style:e})=>{Object.assign(t.style,e)}),c),i((()=>({outerContainer:this.outerContainer,placement:this.effectivePlacement,effectiveOffset:this._effectiveOffset,rtl:this._rtl,debug:this.debug})),(({outerContainer:t,placement:e,effectiveOffset:o,rtl:n,debug:i})=>{const{classList:s}=t;s.add(y.base),s.toggle(y.rtl,n),s.toggle(y.ltr,!n),s.toggle(y.debug,i),this.outerContainer.style.setProperty("--offset",`${o}px`),f(t),w(t,e)}),c),s((()=>"feedback"===this.mode),(()=>{this.position=null,this._clearOverride("effectivePlacement")}),l),o(this.outerContainer,"paste",(t=>{this.emit("paste",t)})),o(this.outerContainer,["focusin","focusout"],(()=>{this._focused=this.content?.container?.contains(document.activeElement)??!1}))])}destroy(){this.info=null,this.content=n(this.content),this.outerContainer.remove()}get mode(){return this.content?.mode??"feedback"}get focused(){return this._focused}get visible(){return"none"!==this._outerContainerStyle.display}get contentContainer(){return this.content?.container}get effectivePlacement(){const t=this.options?.placement;return"auto"===t?"bottom-end":t??C}get _screenPoint(){const{inputManager:t}=this.view;return t?.multiTouchActive?null:t?.latestPointerLocation}get _effectiveOffset(){return this.options?.offset??g}get _outerContainerStyle(){const t=this.position??this._screenPoint;if(this._lastPosition=a(t),null!=t&&null!=this.content){return{display:"block",transform:`translate(${Math.round(t.x)}px, ${Math.round(t.y)}px)`}}return{display:"none",transform:"none"}}clear(){this.info=null}async enterInputMode(t){const e=this.position??this._lastPosition??this._screenPoint,o=this.position=a(e),{effectivePlacement:n}=this;this._override("effectivePlacement",n);const i=()=>{o&&(this.position=j(this.contentContainer,o,this._effectiveOffset,this.view),Object.assign(this.outerContainer.style,this._outerContainerStyle))};await(this.content?.enterInputMode(t,i))}async exitInputMode(t){await(this.content?.exitInputMode(t))}onDragStart(t,e){this._prevXY=[t,e]}onDrag(t,e){const o=t-this._prevXY[0],n=e-this._prevXY[1];this._prevXY=[t,e];const{position:i}=this;if(i){const{view:s}=this,r=t-s.position[0],c=e-s.position[1];if(r<0||r>s.width||c<0||c>s.height-_)return;this.position=p(i.x+o,i.y+n)}}onDragEnd(){this._prevXY=[0,0]}};function j(t,e,o,n){if(!t||!n.container)return e;const i=t.getBoundingClientRect(),{left:s,top:r}=n.container.getBoundingClientRect();let{x:c,y:l}=e;const a=i.left-s-o;a<0&&(c-=a);const u=i.right-s+o-n.width;u>0&&(c-=u);const h=i.top-r-o;h<0&&(l-=h);const f=i.bottom-r+o-n.height;return f>0&&(l-=f),p(c,l)}t([u({nonNullable:!0})],b.prototype,"view",void 0),t([u()],b.prototype,"info",void 0),t([u()],b.prototype,"options",void 0),t([u()],b.prototype,"position",void 0),t([u()],b.prototype,"content",void 0),t([u({readOnly:!0})],b.prototype,"mode",null),t([u()],b.prototype,"_focused",void 0),t([u({readOnly:!0})],b.prototype,"focused",null),t([u({readOnly:!0})],b.prototype,"outerContainer",void 0),t([u({readOnly:!0})],b.prototype,"contentContainer",null),t([u({readOnly:!0})],b.prototype,"effectivePlacement",null),t([u()],b.prototype,"debug",void 0),t([u()],b.prototype,"_lastPosition",void 0),t([u()],b.prototype,"_screenPoint",null),t([u()],b.prototype,"_rtl",void 0),t([u()],b.prototype,"_effectiveOffset",null),t([u()],b.prototype,"_outerContainerStyle",null),b=t([h("esri.views.interactive.Tooltip")],b);const P=["top","bottom","leading","trailing"].flatMap((t=>[O(`${t}-start`),O(t),O(`${t}-end`)]));function O(t){return`${y.base}--${t}`}function w({classList:t},e){P.forEach((e=>t.remove(e))),t.add(O(e))}const x=b;export{x 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import{property as e}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";let t=class extends r{constructor(o){super(o),this.enabled=!1}};o([e({type:Boolean,nonNullable:!0})],t.prototype,"enabled",void 0),t=o([s("esri.views.interactive.sketch.SketchLabelOptions")],t);export{t as default};
5
+ import{_ as o}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import{property as e}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";let t=class extends r{constructor(o){super(o),this.enabled=!1}};o([e({type:Boolean,nonNullable:!0})],t.prototype,"enabled",void 0),t=o([s("esri.views.interactive.sketch.SketchLabelOptions")],t);const c=t;export{c 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";import r from"./SketchLabelOptions.js";import p from"./SketchTooltipOptions.js";import i from"./SketchValueOptions.js";let c=class extends t{constructor(o){super(o),this.labels=new r,this.tooltips=new p,this.values=new i}};o([s({nonNullable:!0,type:r})],c.prototype,"labels",void 0),o([s({nonNullable:!0,type:p})],c.prototype,"tooltips",void 0),o([s({nonNullable:!0,type:i})],c.prototype,"values",void 0),c=o([e("esri.views.interactive.sketch.SketchOptions")],c);export{c as default};
5
+ import{_ as o}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";import r from"./SketchLabelOptions.js";import p from"./SketchTooltipOptions.js";import i from"./SketchValueOptions.js";let c=class extends t{constructor(o){super(o),this.labels=new r,this.tooltips=new p,this.values=new i}};o([s({nonNullable:!0,type:r})],c.prototype,"labels",void 0),o([s({nonNullable:!0,type:p})],c.prototype,"tooltips",void 0),o([s({nonNullable:!0,type:i})],c.prototype,"values",void 0),c=o([e("esri.views.interactive.sketch.SketchOptions")],c);const l=c;export{l 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import o from"../../../core/Accessor.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{SketchTooltipElevationOptions as l}from"./SketchTooltipElevationOptions.js";import i from"./SketchTooltipVisibleElements.js";let p=class extends o{constructor(e){super(e),this.enabled=!1,this.forceEnabled=!1,this.helpMessage=null,this.helpMessageIcon=null,this.inputEnabled=!0,this.elevation=new l,this.placement="auto",this.offset=null,this.visibleElements=new i,this.visualVariables=null,this.xyMode="auto"}get effectiveEnabled(){return this.forceEnabled||this.enabled}};e([t({type:Boolean,nonNullable:!0})],p.prototype,"enabled",void 0),e([t()],p.prototype,"forceEnabled",void 0),e([t()],p.prototype,"effectiveEnabled",null),e([t()],p.prototype,"helpMessage",void 0),e([t()],p.prototype,"helpMessageIcon",void 0),e([t({type:Boolean,nonNullable:!0})],p.prototype,"inputEnabled",void 0),e([t({type:l,nonNullable:!0})],p.prototype,"elevation",void 0),e([t()],p.prototype,"placement",void 0),e([t()],p.prototype,"offset",void 0),e([t({type:i,nonNullable:!0})],p.prototype,"visibleElements",void 0),e([t()],p.prototype,"visualVariables",void 0),e([t()],p.prototype,"xyMode",void 0),p=e([s("esri.views.interactive.sketch.SketchTooltipOptions")],p);export{p as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import o from"../../../core/Accessor.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{SketchTooltipElevationOptions as l}from"./SketchTooltipElevationOptions.js";import i from"./SketchTooltipVisibleElements.js";let p=class extends o{constructor(e){super(e),this.enabled=!1,this.forceEnabled=!1,this.helpMessage=null,this.helpMessageIcon=null,this.inputEnabled=!0,this.elevation=new l,this.placement="auto",this.offset=null,this.visibleElements=new i,this.visualVariables=null,this.xyMode="auto"}get effectiveEnabled(){return this.forceEnabled||this.enabled}};e([t({type:Boolean,nonNullable:!0})],p.prototype,"enabled",void 0),e([t()],p.prototype,"forceEnabled",void 0),e([t()],p.prototype,"effectiveEnabled",null),e([t()],p.prototype,"helpMessage",void 0),e([t()],p.prototype,"helpMessageIcon",void 0),e([t({type:Boolean,nonNullable:!0})],p.prototype,"inputEnabled",void 0),e([t({type:l,nonNullable:!0})],p.prototype,"elevation",void 0),e([t()],p.prototype,"placement",void 0),e([t()],p.prototype,"offset",void 0),e([t({type:i,nonNullable:!0})],p.prototype,"visibleElements",void 0),e([t()],p.prototype,"visualVariables",void 0),e([t()],p.prototype,"xyMode",void 0),p=e([s("esri.views.interactive.sketch.SketchTooltipOptions")],p);const r=p;export{r 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";let a=class extends e{constructor(o){super(o),this.area=!0,this.coordinates=!0,this.direction=!0,this.distance=!0,this.elevation=!0,this.header=!0,this.helpMessage=!1,this.orientation=!0,this.radius=!0,this.rotation=!0,this.scale=!0,this.size=!0,this.totalLength=!0}};o([t({type:Boolean,nonNullable:!0})],a.prototype,"area",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"coordinates",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"direction",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"distance",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"elevation",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"header",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"helpMessage",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"orientation",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"radius",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"rotation",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"scale",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"size",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"totalLength",void 0),a=o([l("esri.views.interactive.sketch.SketchTooltipVisibleElements")],a);export{a as default};
5
+ import{_ as o}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";let a=class extends e{constructor(o){super(o),this.area=!0,this.coordinates=!0,this.direction=!0,this.distance=!0,this.elevation=!0,this.header=!0,this.helpMessage=!1,this.orientation=!0,this.radius=!0,this.rotation=!0,this.scale=!0,this.size=!0,this.totalLength=!0}};o([t({type:Boolean,nonNullable:!0})],a.prototype,"area",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"coordinates",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"direction",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"distance",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"elevation",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"header",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"helpMessage",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"orientation",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"radius",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"rotation",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"scale",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"size",void 0),o([t({type:Boolean,nonNullable:!0})],a.prototype,"totalLength",void 0),a=o([l("esri.views.interactive.sketch.SketchTooltipVisibleElements")],a);const n=a;export{n 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import r from"./Units.js";import{DirectionMode as o}from"../../support/angularMeasurementUtils.js";let n=class extends e{constructor(t){super(t),this.directionMode="relative",this.relativeDirectionIsBilateral=!1}get effectiveDirectionMode(){switch(this.directionMode){case"relative":return this.relativeDirectionIsBilateral?o.RelativeBilateral:o.Relative;case"absolute":return o.Absolute}}get displayUnits(){return this._get("displayUnits")??new r}set displayUnits(t){this._set("displayUnits",t)}get inputUnits(){return this._get("inputUnits")??new r}set inputUnits(t){this._set("inputUnits",t)}};t([i({type:String,nonNullable:!0})],n.prototype,"directionMode",void 0),t([i({type:Boolean,nonNullable:!0})],n.prototype,"relativeDirectionIsBilateral",void 0),t([i()],n.prototype,"effectiveDirectionMode",null),t([i({type:r,nonNullable:!0})],n.prototype,"displayUnits",null),t([i({type:r,nonNullable:!0})],n.prototype,"inputUnits",null),n=t([s("esri.views.interactive.sketch.SketchValueOptions")],n);export{n as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import r from"./Units.js";import{DirectionMode as o}from"../../support/angularMeasurementUtils.js";let n=class extends e{constructor(t){super(t),this.directionMode="relative",this.relativeDirectionIsBilateral=!1}get effectiveDirectionMode(){switch(this.directionMode){case"relative":return this.relativeDirectionIsBilateral?o.RelativeBilateral:o.Relative;case"absolute":return o.Absolute}}get displayUnits(){return this._get("displayUnits")??new r}set displayUnits(t){this._set("displayUnits",t)}get inputUnits(){return this._get("inputUnits")??new r}set inputUnits(t){this._set("inputUnits",t)}};t([i({type:String,nonNullable:!0})],n.prototype,"directionMode",void 0),t([i({type:Boolean,nonNullable:!0})],n.prototype,"relativeDirectionIsBilateral",void 0),t([i()],n.prototype,"effectiveDirectionMode",null),t([i({type:r,nonNullable:!0})],n.prototype,"displayUnits",null),t([i({type:r,nonNullable:!0})],n.prototype,"inputUnits",null),n=t([s("esri.views.interactive.sketch.SketchValueOptions")],n);const l=n;export{l 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as r}from"../../../chunks/tslib.es6.js";import o from"../../../core/Accessor.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";let s=class extends o{constructor(r){super(r),this.length=null,this.verticalLength=null,this.area=null}};r([t()],s.prototype,"length",void 0),r([t()],s.prototype,"verticalLength",void 0),r([t()],s.prototype,"area",void 0),s=r([e("esri.views.interactive.sketch.Units")],s);export{s as default};
5
+ import{_ as o}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";let e=class extends r{constructor(o){super(o),this.length=null,this.verticalLength=null,this.area=null}};o([t()],e.prototype,"length",void 0),o([t()],e.prototype,"verticalLength",void 0),o([t()],e.prototype,"area",void 0),e=o([s("esri.views.interactive.sketch.Units")],e);const c=e;export{c 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as t,equals as e}from"../../../core/arrayUtils.js";import{asinClamped as s}from"../../../core/mathUtils.js";import{dot as r,subtract as n,squaredDistance as i,exactEquals as o,set as c}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{create as u}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{q as a,c as h,i as f,d as l,G as d,b as p,s as m,a as g,k as _,e as L,h as k,n as x}from"../../../chunks/vec32.js";import{create as y,fromValues as P,clone as z,UNIT_Z as M}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as T,h as q}from"../../../chunks/vec42.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{toRadians as j}from"../../../geometry/support/geodesicConstants.js";import{directGeodeticSolver as v,inverseGeodeticSolver as A,InverseGeodeticSolverResult as D}from"../../../geometry/support/geodesicUtils.js";import{create as b,fromPoints as E,fromPositionAndNormal as R,intersectLine as N,signedDistance as U,projectPoint as Z,getNormal as I,distance as G}from"../../../geometry/support/plane.js";import{m as S,l as C,n as O,p as F,a as H}from"../../../chunks/sphere.js";import{tangentFrame as V}from"../../3d/support/mathUtils.js";import{clone as Y,asVec2 as B,createWritable as J,fromVec3 as K,fromValues as Q,create as W}from"./normalizedPoint.js";import{VerticalPlaneType as X,projectPointToVerticalPlane as $,isClose as tt,projectPointToVerticalCylinder as et,projectPointToLineLike as st,intersectLineLikes as rt,intersectVerticalPlaneAndLineLike as nt,intersectLineLikeAndVerticalCylinder as it,intersectLineLikeAndCircle as ot,intersectVerticalPlanes as ct,intersectVerticalPlaneAndVerticalCylinder as ut,intersectVerticalCylinders as at,intersectVerticalPlaneAndPoint as ht,vectorsHaveCloseZ as ft,isPointInsidePlane as lt,pointsInsidePlane as dt}from"../../support/geometry3dUtils.js";import{LineType as pt}from"../../support/geometry2dUtils.js";class mt{intersect(t){return Ht(this,t)}closestPoints(t){return[this.closestTo(t)]}}class gt extends mt{constructor(t){super(),this.point=t}equals(t){return this===t||Le(t)&&a(this.point,t.point)}closestTo(){return Y(this.point)}}class _t extends mt{constructor(t,e,s){super(),this.start=t,this.end=e,this.lineLike={start:t,end:e,type:s}}equals(t){return this===t||ke(t)&&this.lineLike.type===t.lineLike.type&&a(this.start,t.start)&&a(this.end,t.end)}closestTo(t){const e=J();return st(t,this.lineLike,e),e}}class Lt extends _t{constructor(t,e){super(t,e,pt.LINE)}}class kt extends _t{constructor(t,e){super(t,e,pt.RAY)}}class xt extends mt{constructor(t){super(),this.constraints=t}equals(t){return this===t||_e(t)&&e(this.constraints,t.constraints,((t,e)=>t.equals(e)))}closestTo(t){let e,s=1/0;for(const r of this.constraints){const n=r.closestTo(t),i=m(t,n);i<s&&(s=i,e=n)}return Y(e??t)}closestPoints(t){return this.constraints.flatMap((e=>e===this?[]:e.closestPoints(t)))}}class yt extends mt{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||Pe(t)&&this.center[0]===t.center[0]&&this.center[1]===t.center[1]&&this.radius===t.radius}closestTo(t){const e=J();return et(t,this.center,this.radius,e),e}}class Pt extends mt{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||ze(t)&&a(this.center,t.center)&&this.radius===t.radius}closestTo(t){const e=J();return et(t,this.center,this.radius,e),e[2]=this.center[2],e}asCircle(){return new zt(Y(this.center),this.radius,Q(0,0,1))}}class zt extends mt{constructor(t,e,s,r=void 0){super(),this.center=t,this.radius=e,this.normal=s,this.slicePlane=r}equals(t){return this===t||Me(t)&&a(this.center,t.center)&&a(this.normal,t.normal)&&this.radius===t.radius}closestTo(t){const{center:e,radius:s}=this;Z(this.getPlane(Tt),t,Mt);const r=g(Mt,Mt,e),n=_(r);if(tt(n,0))return Y(t);const i=s/Math.sqrt(n),o=J();p(o,e,r,i);const{slicePlane:c}=this;if(c&&!lt(c,o)){const e=Jt(c,this);return e?.closestTo(t)??Y(t)}return o}getPlane(t=b()){return R(this.center,this.normal,t)}}const Mt=y(),Tt=b();class qt extends mt{constructor(t){super(),this.z=t}equals(t){return this===t||xe(t)&&this.z===t.z}closestTo(t){return Q(t[0],t[1],this.z)}getPlane(t=b()){return f(wt,0,0,this.z),R(wt,M,t)}}const wt=y();class jt extends mt{constructor(t,e,s){super(),this.start=t,this.end=e,this.planeLike={start:B(t),end:B(e),type:s}}equals(t){return this===t||ye(t)&&this.planeLike.type===t.planeLike.type&&a(this.start,t.start)&&a(this.end,t.end)}closestTo(t){const e=J();return $(t,this.planeLike,e),e}closestEndTo(t){const{start:e,end:s}=this.planeLike;return Math.sign(r(n(vt,s,e),n(At,B(t),e)))>0?this.end:this.start}getPlane(t=b()){const e=h(Dt,this.end);return e[2]+=1,E(this.start,this.end,e,t)}getSlicePlane(t=b()){const{start:e,end:s,type:r}=this.planeLike;if(r===X.PLANE)return;const n=f(Dt,e[0],e[1],0),i=f(bt,s[0],s[1],0),o=l(bt,i,n);return R(n,o,t),t}}const vt=u(),At=u(),Dt=y(),bt=y();class Et extends jt{constructor(t,e){super(t,e,X.HALF_PLANE)}}class Rt extends jt{constructor(t,e){super(t,e,X.PLANE)}}class Nt extends mt{constructor(t,e){super(),this.sphere=C(t,e)}equals(t){return this===t||Te(t)&&O(this.sphere,t.sphere)}closestTo(t){const e=J();return F(this.sphere,t,e),e}get center(){return H(this.sphere)}get radius(){return this.sphere[3]}}class Ut extends mt{constructor(t,e,s){super(),this.start=t,this.end=e,this.getZ=s,this.planeLike={start:B(t),end:B(e),type:X.PLANE}}equals(t){return this===t||qe(t)&&a(this.start,t.start)&&a(this.end,t.end)&&this.getZ===t.getZ}closestTo(t){return Ft(this,t)}addIfOnTheGround(t,e){for(const s of e){const e=this.getZ(s[0],s[1])??0;tt(s[2],e)&&(s[2]=e,t.push(s))}}}class Zt extends mt{constructor(t,e,s){super(),this._x=t,this._y=e,this._z=s}equals(t){return this===t||je(t)&&this._x===t._x&&this._y===t._y&&this._z===t._z}closestTo([t,e,s]){return W(this._x??t,this._y??e,this._z??s)}}class It extends mt{constructor(t,e,s,r,n){super(),this._origin=t,this._spatialReference=e,this._distanceMeters=s,this._z=r,this._directionDegrees=n}equals(t){return this===t||we(t)&&o(this._origin,t._origin)&&this._spatialReference===t._spatialReference&&this._distanceMeters===t._distanceMeters&&this._z===t._z&&this._directionDegrees===t._directionDegrees}closestTo([t,e,s]){return c(Gt,t,e),o(Gt,this._origin)||this._applyDirectionAndDistance(Gt),W(Gt[0],Gt[1],this._z??s)}_applyDirectionAndDistance(t){if(null!=this._directionDegrees&&null!=this._distanceMeters)v(t,this._origin,this._directionDegrees,this._distanceMeters,this._spatialReference);else if(null!=this._directionDegrees)Ct(t,this._origin,this._directionDegrees,t,this._spatialReference);else if(null!=this._distanceMeters){const{azimuth:e}=A(St,this._origin,t,this._spatialReference);v(t,this._origin,e??0,this._distanceMeters,this._spatialReference)}}}const Gt=[0,0],St=new D;function Ct(t,e,s,r,n){let{azimuth:i,distance:o}=A(Ot,e,r,n);i??=0;let c=o*Math.cos((i-s)*j);c=Math.max(0,c),v(t,e,s,c,n)}const Ot=new D;function Ft(t,e){const s=J();return $(e,t.planeLike,s),s[2]=t.getZ(s[0],s[1])??ve,s}function Ht(t,e){if(_e(t)){const s=[];for(const r of t.constraints){const t=r.intersect(e);t&&s.push(t)}return ge(s)}if(_e(e))return Ht(e,t);if(qe(t))return le(t,e);if(qe(e))return le(e,t);if(Le(t)){const{point:s}=t;if(Le(e))return a(s,e.point)?t:void 0;const r=e.closestTo(s);return d(r,s)?t:void 0}if(ke(t)){if(Le(e))return Ht(e,t);if(ke(e))return pe(rt(t.lineLike,e.lineLike));if(xe(e))return Vt(t,e);if(ye(e))return pe(nt(e.planeLike,t.lineLike));if(Pe(e))return pe(it(t.lineLike,e.center,e.radius));if(Me(e))return pe(ot(t.lineLike,e));if(ze(e))return Yt(t,e);if(Te(e))return Bt(t,e)}else if(xe(t)){if(Le(e)||ke(e))return Ht(e,t);if(xe(e))return Kt(t,e);if(ye(e))return Qt(t,e);if(Pe(e))return Wt(t,e);if(Me(e))return $t(t,e);if(ze(e))return Xt(t,e);if(Te(e))return te(t,e)}else if(ye(t)){if(Le(e)||ke(e)||xe(e))return Ht(e,t);if(ye(e))return de(ct(t.planeLike,e.planeLike));if(Pe(e))return de(ut(t.planeLike,e.center,e.radius));if(Me(e))return se(t,e);if(ze(e))return ee(t,e);if(Te(e))return re(t,e)}else if(Pe(t)){if(Le(e)||ke(e)||xe(e)||ye(e))return Ht(e,t);if(Pe(e))return de(at(B(t.center),t.radius,B(e.center),e.radius));if(Me(e))return ne();if(ze(e))return ie(t,e);if(Te(e))return oe()}else if(Me(t)){if(Le(e)||ke(e)||xe(e)||ye(e)||Pe(e))return Ht(e,t);if(Me(e))return ce();if(ze(e))return ce(e.asCircle());if(Te(e))return ue()}else if(ze(t)){if(Le(e)||ke(e)||xe(e)||ye(e)||Pe(e)||Me(e))return Ht(e,t);if(ze(e))return ae(e,t);if(Te(e))return he()}else if(Te(t)){if(Le(e)||ke(e)||xe(e)||ye(e)||Pe(e)||ze(e))return Ht(e,t);if(Te(e))return fe()}}const Vt=(()=>{const t=b();return(e,s)=>{const{start:r,end:n}=e;if(ft(r,n)&&tt(r[2],s.z))return e;const i=J();return N(s.getPlane(t),r,n,i)?new gt(i):void 0}})();function Yt({lineLike:t},{center:e,radius:s}){const r=e[2];return pe(it(t,e,s).filter((t=>tt(t[2],r))))}function Bt({lineLike:t},{sphere:e}){return pe(S(e,t.start,t.end))}const Jt=(()=>{const t=w(),e=y(),r=y();return(n,i,o)=>{const{normal:c,center:u,radius:a}=i;V(c,e,r);const h=I(n),f=a*L(h,e),l=a*L(h,r);T(t,u[0],u[1],u[2],1);const d=q(n,t),m=Math.hypot(f,l),g=tt(m,0);if(tt(G(n,u),0)){if(g)return i;if(tt(a,0))return!o||lt(o,u)?new gt(Y(u)):void 0;k(e,h,c),x(e,e);const t=new Array,s=z(u);p(s,s,e,a),o&&!lt(o,s)||t.push(s);const r=z(u);return p(r,r,e,-a),o&&!lt(o,r)||t.push(r),pe(t)}if(g)return;const _=-d/m;if(Math.abs(_)>1||tt(_,1))return;const P=Math.atan(f/l),M=s(_)-P,w=Math.PI-M,j=new Array,v=y();p(v,u,e,a*Math.cos(M)),p(v,v,r,a*Math.sin(M)),j.push(v);const A=y();return p(A,u,e,a*Math.cos(w)),p(A,A,r,a*Math.sin(w)),j.push(A),pe(o?dt(o,j):j)}})();function Kt(t,e){return tt(t.z,e.z)?t:void 0}function Qt({z:t},{planeLike:e}){const[s,r]=e.start,[n,i]=e.end,o=Q(s,r,t),c=Q(n,i,t);return e.type===X.PLANE?new Lt(o,c):new kt(o,c)}function Wt(t,e){const[s,r]=e.center;return new Pt(Q(s,r,t.z),e.radius)}function Xt(t,e){return tt(e.center[2],t.z)?e:void 0}const $t=(()=>{const t=b();return(e,s)=>Jt(e.getPlane(t),s,s.slicePlane)})();function te(t,{center:e,radius:s}){const r=Math.abs(e[2]-t.z);if(r>s&&!tt(r,s))return;const n=Q(e[0],e[1],t.z),i=Math.sqrt(s**2-r**2);return tt(i,0)?void 0:new Pt(n,i)}const ee=(()=>{const t=b();return(e,{center:s,radius:r})=>{const n=ut(e.planeLike,s,r),i=s[2];e.getSlicePlane(t);const o=new Array;for(const[c,u]of n){const e=[c,u,i];lt(t,e)&&o.push(e)}return pe(o)}})(),se=(()=>{const t=b(),e=b();return(s,r)=>Jt(s.getPlane(t),r,s.getSlicePlane(e))})(),re=(()=>{const t=b();return(e,{center:s,radius:r})=>{const n=e.getPlane(t),i=U(n,s),o=Math.abs(i);if(o>r&&!tt(o,r))return;const c=Math.sqrt(r**2-i**2);if(tt(c,0)){const t=J();return Z(n,s,t),new gt(t)}const u=J(),a=z(I(n));return p(u,s,a,i),new zt(u,c,a,e.getSlicePlane())}})();function ne(t,e){}function ie(t,e){const s=i(B(t.center),B(e.center));if(tt(s,0)&&tt(t.radius,e.radius))return e;return me(at(B(t.center),t.radius,B(e.center),e.radius),e.center[2])}function oe(t,e){}function ce(t,e){}function ue(t,e){}function ae(t,e){if(!ft(t.center,e.center))return;const s=i(B(t.center),B(e.center));if(tt(s,0)&&tt(t.radius,e.radius))return t;return me(at(B(t.center),t.radius,B(e.center),e.radius),t.center[2])}function he(t,e){}function fe(t,e){}function le(t,e){const{planeLike:s,getZ:r}=t,n=new Array;if(Le(e))t.addIfOnTheGround(n,ht(s,e.point));else if(ke(e))t.addIfOnTheGround(n,nt(s,e.lineLike));else if(Pe(e))for(const[i,o]of ut(s,e.center,e.radius)){const t=r(i,o);null!=t&&n.push(P(i,o,t))}else if(ye(e)||qe(e))for(const[i,o]of ct(s,e.planeLike)){const t=r(i,o)??ve;n.push(P(i,o,t))}return pe(n)}function de(t){return ge(t.map((([t,e])=>{const s=Q(t,e,0),r=Q(t,e,1);return new Lt(s,r)})))}function pe(t){return ge(t.map((t=>t?new gt(K(t)):void 0)))}function me(t,e){return pe(t.map((([t,s])=>[t,s,e])))}function ge(e){if(0!==e.length)return 1===e.length?e[0]??void 0:new xt(e.filter(t))}function _e(t){return t instanceof xt}function Le(t){return t instanceof gt}function ke(t){return t instanceof _t}function xe(t){return t instanceof qt}function ye(t){return t instanceof jt}function Pe(t){return t instanceof yt}function ze(t){return t instanceof Pt}function Me(t){return t instanceof zt}function Te(t){return t instanceof Nt}function qe(t){return t instanceof Ut}function we(t){return t instanceof It}function je(t){return t instanceof Zt}const ve=0;export{zt as CircleConstraint,mt as Constraint,Zt as CoordinateConstraint,Ut as DrapedLineConstraint,It as GeodesicConstraint,Pt as HorizontalCircleConstraint,qt as HorizontalPlaneConstraint,Lt as LineConstraint,_t as LineLikeConstraint,gt as PointConstraint,kt as RayConstraint,xt as SetConstraint,Nt as SphereConstraint,yt as VerticalCylinderConstraint,Et as VerticalHalfPlaneConstraint,Rt as VerticalPlaneConstraint,jt as VerticalPlaneLikeConstraint,ge as constraintOrSet,Le as isPoint};
5
+ import{isSome as t,equals as e}from"../../../core/arrayUtils.js";import{asinClamped as s}from"../../../core/mathUtils.js";import{dot as r,subtract as n,squaredDistance as i,exactEquals as o,set as c}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{create as u}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{q as a,c as h,i as f,d as l,G as d,b as p,s as m,a as g,k as _,e as L,h as k,n as x}from"../../../chunks/vec32.js";import{create as y,UNIT_Z as P,fromValues as z,clone as M}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as T,g as q}from"../../../chunks/vec42.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{toRadians as j}from"../../../geometry/support/geodesicConstants.js";import{directGeodeticSolver as v,inverseGeodeticSolver as A,InverseGeodeticSolverResult as D}from"../../../geometry/support/geodesicUtils.js";import{create as b,fromPoints as E,fromPositionAndNormal as R,intersectLine as N,signedDistance as U,projectPoint as Z,getNormal as I,distance as G}from"../../../geometry/support/plane.js";import{e as S,h as C,j as O,p as F,a as H}from"../../../chunks/sphere.js";import{tangentFrame as V}from"../../3d/support/mathUtils.js";import{clone as Y,asVec2 as B,createWritable as J,create as K,fromValues as Q,fromVec3 as W}from"./normalizedPoint.js";import{VerticalPlaneType as X,projectPointToVerticalPlane as $,isClose as tt,projectPointToVerticalCylinder as et,projectPointToLineLike as st,intersectLineLikes as rt,intersectVerticalPlaneAndLineLike as nt,intersectLineLikeAndVerticalCylinder as it,intersectLineLikeAndCircle as ot,intersectVerticalPlanes as ct,intersectVerticalPlaneAndVerticalCylinder as ut,intersectVerticalCylinders as at,intersectVerticalPlaneAndPoint as ht,vectorsHaveCloseZ as ft,isPointInsidePlane as lt,pointsInsidePlane as dt}from"../../support/geometry3dUtils.js";import{LineType as pt}from"../../support/geometry2dUtils.js";class mt{intersect(t){return Ht(this,t)}closestPoints(t){return[this.closestTo(t)]}}class gt extends mt{constructor(t){super(),this.point=t}equals(t){return this===t||Le(t)&&a(this.point,t.point)}closestTo(){return Y(this.point)}}class _t extends mt{constructor(t,e,s){super(),this.start=t,this.end=e,this.lineLike={start:t,end:e,type:s}}equals(t){return this===t||ke(t)&&this.lineLike.type===t.lineLike.type&&a(this.start,t.start)&&a(this.end,t.end)}closestTo(t){const e=J();return st(t,this.lineLike,e),e}}class Lt extends _t{constructor(t,e){super(t,e,pt.LINE)}}class kt extends _t{constructor(t,e){super(t,e,pt.RAY)}}class xt extends mt{constructor(t){super(),this.constraints=t}equals(t){return this===t||_e(t)&&e(this.constraints,t.constraints,((t,e)=>t.equals(e)))}closestTo(t){let e,s=1/0;for(const r of this.constraints){const n=r.closestTo(t),i=m(t,n);i<s&&(s=i,e=n)}return Y(e??t)}closestPoints(t){return this.constraints.flatMap((e=>e===this?[]:e.closestPoints(t)))}}class yt extends mt{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||Pe(t)&&this.center[0]===t.center[0]&&this.center[1]===t.center[1]&&this.radius===t.radius}closestTo(t){const e=J();return et(t,this.center,this.radius,e),e}}class Pt extends mt{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||ze(t)&&a(this.center,t.center)&&this.radius===t.radius}closestTo(t){const e=J();return et(t,this.center,this.radius,e),e[2]=this.center[2],e}asCircle(){return new zt(Y(this.center),this.radius,Q(0,0,1))}}class zt extends mt{constructor(t,e,s,r=void 0){super(),this.center=t,this.radius=e,this.normal=s,this.slicePlane=r}equals(t){return this===t||Me(t)&&a(this.center,t.center)&&a(this.normal,t.normal)&&this.radius===t.radius}closestTo(t){const{center:e,radius:s}=this;Z(this.getPlane(Tt),t,Mt);const r=g(Mt,Mt,e),n=_(r);if(tt(n,0))return Y(t);const i=s/Math.sqrt(n),o=J();p(o,e,r,i);const{slicePlane:c}=this;if(c&&!lt(c,o)){const e=Jt(c,this);return e?.closestTo(t)??Y(t)}return o}getPlane(t=b()){return R(this.center,this.normal,t)}}const Mt=y(),Tt=b();class qt extends mt{constructor(t){super(),this.z=t}equals(t){return this===t||xe(t)&&this.z===t.z}closestTo(t){return Q(t[0],t[1],this.z)}getPlane(t=b()){return f(wt,0,0,this.z),R(wt,P,t)}}const wt=y();class jt extends mt{constructor(t,e,s){super(),this.start=t,this.end=e,this.planeLike={start:B(t),end:B(e),type:s}}equals(t){return this===t||ye(t)&&this.planeLike.type===t.planeLike.type&&a(this.start,t.start)&&a(this.end,t.end)}closestTo(t){const e=J();return $(t,this.planeLike,e),e}closestEndTo(t){const{start:e,end:s}=this.planeLike;return Math.sign(r(n(vt,s,e),n(At,B(t),e)))>0?this.end:this.start}getPlane(t=b()){const e=h(Dt,this.end);return e[2]+=1,E(this.start,this.end,e,t)}getSlicePlane(t=b()){const{start:e,end:s,type:r}=this.planeLike;if(r===X.PLANE)return;const n=f(Dt,e[0],e[1],0),i=f(bt,s[0],s[1],0),o=l(bt,i,n);return R(n,o,t),t}}const vt=u(),At=u(),Dt=y(),bt=y();class Et extends jt{constructor(t,e){super(t,e,X.HALF_PLANE)}}class Rt extends jt{constructor(t,e){super(t,e,X.PLANE)}}class Nt extends mt{constructor(t,e){super(),this.sphere=C(t,e)}equals(t){return this===t||Te(t)&&O(this.sphere,t.sphere)}closestTo(t){const e=J();return F(this.sphere,t,e),e}get center(){return H(this.sphere)}get radius(){return this.sphere[3]}}class Ut extends mt{constructor(t,e,s){super(),this.start=t,this.end=e,this.getZ=s,this.planeLike={start:B(t),end:B(e),type:X.PLANE}}equals(t){return this===t||qe(t)&&a(this.start,t.start)&&a(this.end,t.end)&&this.getZ===t.getZ}closestTo(t){return Ft(this,t)}addIfOnTheGround(t,e){for(const s of e){const e=this.getZ(s[0],s[1])??0;tt(s[2],e)&&(s[2]=e,t.push(s))}}}class Zt extends mt{constructor(t,e,s){super(),this._x=t,this._y=e,this._z=s}equals(t){return this===t||je(t)&&this._x===t._x&&this._y===t._y&&this._z===t._z}closestTo([t,e,s]){return K(this._x??t,this._y??e,this._z??s)}}class It extends mt{constructor(t,e,s,r,n){super(),this._origin=t,this._spatialReference=e,this._distanceMeters=s,this._z=r,this._directionDegrees=n}equals(t){return this===t||we(t)&&o(this._origin,t._origin)&&this._spatialReference===t._spatialReference&&this._distanceMeters===t._distanceMeters&&this._z===t._z&&this._directionDegrees===t._directionDegrees}closestTo([t,e,s]){return c(Gt,t,e),o(Gt,this._origin)||this._applyDirectionAndDistance(Gt),K(Gt[0],Gt[1],this._z??s)}_applyDirectionAndDistance(t){if(null!=this._directionDegrees&&null!=this._distanceMeters)v(t,this._origin,this._directionDegrees,this._distanceMeters,this._spatialReference);else if(null!=this._directionDegrees)Ct(t,this._origin,this._directionDegrees,t,this._spatialReference);else if(null!=this._distanceMeters){const{azimuth:e}=A(St,this._origin,t,this._spatialReference);v(t,this._origin,e??0,this._distanceMeters,this._spatialReference)}}}const Gt=[0,0],St=new D;function Ct(t,e,s,r,n){let{azimuth:i,distance:o}=A(Ot,e,r,n);i??=0;let c=o*Math.cos((i-s)*j);c=Math.max(0,c),v(t,e,s,c,n)}const Ot=new D;function Ft(t,e){const s=J();return $(e,t.planeLike,s),s[2]=t.getZ(s[0],s[1])??ve,s}function Ht(t,e){if(_e(t)){const s=[];for(const r of t.constraints){const t=r.intersect(e);t&&s.push(t)}return ge(s)}if(_e(e))return Ht(e,t);if(qe(t))return le(t,e);if(qe(e))return le(e,t);if(Le(t)){const{point:s}=t;if(Le(e))return a(s,e.point)?t:void 0;const r=e.closestTo(s);return d(r,s)?t:void 0}if(ke(t)){if(Le(e))return Ht(e,t);if(ke(e))return pe(rt(t.lineLike,e.lineLike));if(xe(e))return Vt(t,e);if(ye(e))return pe(nt(e.planeLike,t.lineLike));if(Pe(e))return pe(it(t.lineLike,e.center,e.radius));if(Me(e))return pe(ot(t.lineLike,e));if(ze(e))return Yt(t,e);if(Te(e))return Bt(t,e)}else if(xe(t)){if(Le(e)||ke(e))return Ht(e,t);if(xe(e))return Kt(t,e);if(ye(e))return Qt(t,e);if(Pe(e))return Wt(t,e);if(Me(e))return $t(t,e);if(ze(e))return Xt(t,e);if(Te(e))return te(t,e)}else if(ye(t)){if(Le(e)||ke(e)||xe(e))return Ht(e,t);if(ye(e))return de(ct(t.planeLike,e.planeLike));if(Pe(e))return de(ut(t.planeLike,e.center,e.radius));if(Me(e))return se(t,e);if(ze(e))return ee(t,e);if(Te(e))return re(t,e)}else if(Pe(t)){if(Le(e)||ke(e)||xe(e)||ye(e))return Ht(e,t);if(Pe(e))return de(at(B(t.center),t.radius,B(e.center),e.radius));if(Me(e))return ne();if(ze(e))return ie(t,e);if(Te(e))return oe()}else if(Me(t)){if(Le(e)||ke(e)||xe(e)||ye(e)||Pe(e))return Ht(e,t);if(Me(e))return ce();if(ze(e))return ce(e.asCircle());if(Te(e))return ue()}else if(ze(t)){if(Le(e)||ke(e)||xe(e)||ye(e)||Pe(e)||Me(e))return Ht(e,t);if(ze(e))return ae(e,t);if(Te(e))return he()}else if(Te(t)){if(Le(e)||ke(e)||xe(e)||ye(e)||Pe(e)||ze(e))return Ht(e,t);if(Te(e))return fe()}}const Vt=(()=>{const t=b();return(e,s)=>{const{start:r,end:n}=e;if(ft(r,n)&&tt(r[2],s.z))return e;const i=J();return N(s.getPlane(t),r,n,i)?new gt(i):void 0}})();function Yt({lineLike:t},{center:e,radius:s}){const r=e[2];return pe(it(t,e,s).filter((t=>tt(t[2],r))))}function Bt({lineLike:t},{sphere:e}){return pe(S(e,t.start,t.end))}const Jt=(()=>{const t=w(),e=y(),r=y();return(n,i,o)=>{const{normal:c,center:u,radius:a}=i;V(c,e,r);const h=I(n),f=a*L(h,e),l=a*L(h,r);T(t,u[0],u[1],u[2],1);const d=q(n,t),m=Math.hypot(f,l),g=tt(m,0);if(tt(G(n,u),0)){if(g)return i;if(tt(a,0))return!o||lt(o,u)?new gt(Y(u)):void 0;k(e,h,c),x(e,e);const t=new Array,s=M(u);p(s,s,e,a),o&&!lt(o,s)||t.push(s);const r=M(u);return p(r,r,e,-a),o&&!lt(o,r)||t.push(r),pe(t)}if(g)return;const _=-d/m;if(Math.abs(_)>1||tt(_,1))return;const P=Math.atan(f/l),z=s(_)-P,w=Math.PI-z,j=new Array,v=y();p(v,u,e,a*Math.cos(z)),p(v,v,r,a*Math.sin(z)),j.push(v);const A=y();return p(A,u,e,a*Math.cos(w)),p(A,A,r,a*Math.sin(w)),j.push(A),pe(o?dt(o,j):j)}})();function Kt(t,e){return tt(t.z,e.z)?t:void 0}function Qt({z:t},{planeLike:e}){const[s,r]=e.start,[n,i]=e.end,o=Q(s,r,t),c=Q(n,i,t);return e.type===X.PLANE?new Lt(o,c):new kt(o,c)}function Wt(t,e){const[s,r]=e.center;return new Pt(Q(s,r,t.z),e.radius)}function Xt(t,e){return tt(e.center[2],t.z)?e:void 0}const $t=(()=>{const t=b();return(e,s)=>Jt(e.getPlane(t),s,s.slicePlane)})();function te(t,{center:e,radius:s}){const r=Math.abs(e[2]-t.z);if(r>s&&!tt(r,s))return;const n=Q(e[0],e[1],t.z),i=Math.sqrt(s**2-r**2);return tt(i,0)?void 0:new Pt(n,i)}const ee=(()=>{const t=b();return(e,{center:s,radius:r})=>{const n=ut(e.planeLike,s,r),i=s[2];e.getSlicePlane(t);const o=new Array;for(const[c,u]of n){const e=[c,u,i];lt(t,e)&&o.push(e)}return pe(o)}})(),se=(()=>{const t=b(),e=b();return(s,r)=>Jt(s.getPlane(t),r,s.getSlicePlane(e))})(),re=(()=>{const t=b();return(e,{center:s,radius:r})=>{const n=e.getPlane(t),i=U(n,s),o=Math.abs(i);if(o>r&&!tt(o,r))return;const c=Math.sqrt(r**2-i**2);if(tt(c,0)){const t=J();return Z(n,s,t),new gt(t)}const u=J(),a=M(I(n));return p(u,s,a,i),new zt(u,c,a,e.getSlicePlane())}})();function ne(t,e){}function ie(t,e){const s=i(B(t.center),B(e.center));if(tt(s,0)&&tt(t.radius,e.radius))return e;return me(at(B(t.center),t.radius,B(e.center),e.radius),e.center[2])}function oe(t,e){}function ce(t,e){}function ue(t,e){}function ae(t,e){if(!ft(t.center,e.center))return;const s=i(B(t.center),B(e.center));if(tt(s,0)&&tt(t.radius,e.radius))return t;return me(at(B(t.center),t.radius,B(e.center),e.radius),t.center[2])}function he(t,e){}function fe(t,e){}function le(t,e){const{planeLike:s,getZ:r}=t,n=new Array;if(Le(e))t.addIfOnTheGround(n,ht(s,e.point));else if(ke(e))t.addIfOnTheGround(n,nt(s,e.lineLike));else if(Pe(e))for(const[i,o]of ut(s,e.center,e.radius)){const t=r(i,o);null!=t&&n.push(z(i,o,t))}else if(ye(e)||qe(e))for(const[i,o]of ct(s,e.planeLike)){const t=r(i,o)??ve;n.push(z(i,o,t))}return pe(n)}function de(t){return ge(t.map((([t,e])=>{const s=Q(t,e,0),r=Q(t,e,1);return new Lt(s,r)})))}function pe(t){return ge(t.map((t=>t?new gt(W(t)):void 0)))}function me(t,e){return pe(t.map((([t,s])=>[t,s,e])))}function ge(e){if(0!==e.length)return 1===e.length?e[0]??void 0:new xt(e.filter(t))}function _e(t){return t instanceof xt}function Le(t){return t instanceof gt}function ke(t){return t instanceof _t}function xe(t){return t instanceof qt}function ye(t){return t instanceof jt}function Pe(t){return t instanceof yt}function ze(t){return t instanceof Pt}function Me(t){return t instanceof zt}function Te(t){return t instanceof Nt}function qe(t){return t instanceof Ut}function we(t){return t instanceof It}function je(t){return t instanceof Zt}const ve=0;export{zt as CircleConstraint,mt as Constraint,Zt as CoordinateConstraint,Ut as DrapedLineConstraint,It as GeodesicConstraint,Pt as HorizontalCircleConstraint,qt as HorizontalPlaneConstraint,Lt as LineConstraint,_t as LineLikeConstraint,gt as PointConstraint,kt as RayConstraint,xt as SetConstraint,Nt as SphereConstraint,yt as VerticalCylinderConstraint,Et as VerticalHalfPlaneConstraint,Rt as VerticalPlaneConstraint,jt as VerticalPlaneLikeConstraint,ge as constraintOrSet,Le as isPoint};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{memoize as i}from"../../../../core/memoize.js";import{throwIfAborted as r,whenOrAbort as n}from"../../../../core/promiseUtils.js";import{watch as o,on as a,initial as s}from"../../../../core/reactiveUtils.js";import{sqlAnd as l}from"../../../../core/sql.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as y}from"../../../../core/accessorSupport/decorators/subclass.js";import{elevationContextAffectsAlignment as c}from"../../../../support/elevationInfoUtils.js";import{makeSnappingQuery as u}from"../snappingUtils.js";import{convertSnappingCandidate as g,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 f=class extends t{get availability(){return 1}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,i=null!=e&&"3d"===e.type;if(!i||"subtype-group"===t.type)return m();const r=async(i,r)=>(await n(e.whenLayerView(t),r)).elevationAlignPointsInFeatures(i,r);return m(i,{elevationInfo:t.elevationInfo,alignPointsInFeatures:r})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"subtype-group"!==this.layerSource.layer.type;return d(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource;return null!=e&&"3d"===e.type&&"subtype-group"!==t.type?v(this._symbologySnappingSupported,(async(i,n)=>{const o=await e.whenLayerView(t);return r(n),o.queryForSymbologySnapping({candidates:i,spatialReference:e.spatialReference},n)})):v()}get _layerView(){const{view:e}=this;if(null==e)return null;const{layer:t}=this.layerSource;return e.allLayerViews.find((e=>e.layer===t))}get _layerView3D(){const{view:e}=this;return null==e||"2d"===e.type?null:this._layerView}get _symbologySnappingSupported(){return null!=this._layerView3D&&this._layerView3D.symbologySnappingSupported}initialize(){const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"subtype-group"!==t.type&&this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{const{elevationInfo:i}=t;c(e,i)&&this._snappingElevationAligner.notifyElevationSourceChange()})),o((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),s),o((()=>null!=this._layerView3D?this._layerView3D.layer?.renderer:null),(()=>this._symbologySnappingFetcher.notifySymbologyChange()),s),a((()=>this._layerView3D?.layer),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))])}constructor(e){super(e),this.view=null,this.updating=!1,this._memoizedMakeGetGroundElevation=i(h)}refresh(){}async fetchCandidates(e,t){const{layer:i}=this.layerSource,{source:n}=i;if(!n?.querySnapping)return[];const o=i.createQuery();this._layerView&&"effectiveDisplayFilter"in this._layerView&&(o.where=l(o.where,this._layerView.effectiveDisplayFilter?.where));const a="returnZ"in i?i.returnZ:void 0,s=u({parameters:e,mode:this.view?.type??"2d",returnZ:a,filter:o}),p=await n.querySnapping(s,{signal:t});r(t);const y=e.coordinateHelper.spatialReference,c=await this._snappingElevationAligner.alignCandidates(p.candidates,y,t);r(t);const h=await this._symbologySnappingFetcher.fetch(c,t);r(t);const m=0===h.length?c:[...c,...h],d=this._snappingElevationFilter.filter(s,m),v=this._memoizedMakeGetGroundElevation(this.view,y);return d.map((e=>g(e,v)))}};e([p({constructOnly:!0})],f.prototype,"layerSource",void 0),e([p({constructOnly:!0})],f.prototype,"view",void 0),e([p()],f.prototype,"_snappingElevationAligner",null),e([p()],f.prototype,"_snappingElevationFilter",null),e([p()],f.prototype,"_symbologySnappingFetcher",null),e([p()],f.prototype,"_layerView",null),e([p()],f.prototype,"_layerView3D",null),e([p()],f.prototype,"_symbologySnappingSupported",null),f=e([y("esri.views.interactive.snapping.featureSources.FeatureCollectionSnappingSource")],f);export{f as FeatureCollectionSnappingSource};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{memoize as i}from"../../../../core/memoize.js";import{throwIfAborted as r,whenOrAbort as n}from"../../../../core/promiseUtils.js";import{watch as o,on as a,initial as s}from"../../../../core/reactiveUtils.js";import{sqlAnd as l}from"../../../../core/sql.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as y}from"../../../../core/accessorSupport/decorators/subclass.js";import{elevationContextAffectsAlignment as c}from"../../../../support/elevationInfoUtils.js";import{makeSnappingQuery as u}from"../snappingUtils.js";import{makeGetGroundElevation as g,convertSnappingCandidate 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 f=class extends t{get availability(){return 1}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,i=null!=e&&"3d"===e.type;if(!i||"subtype-group"===t.type)return m();const r=async(i,r)=>(await n(e.whenLayerView(t),r)).elevationAlignPointsInFeatures(i,r);return m(i,{elevationInfo:t.elevationInfo,alignPointsInFeatures:r})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"subtype-group"!==this.layerSource.layer.type;return d(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource;return null!=e&&"3d"===e.type&&"subtype-group"!==t.type?v(this._symbologySnappingSupported,(async(i,n)=>{const o=await e.whenLayerView(t);return r(n),o.queryForSymbologySnapping({candidates:i,spatialReference:e.spatialReference},n)})):v()}get _layerView(){const{view:e}=this;if(null==e)return null;const{layer:t}=this.layerSource;return e.allLayerViews.find((e=>e.layer===t))}get _layerView3D(){const{view:e}=this;return null==e||"2d"===e.type?null:this._layerView}get _symbologySnappingSupported(){return null!=this._layerView3D&&this._layerView3D.symbologySnappingSupported}initialize(){const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"subtype-group"!==t.type&&this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{const{elevationInfo:i}=t;c(e,i)&&this._snappingElevationAligner.notifyElevationSourceChange()})),o((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),s),o((()=>null!=this._layerView3D?this._layerView3D.layer?.renderer:null),(()=>this._symbologySnappingFetcher.notifySymbologyChange()),s),a((()=>this._layerView3D?.layer),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))])}constructor(e){super(e),this.view=null,this.updating=!1,this._memoizedMakeGetGroundElevation=i(g)}refresh(){}async fetchCandidates(e,t){const{layer:i}=this.layerSource,{source:n}=i;if(!n?.querySnapping)return[];const o=i.createQuery();this._layerView&&"effectiveDisplayFilter"in this._layerView&&(o.where=l(o.where,this._layerView.effectiveDisplayFilter?.where));const a="returnZ"in i?i.returnZ:void 0,s=u({parameters:e,mode:this.view?.type??"2d",returnZ:a,filter:o}),p=await n.querySnapping(s,{signal:t});r(t);const y=e.coordinateHelper.spatialReference,c=await this._snappingElevationAligner.alignCandidates(p.candidates,y,t);r(t);const g=await this._symbologySnappingFetcher.fetch(c,t);r(t);const m=0===g.length?c:[...c,...g],d=this._snappingElevationFilter.filter(s,m),v=this._memoizedMakeGetGroundElevation(this.view,y);return d.map((e=>h(e,v)))}};e([p({constructOnly:!0})],f.prototype,"layerSource",void 0),e([p({constructOnly:!0})],f.prototype,"view",void 0),e([p()],f.prototype,"_snappingElevationAligner",null),e([p()],f.prototype,"_snappingElevationFilter",null),e([p()],f.prototype,"_symbologySnappingFetcher",null),e([p()],f.prototype,"_layerView",null),e([p()],f.prototype,"_layerView3D",null),e([p()],f.prototype,"_symbologySnappingSupported",null),f=e([y("esri.views.interactive.snapping.featureSources.FeatureCollectionSnappingSource")],f);export{f 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{destroyHandle as i}from"../../../../core/handleUtils.js";import{memoize as s}from"../../../../core/memoize.js";import{throwIfAborted as o,ignoreAbortErrors as a}from"../../../../core/promiseUtils.js";import{watch as n,on as l,initial as d,sync as u,syncAndInitial as p}from"../../../../core/reactiveUtils.js";import{sqlAnd as h}from"../../../../core/sql.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as y}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as f}from"../../../../core/support/UpdatingHandles.js";import{isSubtypeGroupLayer as m}from"../../../../layers/support/layerUtils.js";import{elevationContextAffectsAlignment as _}from"../../../../support/elevationInfoUtils.js";import{FeatureServiceTiles2D as g}from"../../../2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js";import{FeatureServiceTiles3D as w}from"../../../3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js";import{isUtilityNetworkWebMap as S}from"../snappingUtils.js";import{convertSnappingCandidate as v,makeGetGroundElevation as b}from"./queryEngineUtils.js";import{WorkerTileTreeDebugger as I}from"./WorkerTileTreeDebugger.js";import{FeatureServiceSnappingSourceWorkerHandle as H}from"./featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js";import{FeatureServiceTilesSimple as j}from"./featureServiceSource/FeatureServiceTilesSimple.js";import F from"../../../support/debugFlags.js";let O=class extends t{get _updateTilesParameters(){return{tiles:this._tilesOfInterest.tiles,tileInfo:this._tilesOfInterest.tileInfo,tileSize:this._tilesOfInterest.tileSize}}get _layerView(){return this.view?.allLayerViews.find((e=>e.layer===this._layer))}get _isSuspended(){if(m(this._layer)){if(!this.layerSource.sublayerSources.some((e=>e.enabled&&e.layer.visible)))return!0}return!!this.view&&(!1!==this._layerView?.suspended||!this.layerSource.enabled)}get updating(){return this._workerHandle?.updating||this._updatingHandles.updating}get _outFields(){const{view:e,_layerView:t,layerSource:r}=this,{layer:i}=r,{fieldsIndex:s,timeInfo:o,floorInfo:a,subtypeField:n}=i,l=t&&"filter"in t?t.filter:null,d=l?.where&&"1=1"!==l.where?this._getOrLoadWhereFields(l.where,s):[];if(l?.timeExtent&&o){const{startField:e,endField:t}=o,r=s.get(e)?.name??e,i=s.get(t)?.name??t;r&&d.push(r),i&&d.push(i)}if(e?.map&&S(e.map)&&e.map.utilityNetworks?.find((e=>e.isUtilityLayer(i)))){const e=i.fieldsIndex.get("assetGroup")?.name,t=i.fieldsIndex.get("assetType")?.name;e&&t&&(d.push(e),d.push(t))}if(i&&a?.floorField&&e?.floors?.length){const e=s.get(a.floorField)?.name??a.floorField;e&&d.push(e)}if(n){const e=s.get(n)?.name??n;e&&d.push(e)}return new Set(d)}get configuration(){const{view:e}=this,{apiKey:t,customParameters:r}=this._layer,i=null!=e?e.type:"2d",s=this._layer.createQuery();return this._layerView&&"effectiveDisplayFilter"in this._layerView&&(s.where=h(s.where,this._layerView.effectiveDisplayFilter?.where)),{filter:s,customParameters:t?{...r,token:t}:r,viewType:i}}get availability(){return this._workerHandle?.availability??0}get _layer(){return this.layerSource.layer}constructor(e){super(e),this._updatingHandles=new f,this._workerHandle=null,this._debug=null,this._memoizedMakeGetGroundElevation=s(b)}initialize(){let e;const t=this.view;if(null==t||t.destroyed)this._tilesOfInterest=new j({layer:this._layer}),e=this._workerHandle=new H;else switch(t.type){case"2d":this._tilesOfInterest=new g({view:t,layer:this._layer}),e=this._workerHandle=new H;break;case"3d":{const{resourceController:r}=t,i=this._layer;this._tilesOfInterest=new w({view:t}),e=this._workerHandle=new H({schedule:e=>r.immediate.schedule(e),hasZ:this._layer.hasZ&&(this._layer.returnZ??!0),elevationAlignPointsInFeatures:async(e,r)=>{const s=await t.whenLayerView(i);return o(r),s.elevationAlignPointsInFeatures(e,r)},queryForSymbologySnapping:async(e,r)=>{const s=await t.whenLayerView(i);return o(r),s.queryForSymbologySnapping(e,r)}}),this.addHandles([t.elevationProvider.on("elevation-change",(({context:t})=>{const{elevationInfo:r}=i;_(t,r)&&a(e.notifyElevationSourceChange())})),n((()=>i.elevationInfo),(()=>a(e.notifyElevationSourceChange())),d),n((()=>this._layerView?.layer?.renderer),(()=>a(e.notifySymbologyChange())),d),n((()=>this._layerView?.symbologySnappingSupported??!1),(t=>a(e.setSymbologySnappingSupported(t))),d),l((()=>this._layerView?.layer),["edits","apply-edits","graphic-update"],(()=>e.notifySymbologyChange()))]);break}}this.addHandles([i(e)]),a(e.setup({layer:this._layer,spatialReference:this.spatialReference,configuration:this.configuration},null)),this._updatingHandles.add((()=>this._updateTilesParameters),(()=>a(e.updateTiles(this._updateTilesParameters,null))),d),this.addHandles([n((()=>this.configuration),(t=>a(e.configure(t,null))),u),n((()=>this._layer.historicMoment),(t=>a(e.setHistoricMoment(t))),p),n((()=>this._outFields),(t=>a(e.updateOutFields(t))),d),n((()=>this._isSuspended),(t=>a(e.setSuspended(t))),p)]),null!=t&&this.addHandles(n((()=>F.FEATURE_SERVICE_SNAPPING_SOURCE_TILE_TREE_SHOW_TILES),(r=>{r&&!this._debug?(this._debug=new I({view:t,handle:e}),this.addHandles(i(this._debug),"debug")):!r&&this._debug&&this.removeHandles("debug")}),d)),this.addHandles([this.layerSource.layer.on("edits",(t=>a(e.handleEdits(t,null)))),this.layerSource.layer.on("apply-edits",(e=>this._updatingHandles.addPromise(e.result)))])}destroy(){this._updatingHandles.destroy(),this._tilesOfInterest.destroy()}refresh(){this._workerHandle?.refresh(null)}async fetchCandidates(e,t){const{coordinateHelper:r,point:i}=e;this._tilesOfInterest.pointOfInterest=r.arrayToPoint(i);const s=this._memoizedMakeGetGroundElevation(this.view,r.spatialReference);return(await this._workerHandle.fetchCandidates({...e},t)).candidates.map((e=>v(e,s)))}getDebugInfo(e){return this._workerHandle.getDebugInfo(e)}_getOrLoadWhereFields(e,t){const{_whereModule:i}=this;if(!this._loadWhereModuleTask&&!i){const e=r((async()=>{const e=await import("../../../../core/sql/WhereClause.js");return this._whereModule=e.default,this._whereModule}));return this._loadWhereModuleTask=e,this._updatingHandles.addPromise(e.promise),[]}if(!i)return[];try{return i.create(e,{fieldsIndex:t}).fieldNames}catch(s){return[]}}};e([c({constructOnly:!0})],O.prototype,"spatialReference",void 0),e([c({constructOnly:!0})],O.prototype,"layerSource",void 0),e([c({constructOnly:!0})],O.prototype,"view",void 0),e([c()],O.prototype,"_tilesOfInterest",void 0),e([c({readOnly:!0})],O.prototype,"_updateTilesParameters",null),e([c()],O.prototype,"_layerView",null),e([c()],O.prototype,"_isSuspended",null),e([c({readOnly:!0})],O.prototype,"updating",null),e([c()],O.prototype,"_outFields",null),e([c({readOnly:!0})],O.prototype,"configuration",null),e([c({readOnly:!0})],O.prototype,"availability",null),e([c()],O.prototype,"_loadWhereModuleTask",void 0),e([c()],O.prototype,"_whereModule",void 0),O=e([y("esri.views.interactive.snapping.featureSources.FeatureServiceSnappingSource")],O);export{O as FeatureServiceSnappingSource};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{destroyHandle as i}from"../../../../core/handleUtils.js";import{memoize as s}from"../../../../core/memoize.js";import{throwIfAborted as o,ignoreAbortErrors as a}from"../../../../core/promiseUtils.js";import{watch as n,on as l,initial as d,sync as u,syncAndInitial as p}from"../../../../core/reactiveUtils.js";import{sqlAnd as h}from"../../../../core/sql.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as y}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as f}from"../../../../core/support/UpdatingHandles.js";import{isSubtypeGroupLayer as m}from"../../../../layers/support/layerUtils.js";import{elevationContextAffectsAlignment as _}from"../../../../support/elevationInfoUtils.js";import{FeatureServiceTiles2D as g}from"../../../2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js";import{FeatureServiceTiles3D as w}from"../../../3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js";import{isUtilityNetworkWebMap as S}from"../snappingUtils.js";import{makeGetGroundElevation as v,convertSnappingCandidate as b}from"./queryEngineUtils.js";import{WorkerTileTreeDebugger as I}from"./WorkerTileTreeDebugger.js";import{FeatureServiceSnappingSourceWorkerHandle as H}from"./featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js";import{FeatureServiceTilesSimple as j}from"./featureServiceSource/FeatureServiceTilesSimple.js";import F from"../../../support/debugFlags.js";let O=class extends t{get _updateTilesParameters(){return{tiles:this._tilesOfInterest.tiles,tileInfo:this._tilesOfInterest.tileInfo,tileSize:this._tilesOfInterest.tileSize}}get _layerView(){return this.view?.allLayerViews.find((e=>e.layer===this._layer))}get _isSuspended(){if(m(this._layer)){if(!this.layerSource.sublayerSources.some((e=>e.enabled&&e.layer.visible)))return!0}return!!this.view&&(!1!==this._layerView?.suspended||!this.layerSource.enabled)}get updating(){return this._workerHandle?.updating||this._updatingHandles.updating}get _outFields(){const{view:e,_layerView:t,layerSource:r}=this,{layer:i}=r,{fieldsIndex:s,timeInfo:o,floorInfo:a,subtypeField:n}=i,l=t&&"filter"in t?t.filter:null,d=l?.where&&"1=1"!==l.where?this._getOrLoadWhereFields(l.where,s):[];if(l?.timeExtent&&o){const{startField:e,endField:t}=o,r=s.get(e)?.name??e,i=s.get(t)?.name??t;r&&d.push(r),i&&d.push(i)}if(e?.map&&S(e.map)&&e.map.utilityNetworks?.find((e=>e.isUtilityLayer(i)))){const e=i.fieldsIndex.get("assetGroup")?.name,t=i.fieldsIndex.get("assetType")?.name;e&&t&&(d.push(e),d.push(t))}if(i&&a?.floorField&&e?.floors?.length){const e=s.get(a.floorField)?.name??a.floorField;e&&d.push(e)}if(n){const e=s.get(n)?.name??n;e&&d.push(e)}return new Set(d)}get configuration(){const{view:e}=this,{apiKey:t,customParameters:r}=this._layer,i=null!=e?e.type:"2d",s=this._layer.createQuery();return this._layerView&&"effectiveDisplayFilter"in this._layerView&&(s.where=h(s.where,this._layerView.effectiveDisplayFilter?.where)),{filter:s,customParameters:t?{...r,token:t}:r,viewType:i}}get availability(){return this._workerHandle?.availability??0}get _layer(){return this.layerSource.layer}constructor(e){super(e),this._updatingHandles=new f,this._workerHandle=null,this._debug=null,this._memoizedMakeGetGroundElevation=s(v)}initialize(){let e;const t=this.view;if(null==t||t.destroyed)this._tilesOfInterest=new j({layer:this._layer}),e=this._workerHandle=new H;else switch(t.type){case"2d":this._tilesOfInterest=new g({view:t,layer:this._layer}),e=this._workerHandle=new H;break;case"3d":{const{resourceController:r}=t,i=this._layer;this._tilesOfInterest=new w({view:t}),e=this._workerHandle=new H({schedule:e=>r.immediate.schedule(e),hasZ:this._layer.hasZ&&(this._layer.returnZ??!0),elevationAlignPointsInFeatures:async(e,r)=>{const s=await t.whenLayerView(i);return o(r),s.elevationAlignPointsInFeatures(e,r)},queryForSymbologySnapping:async(e,r)=>{const s=await t.whenLayerView(i);return o(r),s.queryForSymbologySnapping(e,r)}}),this.addHandles([t.elevationProvider.on("elevation-change",(({context:t})=>{const{elevationInfo:r}=i;_(t,r)&&a(e.notifyElevationSourceChange())})),n((()=>i.elevationInfo),(()=>a(e.notifyElevationSourceChange())),d),n((()=>this._layerView?.layer?.renderer),(()=>a(e.notifySymbologyChange())),d),n((()=>this._layerView?.symbologySnappingSupported??!1),(t=>a(e.setSymbologySnappingSupported(t))),d),l((()=>this._layerView?.layer),["edits","apply-edits","graphic-update"],(()=>e.notifySymbologyChange()))]);break}}this.addHandles([i(e)]),a(e.setup({layer:this._layer,spatialReference:this.spatialReference,configuration:this.configuration},null)),this._updatingHandles.add((()=>this._updateTilesParameters),(()=>a(e.updateTiles(this._updateTilesParameters,null))),d),this.addHandles([n((()=>this.configuration),(t=>a(e.configure(t,null))),u),n((()=>this._layer.historicMoment),(t=>a(e.setHistoricMoment(t))),p),n((()=>this._outFields),(t=>a(e.updateOutFields(t))),d),n((()=>this._isSuspended),(t=>a(e.setSuspended(t))),p)]),null!=t&&this.addHandles(n((()=>F.FEATURE_SERVICE_SNAPPING_SOURCE_TILE_TREE_SHOW_TILES),(r=>{r&&!this._debug?(this._debug=new I({view:t,handle:e}),this.addHandles(i(this._debug),"debug")):!r&&this._debug&&this.removeHandles("debug")}),d)),this.addHandles([this.layerSource.layer.on("edits",(t=>a(e.handleEdits(t,null)))),this.layerSource.layer.on("apply-edits",(e=>this._updatingHandles.addPromise(e.result)))])}destroy(){this._updatingHandles.destroy(),this._tilesOfInterest.destroy()}refresh(){this._workerHandle?.refresh(null)}async fetchCandidates(e,t){const{coordinateHelper:r,point:i}=e;this._tilesOfInterest.pointOfInterest=r.arrayToPoint(i);const s=this._memoizedMakeGetGroundElevation(this.view,r.spatialReference);return(await this._workerHandle.fetchCandidates({...e},t)).candidates.map((e=>b(e,s)))}getDebugInfo(e){return this._workerHandle.getDebugInfo(e)}_getOrLoadWhereFields(e,t){const{_whereModule:i}=this;if(!this._loadWhereModuleTask&&!i){const e=r((async()=>{const e=await import("../../../../core/sql/WhereClause.js");return this._whereModule=e.default,this._whereModule}));return this._loadWhereModuleTask=e,this._updatingHandles.addPromise(e.promise),[]}if(!i)return[];try{return i.create(e,{fieldsIndex:t}).fieldNames}catch(s){return[]}}};e([c({constructOnly:!0})],O.prototype,"spatialReference",void 0),e([c({constructOnly:!0})],O.prototype,"layerSource",void 0),e([c({constructOnly:!0})],O.prototype,"view",void 0),e([c()],O.prototype,"_tilesOfInterest",void 0),e([c({readOnly:!0})],O.prototype,"_updateTilesParameters",null),e([c()],O.prototype,"_layerView",null),e([c()],O.prototype,"_isSuspended",null),e([c({readOnly:!0})],O.prototype,"updating",null),e([c()],O.prototype,"_outFields",null),e([c({readOnly:!0})],O.prototype,"configuration",null),e([c({readOnly:!0})],O.prototype,"availability",null),e([c()],O.prototype,"_loadWhereModuleTask",void 0),e([c()],O.prototype,"_whereModule",void 0),O=e([y("esri.views.interactive.snapping.featureSources.FeatureServiceSnappingSource")],O);export{O as FeatureServiceSnappingSource};