/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../core/maybe","../../../../chunks/mat4","../../../../chunks/vec3f64","../../../../geometry/support/aaBoundingBox","../../../../chunks/sphere","../../layers/i3s/Intersector","../../terrain/Intersector","./intersectorUtils","./lodRendering/Intersector"],(function(e,t,r,n,s,i,o,u,c,a){"use strict";function l(e,t){return c.isObjectIntersectorResult(e)||c.isHudIntersectorResult(e)?y(e.target.object.metadata,t):u.isTerrainIntersectorResult(e)?null==(r=t.map)?void 0:r.ground:o.isPclIntersectorResult(e)||o.isI3sIntersectorResult(e)||u.isOverlayIntersectorResult(e)?y(e.target,t):null;var r}function g(e,r){const n=d(e,r);return t.isSome(n)&&"graphic"===n.type?n.graphic:null}function d(e,r){if(t.isNone(e))return null;if(c.isObjectIntersectorResult(e)||c.isHudIntersectorResult(e))return p(e.target.object.metadata,r);if(o.isPclIntersectorResult(e)){const t=e.target.createGraphic();return{type:"graphic",graphic:t,layer:t.layer}}return u.isOverlayIntersectorResult(e)||a.isLodIntersectorResult(e)?p(e.target,r):o.isI3sIntersectorResult(e)?I(e.target,r):null}function p(e,r){if(t.isNone(e)||t.isNone(e.graphicUid))return null;const n=y(e,r);if(t.isNone(n))return null;if(n===r.graphics)return t.isNone(r.graphicsView)||"number"!=typeof e.graphicUid?null:r.graphicsView.getHit(e.graphicUid);const s=r.allLayerViews.find((e=>e.layer===n));return!s||s.suspended||t.isNone(e.graphicUid)?null:"getHit"in s?s.getHit(e.graphicUid):null}function I(e,r){const n=y(e,r);if(t.isNone(n))return null;const s=r.allLayerViews.find((e=>e.layer===n));return s&&!s.suspended&&"getGraphicFromIntersectorTarget"in s?h(s.getGraphicFromIntersectorTarget(e)):null}function f(e,r){const n=y(e,r);if(t.isNone(n))return null;const s=r.allLayerViews.find((e=>e.layer===n));return s&&!s.suspended&&"getAABBFromIntersectorTarget"in s?s.getAABBFromIntersectorTarget(e):null}function h(e){return t.isSome(e)?{type:"graphic",graphic:e,layer:e.layer}:null}function y(e,r){return t.isNone(e.layerUid)?null:t.isSome(r.graphicsView)&&e.layerUid===r.graphicsView.processor.layer.id?r.graphics:r.map.findLayerByUid(e.layerUid)}function R(e,n){if(c.isObjectIntersectorResult(e)||c.isHudIntersectorResult(e))return i.getRadius(e.target.object.boundingVolumeWorldSpace.bounds);if(a.isLodIntersectorResult(e)){r.getScaling(b,e.transformation);const t=Math.max(b[0],b[1],b[2]);return e.target.baseBoundingSphere.radius*t}return o.isI3sIntersectorResult(e)?t.applySome(f(e.target,n),(e=>.5*s.diameter(e))):null}function m(e){return!c.isObjectIntersectorResult(e)&&!c.isHudIntersectorResult(e)&&(a.isLodIntersectorResult(e)?e.target.numLodLevels>1:!!o.isI3sIntersectorResult(e))}const b=n.create();e.getIntersectedFeatureBSRadius=R,e.hasLod=m,e.toGraphic=g,e.toHit=d,e.toOwner=l,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
