"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getAuthority = getAuthority;
exports.setAuthority = setAuthority;

var _Authorized = require("./Authorized");

function getAuthority(str) {
  var authorityString = typeof str === 'undefined' && localStorage ? localStorage.getItem('antd-pro-authority') : str;
  var authority;

  try {
    if (authorityString) {
      authority = JSON.parse(authorityString);
    }
  } catch (e) {
    authority = authorityString;
  }

  if (typeof authority === 'string') {
    return [authority];
  }

  return authority;
}

function setAuthority(authority) {
  var proAuthority = typeof authority === 'string' ? [authority] : authority;
  localStorage.setItem('antd-pro-authority', JSON.stringify(proAuthority));
  (0, _Authorized.reloadAuthorized)();
}