@arcgis/core 5.2.0-next.164 → 5.2.0-next.166

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 (168) hide show
  1. package/Graphic.d.ts +47 -14
  2. package/PopupTemplate.js +1 -1
  3. package/WebScene.d.ts +3 -0
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/{97d6ef9e34a43ad2e556.js → 02e10f44edf911832c2a.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{97b5f4302fb867c829f4.js → 07f7177bfaf9de73bc25.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{612345f17f5eeb99ea8f.js → 0d9c4c6c571ce26d356b.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{12a7997a40c77f5c9160.js → 151e5799ede763a03ee2.js} +1 -1
  9. package/assets/esri/core/workers/chunks/196979cc6a765be3c5cd.js +1 -0
  10. package/assets/esri/core/workers/chunks/1ab59a97ffa49e9e1659.js +1 -0
  11. package/assets/esri/core/workers/chunks/{8715661a838361d4211a.js → 1b24a40c0fa197014873.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{83f29a159b8b5197e76a.js → 266c90d8d56a2da42fcf.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{b1d989b72203113a06fe.js → 2a36fe3f3f257a779a1b.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{fcaf9450642fcef83286.js → 3048e74e6246324ce6fc.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{95b82cbbe355266c65d7.js → 30af63b3b750142faadb.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{74137ffec5265628c33b.js → 36c780a9527c75b36725.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{6a0ec102962d2c7b4368.js → 40d803584eeade4df433.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{a546ec82ba149e12f7bf.js → 41773d858e212468db88.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{129e04d24ced77c9bb6d.js → 49b967d89d2841cea675.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{b59aaf30c7fe2c8d1aaa.js → 4b99b4cf729881e616bc.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{a09d2e1e2540921e4717.js → 4d3d7ec407ee5cd5f036.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{2c626f525f3483c03477.js → 548b8f74a6883e364931.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{25a3bd8bede2d07d3a54.js → 5af8fb4ec2c72697e35b.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{340256866f524cb069f6.js → 5d2f043ebe1051326c56.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{3f46acfda693c70abbdd.js → 61552b4b8111a8624d84.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{e653c81ffb3d818645dd.js → 632fdf1d95ad69109427.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{434a8ba841a59e0deab9.js → 67e533748435253aaba6.js} +1 -1
  28. package/assets/esri/core/workers/chunks/69d5f8ef78b9b8b3d33d.js +1 -0
  29. package/assets/esri/core/workers/chunks/{feb41abc03d677df6f73.js → 6b9961261241fdce0e94.js} +1 -1
  30. package/assets/esri/core/workers/chunks/6f897b4e7ddd1dd1672b.js +1 -0
  31. package/assets/esri/core/workers/chunks/{e251921bc5367258c4d2.js → 710b8251a59884aee31e.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{af349c7bc8ef41a0e1bd.js → 7748c2886d0122b40eeb.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{8a7b02037151767542f1.js → 7dbf4c7480bf9c72820d.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{1bca39e0e651426bdbb5.js → 7dfbc31f3b56728485a4.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{c19f238b55ff2893f7c2.js → 82a022cc21364c9a8539.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{5cb26bbaa08114aec5ce.js → 89cc1a5539b82fb46216.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{8ab57cb1bfd3dc8d3c2a.js → 8b8118ab56cc808b5a71.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{542e5640ea1b80ef801a.js → 9189dfe19a2a2ccd5173.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{f74ae0eff3f08978e607.js → 9f358c7b052cdc0ac06f.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{ee08ae5b73439a1ff666.js → a163c6005aba3378edaa.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{ec9a2425b4a498054a19.js → a17673e691ced46a90d3.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{72bd866df89b8d92e247.js → a43b33955aa78a2a8deb.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{46c5371c7a627537098c.js → a88f346786b04bd194dc.js} +6 -6
  44. package/assets/esri/core/workers/chunks/{092e311cb7aea92a6a26.js → acb265a22be5e12f38e5.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{9e8f012a56237fc8285f.js → aea44253c80493ef5755.js} +1 -1
  46. package/assets/esri/core/workers/chunks/b5b9d42e1f84ee82429c.js +1 -0
  47. package/assets/esri/core/workers/chunks/c046c4fc934bc6f54c69.js +1 -0
  48. package/assets/esri/core/workers/chunks/{c72a904e01dc8c17d992.js → c47d095434d09b5f10c6.js} +1 -1
  49. package/assets/esri/core/workers/chunks/{226f862bbeb33fc7c597.js → c4b7111dcedd9d6e1c2a.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{81cad8d2f62a5f671c55.js → cb4db5489388559d6bd9.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{bbd44ac63d2a317d8ed9.js → cc794bb94ebc1cb66024.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{be308db5b61a7246edfe.js → cc94bf05b235e65291fc.js} +1 -1
  53. package/assets/esri/core/workers/chunks/d4af9faa5d901274fad2.js +1 -0
  54. package/assets/esri/core/workers/chunks/{fc5a36e54929e03efa86.js → dba5f44c4e4a3f075df2.js} +1 -1
  55. package/assets/esri/core/workers/chunks/{1f43e06dcfe56229bb0f.js → debe45e792212682b304.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{8414ffd937c1099e0bbc.js → e6d10136bc08aef255ff.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{45fd2b456a6997584ca1.js → f8379cd45f750f28a3d8.js} +1 -1
  58. package/assets/esri/core/workers/chunks/{709e019885822b1f6f3e.js → f905f1a1aa4c123cbe83.js} +1 -1
  59. package/assets/esri/core/workers/chunks/{a2fcbc494333376192aa.js → f9c80e9fc349db4873e8.js} +1 -1
  60. package/assets/esri/core/workers/chunks/{c070d2ddf290b4f92916.js → feb4f8c807bb0dca488f.js} +1 -1
  61. package/assets/esri/layers/raster/formats/lerc-wasm.wasm +0 -0
  62. package/chunks/GlobalIllumination.glsl.js +15 -30
  63. package/config.js +1 -1
  64. package/core/workers/WorkerFallback.js +4 -2
  65. package/core/workers/workerFactory.js +1 -1
  66. package/core/workers/workers.js +4 -2
  67. package/form/elements/inputs.d.ts +126 -25
  68. package/form/elements/inputs.js +1 -1
  69. package/form/elements.d.ts +1 -0
  70. package/graphic/AnnotationFeatureGraphicOrigin.d.ts +49 -9
  71. package/graphic/BuildingGraphicOrigin.d.ts +49 -0
  72. package/graphic/CSVGraphicOrigin.d.ts +42 -9
  73. package/graphic/CatalogGraphicOrigin.d.ts +42 -9
  74. package/graphic/DimensionFeatureGraphicOrigin.d.ts +42 -9
  75. package/graphic/FeatureGraphicOrigin.d.ts +42 -9
  76. package/graphic/GeoJSONGraphicOrigin.d.ts +42 -9
  77. package/graphic/GeoRSSGraphicOrigin.d.ts +42 -9
  78. package/graphic/GraphicOrigin.d.ts +52 -12
  79. package/graphic/ImageryGraphicOrigin.d.ts +42 -9
  80. package/graphic/ImageryTileGraphicOrigin.d.ts +42 -9
  81. package/graphic/KMLGraphicOrigin.d.ts +47 -10
  82. package/graphic/KnowledgeGraphGraphicOrigin.d.ts +49 -1
  83. package/graphic/LinkChartGraphicOrigin.d.ts +49 -1
  84. package/graphic/MapImageGraphicOrigin.d.ts +49 -1
  85. package/graphic/MapNotesGraphicOrigin.d.ts +48 -1
  86. package/graphic/OGCFeatureGraphicOrigin.d.ts +42 -9
  87. package/graphic/OrientedImageryGraphicOrigin.d.ts +42 -9
  88. package/graphic/ParquetGraphicOrigin.d.ts +42 -9
  89. package/graphic/PointCloudGraphicOrigin.d.ts +43 -0
  90. package/graphic/SceneGraphicOrigin.d.ts +43 -0
  91. package/graphic/SketchGraphicOrigin.d.ts +43 -0
  92. package/graphic/StreamGraphicOrigin.d.ts +43 -0
  93. package/graphic/SubtypeGroupGraphicOrigin.d.ts +49 -1
  94. package/graphic/TileGraphicOrigin.d.ts +49 -1
  95. package/graphic/VectorTileGraphicOrigin.d.ts +43 -14
  96. package/graphic/VoxelGraphicOrigin.d.ts +43 -0
  97. package/graphic/WCSGraphicOrigin.d.ts +43 -0
  98. package/graphic/WFSGraphicOrigin.d.ts +42 -9
  99. package/graphic/getGraphicOriginTitle.d.ts +21 -3
  100. package/kernel.js +1 -1
  101. package/layers/GaussianSplatLayer.d.ts +2 -1
  102. package/layers/GeospatialPDFLayer.js +1 -1
  103. package/layers/ParquetLayer.d.ts +24 -1
  104. package/layers/ParquetLayer.js +1 -1
  105. package/layers/geospatialPDF/CIM2DLayerview.js +2 -0
  106. package/layers/geospatialPDF/GeospatialPDFFrame.js +1 -1
  107. package/layers/mixins/ReloadableLayer.js +1 -1
  108. package/layers/mixins/SublayersOwner.js +1 -1
  109. package/layers/orientedImagery/transformations/utils.js +1 -1
  110. package/layers/save/featureLayerUtils.js +1 -1
  111. package/layers/save/imageryUtils.js +1 -1
  112. package/layers/save/mapImageLayerUtils.js +1 -1
  113. package/layers/save/mediaLayerUtils.js +1 -1
  114. package/layers/save/parquetLayerUtils.js +2 -0
  115. package/layers/save/streamLayerUtils.js +1 -1
  116. package/layers/support/LabelClass.d.ts +8 -2
  117. package/layers/support/Sublayer.js +1 -1
  118. package/layers/support/SubtypeSublayer.js +1 -1
  119. package/layers/support/layerUtils.js +1 -1
  120. package/layers/support/layersMapping.js +1 -1
  121. package/package.json +2 -2
  122. package/popup/content.js +1 -1
  123. package/portal/schemas/definitions.js +1 -1
  124. package/portal/schemas/webScene.js +1 -1
  125. package/tables/elements.d.ts +1 -0
  126. package/views/2d/engine/webgl/SpriteMosaic.js +1 -1
  127. package/views/2d/layers/GeospatialPDFLayerView2D.js +1 -1
  128. package/views/3d/layers/GeospatialPDFLayerView3D.js +1 -1
  129. package/views/3d/layers/support/featureTileQuery3D.js +1 -1
  130. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  131. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +5 -5
  132. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.glsl.js +1 -1
  133. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
  134. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationTechniqueConfiguration.js +1 -1
  135. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  136. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  137. package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
  138. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  139. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  140. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  141. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  142. package/views/3d/webgl-engine/materials/TriangleMaterial.js +1 -1
  143. package/views/3d/webgl-engine/materials/internal/worldSizedRibbonLineIntersectionUtils.js +1 -1
  144. package/views/selection/SelectionOperation.js +1 -1
  145. package/views/selection/types.d.ts +43 -3
  146. package/views/support/layerViewUtils.js +1 -1
  147. package/views/support/selectionUtils.js +1 -1
  148. package/views/webgl/Texture.js +1 -1
  149. package/webdoc/support/webdocSaveUtils.js +1 -1
  150. package/widgets/OrientedImageryViewer/ImageMeasurementWorker.js +1 -1
  151. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  152. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  153. package/widgets/OrientedImageryViewer/services/ImageMeasurementService.js +1 -1
  154. package/widgets/Sketch/SketchViewModel.js +1 -1
  155. package/widgets/support/SelectionList/GroupLayerItem.d.ts +6 -0
  156. package/widgets/support/SelectionList/GroupLayerItem.js +1 -1
  157. package/widgets/support/SelectionList/ItemBase.js +1 -1
  158. package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.d.ts +6 -1
  159. package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
  160. package/widgets/support/SelectionToolbar.d.ts +8 -1
  161. package/widgets/support/SelectionToolbar.js +1 -1
  162. package/widgets/support/Selector2D/selectorUtils.js +1 -1
  163. package/assets/esri/core/workers/chunks/1fe24ffcd88280d84fbe.js +0 -1
  164. package/assets/esri/core/workers/chunks/72071ea5de89720fbe42.js +0 -1
  165. package/assets/esri/core/workers/chunks/9de5ad77bc37ec142218.js +0 -1
  166. package/assets/esri/core/workers/chunks/b736046c6b4ede73ea46.js +0 -1
  167. package/assets/esri/core/workers/chunks/c19cd5a03b6d480fe53b.js +0 -1
  168. package/assets/esri/core/workers/chunks/d1f98c5249c487eb96f1.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{rad2deg as e}from"../../core/mathUtils.js";import{throwIfAborted as t}from"../../core/promiseUtils.js";import{createArea as n,createLength as r}from"../../core/quantity.js";import{formatArea as i,formatLength as a}from"../../core/quantityFormatUtils.js";import{set as o,determinant as s}from"../../core/libs/gl-matrix-2/math/mat3.js";import{create as c}from"../../core/libs/gl-matrix-2/factories/mat3f64.js";import{zeros as l}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{distance as u}from"../../core/libs/gl-matrix-2/math/vec2.js";import{set as d,cross as f}from"../../core/libs/gl-matrix-2/math/vec3.js";import{isSupported as p,geodesicLengths as m,geodesicAreas as h}from"../../geometry/geodesicUtils.js";import g from"../../geometry/Point.js";import _ from"../../geometry/Polygon.js";import v from"../../geometry/Polyline.js";import{projectAsync as y,project as b}from"../../geometry/projectionUtils.js";import x from"../../geometry/SpatialReference.js";import{areaExecute as S}from"../../geometry/operators/areaOperator.js";import{geodeticAreaLoad as C,geodeticAreaExecute as w}from"../../geometry/operators/geodeticAreaOperator.js";import{geodeticDensifyLoad as T,geodeticDensifyExecute as E}from"../../geometry/operators/geodeticDensifyOperator.js";import{geodeticLengthLoad as D,geodeticLengthExecute as O}from"../../geometry/operators/geodeticLengthOperator.js";import{lengthExecute as k}from"../../geometry/operators/lengthOperator.js";import{simplifyExecute as A}from"../../geometry/operators/simplifyOperator.js";import{imageToWorldPanoramic as j,imageToWorld as M}from"../../layers/orientedImagery/transformations/imageToWorld.js";import{getUpdateElevationProps as N,convertSphereVertexToPixelLocation as P,getImageToWorldProperties as ee}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as F,worldToImage as I}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getPanoramicImageProperties as te}from"./panoramicImageProperties.js";const ne=1e5,L=`meters`,R=`square-meters`;function z(e,t){let n=Math.atan2(-e.y+t.y,e.x-t.x)*180/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function re(e,t){let n=Math.atan2(-e.y+t.y,e.x-t.x)*180/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function B(e,t,n){if(!e?.length||!t?.length||!n)return;let[r,i]=e,[,a]=t,o=a-i;return[r+o*Math.cos(n),i+o*Math.sin(n)]}async function V(e,t,n){if(await T(),p(e)){let e=m([t],L)[0];return{area:h([n],R)[0],perimeter:e}}let r=x.WGS84,i=b(t,r),a=b(n,r),o=E(a,ne);if(o=o?A(o):null,!o)return null;let s=m([i],L)[0];return{area:h([o],R)[0],perimeter:s}}function ie(e,t,n=1){let r=X(e,!1);return r?.length?u([r[0].x,r[0].y],[r.at(-1).x,r.at(-1).y])*20*n/t:void 0}async function H(e){await D();let t=e.spatialReference;if(t.isGeographic){if(p(t))return m([e],L)[0];let n=b(e,x.WGS84);return m([n],L)[0]}return t.isWebMercator?O(e,{unit:L}):k(e,{unit:L})}function ae(e){if(!e?.length)throw Error(`Invalid deviations array`);let[t,n,r]=[0,1,2].map(t=>e.map(e=>e[t]).filter(e=>e!==null)).map(e=>e.length?Z(e):0);return[t,n,r]}function U(e,t){let n=A(t);if(!n)return null;let r=k(e,{unit:L});return{area:S(n,{unit:R}),perimeter:r}}function W(e,t){return[(e[1][0]-e[0][0])/t,(e[1][1]-e[0][1])/t,(e[1][2]-e[0][2])/t]}async function G(e,t){await Promise.all([C(),T(),D()]);let n=E(t,ne);if(n=n?A(n):null,!n)return null;let r=O(e,{unit:L});return{area:w(n,{unit:R}),perimeter:r}}async function oe(e,n,r){if(!n||!e)throw Error(`Missing required parameters`);let i=await M(e,n);t(r);let a=i.clone();a.z?a.z+=20:a.z=20;let{averageElevation:o,cameraPitch:s,cameraRoll:c,farDistance:l,...u}=n;return I(a,u)}async function se(e,n,r,i){let{attributes:a}=r,{location:o}=a,{updateElevationProps:s,...c}=n;if(!e||!n)throw Error(`Missing parameters`);let l=o.clone();l.spatialReference.isGeographic&&(l=await y(l,x.WebMercator));let u=await j(e,{...c,cameraLocation:l},s);t(i);let d=u.clone();return d.z?d.z+=20:d.z=20,F(d,c)}function K(e,t,n,r,i=0,a=1,o){let{averageElevation:s,cameraPitch:c,cameraRoll:l,farDistance:d,...f}=r;if(i>=5||a<=.1)return{value:e*Q(r.cameraLocation.spatialReference)};let p=new g({x:t.x,y:t.y,z:t.z?t.z+e:e,spatialReference:r.cameraLocation.spatialReference}),m=I(p,f),h=u([n[0].x,n[0].y],[m.x,m.y]),_=n.at(0),v=n.at(-1);if(!_||!v)return null;let y=u([_.x,_.y],[v.x,v.y])*e/h,b=Math.abs(e-y);return K(y,t,n,r,i+1,b)}function q(e,t,n,r,i=0,a=1,o){let{averageElevation:s,horizontalFieldOfView:c,verticalFieldOfView:l,farDistance:d,...f}=r;if(i>=5||a<=.1)return{value:e*Q(r.cameraLocation.spatialReference)};let p=new g({x:t.x,y:t.y,z:t.z?t.z+e:e,spatialReference:r.cameraLocation.spatialReference}),m=F(p,f),h=u([n[0].x,n[0].y],[m.x,m.y]),_=n.at(0),v=n.at(-1);if(!_||!v)return null;let y=u([_.x,_.y],[v.x,v.y])*e/h,b=Math.abs(e-y);return q(y,t,n,r,i+1,b)}async function J(e,t,n){return e.spatialReference&&!t.spatialReference.equals(e.spatialReference)&&(t=await y(t,e.spatialReference)),new v({paths:[[[e.x,e.y,e.z??0],[t.x,t.y,t.z??0]]],spatialReference:n})}function ce(e){return 1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*e/6378137)))}function le(e,t){return Math.sqrt((Math.sqrt((e[0][0]-e[1][0])**2+(e[0][1]-e[1][1])**2)/t)**2+(e[0][2]-e[1][2])**2)}function ue(e,t){return Math.sqrt((e[0][0]-e[1][0])**2+(e[0][1]-e[1][1])**2)/t}function de(t){return e(Math.atan((t[1][2]-t[0][2])/Math.sqrt((t[1][0]-t[0][0])**2+(t[1][1]-t[0][1])**2)))}function fe(t){let n=90-e(Math.atan2(t[1][1]-t[0][1],t[1][0]-t[0][0]));return n<0&&(n+=360),n}function Y(e,t){return new g({x:(e.pointOnA[0]+e.pointOnB[0])/2,y:(e.pointOnA[1]+e.pointOnB[1])/2,z:(e.pointOnA[2]+e.pointOnB[2])/2,spatialReference:t})}async function pe(e){if(e?.length===2){let t=[],n=1,[r,i]=e,a=r.camera.spatialReference,{measurePoints:o}=r;for(let e=0;e<o.length;e++){let o=await $(await J(r.camera,r.measurePoints[e],a),await J(i.camera,i.measurePoints[e],a));if(!o)return null;let s=Y(o,a);s.spatialReference.isWebMercator&&(n=ce(s.y)),t.push([s.x,s.y,s.z??0])}if(t?.length>1)return{distance:le(t,n),horizontalDistance:ue(t,n),verticalDistance:Math.abs(t[0][2]-t[1][2]),slope:de(t),aspect:fe(t)}}return null}async function me(e){let t=e[0].camera.spatialReference;if(e?.length!==2)return null;let[n,r]=e,{camera:i,measurePoints:a}=n,{camera:o,measurePoints:s}=r,c=await $(await J(i,a[0],t),await J(o,s[0],t));return c?Y(c,t)??null:null}async function he(e,t){if(!e?.length)return null;let n=[],r=e[0],i=e[1],a=r.camera.spatialReference,{measurePoints:o}=r;for(let e=0;e<o.length;e++){let t=await $(await J(r.camera,r.measurePoints[e],a),await J(i.camera,i.measurePoints[e],a));if(!t)return null;let o=Y(t,a);n.push([o.x,o.y,o.z??0])}if(n?.length<2)return null;let s=new v({paths:[n],spatialReference:t}),c=new _({rings:[n],spatialReference:t});return t.isGeographic?(await V(t,s,c))?.area??null:t.isWebMercator?(await G(s,c))?.area??null:U(s,c)?.area??null}function ge(e,t){return e?{camera:t.geometry.clone(),measurePoints:Array.isArray(e)?e:[e]}:null}async function _e(e,t){let{updateElevationProps:n,...r}=t;return await M(e,r,n)}async function ve(e,t){let{updateElevationProps:n,...r}=t;return j(e,r,n)}function ye(e){navigator.clipboard.writeText(e).catch(e=>{throw e})}function be(e){let t=e.map(e=>[e.x,e.y]),n=e[0].spatialReference;return new v({paths:[t],spatialReference:n})}function X(e,t){return e.map(e=>({x:t?.5+e[0]:e[0],y:t?.5-e[1]:e[1]}))}function xe(e,t,n,i,o){let s=e===`measurement`?t:n;if(o&&s)return a(i,r(s,L),o,3)||null}function Se(e,t){let{cameraPitch:n,cameraRoll:r,cameraLocation:i}=e,{x:a,y:o,z:s,spatialReference:c}=i;if(t.every(e=>e===0)||!t||!t.length||!c)throw Error(`Invalid parameters`);let[l,u,,d,f]=t,p=[-d,0,d],m=[-f,0,f],h=[-l,0,l],g=[-u,0,u],_=[];for(let t of p)for(let i of m)for(let l of h)for(let u of h)for(let d of g){let f={...e};f.cameraPitch=n+t,f.cameraRoll=r+i,f.cameraLocation={x:a+l,y:o+u,z:s?s+d:0,spatialReference:{wkid:c.wkid}},_.push(f)}return _}function Ce(e,t){let{cameraHeading:n,cameraLocation:r}=e,{x:i,y:a,z:o,spatialReference:s}=r;if(!t||t.every(e=>e===0)||!t.length||!s)throw Error(`Invalid parameters`);let[c,l,u]=t,d=u>0?[-u,0,u]:[],f=c>0?[-c,0,c]:[],p=l>0?[-l,0,l]:[],m=[];for(let t of d)for(let r of f)for(let c of f)for(let l of p){let u={...e};u.cameraHeading=n+t,u.cameraLocation={x:i+r,y:a+c,z:o?o+l:0,spatialReference:{wkid:s.wkid}},m.push(u)}return m}function we(e,t,n,i,o){let s=e===`measurement`?t:Z(n);if(o&&s)return a(i,r(s,L),o,3)||null}function Te(e,t,r,a,o){let s=e===`measurement`?t:r;if(o&&s)return i(a,n(s,R),o,3)||null}function Z(e){return Math.sqrt(e.reduce((e,t)=>e+t**2,0))}function Ee(e,t,n){if(!e||!t)return;let{elevationSample:r,attributes:i}=e,{elevationSource:a,cameraHeight:o}=i,s={...ee(i,t[0],t[1]),cameraLocation:i.location},c=s.cameraLocation;return(c.spatialReference.isGeographic?y(c,x.WebMercator):Promise.resolve(c)).then(e=>(c=e,N(c.spatialReference,c.z??0,o,{elevationSample:r,elevationSource:a,extent:n}))).then(t=>(`elevationSample`in t&&(e.elevationSample=t.elevationSample),{...s,cameraLocation:c,updateElevationProps:t}))}function De(e,t,n){if(!e||!t)return;let{elevationSample:r,attributes:i}=e,{elevationSource:a,cameraHeight:o}=i,s=te(i,t[0],t[1]),c=s.cameraLocation;return(c.spatialReference.isGeographic?y(c,x.WebMercator):Promise.resolve(c)).then(e=>(c=e,N(c.spatialReference,c.z??0,o,{elevationSample:r,elevationSource:a,extent:n}))).then(t=>(`elevationSample`in t&&(e.elevationSample=t.elevationSample),{...s,cameraLocation:c,updateElevationProps:t}))}function Oe(e,t,n){if(t==="default")return e;let r={x:e[0],y:e[1],z:e[2]},i=P(r,n[0],n[1]);return[i.x,i.y]}function Q(e){return e.metersPerUnit}function ke(e,t,n,r){let i=[];return i=t===`panoramic`?e.map(([e,t,i])=>{let{x:a,y:o}=P({x:e,y:t,z:i},n[0],n[1],r);return[a-.5,-.5-o]}):e.map(([e,t])=>[e-.5,-.5-t]),i}function Ae(e,t,n){return e.map(e=>P({x:e[0],y:e[1],z:e[2]},t[0],t[1],n))}async function je(e,n,r,i=!1,a=!1,o){if(!e||!n||e.length<2)return null;let s=X(e,i);if(!s||s.length<2)return null;let[c,l]=[s[0],s.at(-1)];if(!l)return null;let d=[c],f=await M(c,n);t(o);let p=f.clone();p.z?p.z+=20:p.z=20;let{averageElevation:m,cameraPitch:h,cameraRoll:g,farDistance:_,...v}=n,y=I(p,v),b=u([c.x,c.y],[y.x,y.y]),x=z(c,y);if(!x)return;let S=B([c.x,c.y],[l.x,l.y],x);if(!S?.length)return;d.push({x:S[0],y:S[1]});let C=u([d[0].x,d[0].y],[d[1].x,d[1].y]),w=n.cameraLocation,T=Q(w.spatialReference),E=C*20*T/b;return a?K(E,f,d,n,0,1)?.value:E}async function Me(e,n,r,i,a=!1,o=!1,s){let{attributes:c}=i,{location:l}=c,{updateElevationProps:d,...f}=n;if(!e||!n||e.length<2)throw Error(`Invalid parameters`);let p=X(e,a),[m,h]=[p[0],p.at(-1)],g=[m],_=l.clone();_.spatialReference.isGeographic&&(_=await y(_,x.WebMercator));let v=await j(m,{...f,cameraLocation:_},d);t(s);let b=v.clone();b.z?b.z+=20:b.z=20;let S=F(b,f),C=u([m.x,m.y],[S.x,S.y]),w=z(m,S);if(!w)return;let T=B([m.x,m.y],[h.x,h.y],w);if(!T?.length)return;g.push({x:T[0],y:T[1]});let E=u([g[0].x,g[0].y],[g[1].x,g[1].y]),D=n.cameraLocation,O=Q(D.spatialReference),k=E*20*O/C;return o?q(k,v,g,n,0,1)?.value:k}async function Ne(e,t,n){let{updateElevationProps:r,...i}=t,{updateElevationProps:a,...o}=n,s=await M(e,i,r);return I(s,o)}async function Pe(e,t,n){let{updateElevationProps:r,...i}=t,{updateElevationProps:a,...o}=n,s=await j(e,i,r);return F(s,o)}async function Fe(e,t,n=!1){if(e.length<3)return null;let r=await _e(X(e,n),t),i=r.map(({x:e,y:t})=>[e,t]);e.push(e[0]),i.push(i[0]);let a=r[0].spatialReference,o=new v({paths:[i],spatialReference:a}),s=new _({rings:[i],spatialReference:a});return a.isGeographic?V(a,o,s):a.isWebMercator?G(o,s):U(o,s)}async function Ie(e,n,r=!1,i){if(e.length<3)return null;let a=await ve(X(e,r),n);t(i);let o=a.map(({x:e,y:t})=>[e,t]);e.push(e[0]),o.push(o[0]);let s=a[0].spatialReference,c=new v({paths:[o],spatialReference:s}),l=new _({rings:[o],spatialReference:s});return s.isGeographic?V(s,c,l):s.isWebMercator?G(c,l):U(c,l)}async function Le(e,t,n=!1){return H(be(await _e(X(e,n),t)))}async function Re(e,n,r=!1,i){let a=await ve(X(e,r),n);return t(i),H(be(a))}async function $(e,t){let n=c(),r=e.paths[0][0],i=t.paths[0][0],a,l;e.spatialReference.isWGS84||e.spatialReference.isWebMercator?(await D(),a=O(e),l=O(t)):(a=k(e),l=k(t));let u=W(e.paths[0],a),d=W(t.paths[0],l),f=ze(u,d),[p,m,h]=u,[g,_,v]=d.map(e=>-e),[y,b,x]=f,[S,C,w]=[i[0]-r[0],i[1]-r[1],i[2]-r[2]];o(n,p,g,y,m,_,b,h,v,x);let T=s(n);if(T===0)return null;o(n,S,g,y,C,_,b,w,v,x);let E=s(n);o(n,p,S,y,m,C,b,h,w,x);let A=s(n);o(n,p,g,S,m,_,C,h,v,w);let j=s(n),M=E/T,N=A/T,P=j/T;return{distance:Math.abs(P/Math.sqrt(f[0]*f[0]+f[1]*f[1]+f[2]*f[2])),pointOnA:Be(r,M,u),pointOnB:Be(i,N,d)}}function ze(e,t){let n=l(),r=d(l(),e[0],e[1],e[2]),i=d(l(),t[0],t[1],t[2]),a=f(n,r,i);return[a[0],a[1],a[2]]}function Be(e,t,n){return[e[0]+t*n[0],e[1]+t*n[1],e[2]+t*n[2]]}export{z as calculateAngle,re as calculateAnglePano,B as calculateCorrectedPixel,ie as calculateHeightFromTemporaryDistance,ae as calculateLocationAccuracyFromDeviations,se as calculateReferenceImagePointPanoramic,oe as calculateTempImagePoint,ce as calculateUpdatedWmsf,K as computeHeightIteratively,q as computeHeightIterativelyPanoramic,he as computeTriangulatedAreaMeasurement,pe as computeTriangulatedDistanceMeasurement,me as computeTriangulatedPoint,ge as computeTriangulatedVector,ye as copyToClipboard,X as formatPixels,Se as generateCombinations,Ce as generateCombinationsPanoramic,Te as getConvertedArea,we as getConvertedDistance,xe as getConvertedHeight,Ee as getMeasurementProperties,De as getMeasurementPropertiesPanoramic,Oe as getModeCorrectedPoint,ke as getModeCorrectedPoints,Ae as getPixelLocationFromSphereVertices,Z as getRootOfSumOfSquaredErrors,Q as getUnitRateFromSpatialReference,je as heightMeasurement2D,Me as heightMeasurementPanoramic,Ne as imageToImageTransform,Pe as imageToImageTransformPanoramic,Fe as pixelAreaMeasurement2D,Ie as pixelAreaMeasurementPanoramic,Le as pixelDistanceMeasurement2D,Re as pixelDistanceMeasurementPanoramic,$ as solveSkewLinesIntersection};
2
+ import{rad2deg as e}from"../../core/mathUtils.js";import{throwIfAborted as t}from"../../core/promiseUtils.js";import{createArea as n,createLength as r}from"../../core/quantity.js";import{formatArea as i,formatLength as a}from"../../core/quantityFormatUtils.js";import{set as o,determinant as s}from"../../core/libs/gl-matrix-2/math/mat3.js";import{create as c}from"../../core/libs/gl-matrix-2/factories/mat3f64.js";import{zeros as l}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{distance as u}from"../../core/libs/gl-matrix-2/math/vec2.js";import{set as d,cross as f}from"../../core/libs/gl-matrix-2/math/vec3.js";import{isSupported as p,geodesicLengths as m,geodesicAreas as h}from"../../geometry/geodesicUtils.js";import g from"../../geometry/Point.js";import _ from"../../geometry/Polygon.js";import v from"../../geometry/Polyline.js";import{projectAsync as y,project as b}from"../../geometry/projectionUtils.js";import x from"../../geometry/SpatialReference.js";import{areaExecute as S}from"../../geometry/operators/areaOperator.js";import{geodeticAreaLoad as C,geodeticAreaExecute as w}from"../../geometry/operators/geodeticAreaOperator.js";import{geodeticDensifyLoad as T,geodeticDensifyExecute as E}from"../../geometry/operators/geodeticDensifyOperator.js";import{geodeticLengthLoad as D,geodeticLengthExecute as O}from"../../geometry/operators/geodeticLengthOperator.js";import{lengthExecute as k}from"../../geometry/operators/lengthOperator.js";import{simplifyExecute as A}from"../../geometry/operators/simplifyOperator.js";import{imageToWorldPanoramic as j,imageToWorld as M}from"../../layers/orientedImagery/transformations/imageToWorld.js";import{createRotationMatrixFromHPR as ee,getUpdateElevationProps as N,convertSphereVertexToPixelLocation as P,getImageToWorldProperties as te}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as F,worldToImage as I}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getPanoramicImageProperties as ne}from"./panoramicImageProperties.js";const re=1e5,L=`meters`,R=`square-meters`;function z(e,t){let n=Math.atan2(-e.y+t.y,e.x-t.x)*180/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function ie(e,t){let n=Math.atan2(-e.y+t.y,e.x-t.x)*180/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function B(e,t,n){if(!e?.length||!t?.length||!n)return;let[r,i]=e,[,a]=t,o=a-i;return[r+o*Math.cos(n),i+o*Math.sin(n)]}async function V(e,t,n){if(await T(),p(e)){let e=m([t],L)[0];return{area:h([n],R)[0],perimeter:e}}let r=x.WGS84,i=b(t,r),a=b(n,r),o=E(a,re);if(o=o?A(o):null,!o)return null;let s=m([i],L)[0];return{area:h([o],R)[0],perimeter:s}}function ae(e,t,n=1){let r=J(e,!1);return r?.length?u([r[0].x,r[0].y],[r.at(-1).x,r.at(-1).y])*20*n/t:void 0}async function oe(e){await D();let t=e.spatialReference;if(t.isGeographic){if(p(t))return m([e],L)[0];let n=b(e,x.WGS84);return m([n],L)[0]}return t.isWebMercator?O(e,{unit:L}):k(e,{unit:L})}function se(e){if(!e?.length)throw Error(`Invalid deviations array`);let[t,n,r]=[0,1,2].map(t=>e.map(e=>e[t]).filter(e=>e!==null)).map(e=>e.length?X(e):0);return[t,n,r]}function H(e,t){let n=A(t);if(!n)return null;let r=k(e,{unit:L});return{area:S(n,{unit:R}),perimeter:r}}function ce(e,t){return[(e[1][0]-e[0][0])/t,(e[1][1]-e[0][1])/t,(e[1][2]-e[0][2])/t]}async function U(e,t){await Promise.all([C(),T(),D()]);let n=E(t,re);if(n=n?A(n):null,!n)return null;let r=O(e,{unit:L});return{area:w(n,{unit:R}),perimeter:r}}async function le(e,n,r){if(!n||!e)throw Error(`Missing required parameters`);let i=await M(e,n);t(r);let a=i.clone();a.z?a.z+=20:a.z=20;let{averageElevation:o,cameraPitch:s,cameraRoll:c,farDistance:l,...u}=n;return I(a,u)}async function ue(e,n,r,i){let{attributes:a}=r,{location:o}=a,{updateElevationProps:s,...c}=n;if(!e||!n)throw Error(`Missing parameters`);let l=o.clone();l.spatialReference.isGeographic&&(l=await y(l,x.WebMercator));let u=await j(e,{...c,cameraLocation:l},s);t(i);let d=u.clone();return d.z?d.z+=20:d.z=20,F(d,c)}function W(e,t,n,r,i=0,a=1,o){let{averageElevation:s,cameraPitch:c,cameraRoll:l,farDistance:d,...f}=r;if(i>=5||a<=.1)return{value:e*Z(r.cameraLocation.spatialReference)};let p=new g({x:t.x,y:t.y,z:t.z?t.z+e:e,spatialReference:r.cameraLocation.spatialReference}),m=I(p,f),h=u([n[0].x,n[0].y],[m.x,m.y]),_=n.at(0),v=n.at(-1);if(!_||!v)return null;let y=u([_.x,_.y],[v.x,v.y])*e/h,b=Math.abs(e-y);return W(y,t,n,r,i+1,b)}function G(e,t,n,r,i=0,a=1,o){let{averageElevation:s,horizontalFieldOfView:c,verticalFieldOfView:l,farDistance:d,...f}=r;if(i>=5||a<=.1)return{value:e*Z(r.cameraLocation.spatialReference)};let p=new g({x:t.x,y:t.y,z:t.z?t.z+e:e,spatialReference:r.cameraLocation.spatialReference}),m=F(p,f),h=u([n[0].x,n[0].y],[m.x,m.y]),_=n.at(0),v=n.at(-1);if(!_||!v)return null;let y=u([_.x,_.y],[v.x,v.y])*e/h,b=Math.abs(e-y);return G(y,t,n,r,i+1,b)}async function K(e,t,n){return e.spatialReference&&!t.spatialReference.equals(e.spatialReference)&&(t=await y(t,e.spatialReference)),new v({paths:[[[e.x,e.y,e.z??0],[t.x,t.y,t.z??0]]],spatialReference:n})}function de(e){return 1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*e/6378137)))}function fe(e,t){return Math.sqrt((Math.sqrt((e[0][0]-e[1][0])**2+(e[0][1]-e[1][1])**2)/t)**2+(e[0][2]-e[1][2])**2)}function pe(e,t){return Math.sqrt((e[0][0]-e[1][0])**2+(e[0][1]-e[1][1])**2)/t}function me(t){return e(Math.atan((t[1][2]-t[0][2])/Math.sqrt((t[1][0]-t[0][0])**2+(t[1][1]-t[0][1])**2)))}function he(t){let n=90-e(Math.atan2(t[1][1]-t[0][1],t[1][0]-t[0][0]));return n<0&&(n+=360),n}function q(e,t){return new g({x:(e.pointOnA[0]+e.pointOnB[0])/2,y:(e.pointOnA[1]+e.pointOnB[1])/2,z:(e.pointOnA[2]+e.pointOnB[2])/2,spatialReference:t})}async function ge(e){if(e?.length===2){let t=[],n=1,[r,i]=e,a=r.camera.spatialReference,{measurePoints:o}=r;for(let e=0;e<o.length;e++){let o=await Q(await K(r.camera,r.measurePoints[e],a),await K(i.camera,i.measurePoints[e],a));if(!o)return null;let s=q(o,a);s.spatialReference.isWebMercator&&(n=de(s.y)),t.push([s.x,s.y,s.z??0])}if(t?.length>1)return{distance:fe(t,n),horizontalDistance:pe(t,n),verticalDistance:Math.abs(t[0][2]-t[1][2]),slope:me(t),aspect:he(t)}}return null}async function _e(e){let t=e[0].camera.spatialReference;if(e?.length!==2)return null;let[n,r]=e,{camera:i,measurePoints:a}=n,{camera:o,measurePoints:s}=r,c=await Q(await K(i,a[0],t),await K(o,s[0],t));return c?q(c,t)??null:null}async function ve(e,t){if(!e?.length)return null;let n=[],r=e[0],i=e[1],a=r.camera.spatialReference,{measurePoints:o}=r;for(let e=0;e<o.length;e++){let t=await Q(await K(r.camera,r.measurePoints[e],a),await K(i.camera,i.measurePoints[e],a));if(!t)return null;let o=q(t,a);n.push([o.x,o.y,o.z??0])}if(n?.length<2)return null;let s=new v({paths:[n],spatialReference:t}),c=new _({rings:[n],spatialReference:t});return t.isGeographic?(await V(t,s,c))?.area??null:t.isWebMercator?(await U(s,c))?.area??null:H(s,c)?.area??null}function ye(e,t){return e?{camera:t.geometry.clone(),measurePoints:Array.isArray(e)?e:[e]}:null}async function be(e,t){let{updateElevationProps:n,...r}=t;return await M(e,r,n)}async function xe(e,t){let{updateElevationProps:n,...r}=t;return j(e,r,n)}function Se(e){navigator.clipboard.writeText(e).catch(e=>{throw e})}function Ce(e){let t=e.map(e=>[e.x,e.y]),n=e[0].spatialReference;return new v({paths:[t],spatialReference:n})}function J(e,t){return e.map(e=>({x:t?.5+e[0]:e[0],y:t?.5-e[1]:e[1]}))}function we(e,t,n,i,o){let s=e===`measurement`?t:n;if(o&&s)return a(i,r(s,L),o,3)||null}function Y(e){return e>0?[-e,0,e]:[0]}function Te(e,t,n){let{cameraPitch:r,cameraRoll:i,cameraLocation:a}=e,{x:o,y:s,z:c,spatialReference:l}=a;if(t.every(e=>e===0)||!t||!t.length||!l)throw Error(`Invalid parameters`);let[u,d,f,p,m]=t,h=Y(f),g=Y(p),_=Y(m),v=Y(u),y=Y(d),b=[];for(let t of g)for(let a of _)for(let u of v)for(let d of v)for(let f of y)for(let p of h){let m={...e};m.cameraPitch=r+t,m.cameraRoll=i+a,m.rotationMatrix=ee([n+p,m.cameraPitch,m.cameraRoll]),m.cameraLocation={x:o+u,y:s+d,z:c?c+f:0,spatialReference:{wkid:l.wkid}},b.push(m)}return b}function Ee(e,t){let{cameraHeading:n,cameraLocation:r}=e,{x:i,y:a,z:o,spatialReference:s}=r;if(!t||t.every(e=>e===0)||!t.length||!s)throw Error(`Invalid parameters`);let[c,l,u]=t,d=Y(u),f=Y(c),p=Y(l),m=[];for(let t of d)for(let r of f)for(let c of f)for(let l of p){let u={...e};u.cameraHeading=n+t,u.cameraLocation={x:i+r,y:a+c,z:o?o+l:0,spatialReference:{wkid:s.wkid}},m.push(u)}return m}function De(e,t,n,i,o){let s=e===`measurement`?t:X(n);if(o&&s)return a(i,r(s,L),o,3)||null}function Oe(e,t,r,a,o){let s=e===`measurement`?t:r;if(o&&s)return i(a,n(s,R),o,3)||null}function X(e){return Math.sqrt(e.reduce((e,t)=>e+t**2,0))}function ke(e,t,n){if(!e||!t)return;let{elevationSample:r,attributes:i}=e,{elevationSource:a,cameraHeight:o}=i,s={...te(i,t[0],t[1]),cameraLocation:i.location},c=s.cameraLocation;return(c.spatialReference.isGeographic?y(c,x.WebMercator):Promise.resolve(c)).then(e=>(c=e,N(c.spatialReference,c.z??0,o,{elevationSample:r,elevationSource:a,extent:n}))).then(t=>(`elevationSample`in t&&(e.elevationSample=t.elevationSample),{...s,cameraLocation:c,updateElevationProps:t}))}function Ae(e,t,n){if(!e||!t)return;let{elevationSample:r,attributes:i}=e,{elevationSource:a,cameraHeight:o}=i,s=ne(i,t[0],t[1]),c=s.cameraLocation;return(c.spatialReference.isGeographic?y(c,x.WebMercator):Promise.resolve(c)).then(e=>(c=e,N(c.spatialReference,c.z??0,o,{elevationSample:r,elevationSource:a,extent:n}))).then(t=>(`elevationSample`in t&&(e.elevationSample=t.elevationSample),{...s,cameraLocation:c,updateElevationProps:t}))}function je(e,t,n){if(t==="default")return e;let r={x:e[0],y:e[1],z:e[2]},i=P(r,n[0],n[1]);return[i.x,i.y]}function Z(e){return e.metersPerUnit}function Me(e,t,n,r){let i=[];return i=t===`panoramic`?e.map(([e,t,i])=>{let{x:a,y:o}=P({x:e,y:t,z:i},n[0],n[1],r);return[a-.5,-.5-o]}):e.map(([e,t])=>[e-.5,-.5-t]),i}function Ne(e,t,n){return e.map(e=>P({x:e[0],y:e[1],z:e[2]},t[0],t[1],n))}async function Pe(e,n,r,i=!1,a=!1,o){if(!e||!n||e.length<2)return null;let s=J(e,i);if(!s||s.length<2)return null;let[c,l]=[s[0],s.at(-1)];if(!l)return null;let d=[c],f=await M(c,n);t(o);let p=f.clone();p.z?p.z+=20:p.z=20;let{averageElevation:m,cameraPitch:h,cameraRoll:g,farDistance:_,...v}=n,y=I(p,v),b=u([c.x,c.y],[y.x,y.y]),x=z(c,y);if(!x)return;let S=B([c.x,c.y],[l.x,l.y],x);if(!S?.length)return;d.push({x:S[0],y:S[1]});let C=u([d[0].x,d[0].y],[d[1].x,d[1].y]),w=n.cameraLocation,T=Z(w.spatialReference),E=C*20*T/b;return a?W(E,f,d,n,0,1)?.value:E}async function Fe(e,n,r,i,a=!1,o=!1,s){let{attributes:c}=i,{location:l}=c,{updateElevationProps:d,...f}=n;if(!e||!n||e.length<2)throw Error(`Invalid parameters`);let p=J(e,a),[m,h]=[p[0],p.at(-1)],g=[m],_=l.clone();_.spatialReference.isGeographic&&(_=await y(_,x.WebMercator));let v=await j(m,{...f,cameraLocation:_},d);t(s);let b=v.clone();b.z?b.z+=20:b.z=20;let S=F(b,f),C=u([m.x,m.y],[S.x,S.y]),w=z(m,S);if(!w)return;let T=B([m.x,m.y],[h.x,h.y],w);if(!T?.length)return;g.push({x:T[0],y:T[1]});let E=u([g[0].x,g[0].y],[g[1].x,g[1].y]),D=n.cameraLocation,O=Z(D.spatialReference),k=E*20*O/C;return o?G(k,v,g,n,0,1)?.value:k}async function Ie(e,t,n){let{updateElevationProps:r,...i}=t,{updateElevationProps:a,...o}=n,s=await M(e,i,r);return I(s,o)}async function Le(e,t,n){let{updateElevationProps:r,...i}=t,{updateElevationProps:a,...o}=n,s=await j(e,i,r);return F(s,o)}async function Re(e,t,n=!1){if(e.length<3)return null;let r=await be(J(e,n),t),i=r.map(({x:e,y:t})=>[e,t]);i.push(i[0]);let a=r[0].spatialReference,o=new v({paths:[i],spatialReference:a}),s=new _({rings:[i],spatialReference:a});return a.isGeographic?V(a,o,s):a.isWebMercator?U(o,s):H(o,s)}async function ze(e,n,r=!1,i){if(e.length<3)return null;let a=await xe(J(e,r),n);t(i);let o=a.map(({x:e,y:t})=>[e,t]);o.push(o[0]);let s=a[0].spatialReference,c=new v({paths:[o],spatialReference:s}),l=new _({rings:[o],spatialReference:s});return s.isGeographic?V(s,c,l):s.isWebMercator?U(c,l):H(c,l)}async function Be(e,t,n=!1){return oe(Ce(await be(J(e,n),t)))}async function Ve(e,n,r=!1,i){let a=await xe(J(e,r),n);return t(i),oe(Ce(a))}async function Q(e,t){let n=c(),r=e.paths[0][0],i=t.paths[0][0],a,l;e.spatialReference.isWGS84||e.spatialReference.isWebMercator?(await D(),a=O(e),l=O(t)):(a=k(e),l=k(t));let u=ce(e.paths[0],a),d=ce(t.paths[0],l),f=He(u,d),[p,m,h]=u,[g,_,v]=d.map(e=>-e),[y,b,x]=f,[S,C,w]=[i[0]-r[0],i[1]-r[1],i[2]-r[2]];o(n,p,g,y,m,_,b,h,v,x);let T=s(n);if(T===0)return null;o(n,S,g,y,C,_,b,w,v,x);let E=s(n);o(n,p,S,y,m,C,b,h,w,x);let A=s(n);o(n,p,g,S,m,_,C,h,v,w);let j=s(n),M=E/T,ee=A/T,N=j/T;return{distance:Math.abs(N/Math.sqrt(f[0]*f[0]+f[1]*f[1]+f[2]*f[2])),pointOnA:$(r,M,u),pointOnB:$(i,ee,d)}}function He(e,t){let n=l(),r=d(l(),e[0],e[1],e[2]),i=d(l(),t[0],t[1],t[2]),a=f(n,r,i);return[a[0],a[1],a[2]]}function $(e,t,n){return[e[0]+t*n[0],e[1]+t*n[1],e[2]+t*n[2]]}export{z as calculateAngle,ie as calculateAnglePano,B as calculateCorrectedPixel,ae as calculateHeightFromTemporaryDistance,se as calculateLocationAccuracyFromDeviations,ue as calculateReferenceImagePointPanoramic,le as calculateTempImagePoint,de as calculateUpdatedWmsf,W as computeHeightIteratively,G as computeHeightIterativelyPanoramic,ve as computeTriangulatedAreaMeasurement,ge as computeTriangulatedDistanceMeasurement,_e as computeTriangulatedPoint,ye as computeTriangulatedVector,Se as copyToClipboard,J as formatPixels,Te as generateCombinations,Ee as generateCombinationsPanoramic,Oe as getConvertedArea,De as getConvertedDistance,we as getConvertedHeight,ke as getMeasurementProperties,Ae as getMeasurementPropertiesPanoramic,je as getModeCorrectedPoint,Me as getModeCorrectedPoints,Ne as getPixelLocationFromSphereVertices,X as getRootOfSumOfSquaredErrors,Z as getUnitRateFromSpatialReference,Pe as heightMeasurement2D,Fe as heightMeasurementPanoramic,Ie as imageToImageTransform,Le as imageToImageTransformPanoramic,Re as pixelAreaMeasurement2D,ze as pixelAreaMeasurementPanoramic,Be as pixelDistanceMeasurement2D,Ve as pixelDistanceMeasurementPanoramic,Q as solveSkewLinesIntersection};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{throwIfAborted as e}from"../../../core/promiseUtils.js";import{open as t}from"../../../core/workers.js";import n from"../../../geometry/Point.js";import{projectAsync as r}from"../../../geometry/projectionUtils.js";import{imageToWorld as i,imageToWorldPanoramic as a}from"../../../layers/orientedImagery/transformations/imageToWorld.js";import{convertSphereVertexToPixelLocation as o}from"../../../layers/orientedImagery/transformations/utils.js";import{getMeasurementProperties as s,pixelAreaMeasurement2D as c,pixelDistanceMeasurement2D as l,getRootOfSumOfSquaredErrors as u,heightMeasurementPanoramic as d,heightMeasurement2D as f,getMeasurementPropertiesPanoramic as p,calculateLocationAccuracyFromDeviations as m,pixelAreaMeasurementPanoramic as h,pixelDistanceMeasurementPanoramic as g,computeTriangulatedAreaMeasurement as _,computeTriangulatedDistanceMeasurement as v,getModeCorrectedPoints as y,computeTriangulatedVector as b}from"../imageMeasurementUtils.js";import{extractHorizonAnglesFromMedia as x}from"../utils.js";class S{constructor(e){this.referenceTransformationService=null,this.measurementVectors=[],this._connection=null,this.transformationService=e.transformationService,this.referenceTransformationService=e.referenceTransformationService}async _load(){this._connection??=await t(`ImageMeasurementWorker`)}async calculateAccuracy(t){await this._load();let{measurementArray:r,measurementType:i,currentBestFeature:a,currentBestFeatureMeasurementImage:o,activeViewer:d,imageSize:f,triangularMeasurementActive:p,footprintExtent:m,signal:h}=t,g=(p&&o&&f?o:a)?.attributes.orientationAccuracy,_=!g||g.every(e=>e===0);if(i===`area`&&r.length<3||i===`distance`&&r.length<2||!a||!d?.imageSize||_)return null;let v=null;if(p&&o&&f?v=await s(o,f,m):(v=await s(a,d?.imageSize,m),e(h)),!v)return null;let y=i===`area`?await c(r,v,!0):await l([r.at(0),r.at(-1)],v,!0);e(h);let{updateElevationProps:b}=v,x=this.getWorkerMethodProps(v,g),S=await this._connection?.invoke(`generateCombinationsWorker`,x,{signal:h});if(e(h),!S?.length)return null;let C=S.map(async t=>{let a={...t,cameraLocation:new n(t.cameraLocation),updateElevationProps:b},o=i===`area`?await c(r,a,!0):await l([r.at(0),r.at(-1)],a,!0);if(e(h),o&&y){if(i===`area`){let e=typeof o==`number`?null:o.area;return e?Math.abs(e-y.area):null}return Math.abs(o-y)}return null}),w=await Promise.all(C);e(h);let T=w.filter(e=>e!==null);return T.length===0?null:u(T)}async calculateHeightAccuracy(e){await this._load();let{mode:t,pixelObj:n,accuracyParameters:r,height:i,properties:a,currentBestFeature:o,signal:s}=e;return t===`panoramic`?this.calculateHeightAccuracyPanoramic(r,n,a,i,o,s):this.calculateHeightAccuracy2D(r,n,a,i,s)}async calculateHeightAccuracyPanoramic(t,r,i,a,o,s){if(r.length<2||!a||!i||!t||!o)throw Error(`Missing parameters`);let c=this.getWorkerMethodProps(i,t),l=await this._connection?.invoke(`generateCombinationsPanoramicWorker`,c,{signal:s});if(e(s),!l?.length)return null;let u=r.map(e=>[e.x,e.y]),f=u.at(0),p=u.at(-1),m=l.map(e=>(e.cameraLocation=new n(e.cameraLocation),d([f,p],e,t,o,!0,!1,s))),h=await Promise.all(m);e(s);let g=0;for(let e of h){if(!e)return 0;let t=Math.abs(e-a);g=Math.max(t,g)}return g}async calculateHeightAccuracy2D(t,r,i,a,o){if(r.length<2||!a||!i||!t)throw Error(`Missing parameters`);let s=this.getWorkerMethodProps(i,t),c=await this._connection?.invoke(`generateCombinationsWorker`,s,{signal:o});if(e(o),!c?.length)return null;let l=r.map(e=>[e.x,e.y]),u=l.at(0),d=l.at(-1);if(!u||!d)return null;let p=c.map(e=>(e.cameraLocation=new n(e.cameraLocation),f([u,d],e,t,!0,!1,o))),m=await Promise.all(p);e(o);let h=0;for(let e of m){if(!e)return 0;let t=Math.abs(e-a);h=Math.max(t,h)}return h}async calculateLocationAccuracy(t){await this._load();let{pixel:o,currentResult:c,currentBestFeature:l,mode:u,activeViewer:d,footprintExtent:f,accuracyParameters:h,viewSpatialReference:g,signal:_}=t,v=u??`default`,y=g??null,b=v==="default"?await s(l,d?.imageSize,f):await p(l,d?.imageSize,f);if(e(_),!b)return null;let{updateElevationProps:x}=b,S=v==="default"?`generateCombinationsWorker`:`generateCombinationsPanoramicWorker`,C=this.getWorkerMethodProps(b,h),w=await this._connection?.invoke(S,C,{signal:_});if(e(_),!w?.length)return null;let T=w.map(async t=>{let{...s}={...t,cameraLocation:new n(t.cameraLocation)},l=v==="default"?await i(o,s,x):await a(o,s,x);return e(_),y&&!l.spatialReference.equals(y)&&(l=await r(l,y),e(_)),l&&c?[Math.abs(l.x-c.x),Math.abs(l.y-c.y),l.z&&c.z?Math.abs(l.z-c.z):0]:null}),E=await Promise.all(T);if(e(_),!E?.length)return null;let D=E.map(e=>[e?.[0]??0,e?.[1]??0,e?.[2]??0]),[O,k,A]=m(D);return{x:O,y:k,z:A}}async calculateAccuracyPanoramic(t){await this._load();let{measurementArray:r,measurementType:i,secondaryViewer:a,currentBestFeature:o,currentBestFeatureMeasurementImage:s,activeViewer:c,activeTriangulatedViewer:l,footprintExtent:d,signal:f}=t,m=a??!1,_=(m&&s&&l?.imageSize?s:o)?.attributes.orientationAccuracy,v=!_||_.every(e=>e===0);if(i===`area`&&r.length<3||i===`distance`&&r.length<2||!o||!c?.imageSize||v)return null;let y=l?.imageSize,b=m&&s&&y?await p(s,y,d):await p(o,c?.imageSize,d);if(e(f),!b)return null;let x=i===`area`?await h(r,b,!0):await g([r.at(0),r.at(-1)],b,!0);e(f);let{updateElevationProps:S}=b,C=this.getWorkerMethodProps(b,_),w=await this._connection?.invoke(`generateCombinationsPanoramicWorker`,C,{signal:f});if(e(f),!w?.length)return null;let T=w.map(async t=>{let a={...t,cameraLocation:new n(t.cameraLocation),updateElevationProps:S},o=i===`area`?await h(r,a,!0):await g([r.at(0),r.at(-1)],a,!0);if(e(f),o&&x){if(i===`area`){let e=typeof o==`number`?null:o.area;return e?Math.abs(e-x.area):null}return Math.abs(o-x)}return null}),E=await Promise.all(T);e(f);let D=E.filter(e=>e!==null);return D.length===0?null:u(D)}async calculateTriangulatedMeasurements(e){let{pixels:t,measureType:n,currentBestFeature:r,currentBestFeatureMeasurementImage:i,activeViewer:a,activeTriangulatedViewer:s,mode:c,imageSize:l,footprintExtent:u}=e;if(!s?.imageSize)return;let[d,f]=s.imageSize;switch(n){case`distance`:{let e=await v(this.measurementVectors),n=t.map(([e,t,n])=>o({x:e,y:t,z:n},d,f)).map(({x:e,y:t})=>[e,t]),p={measurementArray:t,measurementType:`distance`,currentBestFeature:r,currentBestFeatureMeasurementImage:i,activeViewer:a,imageSize:l,triangularMeasurementActive:!0,footprintExtent:u},m={measurementArray:n,measurementType:`distance`,secondaryViewer:!0,currentBestFeature:r,currentBestFeatureMeasurementImage:i,activeViewer:a,activeTriangulatedViewer:s,footprintExtent:u},h=c==="default"?await this.calculateAccuracy(p):await this.calculateAccuracyPanoramic(m);if(h&&e?.distance)return{distance:e,accuracy:{distanceAccuracy:h,angleAccuracy:Math.atan(h/e.distance)}};break}case`area`:if(i?.geometry.spatialReference){let e=await _(this.measurementVectors,i.geometry.spatialReference),n=null;if(c==="default"){let e={measurementArray:t,measurementType:`area`,currentBestFeature:r,currentBestFeatureMeasurementImage:i,activeViewer:a,imageSize:l,triangularMeasurementActive:!0,footprintExtent:u},o=await this.calculateAccuracy(e);o&&(n=o)}else if(c===`panoramic`){let e={measurementArray:t.map(([e,t,n])=>o({x:e,y:t,z:n},d,f)).map(({x:e,y:t})=>[e,t]),measurementType:`area`,secondaryViewer:!0,currentBestFeature:r,currentBestFeatureMeasurementImage:i,activeViewer:a,activeTriangulatedViewer:s,footprintExtent:u},c=await this.calculateAccuracyPanoramic(e);c&&(n=c)}return{area:e,accuracy:n}}}c===`panoramic`&&s.viewModel.restoreNavigationHandles()}async computeMeasurementVector(e){let{pixels:t,activeFeature:n,activeViewer:i,mode:a,spatialReference:o}=e,s=i?.imageSize,c=x(i?.media);if(!t||!n||!s)return;let l=y(t,a,s,c).map(async e=>{let t={x:e[0],y:e[1]},n=null;return n=this.measurementVectors.length===0?await this.transformationService.pixelToMapPoint(t):await this.referenceTransformationService?.pixelToMapPoint(t),n?(o&&!n.spatialReference.equals(o)&&(n=await r(n,o)),n):null}),u=(await Promise.all(l)).filter(e=>e!==null);return b(u,n)}resetMeasurementVectors(){this.measurementVectors=[]}async updateMeasurementVectorsArray(e){let{activeFeature:t}=e;if(t){let t=await this.computeMeasurementVector(e);t&&this.measurementVectors.push(t)}}getWorkerMethodProps(e,t){let{updateElevationProps:n,...r}=e;return{imageToWorldProps:{...r,cameraLocation:r.cameraLocation.toJSON()},accuracyParameters:t}}}export{S as ImageMeasurementService};
2
+ import{throwIfAborted as e}from"../../../core/promiseUtils.js";import{open as t}from"../../../core/workers.js";import n from"../../../geometry/Point.js";import{projectAsync as r}from"../../../geometry/projectionUtils.js";import{imageToWorld as i,imageToWorldPanoramic as a}from"../../../layers/orientedImagery/transformations/imageToWorld.js";import{convertSphereVertexToPixelLocation as o}from"../../../layers/orientedImagery/transformations/utils.js";import{getMeasurementProperties as s,pixelAreaMeasurement2D as c,pixelDistanceMeasurement2D as l,getRootOfSumOfSquaredErrors as u,heightMeasurementPanoramic as d,heightMeasurement2D as f,getMeasurementPropertiesPanoramic as p,calculateLocationAccuracyFromDeviations as m,pixelAreaMeasurementPanoramic as h,pixelDistanceMeasurementPanoramic as g,computeTriangulatedAreaMeasurement as _,computeTriangulatedDistanceMeasurement as v,getModeCorrectedPoints as y,computeTriangulatedVector as b}from"../imageMeasurementUtils.js";import{extractHorizonAnglesFromMedia as x}from"../utils.js";class S{constructor(e){this.referenceTransformationService=null,this.measurementVectors=[],this._connection=null,this.transformationService=e.transformationService,this.referenceTransformationService=e.referenceTransformationService}async _load(){this._connection??=await t(`ImageMeasurementWorker`)}async calculateAccuracy(t){await this._load();let{measurementArray:r,measurementType:i,currentBestFeature:a,currentBestFeatureMeasurementImage:o,activeViewer:d,imageSize:f,triangularMeasurementActive:p,footprintExtent:m,signal:h}=t,g=p&&o&&f?o:a,_=g?.attributes.orientationAccuracy,v=!_||_.every(e=>e===0);if(i===`area`&&r.length<3||i===`distance`&&r.length<2||!a||!d?.imageSize||v)return null;let y=null;if(p&&o&&f?y=await s(o,f,m):(y=await s(a,d?.imageSize,m),e(h)),!y)return null;let b=i===`area`?await c(r,y,!0):await l([r.at(0),r.at(-1)],y,!0);e(h);let{updateElevationProps:x}=y,S=this.getWorkerMethodProps(y,_,g.attributes.cameraHeading),C=await this._connection?.invoke(`generateCombinationsWorker`,S,{signal:h});if(e(h),!C?.length)return null;let w=C.map(async t=>{let a={...t,cameraLocation:new n(t.cameraLocation),updateElevationProps:x},o=i===`area`?await c(r,a,!0):await l([r.at(0),r.at(-1)],a,!0);if(e(h),o&&b){if(i===`area`){let e=typeof o==`number`?null:o.area;return e?Math.abs(e-b.area):null}return Math.abs(o-b)}return null}),T=await Promise.all(w);e(h);let E=T.filter(e=>e!==null);return E.length===0?null:u(E)}async calculateHeightAccuracy(e){await this._load();let{mode:t,pixelObj:n,accuracyParameters:r,height:i,properties:a,currentBestFeature:o,signal:s}=e;return t===`panoramic`?this.calculateHeightAccuracyPanoramic(r,n,a,i,o,s):this.calculateHeightAccuracy2D(r,n,a,i,o.attributes.cameraHeading,s)}async calculateHeightAccuracyPanoramic(t,r,i,a,o,s){if(r.length<2||!a||!i||!t||!o)throw Error(`Missing parameters`);let c=this.getWorkerMethodProps(i,t,i.cameraHeading),l=await this._connection?.invoke(`generateCombinationsPanoramicWorker`,c,{signal:s});if(e(s),!l?.length)return null;let u=r.map(e=>[e.x,e.y]),f=u.at(0),p=u.at(-1),m=l.map(e=>(e.cameraLocation=new n(e.cameraLocation),d([f,p],e,t,o,!0,!1,s))),h=await Promise.all(m);e(s);let g=0;for(let e of h){if(!e)return 0;let t=Math.abs(e-a);g=Math.max(t,g)}return g}async calculateHeightAccuracy2D(t,r,i,a,o,s){if(r.length<2||!a||!i||!t)throw Error(`Missing parameters`);let c=this.getWorkerMethodProps(i,t,o),l=await this._connection?.invoke(`generateCombinationsWorker`,c,{signal:s});if(e(s),!l?.length)return null;let u=r.map(e=>[e.x,e.y]),d=u.at(0),p=u.at(-1);if(!d||!p)return null;let m=l.map(e=>(e.cameraLocation=new n(e.cameraLocation),f([d,p],e,t,!0,!1,s))),h=await Promise.all(m);e(s);let g=0;for(let e of h){if(!e)return 0;let t=Math.abs(e-a);g=Math.max(t,g)}return g}async calculateLocationAccuracy(t){await this._load();let{pixel:o,currentResult:c,currentBestFeature:l,mode:u,activeViewer:d,footprintExtent:f,accuracyParameters:h,viewSpatialReference:g,signal:_}=t,v=u??`default`,y=g??null,b=v==="default"?await s(l,d?.imageSize,f):await p(l,d?.imageSize,f);if(e(_),!b)return null;let{updateElevationProps:x}=b,S=v==="default"?`generateCombinationsWorker`:`generateCombinationsPanoramicWorker`,C=this.getWorkerMethodProps(b,h,l.attributes.cameraHeading),w=await this._connection?.invoke(S,C,{signal:_});if(e(_),!w?.length)return null;let T=w.map(async t=>{let{...s}={...t,cameraLocation:new n(t.cameraLocation)},l=v==="default"?await i(o,s,x):await a(o,s,x);return e(_),y&&!l.spatialReference.equals(y)&&(l=await r(l,y),e(_)),l&&c?[Math.abs(l.x-c.x),Math.abs(l.y-c.y),l.z&&c.z?Math.abs(l.z-c.z):0]:null}),E=await Promise.all(T);if(e(_),!E?.length)return null;let D=E.map(e=>[e?.[0]??0,e?.[1]??0,e?.[2]??0]),[O,k,A]=m(D);return{x:O,y:k,z:A}}async calculateAccuracyPanoramic(t){await this._load();let{measurementArray:r,measurementType:i,secondaryViewer:a,currentBestFeature:o,currentBestFeatureMeasurementImage:s,activeViewer:c,activeTriangulatedViewer:l,footprintExtent:d,signal:f}=t,m=a??!1,_=(m&&s&&l?.imageSize?s:o)?.attributes.orientationAccuracy,v=!_||_.every(e=>e===0);if(i===`area`&&r.length<3||i===`distance`&&r.length<2||!o||!c?.imageSize||v)return null;let y=l?.imageSize,b=m&&s&&y?await p(s,y,d):await p(o,c?.imageSize,d);if(e(f),!b)return null;let x=i===`area`?await h(r,b,!0):await g([r.at(0),r.at(-1)],b,!0);e(f);let{updateElevationProps:S}=b,C=this.getWorkerMethodProps(b,_,b.cameraHeading),w=await this._connection?.invoke(`generateCombinationsPanoramicWorker`,C,{signal:f});if(e(f),!w?.length)return null;let T=w.map(async t=>{let a={...t,cameraLocation:new n(t.cameraLocation),updateElevationProps:S},o=i===`area`?await h(r,a,!0):await g([r.at(0),r.at(-1)],a,!0);if(e(f),o&&x){if(i===`area`){let e=typeof o==`number`?null:o.area;return e?Math.abs(e-x.area):null}return Math.abs(o-x)}return null}),E=await Promise.all(T);e(f);let D=E.filter(e=>e!==null);return D.length===0?null:u(D)}async calculateTriangulatedMeasurements(e){let{pixels:t,measureType:n,currentBestFeature:r,currentBestFeatureMeasurementImage:i,activeViewer:a,activeTriangulatedViewer:s,mode:c,imageSize:l,footprintExtent:u}=e;if(!s?.imageSize)return;let[d,f]=s.imageSize;switch(n){case`distance`:{let e=await v(this.measurementVectors),n=t.map(([e,t,n])=>o({x:e,y:t,z:n},d,f)).map(({x:e,y:t})=>[e,t]),p={measurementArray:t,measurementType:`distance`,currentBestFeature:r,currentBestFeatureMeasurementImage:i,activeViewer:a,imageSize:l,triangularMeasurementActive:!0,footprintExtent:u},m={measurementArray:n,measurementType:`distance`,secondaryViewer:!0,currentBestFeature:r,currentBestFeatureMeasurementImage:i,activeViewer:a,activeTriangulatedViewer:s,footprintExtent:u},h=c==="default"?await this.calculateAccuracy(p):await this.calculateAccuracyPanoramic(m);if(h&&e?.distance)return{distance:e,accuracy:{distanceAccuracy:h,angleAccuracy:Math.atan(h/e.distance)}};break}case`area`:if(i?.geometry.spatialReference){let e=await _(this.measurementVectors,i.geometry.spatialReference),n=null;if(c==="default"){let e={measurementArray:t,measurementType:`area`,currentBestFeature:r,currentBestFeatureMeasurementImage:i,activeViewer:a,imageSize:l,triangularMeasurementActive:!0,footprintExtent:u},o=await this.calculateAccuracy(e);o&&(n=o)}else if(c===`panoramic`){let e={measurementArray:t.map(([e,t,n])=>o({x:e,y:t,z:n},d,f)).map(({x:e,y:t})=>[e,t]),measurementType:`area`,secondaryViewer:!0,currentBestFeature:r,currentBestFeatureMeasurementImage:i,activeViewer:a,activeTriangulatedViewer:s,footprintExtent:u},c=await this.calculateAccuracyPanoramic(e);c&&(n=c)}return{area:e,accuracy:n}}}c===`panoramic`&&s.viewModel.restoreNavigationHandles()}async computeMeasurementVector(e){let{pixels:t,activeFeature:n,activeViewer:i,mode:a,spatialReference:o}=e,s=i?.imageSize,c=x(i?.media);if(!t||!n||!s)return;let l=y(t,a,s,c).map(async e=>{let t={x:e[0],y:e[1]},n=null;return n=this.measurementVectors.length===0?await this.transformationService.pixelToMapPoint(t):await this.referenceTransformationService?.pixelToMapPoint(t),n?(o&&!n.spatialReference.equals(o)&&(n=await r(n,o)),n):null}),u=(await Promise.all(l)).filter(e=>e!==null);return b(u,n)}resetMeasurementVectors(){this.measurementVectors=[]}async updateMeasurementVectorsArray(e){let{activeFeature:t}=e;if(t){let t=await this.computeMeasurementVector(e);t&&this.measurementVectors.push(t)}}getWorkerMethodProps(e,t,n){let{updateElevationProps:r,...i}=e;return{imageToWorldProps:{...i,cameraLocation:i.cameraLocation.toJSON()},accuracyParameters:t,cameraHeading:n}}}export{S as ImageMeasurementService};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as n}from"../../core/arrayUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import{handlesGroup as o,makeHandle as s,drainHandles as c,destroyHandle as l}from"../../core/handleUtils.js";import has from"../../core/has.js";import u from"../../core/Logger.js";import{destroyMaybe as d,abortMaybe as f,removeMaybe as p}from"../../core/maybe.js";import{createAbortError as m,ignoreAbortErrors as h,whenOrAbort as g}from"../../core/promiseUtils.js";import{watch as _,syncAndInitial as v,on as ee,when as te,sync as ne,whenOnce as y}from"../../core/reactiveUtils.js";import{property as b,subclass as re}from"../../core/accessorSupport/decorators.js";import{trackAccess as x}from"../../core/accessorSupport/tracking.js";import{SimpleObservable as ie}from"../../core/accessorSupport/tracking/SimpleObservable.js";import{UpdatingHandles as S}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as ae}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as oe,isLoaded as se,load as ce,project as le}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as C}from"../../geometry/support/coordsUtils.js";import{equals as ue}from"../../geometry/support/spatialReferenceUtils.js";import de from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as fe}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as pe}from"../../support/elevationInfoUtils.js";import me from"../../symbols/FillSymbol3DLayer.js";import he from"../../symbols/MeshSymbol3D.js";import ge from"../../symbols/SimpleFillSymbol.js";import _e from"../../symbols/SimpleLineSymbol.js";import w from"../../symbols/SimpleMarkerSymbol.js";import T from"../../symbols/TextSymbol.js";import{symbolTypes as E}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as D}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as ve}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as ye}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as be}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as O}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as k}from"../../views/input/InputManager.js";import{sketchKeys as A}from"../../views/interactive/keybindings.js";import{bindViewToolOptions as xe}from"../../views/interactive/options/bindViewToolOptions.js";import j from"../../views/interactive/options/InteractiveToolOptions.js";import M from"../../views/interactive/sketch/SketchLabelOptions.js";import N from"../../views/interactive/sketch/SketchOptions.js";import Se from"../../views/interactive/sketch/SketchTooltipOptions.js";import Ce from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as P}from"../../views/interactive/snapping/SnappingManager.js";import{acquireForViewOptions as we}from"../../views/interactive/snapping/SnappingManagerPool.js";import F from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as I}from"../../views/interactive/snapping/snappingUtils.js";import{GeometryWorkerHandle as Te}from"../../views/support/GeometryWorkerHandle.js";import{defaultHighlightName as Ee}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as De}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as L}from"../../views/support/screenUtils.js";import Oe from"./adapters/layer/GraphicsLayerAdapter.js";import ke from"./adapters/layer/MapNotesLayerAdapter.js";import Ae from"./adapters/layer/SketchLayerAdapter.js";import{CreateOperationHandle as je,DrawToolOperationHandle as Me,UpdateOperationHandle as R}from"./support/OperationHandle.js";import{PluginManager as Ne}from"./support/PluginManager.js";import{SettingsManager as Pe}from"./support/SettingsManager.js";import{getLegacyTool as z,isCompletelyDegenerate as Fe,graphicsHaveTooFewVerticesForBox as B,getModeFromCreateOptions as Ie,getDrawToolGeometryTypeFromCreateTool as Le}from"./support/sketchUtils.js";const V={defaultZ:0},H={reshapeOptions:{edgeOperation:`split`,shapeOperation:`move`,vertexOperation:`move`,enableCreateCurveFromStraightEdge:!0},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0,name:Ee},tool:`transform`},U=Symbol(),W=Symbol();let G=class extends a{constructor(e){super(e),this._defaultSnappingManager=null,this._operationContext=null,this._internalGraphicsLayer=new de({listMode:`hide`,internal:!0,title:`SVM Internal`}),this._pluginManager=new Ne({sketchViewModel:this}),this.settingsManager=new Pe({availablePlugins:()=>this.pluginManager.visiblePluginsFlat}),this._operationHandle=null,this._updatingHandles=new S,this._toolTransitionHandles=new S,this._drawToolSimplifyAbortController=null,this._geometryWorkerHandle=new Te,this._viewHandlesKey=`viewHandles`,this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.activeUpdateOptions=null,this.layer=null,this.pointSymbol=new w({style:`circle`,size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new ge({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new _e({color:[130,130,130,1],width:2}),this.meshSymbol=new he({symbolLayers:new r([new me])}),this.updateGraphics=new r,this.updateOnGraphicClick=!0,this.useViewOptions=!1,this.cancelUpdateOnClickAway=!0,this.creationMode=`single`,this.vertexSymbol=new w({style:`circle`,size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new N,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{let{_layerAdapter:e}=this;if(this.removeHandles(W),!e)return;let t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),_(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},v)].filter(n);this.addHandles(t,W)},this._originalPopupEnabled=null,this.defaultCreateOptions=V,this.defaultUpdateOptions=H,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new F,this.textSymbol=new T({text:`text`})}initialize(){this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([ee(()=>this.view?.map?.layers,`change`,e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),_(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),v),_(()=>this.view,e=>{this._defaultSnappingManager=d(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new P({view:e,options:this.snappingOptions})),e.type===`2d`?(import(`../../views/2d/interactive/editingTools.js`),this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe())):e.type===`3d`&&(import(`../../views/3d/interactive/editingTools.js`),import(`../../views/3d/layers/GraphicsLayerView3D.js`)))},v),_(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),I(this,void 0,()=>this._operationSnappingManager?.options??this.snappingOptions)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=d(this._defaultSnappingManager),this._destroyOperationContext(),this._set(`snappingManager`,null),this._set(`view`,null),this._updatingHandles.destroy(),this._toolTransitionHandles.destroy(),this._drawToolSimplifyAbortController=f(this._drawToolSimplifyAbortController),this._geometryWorkerHandle.destroy(),this._pluginManager?.destroy(),this.emit(`destroy`)}get _operationSnappingManager(){return this._operationContext?.snappingManager??this.snappingManager}get _operationToolOptions(){return this._operationContext?.toolOptions??this.sketchOptions}get _layerAdapter(){let{layer:e}=this;switch(e?.type){case`graphics`:return new Oe(e);case`map-notes`:return new ke(e);case`sketch`:return new Ae(e);case void 0:default:return null}}get activeTool(){return this._operationHandle?.tool??null}get geometrySimplificationInProgress(){return!!this._drawToolSimplifyAbortController}get activeCreateToolDrawMode(){let e=this._operationHandle;if(e?.type===`create`&&e.activeComponent&&`mode`in e.activeComponent)return e.activeComponent.mode;if(e?.activeComponent?.type===`draw-2.0`){let t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(n).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){let{activeComponent:e,destroyed:t}=this,n=!t&&e&&`tooltip`in e?e.tooltip:null;return n?.visible?n:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return this.activeComponent!=null&&(this.activeComponent.type===`draw-3d`||this.activeComponent.type===`draw-2d`)?this.activeComponent.graphic:this._get(`createGraphic`)}get defaultCreateOptions(){return this._get(`defaultCreateOptions`)}set defaultCreateOptions(e){this._set(`defaultCreateOptions`,{...V,...e})}get defaultUpdateOptions(){return this._get(`defaultUpdateOptions`)}set defaultUpdateOptions(e){this._set(`defaultUpdateOptions`,{...H,...e,reshapeOptions:{...H.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...H.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get textSymbol(){return this._get(`textSymbol`)}set textSymbol(e){this._set(`textSymbol`,e)}get snappingOptions(){return this.snappingManager?.options??this._get(`snappingOptions`)}set snappingOptions(e){this._defaultSnappingManager!=null&&(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=d(this._defaultSnappingManager)),this._override(`snappingManager`,e);else{let{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new P({options:this.snappingOptions,view:e})),this._clearOverride(`snappingManager`)}}get state(){let e=!!(this.view?.ready&&this.layer),t=this._operationHandle;return e&&t?`active`:e?`ready`:`disabled`}get toolTransitionInProgress(){return this._toolTransitionHandles.updating||!!this.drawTool?.lifecycleManager.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return this.toolTransitionInProgress||this.activeComponent&&`updating`in this.activeComponent&&this.activeComponent.updating||!!(this._updatingHandles.updating||this._drawToolSimplifyAbortController||this.snappingManager?.updating||this.drawTool?.updating)}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get(`view`)}set view(e){let t=this._get(`view`);if(t===e)return;if(t){let{container:e,map:n}=t;e&&this._clearCursor(),n?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}let n=`view-ready`;this.removeHandles(n),e&&this.addHandles(te(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},v),n),this._set(`view`,e),this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||this.view?.type!==`2d`}get pluginManager(){return this._pluginManager}get drawTool(){return this.activeComponent?.type===`draw-2.0`?this.activeComponent:null}get activePluginConfigurations(){return this.drawTool?.pluginStack.toArray().map(e=>e.configuration).filter(n)??[]}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome(`rootPlugins`,e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;let e=this.view?.type??`2d`,{firstPluginWithSwappableLeaf:t}=this;return t?t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e)):this.rootPlugins?.filter(t=>!t.excludedViews?.includes(e)).filter(n)??[]}get firstPluginWithSwappableLeaf(){let e=this.view?.type??`2d`;return this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>t!=null&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1)}get multiplePluginsActive(){return this.drawTool?this.drawTool.pluginStack.length>1:!1}replaceLeaf(e){this.drawTool?.replaceLeaf(e)}addGraphic(e){this._layerAdapter?.add(e)}addGraphics(e){this._layerAdapter?.addMany(e)}hasGraphic(e){return!!this._layerAdapter?.has(e)}removeGraphic(e){this._layerAdapter?.remove(e)}removeGraphics(e){this._layerAdapter?.removeMany(e)}removeAllGraphics(){this._layerAdapter?.removeAll()}cancel(){this._moduleLoaderAbortController=f(this._moduleLoaderAbortController),this._viewReadyAbortController=f(this._viewReadyAbortController),this._drawToolSimplifyAbortController=f(this._drawToolSimplifyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){let{state:e,updateGraphics:t}=this;if(e===`active`&&t.length){let{activeTool:e}=this,n=t.toArray();this.removeGraphics(n),this.cancel(),this._emitDeleteEvent({graphics:n,tool:e})}}duplicate(){if(this.state===`active`&&this.updateGraphics.length){let e=this.updateGraphics.map(e=>e.clone()).toArray();return this.addGraphics(e),this.emit(`duplicate`,{graphics:e,type:`duplicate`}),e}return[]}async create(e,t){return this._toolTransitionHandles.addPromise(this._create(e,t))}async _create(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());let{view:n,layer:r}=this;if(!n||this.state===`disabled`)throw r||this._logMissingLayer(),m();if(n.activeTool!=null&&(n.activeTool=null),!e){this._logError(`sketch:missing-parameter`,`Missing parameter 'tool'.`);return}O(n,this._internalGraphicsLayer);let i=this._createOperationContext(n),a;try{a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t))}catch(e){throw this._destroyOperationContext(i),e}if(a==null||this.destroyed||i!==this._operationContext){let e=i===this._operationContext;a?.onEnd(),d(a),this._destroyOperationContext(i),e&&n.map?.remove(this._internalGraphicsLayer);return}let o=z(e);a.on(`complete`,()=>{if(a===this._operationHandle){let n=this.createGraphic,r=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._destroyOperationContext(),this._set(`createGraphic`,null),this.view?.map?.remove(this._internalGraphicsLayer),!a.cancelled&&n!=null&&this.addGraphic(n),this._sketchContinuationFlag=!1,this.emit(`create`,{graphic:n,state:r?`cancel`:`complete`,tool:o??`point`,toolEventInfo:null,type:`create`}),r||this._sketchContinuationFlag)return;let{creationMode:i}=this;if(i===`continuous`){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(h(this.create(e,t)))}else i===`update`&&n&&this._updatingHandles.consumePromise(h(this.update([n])))}}),this._operationHandle=a,n.ready&&n.focus()}async place(e,t){return await e.load(),this.create(`mesh`,{mode:`click`,hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){return this._toolTransitionHandles.addPromise(this._update(e,t))}async _update(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());let{layer:n,view:r,state:i}=this;if(!r||i===`disabled`)throw n||this._logMissingLayer(),m();r.activeTool!=null&&(r.activeTool=null);let a=Array.isArray(e)?e:[e];if(e==null||!a?.length){this._logError(`sketch:missing-parameter`,`Missing parameter 'graphics'.`);return}if(a.some(e=>this.hasGraphic(e)?e.geometry==null&&(this._logError(`sketch:invalid-parameter`,`Parameter 'graphics' contains one or more graphics with an unsupported geometry.`),!0):(this._logError(`sketch:invalid-parameter`,`Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer.`),!0)))return;let o=this._createOperationContext(r),s;try{s=await this._updatingHandles.addPromise(this._setupUpdateOperation(a,t))}catch(e){throw this._destroyOperationContext(o),e}if(this.destroyed||s==null||$(s)||o!==this._operationContext){s&&!$(s)&&(s.onEnd(),s.destroy()),this._destroyOperationContext(o);return}O(r,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit(`update`,{graphics:a,state:`start`,aborted:!1,tool:s.tool,toolEventInfo:null,type:`update`})}async _updateSpatialReference(e){let t=this.view;if(!t){this._logMissingView();return}e=Array.isArray(e)?e:[e];for(let n of e)n.geometry!=null&&n.geometry.type!==`mesh`&&!ue(n.geometry.spatialReference,t.spatialReference)&&(!oe(n.geometry.spatialReference,t.spatialReference)&&!se()&&await ce(),n.geometry=le(n.geometry,t.spatialReference))}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._updatingHandles.consumePromise(this._operationHandle?.toggleTool())}_createOperationContext(e){this._destroyOperationContext();let t=this.useViewOptions?e.options:null,n=t?we(e):null,r=t?new j:this.sketchOptions,i;if(t){let{values:t}=r;i=o([xe(r,()=>e.options,()=>this.sketchOptions),_(()=>t.directionMode,e=>{this.sketchOptions.values.directionMode=e},ne)])}return this._operationContext={snappingManager:n?.snappingManager??this.snappingManager,toolOptions:r,...o([n,i])}}_destroyOperationContext(e=this._operationContext){if(e!==this._operationContext){p(e);return}this._operationContext=p(this._operationContext)}async _getFirstHit(e){let t=this.view;if(!t)return this._logMissingView(),null;if(t.type===`2d`){let n=[];t.map.allLayers.forEach(e=>{(e.type===`vector-tile`||e.type===`imagery`)&&n.push(e)});let r=await t.hitTest(e,{exclude:n});return De(r.results)}let n=[t.map.ground];t.map.allLayers.forEach(e=>{fe(e)&&(!has(`enable-feature:im-as-ground`)||e.isUsedAsGroundLayer)&&n.push(e)});let r=await t.hitTest(e,{exclude:n});if(r.results.length>0){let e=r.results[0];if(e!=null&&e.type===`graphic`&&e.graphic&&(!r.ground.mapPoint||t.map.ground.opacity<1||r.ground.distance-(e.distance??0)>-Math.min(3*r.ground.distance,t.viewingMode===`global`?ae(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:1/0)))return e}return null}_generateViewHandles(e){return[e.on(`immediate-click`,async e=>{let t=this.state===`active`&&this._operationHandle?.type===`create`;this.state!==`disabled`&&!t&&this.updateOnGraphicClick&&await this._toolTransitionHandles.addPromise(this._handleImmediateClick(e))},k.WIDGET)]}async _handleImmediateClick(e){let t=await e.defer(()=>this._getFirstHit(L(e))),n=null;if(t!=null){let r=t.graphic;this.updateGraphics.includes(r)||this.hasGraphic(r)?(e.stopPropagation(),n=r):this.view?.type===`2d`&&!this._isComponentGraphic(r)&&this.state===`active`&&this.cancel()}else this.state===`active`&&this.cancelUpdateOnClickAway&&this.cancel();n!=null&&!this.updateGraphics.includes(n)&&await this.update([n],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){let n=this.view;if(!n)return this._logMissingView(),null;let r={hasZ:n.type===`3d`,...this.defaultCreateOptions,...t},i=typeof e==`string`?this.pluginManager?.getPluginsEquivalentToCreateTool(e,r):e,a=z(e);if(i&&!this.isUsingLegacyCreateTools){let e=await this._setupDrawTool(i,r,a??`polyline`);if(e)return this._setupDrawToolOperationHandle(e,a??`point`)}if(!a)return null;let o=await this._setupDrawGraphicTool(a,n,r);return o==null?null:(n.tools.add(o),n.activeTool=o,this._setupCreateOperationHandle(o,a))}async _setupDrawGraphicTool(e,t,n){if(e===`multipoint`&&t.type===`3d`)return this._logError(`sketch:create`,`Multipoint geometries are not supported in SceneView.`),null;if(!t)return this._logMissingView(),null;let{cursor:r,defaultZ:i,hasZ:a,geometryToPlace:o,graphicProperties:s,mode:c,preserveAspectRatio:l}=n,u=Ie(c,e),d=Le(e),f=n?.optionsPerTool?.has(e)?n.optionsPerTool.get(e):{},p=f?.preserveAspectRatio??l??e!==`rectangle`,m={centered:e!==`rectangle`&&!(e===`circle`&&!p),cursor:r,defaultZ:i,forceUniformSize:p,graphicProperties:{...s,attributes:{...s?.attributes}},geometryToPlace:o,geometryType:d,mode:u,graphicSymbol:n.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:a,snappingManager:this._operationSnappingManager,snapToScene:!1,view:t,...f};return t.type===`2d`?this._makeDrawGraphicTool2D(m):this._makeDrawGraphicTool3D(m)}async _makeDrawGraphicTool2D(e){let t=await this._requireModule(import(`../../views/2d/interactive/editingTools.js`));return $(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:ze(e.geometryType)?this.activeFillSymbol:null,toolOptions:this._operationToolOptions})}async _makeDrawGraphicTool3D(e){let t=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));return $(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,toolOptions:this._operationToolOptions})}_setupCreateOperationHandle(e,t){let n=this.view;if(!n)return this._logMissingView(),null;let r=null,i=e.forceUniformSize,a=e.centered,o=new ie,l=[s(()=>o.destroy()),n.on(`key-down`,t=>{if(t.key===A.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===A.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key===A.vertexAdd&&!t.repeat){let n=e.drawOperation.geometryType;(n===`polyline`||n===`polygon`||n===`multipoint`)&&(t.stopPropagation(),e.drawOperation.commitStagedVertex())}else t.key===A.undo?(t.stopPropagation(),u.undo()):t.key===A.redo?(t.stopPropagation(),u.redo()):t.key===A.constraint&&(e.geometryType===`rectangle`||e.geometryType===`circle`)&&!t.repeat?(e.forceUniformSize=!i,t.stopPropagation()):t.key===A.center&&(t.repeat||(e.centered=!a,t.stopPropagation()))},k.WIDGET),n.on(`key-up`,t=>{t.key===A.pan?e.enabled=!0:t.key===A.constraint&&(e.geometryType===`rectangle`||e.geometryType===`circle`)?(e.forceUniformSize=i,t.stopPropagation()):t.key===A.center&&(e.centered=a,t.stopPropagation())},k.WIDGET),e.on(`vertex-update`,()=>{o.notify()}),e.on(`vertex-add`,t=>{switch(o.notify(),r=r==null?`start`:`active`,t.operation){case`apply`:this.emit(`create`,{graphic:e.graphic,state:r,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(o.notify(),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),r=`complete`,e.aborted?u&&u.cancel():u&&u.complete()}),_(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],u=new je({activeComponent:e,type:`create`,onEnd:()=>{c(l),n.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>(x(o),e.canUndo),canRedo:()=>(x(o),e.canRedo)});return u}_setupDrawToolOperationHandle(e,t){let r=this.view;if(!r)return this._logMissingView(),null;let i=null,a=[r.on(`key-down`,t=>{t.key===A.pan&&(t.stopPropagation(),t.repeat||(e.editable=!1))},k.WIDGET),r.on(`key-up`,t=>{t.key===A.pan&&(e.editable=!0)},k.WIDGET),e.on(`before-vertex-add`,t=>{let n=e.mostUpstreamPlugin?.configuration;if(n&&`legacyCreateTool`in n&&(n?.legacyCreateTool===`point`||n.legacyCreateTool===`text`)){let e=t.detail.originalEvent;e&&`key`in e&&e.key===A.vertexAdd&&t.preventDefault();return}}),e.on(`before-complete`,t=>{let n=e.getGeometryIfCompleted();if(!n||Fe(n)){t.preventDefault();return}}),e.on([`vertex-add`,`vertex-remove`],r=>{switch(this.createGraphic&&(this.createGraphic.geometry=e.getGeometryIfCompleted()),i=i==null&&r.type!==`vertex-remove`?`start`:`active`,r.operation){case`apply`:this.emit(`create`,{graphic:this.createGraphic,state:i,tool:this.activeTool,toolEventInfo:r,type:`create`});break;case`undo`:this._emitUndoEvent({graphics:[this.createGraphic].filter(n),tool:t});break;case`redo`:this._emitRedoEvent({graphics:[this.createGraphic].filter(n),tool:t})}}),e.on(`cursor-update`,t=>{this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),(t.vertices[0]?.vertexIndex>0||t.vertices[0]?.componentIndex>0)&&this.emit(`create`,{graphic:this.createGraphic,state:`active`,tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:`cursor-update`},type:`create`})}),e.on(`complete`,async({geometry:t,isSimple:n})=>{let r=this.createGraphic,i=!!t&&t.type!==`mesh`&&t.type!==`extent`&&!n;if(r&&(r.geometry=n?t:e.unprocessedGeometry??t),!i||!r)o.complete();else{this._internalGraphicsLayer.add(this.createGraphic);let e=new AbortController;this._drawToolSimplifyAbortController?.abort(),this._drawToolSimplifyAbortController=e,await this._updatingHandles.addPromise(h(this._finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:r,handle:o})))}})],o=new Me({activeComponent:e,type:`create`,onEnd:()=>{c(a),r.tools.remove(e)},undo:()=>e.undo(),redo:()=>e.redo(),canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return a.push(e.on(`cancel`,()=>{this._drawToolSimplifyAbortController=f(this._drawToolSimplifyAbortController),o.cancel()})),o}async _finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:n,handle:r}){let i=this.view?.acquireCursor(`progress`,`high`);i&&this.addHandles(i);let a=()=>e.signal.aborted?(n&&(this._layerAdapter?.remove(n),this._internalGraphicsLayer?.remove(n)),this._set(`createGraphic`,null),!0):!1;try{let i=await this._geometryWorkerHandle.simplify(t,e.signal);if(a())return;n.geometry=i??t,this._internalGraphicsLayer?.remove(n),r.complete()}finally{i?.remove(),this._drawToolSimplifyAbortController===e&&(this._drawToolSimplifyAbortController=null)}}_getGraphicSymbolFromTool(e){switch(e){case`point`:case`multipoint`:return this.pointSymbol;case`polyline`:case`freehandPolyline`:return this.polylineSymbol;case`circle`:case`rectangle`:case`polygon`:case`freehandPolygon`:return this.polygonSymbol;case`mesh`:return this.meshSymbol;case`text`:return this.textSymbol}}async _setupUpdateOperation(e,t){let{view:n}=this;if(!n)return this._logMissingView(),null;let r={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};this.activeUpdateOptions=r;let i=r.tool??H.tool;if(this.removeGraphics(e),this.addGraphics(e),n.type===`3d`){if(e.length===0)return null;switch(i){case`move`:return this._setupMove3DOperation(e,r,n,i);case`reshape`:return e.length>1?(this._logError(`sketch:reshape-multiple`,`Reshape operation does not support multiple graphics.`),null):this._setupReshape3DOperation(e[0],r,n);case`transform`:return this._setupGraphicTransform3DOperation(e,r,n)}}switch(i){case`move`:return this._setupMove2DOperation(e,r,n);case`reshape`:return e.length>1?(this._logError(`sketch:reshape-multiple`,`Reshape operation does not support multiple graphics.`),null):this._setupTransformOrReshape2DOperation(e,i,r,n);case`transform`:return B(e)&&(i=`reshape`),this._setupTransformOrReshape2DOperation(e,i,r,n)}}async _setupMove3DOperation(e,t,n,r,i=!1){let a=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));if($(a))return a;let{ManipulatedObject3DGraphic:o,MoveTool3D:s}=a.module,l=new Map,u=()=>{l.forEach(e=>e.destroy()),l.clear()};for(let t of e){let e=new o({view:n,graphic:t}),r=ve(e);if(r!==0)return u(),this._logError(`sketch:move`,`Move operation not supported for provided graphic(s) (${D(r)}).`),null;l.set(t,e)}let d=new s({view:n,enableZ:t.enableZ,snappingManager:this._operationSnappingManager,toolOptions:this._operationToolOptions});n.tools.add(d),d.objects.addMany(Array.from(l.values())),i||this.updateGraphics.addMany(e);let f=[],p=new R({activeComponent:d,tool:r,type:`update`,onEnd:()=>{c(f),Q(n,d),u()},undo:()=>{X(this.view,d),q(p,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r})},redo:()=>{J(p,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r})},addToSelection:async e=>{this.updateGraphics.push(e);let t=new o({view:n,graphic:e});l.set(e,t),d.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:async e=>{let t=this.updateGraphics.indexOf(e);if(p.history.undo.forEach(e=>e.updates.splice(t,1)),p.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`}),this.updateGraphics.length===0){p.complete();return}let n=l.get(e);n&&(d.objects.remove(n),n.destroy(),l.delete(e))},toggleTool:async()=>{if(this.updateGraphics.length!==1||t.toggleToolOnClick===!1||r!==`transform`)return;let e=this.updateGraphics.at(0),i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,n,!0));i&&!$(i)&&(p.onEnd(),p.destroy(),this._setUpdateOperationHandle(i,t))}});return f.push(...this._getHandlesForComponent(p,t),n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(p,e,t),k.WIDGET),n.on(`key-down`,e=>{this._getCommonUpdateOperationKeyDownHandlers(p,e)},k.WIDGET)),p}_setupGraphicTransform3DOperation(e,t,n,r=!1){if(e.length===1&&be(e[0])===0){let i=e[0],a=i.geometry;if(a!=null&&(a.type===`point`||a.type===`mesh`))return this._setupPointTransform3DOperation(i,t,n);if(a!=null&&(a.type===`polygon`||a.type===`polyline`))return this._setupPolyTransform3DOperation(i,t,n,r)}return this._setupMove3DOperation(e,t,n,`transform`,r)}async _setupPointTransform3DOperation(e,t,n){let r=`transform`,{enableRotation:i,enableScaling:a,enableZ:o}=t,s=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));if($(s))return s;let{TransformTool3D:l,ManipulatedObject3DGraphic:u}=s.module,d=new u({graphic:e,view:n}),f=new l({object:d,view:n,enableRotation:i,enableScaling:a,enableZ:o,snappingManager:this._operationSnappingManager,toolOptions:this._operationToolOptions});n.tools.add(f),this.updateGraphics.add(e);let p=[],m=new R({activeComponent:f,tool:r,type:`update`,onEnd:()=>{c(p),Q(n,f),d.destroy()},undo:()=>{X(this.view,f),q(m,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r})},redo:()=>{J(m,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r})},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`}),await this._replaceUpdateOperationHandle(m,t,()=>this._setupMove3DOperation(this.updateGraphics.toArray(),t,n,`transform`,!0))},removeFromSelection:async 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`}),m.complete()},toggleTool:async()=>{}});return p.push(...this._getHandlesForComponent(m,t),n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(m,e,t),k.WIDGET),n.on(`key-down`,e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},k.WIDGET)),m}async _setupPolyTransform3DOperation(e,t,n,r=!1){let i=`transform`,{enableRotation:a,enableScaling:o,enableZ:s,preserveAspectRatio:l}=t,u=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));if($(u))return u;let{ManipulatedObject3DGraphic:d,ExtentTransformTool:f}=u.module,p=this.view?.inputManager?.isModifierKeyDown(A.constraint),m=new d({view:n,graphic:e}),h=new f({object:m,view:n,enableRotation:a,enableScaling:o,enableZ:s,preserveAspectRatio:!!l!=!!p,toolOptions:this._operationToolOptions});n.tools.add(h),r||this.updateGraphics.add(e);let g=[],_=new R({activeComponent:h,tool:i,type:`update`,onEnd:()=>{c(g),Q(n,h),m.destroy()},canUndo:()=>!h.destroyed&&h.canUndo,undo:()=>{h.destroyed||(h.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i}))},canRedo:()=>!h.destroyed&&h.canRedo,redo:()=>{h.destroyed||(h.redo(),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`}),await this._replaceUpdateOperationHandle(_,t,()=>this._setupMove3DOperation(this.updateGraphics.toArray(),t,n,`transform`,!0))},removeFromSelection:async 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`}),_.complete()},toggleTool:async()=>{if(this.updateGraphics.length!==1||t.toggleToolOnClick===!1)return;let r=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,n,!0));r&&!$(r)&&(_.onEnd(),_.destroy(),this._setUpdateOperationHandle(r,t))}});return g.push(...this._getHandlesForComponent(_,t),n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(_,e,t),k.WIDGET),n.on(`key-down`,e=>this._getCommonUpdateOperationKeyDownHandlers(_,e),k.WIDGET),n.on(`key-down`,e=>{e.key===A.constraint&&!e.repeat&&(h.preserveAspectRatio=!h.preserveAspectRatio,e.stopPropagation())},k.WIDGET),n.on(`key-up`,e=>{e.key===A.constraint&&(h.preserveAspectRatio=!h.preserveAspectRatio,e.stopPropagation())},k.WIDGET)),_}async _setupMove2DOperation(e,t,n){let r=`move`;this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));let i=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,n));if($(i))return i;let a=new R({activeComponent:i,tool:r,type:`update`,onEnd:()=>{this._clearCursor(),c(l),c(s),i.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{let e=this.updateGraphics.toArray();q(a,e),a.refreshComponent(),this._emitUndoEvent({graphics:e,tool:r})},redo:()=>{let e=this.updateGraphics.toArray();J(a,e),a.refreshComponent(),this._emitRedoEvent({graphics:e,tool:r})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),i.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:async e=>{let t=this.updateGraphics.indexOf(e);a.history.undo.forEach(e=>e.updates.splice(t,1)),a.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);let n=this.updateGraphics.toArray();if(this.emit(`update`,{graphics:n,state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:`selection-change`},type:`update`}),this.updateGraphics.length===0){a.complete();return}i.graphics=n}}),o=!1,s=[n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(a,e,t),k.WIDGET),n.on(`key-down`,e=>{this._getCommonUpdateOperationKeyDownHandlers(a,e),e.key===A.constraint&&!e.repeat&&(o=!0,i.enableMoveAllGraphics=!i.enableMoveAllGraphics)},k.WIDGET),n.on(`key-up`,e=>{e.key===A.constraint&&o&&(o=!1,i.enableMoveAllGraphics=!i.enableMoveAllGraphics)},k.WIDGET)],l=this._getHandlesForComponent(a,t);return a}async _setupReshape3DOperation(e,t,n,r=!1){let i=`reshape`,a=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));if($(a))return a;let{ManipulatedObject3DGraphic:o,ReshapeTool3D:s}=a.module,l=new o({view:n,graphic:e}),u=ye(l);if(u!==0)return l.destroy(),this._logError(`sketch:reshape`,`Reshape operation not supported for provided graphic(s) (${D(u)}).`),null;let d=t.reshapeOptions,f=new s({view:n,object:l,enableZVertex:t.enableZ&&d?.vertexOperation===`move`,enableZShape:t.enableZ&&d?.shapeOperation===`move`,enableMoveObject:d?.shapeOperation===`move`||d?.shapeOperation===`move-xy`,enableMidpoints:d?.edgeOperation===`split`,enableEdgeOffset:d?.edgeOperation===`offset`,snappingManager:this._operationSnappingManager,toolOptions:this._operationToolOptions});n.tools.add(f),r||this.updateGraphics.add(l.graphic);let p=[],m=new R({activeComponent:f,tool:i,type:`update`,onEnd:()=>{c(p),Q(n,f),l.destroy()},canUndo:()=>!f.destroyed&&f.canUndo,undo:()=>{f.destroyed||(f.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i}))},canRedo:()=>!f.destroyed&&f.canRedo,redo:()=>{f.destroyed||(f.redo(),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`}),await this._replaceUpdateOperationHandle(m,t,()=>this._setupMove3DOperation(this.updateGraphics.toArray(),t,n,`transform`,!0))},removeFromSelection:async 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`}),m.complete()},toggleTool:async()=>{t.toggleToolOnClick!==!1&&await this._replaceUpdateOperationHandle(m,t,()=>this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,n,!0))}});return p.push(...this._getHandlesForComponent(m,t),n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(m,e,t),k.WIDGET),n.on(`key-down`,e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},k.WIDGET)),m}async _setupTransformOrReshape2DOperation(e,t,n,r){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));let i=await this._updatingHandles.addPromise(t===`transform`?this._getBox(e,n,r):this._getReshape(e,n,r));if($(i))return i;let a=new R({activeComponent:i,type:`update`,onEnd:()=>{c(s),c(o),a.activeComponent&&!a.activeComponent.destroyed&&a.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{q(a,this.updateGraphics.toArray()),a.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a.tool})},redo:()=>{J(a,this.updateGraphics.toArray()),a.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a.tool})},addToSelection:async e=>{let t=a.activeComponent;if(t?.type===`reshape`){let t=[...this.updateGraphics,e];if(this.updateGraphics.removeAll(),!await this._replaceUpdateOperationHandle(a,n,()=>this._setupTransformOrReshape2DOperation(t,`transform`,n,r)))return}else this.updateGraphics.add(e),t=t,t.graphics=this.updateGraphics.toArray(),t.refresh(),a.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=>{let t=this.updateGraphics.indexOf(e);a.history.undo.forEach(e=>e.updates.splice(t,1)),a.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);let n=this.updateGraphics.toArray();n.length===0?a.complete():B(n)?await a.toggleTool():a.activeComponent.graphics=n,this.emit(`update`,{graphics:n,state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:`selection-change`},type:`update`})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;let e=this.updateGraphics.at(0),t=e.geometry;if(t!=null&&(a.tool===`reshape`&&t.type===`point`||a.tool===`transform`&&t.type===`extent`))return;let i=null,o={...this.defaultUpdateOptions,...n,...this.activeUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...n?.reshapeOptions,...this.activeUpdateOptions?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...n?.highlightOptions,...this.activeUpdateOptions?.highlightOptions}};a.tool===`transform`?i=await this._updatingHandles.addPromise(this._getReshape([e],o,r)):a.tool===`reshape`&&(i=await this._updatingHandles.addPromise(this._getBox([e],o,r))),!$(i)&&(a.activeComponent?.destroy(),a.activeComponent=i,a.activeComponent&&(c(s),s=this._getHandlesForComponent(a,o)))}}),o=[r.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(a,e,n),k.WIDGET),r.on(`key-down`,e=>{if(this._getCommonUpdateOperationKeyDownHandlers(a,e),e.key===A.constraint&&!e.repeat&&a){let e=a.activeComponent;e?.type===`box`&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},k.WIDGET),r.on(`key-up`,e=>{if(e.key===A.constraint&&a){let e=a.activeComponent;e?.type===`box`&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},k.WIDGET)],s=this._getHandlesForComponent(a,n);return a}async _getGraphicMover(e,t,n){let{enableMoveAllGraphics:r,highlightOptions:i}=t,a=await this._requireModule(import(`../../views/draw/support/GraphicMover.js`));return $(a)?a:new a.module.default({enableMoveAllGraphics:r,highlightName:i?.name,highlightsEnabled:!!i?.enabled,indicatorsEnabled:!1,graphics:e,view:n,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:n})=>{this._displayCursor(`grabbing`),this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:`move-start`},type:`update`})},onGraphicMove:({dx:e,dy:t,graphic:n})=>this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:`move`},type:`update`}),onGraphicMoveStop:({dx:e,dy:t,graphic:n})=>{this._displayCursor(`pointer`),this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:`move-stop`},type:`update`})},onGraphicPointerOver:()=>this._displayCursor(`move`),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,n){let{enableRotation:r,enableScaling:i,highlightOptions:a,preserveAspectRatio:o}=t,s=await this._requireModule(import(`../../views/draw/support/Box.js`));if($(s))return s;let c=this.view?.inputManager?.isModifierKeyDown(A.constraint),l=new s.module.default({graphics:e,enableRotation:r,enableScaling:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,preserveAspectRatio:!!o!=!!c,layer:this._internalGraphicsLayer,view:n,toolOptions:this._operationToolOptions,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`})}});return l.addHandles(_(()=>[this.activeUpdateOptions?.enableRotation,this.activeUpdateOptions?.enableScaling],([e,n])=>{l.enableRotation=e??t.enableRotation??!0,l.enableScaling=n??t.enableScaling??!0,l.refresh()},v)),l}async _getReshape(e,t,n){let{highlightOptions:r,reshapeOptions:i}=t,a=i?.edgeOperation===`split`,o=i?.shapeOperation===`move`,s=!!i?.enableCreateCurveFromStraightEdge,c=await this._requireModule(import(`../../views/draw/support/Reshape.js`));return $(c)?c:new c.module.default({enableMidpoints:a,enableMovement:o,enableCurveOnMidpoint:s,graphic:e[0],highlightName:r?.name,highlightsEnabled:!!r?.enabled,layer:this._internalGraphicsLayer,snappingManager:this._operationSnappingManager,toolOptions:this._operationToolOptions,view:n,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:n,type:r})=>this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:r},type:`update`}),onMove:({dx:e,dy:t,mover:n,type:r})=>this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:r},type:`update`}),onMoveStop:({dx:e,dy:t,mover:n,type:r})=>this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:r},type:`update`}),onVertexAdd:({added:e,type:t,vertices:n})=>{let r=e.map(e=>C(e.geometry));this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{added:r,vertices:n,type:t},type:`update`})},onVertexRemove:({removed:e,type:t,vertices:n})=>{let r=e.map(e=>C(e.geometry));this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{removed:r,vertices:n,type:t},type:`update`})}}})}_getHandlesForComponent(e,t){let n=e.activeComponent;if(!n)return[];switch(n.type){case`graphic-mover`:return[n.on(`graphic-click`,({graphic:n,viewEvent:r})=>{r.native?.shiftKey&&t.multipleSelectionEnabled&&(r.stopPropagation(),this._updatingHandles.consumePromise(e.removeFromSelection(n)))}),n.on(`graphic-move-start`,t=>e.addToHistory(Z(t.allGraphics)))];case`box`:return[n.on(`graphic-click`,n=>this._onTransformOrReshape2DGraphicClick(e,t,n)),n.on(`move-start`,t=>e.addToHistory(Z(t.graphics))),n.on(`rotate-start`,t=>e.addToHistory(Z(t.graphics))),n.on(`scale-start`,t=>e.addToHistory(Z(t.graphics)))];case`reshape`:return[n.on(`graphic-click`,n=>this._onTransformOrReshape2DGraphicClick(e,t,n)),n.on(`move-start`,t=>e.addToHistory(Z([t.mover]))),n.on(`reshape-start`,t=>e.addToHistory(Z([t.graphic]))),n.on(`vertex-add`,t=>e.addToHistory(Z([t.oldGraphic]))),n.on(`vertex-remove`,t=>e.addToHistory(Z([t.oldGraphic])))];case`move-3d`:return[n.events.on(`record-undo`,({updates:t})=>{e.addToHistory({updates:t})}),n.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`})}),n.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`})}),n.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`})}),n.events.on(`immediate-click`,n=>{this._updatingHandles.consumePromise(n.shiftKey?this._toggleSelection([n.object.graphic],e,t):e.toggleTool())})];case`transform-3d`:return[n.events.on(`record-undo`,({updates:t})=>{e.addToHistory({updates:t})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.events.on(`immediate-click`,n=>{this._updatingHandles.consumePromise(n.shiftKey?this._toggleSelection([n.object.graphic],e,t):e.toggleTool())})];case`reshape-3d`:return[n.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`})}),n.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`})}),n.events.on(`vertex-add`,e=>{this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:e,type:`update`})}),n.events.on(`vertex-remove`,e=>{this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:e,type:`update`})}),n.events.on(`immediate-click`,n=>{this._updatingHandles.consumePromise(n.shiftKey?this._toggleSelection([n.object.graphic],e,t):e.toggleTool())})]}}_onTransformOrReshape2DGraphicClick(e,t,n){let{graphic:r,viewEvent:i}=n;if(i.native?.shiftKey&&this.hasGraphic(r)){i.stopPropagation(),this._updatingHandles.consumePromise(e.removeFromSelection(r));return}t.toggleToolOnClick&&(i.stopPropagation(),this._updatingHandles.consumePromise(e.toggleTool()))}async _replaceUpdateOperationHandle(e,t,n){let r=this._operationContext;e.onEnd(),e.destroy();let i=await this._updatingHandles.addPromise(n());return!i||$(i)||r!==this._operationContext?(i&&!$(i)&&(i.onEnd(),i.destroy()),this._destroyOperationContext(r),!1):(this._setUpdateOperationHandle(i,t),!0)}_setUpdateOperationHandle(e,t){this._operationHandle=e;let n=this.view?.map;this._disablePopup(t),e.on(`complete`,()=>{if(e===this._operationHandle){let r=this.updateGraphics.toArray(),i=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._destroyOperationContext(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),n&&n.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit(`update`,{graphics:r,state:`complete`,aborted:e.cancelled,tool:i,toolEventInfo:null,type:`update`})}})}_getCommonUpdateOperationClickHandlers(e,t,n){return this._updatingHandles.addPromise(this._handleCommonUpdateOperationClick(e,t,n))}async _handleCommonUpdateOperationClick(e,t,n){let r=L(t),i=await t.defer(()=>this._getFirstHit(r));if(i==null){this.cancelUpdateOnClickAway&&e.complete();return}let a=t.native.shiftKey?this._toggleSelection([i.graphic],e,n):null;if(a){t.stopPropagation(),await a;return}this.updateGraphics.includes(i.graphic)?this._shouldTemporarilyDisablePopup(n)&&t.stopPropagation():e.complete()}async _toggleSelection(e,t,n){let r=!!n.multipleSelectionEnabled;for(let n of e)if(n!=null&&r&&this.hasGraphic(n))return this.updateGraphics.includes(n)?await t.removeFromSelection(n):await t.addToSelection(n)}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;let n=t.key;n===A.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):n===A.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):n===A.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&A.delete.includes(n)&&this._onDeleteKey(t)}_onDeleteKey(e){this._operationHandle&&this._operationHandle.type===`update`&&this.activeComponent!=null&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&=(this.view?.map?.remove(this._internalGraphicsLayer),d(this._internalGraphicsLayer))}_isComponentGraphic(e){let{activeComponent:t}=this;return!e||t==null?!1:e.attributes?.esriSketchTool||t.type===`draw-2d`&&t.graphic===e||(t.type===`box`||t.type===`reshape`)&&t.isUIGraphic(e)}_clearCursor(){this.removeHandles(U)}_displayCursor(e){this.removeHandles(U),this.view?.container&&e!=null&&this.addHandles(this.view.acquireCursor(e,`high`),U)}_logError(e,t,n){u.getLogger(this).error(new i(e,t,n))}async _requireModule(e){let t=new AbortController;this._moduleLoaderAbortController=t;let n=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:`aborted`}:{module:n}}_emitUndoEvent(e){this.emit(`undo`,{...e,type:`undo`})}_emitRedoEvent(e){this.emit(`redo`,{...e,type:`redo`})}_emitDeleteEvent(e){this.emit(`delete`,{...e,type:`delete`})}_onLayerGraphicsChangeCallback(e){if(this._operationHandle!=null){let{updateGraphics:t}=this;for(let n of e.removed)if(t.includes(n)){if(t.length>1)this._updatingHandles.consumePromise(this._operationHandle.removeFromSelection(n));else{this._operationHandle.cancel();break}}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,n,r){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;let i=this.view,a=await import(`../../views/draw/DrawTool.js`);await this.pluginManager.loadPlugins();let o=await this.pluginManager.makeRenderer({customSymbol:n.graphicSymbol,useTextSymbol:r===`text`}),s=new a.DrawTool({view:i,elevationInfo:this._layerAdapter?.elevationInfo??pe(i.type===`3d`),hasZ:!!n.hasZ,toolOptions:this._operationToolOptions,renderer:o,defaultZ:n.defaultZ??0,directionOptions:n.directionOptions,snappingManager:this._operationSnappingManager,enableVertexVisuals:r!==`rectangle`&&r!==`circle`,readPluginSetting:(e,t)=>this.settingsManager.getValue(t)});s.addHandles(l(o));let c=new t({...n.graphicProperties,attributes:{...n.graphicProperties?.attributes},symbol:n.graphicSymbol??this._getGraphicSymbolFromTool(r)});return n.graphicSymbol||s.addHandles(_(()=>this._getGraphicSymbolFromTool(r),e=>c.symbol=e)),this._set(`createGraphic`,c),i.addAndActivateTool(s),s.begin(e),s}get test(){}wait(){return y(()=>!this.updating)}_shouldTemporarilyDisablePopup(e){return this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._shouldTemporarilyDisablePopup(e)&&this.view&&this._originalPopupEnabled==null&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._shouldTemporarilyDisablePopup(e)&&this.view&&this._originalPopupEnabled!=null&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){let e=this.view;if(!e){this._logMissingView();return}f(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await g(y(()=>e?.ready),this._viewReadyAbortController.signal)}_logMissingView(){this._logError(`sketch:missing-property`,K(`view`))}_logMissingLayer(){this._logError(Re,K(`layer`))}};e([b()],G.prototype,`_defaultSnappingManager`,void 0),e([b()],G.prototype,`_operationContext`,void 0),e([b()],G.prototype,`_layerAdapter`,null),e([b()],G.prototype,`_pluginManager`,void 0),e([b({readOnly:!0})],G.prototype,`settingsManager`,void 0),e([b()],G.prototype,`_operationHandle`,void 0),e([b({readOnly:!0})],G.prototype,`_updatingHandles`,void 0),e([b({readOnly:!0})],G.prototype,`_toolTransitionHandles`,void 0),e([b()],G.prototype,`_drawToolSimplifyAbortController`,void 0),e([b({readOnly:!0})],G.prototype,`activeTool`,null),e([b()],G.prototype,`geometrySimplificationInProgress`,null),e([b({readOnly:!0})],G.prototype,`activeCreateToolDrawMode`,null),e([b()],G.prototype,`activeTooltip`,null),e([b({types:E})],G.prototype,`activeFillSymbol`,void 0),e([b()],G.prototype,`activeLineSymbol`,void 0),e([b()],G.prototype,`activeVertexSymbol`,void 0),e([b()],G.prototype,`allowDeleteKey`,void 0),e([b({readOnly:!0})],G.prototype,`createGraphic`,null),e([b()],G.prototype,`defaultCreateOptions`,null),e([b()],G.prototype,`defaultUpdateOptions`,null),e([b()],G.prototype,`activeUpdateOptions`,void 0),e([b({type:M,nonNullable:!0})],G.prototype,`labelOptions`,null),e([b()],G.prototype,`layer`,void 0),e([b({types:E})],G.prototype,`pointSymbol`,void 0),e([b({types:E})],G.prototype,`polygonSymbol`,void 0),e([b({types:E})],G.prototype,`polylineSymbol`,void 0),e([b()],G.prototype,`meshSymbol`,void 0),e([b({type:T})],G.prototype,`textSymbol`,null),e([b({type:F,nonNullable:!0})],G.prototype,`snappingOptions`,null),e([b()],G.prototype,`snappingManager`,null),e([b({readOnly:!0})],G.prototype,`state`,null),e([b()],G.prototype,`toolTransitionInProgress`,null),e([b({type:Se,nonNullable:!0})],G.prototype,`tooltipOptions`,null),e([b({readOnly:!0})],G.prototype,`updateGraphics`,void 0),e([b()],G.prototype,`updateOnGraphicClick`,void 0),e([b()],G.prototype,`useViewOptions`,void 0),e([b()],G.prototype,`cancelUpdateOnClickAway`,void 0),e([b()],G.prototype,`updating`,null),e([b()],G.prototype,`creationMode`,void 0),e([b({type:Ce,nonNullable:!0})],G.prototype,`valueOptions`,null),e([b({types:E})],G.prototype,`vertexSymbol`,void 0),e([b({value:null})],G.prototype,`view`,null),e([b({constructOnly:!0,type:N})],G.prototype,`sketchOptions`,void 0),e([b()],G.prototype,`useLegacyCreateTools`,void 0),e([b()],G.prototype,`isUsingLegacyCreateTools`,null),e([b()],G.prototype,`pluginManager`,null),e([b()],G.prototype,`drawTool`,null),e([b()],G.prototype,`activePluginConfigurations`,null),e([b()],G.prototype,`rootPlugins`,null),e([b()],G.prototype,`effectiveAvailablePlugins`,null),e([b()],G.prototype,`firstPluginWithSwappableLeaf`,null),e([b()],G.prototype,`multiplePluginsActive`,null),G=e([re(`esri.widgets.Sketch.SketchViewModel`)],G);const Re=`sketch:missing-property`,K=e=>`Property '${e}' is missing on SketchViewModel.`;function ze(e){return e===`polygon`||e===`rectangle`||e===`circle`}function q(e,t){Y(`undo`,e.history.undo,e.history.redo,t)}function J(e,t){Y(`redo`,e.history.redo,e.history.undo,t)}function Y(e,t,n,r){let i=t.pop();if(!i)return;let a=i.updates,o=[];r.forEach((t,n)=>{let r=a[n];r!=null&&(`geometry`in r&&r.geometry!=null&&(o.push({geometry:t.geometry}),t.geometry=r.geometry),`symbol`in r&&r.symbol!=null&&(o.push({symbol:t.symbol}),t.symbol=r.symbol),`undo`in r&&(o.push(r),r[e](t)))}),n.push({updates:o})}function X(e,t){e!=null&&t.hasGrabbedManipulators&&(e.activeTool=null)}function Z(e){return{updates:e.map(({geometry:e})=>e?.type===`mesh`?{geometry:e.cloneShallow()}:{geometry:e})}}function Q(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function $(e){return`requireError`in e&&e.requireError===`aborted`}export{G as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as n}from"../../core/arrayUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import{handlesGroup as o,makeHandle as s,drainHandles as c,destroyHandle as l}from"../../core/handleUtils.js";import has from"../../core/has.js";import u from"../../core/Logger.js";import{destroyMaybe as d,abortMaybe as f,removeMaybe as p}from"../../core/maybe.js";import{createAbortError as m,ignoreAbortErrors as h,whenOrAbort as g}from"../../core/promiseUtils.js";import{watch as _,syncAndInitial as v,on as ee,when as te,sync as ne,whenOnce as y}from"../../core/reactiveUtils.js";import{property as b,subclass as re}from"../../core/accessorSupport/decorators.js";import{trackAccess as x}from"../../core/accessorSupport/tracking.js";import{SimpleObservable as ie}from"../../core/accessorSupport/tracking/SimpleObservable.js";import{UpdatingHandles as S}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as ae}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as oe,isLoaded as se,load as ce,project as le}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as C}from"../../geometry/support/coordsUtils.js";import{equals as ue}from"../../geometry/support/spatialReferenceUtils.js";import de from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as fe}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as pe}from"../../support/elevationInfoUtils.js";import me from"../../symbols/FillSymbol3DLayer.js";import he from"../../symbols/MeshSymbol3D.js";import ge from"../../symbols/SimpleFillSymbol.js";import _e from"../../symbols/SimpleLineSymbol.js";import w from"../../symbols/SimpleMarkerSymbol.js";import T from"../../symbols/TextSymbol.js";import{symbolTypes as E}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as D}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as ve}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as ye}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as be}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as O}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as k}from"../../views/input/InputManager.js";import{sketchKeys as A}from"../../views/interactive/keybindings.js";import{bindViewToolOptions as xe}from"../../views/interactive/options/bindViewToolOptions.js";import j from"../../views/interactive/options/InteractiveToolOptions.js";import M from"../../views/interactive/sketch/SketchLabelOptions.js";import N from"../../views/interactive/sketch/SketchOptions.js";import Se from"../../views/interactive/sketch/SketchTooltipOptions.js";import Ce from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as P}from"../../views/interactive/snapping/SnappingManager.js";import{acquireForViewOptions as we}from"../../views/interactive/snapping/SnappingManagerPool.js";import F from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as I}from"../../views/interactive/snapping/snappingUtils.js";import{GeometryWorkerHandle as Te}from"../../views/support/GeometryWorkerHandle.js";import{defaultHighlightName as Ee}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as De}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as L}from"../../views/support/screenUtils.js";import Oe from"./adapters/layer/GraphicsLayerAdapter.js";import ke from"./adapters/layer/MapNotesLayerAdapter.js";import Ae from"./adapters/layer/SketchLayerAdapter.js";import{CreateOperationHandle as je,DrawToolOperationHandle as Me,UpdateOperationHandle as R}from"./support/OperationHandle.js";import{PluginManager as Ne}from"./support/PluginManager.js";import{SettingsManager as Pe}from"./support/SettingsManager.js";import{getLegacyTool as z,isCompletelyDegenerate as Fe,graphicsHaveTooFewVerticesForBox as B,getModeFromCreateOptions as Ie,getDrawToolGeometryTypeFromCreateTool as Le}from"./support/sketchUtils.js";const V={defaultZ:0},H={reshapeOptions:{edgeOperation:`split`,shapeOperation:`move`,vertexOperation:`move`,enableCreateCurveFromStraightEdge:!0},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0,name:Ee},tool:`transform`},U=Symbol(),W=Symbol();let G=class extends a{constructor(e){super(e),this._defaultSnappingManager=null,this._operationContext=null,this._internalGraphicsLayer=new de({listMode:`hide`,internal:!0,title:`SVM Internal`}),this._pluginManager=new Ne({sketchViewModel:this}),this.settingsManager=new Pe({availablePlugins:()=>this.pluginManager.visiblePluginsFlat}),this._operationHandle=null,this._updatingHandles=new S,this._toolTransitionHandles=new S,this._drawToolSimplifyAbortController=null,this._geometryWorkerHandle=new Te,this._viewHandlesKey=`viewHandles`,this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.activeUpdateOptions=null,this.layer=null,this.pointSymbol=new w({style:`circle`,size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new ge({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new _e({color:[130,130,130,1],width:2}),this.meshSymbol=new he({symbolLayers:new r([new me])}),this.updateGraphics=new r,this.updateOnGraphicClick=!0,this.useViewOptions=!1,this.cancelUpdateOnClickAway=!0,this.creationMode=`single`,this.vertexSymbol=new w({style:`circle`,size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new N,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{let{_layerAdapter:e}=this;if(this.removeHandles(W),!e)return;let t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),_(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},v)].filter(n);this.addHandles(t,W)},this._originalPopupEnabled=null,this.defaultCreateOptions=V,this.defaultUpdateOptions=H,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new F,this.textSymbol=new T({text:`text`})}initialize(){this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([ee(()=>this.view?.map?.layers,`change`,e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),_(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),v),_(()=>this.view,e=>{this._defaultSnappingManager=d(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new P({view:e,options:this.snappingOptions})),e.type===`2d`?(import(`../../views/2d/interactive/editingTools.js`),this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe())):e.type===`3d`&&(import(`../../views/3d/interactive/editingTools.js`),import(`../../views/3d/layers/GraphicsLayerView3D.js`)))},v),_(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),I(this,void 0,()=>this._operationSnappingManager?.options??this.snappingOptions)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=d(this._defaultSnappingManager),this._destroyOperationContext(),this._set(`snappingManager`,null),this._set(`view`,null),this._updatingHandles.destroy(),this._toolTransitionHandles.destroy(),this._drawToolSimplifyAbortController=f(this._drawToolSimplifyAbortController),this._geometryWorkerHandle.destroy(),this._pluginManager?.destroy(),this.emit(`destroy`)}get _operationSnappingManager(){return this._operationContext?.snappingManager??this.snappingManager}get _operationToolOptions(){return this._operationContext?.toolOptions??this.sketchOptions}get _layerAdapter(){let{layer:e}=this;switch(e?.type){case`graphics`:return new Oe(e);case`map-notes`:return new ke(e);case`sketch`:return new Ae(e);case void 0:default:return null}}get activeTool(){return this._operationHandle?.tool??null}get geometrySimplificationInProgress(){return!!this._drawToolSimplifyAbortController}get activeCreateToolDrawMode(){let e=this._operationHandle;if(e?.type===`create`&&e.activeComponent&&`mode`in e.activeComponent)return e.activeComponent.mode;if(e?.activeComponent?.type===`draw-2.0`){let t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(n).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){let{activeComponent:e,destroyed:t}=this,n=!t&&e&&`tooltip`in e?e.tooltip:null;return n?.visible?n:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return this.activeComponent!=null&&(this.activeComponent.type===`draw-3d`||this.activeComponent.type===`draw-2d`)?this.activeComponent.graphic:this._get(`createGraphic`)}get defaultCreateOptions(){return this._get(`defaultCreateOptions`)}set defaultCreateOptions(e){this._set(`defaultCreateOptions`,{...V,...e})}get defaultUpdateOptions(){return this._get(`defaultUpdateOptions`)}set defaultUpdateOptions(e){this._set(`defaultUpdateOptions`,{...H,...e,reshapeOptions:{...H.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...H.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get textSymbol(){return this._get(`textSymbol`)}set textSymbol(e){this._set(`textSymbol`,e)}get snappingOptions(){return this.snappingManager?.options??this._get(`snappingOptions`)}set snappingOptions(e){this._defaultSnappingManager!=null&&(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=d(this._defaultSnappingManager)),this._override(`snappingManager`,e);else{let{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new P({options:this.snappingOptions,view:e})),this._clearOverride(`snappingManager`)}}get state(){let e=!!(this.view?.ready&&this.layer),t=this._operationHandle;return e&&t?`active`:e?`ready`:`disabled`}get toolTransitionInProgress(){return this._toolTransitionHandles.updating||!!this.drawTool?.lifecycleManager.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return this.toolTransitionInProgress||this.activeComponent&&`updating`in this.activeComponent&&this.activeComponent.updating||!!(this._updatingHandles.updating||this._drawToolSimplifyAbortController||this._operationSnappingManager?.updating||this.drawTool?.updating)}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get(`view`)}set view(e){let t=this._get(`view`);if(t===e)return;if(t){let{container:e,map:n}=t;e&&this._clearCursor(),n?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}let n=`view-ready`;this.removeHandles(n),e&&this.addHandles(te(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},v),n),this._set(`view`,e),this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||this.view?.type!==`2d`}get pluginManager(){return this._pluginManager}get drawTool(){return this.activeComponent?.type===`draw-2.0`?this.activeComponent:null}get activePluginConfigurations(){return this.drawTool?.pluginStack.toArray().map(e=>e.configuration).filter(n)??[]}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome(`rootPlugins`,e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;let e=this.view?.type??`2d`,{firstPluginWithSwappableLeaf:t}=this;return t?t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e)):this.rootPlugins?.filter(t=>!t.excludedViews?.includes(e)).filter(n)??[]}get firstPluginWithSwappableLeaf(){let e=this.view?.type??`2d`;return this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>t!=null&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1)}get multiplePluginsActive(){return this.drawTool?this.drawTool.pluginStack.length>1:!1}replaceLeaf(e){this.drawTool?.replaceLeaf(e)}addGraphic(e){this._layerAdapter?.add(e)}addGraphics(e){this._layerAdapter?.addMany(e)}hasGraphic(e){return!!this._layerAdapter?.has(e)}removeGraphic(e){this._layerAdapter?.remove(e)}removeGraphics(e){this._layerAdapter?.removeMany(e)}removeAllGraphics(){this._layerAdapter?.removeAll()}cancel(){this._moduleLoaderAbortController=f(this._moduleLoaderAbortController),this._viewReadyAbortController=f(this._viewReadyAbortController),this._drawToolSimplifyAbortController=f(this._drawToolSimplifyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){let{state:e,updateGraphics:t}=this;if(e===`active`&&t.length){let{activeTool:e}=this,n=t.toArray();this.removeGraphics(n),this.cancel(),this._emitDeleteEvent({graphics:n,tool:e})}}duplicate(){if(this.state===`active`&&this.updateGraphics.length){let e=this.updateGraphics.map(e=>e.clone()).toArray();return this.addGraphics(e),this.emit(`duplicate`,{graphics:e,type:`duplicate`}),e}return[]}async create(e,t){return this._toolTransitionHandles.addPromise(this._create(e,t))}async _create(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());let{view:n,layer:r}=this;if(!n||this.state===`disabled`)throw r||this._logMissingLayer(),m();if(n.activeTool!=null&&(n.activeTool=null),!e){this._logError(`sketch:missing-parameter`,`Missing parameter 'tool'.`);return}O(n,this._internalGraphicsLayer);let i=this._createOperationContext(n),a;try{a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t))}catch(e){throw this._destroyOperationContext(i),e}if(a==null||this.destroyed||i!==this._operationContext){let e=i===this._operationContext;a?.onEnd(),d(a),this._destroyOperationContext(i),e&&n.map?.remove(this._internalGraphicsLayer);return}let o=z(e);a.on(`complete`,()=>{if(a===this._operationHandle){let n=this.createGraphic,r=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._destroyOperationContext(),this._set(`createGraphic`,null),this.view?.map?.remove(this._internalGraphicsLayer),!a.cancelled&&n!=null&&this.addGraphic(n),this._sketchContinuationFlag=!1,this.emit(`create`,{graphic:n,state:r?`cancel`:`complete`,tool:o??`point`,toolEventInfo:null,type:`create`}),r||this._sketchContinuationFlag)return;let{creationMode:i}=this;if(i===`continuous`){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(h(this.create(e,t)))}else i===`update`&&n&&this._updatingHandles.consumePromise(h(this.update([n])))}}),this._operationHandle=a,n.ready&&n.focus()}async place(e,t){return await e.load(),this.create(`mesh`,{mode:`click`,hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){return this._toolTransitionHandles.addPromise(this._update(e,t))}async _update(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());let{layer:n,view:r,state:i}=this;if(!r||i===`disabled`)throw n||this._logMissingLayer(),m();r.activeTool!=null&&(r.activeTool=null);let a=Array.isArray(e)?e:[e];if(e==null||!a?.length){this._logError(`sketch:missing-parameter`,`Missing parameter 'graphics'.`);return}if(a.some(e=>this.hasGraphic(e)?e.geometry==null&&(this._logError(`sketch:invalid-parameter`,`Parameter 'graphics' contains one or more graphics with an unsupported geometry.`),!0):(this._logError(`sketch:invalid-parameter`,`Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer.`),!0)))return;let o=this._createOperationContext(r),s;try{s=await this._updatingHandles.addPromise(this._setupUpdateOperation(a,t))}catch(e){throw this._destroyOperationContext(o),e}if(this.destroyed||s==null||$(s)||o!==this._operationContext){s&&!$(s)&&(s.onEnd(),s.destroy()),this._destroyOperationContext(o);return}O(r,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit(`update`,{graphics:a,state:`start`,aborted:!1,tool:s.tool,toolEventInfo:null,type:`update`})}async _updateSpatialReference(e){let t=this.view;if(!t){this._logMissingView();return}e=Array.isArray(e)?e:[e];for(let n of e)n.geometry!=null&&n.geometry.type!==`mesh`&&!ue(n.geometry.spatialReference,t.spatialReference)&&(!oe(n.geometry.spatialReference,t.spatialReference)&&!se()&&await ce(),n.geometry=le(n.geometry,t.spatialReference))}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._updatingHandles.consumePromise(this._operationHandle?.toggleTool())}_createOperationContext(e){this._destroyOperationContext();let t=this.useViewOptions?e.options:null,n=t?we(e):null,r=t?new j:this.sketchOptions,i;if(t){let{values:t}=r;i=o([xe(r,()=>e.options,()=>this.sketchOptions),_(()=>t.directionMode,e=>{this.sketchOptions.values.directionMode=e},ne)])}return this._operationContext={snappingManager:n?.snappingManager??this.snappingManager,toolOptions:r,...o([n,i])}}_destroyOperationContext(e=this._operationContext){if(e!==this._operationContext){p(e);return}this._operationContext=p(this._operationContext)}async _getFirstHit(e){let t=this.view;if(!t)return this._logMissingView(),null;if(t.type===`2d`){let n=[];t.map.allLayers.forEach(e=>{(e.type===`vector-tile`||e.type===`imagery`)&&n.push(e)});let r=await t.hitTest(e,{exclude:n});return De(r.results)}let n=[t.map.ground];t.map.allLayers.forEach(e=>{fe(e)&&(!has(`enable-feature:im-as-ground`)||e.isUsedAsGroundLayer)&&n.push(e)});let r=await t.hitTest(e,{exclude:n});if(r.results.length>0){let e=r.results[0];if(e!=null&&e.type===`graphic`&&e.graphic&&(!r.ground.mapPoint||t.map.ground.opacity<1||r.ground.distance-(e.distance??0)>-Math.min(3*r.ground.distance,t.viewingMode===`global`?ae(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:1/0)))return e}return null}_generateViewHandles(e){return[e.on(`immediate-click`,async e=>{let t=this.state===`active`&&this._operationHandle?.type===`create`;this.state!==`disabled`&&!t&&this.updateOnGraphicClick&&await this._toolTransitionHandles.addPromise(this._handleImmediateClick(e))},k.WIDGET)]}async _handleImmediateClick(e){let t=await e.defer(()=>this._getFirstHit(L(e))),n=null;if(t!=null){let r=t.graphic;this.updateGraphics.includes(r)||this.hasGraphic(r)?(e.stopPropagation(),n=r):this.view?.type===`2d`&&!this._isComponentGraphic(r)&&this.state===`active`&&this.cancel()}else this.state===`active`&&this.cancelUpdateOnClickAway&&this.cancel();n!=null&&!this.updateGraphics.includes(n)&&await this.update([n],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){let n=this.view;if(!n)return this._logMissingView(),null;let r={hasZ:n.type===`3d`,...this.defaultCreateOptions,...t},i=typeof e==`string`?this.pluginManager?.getPluginsEquivalentToCreateTool(e,r):e,a=z(e);if(i&&!this.isUsingLegacyCreateTools){let e=await this._setupDrawTool(i,r,a??`polyline`);if(e)return this._setupDrawToolOperationHandle(e,a??`point`)}if(!a)return null;let o=await this._setupDrawGraphicTool(a,n,r);return o==null?null:(n.tools.add(o),n.activeTool=o,this._setupCreateOperationHandle(o,a))}async _setupDrawGraphicTool(e,t,n){if(e===`multipoint`&&t.type===`3d`)return this._logError(`sketch:create`,`Multipoint geometries are not supported in SceneView.`),null;if(!t)return this._logMissingView(),null;let{cursor:r,defaultZ:i,hasZ:a,geometryToPlace:o,graphicProperties:s,mode:c,preserveAspectRatio:l}=n,u=Ie(c,e),d=Le(e),f=n?.optionsPerTool?.has(e)?n.optionsPerTool.get(e):{},p=f?.preserveAspectRatio??l??e!==`rectangle`,m={centered:e!==`rectangle`&&!(e===`circle`&&!p),cursor:r,defaultZ:i,forceUniformSize:p,graphicProperties:{...s,attributes:{...s?.attributes}},geometryToPlace:o,geometryType:d,mode:u,graphicSymbol:n.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:a,snappingManager:this._operationSnappingManager,snapToScene:!1,view:t,...f};return t.type===`2d`?this._makeDrawGraphicTool2D(m):this._makeDrawGraphicTool3D(m)}async _makeDrawGraphicTool2D(e){let t=await this._requireModule(import(`../../views/2d/interactive/editingTools.js`));return $(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:ze(e.geometryType)?this.activeFillSymbol:null,toolOptions:this._operationToolOptions})}async _makeDrawGraphicTool3D(e){let t=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));return $(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,toolOptions:this._operationToolOptions})}_setupCreateOperationHandle(e,t){let n=this.view;if(!n)return this._logMissingView(),null;let r=null,i=e.forceUniformSize,a=e.centered,o=new ie,l=[s(()=>o.destroy()),n.on(`key-down`,t=>{if(t.key===A.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===A.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key===A.vertexAdd&&!t.repeat){let n=e.drawOperation.geometryType;(n===`polyline`||n===`polygon`||n===`multipoint`)&&(t.stopPropagation(),e.drawOperation.commitStagedVertex())}else t.key===A.undo?(t.stopPropagation(),u.undo()):t.key===A.redo?(t.stopPropagation(),u.redo()):t.key===A.constraint&&(e.geometryType===`rectangle`||e.geometryType===`circle`)&&!t.repeat?(e.forceUniformSize=!i,t.stopPropagation()):t.key===A.center&&(t.repeat||(e.centered=!a,t.stopPropagation()))},k.WIDGET),n.on(`key-up`,t=>{t.key===A.pan?e.enabled=!0:t.key===A.constraint&&(e.geometryType===`rectangle`||e.geometryType===`circle`)?(e.forceUniformSize=i,t.stopPropagation()):t.key===A.center&&(e.centered=a,t.stopPropagation())},k.WIDGET),e.on(`vertex-update`,()=>{o.notify()}),e.on(`vertex-add`,t=>{switch(o.notify(),r=r==null?`start`:`active`,t.operation){case`apply`:this.emit(`create`,{graphic:e.graphic,state:r,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(o.notify(),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),r=`complete`,e.aborted?u&&u.cancel():u&&u.complete()}),_(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],u=new je({activeComponent:e,type:`create`,onEnd:()=>{c(l),n.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>(x(o),e.canUndo),canRedo:()=>(x(o),e.canRedo)});return u}_setupDrawToolOperationHandle(e,t){let r=this.view;if(!r)return this._logMissingView(),null;let i=null,a=[r.on(`key-down`,t=>{t.key===A.pan&&(t.stopPropagation(),t.repeat||(e.editable=!1))},k.WIDGET),r.on(`key-up`,t=>{t.key===A.pan&&(e.editable=!0)},k.WIDGET),e.on(`before-vertex-add`,t=>{let n=e.mostUpstreamPlugin?.configuration;if(n&&`legacyCreateTool`in n&&(n?.legacyCreateTool===`point`||n.legacyCreateTool===`text`)){let e=t.detail.originalEvent;e&&`key`in e&&e.key===A.vertexAdd&&t.preventDefault();return}}),e.on(`before-complete`,t=>{let n=e.getGeometryIfCompleted();if(!n||Fe(n)){t.preventDefault();return}}),e.on([`vertex-add`,`vertex-remove`],r=>{switch(this.createGraphic&&(this.createGraphic.geometry=e.getGeometryIfCompleted()),i=i==null&&r.type!==`vertex-remove`?`start`:`active`,r.operation){case`apply`:this.emit(`create`,{graphic:this.createGraphic,state:i,tool:this.activeTool,toolEventInfo:r,type:`create`});break;case`undo`:this._emitUndoEvent({graphics:[this.createGraphic].filter(n),tool:t});break;case`redo`:this._emitRedoEvent({graphics:[this.createGraphic].filter(n),tool:t})}}),e.on(`cursor-update`,t=>{this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),(t.vertices[0]?.vertexIndex>0||t.vertices[0]?.componentIndex>0)&&this.emit(`create`,{graphic:this.createGraphic,state:`active`,tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:`cursor-update`},type:`create`})}),e.on(`complete`,async({geometry:t,isSimple:n})=>{let r=this.createGraphic,i=!!t&&t.type!==`mesh`&&t.type!==`extent`&&!n;if(r&&(r.geometry=n?t:e.unprocessedGeometry??t),!i||!r)o.complete();else{this._internalGraphicsLayer.add(this.createGraphic);let e=new AbortController;this._drawToolSimplifyAbortController?.abort(),this._drawToolSimplifyAbortController=e,await this._updatingHandles.addPromise(h(this._finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:r,handle:o})))}})],o=new Me({activeComponent:e,type:`create`,onEnd:()=>{c(a),r.tools.remove(e)},undo:()=>e.undo(),redo:()=>e.redo(),canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return a.push(e.on(`cancel`,()=>{this._drawToolSimplifyAbortController=f(this._drawToolSimplifyAbortController),o.cancel()})),o}async _finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:n,handle:r}){let i=this.view?.acquireCursor(`progress`,`high`);i&&this.addHandles(i);let a=()=>e.signal.aborted?(n&&(this._layerAdapter?.remove(n),this._internalGraphicsLayer?.remove(n)),this._set(`createGraphic`,null),!0):!1;try{let i=await this._geometryWorkerHandle.simplify(t,e.signal);if(a())return;n.geometry=i??t,this._internalGraphicsLayer?.remove(n),r.complete()}finally{i?.remove(),this._drawToolSimplifyAbortController===e&&(this._drawToolSimplifyAbortController=null)}}_getGraphicSymbolFromTool(e){switch(e){case`point`:case`multipoint`:return this.pointSymbol;case`polyline`:case`freehandPolyline`:return this.polylineSymbol;case`circle`:case`rectangle`:case`polygon`:case`freehandPolygon`:return this.polygonSymbol;case`mesh`:return this.meshSymbol;case`text`:return this.textSymbol}}async _setupUpdateOperation(e,t){let{view:n}=this;if(!n)return this._logMissingView(),null;let r={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};this.activeUpdateOptions=r;let i=r.tool??H.tool;if(this.removeGraphics(e),this.addGraphics(e),n.type===`3d`){if(e.length===0)return null;switch(i){case`move`:return this._setupMove3DOperation(e,r,n,i);case`reshape`:return e.length>1?(this._logError(`sketch:reshape-multiple`,`Reshape operation does not support multiple graphics.`),null):this._setupReshape3DOperation(e[0],r,n);case`transform`:return this._setupGraphicTransform3DOperation(e,r,n)}}switch(i){case`move`:return this._setupMove2DOperation(e,r,n);case`reshape`:return e.length>1?(this._logError(`sketch:reshape-multiple`,`Reshape operation does not support multiple graphics.`),null):this._setupTransformOrReshape2DOperation(e,i,r,n);case`transform`:return B(e)&&(i=`reshape`),this._setupTransformOrReshape2DOperation(e,i,r,n)}}async _setupMove3DOperation(e,t,n,r,i=!1){let a=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));if($(a))return a;let{ManipulatedObject3DGraphic:o,MoveTool3D:s}=a.module,l=new Map,u=()=>{l.forEach(e=>e.destroy()),l.clear()};for(let t of e){let e=new o({view:n,graphic:t}),r=ve(e);if(r!==0)return u(),this._logError(`sketch:move`,`Move operation not supported for provided graphic(s) (${D(r)}).`),null;l.set(t,e)}let d=new s({view:n,enableZ:t.enableZ,snappingManager:this._operationSnappingManager,toolOptions:this._operationToolOptions});n.tools.add(d),d.objects.addMany(Array.from(l.values())),i||this.updateGraphics.addMany(e);let f=[],p=new R({activeComponent:d,tool:r,type:`update`,onEnd:()=>{c(f),Q(n,d),u()},undo:()=>{X(this.view,d),q(p,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r})},redo:()=>{J(p,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r})},addToSelection:async e=>{this.updateGraphics.push(e);let t=new o({view:n,graphic:e});l.set(e,t),d.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:async e=>{let t=this.updateGraphics.indexOf(e);if(p.history.undo.forEach(e=>e.updates.splice(t,1)),p.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`}),this.updateGraphics.length===0){p.complete();return}let n=l.get(e);n&&(d.objects.remove(n),n.destroy(),l.delete(e))},toggleTool:async()=>{if(this.updateGraphics.length!==1||t.toggleToolOnClick===!1||r!==`transform`)return;let e=this.updateGraphics.at(0),i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,n,!0));i&&!$(i)&&(p.onEnd(),p.destroy(),this._setUpdateOperationHandle(i,t))}});return f.push(...this._getHandlesForComponent(p,t),n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(p,e,t),k.WIDGET),n.on(`key-down`,e=>{this._getCommonUpdateOperationKeyDownHandlers(p,e)},k.WIDGET)),p}_setupGraphicTransform3DOperation(e,t,n,r=!1){if(e.length===1&&be(e[0])===0){let i=e[0],a=i.geometry;if(a!=null&&(a.type===`point`||a.type===`mesh`))return this._setupPointTransform3DOperation(i,t,n);if(a!=null&&(a.type===`polygon`||a.type===`polyline`))return this._setupPolyTransform3DOperation(i,t,n,r)}return this._setupMove3DOperation(e,t,n,`transform`,r)}async _setupPointTransform3DOperation(e,t,n){let r=`transform`,{enableRotation:i,enableScaling:a,enableZ:o}=t,s=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));if($(s))return s;let{TransformTool3D:l,ManipulatedObject3DGraphic:u}=s.module,d=new u({graphic:e,view:n}),f=new l({object:d,view:n,enableRotation:i,enableScaling:a,enableZ:o,snappingManager:this._operationSnappingManager,toolOptions:this._operationToolOptions});n.tools.add(f),this.updateGraphics.add(e);let p=[],m=new R({activeComponent:f,tool:r,type:`update`,onEnd:()=>{c(p),Q(n,f),d.destroy()},undo:()=>{X(this.view,f),q(m,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r})},redo:()=>{J(m,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r})},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`}),await this._replaceUpdateOperationHandle(m,t,()=>this._setupMove3DOperation(this.updateGraphics.toArray(),t,n,`transform`,!0))},removeFromSelection:async 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`}),m.complete()},toggleTool:async()=>{}});return p.push(...this._getHandlesForComponent(m,t),n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(m,e,t),k.WIDGET),n.on(`key-down`,e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},k.WIDGET)),m}async _setupPolyTransform3DOperation(e,t,n,r=!1){let i=`transform`,{enableRotation:a,enableScaling:o,enableZ:s,preserveAspectRatio:l}=t,u=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));if($(u))return u;let{ManipulatedObject3DGraphic:d,ExtentTransformTool:f}=u.module,p=this.view?.inputManager?.isModifierKeyDown(A.constraint),m=new d({view:n,graphic:e}),h=new f({object:m,view:n,enableRotation:a,enableScaling:o,enableZ:s,preserveAspectRatio:!!l!=!!p,toolOptions:this._operationToolOptions});n.tools.add(h),r||this.updateGraphics.add(e);let g=[],_=new R({activeComponent:h,tool:i,type:`update`,onEnd:()=>{c(g),Q(n,h),m.destroy()},canUndo:()=>!h.destroyed&&h.canUndo,undo:()=>{h.destroyed||(h.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i}))},canRedo:()=>!h.destroyed&&h.canRedo,redo:()=>{h.destroyed||(h.redo(),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`}),await this._replaceUpdateOperationHandle(_,t,()=>this._setupMove3DOperation(this.updateGraphics.toArray(),t,n,`transform`,!0))},removeFromSelection:async 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`}),_.complete()},toggleTool:async()=>{if(this.updateGraphics.length!==1||t.toggleToolOnClick===!1)return;let r=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,n,!0));r&&!$(r)&&(_.onEnd(),_.destroy(),this._setUpdateOperationHandle(r,t))}});return g.push(...this._getHandlesForComponent(_,t),n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(_,e,t),k.WIDGET),n.on(`key-down`,e=>this._getCommonUpdateOperationKeyDownHandlers(_,e),k.WIDGET),n.on(`key-down`,e=>{e.key===A.constraint&&!e.repeat&&(h.preserveAspectRatio=!h.preserveAspectRatio,e.stopPropagation())},k.WIDGET),n.on(`key-up`,e=>{e.key===A.constraint&&(h.preserveAspectRatio=!h.preserveAspectRatio,e.stopPropagation())},k.WIDGET)),_}async _setupMove2DOperation(e,t,n){let r=`move`;this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));let i=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,n));if($(i))return i;let a=new R({activeComponent:i,tool:r,type:`update`,onEnd:()=>{this._clearCursor(),c(l),c(s),i.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{let e=this.updateGraphics.toArray();q(a,e),a.refreshComponent(),this._emitUndoEvent({graphics:e,tool:r})},redo:()=>{let e=this.updateGraphics.toArray();J(a,e),a.refreshComponent(),this._emitRedoEvent({graphics:e,tool:r})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),i.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:async e=>{let t=this.updateGraphics.indexOf(e);a.history.undo.forEach(e=>e.updates.splice(t,1)),a.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);let n=this.updateGraphics.toArray();if(this.emit(`update`,{graphics:n,state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:`selection-change`},type:`update`}),this.updateGraphics.length===0){a.complete();return}i.graphics=n}}),o=!1,s=[n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(a,e,t),k.WIDGET),n.on(`key-down`,e=>{this._getCommonUpdateOperationKeyDownHandlers(a,e),e.key===A.constraint&&!e.repeat&&(o=!0,i.enableMoveAllGraphics=!i.enableMoveAllGraphics)},k.WIDGET),n.on(`key-up`,e=>{e.key===A.constraint&&o&&(o=!1,i.enableMoveAllGraphics=!i.enableMoveAllGraphics)},k.WIDGET)],l=this._getHandlesForComponent(a,t);return a}async _setupReshape3DOperation(e,t,n,r=!1){let i=`reshape`,a=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));if($(a))return a;let{ManipulatedObject3DGraphic:o,ReshapeTool3D:s}=a.module,l=new o({view:n,graphic:e}),u=ye(l);if(u!==0)return l.destroy(),this._logError(`sketch:reshape`,`Reshape operation not supported for provided graphic(s) (${D(u)}).`),null;let d=t.reshapeOptions,f=new s({view:n,object:l,enableZVertex:t.enableZ&&d?.vertexOperation===`move`,enableZShape:t.enableZ&&d?.shapeOperation===`move`,enableMoveObject:d?.shapeOperation===`move`||d?.shapeOperation===`move-xy`,enableMidpoints:d?.edgeOperation===`split`,enableEdgeOffset:d?.edgeOperation===`offset`,snappingManager:this._operationSnappingManager,toolOptions:this._operationToolOptions});n.tools.add(f),r||this.updateGraphics.add(l.graphic);let p=[],m=new R({activeComponent:f,tool:i,type:`update`,onEnd:()=>{c(p),Q(n,f),l.destroy()},canUndo:()=>!f.destroyed&&f.canUndo,undo:()=>{f.destroyed||(f.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i}))},canRedo:()=>!f.destroyed&&f.canRedo,redo:()=>{f.destroyed||(f.redo(),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`}),await this._replaceUpdateOperationHandle(m,t,()=>this._setupMove3DOperation(this.updateGraphics.toArray(),t,n,`transform`,!0))},removeFromSelection:async 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`}),m.complete()},toggleTool:async()=>{t.toggleToolOnClick!==!1&&await this._replaceUpdateOperationHandle(m,t,()=>this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,n,!0))}});return p.push(...this._getHandlesForComponent(m,t),n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(m,e,t),k.WIDGET),n.on(`key-down`,e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},k.WIDGET)),m}async _setupTransformOrReshape2DOperation(e,t,n,r){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));let i=await this._updatingHandles.addPromise(t===`transform`?this._getBox(e,n,r):this._getReshape(e,n,r));if($(i))return i;let a=new R({activeComponent:i,type:`update`,onEnd:()=>{c(s),c(o),a.activeComponent&&!a.activeComponent.destroyed&&a.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{q(a,this.updateGraphics.toArray()),a.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a.tool})},redo:()=>{J(a,this.updateGraphics.toArray()),a.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a.tool})},addToSelection:async e=>{let t=a.activeComponent;if(t?.type===`reshape`){let t=[...this.updateGraphics,e];if(this.updateGraphics.removeAll(),!await this._replaceUpdateOperationHandle(a,n,()=>this._setupTransformOrReshape2DOperation(t,`transform`,n,r)))return}else this.updateGraphics.add(e),t=t,t.graphics=this.updateGraphics.toArray(),t.refresh(),a.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=>{let t=this.updateGraphics.indexOf(e);a.history.undo.forEach(e=>e.updates.splice(t,1)),a.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);let n=this.updateGraphics.toArray();n.length===0?a.complete():B(n)?await a.toggleTool():a.activeComponent.graphics=n,this.emit(`update`,{graphics:n,state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:`selection-change`},type:`update`})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;let e=this.updateGraphics.at(0),t=e.geometry;if(t!=null&&(a.tool===`reshape`&&t.type===`point`||a.tool===`transform`&&t.type===`extent`))return;let i=null,o={...this.defaultUpdateOptions,...n,...this.activeUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...n?.reshapeOptions,...this.activeUpdateOptions?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...n?.highlightOptions,...this.activeUpdateOptions?.highlightOptions}};a.tool===`transform`?i=await this._updatingHandles.addPromise(this._getReshape([e],o,r)):a.tool===`reshape`&&(i=await this._updatingHandles.addPromise(this._getBox([e],o,r))),!$(i)&&(a.activeComponent?.destroy(),a.activeComponent=i,a.activeComponent&&(c(s),s=this._getHandlesForComponent(a,o)))}}),o=[r.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(a,e,n),k.WIDGET),r.on(`key-down`,e=>{if(this._getCommonUpdateOperationKeyDownHandlers(a,e),e.key===A.constraint&&!e.repeat&&a){let e=a.activeComponent;e?.type===`box`&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},k.WIDGET),r.on(`key-up`,e=>{if(e.key===A.constraint&&a){let e=a.activeComponent;e?.type===`box`&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},k.WIDGET)],s=this._getHandlesForComponent(a,n);return a}async _getGraphicMover(e,t,n){let{enableMoveAllGraphics:r,highlightOptions:i}=t,a=await this._requireModule(import(`../../views/draw/support/GraphicMover.js`));return $(a)?a:new a.module.default({enableMoveAllGraphics:r,highlightName:i?.name,highlightsEnabled:!!i?.enabled,indicatorsEnabled:!1,graphics:e,view:n,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:n})=>{this._displayCursor(`grabbing`),this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:`move-start`},type:`update`})},onGraphicMove:({dx:e,dy:t,graphic:n})=>this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:`move`},type:`update`}),onGraphicMoveStop:({dx:e,dy:t,graphic:n})=>{this._displayCursor(`pointer`),this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:`move-stop`},type:`update`})},onGraphicPointerOver:()=>this._displayCursor(`move`),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,n){let{enableRotation:r,enableScaling:i,highlightOptions:a,preserveAspectRatio:o}=t,s=await this._requireModule(import(`../../views/draw/support/Box.js`));if($(s))return s;let c=this.view?.inputManager?.isModifierKeyDown(A.constraint),l=new s.module.default({graphics:e,enableRotation:r,enableScaling:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,preserveAspectRatio:!!o!=!!c,layer:this._internalGraphicsLayer,view:n,toolOptions:this._operationToolOptions,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`})}});return l.addHandles(_(()=>[this.activeUpdateOptions?.enableRotation,this.activeUpdateOptions?.enableScaling],([e,n])=>{l.enableRotation=e??t.enableRotation??!0,l.enableScaling=n??t.enableScaling??!0,l.refresh()},v)),l}async _getReshape(e,t,n){let{highlightOptions:r,reshapeOptions:i}=t,a=i?.edgeOperation===`split`,o=i?.shapeOperation===`move`,s=!!i?.enableCreateCurveFromStraightEdge,c=await this._requireModule(import(`../../views/draw/support/Reshape.js`));return $(c)?c:new c.module.default({enableMidpoints:a,enableMovement:o,enableCurveOnMidpoint:s,graphic:e[0],highlightName:r?.name,highlightsEnabled:!!r?.enabled,layer:this._internalGraphicsLayer,snappingManager:this._operationSnappingManager,toolOptions:this._operationToolOptions,view:n,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:n,type:r})=>this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:r},type:`update`}),onMove:({dx:e,dy:t,mover:n,type:r})=>this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:r},type:`update`}),onMoveStop:({dx:e,dy:t,mover:n,type:r})=>this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:r},type:`update`}),onVertexAdd:({added:e,type:t,vertices:n})=>{let r=e.map(e=>C(e.geometry));this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{added:r,vertices:n,type:t},type:`update`})},onVertexRemove:({removed:e,type:t,vertices:n})=>{let r=e.map(e=>C(e.geometry));this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{removed:r,vertices:n,type:t},type:`update`})}}})}_getHandlesForComponent(e,t){let n=e.activeComponent;if(!n)return[];switch(n.type){case`graphic-mover`:return[n.on(`graphic-click`,({graphic:n,viewEvent:r})=>{r.native?.shiftKey&&t.multipleSelectionEnabled&&(r.stopPropagation(),this._updatingHandles.consumePromise(e.removeFromSelection(n)))}),n.on(`graphic-move-start`,t=>e.addToHistory(Z(t.allGraphics)))];case`box`:return[n.on(`graphic-click`,n=>this._onTransformOrReshape2DGraphicClick(e,t,n)),n.on(`move-start`,t=>e.addToHistory(Z(t.graphics))),n.on(`rotate-start`,t=>e.addToHistory(Z(t.graphics))),n.on(`scale-start`,t=>e.addToHistory(Z(t.graphics)))];case`reshape`:return[n.on(`graphic-click`,n=>this._onTransformOrReshape2DGraphicClick(e,t,n)),n.on(`move-start`,t=>e.addToHistory(Z([t.mover]))),n.on(`reshape-start`,t=>e.addToHistory(Z([t.graphic]))),n.on(`vertex-add`,t=>e.addToHistory(Z([t.oldGraphic]))),n.on(`vertex-remove`,t=>e.addToHistory(Z([t.oldGraphic])))];case`move-3d`:return[n.events.on(`record-undo`,({updates:t})=>{e.addToHistory({updates:t})}),n.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`})}),n.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`})}),n.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`})}),n.events.on(`immediate-click`,n=>{this._updatingHandles.consumePromise(n.shiftKey?this._toggleSelection([n.object.graphic],e,t):e.toggleTool())})];case`transform-3d`:return[n.events.on(`record-undo`,({updates:t})=>{e.addToHistory({updates:t})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.events.on(`immediate-click`,n=>{this._updatingHandles.consumePromise(n.shiftKey?this._toggleSelection([n.object.graphic],e,t):e.toggleTool())})];case`reshape-3d`:return[n.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`})}),n.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`})}),n.events.on(`vertex-add`,e=>{this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:e,type:`update`})}),n.events.on(`vertex-remove`,e=>{this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:e,type:`update`})}),n.events.on(`immediate-click`,n=>{this._updatingHandles.consumePromise(n.shiftKey?this._toggleSelection([n.object.graphic],e,t):e.toggleTool())})]}}_onTransformOrReshape2DGraphicClick(e,t,n){let{graphic:r,viewEvent:i}=n;if(i.native?.shiftKey&&this.hasGraphic(r)){i.stopPropagation(),this._updatingHandles.consumePromise(e.removeFromSelection(r));return}t.toggleToolOnClick&&(i.stopPropagation(),this._updatingHandles.consumePromise(e.toggleTool()))}async _replaceUpdateOperationHandle(e,t,n){let r=this._operationContext;e.onEnd(),e.destroy();let i=await this._updatingHandles.addPromise(n());return!i||$(i)||r!==this._operationContext?(i&&!$(i)&&(i.onEnd(),i.destroy()),this._destroyOperationContext(r),!1):(this._setUpdateOperationHandle(i,t),!0)}_setUpdateOperationHandle(e,t){this._operationHandle=e;let n=this.view?.map;this._disablePopup(t),e.on(`complete`,()=>{if(e===this._operationHandle){let r=this.updateGraphics.toArray(),i=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._destroyOperationContext(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),n&&n.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit(`update`,{graphics:r,state:`complete`,aborted:e.cancelled,tool:i,toolEventInfo:null,type:`update`})}})}_getCommonUpdateOperationClickHandlers(e,t,n){return this._updatingHandles.addPromise(this._handleCommonUpdateOperationClick(e,t,n))}async _handleCommonUpdateOperationClick(e,t,n){let r=L(t),i=await t.defer(()=>this._getFirstHit(r));if(i==null){this.cancelUpdateOnClickAway&&e.complete();return}let a=t.native.shiftKey?this._toggleSelection([i.graphic],e,n):null;if(a){t.stopPropagation(),await a;return}this.updateGraphics.includes(i.graphic)?this._shouldTemporarilyDisablePopup(n)&&t.stopPropagation():e.complete()}async _toggleSelection(e,t,n){let r=!!n.multipleSelectionEnabled;for(let n of e)if(n!=null&&r&&this.hasGraphic(n))return this.updateGraphics.includes(n)?await t.removeFromSelection(n):await t.addToSelection(n)}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;let n=t.key;n===A.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):n===A.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):n===A.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&A.delete.includes(n)&&this._onDeleteKey(t)}_onDeleteKey(e){this._operationHandle&&this._operationHandle.type===`update`&&this.activeComponent!=null&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&=(this.view?.map?.remove(this._internalGraphicsLayer),d(this._internalGraphicsLayer))}_isComponentGraphic(e){let{activeComponent:t}=this;return!e||t==null?!1:e.attributes?.esriSketchTool||t.type===`draw-2d`&&t.graphic===e||(t.type===`box`||t.type===`reshape`)&&t.isUIGraphic(e)}_clearCursor(){this.removeHandles(U)}_displayCursor(e){this.removeHandles(U),this.view?.container&&e!=null&&this.addHandles(this.view.acquireCursor(e,`high`),U)}_logError(e,t,n){u.getLogger(this).error(new i(e,t,n))}async _requireModule(e){let t=new AbortController;this._moduleLoaderAbortController=t;let n=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:`aborted`}:{module:n}}_emitUndoEvent(e){this.emit(`undo`,{...e,type:`undo`})}_emitRedoEvent(e){this.emit(`redo`,{...e,type:`redo`})}_emitDeleteEvent(e){this.emit(`delete`,{...e,type:`delete`})}_onLayerGraphicsChangeCallback(e){if(this._operationHandle!=null){let{updateGraphics:t}=this;for(let n of e.removed)if(t.includes(n)){if(t.length>1)this._updatingHandles.consumePromise(this._operationHandle.removeFromSelection(n));else{this._operationHandle.cancel();break}}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,n,r){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;let i=this.view,a=await import(`../../views/draw/DrawTool.js`);await this.pluginManager.loadPlugins();let o=await this.pluginManager.makeRenderer({customSymbol:n.graphicSymbol,useTextSymbol:r===`text`}),s=new a.DrawTool({view:i,elevationInfo:this._layerAdapter?.elevationInfo??pe(i.type===`3d`),hasZ:!!n.hasZ,toolOptions:this._operationToolOptions,renderer:o,defaultZ:n.defaultZ??0,directionOptions:n.directionOptions,snappingManager:this._operationSnappingManager,enableVertexVisuals:r!==`rectangle`&&r!==`circle`,readPluginSetting:(e,t)=>this.settingsManager.getValue(t)});s.addHandles(l(o));let c=new t({...n.graphicProperties,attributes:{...n.graphicProperties?.attributes},symbol:n.graphicSymbol??this._getGraphicSymbolFromTool(r)});return n.graphicSymbol||s.addHandles(_(()=>this._getGraphicSymbolFromTool(r),e=>c.symbol=e)),this._set(`createGraphic`,c),i.addAndActivateTool(s),s.begin(e),s}get test(){}wait(){return y(()=>!this.updating)}_shouldTemporarilyDisablePopup(e){return this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._shouldTemporarilyDisablePopup(e)&&this.view&&this._originalPopupEnabled==null&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._shouldTemporarilyDisablePopup(e)&&this.view&&this._originalPopupEnabled!=null&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){let e=this.view;if(!e){this._logMissingView();return}f(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await g(y(()=>e?.ready),this._viewReadyAbortController.signal)}_logMissingView(){this._logError(`sketch:missing-property`,K(`view`))}_logMissingLayer(){this._logError(Re,K(`layer`))}};e([b()],G.prototype,`_defaultSnappingManager`,void 0),e([b()],G.prototype,`_operationContext`,void 0),e([b()],G.prototype,`_layerAdapter`,null),e([b()],G.prototype,`_pluginManager`,void 0),e([b({readOnly:!0})],G.prototype,`settingsManager`,void 0),e([b()],G.prototype,`_operationHandle`,void 0),e([b({readOnly:!0})],G.prototype,`_updatingHandles`,void 0),e([b({readOnly:!0})],G.prototype,`_toolTransitionHandles`,void 0),e([b()],G.prototype,`_drawToolSimplifyAbortController`,void 0),e([b({readOnly:!0})],G.prototype,`activeTool`,null),e([b()],G.prototype,`geometrySimplificationInProgress`,null),e([b({readOnly:!0})],G.prototype,`activeCreateToolDrawMode`,null),e([b()],G.prototype,`activeTooltip`,null),e([b({types:E})],G.prototype,`activeFillSymbol`,void 0),e([b()],G.prototype,`activeLineSymbol`,void 0),e([b()],G.prototype,`activeVertexSymbol`,void 0),e([b()],G.prototype,`allowDeleteKey`,void 0),e([b({readOnly:!0})],G.prototype,`createGraphic`,null),e([b()],G.prototype,`defaultCreateOptions`,null),e([b()],G.prototype,`defaultUpdateOptions`,null),e([b()],G.prototype,`activeUpdateOptions`,void 0),e([b({type:M,nonNullable:!0})],G.prototype,`labelOptions`,null),e([b()],G.prototype,`layer`,void 0),e([b({types:E})],G.prototype,`pointSymbol`,void 0),e([b({types:E})],G.prototype,`polygonSymbol`,void 0),e([b({types:E})],G.prototype,`polylineSymbol`,void 0),e([b()],G.prototype,`meshSymbol`,void 0),e([b({type:T})],G.prototype,`textSymbol`,null),e([b({type:F,nonNullable:!0})],G.prototype,`snappingOptions`,null),e([b()],G.prototype,`snappingManager`,null),e([b({readOnly:!0})],G.prototype,`state`,null),e([b()],G.prototype,`toolTransitionInProgress`,null),e([b({type:Se,nonNullable:!0})],G.prototype,`tooltipOptions`,null),e([b({readOnly:!0})],G.prototype,`updateGraphics`,void 0),e([b()],G.prototype,`updateOnGraphicClick`,void 0),e([b()],G.prototype,`useViewOptions`,void 0),e([b()],G.prototype,`cancelUpdateOnClickAway`,void 0),e([b()],G.prototype,`updating`,null),e([b()],G.prototype,`creationMode`,void 0),e([b({type:Ce,nonNullable:!0})],G.prototype,`valueOptions`,null),e([b({types:E})],G.prototype,`vertexSymbol`,void 0),e([b({value:null})],G.prototype,`view`,null),e([b({constructOnly:!0,type:N})],G.prototype,`sketchOptions`,void 0),e([b()],G.prototype,`useLegacyCreateTools`,void 0),e([b()],G.prototype,`isUsingLegacyCreateTools`,null),e([b()],G.prototype,`pluginManager`,null),e([b()],G.prototype,`drawTool`,null),e([b()],G.prototype,`activePluginConfigurations`,null),e([b()],G.prototype,`rootPlugins`,null),e([b()],G.prototype,`effectiveAvailablePlugins`,null),e([b()],G.prototype,`firstPluginWithSwappableLeaf`,null),e([b()],G.prototype,`multiplePluginsActive`,null),G=e([re(`esri.widgets.Sketch.SketchViewModel`)],G);const Re=`sketch:missing-property`,K=e=>`Property '${e}' is missing on SketchViewModel.`;function ze(e){return e===`polygon`||e===`rectangle`||e===`circle`}function q(e,t){Y(`undo`,e.history.undo,e.history.redo,t)}function J(e,t){Y(`redo`,e.history.redo,e.history.undo,t)}function Y(e,t,n,r){let i=t.pop();if(!i)return;let a=i.updates,o=[];r.forEach((t,n)=>{let r=a[n];r!=null&&(`geometry`in r&&r.geometry!=null&&(o.push({geometry:t.geometry}),t.geometry=r.geometry),`symbol`in r&&r.symbol!=null&&(o.push({symbol:t.symbol}),t.symbol=r.symbol),`undo`in r&&(o.push(r),r[e](t)))}),n.push({updates:o})}function X(e,t){e!=null&&t.hasGrabbedManipulators&&(e.activeTool=null)}function Z(e){return{updates:e.map(({geometry:e})=>e?.type===`mesh`?{geometry:e.cloneShallow()}:{geometry:e})}}function Q(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function $(e){return`requireError`in e&&e.requireError===`aborted`}export{G as default};
@@ -32,6 +32,12 @@ export default class GroupLayerItem extends ItemBase {
32
32
  get items(): ParentItem[];
33
33
  /** Layer containing the sublayer that contains the selected features. */
34
34
  get layer(): SelectionListParentLayer;
35
+ /**
36
+ * Indicates the layer and at least one of its child layers are visible on the map.
37
+ *
38
+ * @since 5.2
39
+ */
40
+ get layerIsVisible(): boolean;
35
41
  /** Convenience property for all child layers and tables on the parent group layer. */
36
42
  get layers(): Layer[] | SubtypeSublayer[];
37
43
  /**
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../core/accessorSupport/decorators.js";import r from"./ItemBase.js";let i=class extends r{constructor(e){super(e),this._items=[],this.expanded=!0,this.layer=null}get isTable(){return this.items.some(e=>e.isTable)}get items(){return this._items}get layers(){let{layer:e}=this;return e.type===`group`||e.type===`knowledge-graph`?e.layers.toArray().reverse():e.type===`subtype-group`?e.sublayers.toArray().reverse():[]}get maxVisibleFeatureCountExceeded(){return this.items.some(e=>e.maxVisibleFeatureCountExceeded)}get total(){return this.items.reduce((e,t)=>e+t.total,0)}get visible(){return this.items.some(e=>e.visible)}get visibleTotal(){return this.items.reduce((e,t)=>e+t.visibleTotal,0)}reset(){this.items.forEach(e=>e.reset())}async sync({controller:e,promises:t}){let{layers:n,viewModel:r}=this;this._items=r.layersToItems({controller:e,groupLayerItem:this,layers:n,promises:t})}};e([t()],i.prototype,`_items`,void 0),e([t()],i.prototype,`expanded`,void 0),e([t()],i.prototype,`isTable`,null),e([t()],i.prototype,`items`,null),e([t({constructOnly:!0})],i.prototype,`layer`,void 0),e([t()],i.prototype,`layers`,null),e([t()],i.prototype,`maxVisibleFeatureCountExceeded`,null),e([t()],i.prototype,`total`,null),e([t()],i.prototype,`visible`,null),e([t()],i.prototype,`visibleTotal`,null),i=e([n(`esri.widgets.support.SelectionList.GroupLayerItem`)],i);const a=i;export{a as default};
2
+ import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../core/accessorSupport/decorators.js";import r from"./ItemBase.js";let i=class extends r{constructor(e){super(e),this._items=[],this.expanded=!0,this.layer=null}get isTable(){return this.items.some(e=>e.isTable)}get items(){return this._items}get layerIsVisible(){return this.items.some(e=>e.layerIsVisible)}get layers(){let{layer:e}=this;return e.type===`group`||e.type===`knowledge-graph`?e.layers.toArray().reverse():e.type===`subtype-group`?e.sublayers.toArray().reverse():[]}get maxVisibleFeatureCountExceeded(){return this.items.some(e=>e.maxVisibleFeatureCountExceeded)}get total(){return this.items.reduce((e,t)=>e+t.total,0)}get visible(){return this.items.some(e=>e.visible)}get visibleTotal(){return this.items.reduce((e,t)=>e+t.visibleTotal,0)}reset(){this.items.forEach(e=>e.reset())}async sync({controller:e,promises:t}){let{layers:n,viewModel:r}=this;this._items=r.layersToItems({controller:e,groupLayerItem:this,layers:n,promises:t})}};e([t()],i.prototype,`_items`,void 0),e([t()],i.prototype,`expanded`,void 0),e([t()],i.prototype,`isTable`,null),e([t()],i.prototype,`items`,null),e([t({constructOnly:!0})],i.prototype,`layer`,void 0),e([t()],i.prototype,`layerIsVisible`,null),e([t()],i.prototype,`layers`,null),e([t()],i.prototype,`maxVisibleFeatureCountExceeded`,null),e([t()],i.prototype,`total`,null),e([t()],i.prototype,`visible`,null),e([t()],i.prototype,`visibleTotal`,null),i=e([n(`esri.widgets.support.SelectionList.GroupLayerItem`)],i);const a=i;export{a as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{isTableLayer as i}from"../../../views/support/selectionUtils.js";import{getIconForLayer as a}from"../iconUtils.js";let o=class extends t{constructor(e){super(e),this.layer=null,this.viewModel=null}get _layerViewSuspended(){return this.layerView?.suspended===!0}get iconName(){return this.layerIsVisible?a(this.layer):`layer-hide`}get isTable(){return i(this.layer,this.view)}get layerIsVisible(){let{layer:e}=this,t=e.parent;return!(this._layerViewSuspended||!e.visible||t&&`visible`in t&&!t.visible)}get key(){return this.layer.id}get layerView(){return this.viewModel.layerViewMap.get(this.layer.id)}get title(){return this.layer.title}get view(){return this.viewModel.view}};e([n()],o.prototype,`_layerViewSuspended`,null),e([n()],o.prototype,`iconName`,null),e([n()],o.prototype,`isTable`,null),e([n()],o.prototype,`layerIsVisible`,null),e([n()],o.prototype,`key`,null),e([n({constructOnly:!0})],o.prototype,`layer`,void 0),e([n()],o.prototype,`layerView`,null),e([n()],o.prototype,`title`,null),e([n()],o.prototype,`view`,null),e([n()],o.prototype,`viewModel`,void 0),o=e([r(`esri.widgets.support.SelectionList.ItemBase`)],o);const s=o;export{s as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{isTableLayer as i,isSelectableLayer as a,isSelectionSourceVisible as o}from"../../../views/support/selectionUtils.js";import{getIconForLayer as s}from"../iconUtils.js";let c=class extends t{constructor(e){super(e),this.layer=null,this.viewModel=null}get _layerViewSuspended(){return this.layerView?.suspended===!0}get iconName(){return this.layerIsVisible?s(this.layer):`layer-hide`}get isTable(){return i(this.layer,this.view)}get layerIsVisible(){let{layer:e,view:t}=this;return!a(e)||i(e,t)?e.effectiveVisible!==!1:!this._layerViewSuspended&&o(e,t)}get key(){return this.layer.id}get layerView(){return this.viewModel.layerViewMap.get(this.layer.id)}get title(){return this.layer.title}get view(){return this.viewModel.view}};e([n()],c.prototype,`_layerViewSuspended`,null),e([n()],c.prototype,`iconName`,null),e([n()],c.prototype,`isTable`,null),e([n()],c.prototype,`layerIsVisible`,null),e([n()],c.prototype,`key`,null),e([n({constructOnly:!0})],c.prototype,`layer`,void 0),e([n()],c.prototype,`layerView`,null),e([n()],c.prototype,`title`,null),e([n()],c.prototype,`view`,null),e([n()],c.prototype,`viewModel`,void 0),c=e([r(`esri.widgets.support.SelectionList.ItemBase`)],c);const l=c;export{l as default};
@@ -6,7 +6,7 @@ import type { SelectableViewUnion, SelectionOperationType, SelectionSource, Sele
6
6
  import type { SelectionToolConfig, SelectionToolOptions, SelectionToolbarState } from "./types.js";
7
7
 
8
8
  /** @internal */
9
- export interface SelectionToolbarViewModelProperties extends Partial<Pick<SelectionToolbarViewModel, "continuousSelectionEnabled" | "defaultLassoToolOptions" | "defaultOperationType" | "defaultPointToolOptions" | "defaultPolygonToolOptions" | "defaultRectangleToolOptions" | "layerViewPreferenceEnabled" | "persistSelection" | "returnFeatureTitleFields" | "returnGeometry" | "selectionManager" | "selectOnComplete" | "sources" | "toolConfigs" | "view">> {}
9
+ export interface SelectionToolbarViewModelProperties extends Partial<Pick<SelectionToolbarViewModel, "continuousSelectionEnabled" | "defaultLassoToolOptions" | "defaultOperationType" | "defaultPointToolOptions" | "defaultPolygonToolOptions" | "defaultRectangleToolOptions" | "ignoreLayerVisibility" | "layerViewPreferenceEnabled" | "persistSelection" | "returnFeatureTitleFields" | "returnGeometry" | "selectionManager" | "selectOnComplete" | "sources" | "toolConfigs" | "view">> {}
10
10
 
11
11
  /**
12
12
  * Events emitted by SelectionToolbarViewModel.
@@ -76,6 +76,11 @@ export default class SelectionToolbarViewModel extends EventedAccessor {
76
76
  get effectiveSelectionManager(): SelectionManager | null | undefined;
77
77
  /** @internal */
78
78
  get effectiveSources(): SelectionSource[];
79
+ /**
80
+ * @default false
81
+ * @internal
82
+ */
83
+ accessor ignoreLayerVisibility: boolean;
79
84
  /**
80
85
  * @default true
81
86
  * @internal
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{deprecatedProperty as t}from"../../../core/deprecate.js";import{EventedAccessor as n}from"../../../core/Evented.js";import{handlesGroup as r}from"../../../core/handleUtils.js";import i from"../../../core/Logger.js";import{removeMaybe as a}from"../../../core/maybe.js";import{watch as o}from"../../../core/reactiveUtils.js";import{property as s,subclass as c}from"../../../core/accessorSupport/decorators.js";import{isKnowledgeGraphLayer as l,isLinkChartLayer as u}from"../../../layers/support/layerUtils.js";import{findLayerView as d}from"../../../views/draw/support/layerUtils.js";import f from"../../../views/selection/SelectionOperation.js";import{isSelectableLayerView2D as p}from"../../../views/support/layerViewUtils.js";import{isSelectableLayerView as m,isTableLayer as h}from"../../../views/support/selectionUtils.js";let g=class extends n{constructor(e){super(e),this._operationHandlesGroup=null,this.activeOperation=null,this.continuousSelectionEnabled=!1,this.defaultLassoToolOptions={createTool:`polygon`,mode:`hybrid`,toolName:`lasso`},this.defaultOperationType=`add`,this.defaultPolygonToolOptions={createTool:`polygon`,mode:`hybrid`,toolName:`polygon`},this.defaultPointToolOptions={createTool:`point`,toolName:`point`},this.defaultRectangleToolOptions={createTool:`rectangle`,toolName:`rectangle`},this.layerViewPreferenceEnabled=!0,this.persistSelection=!0,this.selectionManager=null,this.returnFeatureTitleFields=!1,this.returnGeometry=!0,this.selectOnComplete=!0,this.sources=null,this.toolConfigs=[]}initialize(){this.addHandles([o(()=>this.effectiveSources,e=>{this.activeOperation&&(this.activeOperation.sources=e)}),o(()=>this.defaultOperationType,e=>{this.activeOperation&&(this.activeOperation.type=e)})])}destroy(){this.activeOperation?.cancel(),this.activeOperation?.destroy(),this._operationHandlesGroup=a(this._operationHandlesGroup)}get effectiveSelectionManager(){return this.selectionManager??this.view?.selectionManager}get effectiveSources(){let{layerViewPreferenceEnabled:e,sources:t,view:n}=this,r=t??this.effectiveSelectionManager?.sources;if(!r?.length)return[];let i=new Set,a=n?.type===`3d`?m:p;return r.forEach(t=>{if(!h(t,n)){if(a(t))i.add(t);else if(l(t)||u(t))(t.layers||[]).forEach(t=>{let r=n?d(n,t):void 0,o=e&&a(r)?r:t;i.add(o)});else if(e){let e=n?d(n,t):void 0;i.add(a(e)?e:t)}else i.add(t)}}),Array.from(i)}get layers(){return t(i.getLogger(this),`layers`,{replacement:`Use SelectionToolbar.sources instead.`}),this.sources}set layers(e){t(i.getLogger(this),`layers`,{replacement:`Use SelectionToolbar.sources instead.`}),this.sources=e}get state(){return this.activeOperation?`active`:this.view?.ready&&this.effectiveSources.length?`ready`:`disabled`}activate(e){let{state:t}=this,n=e?.view||this.view,a=e?.sources||this.effectiveSources;if(t===`disabled`||!n){i.getLogger(this).warn(`Unable to start selection operation.`);return}t===`active`&&this.cancel();let o=new CustomEvent(`before-activate`,{cancelable:!0,detail:{toolName:e?.toolName??null}});if(this.emit(`before-activate`,o),o.defaultPrevented)return;let s={type:this.defaultOperationType,persistSelection:this.persistSelection,returnFeatureTitleFields:this.returnFeatureTitleFields,returnGeometry:this.returnGeometry,selectOnComplete:this.selectOnComplete,selectionManager:this.effectiveSelectionManager,...e,sources:a,view:n},c=new f({...s});return this._operationHandlesGroup=r([c.on(`selection-change`,e=>this.emit(`selection-change`,e)),c.once(`complete`,e=>this._onOperationComplete(e,s))]),this._set(`activeOperation`,c),c}activateTool(e){this.cancel();let t=this._getToolOptions(e);if(!t){i.getLogger(this).warn(`Unable to activate tool: unable to determine options.`);return}return this.activate(t)}cancel(){this.activeOperation?.cancel(),this._set(`activeOperation`,null)}toggleTool(e){let{activeOperation:t}=this;if(t){let n=t.toolName;if(this.cancel(),n===e)return}return this.activateTool(e)}_onOperationComplete(e,t){let n=this.activeOperation?.type??e.operationType;this._operationHandlesGroup=a(this._operationHandlesGroup),this.activeOperation?.destroy(),this._set(`activeOperation`,null),this.emit(`complete`,e),this.continuousSelectionEnabled&&!e.aborted&&this.activate({...t,type:n})}_getToolOptions(e){let t=this.toolConfigs.find(t=>t.toolName===e);if(t)return t;if(e===`lasso`)return this.defaultLassoToolOptions;if(e===`point`)return this.defaultPointToolOptions;if(e===`polygon`)return this.defaultPolygonToolOptions;if(e===`rectangle`)return this.defaultRectangleToolOptions}};e([s({readOnly:!0})],g.prototype,`activeOperation`,void 0),e([s()],g.prototype,`continuousSelectionEnabled`,void 0),e([s()],g.prototype,`defaultLassoToolOptions`,void 0),e([s()],g.prototype,`defaultOperationType`,void 0),e([s()],g.prototype,`defaultPolygonToolOptions`,void 0),e([s()],g.prototype,`defaultPointToolOptions`,void 0),e([s()],g.prototype,`defaultRectangleToolOptions`,void 0),e([s()],g.prototype,`effectiveSelectionManager`,null),e([s()],g.prototype,`effectiveSources`,null),e([s()],g.prototype,`layers`,null),e([s()],g.prototype,`layerViewPreferenceEnabled`,void 0),e([s()],g.prototype,`persistSelection`,void 0),e([s()],g.prototype,`selectionManager`,void 0),e([s()],g.prototype,`returnFeatureTitleFields`,void 0),e([s()],g.prototype,`returnGeometry`,void 0),e([s()],g.prototype,`selectOnComplete`,void 0),e([s()],g.prototype,`sources`,void 0),e([s({readOnly:!0})],g.prototype,`state`,null),e([s()],g.prototype,`toolConfigs`,void 0),e([s()],g.prototype,`view`,void 0),g=e([c(`esri.widgets.support.SelectionToolbar.SelectionToolbarViewModel`)],g);const _=g;export{_ as default};
2
+ import{__decorate as e}from"tslib";import{deprecatedProperty as t}from"../../../core/deprecate.js";import{EventedAccessor as n}from"../../../core/Evented.js";import{handlesGroup as r}from"../../../core/handleUtils.js";import i from"../../../core/Logger.js";import{getOrCreateMapValue as a}from"../../../core/MapUtils.js";import{removeMaybe as o}from"../../../core/maybe.js";import s from"../../../core/ReactiveMap.js";import{watch as c}from"../../../core/reactiveUtils.js";import{property as l,subclass as u}from"../../../core/accessorSupport/decorators.js";import{isKnowledgeGraphLayer as d,isLinkChartLayer as f}from"../../../layers/support/layerUtils.js";import{findLayerView as p}from"../../../views/draw/support/layerUtils.js";import m from"../../../views/selection/SelectionOperation.js";import{isSelectableLayer as h,isSelectableLayerView as g,isSelectionSourceVisible as _,isTableLayer as v,isSelectableLayerViewVisible as y}from"../../../views/support/selectionUtils.js";let b=class extends n{constructor(e){super(e),this._operationHandlesGroup=null,this.activeOperation=null,this.continuousSelectionEnabled=!1,this.defaultLassoToolOptions={createTool:`polygon`,mode:`hybrid`,toolName:`lasso`},this.defaultOperationType=`add`,this.defaultPolygonToolOptions={createTool:`polygon`,mode:`hybrid`,toolName:`polygon`},this.defaultPointToolOptions={createTool:`point`,toolName:`point`},this.defaultRectangleToolOptions={createTool:`rectangle`,toolName:`rectangle`},this.ignoreLayerVisibility=!1,this.layerViewPreferenceEnabled=!0,this.persistSelection=!0,this.selectionManager=null,this.returnFeatureTitleFields=!1,this.returnGeometry=!0,this.selectOnComplete=!0,this.sources=null,this.toolConfigs=[]}initialize(){this.addHandles([c(()=>this.effectiveSourceMap,()=>{let{activeOperation:e,effectiveSources:t,effectiveSourceMap:n}=this;e&&(e.effectiveSourceMap=n,e.sources=t)}),c(()=>this.defaultOperationType,e=>{this.activeOperation&&(this.activeOperation.type=e)})])}destroy(){this.activeOperation?.cancel(),this.activeOperation?.destroy(),this._operationHandlesGroup=o(this._operationHandlesGroup)}get effectiveSelectionManager(){return this.selectionManager??this.view?.selectionManager}get effectiveSourceMap(){let e=new s;return(this.sources??this.effectiveSelectionManager?.sources.toArray())?.forEach(t=>this._collectEffectiveSource(t,e)),e}get effectiveSources(){return Array.from(this.effectiveSourceMap.keys())}get layers(){return t(i.getLogger(this),`layers`,{replacement:`Use SelectionToolbar.sources instead.`}),this.sources}set layers(e){t(i.getLogger(this),`layers`,{replacement:`Use SelectionToolbar.sources instead.`}),this.sources=e}get state(){return this.activeOperation?`active`:this.view?.ready&&this.effectiveSources.length?`ready`:`disabled`}activate(e){let{state:t}=this,n=e?.view||this.view,a=e?.sources||this.effectiveSources;if(t===`disabled`||!n){i.getLogger(this).warn(`Unable to start selection operation.`);return}t===`active`&&this.cancel();let o=new CustomEvent(`before-activate`,{cancelable:!0,detail:{toolName:e?.toolName??null}});if(this.emit(`before-activate`,o),o.defaultPrevented)return;let s={effectiveSourceMap:this.effectiveSourceMap,persistSelection:this.persistSelection,returnFeatureTitleFields:this.returnFeatureTitleFields,returnGeometry:this.returnGeometry,selectOnComplete:this.selectOnComplete,selectionManager:this.effectiveSelectionManager,type:this.defaultOperationType,...e,sources:a,view:n},c=new m({...s});return this._operationHandlesGroup=r([c.on(`selection-change`,e=>this.emit(`selection-change`,e)),c.once(`complete`,e=>this._onOperationComplete(e,s))]),this._set(`activeOperation`,c),c}activateTool(e){this.cancel();let t=this._getToolOptions(e);if(!t){i.getLogger(this).warn(`Unable to activate tool: unable to determine options.`);return}return this.activate(t)}cancel(){this.activeOperation?.cancel(),this._set(`activeOperation`,null)}toggleTool(e){let{activeOperation:t}=this;if(t){let n=t.toolName;if(this.cancel(),n===e)return}return this.activateTool(e)}_onOperationComplete(e,t){let n=this.activeOperation?.type??e.operationType;this._operationHandlesGroup=o(this._operationHandlesGroup),this.activeOperation?.destroy(),this._set(`activeOperation`,null),this.emit(`complete`,e),this.continuousSelectionEnabled&&!e.aborted&&this.activate({...t,type:n})}_getToolOptions(e){let t=this.toolConfigs.find(t=>t.toolName===e);if(t)return t;if(e===`lasso`)return this.defaultLassoToolOptions;if(e===`point`)return this.defaultPointToolOptions;if(e===`polygon`)return this.defaultPolygonToolOptions;if(e===`rectangle`)return this.defaultRectangleToolOptions}_collectEffectiveSource(e,t){let{view:n}=this;if(d(e)||f(e)){e.layers.forEach(e=>this._collectEffectiveSource(e,t));return}if(!h(e)&&!g(e)||!this.ignoreLayerVisibility&&!_(e,n)||v(e,n))return;if(!this.layerViewPreferenceEnabled||g(e)){t.set(e,[]);return}let r=n?p(n,e):void 0;if(!g(r)){t.set(e,[]);return}(this.ignoreLayerVisibility||y(r))&&a(t,r,()=>[]).push(e)}};e([l({readOnly:!0})],b.prototype,`activeOperation`,void 0),e([l()],b.prototype,`continuousSelectionEnabled`,void 0),e([l()],b.prototype,`defaultLassoToolOptions`,void 0),e([l()],b.prototype,`defaultOperationType`,void 0),e([l()],b.prototype,`defaultPolygonToolOptions`,void 0),e([l()],b.prototype,`defaultPointToolOptions`,void 0),e([l()],b.prototype,`defaultRectangleToolOptions`,void 0),e([l()],b.prototype,`effectiveSelectionManager`,null),e([l()],b.prototype,`effectiveSourceMap`,null),e([l()],b.prototype,`effectiveSources`,null),e([l()],b.prototype,`layers`,null),e([l()],b.prototype,`ignoreLayerVisibility`,void 0),e([l()],b.prototype,`layerViewPreferenceEnabled`,void 0),e([l()],b.prototype,`persistSelection`,void 0),e([l()],b.prototype,`selectionManager`,void 0),e([l()],b.prototype,`returnFeatureTitleFields`,void 0),e([l()],b.prototype,`returnGeometry`,void 0),e([l()],b.prototype,`selectOnComplete`,void 0),e([l()],b.prototype,`sources`,void 0),e([l({readOnly:!0})],b.prototype,`state`,null),e([l()],b.prototype,`toolConfigs`,void 0),e([l()],b.prototype,`view`,void 0),b=e([u(`esri.widgets.support.SelectionToolbar.SelectionToolbarViewModel`)],b);const x=b;export{x as default};
@@ -12,7 +12,7 @@ import type { VisibleElementsProperties } from "./SelectionToolbar/VisibleElemen
12
12
  *
13
13
  * @internal
14
14
  */
15
- export interface SelectionToolbarProperties extends WidgetProperties, Partial<Pick<SelectionToolbar, "availableOperationTypes" | "continuousSelectionEnabled" | "defaultLassoToolOptions" | "defaultOperationType" | "defaultPointToolOptions" | "defaultPolygonToolOptions" | "defaultRectangleToolOptions" | "disabled" | "layers" | "layerViewPreferenceEnabled" | "layout" | "persistSelection" | "returnFeatureTitleFields" | "returnGeometry" | "selectionManager" | "selectOnComplete" | "sources" | "toolConfigs" | "view">> {
15
+ export interface SelectionToolbarProperties extends WidgetProperties, Partial<Pick<SelectionToolbar, "availableOperationTypes" | "continuousSelectionEnabled" | "defaultLassoToolOptions" | "defaultOperationType" | "defaultPointToolOptions" | "defaultPolygonToolOptions" | "defaultRectangleToolOptions" | "disabled" | "ignoreLayerVisibility" | "layers" | "layerViewPreferenceEnabled" | "layout" | "persistSelection" | "returnFeatureTitleFields" | "returnGeometry" | "selectionManager" | "selectOnComplete" | "sources" | "toolConfigs" | "view">> {
16
16
  /**
17
17
  * The SelectionToolbar widget's default label.
18
18
  *
@@ -107,6 +107,13 @@ export default class SelectionToolbar extends Widget<SelectionToolbarProperties>
107
107
  * @internal
108
108
  */
109
109
  get effectiveSources(): SelectionSource[];
110
+ /**
111
+ * Indicates whether the selection toolbar will ignore layer visibility when determining selection results.
112
+ * Non-visible layers and layer views are typically excluded from selection results.
113
+ *
114
+ * @internal
115
+ */
116
+ accessor ignoreLayerVisibility: boolean;
110
117
  /**
111
118
  * The SelectionToolbar widget's default label.
112
119
  *