{"version":3,"sources":["jsdelivr-header.js","/npm/geoip2ws@3.0.0/geoip2ws.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACmBA,OAAO,QAAU,gBAA0B,OAEzC,EAAM,WACN,EAAU,GACV,EAAK,KAAI,QACT,EAAU,OAAM,SAChB,EAAW,4BAA2B,QACtC,EAAU,MAIV,EAAW,EAAS,QAAS,MAAO,IACpC,GAAY,eAAe,KAAW,IAEtC,MAAM,QAAY,MAAO,EAAU,CACjC,OAAQ,YAAY,QAAS,GAC7B,QAAS,CACP,OAAU,mBACV,iBAAkB,QAClB,cAAiB,SAAW,OAAO,KAAM,GAAG,KAAU,KAAe,SAAU,UAC/E,aAAc,0BAIZ,QAAa,EAAI,OAGvB,GAAK,EAAK,MAAQ,CAChB,MAAM,EAAQ,IAAI,MAAO,QAAQ,EAAK,SAGtC,MADA,EAAM,OAAS,EAAK,KACd,CACR,CAcA,OAXA,EAAK,0BAA4B,CAAC,EAE3B,MAAM,QAAS,EAAK,gBACzB,EAAK,aAAe,IAGjB,EAAK,aAAa,SACrB,EAAK,0BAA4B,EAAK,aAAa,EAAK,aAAa,OAAS,IAIzE,CAET","file":"/npm/geoip2ws@3.0.0/geoip2ws.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/geoip2ws@3.0.0/geoip2ws.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*\nName:           geoip2ws - geoip2ws.js\nDescription:    Maxmind GeoIP2 Web Services for node.js (unofficial)\nAuthor:         Franklin (https://fvdm.com)\nSource & docs:  https://github.com/fvdm/nodejs-geoip2ws\nFeedback:       https://github.com/fvdm/nodejs-geoip2ws/issues\nLicense:        Unlicense (public domain, see LICENSE file)\n*/\n\n\n/**\n * GeoIP lookup\n *\n * @param   {object}  o\n *\n * @param   {string}  o.userId            Account user ID\n * @param   {string}  o.licenseKey        Account license key\n * @param   {string}  [o.ip='me']         IP-address, hostname or 'me' to look up\n * @param   {string}  [o.service='city']  Account service name\n * @param   {string}  [o.endpoint]        API hostname or url\n * @param   {number}  [o.timeout=5000]    Request time out in milliseconds\n *\n * @return  {Promise<object>}\n */\n\nmodule.exports = async function geoip2ws ( {\n\n  userId,\n  licenseKey,\n  ip = 'me',\n  service = 'city',\n  endpoint = 'https://geoip.maxmind.com',\n  timeout = 5000,\n\n} ) {\n\n  endpoint = endpoint.replace( /\\/$/, '' );\n  endpoint += `/geoip/v2.1/${service}/${ip}`;\n\n  const res = await fetch( endpoint, {\n    signal: AbortSignal.timeout( timeout ),\n    headers: {\n      'Accept': 'application/json',\n      'Accept-Charset': 'UTF-8',\n      'Authorization': 'Basic ' + Buffer.from( `${userId}:${licenseKey}` ).toString( 'base64' ),\n      'User-Agent': 'fvdm/nodejs-geoip2ws',\n    },\n  } );\n\n  const data = await res.json();\n\n  // Process API error\n  if ( data.error ) {\n    const error = new Error( `API: ${data.error}` );\n\n    error.reason = data.code;\n    throw error;\n  }\n\n  // Fix response inconsistencies\n  data.most_specific_subdivision = {};\n\n  if ( ! Array.isArray( data.subdivisions ) ) {\n    data.subdivisions = [];\n  }\n\n  if ( data.subdivisions.length ) {\n    data.most_specific_subdivision = data.subdivisions[data.subdivisions.length - 1];\n  }\n\n  // All good\n  return data;\n\n};\n"]}