import e from"@arcgis/core/geometry/SpatialReference";import{ArgumentError as t}from"../ArgumentError.js";const n=[/^urn:ogc:def:crs:([^:]*):.*?:([^:]*?)$/,/^urn:x-ogc:def:crs:([^:]*):.*?:([^:]*?)$/,/^urn:([^:]*):.*?:([^:]*?)$/,/^(.*#)(.*?)$/,/^(.*):(.*?)$/];export const webMercatorAliases=[900913,102100,102113];export var OgcNamespace;!function(e){e.FES="http://www.opengis.net/fes",e.FES_2_0="http://www.opengis.net/fes/2.0",e.GML="http://www.opengis.net/gml",e.GML_3_2="http://www.opengis.net/gml/3.2",e.GML_3_3_CE="http://www.opengis.net/gml/3.3/ce",e.OGC="http://www.opengis.net/ogc",e.OWS="http://www.opengis.net/ows",e.OWS_1_1="http://www.opengis.net/ows/1.1",e.OWS_2_0="http://www.opengis.net/ows/2.0",e.WFS="http://www.opengis.net/wfs",e.WFS_2_0="http://www.opengis.net/wfs/2.0",e.XML="http://www.w3.org/XML/1998/namespace",e.XS="http://www.w3.org/2001/XMLSchema",e.XLINK="http://www.w3.org/1999/xlink"}(OgcNamespace||(OgcNamespace={}));export function getGmlNS(e){switch(e){case"2.0":case"3.0":case"3.1":return OgcNamespace.GML;case"3.2":default:return OgcNamespace.GML_3_2;case"3.3":return OgcNamespace.GML_3_3_CE}}export function inferGmlVersion(e){switch(e){case"1.0.0":case"1.1.0":return"2.0";default:return"3.2"}}export function isGmlNamespace(e){return e===OgcNamespace.GML||e===OgcNamespace.GML_3_2||e===OgcNamespace.GML_3_3_CE}export function ogcSrsToEsriSr(s){for(const t of n){const n=s.match(t);if(null!=n?.[2]&&("EPSG"===n[1]||"http://www.opengis.net/gml/srs/epsg.xml#"===n[1])){const t=parseInt(n[2]);if(t<32767)return new e({wkid:t});if(webMercatorAliases.includes(t))return e.WebMercator}}throw new t("Unable to parse OGC spatial reference")}export function getEpsgCode(e){for(const t of n){const n=e.match(t);if(null!=n?.[2]&&("EPSG"===n[1]||"http://www.opengis.net/gml/srs/epsg.xml#"===n[1])){return parseInt(n[2])}}throw new t(e,"Unable to parse an EPSG code.")}