import { decode as a } from "js-base64";
let n = "";
const i = {
  setToken: (t) => {
    const e = r(t).ten || "_", o = window.location.pathname.split("/")[3];
    n = window.location.hostname !== "localhost" ? `${e}.${o}.u` : "u", window.localStorage.setItem(n, t);
  },
  getToken: (t) => {
    const e = window.localStorage.getItem(t || n);
    if (!e)
      return "";
    try {
      const o = JSON.parse(e);
      return o.token ? o.token : "";
    } catch (o) {
      return e;
    }
  },
  delToken: (t) => {
    window.localStorage.removeItem(t || n);
  },
  setIdTokenHint: (t) => {
    const e = r(t).ten || "_", o = window.location.pathname.split("/")[3];
    n = window.location.hostname !== "localhost" ? `${e}.${o}.idu` : "idu", window.localStorage.setItem(n, t);
  },
  getIdTokenHint: (t) => {
    const e = window.localStorage.getItem(t || n);
    if (!e)
      return "";
    try {
      const o = JSON.parse(e);
      return o.token ? o.token : "";
    } catch (o) {
      return e;
    }
  },
  delIdTokenHint: (t) => {
    window.localStorage.removeItem(t || n);
  }
}, r = (t) => JSON.parse(a(t.split(".")[1])), l = (t) => {
  const e = r(t).exp;
  return (/* @__PURE__ */ new Date()).valueOf() / 1e3 >= e;
}, d = window.location.pathname.split("/")[3];
export {
  r as JWT,
  l as isExpired,
  d as productCode,
  i as tokenTool
};
