/* global chrome */
import LRU from "lru-cache";
const gapiBase = 'https://www.googleapis.com/calendar/v3';
let loggedIn: boolean = null;
enum GApiError {
invalidSyncToken = "invalidSyncToken",
notLoggedIn = "notLoggedIn",
notLoggedOut = "notLoggedOut",
otherError = "otherError",
}
function toParams(dict: Object) {
return Object.entries(dict).filter(([k, v] : string[]) => v)
.map(([k, v]: string[]) => (
`${encodeURIComponent(k)}=${encodeURIComponent(v)}`
)).join('&');
}
async function _getAuthToken(interactive = false): Promise<string> {
let [token, ok]: [string, boolean] = await new Promise(resolver =>
chrome.identity.getAuthToken(
{