import _typeof from '@babel/runtime/helpers/typeof';
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
import _createClass from '@babel/runtime/helpers/createClass';
import { callJsBrowserAdapter } from '../../msdk/msdk.mjs';
import { LocationFlag } from '../location-interface.mjs';
import '../../env/env.mjs';
import '../../loader/little-loader.mjs';

var SlugSdkLocation = /*#__PURE__*/function () {
  function SlugSdkLocation() {
    _classCallCheck(this, SlugSdkLocation);
  }
  return _createClass(SlugSdkLocation, [{
    key: "getLocation",
    value: function getLocation() {
      return new Promise(function (resolve, reject) {
        callJsBrowserAdapter().then(function () {
          if (_typeof(window.customBrowserInterface) === 'object') {
            window.customBrowserInterface.getLocationInfo(function (result) {
              if ((result === null || result === void 0 ? void 0 : result.code) == 1) {
                var location = {
                  lat: result.latitude,
                  lng: result.longitude
                };
                resolve({
                  location: location,
                  flag: LocationFlag.LocationSuccess
                });
              } else {
                reject({
                  flag: result.code
                });
              }
            });
          } else {
            reject({
              flag: LocationFlag.LocationFailed
            });
          }
        })["catch"](function () {
          reject({
            flag: LocationFlag.LocationFailed
          });
        });
      });
    }
  }]);
}();

export { SlugSdkLocation as default };
