/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{memoize as e}from"../core/memoize.js";import{verticalLengthUnitFromSpatialReference as n,convertUnit as t}from"../core/units.js";import{getMetersPerUnit as o}from"../symbols/support/unitConversionUtils.js";function r(e){return e?k:C}function u(e,n){return n?.mode?n.mode:r(e).mode}function i(e,n){return null!=n?n:r(e)}function s(e,n){return u(null==e||(e.hasZ??!1),n)}function l(e,n){return i(null==e||(e.hasZ??!1),n)}function a(e){const n=m(e);return s(e.geometry,n)}function c(e){const n=m(e),t=s(e.geometry,n),o=null!=n&&"on-the-ground"!==t?z(n):0,r=n?.featureExpressionInfo;return{mode:t,offset:o,featureExpressionInfo:r}}function f(e){return g(c(e))}function d(e){return g(e)||v(e)}function v(e){return"0"===e?.featureExpressionInfo?.expression}function g(e){if(!e)return!1;if("on-the-ground"===e.mode)return!1;const n=e?.featureExpressionInfo?e.featureExpressionInfo.expression:null;return!(!n||"0"===n)}function m(e){return e.layer&&"elevationInfo"in e.layer?e.layer.elevationInfo:null}const p=e((e,o,r)=>{if(!e)return 0;if("decimal-degrees"===o)return 0;const u="unknown"!==o&&o?o:"meters",i=n(r);return i?t(e,u,i):0});function h(e,n){return p(e?.offset,e?.unit,n)}function x(e,n,t){if(!t?.mode)return;const o=e.hasZ?e.z:0,r=h(t,e.spatialReference);switch(t.mode){case"absolute-height":return o-r;case"on-the-ground":return 0;case"relative-to-ground":return o-((n.elevationProvider.getElevation(e.x,e.y,o,e.spatialReference,"ground")??0)+r);case"relative-to-scene":return o-((n.elevationProvider.getElevation(e.x,e.y,o,e.spatialReference,"scene")??0)+r)}}function E(e,n,t,o=null){return I(e,n.x,n.y,n.hasZ?n.z:0,n.spatialReference,t,o)}function b(e,n,t,o,r=null){return I(e,n[0],n[1],n.length>2?n[2]:0,t,o,r)}function I(e,n,t,o,r,u,i=null){if(null==u)return;const s=null!=i?i.mode:"absolute-height";if("on-the-ground"===s)return 0;const{absoluteZ:l}=y(n,t,o,r,e,u);return Z(l,n,t,o,r,e,i,s)}function y(e,n,t,o,r,u){const i=h(u,o);switch(u.mode){case"absolute-height":return{absoluteZ:t+i,elevation:0};case"on-the-ground":{const t=r.elevationProvider.getElevation(e,n,0,o,"ground")??0;return{absoluteZ:t,elevation:t}}case"relative-to-ground":{const u=r.elevationProvider.getElevation(e,n,t,o,"ground")??0;return{absoluteZ:t+u+i,elevation:u}}case"relative-to-scene":{const u=r.elevationProvider.getElevation(e,n,t,o,"scene")??0;return{absoluteZ:t+u+i,elevation:u}}}}function Z(e,n,t,o,r,u,i,s){const l=h(i,r);switch(s){case"absolute-height":return e-l;case"relative-to-ground":return e-((u.elevationProvider.getElevation(n,t,o,r,"ground")??0)+l);case"relative-to-scene":return e-((u.elevationProvider.getElevation(n,t,o,r,"scene")??0)+l)}}function P(e,n){if(null==n)return!1;const{mode:t}=n;return null!=t&&("scene"===e&&"relative-to-scene"===t||"ground"===e&&"absolute-height"!==t)}function w(e,n,t){return t&&t.mode!==n?`${e} only support ${n} elevation mode`:null}function $(e,n,t){return t?.mode===n?`${e} do not support ${n} elevation mode`:null}function R(e,n){return null!=n?.featureExpressionInfo&&"0"!==n.featureExpressionInfo.expression?`${e} do not support featureExpressionInfo`:null}function j(e,n){n&&e.warn(".elevationInfo=",n)}function z(e){return(e?.offset??0)*o(e?.unit)}const k={mode:"absolute-height",offset:0},C={mode:"on-the-ground",offset:null};export{k as absoluteHeightElevationInfo,P as elevationContextAffectsAlignment,w as elevationModeRequiredMessage,$ as elevationModeUnsupportedMessage,v as featureExpressionInfoIsZero,R as featureExpressionUnsupportedMessage,E as getConvertedElevation,b as getConvertedElevationFromVector,I as getConvertedElevationFromXYZ,i as getEffectiveElevationInfo,u as getEffectiveElevationMode,h as getElevationOffset,z as getElevationOffsetInMeters,l as getGeometryEffectiveElevationInfo,s as getGeometryEffectiveElevationMode,c as getGraphicEffectiveElevationInfo,a as getGraphicEffectiveElevationMode,x as getZForElevationMode,d as hasFeatureExpressionInfo,f as hasGraphicFeatureExpressionInfo,j as logInvalidElevationInfoWarning,C as onTheGroundElevationInfo,y as zValueInAbsoluteHeightMode};
