/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{length as n,normalize as e,scaleAndAdd as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as t,create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{absoluteHeightElevationInfo as l,getConvertedElevation as i,getGraphicEffectiveElevationInfo as u}from"../../../../support/elevationInfoUtils.js";import a from"../../../../symbols/support/ElevationInfo.js";function s(n){return n?.clone()??null}function c(n){return n?.clone()??null}function f(n){const e=s(n);return n&&e?{observer:n,snapshot:e}:null}function p(n){return{target:n,snapshot:c(n)??n.clone()}}function m(n,e,o,t=null){const r=o.clone();return r.z=i(e,o,t??l,l),n.getMapPointIntersection(r)}function d(n,e,o,t=o.mapPoint,r=null,s=l){if(null==t)return e.position=null,e.elevationInfo=null,void(e.feature=null);const c=t.clone();c.z=i(n,t,s??l,l);const f=!("relative-to-ground"===s?.mode||"on-the-ground"===s?.mode)&&!o.mapPoint?.equals(c);switch(o.context?.type){case"graphic":{const n=o.context.graphic,t=u(n);"on-the-ground"===t.mode&&(t.mode="relative-to-ground",t.offset=0),e.elevationInfo=new a(t),e.feature=n;break}case"gaussian-splat":return e.elevationInfo=r?.clone()??null,e.feature=null,f&&(e.elevationInfo=null),void(e.position=v(n,c,e.elevationInfo,o.normal));case"ground":e.elevationInfo=r?.clone()??new a({mode:"on-the-ground"}),e.feature=null;break;default:e.elevationInfo=r?.clone()??null,e.feature=null}f&&(e.elevationInfo=null);const p=c.clone();p.z=i(n,c,l,e.elevationInfo),e.position=p}function v(u,a,s,c){const f=a.clone(),p=t(a.x,a.y,a.z??0);if(!u.renderCoordsHelper.toRenderCoords(p,a.spatialReference,p)||0===n(c))return f.z=i(u,f,l,s),f;const m=4,d=u.state.camera.computeScreenPixelSizeAt(p)*m,v=e(r(),c);o(p,p,v,d);const g=u.renderCoordsHelper.fromRenderCoords(p,f);return null==g?(f.z=i(u,f,l,s),f):(g.z=i(u,g,l,s),g)}export{f as createLineOfSightObserverItem,p as createLineOfSightTargetItem,v as getGaussianSplatOffsetPosition,m as getLineOfSightMapPointIntersection,s as snapshotLineOfSightObserverState,c as snapshotLineOfSightTargetState,d as updateLineOfSightItemFromIntersection};
