Liferay.Loader.define("commerce-frontend-js@3.0.43/utilities/cookies", ['module', 'exports', 'require'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = void 0;

    function _slicedToArray(arr, i) {
      return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
    }

    function _nonIterableRest() {
      throw new TypeError("Invalid attempt to destructure non-iterable instance");
    }

    function _iterableToArrayLimit(arr, i) {
      if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
        return;
      }var _arr = [];var _n = true;var _d = false;var _e = undefined;try {
        for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
          _arr.push(_s.value);if (i && _arr.length === i) break;
        }
      } catch (err) {
        _d = true;_e = err;
      } finally {
        try {
          if (!_n && _i["return"] != null) _i["return"]();
        } finally {
          if (_d) throw _e;
        }
      }return _arr;
    }

    function _arrayWithHoles(arr) {
      if (Array.isArray(arr)) return arr;
    }

    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;
    }

    /**
     * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
     * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
     */
    var CommerceCookie = /*#__PURE__*/function () {
      function CommerceCookie() {
        var scope = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;

        _classCallCheck(this, CommerceCookie);

        if (!scope) {
          throw new Error('Scope must be defined');
        }

        this.scope = scope;
      }

      _createClass(CommerceCookie, [{
        key: "getValue",
        value: function getValue(key) {
          var _document$cookie$spli = document.cookie.split("".concat(this.scope).concat(key, "=")),
              _document$cookie$spli2 = _slicedToArray(_document$cookie$spli, 2),
              value = _document$cookie$spli2[1];

          return !value ? null : value.split(';')[0];
        }
      }, {
        key: "setValue",
        value: function setValue(key, value, expires) {
          var path = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '/';
          var cookieValue = "".concat(this.scope).concat(key, "=").concat(value, ";"),
              cookiePath = "path=".concat(path, ";");
          var cookieExp = '';

          if (expires) {
            var expirationDate = expires instanceof Date ? expires : new Date(expires);
            cookieExp = "expires=".concat(expirationDate.toUTCString(), ";");
          }

          document.cookie = "".concat(cookieValue).concat(cookieExp).concat(cookiePath);
        }
      }]);

      return CommerceCookie;
    }();

    var _default = CommerceCookie;
    exports.default = _default;
    //# sourceMappingURL=cookies.js.map
  }
});
//# sourceMappingURL=cookies.js.map