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UAAU,GACV,CACT,CA8BA,OA7BA,EAAS,OAAS,SAAU,EAAU,GACpC,IAAK,GAAM,KACT,MAAM,MAAM,qEAEd,EAAW,IAAI,EAAU,EAC3B,EACA,EAAS,OAAO,SAAU,CAAC,EAAS,IAAW,CAAC,EAAO,EAAO,CAAC,KAC7D,IAAK,CAAC,SAAU,aAAa,gBAAgB,GAC3C,MAAM,MAAM,6EAEd,IAAK,CAAC,SAAU,aAAa,gBAAgB,IAAS,MAAM,QAAQ,IAAkB,OAAT,EAC3E,MAAM,MAAM,oEAEd,OAAO,EAAQ,OAAQ,SAAU,IAC5B,EAAO,WACP,EACH,YAGJ,EAAS,OAAO,UAAW,CAAC,EAAS,IAAW,CAAC,EAAO,CAAC,KACvD,IAAK,CAAC,SAAU,aAAa,gBAAgB,IAAS,MAAM,QAAQ,IAAkB,OAAT,EAC3E,MAAM,MAAM,qEAEd,OAAO,EAAQ,OAAQ,UAAW,IAC7B,EAAO,WACP,MAIA,CAER","file":"/npm/@placekit/client-js@2.3.1/dist/placekit-lite.umd.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.48.0.\n * Original file: /npm/@placekit/client-js@2.3.1/dist/placekit-lite.umd.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*! @placekit/client-js v2.3.1 | © placekit.io | MIT license | https://github.com/placekit/client-js#readme */\n(function (global, factory) {\n  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n  typeof define === 'function' && define.amd ? define(factory) :\n  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.placekit = factory());\n})(this, (function () { 'use strict';\n\n  const extensions = new Map();\n  function getUserAgent() {\n    const chunks = [];\n    if (typeof window !== 'undefined' && navigator.userAgent) {\n      chunks.push(navigator.userAgent);\n    }\n    chunks.push(`PlaceKit/__PLACEKIT_VERSION__ (Client=JavaScript)`);\n    if (typeof process !== 'undefined' && process.version) {\n      chunks.push(`NodeJS/${process.version}`);\n    }\n    return chunks.join(' ');\n  }\n  function placekit(apiKey, options = {}) {\n    if (!['string', 'undefined'].includes(typeof apiKey)) {\n      throw Error('PlaceKit: `apiKey` argument is invalid, expected a string.');\n    } else if (!apiKey) {\n      console.warn('PlaceKit: missing or empty `apiKey` argument.');\n    }\n    let currentHost = 0;\n    const hosts = [`https://api.placekit.co`];\n    let hasGeolocation = false;\n    const globalParams = {\n      maxResults: 5,\n    };\n    if (typeof window !== 'undefined' && navigator.language) {\n      globalParams.language = navigator.language.slice(0, 2);\n    }\n    const userAgent = getUserAgent();\n    function request(method = 'POST', resource = '', opts = {}) {\n      const { timeout, forwardIP, ...params } = opts;\n      const controller = new AbortController();\n      const id =\n        typeof timeout !== 'undefined' ? setTimeout(() => controller.abort(), timeout) : undefined;\n      const url = new URL(resource.trim().replace(/^\\/+/, ''), hosts[currentHost]);\n      if (['GET', 'HEAD'].includes(method) && typeof params !== 'undefined') {\n        Object.keys(params).forEach((k) => url.searchParams.append(k, params[k]));\n      }\n      const headers = {\n        'Content-Type': 'application/json; charset=UTF-8',\n        'User-Agent': userAgent,\n        'x-placekit-api-key': apiKey,\n      };\n      if (forwardIP) {\n        headers['x-forwarded-for'] = forwardIP;\n      }\n      return fetch(url, {\n        method,\n        headers,\n        signal: controller.signal,\n        body: !['GET', 'HEAD'].includes(method) ? JSON.stringify(params) : undefined,\n      })\n        .then(async (res) => {\n          clearTimeout(id);\n          const body = await res.json();\n          if (!res.ok) {\n            throw {\n              status: res.status,\n              statusText: res.statusText,\n              ...body,\n            };\n          }\n          return body;\n        })\n        .catch((err) => {\n          if (err.name === 'AbortError' || (err.status && err.status >= 500)) {\n            currentHost++;\n            if (currentHost < hosts.length - 1) {\n              return request(method, resource, opts);\n            }\n          }\n          throw err;\n        });\n    }\n    const client = {\n      get options() {\n        return globalParams;\n      },\n      get hasGeolocation() {\n        return hasGeolocation;\n      },\n      configure(opts = {}) {\n        if (!['object', 'undefined'].includes(typeof opts) || Array.isArray(opts) || opts === null) {\n          throw Error('PlaceKit.configure: `opts` argument is invalid, expected an object.');\n        }\n        Object.assign(globalParams, opts);\n      },\n      requestGeolocation(opts = {}) {\n        if (!['object', 'undefined'].includes(typeof opts) || Array.isArray(opts) || opts === null) {\n          throw Error('PlaceKit.requestGeolocation: `opts` argument is invalid, expected an object.');\n        }\n        return new Promise((resolve, reject) => {\n          if (typeof window === 'undefined' || !navigator.geolocation) {\n            reject(\n              Error('PlaceKit.requestGeolocation: geolocation is only available in the browser.'),\n            );\n          } else {\n            navigator.geolocation.getCurrentPosition(\n              (pos) => {\n                hasGeolocation = true;\n                globalParams.coordinates = `${pos.coords.latitude},${pos.coords.longitude}`;\n                resolve(pos);\n              },\n              (err) => {\n                hasGeolocation = false;\n                delete globalParams.coordinates;\n                reject(Error(`PlaceKit.requestGeolocation: (${err.code}) ${err.message}`));\n              },\n              opts,\n            );\n          }\n        });\n      },\n      clearGeolocation() {\n        hasGeolocation = false;\n        delete globalParams.coordinates;\n      },\n    };\n    for (const [resource, init] of extensions.entries()) {\n      if (resource in client) {\n        throw Error(`PlaceKit extend: \\`client.${resource}\\` already exists.`);\n      }\n      client[resource] = init(request, client);\n    }\n    client.configure(options);\n    return client;\n  }\n  placekit.extend = function (resource, init) {\n    if (!init?.call) {\n      throw Error('PlaceKit extend: `init` argument is invalid, expected a function.');\n    }\n    extensions.set(resource, init);\n  };\n  placekit.extend('search', (request, client) => (query, opts = {}) => {\n    if (!['string', 'undefined'].includes(typeof query)) {\n      throw Error('PlaceKit `client.search`: `query` argument is invalid, expected a string.');\n    }\n    if (!['object', 'undefined'].includes(typeof opts) || Array.isArray(opts) || opts === null) {\n      throw Error('PlaceKit.search: `opts` argument is invalid, expected an object.');\n    }\n    return request('POST', 'search', {\n      ...client.options,\n      ...opts,\n      query,\n    });\n  });\n  placekit.extend('reverse', (request, client) => (opts = {}) => {\n    if (!['object', 'undefined'].includes(typeof opts) || Array.isArray(opts) || opts === null) {\n      throw Error('PlaceKit.reverse: `opts` argument is invalid, expected an object.');\n    }\n    return request('POST', 'reverse', {\n      ...client.options,\n      ...opts,\n    });\n  });\n\n  return placekit;\n\n}));\n"]}