"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.fetchCurrency = void 0;
var _dataSources = require("@mirai/data-sources");
var _services = require("@mirai/services");
const fetchCurrency = async id => {
  var _window$navigator$lan, _await$ServiceHotel$g;
  const [, navigatorCountry] = ((_window$navigator$lan = window.navigator.language) === null || _window$navigator$lan === void 0 ? void 0 : _window$navigator$lan.split('-')) || [];
  const {
    country = navigatorCountry
  } = (await (0, _dataSources.request)({
    hostname: process.env.SERVICE_CURRENCY,
    endpoint: '/ip/get',
    headers: {
      'X-Requested-With': undefined,
      Authorization: 'Basic YW5vbmltb3VzOmFub25pbW91cw=='
    }
  }).catch(() => {})) || {};
  return country ? (_await$ServiceHotel$g = await _services.ServiceHotel.getCurrencies(id).catch(() => ({}))) === null || _await$ServiceHotel$g === void 0 ? void 0 : _await$ServiceHotel$g[country] : undefined;
};
exports.fetchCurrency = fetchCurrency;
//# sourceMappingURL=fetchCurrency.js.map