@arcgis/core 4.24.0-next.20220606 → 4.24.0-next.20220607

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 (49) hide show
  1. package/analysis/Analysis.js +1 -1
  2. package/analysis/LineOfSightAnalysis.js +1 -1
  3. package/arcade/featureset/support/sqlUtils.js +1 -1
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/471beeb6924599209567.js +1 -0
  6. package/assets/esri/core/workers/chunks/{8102bb78fe96e6197e4e.js → 5da1b3dacc6c8c080a1c.js} +1 -1
  7. package/assets/esri/core/workers/chunks/b780228a520e1a0b100b.js +1 -0
  8. package/assets/esri/themes/base/widgets/_Daylight.scss +31 -32
  9. package/assets/esri/themes/base/widgets/_SnappingControls.scss +14 -0
  10. package/assets/esri/themes/dark/main.css +1 -1
  11. package/assets/esri/themes/light/main.css +1 -1
  12. package/assets/esri/themes/light/view.css +1 -1
  13. package/core/unitUtils.js +1 -1
  14. package/interfaces.d.ts +19 -41
  15. package/layers/LineOfSightLayer.js +1 -1
  16. package/networks/support/typeUtils.js +1 -1
  17. package/package.json +1 -1
  18. package/properties/defaultUnit.js +1 -1
  19. package/rest/networks/queryAssociations.js +5 -0
  20. package/rest/networks/support/Association.js +1 -1
  21. package/rest/networks/support/QueryAssociationsParameters.js +5 -0
  22. package/rest/networks/support/QueryAssociationsResult.js +5 -0
  23. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  24. package/support/revision.js +1 -1
  25. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  26. package/views/2d/engine/webgl/mesh/templates/WGLLabelTemplate.js +1 -1
  27. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  28. package/views/3d/analysis/LineOfSight/LineOfSightVisualization.js +1 -1
  29. package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
  30. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  31. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  32. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  33. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  34. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  35. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  36. package/views/draw/DrawOperation.js +1 -1
  37. package/views/interactive/SegmentLabels.js +1 -1
  38. package/views/interactive/tooltip/Tooltip.js +1 -1
  39. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  40. package/views/support/lengthMeasurementUtils.js +1 -1
  41. package/widgets/Daylight/support/SliderWithDropdown.js +1 -1
  42. package/widgets/Slider.js +1 -1
  43. package/widgets/support/AnalysisViewModel.js +1 -1
  44. package/widgets/support/InteractiveAnalysisViewModel.js +1 -1
  45. package/widgets/support/SnappingControls/SnappingControlsViewModel.js +1 -1
  46. package/widgets/support/SnappingControls/SnappingListItem.js +1 -1
  47. package/widgets/support/SnappingControls.js +1 -1
  48. package/assets/esri/core/workers/chunks/0832c0f5e61b7b354a17.js +0 -1
  49. package/assets/esri/core/workers/chunks/6f41f039226a043a2d18.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../request.js";import{binaryIndexOf as t,flatten as r,splitIntoChunks as o}from"../../../../core/arrayUtils.js";import n from"../../../../core/Error.js";import a from"../../../../core/has.js";import{isSome as s,isNone as i}from"../../../../core/maybe.js";import{eachAlways as c}from"../../../../core/promiseUtils.js";import{isInt16Array as l,isInt32Array as u}from"../../../../core/typedArrayUtil.js";import{g as f}from"../../../../chunks/mat3.js";import{c as p}from"../../../../chunks/mat3f64.js";import{a as m}from"../../../../chunks/mat4.js";import{c as h}from"../../../../chunks/mat4f64.js";import{a as d,m as y,c as S}from"../../../../chunks/quat.js";import{b}from"../../../../chunks/quatf32.js";import{s as g,c as w,v as E,q as T,g as I,a as M,m as v}from"../../../../chunks/vec3.js";import{c as R}from"../../../../chunks/vec3f64.js";import{c as x}from"../../../../chunks/vec4f64.js";import{projectBoundingSphere as j,canProjectWithoutEngine as C,projectBuffer as N,computeTranslationToOriginAndRotation as q,projectVectorToVector as k}from"../../../../geometry/projection.js";import{getSphericalPCPF as U,getReferenceEllipsoid as D}from"../../../../geometry/projectionEllipsoid.js";import _ from"../../../../geometry/SpatialReference.js";import{create as W,empty as z,expandPointInPlace as F,intersects as O}from"../../../../geometry/support/aaBoundingRect.js";import{isPlateCarree as A}from"../../../../geometry/support/spatialReferenceUtils.js";import G from"../../../../rest/support/Query.js";import{readBinaryAttribute as K}from"./I3SBinaryReader.js";import{computeGlobalTransformation as L}from"./I3SProjectionUtil.js";import{createSolidEdgeMaterial as B,createMaterialFromEdges as P}from"../support/edgeUtils.js";import{parseColorMixMode as $,ColorMixModeEnum as Q}from"../support/symbolColorUtils.js";import{create as Z,compute as H,corners as J}from"../../support/orientedBoundingBox.js";function V(e){return e&&parseInt(e.substring(e.lastIndexOf("/")+1,e.length),10)}function X(e){if(a("disable-feature:i3s-draco")||!e)return!1;for(const t of e)for(const e of t.geometryBuffers)if("draco"===e.compressedAttributes?.encoding)return!0;return!1}function Y(e,t,r,o,n,a){const s=t!==o;n.traverse(r,(r=>{let n=r.mbs;s&&(n=ne,j(r.mbs,o,n,t));return se(e,n)!==ae.OUTSIDE&&(a(r),!0)}))}function ee(e,t,r){let o=0,n=0;for(let a=0;a<t.length&&o<e.length;a++)e[o]===t[a]&&(r(a)&&(e[n]=e[o],n++),o++);e.length=n}function te(e,r,o){let n=0,a=0;for(;n<o.length;){t(e,o[n])>=0===r&&(o[a]=o[n],a++),n++}o.length=a}const re=W();function oe(e,t){if(0===t.rotationScale[1]&&0===t.rotationScale[2]&&0===t.rotationScale[3]&&0===t.rotationScale[5]&&0===t.rotationScale[6]&&0===t.rotationScale[7])return re[0]=(e[0]-t.position[0])/t.rotationScale[0],re[1]=(e[1]-t.position[1])/t.rotationScale[4],re[2]=(e[2]-t.position[0])/t.rotationScale[0],re[3]=(e[3]-t.position[1])/t.rotationScale[4],re}const ne=x();var ae;function se(e,t){const r=t[0],o=t[1],n=t[3],a=e[0]-r,s=r-e[2],i=e[1]-o,c=o-e[3],l=Math.max(a,s,0),u=Math.max(i,c,0),f=l*l+u*u;if(f>n*n)return ae.OUTSIDE;if(f>0)return ae.INTERSECTS_CENTER_OUTSIDE;return-Math.max(a,s,i,c)>n?ae.INSIDE:ae.INTERSECTS_CENTER_INSIDE}function ie(e,t){const r=t[0],o=t[1],n=t[2],a=t[3],s=e[0]-r,i=r-e[3],c=e[1]-o,l=o-e[4],u=e[2]-n,f=n-e[5],p=Math.max(s,i,0),m=Math.max(c,l,0),h=Math.max(u,f,0),d=p*p+m*m+h*h;if(d>a*a)return ae.OUTSIDE;if(d>0)return ae.INTERSECTS_CENTER_OUTSIDE;return-Math.max(s,i,c,l,u,f)>a?ae.INSIDE:ae.INTERSECTS_CENTER_INSIDE}function ce(e,t,r){const o=[],n=r&&r.missingFields,a=r&&r.originalFields;for(const s of e){const e=s.toLowerCase();let r=!1;for(const n of t)if(e===n.name.toLowerCase()){o.push(n.name),r=!0,a&&a.push(s);break}!r&&n&&n.push(s)}return o}async function le(e,t,o,a,c){if(0===t.length)return[];const l=e.attributeStorageInfo;if(s(e.associatedLayer))try{return await fe(e.associatedLayer,t,o,a)}catch(u){if(e.associatedLayer.loaded)throw u}if(l){const s=ue(t,o,c);if(i(s))throw new n("scenelayer:features-not-loaded","Tried to query attributes for unloaded features");const u=e.parsedUrl.path,f=await Promise.all(s.map((e=>me(u,l,e.node,e.indices,a).then((t=>{for(let r=0;r<e.graphics.length;r++){const o=e.graphics[r],n=t[r];if(o.attributes)for(const e in o.attributes)e in n||(n[e]=o.attributes[e]);o.attributes=n}return e.graphics})))));return r(f)}throw new n("scenelayer:no-attribute-source","This scene layer does not have a source for attributes available")}function ue(e,t,r){const o=new Map,n=[],a=r();for(const s of e){const e=s.attributes[t];for(let t=0;t<a.length;t++){const r=a[t],i=r.featureIds.indexOf(e);if(i>=0){let e=o.get(r.node);e||(e={node:r.node,indices:[],graphics:[]},n.push(e),o.set(r.node,e)),e.indices.push(i),e.graphics.push(s);for(let r=t;r>0;r--)a[r]=a[r-1];a[0]=r;break}}}return n}async function fe(e,t,r,o){t.sort(((e,t)=>e.attributes[r]-t.attributes[r]));const n=t.map((e=>e.attributes[r])),a=[],s=ce(o,e.fields,{originalFields:a}),i=await pe(e,n,s);for(let c=0;c<t.length;c++){const e=t[c],r=i[c],o={};if(e.attributes)for(const t in e.attributes)o[t]=e.attributes[t];for(let t=0;t<a.length;t++)o[a[t]]=r[s[t]];e.attributes=o}return t}function pe(e,t,a){const s=e.capabilities.query.maxRecordCount;if(null!=s&&t.length>s){const n=o(t,s);return Promise.all(n.map((t=>pe(e,t,a)))).then(r)}const i=new G({objectIds:t,outFields:a,orderByFields:[e.objectIdField]});return e.queryFeatures(i).then((e=>{if(e&&e.features&&e.features.length===t.length)return e.features.map((e=>e.attributes));throw new n("scenelayer:feature-not-in-associated-layer","Feature not found in associated feature layer")}))}function me(t,r,o,n,a){const s=[];for(const e of r)if(e&&a.includes(e.name)){const r=`${t}/nodes/${o.resources.attributes}/attributes/${e.key}/0`;s.push({url:r,storageInfo:e})}return c(s.map((t=>e(t.url,{responseType:"array-buffer"}).then((e=>K(t.storageInfo,e.data)))))).then((e=>{const t=[];for(const r of n){const o={};for(let t=0;t<e.length;t++)null!=e[t].value&&(o[s[t].storageInfo.name]=ye(e[t].value,r));t.push(o)}return t}))}!function(e){e[e.OUTSIDE=0]="OUTSIDE",e[e.INTERSECTS_CENTER_OUTSIDE=1]="INTERSECTS_CENTER_OUTSIDE",e[e.INTERSECTS_CENTER_INSIDE=2]="INTERSECTS_CENTER_INSIDE",e[e.INSIDE=3]="INSIDE"}(ae||(ae={}));const he=-32768,de=-(2**31);function ye(e,t){if(!e)return null;const r=e[t];if(l(e))return r===he?null:r;if(u(e))return r===de?null:r;return r!=r?null:r}function Se(e){const t=e.store.indexCRS||e.store.geographicCRS,r=void 0===t?e.store.indexWKT:void 0;if(r){if(!e.spatialReference)throw new n("layerview:no-store-spatial-reference-wkt-index-and-no-layer-spatial-reference","Found indeWKT in the scene layer store but no layer spatial reference",{});if(r!==e.spatialReference.wkt)throw new n("layerview:store-spatial-reference-wkt-index-incompatible","The indeWKT of the scene layer store does not match the WKT of the layer spatial reference",{})}const o=t?new _(V(t)):e.spatialReference;return o.equals(e.spatialReference)?e.spatialReference:o}function be(e){const t=e.store.vertexCRS||e.store.projectedCRS,r=void 0===t?e.store.vertexWKT:void 0;if(r){if(!e.spatialReference)throw new n("layerview:no-store-spatial-reference-wkt-vertex-and-no-layer-spatial-reference","Found vertexWKT in the scene layer store but no layer spatial reference",{});if(r!==e.spatialReference.wkt)throw new n("layerview:store-spatial-reference-wkt-vertex-incompatible","The vertexWKT of the scene layer store does not match the WKT of the layer spatial reference",{})}const o=t?new _(V(t)):e.spatialReference;return o.equals(e.spatialReference)?e.spatialReference:o}function ge(e,t){return i(t)?"@null":t===U(t)?"@ECEF":e.equals(t)?"":null!=t.wkid?"@"+t.wkid:null}function we(e,t,r){if(!C(e,t))throw new n("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});if("local"===r&&!Ee(e,t))throw new n("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{})}function Ee(e,t){return e.equals(t)||e.isWGS84&&t.isWebMercator||e.isWebMercator&&t.isWGS84}function Te(e,t,r){const o=Se(e),n=be(e);we(o,t,r),we(n,t,r)}function Ie(e){return(null==e.geometryType||"triangles"===e.geometryType)&&((null==e.topology||"PerAttributeArray"===e.topology)&&(null!=e.vertexAttributes&&null!=e.vertexAttributes.position))}function Me(e){if(null==e.store||null==e.store.defaultGeometrySchema||!Ie(e.store.defaultGeometrySchema))throw new n("scenelayer:unsupported-geometry-schema","The geometry schema of this scene layer is not supported.",{url:e.parsedUrl.path})}function ve(e,t){Te(e,t.spatialReference,t.viewingMode)}function Re(e){return null!=e.geometryType&&"points"===e.geometryType&&((null==e.topology||"PerAttributeArray"===e.topology)&&((null==e.encoding||""===e.encoding||"lepcc-xyz"===e.encoding)&&(null!=e.vertexAttributes&&null!=e.vertexAttributes.position)))}function xe(e){if(null==e.store||null==e.store.defaultGeometrySchema||!Re(e.store.defaultGeometrySchema))throw new n("pointcloud:unsupported-geometry-schema","The geometry schema of this point cloud scene layer is not supported.",{})}function je(e,t){we(e.spatialReference,t.spatialReference,t.viewingMode)}function Ce(e){return"simple"===e.type||"class-breaks"===e.type||"unique-value"===e.type}function Ne(e){return"mesh-3d"===e.type}function qe(e){if(null==e||!Ce(e))return!0;if(("unique-value"===e.type||"class-breaks"===e.type)&&null==e.defaultSymbol)return!0;const t=e.getSymbols();if(0===t.length)return!0;for(const r of t){if(!Ne(r)||0===r.symbolLayers.length)return!0;for(const e of r.symbolLayers.items)if("fill"!==e.type||i(e.material)||i(e.material.color)||"replace"!==e.material.colorMixMode)return!0}return!1}const ke=B({color:[0,0,0,0],opacity:0});class Ue{constructor(){this.edgeMaterial=null,this.material=null,this.castShadows=!0}}function De(e){const t=new Ue;let r=!1,o=!1;for(const n of e.symbolLayers.items)if("fill"===n.type&&n.enabled){const e=n.material,a=n.edges;if(s(e)&&!r){const o=e.color,a=$(e.colorMixMode);s(o)?t.material={color:[o.r/255,o.g/255,o.b/255],alpha:o.a,colorMixMode:a}:t.material={color:[1,1,1],alpha:1,colorMixMode:Q.Multiply},t.castShadows=n.castShadows,r=!0}s(a)&&!o&&(t.edgeMaterial=P(a,{}),o=!0)}return t.material||(t.material={color:[1,1,1],alpha:1,colorMixMode:Q.Multiply}),t}function _e(e,t){return(0|e)+(0|t)|0}function We(e,t,r,o,n=0){o===U(o)?t.isGeographic?$e(e,r,t,n):Pe(e,r,t,n):t.isWGS84&&(o.isWebMercator||A(o))?ze(t,e,o,r,n):t.isWebMercator&&A(o)?Le(t,e,o,r,n):e===r?(r.center[2]+=n,N(r.center,t,0,r.center,o,0,1)):(g(r.center,e.center[0],e.center[1],e.center[2]+n),N(r.center,t,0,r.center,o,0,1),d(r.quaternion,e.quaternion),w(r.halfSize,e.halfSize))}function ze(e,t,r,o,n){w(Ge,t.center),Ge[2]+=n;const a=U(r);N(Ge,e,0,Ge,a,0,1),Be(a,t,Ge,r,o)}const Fe=new Float64Array(24),Oe={data:Fe,size:3},Ae=R(),Ge=R(),Ke=p();function Le(e,t,r,o,n){w(Ge,t.center),Ge[2]+=n,Be(e,t,Ge,r,o)}function Be(e,t,r,o,n){const a=f(Ke,t.quaternion);for(let s=0;s<8;++s){for(let e=0;e<3;++e)Ae[e]=t.halfSize[e]*(0!=(s&1<<e)?-1:1);for(let e=0;e<3;++e){let t=r[e];for(let r=0;r<3;++r)t+=Ae[r]*a[3*r+e];Fe[3*s+e]=t}}N(Fe,e,0,Fe,o,0,8),H(Oe,n)}function Pe(e,t,r,o){J(e,Je),g(t.center,e.center[0],e.center[1],e.center[2]+o),q(r,t.center,Ze,U(r)),g(t.center,Ze[12],Ze[13],Ze[14]);const n=2*Math.sqrt(1+Ze[0]+Ze[5]+Ze[10]);He[0]=(Ze[6]-Ze[9])/n,He[1]=(Ze[8]-Ze[2])/n,He[2]=(Ze[1]-Ze[4])/n,He[3]=.25*n,y(t.quaternion,He,e.quaternion),S(He,t.quaternion);let a=0,s=0,i=0;for(const c of Je)c[2]+=o,N(c,r,0,c,U(r),0,1),E(et,c,t.center),T(et,et,He),a=Math.max(a,Math.abs(et[0])),s=Math.max(s,Math.abs(et[1])),i=Math.max(i,Math.abs(et[2]));g(t.halfSize,a,s,i)}function $e(e,t,r,o){const n=D(r),a=1+Math.max(0,o)/(n.radius+e.center[2]);g(t.center,e.center[0],e.center[1],e.center[2]+o),N(t.center,r,0,t.center,U(r),0,1),d(t.quaternion,e.quaternion),S(He,e.quaternion),g(et,0,0,1),T(et,et,He),g(et,e.halfSize[0]*Math.abs(et[0]),e.halfSize[1]*Math.abs(et[1]),e.halfSize[2]*Math.abs(et[2])),I(et,et,n.inverseFlattening),M(t.halfSize,e.halfSize,et),I(t.halfSize,t.halfSize,a)}function Qe(e,t,r,o,n,a){if(!a||0===a.length||i(t))return null;const c=L(e.mbs,n,r,t);let l;m(rt,c);const u=()=>{if(!l)if(l=Je,z(Xe),s(e.serviceObb)){We(e.serviceObb,r,Ye,t,n),J(Ye,l);for(const e of l)v(e,e,rt),F(Xe,e)}else{const o=e.mbs,a=o[3];k(o,r,et,t),v(et,et,rt),et[2]+=n;for(let e=0;e<8;++e){const t=1&e?a:-a,r=2&e?a:-a,o=4&e?a:-a,n=l[e];w(n,[et[0]+t,et[1]+r,et[2]+o]),F(Xe,n)}}};let f=1/0,p=-1/0;const h=e=>{if("replace"!==e.type)return;const r=e.geometry;if(!r.hasZ)return;z(Ve);const n=r.spatialReference||o,a=r.rings.reduce(((e,r)=>r.reduce(((e,r)=>(k(r,n,et,t),v(et,et,rt),F(Ve,et),Math.min(et[2],e))),e)),1/0);u(),O(Xe,Ve)&&(f=Math.min(f,a),p=Math.max(p,a))};if(a.forEach((e=>h(e))),f===1/0)return null;const d=(e,t,r)=>{v(et,r,c),e[t+0]=et[0],e[t+1]=et[1],e[t+2]=et[2],t+=24,r[2]=f,v(et,r,c),e[t+0]=et[0],e[t+1]=et[1],e[t+2]=et[2],t+=24,r[2]=p,v(et,r,c),e[t+0]=et[0],e[t+1]=et[1],e[t+2]=et[2]};for(let s=0;s<8;++s)d(tt.data,3*s,l[s]);return H(tt)}const Ze=h(),He=b(),Je=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],Ve=W(),Xe=W(),Ye=Z(),et=[0,0,0],tt={data:new Array(72),size:3},rt=h();export{ae as MbsIntersectResult,Ue as SymbolInfo,_e as addWraparound,je as checkPointCloudLayerCompatibleWithView,xe as checkPointCloudLayerValid,ve as checkSceneLayerCompatibleWithView,Me as checkSceneLayerValid,we as checkSpatialReference,Te as checkSpatialReferences,Qe as computeVisibilityObb,X as containsDraco,V as extractWkid,ee as filterInPlace,ce as findFieldsCaseInsensitive,Y as findIntersectingNodes,ge as getCacheKeySuffix,ye as getCachedAttributeValue,oe as getClipRect,Se as getIndexCrs,De as getSymbolInfo,be as getVertexCrs,ie as intersectBoundingBoxWithMbs,se as intersectBoundingRectWithMbs,Ee as isSupportedLocalModeProjection,te as objectIdFilter,qe as rendererNeedsTextures,We as transformObb,ke as transparentEdgeMaterial,le as whenGraphicAttributes};
5
+ import e from"../../../../request.js";import{binaryIndexOf as t,flatten as r,splitIntoChunks as n}from"../../../../core/arrayUtils.js";import o from"../../../../core/Error.js";import a from"../../../../core/has.js";import{isSome as i,isNone as s}from"../../../../core/maybe.js";import{eachAlways as c}from"../../../../core/promiseUtils.js";import{isInt16Array as l,isInt32Array as u}from"../../../../core/typedArrayUtil.js";import{g as f}from"../../../../chunks/mat3.js";import{c as p}from"../../../../chunks/mat3f64.js";import{a as m}from"../../../../chunks/mat4.js";import{c as h}from"../../../../chunks/mat4f64.js";import{a as d,m as y,c as S}from"../../../../chunks/quat.js";import{b}from"../../../../chunks/quatf32.js";import{s as g,c as w,v as E,q as T,g as I,a as M,m as v}from"../../../../chunks/vec3.js";import{c as R}from"../../../../chunks/vec3f64.js";import{c as x}from"../../../../chunks/vec4f64.js";import{projectBoundingSphere as j,canProjectWithoutEngine as C,projectBuffer as N,computeTranslationToOriginAndRotation as q,projectVectorToVector as k}from"../../../../geometry/projection.js";import{getSphericalPCPF as U,getReferenceEllipsoid as D}from"../../../../geometry/projectionEllipsoid.js";import z from"../../../../geometry/SpatialReference.js";import{create as _,empty as W,expandPointInPlace as F,intersects as O}from"../../../../geometry/support/aaBoundingRect.js";import{isPlateCarree as A}from"../../../../geometry/support/spatialReferenceUtils.js";import G from"../../../../rest/support/Query.js";import{readBinaryAttribute as K}from"./I3SBinaryReader.js";import{computeGlobalTransformation as L}from"./I3SProjectionUtil.js";import{createSolidEdgeMaterial as B,createMaterialFromEdges as P}from"../support/edgeUtils.js";import{parseColorMixMode as $,ColorMixModeEnum as Q}from"../support/symbolColorUtils.js";import{create as Z,compute as H,corners as J}from"../../support/orientedBoundingBox.js";function V(e){return e&&parseInt(e.substring(e.lastIndexOf("/")+1,e.length),10)}function X(e){if(a("disable-feature:i3s-draco")||!e)return!1;for(const t of e)for(const e of t.geometryBuffers)if("draco"===e.compressedAttributes?.encoding)return!0;return!1}function Y(e,t,r,n,o,a){const i=t!==n;o.traverse(r,(r=>{let o=r.mbs;i&&(o=oe,j(r.mbs,n,o,t));return ie(e,o)!==ae.OUTSIDE&&(a(r),!0)}))}function ee(e,t,r){let n=0,o=0;for(let a=0;a<t.length&&n<e.length;a++)e[n]===t[a]&&(r(a)&&(e[o]=e[n],o++),n++);e.length=o}function te(e,r,n){let o=0,a=0;for(;o<n.length;){t(e,n[o])>=0===r&&(n[a]=n[o],a++),o++}n.length=a}const re=_();function ne(e,t){if(0===t.rotationScale[1]&&0===t.rotationScale[2]&&0===t.rotationScale[3]&&0===t.rotationScale[5]&&0===t.rotationScale[6]&&0===t.rotationScale[7])return re[0]=(e[0]-t.position[0])/t.rotationScale[0],re[1]=(e[1]-t.position[1])/t.rotationScale[4],re[2]=(e[2]-t.position[0])/t.rotationScale[0],re[3]=(e[3]-t.position[1])/t.rotationScale[4],re}const oe=x();var ae;function ie(e,t){const r=t[0],n=t[1],o=t[3],a=e[0]-r,i=r-e[2],s=e[1]-n,c=n-e[3],l=Math.max(a,i,0),u=Math.max(s,c,0),f=l*l+u*u;if(f>o*o)return ae.OUTSIDE;if(f>0)return ae.INTERSECTS_CENTER_OUTSIDE;return-Math.max(a,i,s,c)>o?ae.INSIDE:ae.INTERSECTS_CENTER_INSIDE}function se(e,t){const r=t[0],n=t[1],o=t[2],a=t[3],i=e[0]-r,s=r-e[3],c=e[1]-n,l=n-e[4],u=e[2]-o,f=o-e[5],p=Math.max(i,s,0),m=Math.max(c,l,0),h=Math.max(u,f,0),d=p*p+m*m+h*h;if(d>a*a)return ae.OUTSIDE;if(d>0)return ae.INTERSECTS_CENTER_OUTSIDE;return-Math.max(i,s,c,l,u,f)>a?ae.INSIDE:ae.INTERSECTS_CENTER_INSIDE}function ce(e,t,r){const n=[],o=r&&r.missingFields,a=r&&r.originalFields;for(const i of e){const e=i.toLowerCase();let r=!1;for(const o of t)if(e===o.name.toLowerCase()){n.push(o.name),r=!0,a&&a.push(i);break}!r&&o&&o.push(i)}return n}async function le(e,t,n,a,c){if(0===t.length)return[];const l=e.attributeStorageInfo;if(i(e.associatedLayer))try{return await fe(e.associatedLayer,t,n,a)}catch(u){if(e.associatedLayer.loaded)throw u}if(l){const i=ue(t,n,c);if(s(i))throw new o("scenelayer:features-not-loaded","Tried to query attributes for unloaded features");const u=e.parsedUrl.path,f=await Promise.all(i.map((e=>me(u,l,e.node,e.indices,a).then((t=>{for(let r=0;r<e.graphics.length;r++){const n=e.graphics[r],o=t[r];if(n.attributes)for(const e in n.attributes)e in o||(o[e]=n.attributes[e]);n.attributes=o}return e.graphics})))));return r(f)}throw new o("scenelayer:no-attribute-source","This scene layer does not have a source for attributes available")}function ue(e,t,r){const n=new Map,o=[],a=r();for(const i of e){const e=i.attributes[t];for(let t=0;t<a.length;t++){const r=a[t],s=r.featureIds.indexOf(e);if(s>=0){let e=n.get(r.node);e||(e={node:r.node,indices:[],graphics:[]},o.push(e),n.set(r.node,e)),e.indices.push(s),e.graphics.push(i);for(let r=t;r>0;r--)a[r]=a[r-1];a[0]=r;break}}}return o}async function fe(e,t,r,n){t.sort(((e,t)=>e.attributes[r]-t.attributes[r]));const o=t.map((e=>e.attributes[r])),a=[],i=ce(n,e.fields,{originalFields:a}),s=await pe(e,o,i);for(let c=0;c<t.length;c++){const e=t[c],r=s[c],n={};if(e.attributes)for(const t in e.attributes)n[t]=e.attributes[t];for(let t=0;t<a.length;t++)n[a[t]]=r[i[t]];e.attributes=n}return t}function pe(e,t,a){const i=e.capabilities.query.maxRecordCount;if(null!=i&&t.length>i){const o=n(t,i);return Promise.all(o.map((t=>pe(e,t,a)))).then(r)}const s=new G({objectIds:t,outFields:a,orderByFields:[e.objectIdField]});return e.queryFeatures(s).then((e=>{if(e&&e.features&&e.features.length===t.length)return e.features.map((e=>e.attributes));throw new o("scenelayer:feature-not-in-associated-layer","Feature not found in associated feature layer")}))}function me(t,r,n,o,a){const i=[];for(const e of r)if(e&&a.includes(e.name)){const r=`${t}/nodes/${n.resources.attributes}/attributes/${e.key}/0`;i.push({url:r,storageInfo:e})}return c(i.map((t=>e(t.url,{responseType:"array-buffer"}).then((e=>K(t.storageInfo,e.data)))))).then((e=>{const t=[];for(const r of o){const n={};for(let t=0;t<e.length;t++)null!=e[t].value&&(n[i[t].storageInfo.name]=ye(e[t].value,r));t.push(n)}return t}))}!function(e){e[e.OUTSIDE=0]="OUTSIDE",e[e.INTERSECTS_CENTER_OUTSIDE=1]="INTERSECTS_CENTER_OUTSIDE",e[e.INTERSECTS_CENTER_INSIDE=2]="INTERSECTS_CENTER_INSIDE",e[e.INSIDE=3]="INSIDE"}(ae||(ae={}));const he=-32768,de=-(2**31);function ye(e,t){if(!e)return null;const r=e[t];if(l(e))return r===he?null:r;if(u(e))return r===de?null:r;return r!=r?null:r}function Se(e){const t=e.store.indexCRS||e.store.geographicCRS,r=void 0===t?e.store.indexWKT:void 0;if(r){if(!e.spatialReference)throw new o("layerview:no-store-spatial-reference-wkt-index-and-no-layer-spatial-reference","Found indeWKT in the scene layer store but no layer spatial reference",{});if(r!==e.spatialReference.wkt)throw new o("layerview:store-spatial-reference-wkt-index-incompatible","The indeWKT of the scene layer store does not match the WKT of the layer spatial reference",{})}const n=t?new z(V(t)):e.spatialReference;return n.equals(e.spatialReference)?e.spatialReference:n}function be(e){const t=e.store.vertexCRS||e.store.projectedCRS,r=void 0===t?e.store.vertexWKT:void 0;if(r){if(!e.spatialReference)throw new o("layerview:no-store-spatial-reference-wkt-vertex-and-no-layer-spatial-reference","Found vertexWKT in the scene layer store but no layer spatial reference",{});if(r!==e.spatialReference.wkt)throw new o("layerview:store-spatial-reference-wkt-vertex-incompatible","The vertexWKT of the scene layer store does not match the WKT of the layer spatial reference",{})}const n=t?new z(V(t)):e.spatialReference;return n.equals(e.spatialReference)?e.spatialReference:n}function ge(e,t){return s(t)?"@null":t===U(t)?"@ECEF":e.equals(t)?"":null!=t.wkid?"@"+t.wkid:null}function we(e,t,r){if(!C(e,t))throw new o("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});if("local"===r&&!Ee(e,t))throw new o("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{})}function Ee(e,t){return e.equals(t)||e.isWGS84&&t.isWebMercator||e.isWebMercator&&t.isWGS84}function Te(e,t,r){const n=Se(e),o=be(e);we(n,t,r),we(o,t,r)}function Ie(e){return(null==e.geometryType||"triangles"===e.geometryType)&&((null==e.topology||"PerAttributeArray"===e.topology)&&(null!=e.vertexAttributes&&null!=e.vertexAttributes.position))}function Me(e){if(null==e.store||null==e.store.defaultGeometrySchema||!Ie(e.store.defaultGeometrySchema))throw new o("scenelayer:unsupported-geometry-schema","The geometry schema of this scene layer is not supported.",{url:e.parsedUrl.path})}function ve(e,t){Te(e,t.spatialReference,t.viewingMode)}function Re(e){return null!=e.geometryType&&"points"===e.geometryType&&((null==e.topology||"PerAttributeArray"===e.topology)&&((null==e.encoding||""===e.encoding||"lepcc-xyz"===e.encoding)&&(null!=e.vertexAttributes&&null!=e.vertexAttributes.position)))}function xe(e){if(null==e.store||null==e.store.defaultGeometrySchema||!Re(e.store.defaultGeometrySchema))throw new o("pointcloud:unsupported-geometry-schema","The geometry schema of this point cloud scene layer is not supported.",{})}function je(e,t){we(e.spatialReference,t.spatialReference,t.viewingMode)}function Ce(e){return"simple"===e.type||"class-breaks"===e.type||"unique-value"===e.type}function Ne(e){return"mesh-3d"===e.type}function qe(e){if(null==e||!Ce(e))return!0;if(("unique-value"===e.type||"class-breaks"===e.type)&&null==e.defaultSymbol)return!0;const t=e.getSymbols();if(0===t.length)return!0;for(const r of t){if(!Ne(r)||0===r.symbolLayers.length)return!0;for(const e of r.symbolLayers.items)if("fill"!==e.type||s(e.material)||s(e.material.color)||"replace"!==e.material.colorMixMode)return!0}return!1}const ke=B({color:[0,0,0,0],opacity:0});class Ue{constructor(){this.edgeMaterial=null,this.material=null,this.castShadows=!0}}function De(e){const t=new Ue;let r=!1,n=!1;for(const o of e.symbolLayers.items)if("fill"===o.type&&o.enabled){const e=o.material,a=o.edges;if(i(e)&&!r){const n=e.color,a=$(e.colorMixMode);i(n)?t.material={color:[n.r/255,n.g/255,n.b/255],alpha:n.a,colorMixMode:a}:t.material={color:[1,1,1],alpha:1,colorMixMode:Q.Multiply},t.castShadows=o.castShadows,r=!0}i(a)&&!n&&(t.edgeMaterial=P(a,{}),n=!0)}return t.material||(t.material={color:[1,1,1],alpha:1,colorMixMode:Q.Multiply}),t}function ze(e,t){return(0|e)+(0|t)|0}function _e(e,t,r,n,o=0){n===U(n)?t.isGeographic?$e(e,r,t,o):Pe(e,r,t,o):t.isWGS84&&(n.isWebMercator||A(n))?We(t,e,n,r,o):t.isWebMercator&&A(n)?Le(t,e,n,r,o):e===r?(r.center[2]+=o,N(r.center,t,0,r.center,n,0,1)):(g(r.center,e.center[0],e.center[1],e.center[2]+o),N(r.center,t,0,r.center,n,0,1),d(r.quaternion,e.quaternion),w(r.halfSize,e.halfSize))}function We(e,t,r,n,o){w(Ge,t.center),Ge[2]+=o;const a=U(r);N(Ge,e,0,Ge,a,0,1),Be(a,t,Ge,r,n)}const Fe=new Float64Array(24),Oe={data:Fe,size:3},Ae=R(),Ge=R(),Ke=p();function Le(e,t,r,n,o){w(Ge,t.center),Ge[2]+=o,Be(e,t,Ge,r,n)}function Be(e,t,r,n,o){const a=f(Ke,t.quaternion);for(let i=0;i<8;++i){for(let e=0;e<3;++e)Ae[e]=t.halfSize[e]*(0!=(i&1<<e)?-1:1);for(let e=0;e<3;++e){let t=r[e];for(let r=0;r<3;++r)t+=Ae[r]*a[3*r+e];Fe[3*i+e]=t}}N(Fe,e,0,Fe,n,0,8),H(Oe,o)}function Pe(e,t,r,n){J(e,et),g(t.center,e.center[0],e.center[1],e.center[2]+n),q(r,t.center,Xe,U(r)),g(t.center,Xe[12],Xe[13],Xe[14]);const o=2*Math.sqrt(1+Xe[0]+Xe[5]+Xe[10]);Ye[0]=(Xe[6]-Xe[9])/o,Ye[1]=(Xe[8]-Xe[2])/o,Ye[2]=(Xe[1]-Xe[4])/o,Ye[3]=.25*o,y(t.quaternion,Ye,e.quaternion),S(Ye,t.quaternion);let a=0,i=0,s=0;for(const c of et)c[2]+=n,N(c,r,0,c,U(r),0,1),E(ot,c,t.center),T(ot,ot,Ye),a=Math.max(a,Math.abs(ot[0])),i=Math.max(i,Math.abs(ot[1])),s=Math.max(s,Math.abs(ot[2]));g(t.halfSize,a,i,s)}function $e(e,t,r,n){const o=D(r),a=1+Math.max(0,n)/(o.radius+e.center[2]);g(t.center,e.center[0],e.center[1],e.center[2]+n),N(t.center,r,0,t.center,U(r),0,1),d(t.quaternion,e.quaternion),S(Ye,e.quaternion),g(ot,0,0,1),T(ot,ot,Ye),g(ot,e.halfSize[0]*Math.abs(ot[0]),e.halfSize[1]*Math.abs(ot[1]),e.halfSize[2]*Math.abs(ot[2])),I(ot,ot,o.inverseFlattening),M(t.halfSize,e.halfSize,ot),I(t.halfSize,t.halfSize,a)}function Qe(e,t,r,n,o,a){if(!a||0===a.length||s(t))return null;const c=L(e.mbs,o,r,t);let l;m(it,c);const u=()=>{if(!l)if(l=et,W(rt),i(e.serviceObb)){_e(e.serviceObb,r,nt,t,o),J(nt,l);for(const e of l)v(e,e,it),F(rt,e)}else{const n=e.mbs,a=n[3];k(n,r,ot,t),v(ot,ot,it),ot[2]+=o;for(let e=0;e<8;++e){const t=1&e?a:-a,r=2&e?a:-a,n=4&e?a:-a,o=l[e];w(o,[ot[0]+t,ot[1]+r,ot[2]+n]),F(rt,o)}}};let f=1/0,p=-1/0;const h=e=>{if("replace"!==e.type)return;const r=e.geometry;if(!r.hasZ)return;W(tt);const o=r.spatialReference||n,a=r.rings.reduce(((e,r)=>r.reduce(((e,r)=>(k(r,o,ot,t),v(ot,ot,it),F(tt,ot),Math.min(ot[2],e))),e)),1/0);u(),O(rt,tt)&&(f=Math.min(f,a),p=Math.max(p,a))};if(a.forEach((e=>h(e))),f===1/0)return null;const d=(e,t,r)=>{v(ot,r,c),e[t+0]=ot[0],e[t+1]=ot[1],e[t+2]=ot[2],t+=24,r[2]=f,v(ot,r,c),e[t+0]=ot[0],e[t+1]=ot[1],e[t+2]=ot[2],t+=24,r[2]=p,v(ot,r,c),e[t+0]=ot[0],e[t+1]=ot[1],e[t+2]=ot[2]};for(let i=0;i<8;++i)d(at.data,3*i,l[i]);return H(at)}function Ze(e){return i(e)&&e.halfSize[0]>=0}function He(e){return e[3]>=0}function Je(e){i(e)&&(e.halfSize[0]=-1)}function Ve(e){i(e)&&(e[3]=-1)}const Xe=h(),Ye=b(),et=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],tt=_(),rt=_(),nt=Z(),ot=[0,0,0],at={data:new Array(72),size:3},it=h();export{ae as MbsIntersectResult,Ue as SymbolInfo,ze as addWraparound,je as checkPointCloudLayerCompatibleWithView,xe as checkPointCloudLayerValid,ve as checkSceneLayerCompatibleWithView,Me as checkSceneLayerValid,we as checkSpatialReference,Te as checkSpatialReferences,Qe as computeVisibilityObb,X as containsDraco,V as extractWkid,ee as filterInPlace,ce as findFieldsCaseInsensitive,Y as findIntersectingNodes,ge as getCacheKeySuffix,ye as getCachedAttributeValue,ne as getClipRect,Se as getIndexCrs,De as getSymbolInfo,be as getVertexCrs,se as intersectBoundingBoxWithMbs,ie as intersectBoundingRectWithMbs,Ve as invalidateMbs,Je as invalidateObb,Ee as isSupportedLocalModeProjection,He as isValidMbs,Ze as isValidObb,te as objectIdFilter,qe as rendererNeedsTextures,_e as transformObb,ke as transparentEdgeMaterial,le as whenGraphicAttributes};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as t,isNone as e}from"../../../../core/maybe.js";import{d as i,i as s,l as r,g as n,e as a,p as o,b as h,a as c}from"../../../../chunks/vec3.js";import{c as m}from"../../../../chunks/vec3f64.js";import{c as p}from"../../../../chunks/vec4.js";import{projectBoundingSphere as u}from"../../../../geometry/projection.js";import{getSphericalPCPF as _}from"../../../../geometry/projectionEllipsoid.js";import{create as l,fromMatrix as d,intersectsSphere as g}from"../../../../geometry/support/frustum.js";import{w as b}from"../../../../chunks/sphere.js";import{makeDehydratedPoint as f}from"../../../../layers/graphics/dehydratedFeatures.js";import{evaluateElevationAlignmentAtPoint as v}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as D}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as M,extractExpressionInfo as x}from"../graphics/featureExpressionInfoUtils.js";import{LodMetric as C}from"./I3SNode.js";import{transformObb as S,intersectBoundingRectWithMbs as R,MbsIntersectResult as P}from"./I3SUtil.js";import{create as E,isVisible as L}from"../../support/orientedBoundingBox.js";const O=1e5;class j{constructor(t,e,i,s,r,n,a,o={}){this._indexSR=t,this._renderCoordsHelper=e,this.clippingArea=r,this._elevationProvider=n,this._options=o,this._frustum=l(),this._useFrustumCulling=!1,this._poi=m(),this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._tmp1=m(),this._tmp2=m(),this._tmp3=m(),this._tmp0=m(),this._screenspaceErrorBias=o.screenspaceErrorBias||1,this._progressiveLoadFactor=o.progressiveLoadFactor||1,this.updateCamera(i,s),this.engineSR=this._renderCoordsHelper.spatialReference,this.updateElevationInfo(a),this._tmpPoint=f(0,0,0,t)}updateElevationInfo(t){null!=t?(this._elevationContext=D.fromElevationInfo(t),this._elevationContext.updateFeatureExpressionInfoContext(M(x(t,!1)))):this._elevationContext=null}updateCamera(t,e){this._useFrustumCulling=e,e&&d(t.viewMatrix,t.projectionMatrix,this._frustum),this._screenSizeFactor=1/(t.perScreenPixelRatio/2),this._camPos=t.eye,this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(t){this._poi=t}updateScreenSpaceErrorBias(t){const e=this._screenspaceErrorBias;return this._screenspaceErrorBias=t,e}updateClippingArea(t){this.clippingArea=t}getRenderMbs(t){const e=t.renderMbs;return e[3]<0&&(p(e,t.mbs),this._elevationContext&&e[3]<O&&(this._tmpPoint.x=e[0],this._tmpPoint.y=e[1],this._tmpPoint.z=e[2],e[2]=v(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper)),u(e,this._indexSR,e,this.engineSR)),e}getVisibilityObb(i){if(t(i.visibilityObb))return i.visibilityObb;const s=i.serviceObb;return e(s)||s.halfSize[0]<0?void 0:(i.serviceObbInRenderSR=this._computeRenderObb(s,i.serviceObbInRenderSR,i.mbs[3]),i.serviceObbInRenderSR)}_computeRenderObb(t,i,s){if(e(i)&&(i=E()),i.halfSize[0]<0){let e=0;this._elevationContext&&s<O&&(this._tmpPoint.x=t.center[0],this._tmpPoint.y=t.center[1],this._tmpPoint.z=t.center[2],e=v(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper)-t.center[2]),S(t,this._indexSR,i,this.engineSR,e)}return i}isNodeVisible(e){const i=this.getRenderMbs(e);if(!this._isMBSinClippingArea(i))return!1;if(!this._useFrustumCulling)return!0;const s=this.getVisibilityObb(e);return t(s)?L(s,this._frustum):g(this._frustum,b(i))}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const i=e.geometryObb;return t(i)?L(i,this._frustum):this.isNodeVisible(e)}_isMBSinClippingArea(t){return!!e(this.clippingArea)||R(this.clippingArea,t)!==P.OUTSIDE}_screenSpaceDiameterMbs(t,e){const s=this.getRenderMbs(t),r=Math.sqrt(i(s,this._camPos)),n=r-s[3];return this._updateMinMaxDistance(r),n<0?.5*Number.MAX_VALUE:e/n*this._screenSizeFactor}calcCameraDistance(t){return this.calcCameraDistanceToCenter(t)-this.getRenderMbs(t)[3]}calcCameraDistanceToCenter(t){const e=this.getRenderMbs(t),i=s(e,this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(t){const e=this.getRenderMbs(t),i=e[3],n=(Math.abs(e[0]*(e[0]-this._camPos[0])+e[1]*(e[1]-this._camPos[1])+e[2]*(e[2]-this._camPos[2]))/r(e)+i)/s(e,this._camPos);return Math.min(1,n)}hasLOD(t){return t.lodMetric!==C.None}_getDistancePlanarMode(t,e){const i=t[0]-e[0],s=t[1]-e[1],r=t[2]-e[2],n=i*i+s*s,a=e[3];if(n<=a*a)return Math.abs(r);const o=Math.sqrt(n)-a;return Math.sqrt(r*r+o*o)}_getDistanceGlobeMode(t,e){const m=r(e),p=r(t)-m;n(this._tmp0,t,a(t,e)/o(t));const u=i(e,this._tmp0),_=e[3];if(u<=_*_)return Math.abs(p);{const i=n(this._tmp0,e,1/m),o=m,u=_*_/2/o,l=n(this._tmp1,i,o-u),d=t,g=h(this._tmp2,d,l),b=h(this._tmp2,g,n(this._tmp3,i,a(i,g))),f=c(this._tmp2,l,n(this._tmp2,b,_/r(b)));let v=s(d,f);if(p>=2e5){const t=h(this._tmp1,d,f);let e=a(t,i)/r(t);e<.08&&(e=1e-4),v/=e}return v}}_getDistance(t,e){return this.engineSR===_(this.engineSR)?this._getDistanceGlobeMode(t,e):this._getDistancePlanarMode(t,e)}_updateMinMaxDistance(t){t>0?(this.minDistance=Math.min(this.minDistance,t),this.maxDistance=Math.max(this.maxDistance,t)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-t))}getLodLevel(t){if(t.lodMetric===C.None)return 0;if(0===t.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const e=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(t,e)?this.evaluateLODmetric(t,i)?2:1:0}return this.evaluateLODmetric(t,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(t,e){switch(t.lodMetric){case C.ScreenSpaceRelative:{const i=this.getRenderMbs(t),s=this._getDistance(this._camPos,i),r=2*s/this._screenSizeFactor,n=s+i[3];return this._updateMinMaxDistance(n),t.maxError*e<=r}case C.MaxScreenThreshold:{let i=this._screenSpaceDiameterMbs(t,t.mbs[3]*e);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(t)),i<t.maxError}case C.RemovedFeatureDiameter:return this._screenSpaceDiameterMbs(t,t.maxError)*e<10;case C.DistanceRangeFromDefaultCamera:return this.calcCameraDistance(t)>t.maxError*e}return!1}distToPOI(t){const e=this.getRenderMbs(t);return s(e,this._poi)-e[3]}distCameraToPOI(){return s(this._camPos,this._poi)}}export{j as default};
5
+ import{isSome as t,isNone as e}from"../../../../core/maybe.js";import{d as i,i as s,l as r,g as n,e as a,p as o,b as h,a as c}from"../../../../chunks/vec3.js";import{c as m}from"../../../../chunks/vec3f64.js";import{c as p}from"../../../../chunks/vec4.js";import{projectBoundingSphere as u}from"../../../../geometry/projection.js";import{getSphericalPCPF as _}from"../../../../geometry/projectionEllipsoid.js";import{create as l,fromMatrix as d,intersectsSphere as g}from"../../../../geometry/support/frustum.js";import{w as b}from"../../../../chunks/sphere.js";import{makeDehydratedPoint as f}from"../../../../layers/graphics/dehydratedFeatures.js";import{evaluateElevationAlignmentAtPoint as D}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as M}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as v,extractExpressionInfo as x}from"../graphics/featureExpressionInfoUtils.js";import{LodMetric as C}from"./I3SNode.js";import{isValidMbs as R,isValidObb as S,transformObb as P,intersectBoundingRectWithMbs as E,MbsIntersectResult as L}from"./I3SUtil.js";import{create as O,isVisible as j}from"../../support/orientedBoundingBox.js";const F=1e5;class y{constructor(t,e,i,s,r,n,a,o={}){this._indexSR=t,this._renderCoordsHelper=e,this.clippingArea=r,this._elevationProvider=n,this._options=o,this._frustum=l(),this._useFrustumCulling=!1,this._poi=m(),this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._tmp1=m(),this._tmp2=m(),this._tmp3=m(),this._tmp0=m(),this._screenspaceErrorBias=o.screenspaceErrorBias||1,this._progressiveLoadFactor=o.progressiveLoadFactor||1,this.updateCamera(i,s),this.engineSR=this._renderCoordsHelper.spatialReference,this.updateElevationInfo(a),this._tmpPoint=f(0,0,0,t)}updateElevationInfo(t){null!=t?(this._elevationContext=M.fromElevationInfo(t),this._elevationContext.updateFeatureExpressionInfoContext(v(x(t,!1)))):this._elevationContext=null}updateCamera(t,e){this._useFrustumCulling=e,e&&d(t.viewMatrix,t.projectionMatrix,this._frustum),this._screenSizeFactor=1/(t.perScreenPixelRatio/2),this._camPos=t.eye,this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(t){this._poi=t}updateScreenSpaceErrorBias(t){const e=this._screenspaceErrorBias;return this._screenspaceErrorBias=t,e}updateClippingArea(t){this.clippingArea=t}getRenderMbs(t){const e=t.renderMbs;return R(e)||(p(e,t.mbs),this._elevationContext&&e[3]<F&&(this._tmpPoint.x=e[0],this._tmpPoint.y=e[1],this._tmpPoint.z=e[2],e[2]=D(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper)),u(e,this._indexSR,e,this.engineSR)),e}getVisibilityObb(i){if(t(i.visibilityObb))return i.visibilityObb;const s=i.serviceObb;return e(s)||!S(s)?null:(i.serviceObbInRenderSR=this._computeRenderObb(s,i.serviceObbInRenderSR,i.mbs[3]),i.serviceObbInRenderSR)}_computeRenderObb(t,i,s){if(e(i))i=O();else if(S(i))return i;let r=0;return this._elevationContext&&s<F&&(this._tmpPoint.x=t.center[0],this._tmpPoint.y=t.center[1],this._tmpPoint.z=t.center[2],r=D(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper)-t.center[2]),P(t,this._indexSR,i,this.engineSR,r),i}isNodeVisible(e){const i=this.getRenderMbs(e);if(!this._isMBSinClippingArea(i))return!1;if(!this._useFrustumCulling)return!0;const s=this.getVisibilityObb(e);return t(s)?j(s,this._frustum):g(this._frustum,b(i))}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const i=e.geometryObb;return t(i)?j(i,this._frustum):this.isNodeVisible(e)}_isMBSinClippingArea(t){return!!e(this.clippingArea)||E(this.clippingArea,t)!==L.OUTSIDE}_screenSpaceDiameterMbs(t,e){const s=this.getRenderMbs(t),r=Math.sqrt(i(s,this._camPos)),n=r-s[3];return this._updateMinMaxDistance(r),n<0?.5*Number.MAX_VALUE:e/n*this._screenSizeFactor}calcCameraDistance(t){return this.calcCameraDistanceToCenter(t)-this.getRenderMbs(t)[3]}calcCameraDistanceToCenter(t){const e=this.getRenderMbs(t),i=s(e,this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(t){const e=this.getRenderMbs(t),i=e[3],n=(Math.abs(e[0]*(e[0]-this._camPos[0])+e[1]*(e[1]-this._camPos[1])+e[2]*(e[2]-this._camPos[2]))/r(e)+i)/s(e,this._camPos);return Math.min(1,n)}hasLOD(t){return t.lodMetric!==C.None}_getDistancePlanarMode(t,e){const i=t[0]-e[0],s=t[1]-e[1],r=t[2]-e[2],n=i*i+s*s,a=e[3];if(n<=a*a)return Math.abs(r);const o=Math.sqrt(n)-a;return Math.sqrt(r*r+o*o)}_getDistanceGlobeMode(t,e){const m=r(e),p=r(t)-m;n(this._tmp0,t,a(t,e)/o(t));const u=i(e,this._tmp0),_=e[3];if(u<=_*_)return Math.abs(p);{const i=n(this._tmp0,e,1/m),o=m,u=_*_/2/o,l=n(this._tmp1,i,o-u),d=t,g=h(this._tmp2,d,l),b=h(this._tmp2,g,n(this._tmp3,i,a(i,g))),f=c(this._tmp2,l,n(this._tmp2,b,_/r(b)));let D=s(d,f);if(p>=2e5){const t=h(this._tmp1,d,f);let e=a(t,i)/r(t);e<.08&&(e=1e-4),D/=e}return D}}_getDistance(t,e){return this.engineSR===_(this.engineSR)?this._getDistanceGlobeMode(t,e):this._getDistancePlanarMode(t,e)}_updateMinMaxDistance(t){t>0?(this.minDistance=Math.min(this.minDistance,t),this.maxDistance=Math.max(this.maxDistance,t)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-t))}getLodLevel(t){if(t.lodMetric===C.None)return 0;if(0===t.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const e=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(t,e)?this.evaluateLODmetric(t,i)?2:1:0}return this.evaluateLODmetric(t,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(t,e){switch(t.lodMetric){case C.ScreenSpaceRelative:{const i=this.getRenderMbs(t),s=this._getDistance(this._camPos,i),r=2*s/this._screenSizeFactor,n=s+i[3];return this._updateMinMaxDistance(n),t.maxError*e<=r}case C.MaxScreenThreshold:{let i=this._screenSpaceDiameterMbs(t,t.mbs[3]*e);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(t)),i<t.maxError}case C.RemovedFeatureDiameter:return this._screenSpaceDiameterMbs(t,t.maxError)*e<10;case C.DistanceRangeFromDefaultCamera:return this.calcCameraDistance(t)>t.maxError*e}return!1}distToPOI(t){const e=this.getRenderMbs(t);return s(e,this._poi)-e[3]}distCameraToPOI(){return s(this._camPos,this._poi)}}export{y as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{isNone as e,isSome as t,unwrapOr as r}from"../../../../core/maybe.js";import i from"../../../../core/PooledArray.js";import{castRenderScreenPointArray3 as n,createRenderScreenPointArray3 as s}from"../../../../core/screenUtils.js";import{a as o,n as a,g as c,l}from"../../../../chunks/vec3.js";import{c as h}from"../../../../chunks/vec3f64.js";import{create as u,copy as m,NEGATIVE_INFINITY as d,width as p,height as y,expandPointInPlace as g}from"../../../../geometry/support/aaBoundingRect.js";import{create as f}from"../../../../geometry/support/ray.js";import{sv3d as R}from"../../../../geometry/support/vectorStacks.js";import{ViewingMode as v}from"../../../ViewingMode.js";import{fromRenderAtEye as x,fromScreen as w}from"../../support/geometryUtils/ray.js";import{DEFAULT_TOLERANCE as b,newIntersector as I}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as M,IntersectorType as P}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as j,sliceFilterPredicate as E}from"../../webgl-engine/lib/intersectorUtils.js";class H{constructor(e,t,r){this.viewingMode=e,this._forEachLayer=t,this.view=r,this.externalIntersectionHandlers=new i,this.tolerance=b,this.tmpRay=f(),this.tmpRegion=u(),this.validateHUDIntersector=I(this.viewingMode),this.validateHUDIntersector.options.hud=!1}intersectScreen(e,t,r){return this.intersectRay(this._getPickRay(e,this.tmpRay),k(this.viewingMode),t,r)}intersectScreenFreePointFallback(e,t,r){return this.intersectRayFreePointFallback(this._getPickRay(e,this.tmpRay),t,r)}intersectRayFreePointFallback(e,t,r){return this.intersectRay(e,k(this.viewingMode),t,r)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,r,i){return t.options.selectionMode=!1,t.options.store=M.MIN,this.computeIntersection(e,t,i),!!t.results.min&&t.results.min.getIntersectionPoint(r)}getCenterRayWithSubpixelOffset(e,t,r=.5,i=.5){return e.getRenderCenter(N,r,i),N[0]+=.0466,N[1]-=.0123,x(e,N,t)}intersectIntersectorScreen(e,t,r){this.computeIntersection(this._getPickRay(e,this.tmpRay),t,r)}intersectToolIntersectorScreen(e,t,r){const i=this._getPickRay(e,this.tmpRay);this.intersectToolIntersectorRay(i,t,r)}intersectToolIntersectorRay(e,t,r){t.options.selectionMode=!0,this.computeIntersection(e,t,r);const i=t.results.min;!!this.view.basemapTerrain&&this.view.basemapTerrain.opaque||j(i)&&i.intersector!==P.TERRAIN||(t.options.selectionMode=!1,this.computeIntersection(e,t,r))}setTolerance(e=b){this.tolerance=e}addIntersectionHandler(e){this.externalIntersectionHandlers.push(e),this.externalIntersectionHandlers.sort(((e,t)=>e.type===P.TERRAIN?1:t.type===P.TERRAIN?-1:0))}removeIntersectionHandler(e){null!=this.externalIntersectionHandlers.removeUnordered(e)&&this.externalIntersectionHandlers.sort(((e,t)=>e.type===P.TERRAIN?1:t.type===P.TERRAIN?-1:0))}_getPickRay(e,t){const r=this.view.state.camera;return w(r,e,t)}_intersectRayFreePointLocal(t,r){if(this.viewingMode!==v.Local||e(t))return!1;const i=this.view.renderDataExtent;if(e(i))return o(r,t.origin,a(R.get(),t.direction)),!0;const n={x:i.xmax-i.xmin,y:i.ymax-i.ymin,z:8*Math.max(i.xmax-i.xmin,i.ymax-i.ymin)},s=Math.max(n.x,n.y,n.z);if(0===s)return o(r,t.origin,a(R.get(),t.direction)),!0;const h=this.view.state.camera,u=Math.max(0,i.xmin-h.eye[0],h.eye[0]-i.xmax),m=Math.max(0,i.ymin-h.eye[1],h.eye[1]-i.ymax),d=Math.sqrt(u*u+m*m),p=Math.abs(h.relativeElevation)+Number.MIN_VALUE,y=Math.max(0,Math.log(s/p))**2;let g=s/Math.max(1,y);g=Math.max(g,Math.min(d,s));const f=c(R.get(),t.direction,g/l(t.direction));return o(r,t.origin,f),!0}intersectElevationFromScreen(e,t,r=0,i=null){return this._intersectElevation(this._getPickRay(e,this.tmpRay),t,r,i)}_intersectElevation(i,s,a=0,c=null){if(e(i))return null;const l=t(s)?s.mode:"absolute-height",h=t(s)?r(s.offset,0):0,u="on-the-ground"!==l?h+a:0,m=u/this.view.renderCoordsHelper.unitInMeters;if("absolute-height"===l){if(this.view.renderCoordsHelper.intersectInfiniteManifold(i,u,S)){const e=this.view.computeMapPointFromVec3d(S);return e.z-=h,e}return null}const d=this.view.state.camera,p=n(R.get());d.projectToRenderScreen(i.origin,p);const y=new A(null,this._forEachLayer),g=this.view.slicePlane,f=t(g)?E(g):null,v=I(this.viewingMode);v.options.store=M.MIN,v.options.verticalOffset=m;const x=i.origin,w=o(R.get(),x,i.direction);v.reset(x,w,d),v.point=p;const b=t(c)?"type"in c&&"graphics"===c.type?e=>e.metadata.layerUid!==c.uid:e=>e.metadata.graphicUid!==c.uid:null;switch(l){case"relative-to-scene":{const t=t=>(e(b)||b(t))&&t.metadata&&t.metadata.isElevationSource;v.intersect(y.layers,p,this.tolerance,null,t),this.externalIntersectionHandlers.forAll((e=>{if(e.type===P.I3S||e.type===P.TERRAIN){const t=e.slicePlaneEnabled?f:null;e.intersect(v,t,v.rayBegin,v.rayEnd,p)}}))}break;case"on-the-ground":case"relative-to-ground":this.externalIntersectionHandlers.forAll((e=>{if(e.isGround){const t=e.slicePlaneEnabled?f:null;e.intersect(v,t,v.rayBegin,v.rayEnd,p)}}))}if(v.results.min.getIntersectionPoint(S)){const e=this.view.computeMapPointFromVec3d(S);return e.z=a,e}return null}computeIntersection(i,s,a){if(e(i))return;const c=this.view.state.camera,l=n(R.get());c.projectToRenderScreen(i.origin,l);const h=new A(a,this._forEachLayer);s.options.selectOpaqueTerrainOnly=!a||!("include"in a||"exclude"in a);const u=i.origin,m=o(R.get(),i.origin,i.direction);s.reset(u,m,c),s.intersect(h.layers,l,this.tolerance);const d=this.view.slicePlane,p=t(d)?E(d):null;s.intersect(h.sliceableLayers,l,this.tolerance,p);const y=a&&(a.requiresGroundFeedback||a.enableDraped);this.externalIntersectionHandlers.forAll((e=>{if(s.options.isFiltered=!h.filterLayerUid(e.layerUid),e.isGround&&y||!s.options.isFiltered){const t=e.slicePlaneEnabled?p:null;e.intersect(s,t,u,m,l)}}));const g=R.get();if(a&&a.enableDraped&&s.results.ground.getIntersectionPoint(g)){const e=this.view.basemapTerrain.overlayManager.renderer,t=this.view.renderCoordsHelper.spatialReference,i=R.get();this.view.renderCoordsHelper.fromRenderCoords(g,i,this.view.spatialReference),i[2]=r(this.view.elevationProvider.getElevation(g[0],g[1],g[2],t,"ground"),0),e.intersect(s,i,s.results.ground,(e=>h.filterRenderGeometry(e)))}s.sortResults(),this._processHUDResults(s)}_processHUDResults(r){const i=r.results.hud;m(this.tmpRegion,d);const n=this.view.state.camera,s=[],o=this.tmpRegion,a=e=>{const t=new T(e);n.projectToRenderScreen(e.target.center,t.screenPoint),t.screenPoint[0]=Math.floor(t.screenPoint[0]),t.screenPoint[1]=Math.floor(t.screenPoint[1]),s.push(t),g(o,t.screenPoint)};r.sortResults(i.all),t(i.min.dist)&&a(i.min);for(const e of i.all)i.min.target.object!==e.target.object&&i.max.target.object!==e.target.object&&a(e);if(t(i.max.dist)&&i.max.target.object!==i.min.target.object&&a(i.max),!s.length)return;o[0]===o[2]&&(o[2]+=1),o[1]===o[3]&&(o[3]+=1);const c=n.fullWidth,l=n.fullHeight,h=Math.max(0,o[0]-U),u=Math.max(0,o[1]-U),f=Math.min(p(o)+2*U,c-h),R=Math.min(y(o)+2*U,l-u),v=new Uint8Array(f*R*4);this.view._stage.renderView.readHUDVisibility(h,u,f,R,v);let x=!0;const w=e(r.results.max.dist);let b=0;for(const e of s)for(const t of L){if(v[4*(Math.min(e.screenPoint[0]+t[0],c)-o[0]+(Math.min(e.screenPoint[1]+t[1],l)-o[1])*f)]){x&&(r.results.min.copy(e.result),x=!1),w&&r.results.max.copy(e.result),r.options.store===M.ALL&&r.results.all.splice(b++,0,e.result);break}}}}const U=1,L=(()=>{const e=[],t=U;for(let r=-t;r<=t;r++)for(let i=-t;i<=t;i++)e.push([i+t,r+t]);return e})();class T{constructor(e){this.result=e,this.screenPoint=s()}}let _;function k(e){return _&&_.viewingMode===e||(_=I(e)),_}class A{constructor(e,t){this.layers=new Array,this.sliceableLayers=new Array,this.include=e?.include,this.exclude=e?.exclude,t((e=>{e.isPickable&&this.filterLayerUid(e.apiLayerUid)&&(e.isSliceable?this.sliceableLayers:this.layers).push(e)}))}filterLayerUid(t){const{include:r,exclude:i}=this;return e(t)?null==r&&null==i:(null==r||r.has(t))&&(null==i||!i.has(t))}filterRenderGeometry(e){return this.filterLayerUid(e.layerUid)}}function F(e){return"object"==typeof e&&"intersect"in e}const S=h(),N=s();export{H as SceneIntersectionHelper,F as isIntersectionHandler};
5
+ import{isNone as e,isSome as t,unwrapOr as r}from"../../../../core/maybe.js";import i from"../../../../core/PooledArray.js";import{castRenderScreenPointArray3 as n,createRenderScreenPointArray3 as s}from"../../../../core/screenUtils.js";import{a as o,n as a,g as c,l}from"../../../../chunks/vec3.js";import{c as h}from"../../../../chunks/vec3f64.js";import{create as u,copy as m,NEGATIVE_INFINITY as d,width as p,height as y,expandPointInPlace as g}from"../../../../geometry/support/aaBoundingRect.js";import{create as f}from"../../../../geometry/support/ray.js";import{sv3d as R}from"../../../../geometry/support/vectorStacks.js";import{ViewingMode as v}from"../../../ViewingMode.js";import{fromRenderAtEye as x,fromScreen as w}from"../../support/geometryUtils/ray.js";import{DEFAULT_TOLERANCE as b,newIntersector as I}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as M,IntersectorType as P}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as j,sliceFilterPredicate as E}from"../../webgl-engine/lib/intersectorUtils.js";class H{constructor(e,t,r){this.viewingMode=e,this._forEachLayer=t,this.view=r,this.externalIntersectionHandlers=new i,this.tolerance=b,this.tmpRay=f(),this.tmpRegion=u(),this.validateHUDIntersector=I(this.viewingMode),this.validateHUDIntersector.options.hud=!1}intersectScreen(e,t,r){return this.intersectRay(this._getPickRay(e,this.tmpRay),k(this.viewingMode),t,r)}intersectScreenFreePointFallback(e,t,r){return this.intersectRayFreePointFallback(this._getPickRay(e,this.tmpRay),t,r)}intersectRayFreePointFallback(e,t,r){return this.intersectRay(e,k(this.viewingMode),t,r)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,r,i){return t.options.selectionMode=!1,t.options.store=M.MIN,this.computeIntersection(e,t,i),!!t.results.min&&t.results.min.getIntersectionPoint(r)}getCenterRayWithSubpixelOffset(e,t,r=.5,i=.5){return e.getRenderCenter(N,r,i),N[0]+=.0466,N[1]-=.0123,x(e,N,t)}intersectIntersectorScreen(e,t,r){this.computeIntersection(this._getPickRay(e,this.tmpRay),t,r)}intersectToolIntersectorScreen(e,t,r){const i=this._getPickRay(e,this.tmpRay);this.intersectToolIntersectorRay(i,t,r)}intersectToolIntersectorRay(e,t,r){t.options.selectionMode=!0,this.computeIntersection(e,t,r);const i=t.results.min;!!this.view.basemapTerrain&&this.view.basemapTerrain.opaque||j(i)&&i.intersector!==P.TERRAIN||(t.options.selectionMode=!1,this.computeIntersection(e,t,r))}setTolerance(e=b){this.tolerance=e}addIntersectionHandler(e){this.externalIntersectionHandlers.push(e),this.externalIntersectionHandlers.sort(((e,t)=>e.type===P.TERRAIN?1:t.type===P.TERRAIN?-1:0))}removeIntersectionHandler(e){null!=this.externalIntersectionHandlers.removeUnordered(e)&&this.externalIntersectionHandlers.sort(((e,t)=>e.type===P.TERRAIN?1:t.type===P.TERRAIN?-1:0))}_getPickRay(e,t){const r=this.view.state.camera;return w(r,e,t)}_intersectRayFreePointLocal(t,r){if(this.viewingMode!==v.Local||e(t))return!1;const i=this.view.renderDataExtent;if(e(i))return o(r,t.origin,a(R.get(),t.direction)),!0;const n={x:i.xmax-i.xmin,y:i.ymax-i.ymin,z:8*Math.max(i.xmax-i.xmin,i.ymax-i.ymin)},s=Math.max(n.x,n.y,n.z);if(0===s)return o(r,t.origin,a(R.get(),t.direction)),!0;const h=this.view.state.camera,u=Math.max(0,i.xmin-h.eye[0],h.eye[0]-i.xmax),m=Math.max(0,i.ymin-h.eye[1],h.eye[1]-i.ymax),d=Math.sqrt(u*u+m*m),p=Math.abs(h.relativeElevation)+Number.MIN_VALUE,y=Math.max(0,Math.log(s/p))**2;let g=s/Math.max(1,y);g=Math.max(g,Math.min(d,s));const f=c(R.get(),t.direction,g/l(t.direction));return o(r,t.origin,f),!0}intersectElevationFromScreen(e,t,r=0,i=null){return this._intersectElevation(this._getPickRay(e,this.tmpRay),t,r,i)}_intersectElevation(i,s,a=0,c=null){if(e(i))return null;const l=t(s)?s.mode:"absolute-height",h=t(s)?r(s.offset,0):0,u="on-the-ground"!==l?h+a:0,m=u/this.view.renderCoordsHelper.unitInMeters;if("absolute-height"===l){if(this.view.renderCoordsHelper.intersectInfiniteManifold(i,u,S)){const e=this.view.computeMapPointFromVec3d(S);return e.z-=h,e}return null}const d=this.view.state.camera,p=n(R.get());d.projectToRenderScreen(i.origin,p);const y=new A(null,this._forEachLayer),g=this.view.slicePlane,f=t(g)?E(g):null,v=I(this.viewingMode);v.options.store=M.MIN,v.options.verticalOffset=m;const x=i.origin,w=o(R.get(),x,i.direction);v.reset(x,w,d),v.point=p;const b=t(c)?"type"in c&&"graphics"===c.type?e=>e.metadata.layerUid!==c.uid:e=>e.metadata.graphicUid!==c.uid:null;switch(l){case"relative-to-scene":{const t=t=>(e(b)||b(t))&&t.metadata&&t.metadata.isElevationSource;v.intersect(y.layers,p,this.tolerance,null,t),this.externalIntersectionHandlers.forAll((e=>{if(e.type===P.I3S||e.type===P.TERRAIN){const t=e.slicePlaneEnabled?f:null;e.intersect(v,t,v.rayBegin,v.rayEnd,p)}}))}break;case"on-the-ground":case"relative-to-ground":this.externalIntersectionHandlers.forAll((e=>{if(e.isGround){const t=e.slicePlaneEnabled?f:null;e.intersect(v,t,v.rayBegin,v.rayEnd,p)}}))}if(v.results.min.getIntersectionPoint(S)){const e=this.view.computeMapPointFromVec3d(S);return e.z=a,e}return null}computeIntersection(i,s,a){if(e(i))return;const c=this.view.state.camera,l=n(R.get());c.projectToRenderScreen(i.origin,l);const h=new A(a,this._forEachLayer);s.options.selectOpaqueTerrainOnly=!a||!("include"in a||"exclude"in a);const u=i.origin,m=o(R.get(),i.origin,i.direction);s.reset(u,m,c),s.intersect(h.layers,l,this.tolerance);const d=this.view.slicePlane,p=t(d)?E(d):null;s.intersect(h.sliceableLayers,l,this.tolerance,p);const y=a&&(a.requiresGroundFeedback||a.enableDraped);this.externalIntersectionHandlers.forAll((e=>{if(s.options.isFiltered=!h.filterLayerUid(e.layerUid),e.isGround&&y||!s.options.isFiltered){const t=e.slicePlaneEnabled?p:null;e.intersect(s,t,u,m,l)}}));const g=R.get();if(a&&a.enableDraped&&s.results.ground.getIntersectionPoint(g)){const e=this.view.basemapTerrain,t=e.overlayManager.renderer,i=this.view.renderCoordsHelper.spatialReference,n=R.get();this.view.renderCoordsHelper.fromRenderCoords(g,n,e.spatialReference),n[2]=r(this.view.elevationProvider.getElevation(g[0],g[1],g[2],i,"ground"),0),t.intersect(s,n,s.results.ground,(e=>h.filterRenderGeometry(e)))}s.sortResults(),this._processHUDResults(s)}_processHUDResults(r){const i=r.results.hud;m(this.tmpRegion,d);const n=this.view.state.camera,s=[],o=this.tmpRegion,a=e=>{const t=new T(e);n.projectToRenderScreen(e.target.center,t.screenPoint),t.screenPoint[0]=Math.floor(t.screenPoint[0]),t.screenPoint[1]=Math.floor(t.screenPoint[1]),s.push(t),g(o,t.screenPoint)};r.sortResults(i.all),t(i.min.dist)&&a(i.min);for(const e of i.all)i.min.target.object!==e.target.object&&i.max.target.object!==e.target.object&&a(e);if(t(i.max.dist)&&i.max.target.object!==i.min.target.object&&a(i.max),!s.length)return;o[0]===o[2]&&(o[2]+=1),o[1]===o[3]&&(o[3]+=1);const c=n.fullWidth,l=n.fullHeight,h=Math.max(0,o[0]-U),u=Math.max(0,o[1]-U),f=Math.min(p(o)+2*U,c-h),R=Math.min(y(o)+2*U,l-u),v=new Uint8Array(f*R*4);this.view._stage.renderView.readHUDVisibility(h,u,f,R,v);let x=!0;const w=e(r.results.max.dist);let b=0;for(const e of s)for(const t of L){if(v[4*(Math.min(e.screenPoint[0]+t[0],c)-o[0]+(Math.min(e.screenPoint[1]+t[1],l)-o[1])*f)]){x&&(r.results.min.copy(e.result),x=!1),w&&r.results.max.copy(e.result),r.options.store===M.ALL&&r.results.all.splice(b++,0,e.result);break}}}}const U=1,L=(()=>{const e=[],t=U;for(let r=-t;r<=t;r++)for(let i=-t;i<=t;i++)e.push([i+t,r+t]);return e})();class T{constructor(e){this.result=e,this.screenPoint=s()}}let _;function k(e){return _&&_.viewingMode===e||(_=I(e)),_}class A{constructor(e,t){this.layers=new Array,this.sliceableLayers=new Array,this.include=e?.include,this.exclude=e?.exclude,t((e=>{e.isPickable&&this.filterLayerUid(e.apiLayerUid)&&(e.isSliceable?this.sliceableLayers:this.layers).push(e)}))}filterLayerUid(t){const{include:r,exclude:i}=this;return e(t)?null==r&&null==i:(null==r||r.has(t))&&(null==i||!i.has(t))}filterRenderGeometry(e){return this.filterLayerUid(e.layerUid)}}function F(e){return"object"==typeof e&&"intersect"in e}const S=h(),N=s();export{H as SceneIntersectionHelper,F as isIntersectionHandler};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Evented.js";import{HandleOwner as i}from"../../core/HandleOwner.js";import{clone as o}from"../../core/lang.js";import{isNone as n,isSome as r,destroyMaybe as s,unwrap as a,unwrapOr as p,equalsMaybe as l}from"../../core/maybe.js";import{ignoreAbortErrors as c}from"../../core/promiseUtils.js";import{createLength as h,createArea as d}from"../../core/quantityUtils.js";import{watch as m,syncAndInitial as g,initial as u}from"../../core/reactiveUtils.js";import{createScreenPoint as v}from"../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as y}from"../../core/unitUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as x}from"../../core/accessorSupport/decorators/subclass.js";import{pointEquals as f}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getConvertedElevation as T}from"../../support/elevationInfoUtils.js";import{ViewingMode as O}from"../ViewingMode.js";import{defaultDrawingMode as w}from"./DrawingMode.js";import{DrawManipulator as V}from"./DrawManipulator.js";import{createCoordinateHelper as b}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as M,Component as D}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as C}from"../interactive/editGeometry/EditGeometryOperations.js";import I from"../interactive/sketch/SketchLabelOptions.js";import E from"../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as P}from"../interactive/snapping/SnappingContext.js";import{SnappingPipeline as j}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as k}from"../interactive/snapping/SnappingOperation.js";import{DrawPolygonTooltipInfo as G,DrawPolylineTooltipInfo as H,DrawPointTooltipInfo as L}from"../interactive/tooltip/DrawTooltipInfos.js";import{Tooltip as Z}from"../interactive/tooltip/Tooltip.js";import{computeAreaWithStagedVertex as A,computeLengthWithStagedVertex as U}from"../interactive/tooltip/support/measurements.js";let z=class extends(e.EventedMixin(i)){constructor(t){super(t),this._createOperationCompleted=!1,this._pointerDownStates=new Set,this._snappingPipeline=new j,this._tooltip=null,this._tooltipContext={calculateElevation:null,calculateTotalLength:null,calculateArea:null},this.labelOptions=new I,this.tooltipOptions=new E,this.snapToSceneEnabled=null,n(t.elevationInfo)&&(this.elevationInfo={mode:t.hasZ?"absolute-height":"on-the-ground",offset:0})}initialize(){const{geometryType:t,view:e}=this,{spatialReference:i}=e,o="viewingMode"in e.state?e.state.viewingMode:O.Local,a="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=b(this.hasZ,this.hasM,i),this._editGeometryOperations=new C(new M(a,this.coordinateHelper)),this._snappingOperation=new k({view:e}),this.handles.add(m((()=>this.stagedVertex),(t=>{r(this._tooltip)&&this._updateTooltipInfo(),n(t)||this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(t)}],operation:"apply",type:"vertex-update"})}),{sync:!0,equals:(t,e)=>l(t,e,f)})),this._activeComponent=new D(i,o),this._editGeometryOperations.data.components.push(this._activeComponent);const p=this.segmentLabels;r(p)&&(p.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo},this.handles.add([m((()=>this.labelOptions.enabled),(t=>{p.visible=t}),g),this.on("cursor-update",(()=>{const t=this.stagedVertex;p.stagedVertex=r(t)?this.coordinateHelper.pointToVector(t):null}))])),this.handles.add(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(t=>{const e=t.vertices.map((t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)}))),i=e.map((t=>t.coordinates));switch(t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}}))),this._manipulator=new V({grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size}),this.manipulators.add(this._manipulator),this._manipulator.grabbable="point"!==t,this.handles.add([this._createManipulatorDragPipeline(this._manipulator),this._manipulator.events.on("immediate-click",(t=>this._onImmediateClick(t))),this._manipulator.events.on("immediate-double-click",(t=>this._onImmediateDoubleClick(t))),m((()=>this.tooltipOptions.enabled),(t=>{this._tooltip=t?new Z({view:e,info:this._getTooltipInfo()}):s(this._tooltip)}),u)])}destroy(){s(this.segmentLabels),s(this._snappingOperation),this._tooltip=s(this._tooltip),this._editGeometryOperations=s(this._editGeometryOperations)}get _snappingEnabled(){return r(this.snappingManager)&&this.snappingManager.options.effectiveEnabled}get _defaultElevation(){return h(this.defaultZ,"meters")}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((t=>this.coordinateHelper.vectorToArray(t.pos)))}set drawingMode(t){this._set("drawingMode",t??w)}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return r(this.stagedVertex)?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get stagedVertex(){return this._snappingOperation.stagedPoint}set stagedVertex(t){this._snappingOperation.stagedPoint=o(t)}get updating(){return this.updatingHandles.updating}get vertices(){const t=this.committedVertices;return r(this.stagedVertex)&&t.push(this.coordinateHelper.pointToArray(this.stagedVertex)),t}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingOperation.abort(),r(this.stagedVertex)){const{stagedVertex:t}=this;this.stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t))}}complete(t){const e=t&&t.aborted||!1;this._snappingOperation.abort(),r(this.snappingManager)&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.stagedVertex=null;const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||e)&&this.emit("complete",{vertices:this.vertices.map(((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t}))),aborted:e,type:"complete"})}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){r(this.snappingManager)&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(t){const e=this._activeComponent;if("polygon"===this.geometryType&&e.vertices.length>2){if(this._vertexWithinPointerDistance(e.vertices[0].pos,t))return 0;if(this._vertexWithinPointerDistance(e.vertices[e.vertices.length-1].pos,t))return e.vertices.length-1}return null}_createManipulatorDragPipeline(t){switch(a(this.drawingMode)){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return S(t,((t,e,i,o)=>{const n="touch"===o&&this._snappingEnabled;!this.isCompleted&&n&&(e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this.stagedVertex=t.mapStart,("segment"===this.geometryType||n&&0===this.numVertices)&&this.commitStagedVertex()),t))).next(this._snappingPipeline.createSnapDragEventPipelineStep({predicate:()=>n,cancel:i,snappingManager:this.snappingManager,snappingContext:new P({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:o,visualizer:this.snappingVisualizer}),updatingHandles:this.updatingHandles}),this._snappingPipeline.next).next((t=>(n&&(this.stagedVertex=t.mapEnd,"end"===t.action&&this.commitStagedVertex()),t))).next((t=>("end"===t.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t))),i.next((()=>{n&&r(this.snappingManager)&&this.snappingManager.doneSnapping()})))}))}_createManipulatorDragPipelineFreehand(t){return S(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(n(this.stagedVertex)&&(this.stagedVertex=t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this.stagedVertex=t.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t}))}))}_createManipulatorDragPipelineHybrid(t){return S(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(n(this.stagedVertex)&&(this.stagedVertex=t.mapStart),this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this.stagedVertex=t.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t}))}))}_getDrawSurface(){if(n(this.elevationDrawSurface))return this.drawSurface;if(!this.coordinateHelper.hasZ)return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let t=this.defaultZ,e=!1;r(this.elevationInfo)&&"absolute-height"===this.elevationInfo.mode&&(e=!0),r(this.snapToSceneEnabled)&&(e=this.snapToSceneEnabled),r(this.elevationInfo)&&"on-the-ground"===this.elevationInfo.mode&&(e=!1);const i=this._activeComponent.vertices.length;return("segment"===this.geometryType||"polygon"===this.geometryType)&&i>0&&(t=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),e=!1),e?this.drawSurface:(this.elevationDrawSurface.defaultZ=t,this.elevationDrawSurface)}_mapToScreen(t){return this._getDrawSurface().mapToScreen(t)}_onHold(t){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&(this.stagedVertex=t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging)return;const e=this._activeComponent,i=this._closeOnClickVertexIndex(t.screenPoint);if(r(i))return t.stopPropagation(),void this.complete();const o=this._screenToMap(t.screenPoint);if(r(o))switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(r(this.stagedVertex)?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(o)),this.complete());break;case"click":case"hybrid":this._snappingOperation.abort(),r(this.stagedVertex)?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(o)),("point"===this.geometryType||"segment"===this.geometryType&&2===e.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===e.vertices.length)&&this.complete()}t.stopPropagation()}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){const e=v(t.x,t.y);if(this._manipulator.dragging||this._pointerDownStates.has(t.pointerId)||this._manipulator.grabbing||!this._manipulator.interactive)return void this._snappingOperation.abort();t.stopPropagation();const i=this._closeOnClickVertexIndex(e);if(r(i))return this._closeOnVertex(i),void this._snappingOperation.abort();const o=this._screenToMap(e);if(this._manipulator.cursor=r(o)?"crosshair":null,n(o))return void this._snappingOperation.abort();if(n(this.snappingManager))return this.stagedVertex=o,void this._snappingOperation.abort();const s=this.snappingManager,a=new P({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t.pointerType,visualizer:this.snappingVisualizer});this.updatingHandles.addPromise(c(this._snappingOperation.snap(o,s,a)))}_closeOnVertex(t){this.stagedVertex=null;const e={componentIndex:0,vertexIndex:t,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[t].pos)};this.emit("cursor-update",{updated:null,vertices:[e],operation:"apply",type:"vertex-update"})}_screenToMap(t){return this._getDrawSurface().screenToMap(t)}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),n(t))return null;const i=this._screenToMap(e.screenEnd);return r(i)?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,o=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return!!r(o)&&F(o,e,i)}_calculateVertexTooltipElevation(t){const{tooltipOptions:e,view:i}=this;if(n(t)||"2d"===i.type)return this._defaultElevation;const o=this.elevationInfo,r=e.elevation.mode,{spatialReference:s}=t,a=y(s),p=T(i,t,o,{mode:r,offset:0});return h(p*a,"meters")}_getTooltipInfo(){const{tooltipOptions:t}=this;if(!t.enabled)return null;this._tooltipContext.calculateElevation=t=>this._calculateVertexTooltipElevation(t);const{stagedVertex:e}=this,i=this._elevationTooltipDetail(e);switch(this.geometryType){case"point":return new L({tooltipOptions:t,elevation:i});case"polyline":return this._tooltipContext.calculateTotalLength=t=>U(this._editGeometryOperations.data.geometry)(t),new H({tooltipOptions:t,elevation:i,totalLength:this._totalLengthTooltipDetail(e)});case"polygon":return this._tooltipContext.calculateArea=t=>A(this._editGeometryOperations.data.geometry)(t),new G({tooltipOptions:t,elevation:i,area:this._areaTooltipDetail(e)});default:return null}}_elevationTooltipDetail(t){return{mode:this.elevationInfo.mode,...a(this._tooltipContext.calculateElevation)(t)}}_totalLengthTooltipDetail(t){return{...p(a(this._tooltipContext.calculateTotalLength)(t),h(0,"meters"))}}_areaTooltipDetail(t){return{...p(a(this._tooltipContext.calculateArea)(t),d(0,"square-meters"))}}_updateTooltipInfo(){const t=this._tooltip;if(n(t))return;const{stagedVertex:e}=this,i=this._elevationTooltipDetail(e);switch(this.geometryType){case"point":t.info.elevation=i;break;case"polyline":{const o=t.info;o.elevation=i,o.totalLength=this._totalLengthTooltipDetail(e);break}case"polygon":{const o=t.info;o.elevation=i,o.area=this._areaTooltipDetail(e);break}}}get test(){return{tooltip:this._tooltip}}};function F(t,e,i){const o=t.x-e.x,n=t.y-e.y;return o*o+n*n<=i}t([_()],z.prototype,"_defaultElevation",null),t([_()],z.prototype,"defaultZ",void 0),t([_({value:w})],z.prototype,"drawingMode",null),t([_({constructOnly:!0})],z.prototype,"elevationDrawSurface",void 0),t([_({constructOnly:!0})],z.prototype,"elevationInfo",void 0),t([_({constructOnly:!0,type:I})],z.prototype,"labelOptions",void 0),t([_({constructOnly:!0,type:E})],z.prototype,"tooltipOptions",void 0),t([_({constructOnly:!0})],z.prototype,"geometryType",void 0),t([_({constructOnly:!0})],z.prototype,"hasM",void 0),t([_({constructOnly:!0})],z.prototype,"hasZ",void 0),t([_({constructOnly:!0})],z.prototype,"manipulators",void 0),t([_({constructOnly:!0})],z.prototype,"drawSurface",void 0),t([_({constructOnly:!0})],z.prototype,"segmentLabels",void 0),t([_({constructOnly:!0})],z.prototype,"snappingManager",void 0),t([_({constructOnly:!0})],z.prototype,"snappingVisualizer",void 0),t([_()],z.prototype,"snapToSceneEnabled",void 0),t([_()],z.prototype,"_snappingOperation",void 0),t([_()],z.prototype,"stagedVertex",null),t([_()],z.prototype,"updating",null),t([_({constructOnly:!0})],z.prototype,"view",void 0),z=t([x("esri.views.draw.DrawOperation")],z);export{z as DrawOperation};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Evented.js";import{HandleOwner as i}from"../../core/HandleOwner.js";import{clone as o}from"../../core/lang.js";import{isNone as n,isSome as r,destroyMaybe as s,unwrap as a,unwrapOr as p,equalsMaybe as l}from"../../core/maybe.js";import{ignoreAbortErrors as c}from"../../core/promiseUtils.js";import{createLength as h,createArea as d}from"../../core/quantityUtils.js";import{watch as m,syncAndInitial as g,initial as u}from"../../core/reactiveUtils.js";import{createScreenPoint as v}from"../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as y}from"../../core/unitUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as x}from"../../core/accessorSupport/decorators/subclass.js";import{pointEquals as f}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getConvertedElevation as T}from"../../support/elevationInfoUtils.js";import{ViewingMode as O}from"../ViewingMode.js";import{defaultDrawingMode as w}from"./DrawingMode.js";import{DrawManipulator as b}from"./DrawManipulator.js";import{createCoordinateHelper as V}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as M,Component as D}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as C}from"../interactive/editGeometry/EditGeometryOperations.js";import I from"../interactive/sketch/SketchLabelOptions.js";import E from"../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as P}from"../interactive/snapping/SnappingContext.js";import{SnappingPipeline as j}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as k}from"../interactive/snapping/SnappingOperation.js";import{DrawPolygonTooltipInfo as G,DrawPolylineTooltipInfo as H,DrawPointTooltipInfo as L}from"../interactive/tooltip/DrawTooltipInfos.js";import{Tooltip as Z}from"../interactive/tooltip/Tooltip.js";import{computeAreaWithStagedVertex as A,computeLengthWithStagedVertex as U}from"../interactive/tooltip/support/measurements.js";let z=class extends(e.EventedMixin(i)){constructor(t){super(t),this._createOperationCompleted=!1,this._pointerDownStates=new Set,this._snappingPipeline=new j,this._tooltip=null,this._tooltipContext={calculateElevation:null,calculateTotalLength:null,calculateArea:null},this.labelOptions=new I,this.tooltipOptions=new E,this.snapToSceneEnabled=null,n(t.elevationInfo)&&(this.elevationInfo={mode:t.hasZ?"absolute-height":"on-the-ground",offset:0})}initialize(){const{geometryType:t,view:e}=this,{spatialReference:i}=e,o="viewingMode"in e.state?e.state.viewingMode:O.Local,a="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=V(this.hasZ,this.hasM,i),this._editGeometryOperations=new C(new M(a,this.coordinateHelper)),this._snappingOperation=new k({view:e}),this.handles.add(m((()=>this.stagedVertex),(t=>{r(this._tooltip)&&this._updateTooltipInfo(),n(t)||this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(t)}],operation:"apply",type:"vertex-update"})}),{sync:!0,equals:(t,e)=>l(t,e,f)})),this._activeComponent=new D(i,o),this._editGeometryOperations.data.components.push(this._activeComponent);const p=this.segmentLabels;r(p)&&(p.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.handles.add([m((()=>this.labelOptions.enabled),(t=>{p.visible=t}),g),this.on("cursor-update",(()=>{const t=this.stagedVertex;p.stagedVertex=r(t)?this.coordinateHelper.pointToVector(t):null}))])),this.handles.add(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(t=>{const e=t.vertices.map((t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)}))),i=e.map((t=>t.coordinates));switch(t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}}))),this._manipulator=new b({grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size}),this.manipulators.add(this._manipulator),this._manipulator.grabbable="point"!==t,this.handles.add([this._createManipulatorDragPipeline(this._manipulator),this._manipulator.events.on("immediate-click",(t=>this._onImmediateClick(t))),this._manipulator.events.on("immediate-double-click",(t=>this._onImmediateDoubleClick(t))),m((()=>this.tooltipOptions.enabled),(t=>{this._tooltip=t?new Z({view:e,info:this._getTooltipInfo()}):s(this._tooltip)}),u)])}destroy(){s(this.segmentLabels),s(this._snappingOperation),this._tooltip=s(this._tooltip),this._editGeometryOperations=s(this._editGeometryOperations)}get _snappingEnabled(){return r(this.snappingManager)&&this.snappingManager.options.effectiveEnabled}get _defaultElevation(){return h(this.defaultZ,"meters")}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((t=>this.coordinateHelper.vectorToArray(t.pos)))}set drawingMode(t){this._set("drawingMode",t??w)}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return r(this.stagedVertex)?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get stagedVertex(){return this._snappingOperation.stagedPoint}set stagedVertex(t){this._snappingOperation.stagedPoint=o(t)}get updating(){return this.updatingHandles.updating}get vertices(){const t=this.committedVertices;return r(this.stagedVertex)&&t.push(this.coordinateHelper.pointToArray(this.stagedVertex)),t}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingOperation.abort(),r(this.stagedVertex)){const{stagedVertex:t}=this;this.stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t))}}complete(t){const e=t&&t.aborted||!1;this._snappingOperation.abort(),r(this.snappingManager)&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.stagedVertex=null;const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||e)&&this.emit("complete",{vertices:this.vertices.map(((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t}))),aborted:e,type:"complete"})}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){r(this.snappingManager)&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(t){const e=this._activeComponent;if("polygon"===this.geometryType&&e.vertices.length>2){if(this._vertexWithinPointerDistance(e.vertices[0].pos,t))return 0;if(this._vertexWithinPointerDistance(e.vertices[e.vertices.length-1].pos,t))return e.vertices.length-1}return null}_createManipulatorDragPipeline(t){switch(a(this.drawingMode)){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return S(t,((t,e,i,o)=>{const n="touch"===o&&this._snappingEnabled;!this.isCompleted&&n&&(e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this.stagedVertex=t.mapStart,("segment"===this.geometryType||n&&0===this.numVertices)&&this.commitStagedVertex()),t))).next(this._snappingPipeline.createSnapDragEventPipelineStep({predicate:()=>n,cancel:i,snappingManager:this.snappingManager,snappingContext:new P({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:o,visualizer:this.snappingVisualizer}),updatingHandles:this.updatingHandles}),this._snappingPipeline.next).next((t=>(n&&(this.stagedVertex=t.mapEnd,"end"===t.action&&this.commitStagedVertex()),t))).next((t=>("end"===t.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t))),i.next((()=>{n&&r(this.snappingManager)&&this.snappingManager.doneSnapping()})))}))}_createManipulatorDragPipelineFreehand(t){return S(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(n(this.stagedVertex)&&(this.stagedVertex=t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this.stagedVertex=t.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t}))}))}_createManipulatorDragPipelineHybrid(t){return S(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(n(this.stagedVertex)&&(this.stagedVertex=t.mapStart),this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this.stagedVertex=t.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t}))}))}_getDrawSurface(){if(n(this.elevationDrawSurface))return this.drawSurface;if(!this.coordinateHelper.hasZ)return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let t=this.defaultZ,e=!1;r(this.elevationInfo)&&"absolute-height"===this.elevationInfo.mode&&(e=!0),r(this.snapToSceneEnabled)&&(e=this.snapToSceneEnabled),r(this.elevationInfo)&&"on-the-ground"===this.elevationInfo.mode&&(e=!1);const i=this._activeComponent.vertices.length;return("segment"===this.geometryType||"polygon"===this.geometryType)&&i>0&&(t=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),e=!1),e?this.drawSurface:(this.elevationDrawSurface.defaultZ=t,this.elevationDrawSurface)}_mapToScreen(t){return this._getDrawSurface().mapToScreen(t)}_onHold(t){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&(this.stagedVertex=t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging)return;const e=this._activeComponent,i=this._closeOnClickVertexIndex(t.screenPoint);if(r(i))return t.stopPropagation(),void this.complete();const o=this._screenToMap(t.screenPoint);if(r(o))switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(r(this.stagedVertex)?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(o)),this.complete());break;case"click":case"hybrid":this._snappingOperation.abort(),r(this.stagedVertex)?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(o)),("point"===this.geometryType||"segment"===this.geometryType&&2===e.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===e.vertices.length)&&this.complete()}t.stopPropagation()}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){const e=v(t.x,t.y);if(this._manipulator.dragging||this._pointerDownStates.has(t.pointerId)||this._manipulator.grabbing||!this._manipulator.interactive)return void this._snappingOperation.abort();t.stopPropagation();const i=this._closeOnClickVertexIndex(e);if(r(i))return this._closeOnVertex(i),void this._snappingOperation.abort();const o=this._screenToMap(e);if(this._manipulator.cursor=r(o)?"crosshair":null,n(o))return void this._snappingOperation.abort();if(n(this.snappingManager))return this.stagedVertex=o,void this._snappingOperation.abort();const s=this.snappingManager,a=new P({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t.pointerType,visualizer:this.snappingVisualizer});this.updatingHandles.addPromise(c(this._snappingOperation.snap(o,s,a)))}_closeOnVertex(t){this.stagedVertex=null;const e={componentIndex:0,vertexIndex:t,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[t].pos)};this.emit("cursor-update",{updated:null,vertices:[e],operation:"apply",type:"vertex-update"})}_screenToMap(t){return this._getDrawSurface().screenToMap(t)}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),n(t))return null;const i=this._screenToMap(e.screenEnd);return r(i)?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,o=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return!!r(o)&&F(o,e,i)}_calculateVertexTooltipElevation(t){const{tooltipOptions:e,view:i}=this;if(n(t)||"2d"===i.type)return this._defaultElevation;const o=this.elevationInfo,r=e.elevation.mode,{spatialReference:s}=t,a=y(s),p=T(i,t,o,{mode:r,offset:0});return h(p*a,"meters")}_getTooltipInfo(){const{tooltipOptions:t}=this;if(!t.enabled)return null;this._tooltipContext.calculateElevation=t=>this._calculateVertexTooltipElevation(t);const{stagedVertex:e}=this,i=this._elevationTooltipDetail(e);switch(this.geometryType){case"point":return new L({tooltipOptions:t,elevation:i});case"polyline":return this._tooltipContext.calculateTotalLength=t=>U(this._editGeometryOperations.data.geometry)(t),new H({tooltipOptions:t,elevation:i,totalLength:this._totalLengthTooltipDetail(e)});case"polygon":return this._tooltipContext.calculateArea=t=>A(this._editGeometryOperations.data.geometry)(t),new G({tooltipOptions:t,elevation:i,area:this._areaTooltipDetail(e)});default:return null}}_elevationTooltipDetail(t){return{mode:this.elevationInfo.mode,...a(this._tooltipContext.calculateElevation)(t)}}_totalLengthTooltipDetail(t){return{...p(a(this._tooltipContext.calculateTotalLength)(t),h(0,"meters"))}}_areaTooltipDetail(t){return{...p(a(this._tooltipContext.calculateArea)(t),d(0,"square-meters"))}}_updateTooltipInfo(){const t=this._tooltip;if(n(t))return;const{stagedVertex:e}=this,i=this._elevationTooltipDetail(e);switch(this.geometryType){case"point":t.info.elevation=i;break;case"polyline":{const o=t.info;o.elevation=i,o.totalLength=this._totalLengthTooltipDetail(e);break}case"polygon":{const o=t.info;o.elevation=i,o.area=this._areaTooltipDetail(e);break}}}get test(){return{tooltip:this._tooltip}}};function F(t,e,i){const o=t.x-e.x,n=t.y-e.y;return o*o+n*n<=i}t([_()],z.prototype,"_defaultElevation",null),t([_()],z.prototype,"defaultZ",void 0),t([_({value:w})],z.prototype,"drawingMode",null),t([_({constructOnly:!0})],z.prototype,"elevationDrawSurface",void 0),t([_({constructOnly:!0})],z.prototype,"elevationInfo",void 0),t([_({constructOnly:!0,type:I})],z.prototype,"labelOptions",void 0),t([_({constructOnly:!0,type:E})],z.prototype,"tooltipOptions",void 0),t([_({constructOnly:!0})],z.prototype,"geometryType",void 0),t([_({constructOnly:!0})],z.prototype,"hasM",void 0),t([_({constructOnly:!0})],z.prototype,"hasZ",void 0),t([_({constructOnly:!0})],z.prototype,"manipulators",void 0),t([_({constructOnly:!0})],z.prototype,"drawSurface",void 0),t([_({constructOnly:!0})],z.prototype,"segmentLabels",void 0),t([_({constructOnly:!0})],z.prototype,"snappingManager",void 0),t([_({constructOnly:!0})],z.prototype,"snappingVisualizer",void 0),t([_()],z.prototype,"snapToSceneEnabled",void 0),t([_()],z.prototype,"_snappingOperation",void 0),t([_()],z.prototype,"stagedVertex",null),t([_()],z.prototype,"updating",null),t([_({constructOnly:!0})],z.prototype,"view",void 0),z=t([x("esri.views.draw.DrawOperation")],z);export{z as DrawOperation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{makeHandle as s}from"../../core/handleUtils.js";import{isNone as o,isSome as r,applySome as i}from"../../core/maybe.js";import{createTask as a,throwIfAborted as n}from"../../core/promiseUtils.js";import{formatLength as l}from"../../core/quantityFormatUtils.js";import{watch as c,on as p}from"../../core/reactiveUtils.js";import{createScreenPointArray as h}from"../../core/screenUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{s as b,a as f,i as u,f as _,l as x,b as y}from"../../chunks/vec2.js";import{a as g}from"../../chunks/vec2f64.js";import{z as v}from"../../chunks/vec3.js";import{isClockwise as j}from"../../geometry/support/coordsUtils.js";import{fetchMessageBundle as L}from"../../intl/messages.js";import U from"../overlay/TextOverlayItem.js";import{euclideanDirectDistance as I}from"../support/lengthMeasurementUtils.js";let O=class extends e{constructor(t){super(t),this.context=null,this.stagedVertex=null,this.visible=!0,this._messagesUnits=null,this._labelInfos=[],this._nextLabelIndex=0}initialize(){const t=a((async t=>{this._messagesUnits=await L("esri/core/t9n/Units"),n(t),this._update()})),e=()=>i(this.context,(t=>t.editGeometryOperations));this.own([c((()=>({cameraOrExtent:r(this.context)&&this.getCameraOrExtent(this.context),visible:this.visible,stagedVertex:this.stagedVertex})),(()=>this._update())),...["vertex-add","vertex-update","vertex-remove"].map((t=>p(e,t,(()=>this._update())))),s((()=>t.abort()))])}destroy(){for(this._nextLabelIndex=0;this._labelInfos.length;)this._destroyLabel(this._labelInfos.pop())}get updating(){return o(this._messagesUnits)}_update(){this._nextLabelIndex=0;const t=this.context;if(o(t))return void this._destroyUnusedLabels();const{components:e,geometry:s,coordinateHelper:i}=t.editGeometryOperations.data;if(!s)return void this._destroyUnusedLabels();const a=e.length;for(let o=0;o<a;++o){const n=e[o].vertices.map((t=>i.toXYZ(t.pos)));if(0===o&&r(this.stagedVertex)&&n.push(i.toXYZ(this.stagedVertex)),n.length<2)continue;const l=n[0],c=n[n.length-1];"polygon"===s.type&&n.length>2&&!v(l,c)&&n.push(l);const p=1===a&&!j(n,!1,!1);let h=V,m=k;this.toScreenPointArray(t,l,h);for(let e=1;e<n.length;++e){const s=n[e-1],o=n[e];this.toScreenPointArray(t,o,m),this._addLabel(t,s,h,o,m,p),[h,m]=[m,h]}}this._destroyUnusedLabels()}_addLabel(t,e,s,o,i,a){const{label:n}=this._getOrCreateLabel(t);if(!this.visible||b(s,i)<z)return void(n.visible=!1);const c=I(e,o,t.editGeometryOperations.data.spatialReference),p=this._messagesUnits;n.text=r(p)&&r(c)?l(p,c,"metric"):"",n.visible=!0;const h=i[0]-s[0],m=i[1]-s[1];a?f(w,-m,h):f(w,m,-h),u(w,w),_(w,w,A),x(S,s,i,.5),y(S,S,w),n.position=[S[0],S[1]],Math.abs(w[0])>Math.abs(w[1])?n.anchor=w[0]>0?"left":"right":n.anchor=-w[1]<0?"top":"bottom"}_getOrCreateLabel(t){if(this._labelInfos.length>this._nextLabelIndex)return this._labelInfos[this._nextLabelIndex++];const e=new U({fontSize:10,anchor:"center"});t.view.overlay.items.add(e);const s={label:e};return this._labelInfos.push(s),this._nextLabelIndex=this._labelInfos.length,s}_destroyUnusedLabels(){for(;this._labelInfos.length>this._nextLabelIndex;)this._destroyLabel(this._labelInfos.pop())}_destroyLabel({label:t}){i(this.context,(e=>e.view.overlay.items.remove(t))),t.destroy()}};t([m()],O.prototype,"context",void 0),t([m()],O.prototype,"stagedVertex",void 0),t([m()],O.prototype,"visible",void 0),t([m()],O.prototype,"updating",null),t([m()],O.prototype,"_messagesUnits",void 0),O=t([d("esri.views.interactive")],O);const w=g(),S=g(),V=h(),k=h(),z=3025,A=15;export{O as SegmentLabels};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{makeHandle as s}from"../../core/handleUtils.js";import{isNone as o,isSome as r,applySome as i}from"../../core/maybe.js";import{createTask as a,throwIfAborted as n}from"../../core/promiseUtils.js";import{formatLength as l}from"../../core/quantityFormatUtils.js";import{watch as h,on as p}from"../../core/reactiveUtils.js";import{createScreenPointArray as c}from"../../core/screenUtils.js";import{getDefaultUnitForView as m}from"../../core/unitUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{s as f,a as u,i as _,f as x,l as g,b as v}from"../../chunks/vec2.js";import{a as y}from"../../chunks/vec2f64.js";import{z as j}from"../../chunks/vec3.js";import{isClockwise as U}from"../../geometry/support/coordsUtils.js";import{fetchMessageBundle as I}from"../../intl/messages.js";import L from"../overlay/TextOverlayItem.js";import{euclideanDirectDistance as O}from"../support/lengthMeasurementUtils.js";let w=class extends e{constructor(t){super(t),this.context=null,this.stagedVertex=null,this.visible=!0,this._messagesUnits=null,this._labelInfos=[],this._nextLabelIndex=0}initialize(){const t=a((async t=>{this._messagesUnits=await I("esri/core/t9n/Units"),n(t),this._update()})),e=()=>i(this.context,(t=>t.editGeometryOperations));this.own([h((()=>({cameraOrExtent:r(this.context)&&this.getCameraOrExtent(this.context),visible:this.visible,stagedVertex:this.stagedVertex,messages:this._messagesUnits})),(()=>this._update())),...["vertex-add","vertex-update","vertex-remove"].map((t=>p(e,t,(()=>this._update())))),s((()=>t.abort()))])}destroy(){for(this._nextLabelIndex=0;this._labelInfos.length;)this._destroyLabel(this._labelInfos.pop())}get updating(){return o(this._messagesUnits)}get test(){return{labelContents:this._labelInfos.slice(0,this._nextLabelIndex).map((t=>t.label.text))}}_update(){this._nextLabelIndex=0;const t=this.context;if(o(t))return void this._destroyUnusedLabels();const{components:e,geometry:s,coordinateHelper:i}=t.editGeometryOperations.data;if(!s)return void this._destroyUnusedLabels();const a=e.length;for(let o=0;o<a;++o){const n=e[o].vertices.map((t=>i.toXYZ(t.pos)));if(0===o&&r(this.stagedVertex)&&n.push(i.toXYZ(this.stagedVertex)),n.length<2)continue;const l=n[0],h=n[n.length-1];"polygon"===s.type&&n.length>2&&!j(l,h)&&n.push(l);const p=1===a&&!U(n,!1,!1);let c=k,m=C;this.toScreenPointArray(t,l,c);for(let e=1;e<n.length;++e){const s=n[e-1],o=n[e];this.toScreenPointArray(t,o,m),this._addLabel(t,s,c,o,m,p),[c,m]=[m,c]}}this._destroyUnusedLabels()}_addLabel(t,e,s,o,i,a){const{label:n}=this._getOrCreateLabel(t);if(!this.visible||f(s,i)<z)return void(n.visible=!1);const h=O(e,o,t.editGeometryOperations.data.spatialReference),p=this._messagesUnits,c=m(t.view);n.text=r(p)&&r(h)?l(p,h,c):"",n.visible=!0;const d=i[0]-s[0],b=i[1]-s[1];a?u(S,-b,d):u(S,b,-d),_(S,S),x(S,S,A),g(V,s,i,.5),v(V,V,S),n.position=[V[0],V[1]],Math.abs(S[0])>Math.abs(S[1])?n.anchor=S[0]>0?"left":"right":n.anchor=-S[1]<0?"top":"bottom"}_getOrCreateLabel(t){if(this._labelInfos.length>this._nextLabelIndex)return this._labelInfos[this._nextLabelIndex++];const e=new L({fontSize:10,anchor:"center"});t.view.overlay.items.add(e);const s={label:e};return this._labelInfos.push(s),this._nextLabelIndex=this._labelInfos.length,s}_destroyUnusedLabels(){for(;this._labelInfos.length>this._nextLabelIndex;)this._destroyLabel(this._labelInfos.pop())}_destroyLabel({label:t}){i(this.context,(e=>e.view.overlay.items.remove(t))),t.destroy()}};t([d()],w.prototype,"context",void 0),t([d()],w.prototype,"stagedVertex",void 0),t([d()],w.prototype,"visible",void 0),t([d()],w.prototype,"updating",null),t([d()],w.prototype,"_messagesUnits",void 0),w=t([b("esri.views.interactive")],w);const S=y(),V=y(),k=c(),C=c(),z=3025,A=15;export{w as SegmentLabels};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import{applySome as o,isSome as n,destroyMaybe as i}from"../../../core/maybe.js";import{watch as r,syncAndInitial as s}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{defaultUnitPropertyMetadata as p}from"../../../properties/defaultUnit.js";import{BASE as l}from"./css.js";import{tooltipContentFactory as d}from"./content/tooltipContentFactory.js";const h={base:`${l}`};let u=class extends e{constructor(t){super(t),this._contentContainer=(()=>{const t=document.createElement("div");t.classList.add(h.base);const{style:e}=t;return e.position="absolute",e.top=e.left="0",t})(),this._contentWidget=null}initialize(){const t=this._contentContainer;this.own([r((()=>this.view.overlay?.surface),(e=>{t.remove(),o(e,(e=>e.appendChild(t)))}),s),r((()=>this.info),((e,r)=>{n(this._contentWidget)&&n(e)&&n(r)&&e.type===r.type?this._contentWidget.info=e:(this._contentWidget=i(this._contentWidget),o(d(this,e),(e=>{this._contentWidget=e,t.appendChild(e.container)})))}),s),r((()=>({container:this._contentContainer,contentWidget:this._contentWidget,screenPoint:this.view.inputManager?.latestPointerLocation})),m,s)])}destroy(){this._contentWidget=i(this._contentWidget),this._contentContainer.remove()}get units(){return{length:this.defaultUnit,verticalLength:this.defaultUnit,area:this.defaultUnit}}clear(){this.info=null}get test(){return{contentContainer:this._contentContainer}}};function m({container:t,contentWidget:e,screenPoint:o}){const{style:i}=t;n(o)&&n(e)?(i.display="block",i.transform=`translate(${Math.round(o.x)}px, ${Math.round(o.y)}px)`):i.display="none"}t([c({nonNullable:!0})],u.prototype,"view",void 0),t([c()],u.prototype,"info",void 0),t([c(p)],u.prototype,"defaultUnit",void 0),t([c()],u.prototype,"units",null),t([c()],u.prototype,"_contentContainer",void 0),t([c()],u.prototype,"_contentWidget",void 0),u=t([a("esri.views.interactive.tooltip.Tooltip")],u);export{u as Tooltip};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import o from"../../../core/Accessor.js";import{applySome as e,isSome as n,destroyMaybe as i}from"../../../core/maybe.js";import{watch as r,syncAndInitial as s}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{BASE as p}from"./css.js";import{tooltipContentFactory as d}from"./content/tooltipContentFactory.js";const l={base:`${p}`};let h=class extends o{constructor(t){super(t),this._contentContainer=(()=>{const t=document.createElement("div");t.classList.add(l.base);const{style:o}=t;return o.position="absolute",o.top=o.left="0",t})(),this._contentWidget=null}initialize(){const t=this._contentContainer;this.own([r((()=>this.view.overlay?.surface),(o=>{t.remove(),e(o,(o=>o.appendChild(t)))}),s),r((()=>this.info),((o,r)=>{n(this._contentWidget)&&n(o)&&n(r)&&o.type===r.type?this._contentWidget.info=o:(this._contentWidget=i(this._contentWidget),e(d(this,o),(o=>{this._contentWidget=o,t.appendChild(o.container)})))}),s),r((()=>({container:this._contentContainer,contentWidget:this._contentWidget,screenPoint:this.view.inputManager?.latestPointerLocation})),m,s)])}destroy(){this._contentWidget=i(this._contentWidget),this._contentContainer.remove()}clear(){this.info=null}get test(){return{contentContainer:this._contentContainer}}};function m({container:t,contentWidget:o,screenPoint:e}){const{style:i}=t;n(e)&&n(o)?(i.display="block",i.transform=`translate(${Math.round(e.x)}px, ${Math.round(e.y)}px)`):i.display="none"}t([c({nonNullable:!0})],h.prototype,"view",void 0),t([c()],h.prototype,"info",void 0),t([c()],h.prototype,"_contentContainer",void 0),t([c()],h.prototype,"_contentWidget",void 0),h=t([a("esri.views.interactive.tooltip.Tooltip")],h);export{h as Tooltip};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../chunks/tslib.es6.js";import"../../../../intl.js";import{unwrapOr as s}from"../../../../core/maybe.js";import{formatLength as e,formatRelativeLength as r,formatVerticalLength as i,formatRelativeVerticalLength as o,formatArea as n}from"../../../../core/quantityFormatUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as m}from"../../../../core/accessorSupport/decorators/subclass.js";import p from"../../../../widgets/Widget.js";import"../../../../widgets/support/widgetUtils.js";import{messageBundle as l}from"../../../../widgets/support/decorators/messageBundle.js";import{formatNumber as u}from"../../../../intl/number.js";let c=class extends p{constructor(){super(...arguments),this._messagesUnits=null,this._messagesTooltip=null}get _units(){return this.tooltip.units}_formatScale(t){return u(t,{style:"percent",maximumFractionDigits:0})}_formatRelativeOrientation(t){return u(t,{maximumFractionDigits:2,minimumFractionDigits:2,signDisplay:"exceptZero"})}_formatLength(t,r,i){return e(this._messagesUnits,t,s(r,this._units.length),i)}_formatRelativeLength(t){return r(this._messagesUnits,t,this._units.length)}_formatVerticalLength(t){return i(this._messagesUnits,t,this._units.verticalLength)}_formatRelativeVerticalLength(t){return o(this._messagesUnits,t,this._units.verticalLength)}_formatTotalLength(t){return e(this._messagesUnits,t,this._units.length)}_formatArea(t){return n(this._messagesUnits,t,this._units.area)}_formatPercentage(t){return u(t.value,{style:"percent"})}};t([a()],c.prototype,"info",void 0),t([a()],c.prototype,"tooltip",void 0),t([a()],c.prototype,"_units",null),t([l("esri/core/t9n/Units"),a()],c.prototype,"_messagesUnits",void 0),t([l("esri/views/interactive/tooltip/t9n/Tooltip"),a()],c.prototype,"_messagesTooltip",void 0),c=t([m("esri.views.interactive.tooltip.content.TooltipContent")],c);export{c as TooltipContent};
5
+ import{_ as t}from"../../../../chunks/tslib.es6.js";import"../../../../intl.js";import{unwrapOr as e}from"../../../../core/maybe.js";import{formatLength as s,formatRelativeLength as r,formatVerticalLength as i,formatRelativeVerticalLength as o,formatArea as n}from"../../../../core/quantityFormatUtils.js";import{getDefaultUnitForView as a}from"../../../../core/unitUtils.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as p}from"../../../../core/accessorSupport/decorators/subclass.js";import l from"../../../../widgets/Widget.js";import"../../../../widgets/support/widgetUtils.js";import{messageBundle as c}from"../../../../widgets/support/decorators/messageBundle.js";import{formatNumber as u}from"../../../../intl/number.js";let g=class extends l{constructor(){super(...arguments),this._messagesUnits=null,this._messagesTooltip=null}get _units(){const t=a(this.tooltip.view);return{length:t,verticalLength:t,area:t}}_formatScale(t){return u(t,{style:"percent",maximumFractionDigits:0})}_formatRelativeOrientation(t){return u(t,{maximumFractionDigits:2,minimumFractionDigits:2,signDisplay:"exceptZero"})}_formatLength(t,r,i){return s(this._messagesUnits,t,e(r,this._units.length),i)}_formatRelativeLength(t){return r(this._messagesUnits,t,this._units.length)}_formatVerticalLength(t){return i(this._messagesUnits,t,this._units.verticalLength)}_formatRelativeVerticalLength(t){return o(this._messagesUnits,t,this._units.verticalLength)}_formatTotalLength(t){return s(this._messagesUnits,t,this._units.length)}_formatArea(t){return n(this._messagesUnits,t,this._units.area)}_formatPercentage(t){return u(t.value,{style:"percent"})}};t([m()],g.prototype,"info",void 0),t([m()],g.prototype,"tooltip",void 0),t([m()],g.prototype,"_units",null),t([c("esri/core/t9n/Units"),m()],g.prototype,"_messagesUnits",void 0),t([c("esri/views/interactive/tooltip/t9n/Tooltip"),m()],g.prototype,"_messagesTooltip",void 0),g=t([p("esri.views.interactive.tooltip.content.TooltipContent")],g);export{g as TooltipContent};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{isNone as n,isSome as t}from"../../core/maybe.js";import{createLength as e}from"../../core/quantityUtils.js";import{lengthUnitFromSpatialReference as r}from"../../core/unitUtils.js";import{j as o}from"../../chunks/vec2.js";import{i as s}from"../../chunks/vec3.js";import{c}from"../../chunks/vec3f64.js";import{canProjectWithoutEngine as u,projectVectorToVector as i}from"../../geometry/projection.js";import{getSphericalPCPF as l,SphericalECEFSpatialReference as f,WGS84ECEFSpatialReference as a}from"../../geometry/projectionEllipsoid.js";import{equals as m,isGeographic as p}from"../../geometry/support/spatialReferenceUtils.js";function h(t){const{hasZ:o,spatialReference:s}=t,c=r(s);if(n(c))return null;let u=0;for(const e of t.paths){if(e.length<2)continue;const t=e.length-1;for(let r=0;r<t;++r){const t=e[r];b[0]=t[0],b[1]=t[1],b[2]=o?t[2]:0;const c=e[r+1];E[0]=c[0],E[1]=c[1],E[2]=o?c[2]:0;const i=Z(b,E,s);n(i)||(u+=i.value)}}return e(u,c)}function y(n,t){const{spatialReference:e}=n;return m(e,t.spatialReference)?(b[0]=n.x,b[1]=n.y,b[2]=n.hasZ?n.z:0,E[0]=t.x,E[1]=t.y,E[2]=t.hasZ?t.z:0,z(b,E,e)):null}function j(n,t){const{spatialReference:e}=n;return m(e,t.spatialReference)?(b[0]=n.x,b[1]=n.y,b[2]=n.hasZ?n.z:0,E[0]=t.x,E[1]=t.y,E[2]=t.hasZ?t.z:0,Z(b,E,e)):null}function R(n,t){const{spatialReference:e}=n;return m(e,t.spatialReference)?(b[0]=n.x,b[1]=n.y,b[2]=n.hasZ?n.z:0,E[0]=t.x,E[1]=t.y,E[2]=t.hasZ?t.z:0,g(b,E,e)):null}function x(n,t){const{spatialReference:e}=n;return m(e,t.spatialReference)?(b[0]=n.x,b[1]=n.y,b[2]=n.hasZ?n.z:0,E[0]=t.x,E[1]=t.y,E[2]=t.hasZ?t.z:0,v(b,E,e)):null}function z(n,e,o){if(p(o))return k(b,E,n,e,o)?q(b,E,"meters"):null;const s=r(o);return t(s)?q(n,e,s):null}function Z(n,e,o){if(p(o))return k(b,E,n,e,o)?U(b,E,"meters"):null;const s=r(o);return t(s)?U(n,e,s):null}function g(n,e,o){if(p(o))return k(b,E,n,e,o)?d(b,E,"meters"):null;const s=r(o);return t(s)?d(n,e,s):null}function v(n,e,o){if(p(o))return k(b,E,n,e,o)?M(b,E,"meters"):null;const s=r(o);return t(s)?M(n,e,s):null}function k(n,t,e,r,o){const s=l(o),c=s===f?a:s;return!!(u(o,c)&&i(e,o,n,c)&&i(r,o,t,c))}function q(n,t,r){const o=t[0]-n[0],s=t[1]-n[1],c=t[2]-n[2],u=o*o,i=s*s;return{direct:e(Math.sqrt(u+i+c*c),r),horizontal:e(Math.sqrt(u+i),r),vertical:e(c,r)}}function U(n,t,r){return e(s(n,t),r)}function d(n,t,r){return e(o(n,t),r)}function M(n,t,r){return e(t[2]-n[2],r)}const b=c(),E=c();export{Z as euclideanDirectDistance,j as euclideanDirectDistanceBetweenPoints,z as euclideanDistance,y as euclideanDistanceBetweenPoints,g as euclideanHorizontalDistance,R as euclideanHorizontalDistanceBetweenPoints,h as euclideanLength,v as verticalDistance,x as verticalDistanceBetweenPoints};
5
+ import{isSome as t,isNone as n}from"../../core/maybe.js";import{createLength as r}from"../../core/quantityUtils.js";import{lengthUnitFromSpatialReference as e,verticalLengthUnitFromSpatialReference as i}from"../../core/unitUtils.js";import{i as o,s as c}from"../../chunks/vec3.js";import{c as u}from"../../chunks/vec3f64.js";import{projectVectorToVector as l,canProjectWithoutEngine as s}from"../../geometry/projection.js";import{getSphericalPCPF as a,SphericalECEFSpatialReference as f,WGS84ECEFSpatialReference as p}from"../../geometry/projectionEllipsoid.js";import{equals as h}from"../../geometry/support/spatialReferenceUtils.js";function m(t){const{hasZ:i,spatialReference:o}=t,c=U(o);let u=0;const l=e(c);if(n(l))return null;for(const r of t.paths){if(r.length<2)continue;const t=r.length-1;for(let e=0;e<t;++e){const t=r[e];k[0]=t[0],k[1]=t[1],k[2]=i?t[2]:0;const c=r[e+1];M[0]=c[0],M[1]=c[1],M[2]=i?c[2]:0;const l=R(k,M,o);if(n(l))return null;u+=l.value}}return r(u,l)}function z(t,n){const{spatialReference:r}=t;return h(r,n.spatialReference)?(k[0]=t.x,k[1]=t.y,k[2]=t.hasZ?t.z:0,M[0]=n.x,M[1]=n.y,M[2]=n.hasZ?n.z:0,j(k,M,r)):null}function y(t,n){const{spatialReference:r}=t;return h(r,n.spatialReference)?(k[0]=t.x,k[1]=t.y,k[2]=t.hasZ?t.z:0,M[0]=n.x,M[1]=n.y,M[2]=n.hasZ?n.z:0,R(k,M,r)):null}function v(t,n){const{spatialReference:r}=t;return h(r,n.spatialReference)?(k[0]=t.x,k[1]=t.y,k[2]=t.hasZ?t.z:0,M[0]=n.x,M[1]=n.y,M[2]=n.hasZ?n.z:0,x(k,M,r)):null}function d(t,n){const{spatialReference:r}=t;return h(r,n.spatialReference)?(k[0]=t.x,k[1]=t.y,k[2]=t.hasZ?t.z:0,M[0]=n.x,M[1]=n.y,M[2]=n.hasZ?n.z:0,g(k,M,r)):null}function j(n,e,i){const o=S(n,e,i);return t(o)?{direct:r(o.direct,o.unit),horizontal:r(o.horizontal,o.unit),vertical:r(o.vertical,o.unit)}:null}function R(n,e,i){const o=S(n,e,i,"direct");return t(o)?r(o.direct,o.unit):null}function x(n,e,i){const o=S(n,e,i,"horizontal");return t(o)?r(o.horizontal,o.unit):null}function Z(n,e,i){const o=S(n,e,i,"vertical");return t(o)?r(Math.abs(o.verticalSigned),o.unit):null}function g(n,e,i){const o=S(n,e,i,"vertical");return t(o)?r(o.verticalSigned,o.unit):null}function b(n,e){const o=i(e);return t(o)?r(n[2],o):null}function S(t,r,i,u){const s=U(i),a=e(s);if(n(a))return null;const f=r[2]-t[2];if("vertical"===u)return{verticalSigned:f,unit:a};if(!l(t,i,q,s)||!l(r,i,E,s))return null;if("direct"===u){return{direct:o(E,q),unit:a}}if(c(w,t[0],t[1],r[2]),!l(w,i,w,s))return null;const p=o(w,E);if("horizontal"===u)return{horizontal:p,unit:a};return{direct:o(E,q),horizontal:p,vertical:Math.abs(f),unit:a}}function U(t){const n=a(t),r=n===f?p:n;return s(t,r)?r:t}const k=u(),M=u(),q=u(),E=u(),w=u();export{b as elevation,R as euclideanDirectDistance,y as euclideanDirectDistanceBetweenPoints,j as euclideanDistance,z as euclideanDistanceBetweenPoints,x as euclideanHorizontalDistance,v as euclideanHorizontalDistanceBetweenPoints,m as euclideanLength,Z as verticalDistance,g as verticalSignedDistance,d as verticalSignedDistanceBetweenPoints};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../../chunks/tslib.es6.js";import{eventKey as e}from"../../../core/events.js";import{isSome as t}from"../../../core/maybe.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import s from"../../Slider.js";import{SliderWithDropdownViewModel as n}from"./SliderWithDropdownViewModel.js";import"../../support/widgetUtils.js";import{tsx as d}from"../../support/jsxFactory.js";const l={interactive:"esri-interactive",label:"esri-slider__label",box:"esri-slider-with-dropdown__box",dropdownRoot:"esri-slider-with-dropdown__dropdown-root",anchor:" esri-widget__anchor esri-slider-with-dropdown__anchor",anchorOpen:"esri-slider-with-dropdown__anchor--open",anchorClosed:"esri-slider-with-dropdown__anchor--closed",dropdownList:"esri-slider-with-dropdown__list",dropdownListItem:"esri-slider-with-dropdown__list-item",dropdownListItemSelected:"esri-slider-with-dropdown__list-item--selected",boxDropDownOn:"esri-slider-with-dropdown__box--drop-down-on",boxDropDownOff:"esri-slider-with-dropdown__box--drop-down-off"},p={selectItem:"Enter",closeDropdown:"Escape",moveSelectionUp:"ArrowUp",moveSelectionDown:"ArrowDown"};let a=class extends s{constructor(o,e){super(o,e),this.viewModel=new n,this.buttonTooltip="",this.showDropDown=!0,this.currentIndex=0,this._rootNode=null}renderThumbLabel(o){const e={[l.boxDropDownOn]:this.showDropDown,[l.boxDropDownOff]:!this.showDropDown};return d("div",{class:this.classes(l.box,l.label,e)},super.renderThumbLabel(o),this.showDropDown?d("div",{bind:this,afterCreate:this._onRootNodeCreate,class:l.dropdownRoot},d("button",{class:this.classes(l.interactive,l.anchor,this.isDropdownOpen?l.anchorOpen:l.anchorClosed),bind:this,disabled:this.disabled,onclick:this._onAnchorClick,onpointerdown:this._killEvent,"aria-label":this.buttonTooltip,title:this.buttonTooltip,"aria-expanded":this.isDropdownOpen.toString(),"aria-haspopup":"listbox",type:"button"},this.currentItem?this.currentItem.name+" ":""),this.isDropdownOpen?d("ol",{class:this.classes(l.dropdownList),onpointerdown:this._killEvent,onblur:this._onDropdownBlur,bind:this,tabindex:"-1","aria-label":this.buttonTooltip,role:"listbox",onkeydown:this._onOlKeyDown,afterCreate:this._focusOnSelectedItem},this.items.map(((o,e)=>d("li",{class:e===this.currentIndex?this.classes(l.interactive,l.dropdownListItem,l.dropdownListItemSelected):this.classes(l.interactive,l.dropdownListItem),bind:this,onclick:this._onDropdownItemClick,"data-result":e,"aria-label":o.label.join(" "),role:"option","aria-selected":(e===this.currentIndex).toString(),onkeydown:this._onLiKeyDown,onblur:this._onDropdownBlur,tabindex:"0"},o.label.map((o=>d("span",{bind:this},o))))))):null):null)}_onRootNodeCreate(o){this._rootNode=o}_focusOnSelectedItem(o){const e=o.querySelector(`.${l.dropdownListItemSelected}`)??o.firstChild;t(e)&&e instanceof HTMLElement&&(e.scrollIntoView(),e.focus())}_onAnchorClick(){return!this.disabled&&(this.viewModel.toggle(),!0)}_onDropdownItemClick(o){const e=o.currentTarget;this.viewModel.selectItem(e["data-result"])}_onDropdownBlur(o){let e=o.relatedTarget;null===e&&(e=document.activeElement),t(this._rootNode)&&!this._rootNode.contains(e)&&e!==this._rootNode.parentElement&&e!==this._rootNode.parentElement.parentElement&&(this.viewModel.isDropdownOpen=!1)}_killEvent(o){return o.stopPropagation(),!0}_onOlKeyDown(o){o.stopPropagation(),e(o)===p.closeDropdown&&(this.viewModel.isDropdownOpen=!1)}_onLiKeyDown(o){const t=o.target;switch(e(o)){case p.moveSelectionUp:if(t.previousElementSibling){t.previousElementSibling.focus()}break;case p.moveSelectionDown:if(t.nextElementSibling){t.nextElementSibling.focus()}break;case p.selectItem:t.click()}}};o([i()],a.prototype,"viewModel",void 0),o([i()],a.prototype,"buttonTooltip",void 0),o([i()],a.prototype,"showDropDown",void 0),o([i({aliasOf:"viewModel.items"})],a.prototype,"items",void 0),o([i({aliasOf:"viewModel.currentIndex"})],a.prototype,"currentIndex",void 0),o([i({aliasOf:"viewModel.currentItem"})],a.prototype,"currentItem",void 0),o([i({aliasOf:"viewModel.isDropdownOpen"})],a.prototype,"isDropdownOpen",void 0),a=o([r("esri.widgets.Daylight.SliderWithDropdown")],a);const c=a;export{c as default};
5
+ import{_ as o}from"../../../chunks/tslib.es6.js";import{eventKey as e}from"../../../core/events.js";import{unwrap as t,isSome as r}from"../../../core/maybe.js";import{watch as i,initial as n}from"../../../core/reactiveUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../Slider.js";import{SliderWithDropdownViewModel as l}from"./SliderWithDropdownViewModel.js";import c from"../../support/Popover.js";import"../../support/widgetUtils.js";import{tsx as a}from"../../support/jsxFactory.js";const w={interactive:"esri-interactive",label:"esri-slider__label",box:"esri-slider-with-dropdown__box",dropdownRoot:"esri-slider-with-dropdown__dropdown-root",anchor:" esri-widget__anchor esri-slider-with-dropdown__anchor",anchorOpen:"esri-slider-with-dropdown__anchor--open",anchorClosed:"esri-slider-with-dropdown__anchor--closed",dropdownList:"esri-slider-with-dropdown__list",dropdownListItem:"esri-slider-with-dropdown__list-item",dropdownListItemSelected:"esri-slider-with-dropdown__list-item--selected",boxDropDownOn:"esri-slider-with-dropdown__box--drop-down-on",boxDropDownOff:"esri-slider-with-dropdown__box--drop-down-off"},h={selectItem:"Enter",closeDropdown:"Escape",moveSelectionUp:"ArrowUp",moveSelectionDown:"ArrowDown"};let m=class extends p{constructor(o,e){super(o,e),this.viewModel=new l,this.buttonTooltip="",this.showDropDown=!0,this.currentIndex=0,this._dropdownAnchor=null,this._dropdownElement=null,this._popover=new c({owner:this,placement:"bottom-start",anchorElement:()=>t(this._dropdownAnchor),renderContentFunction:()=>this._renderPopover()})}initialize(){this.own(i((()=>this.viewModel.isDropdownOpen),(o=>{this._popover.open=o}),n))}destroy(){this._popover.destroy()}renderThumbLabel(o){const e={[w.boxDropDownOn]:this.showDropDown,[w.boxDropDownOff]:!this.showDropDown};return a("div",{class:this.classes(w.box,w.label,e)},super.renderThumbLabel(o),this.showDropDown&&a("div",{bind:this,afterCreate:this._onDropdownAnchorAfterCreate,class:w.dropdownRoot},a("button",{class:this.classes(w.interactive,w.anchor,this.isDropdownOpen?w.anchorOpen:w.anchorClosed),bind:this,disabled:this.disabled,onclick:this._onAnchorClick,onpointerdown:this._killEvent,"aria-label":this.buttonTooltip,title:this.buttonTooltip,"aria-expanded":this.isDropdownOpen.toString(),"aria-haspopup":"listbox",type:"button"},this.currentItem?this.currentItem.name+" ":"")))}_onDropdownAnchorAfterCreate(o){this._dropdownAnchor=o}_renderPopover(){return a("ol",{role:"listbox",afterCreate:this._onDropdownAfterCreate,"aria-label":this.buttonTooltip,bind:this,class:this.classes(w.dropdownList),tabindex:"-1",onkeydown:this._onDropdownKeyDown,onfocusout:this._onDropdownFocusOut,onpointerdown:this._killEvent},this.items.map(((o,e)=>a("li",{class:e===this.currentIndex?this.classes(w.interactive,w.dropdownListItem,w.dropdownListItemSelected):this.classes(w.interactive,w.dropdownListItem),bind:this,onclick:this._onDropdownItemClick,"data-result":e,"aria-label":o.label.join(" "),role:"option","aria-selected":(e===this.currentIndex).toString(),onkeydown:this._onLiKeyDown,tabindex:"0"},o.label.map((o=>a("span",{bind:this},o)))))))}_onDropdownAfterCreate(o){this._dropdownElement=o;const e=o.querySelector(`.${w.dropdownListItemSelected}`)??o.firstChild;r(e)&&e instanceof HTMLElement&&(e.scrollIntoView(),e.focus())}_onAnchorClick(){return!this.disabled&&(this.viewModel.toggle(),!0)}_onDropdownItemClick(o){const e=o.currentTarget;this.viewModel.selectItem(e["data-result"])}_onDropdownFocusOut(o){let e=o.relatedTarget;null===e&&(e=document.activeElement),r(this._dropdownElement)&&!this._dropdownElement.contains(e)&&r(this._dropdownAnchor)&&!this._dropdownAnchor.contains(e)&&(this.viewModel.isDropdownOpen=!1)}_killEvent(o){return o.stopPropagation(),!0}_onDropdownKeyDown(o){o.stopPropagation(),e(o)===h.closeDropdown&&(this.viewModel.isDropdownOpen=!1)}_onLiKeyDown(o){const t=o.target;switch(e(o)){case h.moveSelectionUp:if(t.previousElementSibling){t.previousElementSibling.focus()}break;case h.moveSelectionDown:if(t.nextElementSibling){t.nextElementSibling.focus()}break;case h.selectItem:t.click()}}};o([s()],m.prototype,"viewModel",void 0),o([s()],m.prototype,"buttonTooltip",void 0),o([s()],m.prototype,"showDropDown",void 0),o([s({aliasOf:"viewModel.items"})],m.prototype,"items",void 0),o([s({aliasOf:"viewModel.currentIndex"})],m.prototype,"currentIndex",void 0),o([s({aliasOf:"viewModel.currentItem"})],m.prototype,"currentItem",void 0),o([s({aliasOf:"viewModel.isDropdownOpen"})],m.prototype,"isDropdownOpen",void 0),m=o([d("esri.widgets.Daylight.SliderWithDropdown")],m);const u=m;export{u as default};