import e from"@arcgis/core/core/Collection";import r from"@arcgis/core/geometry/SpatialReference";import{isGroupLayer as a}from"./_layers.js";export function isMap(e){return"esri.Map"===e?.declaredClass}export function isWebMap(e){return"esri.WebMap"===e?.declaredClass}export function isWebScene(e){return"esri.WebScene"===e?.declaredClass}export function isBasemap(e){return"esri.Basemap"===e?.declaredClass}export function isGround(e){return"esri.Ground"===e?.declaredClass}export function getMapSpatialReference(i){if((isWebScene(i)||isWebMap(i))&&i.initialViewProperties?.spatialReference)return i.initialViewProperties.spatialReference;let n=new e;i.basemap&&(n=n.concat(i.basemap.baseLayers)),n=n.concat(i.layers.flatten((e=>a(e)?e.layers:[]))),i.ground&&(n=n.concat(i.ground.layers));const t=n.find((e=>e.loaded));return t?"spatialReference"in t?t.spatialReference:r.WebMercator:void 0}