Liferay.Loader.define("dynamic-data-mapping-form-field-type@5.0.73/Geolocation/Geolocation.es", ['module', 'exports', 'require', 'dynamic-data-mapping-form-field-type$leaflet/dist/leaflet.css', 'frontend-js-react-web$react', '../FieldBase/ReactFieldBase.es', './useGeolocation.es'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = void 0;

    require("dynamic-data-mapping-form-field-type$leaflet/dist/leaflet.css");

    var _react = _interopRequireDefault(require("frontend-js-react-web$react"));

    var _ReactFieldBase = require("../FieldBase/ReactFieldBase.es");

    var _useGeolocation = require("./useGeolocation.es");

    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { default: obj };
    }

    function _extends() {
      _extends = Object.assign || function (target) {
        for (var i = 1; i < arguments.length; i++) {
          var source = arguments[i];for (var key in source) {
            if (Object.prototype.hasOwnProperty.call(source, key)) {
              target[key] = source[key];
            }
          }
        }return target;
      };return _extends.apply(this, arguments);
    }

    function _objectWithoutProperties(source, excluded) {
      if (source == null) return {};var target = _objectWithoutPropertiesLoose(source, excluded);var key, i;if (Object.getOwnPropertySymbols) {
        var sourceSymbolKeys = Object.getOwnPropertySymbols(source);for (i = 0; i < sourceSymbolKeys.length; i++) {
          key = sourceSymbolKeys[i];if (excluded.indexOf(key) >= 0) continue;if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;target[key] = source[key];
        }
      }return target;
    }

    function _objectWithoutPropertiesLoose(source, excluded) {
      if (source == null) return {};var target = {};var sourceKeys = Object.keys(source);var key, i;for (i = 0; i < sourceKeys.length; i++) {
        key = sourceKeys[i];if (excluded.indexOf(key) >= 0) continue;target[key] = source[key];
      }return target;
    }

    function _typeof(obj) {
      "@babel/helpers - typeof";
      if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
          return typeof obj;
        };
      } else {
        _typeof = function _typeof(obj) {
          return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
      }return _typeof(obj);
    }

    function _classCallCheck(instance, Constructor) {
      if (!(instance instanceof Constructor)) {
        throw new TypeError("Cannot call a class as a function");
      }
    }

    function _defineProperties(target, props) {
      for (var i = 0; i < props.length; i++) {
        var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
      }
    }

    function _createClass(Constructor, protoProps, staticProps) {
      if (protoProps) _defineProperties(Constructor.prototype, protoProps);if (staticProps) _defineProperties(Constructor, staticProps);return Constructor;
    }

    function _possibleConstructorReturn(self, call) {
      if (call && (_typeof(call) === "object" || typeof call === "function")) {
        return call;
      }return _assertThisInitialized(self);
    }

    function _assertThisInitialized(self) {
      if (self === void 0) {
        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
      }return self;
    }

    function _getPrototypeOf(o) {
      _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
        return o.__proto__ || Object.getPrototypeOf(o);
      };return _getPrototypeOf(o);
    }

    function _inherits(subClass, superClass) {
      if (typeof superClass !== "function" && superClass !== null) {
        throw new TypeError("Super expression must either be null or a function");
      }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });if (superClass) _setPrototypeOf(subClass, superClass);
    }

    function _setPrototypeOf(o, p) {
      _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
        o.__proto__ = p;return o;
      };return _setPrototypeOf(o, p);
    }

    var geolocateTitle = Liferay.Language.get('geolocate');
    var pathThemeImages = Liferay.ThemeDisplay.getPathThemeImages();

    var NoRender = /*#__PURE__*/function (_React$Component) {
      _inherits(NoRender, _React$Component);

      function NoRender() {
        _classCallCheck(this, NoRender);

        return _possibleConstructorReturn(this, _getPrototypeOf(NoRender).apply(this, arguments));
      }

      _createClass(NoRender, [{
        key: "shouldComponentUpdate",
        value: function shouldComponentUpdate() {
          return false;
        }
      }, {
        key: "render",
        value: function render() {
          return (/*#__PURE__*/_react.default.createElement("div", this.props)
          );
        }
      }]);

      return NoRender;
    }(_react.default.Component);

    var Geolocation = function Geolocation(_ref) {
      var disabled = _ref.disabled,
          googleMapsAPIKey = _ref.googleMapsAPIKey,
          instanceId = _ref.instanceId,
          mapProviderKey = _ref.mapProviderKey,
          name = _ref.name,
          onChange = _ref.onChange,
          value = _ref.value,
          viewMode = _ref.viewMode,
          otherProps = _objectWithoutProperties(_ref, ["disabled", "googleMapsAPIKey", "instanceId", "mapProviderKey", "name", "onChange", "value", "viewMode"]);

      (0, _useGeolocation.useGeolocation)({
        disabled: disabled,
        googleMapsAPIKey: googleMapsAPIKey,
        instanceId: instanceId,
        mapProviderKey: mapProviderKey,
        name: name,
        onChange: onChange,
        value: value,
        viewMode: viewMode
      });
      return (/*#__PURE__*/_react.default.createElement("div", _extends({}, otherProps, {
          className: "ddm-geolocation field-labels-inline"
        }), !disabled || viewMode ? /*#__PURE__*/_react.default.createElement("dl", null, /*#__PURE__*/_react.default.createElement("dt", {
          className: "text-capitalize"
        }), /*#__PURE__*/_react.default.createElement("dd", null, /*#__PURE__*/_react.default.createElement(NoRender, {
          className: "lfr-map",
          id: "map_".concat(instanceId),
          style: {
            height: '280px'
          }
        }), /*#__PURE__*/_react.default.createElement("input", {
          id: "input_value_".concat(instanceId),
          name: name,
          type: "hidden"
        }))) : /*#__PURE__*/_react.default.createElement("img", {
          alt: pathThemeImages,
          src: "".concat(pathThemeImages, "/common/geolocation.png"),
          title: geolocateTitle
        }))
      );
    };

    var Main = function Main(_ref2) {
      var googleMapsAPIKey = _ref2.googleMapsAPIKey,
          instanceId = _ref2.instanceId,
          _ref2$mapProviderKey = _ref2.mapProviderKey,
          mapProviderKey = _ref2$mapProviderKey === void 0 ? _useGeolocation.MAP_PROVIDER.openStreetMap : _ref2$mapProviderKey,
          name = _ref2.name,
          _onChange = _ref2.onChange,
          readOnly = _ref2.readOnly,
          value = _ref2.value,
          viewMode = _ref2.viewMode,
          otherProps = _objectWithoutProperties(_ref2, ["googleMapsAPIKey", "instanceId", "mapProviderKey", "name", "onChange", "readOnly", "value", "viewMode"]);

      return (/*#__PURE__*/_react.default.createElement(_ReactFieldBase.FieldBase, _extends({}, otherProps, {
          name: name
        }), /*#__PURE__*/_react.default.createElement(Geolocation, {
          disabled: readOnly,
          googleMapsAPIKey: googleMapsAPIKey,
          instanceId: instanceId,
          mapProviderKey: mapProviderKey,
          name: name,
          onChange: function onChange(value) {
            return _onChange({}, value);
          },
          value: value,
          viewMode: viewMode
        }))
      );
    };

    Main.displayName = 'Geolocation';
    var _default = Main;
    exports.default = _default;
    //# sourceMappingURL=Geolocation.es.js.map
  }
});
//# sourceMappingURL=Geolocation.es.js.map