import e from"@arcgis/core/Basemap";import a from"@arcgis/core/portal/Portal.js";import{esriBasemapDefinitions as s}from"@arcgis/core/support/basemapDefinitions.js";import{}from"../json/BasemapJson.js";import{WellKnownBasemap as r,wellKnownBasemapTitles as t}from"../support/esri.js";import{basemapsAreEquivalent as o,standardBasemaps as n}from"./_layers.js";import{checkArg as c}from"./checkArg.js";import{isBasemap as T}from"./mapping.js";export{basemapsAreEquivalent,standardBasemaps}from"./_layers.js";export async function createStandardBasemap(s){c("id",s).satisfies((e=>n.hasOwnProperty(e)),`Invalid basemap ID "${s}".`);const r=basemapHas3DLayers(n[s]),o=e.fromJSON(n[s],r?{origin:"web-scene",portal:a.getDefault()}:{origin:"web-map"});o.id=s;const T=e.fromId(i(s));return await Promise.all([o.load(),T?.load()]),o.title=T?.title||t[s],o.thumbnailUrl=T?.thumbnailUrl,o}export function isStandardBasemap(e){return Object.values(n).some((a=>o(a,e)))}export function isStandardBasemap2D(e){return isStandardBasemap(e)&&!basemapHas3DLayers(e)}export function getStandardBasemapId(e){return Object.entries(n).find((([a,s])=>o(e,s)))?.[0]}export function getStandardBasemapThumbnailUrl(e){c("id",e).satisfies((e=>n.hasOwnProperty(e)),`Invalid basemap ID "${e}".`);const a=i({[r.STREETS_NAVIGATION_DARK_3D]:r.STREETS_NAVIGATION_3D,[r.STREETS_DARK_3D]:r.STREETS_NIGHT_VECTOR,[r.DARK_GRAY_3D]:r.DARK_GRAY}[e]??e);return s[a].thumbnailUrl}export function basemapHas3DLayers(e){if(!e)return!1;const a=new Set(["scene","integrated-mesh","point-cloud","ArcGISSceneServiceLayer","IntegratedMeshLayer","PointCloudLayer","SceneLayer"]);if(T(e)){return[...e.baseLayers?.toArray()??[],...e.referenceLayers?.toArray()??[]].some((e=>a.has(e.type)))}return(e.baseMapLayers??[]).some((e=>a.has(e.layerType)))}function i(e){switch(e){case r.HYBRID_VECTOR:case r.TERRAIN_VECTOR:case r.OCEANS_VECTOR:case r.OPEN_STREET_MAP_VECTOR:return e.replace("-vector","");case r.SATELLITE:case r.HYBRID:case r.STREETS:case r.STREETS_3D:case r.STREETS_DARK_3D:case r.STREETS_VECTOR:case r.TOPO:case r.TOPO_3D:case r.TOPO_VECTOR:case r.STREETS_NAVIGATION_3D:case r.STREETS_NAVIGATION_DARK_3D:case r.STREETS_NAVIGATION_VECTOR:case r.STREETS_NIGHT_VECTOR:case r.TERRAIN:case r.DARK_GRAY:case r.DARK_GRAY_3D:case r.DARK_GRAY_VECTOR:case r.GRAY:case r.GRAY_3D:case r.GRAY_VECTOR:case r.OCEANS:case r.OPEN_STREET_MAP:case r.OPEN_STREET_MAP_3D:case r.STREETS_RELIEF_VECTOR:default:return e}}