@arcgis/core 4.32.0-next.20250107 → 4.32.0-next.20250108

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 (99) hide show
  1. package/WebLinkChart.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{07304287ed5244fa4e12.js → 12b2c8251ec2d0e2ca46.js} +1 -1
  4. package/assets/esri/core/workers/chunks/24a597ae32a2083a50a5.js +1 -0
  5. package/assets/esri/core/workers/chunks/510cb8647841fec436c8.js +1 -0
  6. package/assets/esri/core/workers/chunks/{f6d6bc43ac1c13892d44.js → 58485909e1cfeb52c01e.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{c49707b577f3805f0142.js → 5b61a1e7ac60a02a906d.js} +1 -1
  8. package/assets/esri/core/workers/chunks/76a7114a69264f5c07b0.js +2 -0
  9. package/assets/esri/core/workers/chunks/{ca1e186f136abb23ae4b.js → 7d0fc25ce1f74adcfeb6.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{dca0eb66116e4b5403fc.js → 7df076d15b7b7a66dcee.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{955421ee2247965244f0.js → 7fe92f072d3641ec4662.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{4423aac6e44c3dbf184e.js → 89286d8f59844724cd16.js} +1 -1
  13. package/assets/esri/core/workers/chunks/a8ec4189ec3b37d5ff74.js +1 -0
  14. package/assets/esri/core/workers/chunks/cd92b80de7e9f982f9a9.js +1 -0
  15. package/chunks/CrackAndCluster-CfzXpEle.js +1 -1
  16. package/chunks/LineSeries.js +1 -1
  17. package/chunks/OperatorProject.js +1 -1
  18. package/chunks/Pattern.glsl.js +1 -1
  19. package/chunks/QuadraticBezier.js +1 -1
  20. package/chunks/Transformation2D.js +1 -1
  21. package/chunks/chartUtilsAm5.js +1 -1
  22. package/chunks/lyr3DWorker.js +1 -1
  23. package/chunks/vxlLayer.js +1 -1
  24. package/geometry/support/meshUtils/primitives.js +1 -1
  25. package/geometry/support/triangle.js +1 -1
  26. package/interfaces.d.ts +175 -91
  27. package/layers/LinkChartLayer.js +1 -1
  28. package/layers/MapNotesLayer.js +1 -1
  29. package/layers/MediaLayer.js +1 -1
  30. package/layers/support/ImageElement.js +1 -1
  31. package/layers/support/VideoElement.js +1 -1
  32. package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
  33. package/layers/video/VideoController.js +1 -1
  34. package/linkChart/OrganicLayoutSettings.js +1 -1
  35. package/package.json +3 -3
  36. package/smartMapping/renderers/color.js +1 -1
  37. package/smartMapping/renderers/size.js +1 -1
  38. package/smartMapping/renderers/univariateColorSize.js +1 -1
  39. package/support/mediaLayerUtils.js +5 -0
  40. package/support/revision.js +1 -1
  41. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  42. package/symbols/cim/placements/PlacementInsidePolygon.js +1 -1
  43. package/views/2d/AnimationManager.js +1 -1
  44. package/views/2d/engine/vectorTiles/buckets/FillBucket.js +1 -1
  45. package/views/2d/engine/webgl/Overlay.js +1 -1
  46. package/views/2d/engine/webgl/SDFConverter.js +1 -1
  47. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  48. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/hittestUtils.js +1 -1
  49. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  50. package/views/2d/layers/features/support/GraphicsReader.js +1 -1
  51. package/views/2d/navigation/MapViewNavigation.js +1 -1
  52. package/views/2d/support/HighlightGroup.js +1 -1
  53. package/views/3d/analysis/Slice/ShiftManipulator.js +1 -1
  54. package/views/3d/analysis/Viewshed/FieldOfViewManipulation.js +1 -1
  55. package/views/3d/analysis/support/measurementUtils.js +1 -1
  56. package/views/3d/environment/CloudsParameters.js +1 -1
  57. package/views/3d/environment/MarsAtmosphere.js +1 -1
  58. package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
  59. package/views/3d/layers/MediaLayerView3D.js +1 -1
  60. package/views/3d/layers/graphics/placementUtils.js +1 -1
  61. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  62. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  63. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  64. package/views/3d/support/HighlightGroup.js +1 -1
  65. package/views/3d/terrain/SphericalPatch.js +1 -1
  66. package/views/3d/terrain/TilePerLayerInfo.js +1 -1
  67. package/views/3d/terrain/TileRenderer.js +1 -1
  68. package/views/3d/terrain/TileTexture.js +1 -1
  69. package/views/3d/webgl-engine/collections/Component/ComponentIntersectionData.js +1 -1
  70. package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
  71. package/views/3d/webgl-engine/lib/PathProfile.js +1 -1
  72. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  73. package/views/SceneView.js +1 -1
  74. package/views/View.js +1 -1
  75. package/views/input/BrowserEventSource.js +1 -1
  76. package/views/layers/MediaLayerView.js +1 -1
  77. package/views/support/HighlightGroup.d.ts +4 -0
  78. package/views/support/HighlightGroup.js +5 -0
  79. package/views/webgl/Texture.js +1 -1
  80. package/views/webgl/textureUtils.js +1 -1
  81. package/webscene/Slide.js +1 -1
  82. package/widgets/BasemapLayerList.js +1 -1
  83. package/widgets/BuildingExplorer/BuildingLevelPicker/BuildingLevelPicker.js +1 -1
  84. package/widgets/CatalogLayerList.js +1 -1
  85. package/widgets/FeatureTable/support/exportUtils.js +1 -1
  86. package/widgets/LayerList/support/layerListUtils.js +1 -1
  87. package/widgets/LayerList.js +1 -1
  88. package/widgets/Legend/styles/support/relationshipUtils.js +1 -1
  89. package/widgets/PanoramicViewer/utils.js +1 -1
  90. package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
  91. package/widgets/Sketch/SketchViewModel.js +1 -1
  92. package/widgets/TableList.js +1 -1
  93. package/assets/esri/core/workers/chunks/127c82cdb229434883b6.js +0 -1
  94. package/assets/esri/core/workers/chunks/66b411119b8ffb99b9dc.js +0 -1
  95. package/assets/esri/core/workers/chunks/8cd2c9ec1e541836b81c.js +0 -1
  96. package/assets/esri/core/workers/chunks/b07710e01494a6cda097.js +0 -1
  97. package/assets/esri/core/workers/chunks/c05e0bd145a1c27d6857.js +0 -2
  98. package/views/2d/support/HighlightGroup.d.ts +0 -4
  99. /package/assets/esri/core/workers/chunks/{c05e0bd145a1c27d6857.js.LICENSE.txt → 76a7114a69264f5c07b0.js.LICENSE.txt} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{symbolTypes as t}from"../../symbols.js";import o from"../../core/Collection.js";import i from"../../core/Error.js";import a from"../../core/Evented.js";import{drainHandles as r}from"../../core/handleUtils.js";import"../../core/has.js";import s from"../../core/Logger.js";import{destroyMaybe as n,abortMaybe as p}from"../../core/maybe.js";import{createAbortError as l,whenOrAbort as c}from"../../core/promiseUtils.js";import{on as h,watch as d,when as u,whenOnce as y,syncAndInitial as m}from"../../core/reactiveUtils.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{getReferenceEllipsoid as f}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as _,isLoaded as b,load as w,project as G}from"../../geometry/projection.js";import{geometryToCoordinates as O}from"../../geometry/support/coordsUtils.js";import{equals as T}from"../../geometry/support/spatialReferenceUtils.js";import E from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as S}from"../../layers/support/layerUtils.js";import{SupportedObjectResult as A,isSupportedObjectResultMessage as k}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as M}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as C}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as D}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as H}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as R}from"../../views/input/InputManager.js";import{sketchKeys as j}from"../../views/interactive/keybindings.js";import I from"../../views/interactive/sketch/SketchLabelOptions.js";import U from"../../views/interactive/sketch/SketchOptions.js";import x from"../../views/interactive/sketch/SketchTooltipOptions.js";import P from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as L}from"../../views/interactive/snapping/SnappingManager.js";import F from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as V}from"../../views/interactive/snapping/snappingUtils.js";import{findFirstGraphicHit as K}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as W}from"../../views/support/screenUtils.js";import{CreateOperationHandle as Z,UpdateOperationHandle as q}from"./support/OperationHandle.js";import z from"../../symbols/SimpleMarkerSymbol.js";import N from"../../symbols/SimpleFillSymbol.js";import B from"../../symbols/SimpleLineSymbol.js";import $ from"../../symbols/MeshSymbol3D.js";import Y from"../../symbols/FillSymbol3DLayer.js";const J={defaultZ:0},Q={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move"},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0},tool:"transform"};let X=class extends a.EventedAccessor{constructor(e){super(e),this._numUpdating=0,this._defaultSnappingManager=null,this._internalGraphicsLayer=new E({listMode:"hide",internal:!0,title:"SVM Internal"}),this._operationHandle=null,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.layer=null,this.pointSymbol=new z({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new N({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new B({color:[130,130,130,1],width:2}),this.meshSymbol=new $({symbolLayers:new o([new Y])}),this.updateGraphics=new o,this.updateOnGraphicClick=!0,this.vertexSymbol=new z({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new U,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._originalPopupEnabled=null,this.defaultCreateOptions=J,this.defaultUpdateOptions=Q,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new F}initialize(){this.addHandles([h((()=>this.view?.map?.layers),"change",(e=>{e.removed.includes(this.layer)&&this.cancel()})),h((()=>this.layer?.graphics),"change",(e=>{if(null!=this._operationHandle)for(const t of e.removed)this.updateGraphics.includes(t)&&(this.updateGraphics.length>1?this._operationHandle.removeFromSelection(t):this._operationHandle.cancel())})),d((()=>this.layer?.elevationInfo??null),(e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer.elevationInfo=e)}),m),d((()=>this.view),(e=>{this._defaultSnappingManager=n(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new L({view:e,options:this.snappingOptions})),"2d"===e.type?import("../../views/2d/interactive/editingTools.js"):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))}),m),d((()=>this.view?.spatialReference),((e,t)=>{e&&t&&!e.equals(t)&&this.cancel()}))]),V(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=n(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this.emit("destroy")}get updating(){return this._numUpdating>0||null!=this.snappingManager&&this.snappingManager.updating}get activeTool(){return this._operationHandle?.tool??null}get activeTooltip(){const{activeComponent:e,destroyed:t}=this,o=!t&&e&&"tooltip"in e?e.tooltip:null;return o?.visible?o:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return null==this.activeComponent||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):this.activeComponent.graphic}get defaultCreateOptions(){return this._get("defaultCreateOptions")}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...J,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...Q,...e,reshapeOptions:{...Q.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...Q.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get snappingOptions(){return this.snappingManager?.options??this._get("snappingOptions")}set snappingOptions(e){null!=this._defaultSnappingManager&&(this._defaultSnappingManager.options=e),this._set("snappingOptions",e)}get snappingManager(){return this._isOverridden("snappingManager")&&this._get("snappingManager"),this._defaultSnappingManager}set snappingManager(e){if(e)this._isOverridden("snappingManager")||(this._defaultSnappingManager=n(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new L({options:this.snappingOptions,view:e})),this._clearOverride("snappingManager")}}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&(t.cursor=null),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(u((()=>e.ready),(t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)}),m),o),this._set("view",e)}cancel(){this._moduleLoaderAbortController=p(this._moduleLoaderAbortController),this._viewReadyAbortController=p(this._viewReadyAbortController),this._operationHandle&&this._operationHandle.cancel()}complete(){this._operationHandle&&this._operationHandle.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e,layer:o}=this,i=t.toArray();o.removeMany(i),this.cancel(),this._emitDeleteEvent({graphics:i,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map((e=>e.clone())).toArray();return this.layer.addMany(e),this.emit("duplicate",{graphics:e,type:"duplicate"}),e}return[]}async create(e,t){this.cancel(),await this._waitViewReady();const{view:o,layer:i}=this;if(!o||"disabled"===this.state)throw i||this._logMissingLayer(),l();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");H(o,this._internalGraphicsLayer);const a=await this._setupCreateOperation(e,t);if(null==a||this.destroyed)return void o.map.remove(this._internalGraphicsLayer);const r=()=>{if(a===this._operationHandle){const t=this.createGraphic,o=this._operationHandle.cancelled;this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map&&this.view.map.remove(this._internalGraphicsLayer),a.cancelled||null==t||i.add(t),this.emit("create",{graphic:t,state:o?"cancel":"complete",tool:e,toolEventInfo:null,type:"create"})}};a.on("complete",r),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return this.create("mesh",{mode:"click",hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){this.cancel(),await this._waitViewReady();const{layer:o,view:i,state:a}=this;if(!i||"disabled"===a)throw o||this._logMissingLayer(),l();null!=i.activeTool&&(i.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some((e=>e.layer!==o?(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0):null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0))))return;const s=await this._setupUpdateOperation(r,t);this.destroyed||null==s||le(s)||(H(i,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit("update",{graphics:r,state:"start",aborted:!1,tool:s.tool,toolEventInfo:null,type:"update"}))}async _updateSpatialReference(e){const t=this.view;if(t){this._beginAsyncOperation(),e=Array.isArray(e)?e:[e];for(const o of e)null==o.geometry||"mesh"===o.geometry.type||T(o.geometry.spatialReference,t.spatialReference)||(_(o.geometry.spatialReference,t.spatialReference)||b()||await w(),o.geometry=G(o.geometry,t.spatialReference));this._endAsyncOperation()}else this._logMissingView()}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._operationHandle?.toggleTool()}async _getFirstHit(e){const t=this.view;if(!t)return this._logMissingView(),null;if("2d"===t.type){const o=[];t.map.allLayers.forEach((e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)}));const i=await t.hitTest(e,{exclude:o});return K(i.results)}const o=[t.map.ground];t.map.allLayers.forEach((e=>{S(e.type)&&o.push(e)}));const i=await t.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!i.ground.mapPoint||t.map.ground.opacity<1||i.ground.distance-(e.distance??0)>-Math.min(3*i.ground.distance,"global"===t.viewingMode?f(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY)))return e}return null}_generateViewHandles(e){return[e.on("immediate-click",(async t=>{const o="active"===this.state&&"create"===this._operationHandle?.type;if("disabled"===this.state||o||!this.updateOnGraphicClick)return;this._beginAsyncOperation();const i=await t.async((()=>this._getFirstHit(W(t))));let a=null;if(null!=i){const o=i.graphic;this.updateGraphics.includes(o)||o.layer===this.layer?(t.stopPropagation(),a=o):"2d"!==e.type||this._isComponentGraphic(o)||"active"!==this.state||this.cancel()}else"active"===this.state&&this.cancel();null==a||this.updateGraphics.includes(a)||await this.update([a],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}}),this._endAsyncOperation()}),R.WIDGET)]}async _setupCreateOperation(e,t){const o=this.view;if(!o)return this._logMissingView(),null;const i={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},a=await this._setupDrawGraphicTool(e,o,i);return null==a?null:(o.tools.add(a),o.activeTool=a,this._setupCreateOperationHandle(a))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView."),null;if(!t)return this._logMissingView(),null;const{cursor:i,defaultZ:a,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,c="rectangle"===e||"circle"===e?"hybrid":"click",h=l??"rectangle"!==e,d={centered:"rectangle"!==e&&!("circle"===e&&!h),cursor:i,defaultZ:a,forceUniformSize:h,graphicProperties:n,geometryToPlace:s,geometryType:e,graphicSymbol:this._getGraphicSymbolFromTool(e),hasZ:r,mode:p??c,snappingManager:this.snappingManager,snapToScene:!1,view:t};return"2d"===t.type?this._makeDrawGraphicTool2D(d):this._makeDrawGraphicTool3D(d)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return le(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:oe(e.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(le(t)||this.destroyed)return null;const{elevationInfo:o}=this.layer;return new t.module.DrawGraphicTool3D({...e,elevationInfo:o,snapToScene:!0,sketchOptions:this.sketchOptions})}_setupCreateOperationHandle(e){const t=this.view;if(!t)return this._logMissingView(),null;let o=null;const i=e.forceUniformSize,a=e.centered,s=[t.on("key-down",(t=>{if(t.key===j.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===j.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==j.vertexAdd||t.repeat)t.key===j.undo?(t.stopPropagation(),n.undo()):t.key===j.redo?(t.stopPropagation(),n.redo()):t.key!==j.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===j.center&&(t.repeat||(e.centered=!a,t.stopPropagation())):(e.forceUniformSize=!i,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}}),R.WIDGET),t.on("key-up",(t=>{t.key===j.pan?e.enabled=!0:t.key!==j.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===j.center&&(e.centered=a,t.stopPropagation()):(e.forceUniformSize=i,t.stopPropagation())}),R.WIDGET),e.on("vertex-add",(t=>{switch(o=null==o?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:o,tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}})),e.on("cursor-update",(t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})})),e.on("vertex-remove",(t=>{switch(t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}})),e.on("complete",(e=>{this._set("createGraphic",e.graphic),o="complete",e.aborted?n&&n.cancel():n&&n.complete()})),d((()=>this._getGraphicSymbolFromTool(e.geometryType)),(t=>{e.graphicSymbol=t}))],n=new Z({activeComponent:e,tool:e.geometryType,type:"create",onEnd:()=>{r(s),t.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return n}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":return this.polygonSymbol;case"mesh":return this.meshSymbol}}async _setupUpdateOperation(e,t){const{layer:o,view:i}=this;if(!i)return this._logMissingView(),null;const a={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};let r=a.tool??Q.tool;for(const s of e)o.remove(s),o.add(s);if("3d"===i.type){if(0===e.length)return null;switch(r){case"move":return this._setupMove3DOperation(e,a,i,r);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],a,i);case"transform":return this._setupGraphicTransform3DOperation(e,a,i)}}switch(r){case"move":return this._setupMove2DOperation(e,a,i);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,r,a,i);case"transform":if(1===e.length){const t=e[0].geometry?.type;"point"!==t&&"multipoint"!==t||(r="reshape")}return this._setupTransformOrReshape2DOperation(e,r,a,i)}}async _setupMove3DOperation(e,t,o,i,a=!1){const s=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(le(s))return s;const{ManipulatedObject3DGraphic:n,MoveTool3D:p}=s.module,l=new Map,c=()=>{l.forEach((e=>e.destroy())),l.clear()};for(const r of e){const e=new n({view:o,graphic:r}),t=M(e);if(t!==A.SUPPORTED)return c(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${k(t)}).`),null;l.set(r,e)}const h=new p({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(h),h.objects.addMany(Array.from(l.values())),a||this.updateGraphics.addMany(e);const d=[],u=new q({activeComponent:h,tool:i,type:"update",onEnd:()=>{r(d),pe(o,h),c()},undo:()=>{se(this.view,h),ie(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{ae(u,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:e=>{this.updateGraphics.push(e);const t=new n({view:o,graphic:e});l.set(e,t),h.objects.push(t),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);if(u.history.undo.forEach((e=>e.updates.splice(t,1))),u.history.redo.forEach((e=>e.updates.splice(t,1))),this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0===this.updateGraphics.length)return void u.complete();const o=l.get(e);o&&(h.objects.remove(o),o.destroy(),l.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.at(0),a=await this._setupReshape3DOperation(e,t,o,!0);a&&!le(a)&&(u.onEnd(),u.destroy(),this._setUpdateOperationHandle(a,t))}});return d.push(...this._getHandlesForComponent(u,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(u,e,t)),R.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)}),R.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&D(e[0])===A.SUPPORTED){const a=e[0],r=a.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=r&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(a,t,o,i)}return this._setupMove3DOperation(e,t,o,"transform",i)}async _setupPointTransform3DOperation(e,t,o){const i="transform",{enableRotation:a,enableScaling:s,enableZ:n}=t,p=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(le(p))return p;const{TransformTool3D:l,ManipulatedObject3DGraphic:c}=p.module,h=new c({graphic:e,view:o}),d=new l({object:h,view:o,enableRotation:a,enableScaling:s,enableZ:n,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),this.updateGraphics.add(e);const u=[],y=new q({activeComponent:d,tool:i,type:"update",onEnd:()=>{r(u),pe(o,d),h.destroy()},undo:()=>{se(this.view,d),ie(y,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{ae(y,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),y.onEnd(),y.destroy();const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);le(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),y.complete()},toggleTool:()=>{}});return u.push(...this._getHandlesForComponent(y,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(y,e,t)),R.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(y,e)}),R.WIDGET)),y}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:s,enableScaling:n,enableZ:p,preserveAspectRatio:l}=t,c=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(le(c))return c;const{ManipulatedObject3DGraphic:h,ExtentTransformTool:d}=c.module,u=this.view?.inputManager?.isModifierKeyDown(j.constraint),y=new h({view:o,graphic:e}),m=new d({object:y,view:o,enableRotation:s,enableScaling:n,enableZ:p,preserveAspectRatio:!!l!=!!u,sketchOptions:this.sketchOptions});o.tools.add(m),i||this.updateGraphics.add(e);const g=[],v=new q({activeComponent:m,tool:a,type:"update",onEnd:()=>{r(g),pe(o,m),y.destroy()},canUndo:()=>!m.destroyed&&m.canUndo,undo:()=>{m.destroyed||(m.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!m.destroyed&&m.canRedo,redo:()=>{m.destroyed||(m.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),v.onEnd(),v.destroy();const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);le(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),v.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const i=await this._setupReshape3DOperation(e,t,o,!0);i&&!le(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return g.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(v,e,t)),R.WIDGET),o.on("key-down",(e=>this._getCommonUpdateOperationKeyDownHandlers(v,e)),R.WIDGET),o.on("key-down",(e=>{e.key!==j.constraint||e.repeat||(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())}),R.WIDGET),o.on("key-up",(e=>{e.key===j.constraint&&(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())}),R.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updateSpatialReference(e);const a=await this._getGraphicMover(e,t,o);if(le(a))return a;const s=new q({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._displayDefaultCursor(),r(l),r(p),a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();ie(s,e),s.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();ae(s,e),s.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updateSpatialReference(e),this.updateGraphics.push(e),a.graphics=this.updateGraphics.toArray(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);s.history.undo.forEach((e=>e.updates.splice(t,1))),s.history.redo.forEach((e=>e.updates.splice(t,1))),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?a.graphics=o:s.complete()}});let n=!1;const p=[o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(s,e,t)),R.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(s,e),e.key!==j.constraint||e.repeat||(n=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)}),R.WIDGET),o.on("key-up",(e=>{e.key===j.constraint&&n&&(n=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)}),R.WIDGET)],l=this._getHandlesForComponent(s,t);return s}async _setupReshape3DOperation(e,t,o,i=!1){const a="reshape",s=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(le(s))return s;const{ManipulatedObject3DGraphic:n,ReshapeTool3D:p}=s.module,l=new n({view:o,graphic:e}),c=C(l);if(c!==A.SUPPORTED)return l.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${k(c)}).`),null;const h=t.reshapeOptions,d=new p({view:o,object:l,enableZVertex:t.enableZ&&"move"===h?.vertexOperation,enableZShape:t.enableZ&&"move"===h?.shapeOperation,enableMoveObject:"move"===h?.shapeOperation||"move-xy"===h?.shapeOperation,enableMidpoints:"split"===h?.edgeOperation,enableEdgeOffset:"offset"===h?.edgeOperation,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),i||this.updateGraphics.add(l.graphic);const u=[],y=new q({activeComponent:d,tool:a,type:"update",onEnd:()=>{r(u),pe(o,d),l.destroy()},canUndo:()=>!d.destroyed&&d.canUndo,undo:()=>{d.destroyed||(d.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!d.destroyed&&d.canRedo,redo:()=>{d.destroyed||(d.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),y.onEnd(),y.destroy();const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);le(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),y.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;y.onEnd(),y.destroy();const e=await this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0);le(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(y,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(y,e,t)),R.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(y,e)}),R.WIDGET)),y}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updateSpatialReference(e);const a="transform"===t?await this._getBox(e,o,i):await this._getReshape(e,o,i);if(le(a))return a;const s=new q({activeComponent:a,type:"update",onEnd:()=>{r(p),r(n),s.activeComponent&&!s.activeComponent.destroyed&&s.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{ie(s,this.updateGraphics.toArray()),s.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:s.tool})},redo:()=>{ae(s,this.updateGraphics.toArray()),s.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:s.tool})},addToSelection:async e=>{let t=s.activeComponent;if("reshape"===t?.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll(),s.onEnd(),s.destroy();const a=await this._setupTransformOrReshape2DOperation(t,"transform",o,i);if(le(a))return;this._setUpdateOperationHandle(a,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),s.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:async e=>{const t=this.updateGraphics.indexOf(e);s.history.undo.forEach((e=>e.updates.splice(t,1))),s.history.redo.forEach((e=>e.updates.splice(t,1))),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();if(0===o.length)s.complete();else{const e=o[0].geometry;1!==o.length||null==e||"point"!==e.type&&"multipoint"!==e.type?s.activeComponent.graphics=o:s.toggleTool()}this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;const e=this.updateGraphics.at(0),t=e.geometry;if(null!=t&&("reshape"===s.tool&&("point"===t.type||"multipoint"===t.type)||"transform"===s.tool&&"extent"===t.type))return;let a=null;"transform"===s.tool?a=await this._getReshape([e],o,i):"reshape"===s.tool&&(a=await this._getBox([e],o,i)),le(a)||(s.activeComponent?.destroy(),s.activeComponent=a,s.activeComponent&&(r(p),p=this._getHandlesForComponent(s,o)))}}),n=[i.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(s,e,o)),R.WIDGET),i.on("key-down",(e=>{if(this._getCommonUpdateOperationKeyDownHandlers(s,e),e.key===j.constraint&&!e.repeat&&s){const e=s.activeComponent;e&&"box"===e.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}}),R.WIDGET),i.on("key-up",(e=>{if(e.key===j.constraint&&s){const e=s.activeComponent;e&&"box"===e.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}}),R.WIDGET)];let p=this._getHandlesForComponent(s,o);return s}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return le(r)?r:new r.module.default({enableMoveAllGraphics:i,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayGrabbingCursor(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayPointerCursor(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayPointerCursor(),onGraphicPointerOut:()=>this._displayDefaultCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:r,preserveAspectRatio:s}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(le(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(j.constraint);return new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!p,layer:this._internalGraphicsLayer,view:o,sketchOptions:this.sketchOptions,callbacks:{onMoveStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMove:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMoveStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScale:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotate:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"})}})}async _getReshape(e,t,o){const i="split"===t.reshapeOptions?.edgeOperation,a="move"===t.reshapeOptions?.shapeOperation,r=!!t.highlightOptions?.enabled,s=await this._requireModule(import("../../views/draw/support/Reshape.js"));return le(s)?s:new s.module.default({enableMidpoints:i,enableMovement:a,graphic:e[0],highlightsEnabled:r,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,view:o,callbacks:{onReshapeStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshape:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshapeStop:({mover:e,type:t})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e,type:t},type:"update"}),onMoveStart:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const i=e.map((e=>O(e.geometry)));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:i,vertices:o,type:t},type:"update"})},onVertexRemove:({removed:e,type:t,vertices:o})=>{const i=e.map((e=>O(e.geometry)));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:i,vertices:o,type:t},type:"update"})}}})}_getHandlesForComponent(e,t){const o=e.activeComponent;if(!o)return[];switch(o.type){case"graphic-mover":return[o.on("graphic-click",(({graphic:t,viewEvent:o})=>{o.native?.shiftKey&&(o.stopPropagation(),e.removeFromSelection(t))})),o.on("graphic-move-start",(t=>e.addToHistory(ne(t.allGraphics))))];case"box":return[o.on("graphic-click",(o=>this._onTransformOrReshape2DGraphicClick(e,t,o))),o.on("move-start",(t=>e.addToHistory(ne(t.graphics)))),o.on("rotate-start",(t=>e.addToHistory(ne(t.graphics)))),o.on("scale-start",(t=>e.addToHistory(ne(t.graphics))))];case"reshape":return[o.on("graphic-click",(o=>this._onTransformOrReshape2DGraphicClick(e,t,o))),o.on("move-start",(t=>e.addToHistory(ne([t.mover])))),o.on("reshape-start",(t=>e.addToHistory(ne([t.graphic])))),o.on("vertex-add",(t=>e.addToHistory(ne([t.oldGraphic])))),o.on("vertex-remove",(t=>e.addToHistory(ne([t.oldGraphic]))))];case"move-3d":return[o.events.on("record-undo",(({updates:t})=>{e.addToHistory({updates:t})})),o.events.on("move-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-start"},type:"update"})})),o.events.on("move",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e.dx,dy:e.dy,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move"},type:"update"})})),o.events.on("move-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-stop"},type:"update"})})),o.events.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()}))];case"transform-3d":return[o.events.on("record-undo",(({updates:t})=>{e.addToHistory({updates:t})})),o.events.on("translate-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})})),o.events.on("translate-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})})),o.events.on("rotate-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-start"},type:"update"})})),o.events.on("rotate-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})})),o.events.on("scale-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})})),o.events.on("scale-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})})),o.events.on("translate",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})})),o.events.on("rotate",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate"},type:"update"})})),o.events.on("scale",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})})),o.events.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()}))];case"reshape-3d":return[o.events.on("reshape",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})})),o.events.on("move",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})})),o.events.on("vertex-add",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.events.on("vertex-remove",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.events.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()}))]}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;return a.native?.shiftKey&&i.layer===this.layer?(a.stopPropagation(),e.removeFromSelection(i)):t.toggleToolOnClick?(a.stopPropagation(),e.toggleTool()):void 0}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view?.map;this._disablePopup(t);const i=()=>{if(e===this._operationHandle){const i=this.updateGraphics.toArray(),a=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),o&&o.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit("update",{graphics:i,state:"complete",aborted:e.cancelled,tool:a,toolEventInfo:null,type:"update"})}};e.on("complete",i)}async _getCommonUpdateOperationClickHandlers(e,t,o){const i=W(t),a=await t.async((()=>this._getFirstHit(i)));if(null==a)return void e.complete();if(t.native.shiftKey&&this._toggleSelection([a.graphic],e,o))return void t.stopPropagation();this.updateGraphics.includes(a.graphic)?t.stopPropagation():e.complete()}_toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;return e.some((e=>null!=e&&(!(!i||e.layer!==this.layer)&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0))))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===j.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===j.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===j.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&j.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){if(!this._operationHandle||"update"!==this._operationHandle.type)return;const t=this.activeComponent,o=this.updateGraphics.toArray();null!=t&&("reshape"!==t.type||1===o.length&&"point"===o[0].geometry?.type)&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view?.map?.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=n(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||null==t)&&(e.attributes?.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_displayPointerCursor(){this.view?.container&&"pointer"!==this.view.cursor&&(this.view.cursor="pointer")}_displayGrabbingCursor(){this.view?.container&&"grabbing"!==this.view.cursor&&(this.view.cursor="grabbing")}_displayDefaultCursor(){this.view?.container&&null!==this.view.cursor&&(this.view.cursor=null)}_logError(e,t,o){s.getLogger(this).error(new i(e,t,o))}async _requireModule(e){const t=new AbortController;this._moduleLoaderAbortController=t;const o=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:"aborted"}:{module:o}}_emitUndoEvent(e){this.emit("undo",{...e,type:"undo"})}_emitRedoEvent(e){this.emit("redo",{...e,type:"redo"})}_emitDeleteEvent(e){this.emit("delete",{...e,type:"delete"})}get test(){}wait(){return y((()=>!this.updating))}_beginAsyncOperation(){this._numUpdating+=1,this.notifyChange("updating")}_endAsyncOperation(){this._numUpdating-=1,this.notifyChange("updating")}_disablePopupEnabled(e){return"3d"!==this.view?.type||this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._disablePopupEnabled(e)&&this.view&&null==this._originalPopupEnabled&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._disablePopupEnabled(e)&&this.view&&null!=this._originalPopupEnabled&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){const e=this.view;e?(p(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await c(y((()=>e?.ready)),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",te("view"))}_logMissingLayer(){this._logError(ee,te("layer"))}};e([g()],X.prototype,"_defaultSnappingManager",void 0),e([g()],X.prototype,"updating",null),e([g()],X.prototype,"_operationHandle",void 0),e([g({readOnly:!0})],X.prototype,"activeTool",null),e([g()],X.prototype,"activeTooltip",null),e([g()],X.prototype,"activeFillSymbol",void 0),e([g()],X.prototype,"activeLineSymbol",void 0),e([g()],X.prototype,"activeVertexSymbol",void 0),e([g()],X.prototype,"allowDeleteKey",void 0),e([g({readOnly:!0})],X.prototype,"createGraphic",null),e([g()],X.prototype,"defaultCreateOptions",null),e([g()],X.prototype,"defaultUpdateOptions",null),e([g({type:I,nonNullable:!0})],X.prototype,"labelOptions",null),e([g()],X.prototype,"layer",void 0),e([g({types:t})],X.prototype,"pointSymbol",void 0),e([g({types:t})],X.prototype,"polygonSymbol",void 0),e([g({types:t})],X.prototype,"polylineSymbol",void 0),e([g()],X.prototype,"meshSymbol",void 0),e([g({type:F,nonNullable:!0})],X.prototype,"snappingOptions",null),e([g()],X.prototype,"snappingManager",null),e([g({readOnly:!0})],X.prototype,"state",null),e([g({type:x,nonNullable:!0})],X.prototype,"tooltipOptions",null),e([g({readOnly:!0})],X.prototype,"updateGraphics",void 0),e([g()],X.prototype,"updateOnGraphicClick",void 0),e([g({type:P,nonNullable:!0})],X.prototype,"valueOptions",null),e([g({types:t})],X.prototype,"vertexSymbol",void 0),e([g({value:null})],X.prototype,"view",null),e([g({constructOnly:!0,type:U})],X.prototype,"sketchOptions",void 0),X=e([v("esri.widgets.Sketch.SketchViewModel")],X);const ee="sketch:missing-property",te=e=>`Property '${e}' is missing on SketchViewModel.`;function oe(e){return"polygon"===e||"rectangle"===e||"circle"===e}function ie(e,t){re("undo",e.history.undo,e.history.redo,t)}function ae(e,t){re("redo",e.history.redo,e.history.undo,t)}function re(e,t,o,i){const a=t.pop();if(!a)return;const r=a.updates,s=[];i.forEach(((t,o)=>{const i=r[o];null!=i&&("geometry"in i&&null!=i.geometry&&(s.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(s.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(s.push(i),i[e](t)))})),o.push({updates:s})}function se(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function ne(e){return{updates:e.map((({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e}))}}function pe(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function le(e){return"requireError"in e&&"aborted"===e.requireError}const ce=X;export{ce as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{symbolTypes as t}from"../../symbols.js";import o from"../../core/Collection.js";import i from"../../core/Error.js";import a from"../../core/Evented.js";import{drainHandles as r}from"../../core/handleUtils.js";import"../../core/has.js";import s from"../../core/Logger.js";import{destroyMaybe as n,abortMaybe as p}from"../../core/maybe.js";import{createAbortError as l,whenOrAbort as c}from"../../core/promiseUtils.js";import{on as h,watch as d,when as u,whenOnce as y,syncAndInitial as m}from"../../core/reactiveUtils.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{getReferenceEllipsoid as f}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as _,load as b,project as w,isLoaded as G}from"../../geometry/projection.js";import{geometryToCoordinates as O}from"../../geometry/support/coordsUtils.js";import{equals as T}from"../../geometry/support/spatialReferenceUtils.js";import E from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as S}from"../../layers/support/layerUtils.js";import{SupportedObjectResult as A,isSupportedObjectResultMessage as k}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as M}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as C}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as D}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as H}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as R}from"../../views/input/InputManager.js";import{sketchKeys as j}from"../../views/interactive/keybindings.js";import I from"../../views/interactive/sketch/SketchLabelOptions.js";import U from"../../views/interactive/sketch/SketchOptions.js";import x from"../../views/interactive/sketch/SketchTooltipOptions.js";import P from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as L}from"../../views/interactive/snapping/SnappingManager.js";import F from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as V}from"../../views/interactive/snapping/snappingUtils.js";import{findFirstGraphicHit as K}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as W}from"../../views/support/screenUtils.js";import{CreateOperationHandle as Z,UpdateOperationHandle as q}from"./support/OperationHandle.js";import z from"../../symbols/SimpleMarkerSymbol.js";import N from"../../symbols/SimpleFillSymbol.js";import B from"../../symbols/SimpleLineSymbol.js";import $ from"../../symbols/MeshSymbol3D.js";import Y from"../../symbols/FillSymbol3DLayer.js";const J={defaultZ:0},Q={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move"},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0},tool:"transform"};let X=class extends a.EventedAccessor{constructor(e){super(e),this._numUpdating=0,this._defaultSnappingManager=null,this._internalGraphicsLayer=new E({listMode:"hide",internal:!0,title:"SVM Internal"}),this._operationHandle=null,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.layer=null,this.pointSymbol=new z({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new N({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new B({color:[130,130,130,1],width:2}),this.meshSymbol=new $({symbolLayers:new o([new Y])}),this.updateGraphics=new o,this.updateOnGraphicClick=!0,this.vertexSymbol=new z({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new U,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._originalPopupEnabled=null,this.defaultCreateOptions=J,this.defaultUpdateOptions=Q,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new F}initialize(){this.addHandles([h((()=>this.view?.map?.layers),"change",(e=>{e.removed.includes(this.layer)&&this.cancel()})),h((()=>this.layer?.graphics),"change",(e=>{if(null!=this._operationHandle)for(const t of e.removed)this.updateGraphics.includes(t)&&(this.updateGraphics.length>1?this._operationHandle.removeFromSelection(t):this._operationHandle.cancel())})),d((()=>this.layer?.elevationInfo??null),(e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer.elevationInfo=e)}),m),d((()=>this.view),(e=>{this._defaultSnappingManager=n(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new L({view:e,options:this.snappingOptions})),"2d"===e.type?import("../../views/2d/interactive/editingTools.js"):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))}),m),d((()=>this.view?.spatialReference),((e,t)=>{e&&t&&!e.equals(t)&&this.cancel()}))]),V(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=n(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this.emit("destroy")}get updating(){return this._numUpdating>0||null!=this.snappingManager&&this.snappingManager.updating}get activeTool(){return this._operationHandle?.tool??null}get activeTooltip(){const{activeComponent:e,destroyed:t}=this,o=!t&&e&&"tooltip"in e?e.tooltip:null;return o?.visible?o:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return null==this.activeComponent||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):this.activeComponent.graphic}get defaultCreateOptions(){return this._get("defaultCreateOptions")}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...J,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...Q,...e,reshapeOptions:{...Q.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...Q.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get snappingOptions(){return this.snappingManager?.options??this._get("snappingOptions")}set snappingOptions(e){null!=this._defaultSnappingManager&&(this._defaultSnappingManager.options=e),this._set("snappingOptions",e)}get snappingManager(){return this._isOverridden("snappingManager")&&this._get("snappingManager"),this._defaultSnappingManager}set snappingManager(e){if(e)this._isOverridden("snappingManager")||(this._defaultSnappingManager=n(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new L({options:this.snappingOptions,view:e})),this._clearOverride("snappingManager")}}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&(t.cursor=null),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(u((()=>e.ready),(t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)}),m),o),this._set("view",e)}cancel(){this._moduleLoaderAbortController=p(this._moduleLoaderAbortController),this._viewReadyAbortController=p(this._viewReadyAbortController),this._operationHandle&&this._operationHandle.cancel()}complete(){this._operationHandle&&this._operationHandle.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e,layer:o}=this,i=t.toArray();o.removeMany(i),this.cancel(),this._emitDeleteEvent({graphics:i,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map((e=>e.clone())).toArray();return this.layer.addMany(e),this.emit("duplicate",{graphics:e,type:"duplicate"}),e}return[]}async create(e,t){this.cancel(),await this._waitViewReady();const{view:o,layer:i}=this;if(!o||"disabled"===this.state)throw i||this._logMissingLayer(),l();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");H(o,this._internalGraphicsLayer);const a=await this._setupCreateOperation(e,t);if(null==a||this.destroyed)return void o.map.remove(this._internalGraphicsLayer);const r=()=>{if(a===this._operationHandle){const t=this.createGraphic,o=this._operationHandle.cancelled;this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map&&this.view.map.remove(this._internalGraphicsLayer),a.cancelled||null==t||i.add(t),this.emit("create",{graphic:t,state:o?"cancel":"complete",tool:e,toolEventInfo:null,type:"create"})}};a.on("complete",r),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return this.create("mesh",{mode:"click",hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){this.cancel(),await this._waitViewReady();const{layer:o,view:i,state:a}=this;if(!i||"disabled"===a)throw o||this._logMissingLayer(),l();null!=i.activeTool&&(i.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some((e=>e.layer!==o?(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0):null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0))))return;const s=await this._setupUpdateOperation(r,t);this.destroyed||null==s||le(s)||(H(i,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit("update",{graphics:r,state:"start",aborted:!1,tool:s.tool,toolEventInfo:null,type:"update"}))}async _updateSpatialReference(e){const t=this.view;if(t){this._beginAsyncOperation(),e=Array.isArray(e)?e:[e];for(const o of e)null==o.geometry||"mesh"===o.geometry.type||T(o.geometry.spatialReference,t.spatialReference)||(_(o.geometry.spatialReference,t.spatialReference)||G()||await b(),o.geometry=w(o.geometry,t.spatialReference));this._endAsyncOperation()}else this._logMissingView()}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._operationHandle?.toggleTool()}async _getFirstHit(e){const t=this.view;if(!t)return this._logMissingView(),null;if("2d"===t.type){const o=[];t.map.allLayers.forEach((e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)}));const i=await t.hitTest(e,{exclude:o});return K(i.results)}const o=[t.map.ground];t.map.allLayers.forEach((e=>{S(e.type)&&o.push(e)}));const i=await t.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!i.ground.mapPoint||t.map.ground.opacity<1||i.ground.distance-(e.distance??0)>-Math.min(3*i.ground.distance,"global"===t.viewingMode?f(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY)))return e}return null}_generateViewHandles(e){return[e.on("immediate-click",(async t=>{const o="active"===this.state&&"create"===this._operationHandle?.type;if("disabled"===this.state||o||!this.updateOnGraphicClick)return;this._beginAsyncOperation();const i=await t.async((()=>this._getFirstHit(W(t))));let a=null;if(null!=i){const o=i.graphic;this.updateGraphics.includes(o)||o.layer===this.layer?(t.stopPropagation(),a=o):"2d"!==e.type||this._isComponentGraphic(o)||"active"!==this.state||this.cancel()}else"active"===this.state&&this.cancel();null==a||this.updateGraphics.includes(a)||await this.update([a],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}}),this._endAsyncOperation()}),R.WIDGET)]}async _setupCreateOperation(e,t){const o=this.view;if(!o)return this._logMissingView(),null;const i={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},a=await this._setupDrawGraphicTool(e,o,i);return null==a?null:(o.tools.add(a),o.activeTool=a,this._setupCreateOperationHandle(a))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView."),null;if(!t)return this._logMissingView(),null;const{cursor:i,defaultZ:a,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,c="rectangle"===e||"circle"===e?"hybrid":"click",h=l??"rectangle"!==e,d={centered:"rectangle"!==e&&!("circle"===e&&!h),cursor:i,defaultZ:a,forceUniformSize:h,graphicProperties:n,geometryToPlace:s,geometryType:e,graphicSymbol:this._getGraphicSymbolFromTool(e),hasZ:r,mode:p??c,snappingManager:this.snappingManager,snapToScene:!1,view:t};return"2d"===t.type?this._makeDrawGraphicTool2D(d):this._makeDrawGraphicTool3D(d)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return le(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:oe(e.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(le(t)||this.destroyed)return null;const{elevationInfo:o}=this.layer;return new t.module.DrawGraphicTool3D({...e,elevationInfo:o,snapToScene:!0,sketchOptions:this.sketchOptions})}_setupCreateOperationHandle(e){const t=this.view;if(!t)return this._logMissingView(),null;let o=null;const i=e.forceUniformSize,a=e.centered,s=[t.on("key-down",(t=>{if(t.key===j.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===j.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==j.vertexAdd||t.repeat)t.key===j.undo?(t.stopPropagation(),n.undo()):t.key===j.redo?(t.stopPropagation(),n.redo()):t.key!==j.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===j.center&&(t.repeat||(e.centered=!a,t.stopPropagation())):(e.forceUniformSize=!i,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}}),R.WIDGET),t.on("key-up",(t=>{t.key===j.pan?e.enabled=!0:t.key!==j.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===j.center&&(e.centered=a,t.stopPropagation()):(e.forceUniformSize=i,t.stopPropagation())}),R.WIDGET),e.on("vertex-add",(t=>{switch(o=null==o?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:o,tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}})),e.on("cursor-update",(t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})})),e.on("vertex-remove",(t=>{switch(t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}})),e.on("complete",(e=>{this._set("createGraphic",e.graphic),o="complete",e.aborted?n&&n.cancel():n&&n.complete()})),d((()=>this._getGraphicSymbolFromTool(e.geometryType)),(t=>{e.graphicSymbol=t}))],n=new Z({activeComponent:e,tool:e.geometryType,type:"create",onEnd:()=>{r(s),t.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return n}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":return this.polygonSymbol;case"mesh":return this.meshSymbol}}async _setupUpdateOperation(e,t){const{layer:o,view:i}=this;if(!i)return this._logMissingView(),null;const a={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};let r=a.tool??Q.tool;for(const s of e)o.remove(s),o.add(s);if("3d"===i.type){if(0===e.length)return null;switch(r){case"move":return this._setupMove3DOperation(e,a,i,r);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],a,i);case"transform":return this._setupGraphicTransform3DOperation(e,a,i)}}switch(r){case"move":return this._setupMove2DOperation(e,a,i);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,r,a,i);case"transform":if(1===e.length){const t=e[0].geometry?.type;"point"!==t&&"multipoint"!==t||(r="reshape")}return this._setupTransformOrReshape2DOperation(e,r,a,i)}}async _setupMove3DOperation(e,t,o,i,a=!1){const s=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(le(s))return s;const{ManipulatedObject3DGraphic:n,MoveTool3D:p}=s.module,l=new Map,c=()=>{l.forEach((e=>e.destroy())),l.clear()};for(const r of e){const e=new n({view:o,graphic:r}),t=M(e);if(t!==A.SUPPORTED)return c(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${k(t)}).`),null;l.set(r,e)}const h=new p({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(h),h.objects.addMany(Array.from(l.values())),a||this.updateGraphics.addMany(e);const d=[],u=new q({activeComponent:h,tool:i,type:"update",onEnd:()=>{r(d),pe(o,h),c()},undo:()=>{se(this.view,h),ie(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{ae(u,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:e=>{this.updateGraphics.push(e);const t=new n({view:o,graphic:e});l.set(e,t),h.objects.push(t),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);if(u.history.undo.forEach((e=>e.updates.splice(t,1))),u.history.redo.forEach((e=>e.updates.splice(t,1))),this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0===this.updateGraphics.length)return void u.complete();const o=l.get(e);o&&(h.objects.remove(o),o.destroy(),l.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.at(0),a=await this._setupReshape3DOperation(e,t,o,!0);a&&!le(a)&&(u.onEnd(),u.destroy(),this._setUpdateOperationHandle(a,t))}});return d.push(...this._getHandlesForComponent(u,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(u,e,t)),R.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)}),R.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&D(e[0])===A.SUPPORTED){const a=e[0],r=a.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=r&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(a,t,o,i)}return this._setupMove3DOperation(e,t,o,"transform",i)}async _setupPointTransform3DOperation(e,t,o){const i="transform",{enableRotation:a,enableScaling:s,enableZ:n}=t,p=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(le(p))return p;const{TransformTool3D:l,ManipulatedObject3DGraphic:c}=p.module,h=new c({graphic:e,view:o}),d=new l({object:h,view:o,enableRotation:a,enableScaling:s,enableZ:n,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),this.updateGraphics.add(e);const u=[],y=new q({activeComponent:d,tool:i,type:"update",onEnd:()=>{r(u),pe(o,d),h.destroy()},undo:()=>{se(this.view,d),ie(y,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{ae(y,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),y.onEnd(),y.destroy();const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);le(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),y.complete()},toggleTool:()=>{}});return u.push(...this._getHandlesForComponent(y,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(y,e,t)),R.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(y,e)}),R.WIDGET)),y}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:s,enableScaling:n,enableZ:p,preserveAspectRatio:l}=t,c=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(le(c))return c;const{ManipulatedObject3DGraphic:h,ExtentTransformTool:d}=c.module,u=this.view?.inputManager?.isModifierKeyDown(j.constraint),y=new h({view:o,graphic:e}),m=new d({object:y,view:o,enableRotation:s,enableScaling:n,enableZ:p,preserveAspectRatio:!!l!=!!u,sketchOptions:this.sketchOptions});o.tools.add(m),i||this.updateGraphics.add(e);const g=[],v=new q({activeComponent:m,tool:a,type:"update",onEnd:()=>{r(g),pe(o,m),y.destroy()},canUndo:()=>!m.destroyed&&m.canUndo,undo:()=>{m.destroyed||(m.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!m.destroyed&&m.canRedo,redo:()=>{m.destroyed||(m.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),v.onEnd(),v.destroy();const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);le(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),v.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const i=await this._setupReshape3DOperation(e,t,o,!0);i&&!le(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return g.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(v,e,t)),R.WIDGET),o.on("key-down",(e=>this._getCommonUpdateOperationKeyDownHandlers(v,e)),R.WIDGET),o.on("key-down",(e=>{e.key!==j.constraint||e.repeat||(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())}),R.WIDGET),o.on("key-up",(e=>{e.key===j.constraint&&(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())}),R.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updateSpatialReference(e);const a=await this._getGraphicMover(e,t,o);if(le(a))return a;const s=new q({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._displayDefaultCursor(),r(l),r(p),a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();ie(s,e),s.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();ae(s,e),s.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updateSpatialReference(e),this.updateGraphics.push(e),a.graphics=this.updateGraphics.toArray(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);s.history.undo.forEach((e=>e.updates.splice(t,1))),s.history.redo.forEach((e=>e.updates.splice(t,1))),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?a.graphics=o:s.complete()}});let n=!1;const p=[o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(s,e,t)),R.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(s,e),e.key!==j.constraint||e.repeat||(n=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)}),R.WIDGET),o.on("key-up",(e=>{e.key===j.constraint&&n&&(n=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)}),R.WIDGET)],l=this._getHandlesForComponent(s,t);return s}async _setupReshape3DOperation(e,t,o,i=!1){const a="reshape",s=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(le(s))return s;const{ManipulatedObject3DGraphic:n,ReshapeTool3D:p}=s.module,l=new n({view:o,graphic:e}),c=C(l);if(c!==A.SUPPORTED)return l.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${k(c)}).`),null;const h=t.reshapeOptions,d=new p({view:o,object:l,enableZVertex:t.enableZ&&"move"===h?.vertexOperation,enableZShape:t.enableZ&&"move"===h?.shapeOperation,enableMoveObject:"move"===h?.shapeOperation||"move-xy"===h?.shapeOperation,enableMidpoints:"split"===h?.edgeOperation,enableEdgeOffset:"offset"===h?.edgeOperation,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),i||this.updateGraphics.add(l.graphic);const u=[],y=new q({activeComponent:d,tool:a,type:"update",onEnd:()=>{r(u),pe(o,d),l.destroy()},canUndo:()=>!d.destroyed&&d.canUndo,undo:()=>{d.destroyed||(d.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!d.destroyed&&d.canRedo,redo:()=>{d.destroyed||(d.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),y.onEnd(),y.destroy();const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);le(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),y.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;y.onEnd(),y.destroy();const e=await this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0);le(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(y,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(y,e,t)),R.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(y,e)}),R.WIDGET)),y}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updateSpatialReference(e);const a="transform"===t?await this._getBox(e,o,i):await this._getReshape(e,o,i);if(le(a))return a;const s=new q({activeComponent:a,type:"update",onEnd:()=>{r(p),r(n),s.activeComponent&&!s.activeComponent.destroyed&&s.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{ie(s,this.updateGraphics.toArray()),s.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:s.tool})},redo:()=>{ae(s,this.updateGraphics.toArray()),s.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:s.tool})},addToSelection:async e=>{let t=s.activeComponent;if("reshape"===t?.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll(),s.onEnd(),s.destroy();const a=await this._setupTransformOrReshape2DOperation(t,"transform",o,i);if(le(a))return;this._setUpdateOperationHandle(a,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),s.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:async e=>{const t=this.updateGraphics.indexOf(e);s.history.undo.forEach((e=>e.updates.splice(t,1))),s.history.redo.forEach((e=>e.updates.splice(t,1))),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();if(0===o.length)s.complete();else{const e=o[0].geometry;1!==o.length||null==e||"point"!==e.type&&"multipoint"!==e.type?s.activeComponent.graphics=o:s.toggleTool()}this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;const e=this.updateGraphics.at(0),t=e.geometry;if(null!=t&&("reshape"===s.tool&&("point"===t.type||"multipoint"===t.type)||"transform"===s.tool&&"extent"===t.type))return;let a=null;"transform"===s.tool?a=await this._getReshape([e],o,i):"reshape"===s.tool&&(a=await this._getBox([e],o,i)),le(a)||(s.activeComponent?.destroy(),s.activeComponent=a,s.activeComponent&&(r(p),p=this._getHandlesForComponent(s,o)))}}),n=[i.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(s,e,o)),R.WIDGET),i.on("key-down",(e=>{if(this._getCommonUpdateOperationKeyDownHandlers(s,e),e.key===j.constraint&&!e.repeat&&s){const e=s.activeComponent;e&&"box"===e.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}}),R.WIDGET),i.on("key-up",(e=>{if(e.key===j.constraint&&s){const e=s.activeComponent;e&&"box"===e.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}}),R.WIDGET)];let p=this._getHandlesForComponent(s,o);return s}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return le(r)?r:new r.module.default({enableMoveAllGraphics:i,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayGrabbingCursor(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayPointerCursor(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayPointerCursor(),onGraphicPointerOut:()=>this._displayDefaultCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:r,preserveAspectRatio:s}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(le(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(j.constraint);return new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!p,layer:this._internalGraphicsLayer,view:o,sketchOptions:this.sketchOptions,callbacks:{onMoveStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMove:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMoveStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScale:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotate:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"})}})}async _getReshape(e,t,o){const i="split"===t.reshapeOptions?.edgeOperation,a="move"===t.reshapeOptions?.shapeOperation,r=!!t.highlightOptions?.enabled,s=await this._requireModule(import("../../views/draw/support/Reshape.js"));return le(s)?s:new s.module.default({enableMidpoints:i,enableMovement:a,graphic:e[0],highlightsEnabled:r,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,view:o,callbacks:{onReshapeStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshape:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshapeStop:({mover:e,type:t})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e,type:t},type:"update"}),onMoveStart:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const i=e.map((e=>O(e.geometry)));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:i,vertices:o,type:t},type:"update"})},onVertexRemove:({removed:e,type:t,vertices:o})=>{const i=e.map((e=>O(e.geometry)));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:i,vertices:o,type:t},type:"update"})}}})}_getHandlesForComponent(e,t){const o=e.activeComponent;if(!o)return[];switch(o.type){case"graphic-mover":return[o.on("graphic-click",(({graphic:t,viewEvent:o})=>{o.native?.shiftKey&&(o.stopPropagation(),e.removeFromSelection(t))})),o.on("graphic-move-start",(t=>e.addToHistory(ne(t.allGraphics))))];case"box":return[o.on("graphic-click",(o=>this._onTransformOrReshape2DGraphicClick(e,t,o))),o.on("move-start",(t=>e.addToHistory(ne(t.graphics)))),o.on("rotate-start",(t=>e.addToHistory(ne(t.graphics)))),o.on("scale-start",(t=>e.addToHistory(ne(t.graphics))))];case"reshape":return[o.on("graphic-click",(o=>this._onTransformOrReshape2DGraphicClick(e,t,o))),o.on("move-start",(t=>e.addToHistory(ne([t.mover])))),o.on("reshape-start",(t=>e.addToHistory(ne([t.graphic])))),o.on("vertex-add",(t=>e.addToHistory(ne([t.oldGraphic])))),o.on("vertex-remove",(t=>e.addToHistory(ne([t.oldGraphic]))))];case"move-3d":return[o.events.on("record-undo",(({updates:t})=>{e.addToHistory({updates:t})})),o.events.on("move-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-start"},type:"update"})})),o.events.on("move",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e.dx,dy:e.dy,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move"},type:"update"})})),o.events.on("move-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-stop"},type:"update"})})),o.events.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()}))];case"transform-3d":return[o.events.on("record-undo",(({updates:t})=>{e.addToHistory({updates:t})})),o.events.on("translate-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})})),o.events.on("translate-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})})),o.events.on("rotate-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-start"},type:"update"})})),o.events.on("rotate-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})})),o.events.on("scale-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})})),o.events.on("scale-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})})),o.events.on("translate",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})})),o.events.on("rotate",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate"},type:"update"})})),o.events.on("scale",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})})),o.events.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()}))];case"reshape-3d":return[o.events.on("reshape",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})})),o.events.on("move",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})})),o.events.on("vertex-add",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.events.on("vertex-remove",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.events.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()}))]}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;return a.native?.shiftKey&&i.layer===this.layer?(a.stopPropagation(),e.removeFromSelection(i)):t.toggleToolOnClick?(a.stopPropagation(),e.toggleTool()):void 0}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view?.map;this._disablePopup(t);const i=()=>{if(e===this._operationHandle){const i=this.updateGraphics.toArray(),a=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),o&&o.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit("update",{graphics:i,state:"complete",aborted:e.cancelled,tool:a,toolEventInfo:null,type:"update"})}};e.on("complete",i)}async _getCommonUpdateOperationClickHandlers(e,t,o){const i=W(t),a=await t.async((()=>this._getFirstHit(i)));if(null==a)return void e.complete();if(t.native.shiftKey&&this._toggleSelection([a.graphic],e,o))return void t.stopPropagation();this.updateGraphics.includes(a.graphic)?t.stopPropagation():e.complete()}_toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;return e.some((e=>null!=e&&(!(!i||e.layer!==this.layer)&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0))))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===j.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===j.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===j.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&j.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){if(!this._operationHandle||"update"!==this._operationHandle.type)return;const t=this.activeComponent,o=this.updateGraphics.toArray();null!=t&&("reshape"!==t.type||1===o.length&&"point"===o[0].geometry?.type)&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view?.map?.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=n(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||null==t)&&(e.attributes?.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_displayPointerCursor(){this.view?.container&&"pointer"!==this.view.cursor&&(this.view.cursor="pointer")}_displayGrabbingCursor(){this.view?.container&&"grabbing"!==this.view.cursor&&(this.view.cursor="grabbing")}_displayDefaultCursor(){this.view?.container&&null!==this.view.cursor&&(this.view.cursor=null)}_logError(e,t,o){s.getLogger(this).error(new i(e,t,o))}async _requireModule(e){const t=new AbortController;this._moduleLoaderAbortController=t;const o=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:"aborted"}:{module:o}}_emitUndoEvent(e){this.emit("undo",{...e,type:"undo"})}_emitRedoEvent(e){this.emit("redo",{...e,type:"redo"})}_emitDeleteEvent(e){this.emit("delete",{...e,type:"delete"})}get test(){}wait(){return y((()=>!this.updating))}_beginAsyncOperation(){this._numUpdating+=1,this.notifyChange("updating")}_endAsyncOperation(){this._numUpdating-=1,this.notifyChange("updating")}_disablePopupEnabled(e){return"3d"!==this.view?.type||this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._disablePopupEnabled(e)&&this.view&&null==this._originalPopupEnabled&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._disablePopupEnabled(e)&&this.view&&null!=this._originalPopupEnabled&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){const e=this.view;e?(p(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await c(y((()=>e?.ready)),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",te("view"))}_logMissingLayer(){this._logError(ee,te("layer"))}};e([g()],X.prototype,"_defaultSnappingManager",void 0),e([g()],X.prototype,"updating",null),e([g()],X.prototype,"_operationHandle",void 0),e([g({readOnly:!0})],X.prototype,"activeTool",null),e([g()],X.prototype,"activeTooltip",null),e([g()],X.prototype,"activeFillSymbol",void 0),e([g()],X.prototype,"activeLineSymbol",void 0),e([g()],X.prototype,"activeVertexSymbol",void 0),e([g()],X.prototype,"allowDeleteKey",void 0),e([g({readOnly:!0})],X.prototype,"createGraphic",null),e([g()],X.prototype,"defaultCreateOptions",null),e([g()],X.prototype,"defaultUpdateOptions",null),e([g({type:I,nonNullable:!0})],X.prototype,"labelOptions",null),e([g()],X.prototype,"layer",void 0),e([g({types:t})],X.prototype,"pointSymbol",void 0),e([g({types:t})],X.prototype,"polygonSymbol",void 0),e([g({types:t})],X.prototype,"polylineSymbol",void 0),e([g()],X.prototype,"meshSymbol",void 0),e([g({type:F,nonNullable:!0})],X.prototype,"snappingOptions",null),e([g()],X.prototype,"snappingManager",null),e([g({readOnly:!0})],X.prototype,"state",null),e([g({type:x,nonNullable:!0})],X.prototype,"tooltipOptions",null),e([g({readOnly:!0})],X.prototype,"updateGraphics",void 0),e([g()],X.prototype,"updateOnGraphicClick",void 0),e([g({type:P,nonNullable:!0})],X.prototype,"valueOptions",null),e([g({types:t})],X.prototype,"vertexSymbol",void 0),e([g({value:null})],X.prototype,"view",null),e([g({constructOnly:!0,type:U})],X.prototype,"sketchOptions",void 0),X=e([v("esri.widgets.Sketch.SketchViewModel")],X);const ee="sketch:missing-property",te=e=>`Property '${e}' is missing on SketchViewModel.`;function oe(e){return"polygon"===e||"rectangle"===e||"circle"===e}function ie(e,t){re("undo",e.history.undo,e.history.redo,t)}function ae(e,t){re("redo",e.history.redo,e.history.undo,t)}function re(e,t,o,i){const a=t.pop();if(!a)return;const r=a.updates,s=[];i.forEach(((t,o)=>{const i=r[o];null!=i&&("geometry"in i&&null!=i.geometry&&(s.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(s.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(s.push(i),i[e](t)))})),o.push({updates:s})}function se(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function ne(e){return{updates:e.map((({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e}))}}function pe(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function le(e){return"requireError"in e&&"aborted"===e.requireError}const ce=X;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.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import i from"../core/Identifiable.js";import{on as s,initial as o}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import n from"./Widget.js";import a from"./LayerList/LayerListItem.js";import{minDragEnabledItems as d,minFilterItems as m,getLayerType as c,removeDestroyedListItems as p}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as h}from"./support/componentsUtils.js";import{globalCss as u}from"./support/globalCss.js";import{calciteListFilterProps as g}from"./support/listUtils.js";import{setFocus as f}from"./support/widgetUtils.js";import{messageBundle as I}from"./support/decorators/messageBundle.js";import{vmEvent as b}from"./support/decorators/vmEvent.js";import{tsx as v}from"./support/jsxFactory.js";import{css as _}from"./TableList/css.js";import w from"./TableList/ListItem.js";import y from"./TableList/TableListViewModel.js";import L from"./TableList/TableListVisibleElements.js";import{getItem as C,sortTablesToIds as E}from"./TableList/support/tableListUtils.js";const F="flat",M=t.ofType(w);let P=class extends(i.IdentifiableMixin(n)){constructor(e,t){super(e,t),this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`table-${this.uid}`,this.collapsed=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.messages=null,this.messagesCommon=null,this.minDragEnabledItems=d,this.minFilterItems=m,this.selectedItems=new M,this.selectionMode="none",this.viewModel=new y,this.visibleElements=new L,this._canMove=({dragEl:e,fromEl:t,toEl:i},s)=>{const o="pull"===s?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,l=C(e);if(!l?.sortable)return!1;const r=C(t),n=c(t),a=C(i),d=c(i),m=!!n&&!!d&&n===d,p={selected:l,from:r,to:a},h=t.group,u=i.group;return h&&u&&"function"==typeof o?o.call(null,p):m},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:s,dragEl:o,newIndex:l}=e;if(!s||!i||t?.newIndex===l&&t?.dragEl===o&&t?.toEl===i&&t?.fromEl===s)return;this._lastDragDetail=e,this._selectedDragItemLayerUid=o.value;const r=Array.from(s.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));E(this.map?.tables,r)},this._onSelectedDragItemLayerUidChange=e=>{this._selectedDragItemLayerUid=e},this._onTriggerAction=(e,t)=>{this.triggerAction(e,t)},this._onPanelOpen=()=>{this._focusPanelFlowItem=!0}}initialize(){this.addHandles(s((()=>this.viewModel.tableItems),"change",(()=>p(this.selectedItems)),o))}loadDependencies(){return h({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}get _dragEnabled(){return this.viewModel.totalItems>=this.minDragEnabledItems&&this.dragEnabled}get _filterEnabled(){return this.viewModel.totalItems>=this.minFilterItems&&this.visibleElements.filter}get _visibleItems(){return this.tableItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}get _openedPanelItems(){return this._visibleItems.filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled))}get icon(){return"table"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get tableItems(){return this.viewModel.tableItems}get tables(){return this.viewModel.tables}set tables(e){this.viewModel.tables=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,{_visibleItems:t}=this,i={[u.hidden]:"loading"===e,[u.disabled]:"disabled"===e};return v("div",{class:this.classes(_.base,u.widget,u.panel,i)},t?.length?this._renderItems():this._renderNoItems())}_renderNoItemsMessage(){return v("div",{slot:"message"},this.messages.noItemsToDisplay)}_renderNoItems(){return v("div",{class:_.itemMessage,key:"esri-layer-list__no-items"},v("calcite-notice",{icon:"information",kind:"info",open:!0,width:"full"},this._renderNoItemsMessage()))}_renderPanelFlowItems(){const{_openedPanelItems:e}=this;return e.toArray().map((({title:t,panel:i},s)=>{const o=()=>this._handlePanelFlowItemBack(i);return v("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:t,heading:i.title,headingLevel:this.headingLevel,key:`flow-panel-${i.uid}`,selected:s===e.length-1,onCalciteFlowItemBack:e=>{e.preventDefault(),o()}},i.render(),v("calcite-button",{appearance:"transparent",onclick:o,slot:"footer-actions",width:"full"},this.messagesCommon.back))}))}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,f(e))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,f(e))}_renderItems(){const{visible:e,collapsed:t,visibleElements:{closeButton:i,collapseButton:s,heading:o,flow:l},_dragEnabled:r,_visibleItems:n,_filterEnabled:a,_rootGroupUid:d,_openedPanelItems:m,selectionMode:c,messages:p,filterPlaceholder:h,filterText:u}=this,f=[v("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:i,closed:!e,collapsed:t,collapsible:s,heading:o?p.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",selected:!m.length,onCalciteFlowItemClose:()=>this.visible=!1},v("calcite-list",{canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-layer-type":d,displayMode:F,dragEnabled:r,filterEnabled:a,filterPlaceholder:h,filterProps:g,filterText:a?u:"",group:d,key:"root-list",label:p.widgetLabel,selectionAppearance:"border",selectionMode:c,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.currentTarget?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},n?.toArray().map((e=>this._renderItem(e))),n?.length&&a?v("div",{class:_.filterNoResults,slot:"filter-no-results"},v("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems()];return e?l?v("calcite-flow",{key:"root-flow"},f):f:null}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:s}=e;t.insertBefore(i,t.children[s])}_renderItem(e){return v(a,{canMove:this._canMove,css:_,displayMode:F,dragEnabled:this.dragEnabled,item:e,key:`layerListItem-${e.layer.uid}`,listModeDisabled:this.viewModel.listModeDisabled,messages:this.messages,messagesCommon:this.messagesCommon,rootGroupUid:this._rootGroupUid,selectedDragItemLayerUid:this._selectedDragItemLayerUid,selectedItems:this.selectedItems,selectionMode:this.selectionMode,visibleElements:this.visibleElements,onAction:this._onTriggerAction,onPanelOpen:this._onPanelOpen,onSelectedDragItemLayerUidChange:this._onSelectedDragItemLayerUidChange})}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const s=e.target.selectedItems.map((e=>C(e))).filter(Boolean);i.removeAll(),i.addMany(s)}};e([l()],P.prototype,"_focusRootFlowItem",void 0),e([l()],P.prototype,"_focusPanelFlowItem",void 0),e([l()],P.prototype,"_dragEnabled",null),e([l()],P.prototype,"_filterEnabled",null),e([l()],P.prototype,"_visibleItems",null),e([l()],P.prototype,"_openedPanelItems",null),e([l()],P.prototype,"collapsed",void 0),e([l()],P.prototype,"dragEnabled",void 0),e([l()],P.prototype,"filterPlaceholder",void 0),e([l()],P.prototype,"filterText",void 0),e([l()],P.prototype,"headingLevel",void 0),e([l()],P.prototype,"icon",null),e([l()],P.prototype,"label",null),e([l()],P.prototype,"listItemCanGiveFunction",void 0),e([l()],P.prototype,"listItemCanReceiveFunction",void 0),e([l()],P.prototype,"listItemCreatedFunction",null),e([l()],P.prototype,"map",null),e([l(),I("esri/widgets/TableList/t9n/TableList")],P.prototype,"messages",void 0),e([l(),I("esri/t9n/common")],P.prototype,"messagesCommon",void 0),e([l()],P.prototype,"minDragEnabledItems",void 0),e([l()],P.prototype,"minFilterItems",void 0),e([l()],P.prototype,"selectedItems",void 0),e([l()],P.prototype,"selectionMode",void 0),e([l({readOnly:!0})],P.prototype,"tableItems",null),e([l()],P.prototype,"tables",null),e([b("trigger-action"),l({type:y})],P.prototype,"viewModel",void 0),e([l({type:L,nonNullable:!0})],P.prototype,"visibleElements",void 0),P=e([r("esri.widgets.TableList")],P);const j=P;export{j as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import i from"../core/Identifiable.js";import{on as o,watch as s,initial as l}from"../core/reactiveUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import a from"./Widget.js";import d from"./LayerList/LayerListItem.js";import{minDragEnabledItems as c,minFilterItems as m,getLayerType as p,removeDestroyedListItems as h,setFilterPredicate as u}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import{globalCss as f}from"./support/globalCss.js";import{calciteListFilterProps as I}from"./support/listUtils.js";import{setFocus as b}from"./support/widgetUtils.js";import{messageBundle as _}from"./support/decorators/messageBundle.js";import{vmEvent as v}from"./support/decorators/vmEvent.js";import{tsx as y}from"./support/jsxFactory.js";import{css as w}from"./TableList/css.js";import L from"./TableList/ListItem.js";import E from"./TableList/TableListViewModel.js";import C from"./TableList/TableListVisibleElements.js";import{getItem as F,sortTablesToIds as M}from"./TableList/support/tableListUtils.js";const P="flat",j=t.ofType(L);let D=class extends(i.IdentifiableMixin(a)){constructor(e,t){super(e,t),this._rootListEl=null,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`table-${this.uid}`,this.collapsed=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterPredicate=null,this.filterText="",this.headingLevel=2,this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.messages=null,this.messagesCommon=null,this.minDragEnabledItems=c,this.minFilterItems=m,this.selectedItems=new j,this.selectionMode="none",this.viewModel=new E,this.visibleElements=new C,this._canMove=({dragEl:e,fromEl:t,toEl:i},o)=>{const s="pull"===o?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,l=F(e);if(!l?.sortable)return!1;const r=F(t),n=p(t),a=F(i),d=p(i),c=!!n&&!!d&&n===d,m={selected:l,from:r,to:a},h=t.group,u=i.group;return h&&u&&"function"==typeof s?s.call(null,m):c},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:o,dragEl:s,newIndex:l}=e;if(!o||!i||t?.newIndex===l&&t?.dragEl===s&&t?.toEl===i&&t?.fromEl===o)return;this._lastDragDetail=e,this._selectedDragItemLayerUid=s.value;const r=Array.from(o.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));M(this.map?.tables,r)},this._onSelectedDragItemLayerUidChange=e=>{this._selectedDragItemLayerUid=e},this._onTriggerAction=(e,t)=>{this.triggerAction(e,t)},this._onPanelOpen=()=>{this._focusPanelFlowItem=!0}}initialize(){this.addHandles([o((()=>this.viewModel.tableItems),"change",(()=>h(this.selectedItems)),l),s((()=>[this.filterPredicate,this._rootListEl]),(()=>u(this._rootListEl,this.filterPredicate)))])}loadDependencies(){return g({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}get _dragEnabled(){return this.viewModel.totalItems>=this.minDragEnabledItems&&this.dragEnabled}get _filterEnabled(){return this.viewModel.totalItems>=this.minFilterItems&&this.visibleElements.filter}get _visibleItems(){return this.tableItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}get _openedPanelItems(){return this._visibleItems.filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled))}get icon(){return"table"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get tableItems(){return this.viewModel.tableItems}get tables(){return this.viewModel.tables}set tables(e){this.viewModel.tables=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,{_visibleItems:t}=this,i={[f.hidden]:"loading"===e,[f.disabled]:"disabled"===e};return y("div",{class:this.classes(w.base,f.widget,f.panel,i)},t?.length?this._renderItems():this._renderNoItems())}_renderNoItemsMessage(){return y("div",{slot:"message"},this.messages.noItemsToDisplay)}_renderNoItems(){return y("div",{class:w.itemMessage,key:"esri-layer-list__no-items"},y("calcite-notice",{icon:"information",kind:"info",open:!0,width:"full"},this._renderNoItemsMessage()))}_renderPanelFlowItems(){const{_openedPanelItems:e}=this;return e.toArray().map((({title:t,panel:i},o)=>{const s=()=>this._handlePanelFlowItemBack(i);return y("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:t,heading:i.title,headingLevel:this.headingLevel,key:`flow-panel-${i.uid}`,selected:o===e.length-1,onCalciteFlowItemBack:e=>{e.preventDefault(),s()}},i.render(),y("calcite-button",{appearance:"transparent",onclick:s,slot:"footer-actions",width:"full"},this.messagesCommon.back))}))}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,b(e))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,b(e))}_renderItems(){const{visible:e,collapsed:t,visibleElements:{closeButton:i,collapseButton:o,heading:s,flow:l},_dragEnabled:r,_visibleItems:n,_filterEnabled:a,_rootGroupUid:d,_openedPanelItems:c,selectionMode:m,messages:p,filterPlaceholder:h,filterText:u}=this,g=[y("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:i,closed:!e,collapsed:t,collapsible:o,heading:s?p.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",selected:!c.length,onCalciteFlowItemClose:()=>this.visible=!1},y("calcite-list",{afterCreate:e=>{this._rootListEl=e},afterRemoved:()=>{this._rootListEl=null},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-layer-type":d,displayMode:P,dragEnabled:r,filterEnabled:a,filterPlaceholder:h,filterProps:I,filterText:a?u:"",group:d,key:"root-list",label:p.widgetLabel,selectionAppearance:"border",selectionMode:m,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.currentTarget?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},n?.toArray().map((e=>this._renderItem(e))),n?.length&&a?y("div",{class:w.filterNoResults,slot:"filter-no-results"},y("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems()];return e?l?y("calcite-flow",{key:"root-flow"},g):g:null}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:o}=e;t.insertBefore(i,t.children[o])}_renderItem(e){return y(d,{canMove:this._canMove,css:w,displayMode:P,dragEnabled:this.dragEnabled,item:e,key:`layerListItem-${e.layer.uid}`,listModeDisabled:this.viewModel.listModeDisabled,messages:this.messages,messagesCommon:this.messagesCommon,rootGroupUid:this._rootGroupUid,selectedDragItemLayerUid:this._selectedDragItemLayerUid,selectedItems:this.selectedItems,selectionMode:this.selectionMode,visibleElements:this.visibleElements,onAction:this._onTriggerAction,onPanelOpen:this._onPanelOpen,onSelectedDragItemLayerUidChange:this._onSelectedDragItemLayerUidChange})}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const o=e.target.selectedItems.map((e=>F(e))).filter(Boolean);i.removeAll(),i.addMany(o)}};e([r()],D.prototype,"_rootListEl",void 0),e([r()],D.prototype,"_focusRootFlowItem",void 0),e([r()],D.prototype,"_focusPanelFlowItem",void 0),e([r()],D.prototype,"_dragEnabled",null),e([r()],D.prototype,"_filterEnabled",null),e([r()],D.prototype,"_visibleItems",null),e([r()],D.prototype,"_openedPanelItems",null),e([r()],D.prototype,"collapsed",void 0),e([r()],D.prototype,"dragEnabled",void 0),e([r()],D.prototype,"filterPlaceholder",void 0),e([r()],D.prototype,"filterPredicate",void 0),e([r()],D.prototype,"filterText",void 0),e([r()],D.prototype,"headingLevel",void 0),e([r()],D.prototype,"icon",null),e([r()],D.prototype,"label",null),e([r()],D.prototype,"listItemCanGiveFunction",void 0),e([r()],D.prototype,"listItemCanReceiveFunction",void 0),e([r()],D.prototype,"listItemCreatedFunction",null),e([r()],D.prototype,"map",null),e([r(),_("esri/widgets/TableList/t9n/TableList")],D.prototype,"messages",void 0),e([r(),_("esri/t9n/common")],D.prototype,"messagesCommon",void 0),e([r()],D.prototype,"minDragEnabledItems",void 0),e([r()],D.prototype,"minFilterItems",void 0),e([r()],D.prototype,"selectedItems",void 0),e([r()],D.prototype,"selectionMode",void 0),e([r({readOnly:!0})],D.prototype,"tableItems",null),e([r()],D.prototype,"tables",null),e([v("trigger-action"),r({type:E})],D.prototype,"viewModel",void 0),e([r({type:C,nonNullable:!0})],D.prototype,"visibleElements",void 0),D=e([n("esri.widgets.TableList")],D);const T=D;export{T as default};
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[1728],{71728:(e,t,a)=>{a.r(t),a.d(t,{default:()=>S});var i,n,o=a(90237),s=(a(59456),a(67996)),r=a(5503),l=a(49186),h=a(53966),d=a(91869),c=a(92071),u=a(74887),p=a(36708),y=a(10107),g=(a(44208),a(87811),a(40608)),m=a(35666),f=a(4146),L=a(90708);(n=i||(i={})).MULTIPLIER="multiplier",n.ABSOLUTE="absolute-value";var b=a(80340),M=a(70643),w=a(85342),T=a(69860),k=a(30504),C=a(63074),N=a(16131),v=a(25036),x=a(8460),D=a(71402),E=a(5443),A=a(86738),_=a(82799);let I=class extends((0,N.q)((0,C.dM)((0,v.j)((0,c.P)(f.A))))){constructor(e){if(super(e),this.dataPreloadedInLocalCache=!1,this.defaultLinkChartConfig=null,this.membershipModified=!0,this._currentLinkChartConfig={layoutMode:"radial-root-centric"},this._graphTypeLookup=new Map,this.dataManager=null,this.knowledgeGraph=null,this.layers=new(r.A.ofType(M.A)),this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map,this.linkChartExtent=new E.A({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7}),this.memberEntityTypes=null,this.memberRelationshipTypes=null,this.operationalLayerType="LinkChartLayer",this.sublayerIdsCache=new Map,this.tables=new(r.A.ofType(M.A)),this.type="link-chart",this.chronologicalAuxiliaryGraphics=null,this._originalInclusionList=e?.inclusionModeDefinition,e?.dataPreloadedInLocalCache&&!e?.inclusionModeDefinition)throw new l.A("knowledge-graph:linkchart-layer-constructor","If creating a link chart composite layer and configured that data is already loaded in the cache, you must specify an inclusion list so the Composite Layer knows what records belong to it");this.addHandles((0,p.wB)((()=>this.layers.concat(this.tables)),((e,t)=>this._handleSublayersChange(e,t)),p.OH))}normalizeCtorArgs(e){if(!e)return{};const{url:t,title:a,dataPreloadedInLocalCache:i,defaultLinkChartConfig:n}=e;return{url:t,title:a,dataPreloadedInLocalCache:i,defaultLinkChartConfig:n}}_initializeLayerProperties(e){if(!this.title&&this.url){const e=this.url.split("/");this.title=e[e.length-2]}const t=new Set;let a=[],i=[];if(e.inclusionModeDefinition&&(!e.inclusionModeDefinition.namedTypeDefinitions||e.inclusionModeDefinition.namedTypeDefinitions.size<1))throw new l.A("knowledge-graph:composite-layer-constructor","If an explicit inclusion definition is defined, at least one namedTypeDefinition must also be defined");e.inclusionModeDefinition?.generateAllSublayers?(a=e.knowledgeGraph.dataModel.entityTypes??[],i=e.knowledgeGraph.dataModel.relationshipTypes??[]):e.inclusionModeDefinition?.namedTypeDefinitions&&e.inclusionModeDefinition?.namedTypeDefinitions.size>0?e.inclusionModeDefinition?.namedTypeDefinitions.forEach(((n,o)=>{const s=this._graphTypeLookup.get(o);if(!s)return h.A.getLogger(this).warn(`A named type, ${o}, was in the inclusion list that wasn't in the data model and will be removed`),void e.inclusionModeDefinition?.namedTypeDefinitions.delete(o);"relationship"===s.type?t.has(o)||(t.add(o),i.push(s)):"entity"===s.type?t.has(o)||(t.add(o),a.push(s)):(h.A.getLogger(this).warn(`A named type, ${o}, was in the inclusion list that wasn't properly modeled and will be removed`),e.inclusionModeDefinition?.namedTypeDefinitions.delete(o))})):(a=e.knowledgeGraph.dataModel.entityTypes??[],i=e.knowledgeGraph.dataModel.relationshipTypes??[]);const n=new b.P({knowledgeGraph:e.knowledgeGraph,inclusionModeDefinition:e.inclusionModeDefinition});this.knowledgeGraph=e.knowledgeGraph,this.memberEntityTypes=a,this.memberRelationshipTypes=i,this.dataManager=n}load(e){const t=async()=>{const e=[],t=[];this.loadLayerAssumingLocalCache(),await(0,w.qN)(this),this.dataManager.inclusionModeDefinition&&(this.dataManager.inclusionModeDefinition.generateAllSublayers=!1),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach((e=>{e.useAllData=!1})),await this._initializeDiagram(),this.layers.forEach((a=>{t.push(a.refreshCachedQueryEngine()),e.push(new Promise((e=>{a.on("layerview-create",(()=>{e(null)}))})))})),this.tables.forEach((e=>{t.push(e.refreshCachedQueryEngine())})),await Promise.all(t)};return this.addResolvingPromise(new Promise((a=>{(0,D.fetchKnowledgeGraph)(this.url).then((async i=>{i.dataModel.entityTypes?.forEach((e=>{e.name&&this._graphTypeLookup.set(e.name,e)})),i.dataModel.relationshipTypes?.forEach((e=>{e.name&&this._graphTypeLookup.set(e.name,e)}));const n=this.parent?.linkChartProperties;if(n?.originIdOf("entitiesUrl")===m.Gr.LINK_CHART&&(this.membershipModified=!1,this._originalInclusionList=await s.XW.fetchAndConvertSerializedLinkChart({entitiesUrl:this.parent.linkChartProperties.entitiesUrl,relationshipsUrl:this.parent.linkChartProperties.relationshipsUrl}),this._alignLayersDataModelAndInclusionDefinition(i.dataModel),this.defaultLinkChartConfig={layoutSettings:n?.layoutSettings??void 0,layoutMode:(0,k.k5)(n.layoutType)}),this._initializeLayerProperties({knowledgeGraph:i,inclusionModeDefinition:this._originalInclusionList}),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.size||(this.dataManager.inclusionModeDefinition={generateAllSublayers:!1,namedTypeDefinitions:new Map},this.dataManager.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})})),this.dataManager.knowledgeGraph.dataModel.relationshipTypes?.forEach((e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})}))),this.dataPreloadedInLocalCache){const e=T.A.getInstance();for(const[t,a]of this.dataManager.inclusionModeDefinition?.namedTypeDefinitions??[])for(const i of a.members?.values()??[]){const a=e.readFromStoreById(`${t}__${i.id}`);a&&(0,d.tE)(this.dataManager.sublayerCaches,t,(()=>new Map)).set(i.id,a)}await t()}else{const a="geographic-organic-standard"===this.defaultLinkChartConfig?.layoutMode;this.addResolvingPromise(this.dataManager.refreshCacheContent(void 0,!1,a,!0).then((async()=>{(0,u.Te)(e),await t()})))}a(null)}))}))),Promise.resolve(this)}set inclusionModeDefinition(e){"loaded"!==this.loadStatus&&"failed"!==this.loadStatus?this._set("inclusionModeDefinition",e):h.A.getLogger(this).error("#inclusionModeDefinition","inclusionModeDefinition cannot be changed after the layer is loaded.")}async addRecords(e,t){let a=[];t?.cascadeAddRelationshipEndNodes&&this.dataManager.knowledgeGraph.dataModel&&(a=await(0,k.aq)(e,this.dataManager.knowledgeGraph));const i=e.concat(a).filter((e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id)));i.length>0&&(this.membershipModified=!0),await this._handleNewRecords(i,t)}async removeRecords(e,{cascadeRemoveRelationships:t=!0,recalculateLayout:a=!1,overrideMembershipCheck:i=!1}={cascadeRemoveRelationships:!0,recalculateLayout:!1,overrideMembershipCheck:!1}){let n=[];for(const t of e)(i||!1===this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(t.typeName)?.useAllData&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(t.typeName)?.members?.has(t.id))&&n.push(t);if(t){const e=new Set,t=[];for(const t of n)if(this.dataManager.nodeConnectionsLookup.has(t.id))for(const a of this.dataManager.nodeConnectionsLookup.get(t.id))e.add(a);for(const a of e)if(this.dataManager.memberIdTypeLookup.has(a))for(const e of this.dataManager.memberIdTypeLookup.get(a))this.dataManager.relationshipTypeNames.has(e)&&t.push({id:a,typeName:e});n=n.concat(t)}this.dataManager.removeFromLayer(n);for(const e of n)this.sublayerIdsCache.get(e.typeName)?.delete(e.id),this.dataManager.relationshipTypeNames.has(e.typeName)?this.relationshipLinkChartDiagramLookup.delete(e.id):this.entityLinkChartDiagramLookup.delete(e.id);a&&await this._calculateLayoutWithSublayerTimeInfo(this._currentLinkChartConfig.layoutMode,{layoutSettings:this._currentLinkChartConfig.layoutSettings}),n.length>0&&(this.membershipModified=!0);const o=[];return this.layers.forEach((e=>{o.push(e.refreshCachedQueryEngine())})),await Promise.all(o),this._refreshNamedTypes(),n}async expand(e,t){let a=[];try{const i=await this.dataManager.getConnectedRecordIds(e,t?.relationshipTypeNames,t);a=i.filter((e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id))),await this._handleNewRecords(i,t),i.length>0&&(this.membershipModified=!0),(0,u.Te)(t?.signal)}catch(e){throw(0,u.zf)(e)&&a.length>0&&this.removeRecords(a,{overrideMembershipCheck:!0}),e}return{records:a}}loadLayerAssumingLocalCache(){const e=[...this.memberRelationshipTypes,...this.memberEntityTypes];this.originIdOf("layers")===m.Gr.DEFAULTS?this._createSublayers(e,this.layers,(e=>!!e.geometryType)):this._updateSublayers(e,this.layers),this.originIdOf("tables")===m.Gr.DEFAULTS?this._createSublayers(e,this.tables,(e=>!e.geometryType)):this._updateSublayers(e,this.tables),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach(((e,t)=>{const a=(0,d.tE)(this.sublayerIdsCache,t,(()=>new Set));e.members?.forEach((({id:e,linkChartLocation:i})=>{if(a.add(e),i){const a="coords"in i&&"lengths"in i?i:(0,L.Ux)(i);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(e,a):this.entityLinkChartDiagramLookup.set(e,a)}}))}))}async calculateLinkChartLayout(e="radial-root-centric",t){const a=[],i=[],n=[];this.dataManager.sublayerCaches.forEach(((e,t)=>{this.dataManager.entityTypeNames.has(t)?e.forEach((e=>{a.push({typeName:t,feature:e})})):this.dataManager.relationshipTypeNames.has(t)&&e.forEach((e=>{i.push({typeName:t,feature:e})}))})),this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map;const o=new Map,s=new Map,r=new Map,c=new Map,p=new Uint8Array(a.length),y=new Float64Array(a.length),g=new Float64Array(a.length),m=new Float64Array(a.length),f=new Float64Array(a.length),b=new Uint32Array(i.length),M=new Uint32Array(i.length),T=new Float64Array(i.length),k=new Float64Array(i.length),C=[],N=new E.A({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7});let v,D="organic-standard",I=0,S=0;const R=x.i6.apply;switch(D="geographic-organic-standard"===e?"organic-standard":e,D){case"organic-standard":v=x.pM.apply;break;case"organic-community":v=x.Tu.apply;break;case"hierarchical-bottom-to-top":v=x.$C.apply;break;case"radial-root-centric":v=x.vJ.apply;break;case"tree-left-to-right":v=x.Xq.apply;break;default:v=x.Wg.apply}let G=!1;a.forEach((({typeName:a,feature:i})=>{if("chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e&&t?.lockedNodeLocations?.has(i.attributes[w.dr])){"geographic-organic-standard"===e&&this.dataManager.geographicLookup.has(a)?p[I]=x.tx.IsGeographic:p[I]=x.tx.None;const n=t.lockedNodeLocations.get(i.attributes[w.dr]);y[I]=n.x,g[I]=n.y}else if("geographic-organic-standard"===e&&this.dataManager.geographicLookup.has(a)){p[I]=x.tx.IsGeographic;let e=null;const t=i.attributes[this.dataManager.geographicLookup.get(a).name],n=this.dataManager.geographicLookup.get(a)?.geometryType;switch(n){case"esriGeometryPoint":y[I]=t?.x,g[I]=t?.y;break;case"esriGeometryPolygon":e=t?.centroid,null!=e?.x&&null!=e?.y?(y[I]=e.x,g[I]=e.y):p[I]=x.tx.IsMovable;break;case"esriGeometryPolyline":case"esriGeometryMultipoint":e=t?.extent?.center,null!=e?.x&&null!=e?.y?(y[I]=e.x,g[I]=e.y):p[I]=x.tx.IsMovable;break;default:p[I]=x.tx.IsMovable}(null==y[I]||null==g[I]||Number.isNaN(y[I])||Number.isNaN(g[I]))&&(p[I]=x.tx.IsMovable,y[I]=0,g[I]=0)}else if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){!G&&t?.lockedNodeLocations?.has(i.attributes[w.dr])&&(G=!0);const e=t?.timeInfoByTypeName?.get(a),n=e?.startField,o=n&&e?.startField?i.attributes[n]:null;m[I]=o?new Date(o).getTime():NaN;const s=e?.endField,r=s&&e?.endField?i.attributes[s]:null;f[I]=r?new Date(r).getTime():NaN,y[I]=0,g[I]=0,p[I]=x.tx.IsMovable}else p[I]=x.tx.IsMovable,y[I]=0,g[I]=0;c.set(i.attributes[w.dr],I),C[I]={feature:i,typeName:a},I++})),G&&h.A.getLogger(this).warn("Locked node locations are not supported for chronological layout at this time. Requested node locations were ignored");let P=!1;const F=new Map;i.forEach((a=>{const i=a.feature.attributes[w.Cz],o=a.feature.attributes[w.KQ],s=c.get(i),r=c.get(o),l=t?.timeInfoByTypeName?.get(a.typeName),h=t?.timeInfoByTypeName?l?.startField:null,d=h?a.feature.attributes[h]:null,u=l?.endField,p=u?a.feature.attributes[u]:null;if(void 0!==s&&void 0!==r){let t=i+"-"+o;"chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e||(t=t+"-"+d+"-"+p);const l=F.get(t),h=l?.has(a.typeName);h||(b[S]=s,M[S]=r,"chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e||(T[S]=d?new Date(d).getTime():NaN,k[S]=p?new Date(p).getTime():NaN),void 0===l?F.set(t,new Map([[a.typeName,S]])):l.set(a.typeName,S),S++),n.push(a)}else P=!0,this.relationshipLinkChartDiagramLookup.set(i,null)})),P&&h.A.getLogger(this).warn("A relationship is a member of this layer that has either origin or destination entity nodes that are not members. The diagram geometry will be set to null");const B=this._validateLayoutSettings(e,t?.layoutSettings),U=this._convertLayoutSettingsToCalculationSettings(B);await(0,x.Hh)();let z=x.JT.Error,Z=null;if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){let a;({status:z,links:Z,graphics:a}=R((()=>t?.signal?.aborted??!1),p,y,g,m,f,b.subarray(0,S),M.subarray(0,S),T.subarray(0,S),k.subarray(0,S),"chronological-multi-timeline"===e,t?.layoutSettings?.chronologicalLayoutSettings??{})),z===x.JT.Success&&(this.chronologicalAuxiliaryGraphics=a)}else({status:z,links:Z}=v((()=>t?.signal?.aborted??!1),p,y,g,b.subarray(0,S),M.subarray(0,S),U.computationBudgetTime,U.idealEdgeLengthMultiplier,U.repulsionRadiusMultiplier));if((0,u.Te)(t?.signal),z===x.JT.Error)throw new l.A("knowledge-graph:layout-failed","Attempting to arrange the records in the specified layout failed");if(z===x.JT.Canceled)throw(0,u.NK)();for(let e=0;e<C.length;e++){if(g[e]>84.9999?g[e]=84.9999:g[e]<-84.9999&&(g[e]=-84.9999),y[e]>179.9999?y[e]=179.9999:y[e]<-179.9999&&(y[e]=-179.9999),C[e].feature.attributes[w.T1]=new A.A(y[e],g[e]),o.has(C[e].typeName)){const t=o.get(C[e].typeName);t?.set(C[e].feature.attributes[w.dr],C[e].feature)}else{const t=new Map;t.set(C[e].feature.attributes[w.dr],C[e].feature),o.set(C[e].typeName,t)}r.set(C[e].feature.attributes[w.dr],C[e].feature);const t=(0,L.Ux)(C[e].feature.attributes[w.T1]);this.entityLinkChartDiagramLookup.set(C[e].feature.attributes[w.dr],C[e].feature.attributes[w.T1]?t:null);const a=(0,d.tE)(this.dataManager.inclusionModeDefinition.namedTypeDefinitions,C[e].typeName,(()=>({useAllData:!1,members:new Map})));(0,d.tE)(a.members,C[e].feature.attributes[w.dr],(()=>({id:C[e].feature.attributes[w.dr],linkChartLocation:void 0}))).linkChartLocation=C[e].feature.attributes[w.T1],C[e].feature.attributes[w.T1].x<N.xmin&&(N.xmin=C[e].feature.attributes[w.T1].x),C[e].feature.attributes[w.T1].x>N.xmax&&(N.xmax=C[e].feature.attributes[w.T1].x),C[e].feature.attributes[w.T1].y<N.ymin&&(N.ymin=C[e].feature.attributes[w.T1].y),C[e].feature.attributes[w.T1].y>N.ymax&&(N.ymax=C[e].feature.attributes[w.T1].y)}if(this.linkChartExtent.xmin=N.xmin,this.linkChartExtent.xmax=N.xmax,this.linkChartExtent.ymin=N.ymin,this.linkChartExtent.ymax=N.ymax,!Z)throw new l.A("knowledge-graph:layout-failed","Attempting to retrieve link geometry from diagram engine failed");const O=new Map,j=new Map,W=new Map,Q=new Set;for(let a=0;a<n.length;a++){const i=[],o=n[a],l=o.feature.attributes[w.Cz],u=o.feature.attributes[w.KQ];let p=l+"-"+u;if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){const e=t?.timeInfoByTypeName?.get(o.typeName),a=t?.timeInfoByTypeName?e?.startField:null,i=a?o.feature.attributes[a]:null,n=e?.endField;p+="-"+i+"-"+(n?o.feature.attributes[n]:null)}const y=F.get(p).get(o.typeName),g=0===y?0:Z?.vertexEndIndex[y-1];if(!Q.has(y)){if(Q.add(y),Z.types[y]===x.J.Recursive){const e=[Z.vertices[2*g],Z.vertices[2*g+1]],t=[Z.vertices[2*(g+1)],Z.vertices[2*(g+1)+1]],a=[.5*(e[0]+t[0]),.5*(e[1]+t[1])],n=[a[0]-e[0],a[1]-e[1]],o=[a[0]+n[1],a[1]-n[0]],s=[a[0]-n[1],a[1]+n[0]];i.push(e),i.push(o),i.push(t),i.push(s),i.push(e)}else{if(Z.types[y]!==x.J.Regular){h.A.getLogger(this).warn("A relationship generated an unsupported link geometry type. It will not be rendered");continue}for(let e=g;e<Z.vertexEndIndex[y];e++)i.push([Z.vertices[2*e],Z.vertices[2*e+1]])}if("chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e){const e=C[c.get(l)]?.feature.attributes[w.T1],t=C[c.get(u)]?.feature.attributes[w.T1];i[0][0]===e.x&&i[0][1]===e.y||(i[0]=[e.x,e.y]),i[i.length-1][0]===t.x&&i[i.length-1][1]===t.y||(i[i.length-1]=[t.x,t.y])}for(let e=1;e<i.length-1;e++)i[e][1]>85.5?i[e][1]=85.5:i[e][1]<-85.5&&(i[e][1]=-85.5),i[e][0]>179.9999?i[e][0]=179.9999:i[e][0]<-179.9999&&(i[e][0]=-179.9999);O.has(p)?O.get(p).push(i):O.set(p,[i])}const m=O.get(p);j.has(p)||(j.set(p,new Map),W.set(p,new Map));const f=j.get(p),b=W.get(p);f.has(o.typeName)||(f.set(o.typeName,m.shift()),b.set(o.typeName,0));const M=f.get(o.typeName);b.set(o.typeName,b.get(o.typeName)+1);const T=new _.A({paths:[M]});if(o.feature.attributes[w.T1]=T,s.has(o.typeName)){const e=s.get(o.typeName);e?.set(o.feature.attributes[w.dr],o.feature)}else{const e=new Map;e.set(o.feature.attributes[w.dr],o.feature),s.set(o.typeName,e)}r.set(o.feature.attributes[w.dr],o.feature);const k=(0,L.Ux)(o.feature.attributes[w.T1]);this.relationshipLinkChartDiagramLookup.set(o.feature.attributes[w.dr],o.feature.attributes[w.T1]?k:null);const N=(0,d.tE)(this.dataManager.inclusionModeDefinition.namedTypeDefinitions,o.typeName,(()=>({useAllData:!1,members:new Map})));(0,d.tE)(N.members,o.feature.attributes[w.dr],(()=>({id:o.feature.attributes[w.dr],linkChartLocation:void 0}))).linkChartLocation=o.feature.attributes[w.T1]}for(const e of n)e.feature.attributes[w.M1]=W.get(e.feature.attributes[w.Cz]+"-"+e.feature.attributes[w.KQ])?.get(e.typeName)??null;return this._currentLinkChartConfig={layoutMode:e,layoutSettings:B},{nodes:o,links:s,idMap:r}}async applyNewLinkChartLayout(e="radial-root-centric",t){const a=[];await this._calculateLayoutWithSublayerTimeInfo(e,t),this.layers.forEach((e=>{a.push(e.refreshCachedQueryEngine())})),this.membershipModified=!0,await Promise.all(a),this._refreshNamedTypes()}getCurrentNodeLocations(){const e=new Map;for(const[t,a]of this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.entries()??[])this.dataManager.relationshipTypeNames.has(t)||a?.members?.forEach((t=>{const a=t.linkChartLocation;let i;const n=t.id;a&&(i="x"in a?{x:a.x,y:a.y}:{x:a.coords[0],y:a.coords[1]},e.set(n,new A.A({x:i.x,y:i.y})))}));return e}async refreshLinkChartCache(e){await this.dataManager.refreshCacheContent(e);const t=[];this.layers.forEach((e=>{t.push(e.refreshCachedQueryEngine())})),await Promise.all(t),this._refreshNamedTypes()}async connectBetweenEntities(e,t){if(!e.length)return{records:[]};let a=[];try{let i=[];for(const e of this.dataManager.relationshipTypeNames){const t=this.sublayerIdsCache.get(e);t&&(i=i.concat(Array.from(t.keys())))}a=await this.dataManager.getRelationshipsBetweenNodes(e,i,t),await this._handleNewRecords(a,t),(0,u.Te)(t)}catch(e){throw(0,u.zf)(e)&&this.removeRecords(a),e}return{records:a}}async connectFromEntities(e,t){if(!e.length)return{records:[]};let a=[];try{let i=[];for(const e of this.dataManager.relationshipTypeNames){const t=this.sublayerIdsCache.get(e);t&&(i=i.concat(Array.from(t.keys())))}let n=[];for(const e of this.dataManager.entityTypeNames){const t=this.sublayerIdsCache.get(e);t&&(n=n.concat(Array.from(t)))}a=await this.dataManager.getRelationshipsFromNodes(e,n,i,t),await this._handleNewRecords(a,t),a.length>0&&(this.membershipModified=!0),(0,u.Te)(t)}catch(e){throw(0,u.zf)(e)&&this.removeRecords(a),e}return{records:a}}getCurrentLayout(){return this._currentLinkChartConfig.layoutMode}async _calculateLayoutWithSublayerTimeInfo(e="radial-root-centric",t){const a=new Map;this.layers.forEach((e=>{a.set(e.objectType.name,e.timeInfo)})),await this.calculateLinkChartLayout(e,{timeInfoByTypeName:a,...t})}async _handleNewRecords(e,t){const a=[];this.dataManager.addToLayer(e);for(const t of e)this.sublayerIdsCache.has(t.typeName)||(this.sublayerIdsCache.set(t.typeName,new Set),a.push(t.typeName)),this.sublayerIdsCache.get(t.typeName).add(t.id);for(const e of a){const t=this._graphTypeLookup.get(e);if(t){const a=this._createSublayer(t);"entity"===t.type?this.dataManager.entityTypeNames.add(e):this.dataManager.relationshipTypeNames.add(e),a.geometryType?this.layers.push(a):this.tables.push(a),this.dataManager.sublayerCaches.set(e,new Map)}}await(0,w.qN)(this,a,t),await this.dataManager.refreshCacheContent(e.map((e=>e.id)),void 0,void 0,void 0,t);const i=Object.assign({},this._currentLinkChartConfig.layoutSettings);i.lockedNodeLocations=new Map;for(const[e,t]of this.entityLinkChartDiagramLookup.entries())t&&i.lockedNodeLocations.set(e,new A.A(t.coords[0],t.coords[1]));await this.applyNewLinkChartLayout(this._currentLinkChartConfig.layoutMode,{layoutSettings:i})}_createSublayers(e,t,a){e.forEach((e=>{const i=this._createSublayer(e);a(i)&&t.push(i),this._updateSublayerCaches(e)}))}_updateSublayers(e,t){t.forEach((t=>{t.parentCompositeLayer=this;const a=e.find((e=>e.type===t.graphType&&e.name===t.graphTypeName));a&&(t.objectType=a,t.read({title:a.name},{origin:"service"}),this._updateSublayerCaches(a))}))}_updateSublayerCaches(e){const t=this.dataManager.sublayerCaches;t.has(e.name)||t.set(e.name,new Map)}async _initializeDiagram(){this.defaultLinkChartConfig?this.defaultLinkChartConfig.doNotRecalculateLayout?(this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach(((e,t)=>{e?.members?.forEach((e=>{const a=e.linkChartLocation;let i;const n=e.id;if(!a)return;i="x"in a?{x:a.x,y:a.y}:{x:a.coords[0],y:a.coords[1]};const o=(0,L.Ux)(i);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(n,o):this.entityLinkChartDiagramLookup.set(n,o),this.linkChartExtent.xmin>i.x&&(this.linkChartExtent.xmin=i.x),this.linkChartExtent.xmax<i.x&&(this.linkChartExtent.xmax=i.x),this.linkChartExtent.ymin>i.y&&(this.linkChartExtent.ymin=i.y),this.linkChartExtent.ymax<i.y&&(this.linkChartExtent.ymax=i.y)}))})),this.memberRelationshipTypes.forEach((e=>{e.name&&this.dataManager.sublayerCaches.get(e.name)?.forEach((e=>{const t=this.relationshipLinkChartDiagramLookup.get(e.attributes[w.Cz]),a=this.relationshipLinkChartDiagramLookup.get(e.attributes[w.KQ]);if(t&&a){const i=(0,L.Ux)(new _.A({paths:[[[t.coords[0],t.coords[1]],[a.coords[0],a.coords[1]]]]}));this.relationshipLinkChartDiagramLookup.set(e.attributes[w.dr],i)}else this.relationshipLinkChartDiagramLookup.set(e.attributes[w.dr],null)}))}))):await this._calculateLayoutWithSublayerTimeInfo(this.defaultLinkChartConfig.layoutMode,{lockedNodeLocations:this.getCurrentNodeLocations(),...this.defaultLinkChartConfig||{}}):await this._calculateLayoutWithSublayerTimeInfo("radial-root-centric",{lockedNodeLocations:this.getCurrentNodeLocations()})}_refreshNamedTypes(){for(const e of this.layers)e.emit("refresh",{dataChanged:!0});for(const e of this.tables)e.emit("refresh",{dataChanged:!0})}_validateLayoutSettings(e,t){const a=e=>"number"==typeof e&&!isNaN(e),n=e=>a(e)&&e>=0,o={organicLayoutSettings:{},chronologicalLayoutSettings:{}};if(!new Set(["organic-standard","organic-community","geographic-organic-standard","chronological-multi-timeline","chronological-mono-timeline"]).has(e)||!t)return o;t.organicLayoutSettings??={};const{computationBudgetTime:s,repulsionRadiusMultiplier:r,absoluteIdealEdgeLength:l,multiplicativeIdealEdgeLength:d,idealEdgeLengthType:c}=t.organicLayoutSettings;if((e=>a(e)&&e>=1)(s)?o.organicLayoutSettings.computationBudgetTime=s:void 0!==s&&h.A.getLogger(this).warn("Invalid layout computationBudgetTime setting, will revert to default setting"),(e=>a(e)&&e>=1)(r)?o.organicLayoutSettings.repulsionRadiusMultiplier=r:void 0!==r&&h.A.getLogger(this).warn("Invalid layout repulsionRadiusMultiplier setting, will revert to default setting"),"geographic-organic-standard"===e&&(void 0!==l||void 0!==d||void 0!==c)&&((e=>Object.values(i).includes(e))(c)?o.organicLayoutSettings.idealEdgeLengthType=c:void 0!==c&&h.A.getLogger(this).warn('Invalid layout idealEdgeLengthType setting, will revert to "multiplier" setting'),"absolute-value"===c&&n(l)?o.organicLayoutSettings.absoluteIdealEdgeLength=l:"absolute-value"===c&&void 0!==l?h.A.getLogger(this).warn("Invalid layout idealEdgeLength setting, will revert to default setting"):"multiplier"===c&&n(d)?o.organicLayoutSettings.multiplicativeIdealEdgeLength=d:"multiplier"===c&&void 0!==d&&h.A.getLogger(this).warn("Invalid layout idealEdgeLength setting, will revert to default setting")),("chronological-multi-timeline"===e||"chronological-mono-timeline"===e)&&t.chronologicalLayoutSettings){const e=t.chronologicalLayoutSettings;e.durationLineWidth&&e.durationLineWidth<0&&h.A.getLogger(this).warn("Invalid layout durationLineWidth setting, will revert to default setting")}return o}_convertLayoutSettingsToCalculationSettings(e){e.organicLayoutSettings??={};let t=e.organicLayoutSettings.idealEdgeLengthType===i.ABSOLUTE?e.organicLayoutSettings.absoluteIdealEdgeLength:e.organicLayoutSettings.multiplicativeIdealEdgeLength;return e.organicLayoutSettings.idealEdgeLengthType===i.ABSOLUTE&&(void 0===t?t=-1:t*=-1),{computationBudgetTime:e.organicLayoutSettings.computationBudgetTime??void 0,repulsionRadiusMultiplier:e.organicLayoutSettings.repulsionRadiusMultiplier??void 0,idealEdgeLengthMultiplier:t}}_createSublayer(e){return new M.A({objectType:e,parentCompositeLayer:this,graphType:e.type})}_handleSublayersChange(e,t){t&&(t.forEach((e=>{e.parent=null})),this.removeHandles("sublayers-owner")),e&&(e.forEach((e=>{e.parent=this})),this.addHandles([e.on("after-add",(({item:e})=>{e.parent=this})),e.on("after-remove",(({item:e})=>{e.parent=null}))],"sublayers-owner"))}_alignLayersDataModelAndInclusionDefinition(e){const t=new Set((e.entityTypes??[]).map((e=>e.name)).concat((e.relationshipTypes??[]).map((e=>e.name)))),a=new Set((e.entityTypes??[]).map((e=>e.name))),i=new Set((e.relationshipTypes??[]).map((e=>e.name)));if(this.layers){for(const e of this.layers)!e.graphType&&t.has(e.graphTypeName)&&(e.graphType=a.has(e.graphTypeName)?"entity":"relationship");this.layers=this.layers.filter((e=>t.has(e.graphTypeName)&&("entity"===e.graphType?a.has(e.graphTypeName):i.has(e.graphTypeName))))}else this.layers=new r.A;if(this.layers&&this._originalInclusionList){const e=new Set(this._originalInclusionList.namedTypeDefinitions.keys()),t=this.tables?.map((e=>e.graphTypeName))??[],a=this.layers.map((e=>e.graphTypeName)).concat(t);for(const t of a)e.has(t)||this._originalInclusionList.namedTypeDefinitions.set(t,{useAllData:!1,members:new Map});const i=[];for(const e of this._originalInclusionList.namedTypeDefinitions.keys())a.includes(e)||(h.A.getLogger(this).warn(`A named type, ${e}, was in the serialized feature collection but did not have a sublayer config in the item, so will be removed`),i.push(e));for(const e of i)this._originalInclusionList.namedTypeDefinitions.delete(e)}}};(0,o._)([(0,y.MZ)()],I.prototype,"dataPreloadedInLocalCache",void 0),(0,o._)([(0,y.MZ)()],I.prototype,"defaultLinkChartConfig",void 0),(0,o._)([(0,y.MZ)()],I.prototype,"membershipModified",void 0),(0,o._)([(0,y.MZ)()],I.prototype,"dataManager",void 0),(0,o._)([(0,y.MZ)()],I.prototype,"inclusionModeDefinition",null),(0,o._)([(0,y.MZ)()],I.prototype,"knowledgeGraph",void 0),(0,o._)([(0,y.MZ)({type:r.A.ofType(M.A),json:{write:{ignoreOrigin:!0}}})],I.prototype,"layers",void 0),(0,o._)([(0,y.MZ)()],I.prototype,"entityLinkChartDiagramLookup",void 0),(0,o._)([(0,y.MZ)()],I.prototype,"relationshipLinkChartDiagramLookup",void 0),(0,o._)([(0,y.MZ)()],I.prototype,"linkChartExtent",void 0),(0,o._)([(0,y.MZ)()],I.prototype,"memberEntityTypes",void 0),(0,o._)([(0,y.MZ)()],I.prototype,"memberRelationshipTypes",void 0),(0,o._)([(0,y.MZ)({type:["LinkChartLayer"]})],I.prototype,"operationalLayerType",void 0),(0,o._)([(0,y.MZ)()],I.prototype,"sublayerIdsCache",void 0),(0,o._)([(0,y.MZ)({type:r.A.ofType(M.A),json:{write:{ignoreOrigin:!0}}})],I.prototype,"tables",void 0),(0,o._)([(0,y.MZ)({json:{read:!1}})],I.prototype,"type",void 0),(0,o._)([(0,y.MZ)({json:{read:!1}})],I.prototype,"chronologicalAuxiliaryGraphics",void 0),I=(0,o._)([(0,g.$)("esri.layers.LinkChartLayer")],I);const S=I}}]);