(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define([], factory);
	else if(typeof exports === 'object')
		exports["main"] = factory();
	else
		root["main"] = factory();
})((typeof self !== 'undefined' ? self : this), function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "/";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ({

/***/ "./GMailBitFactory.ts":
/*!****************************!*\
  !*** ./GMailBitFactory.ts ***!
  \****************************/
/*! no static exports found */
/*! exports used: GMailBitFactory */
/***/ (function(module, exports) {



/***/ }),

/***/ "./GMailLoader.ts":
/*!************************!*\
  !*** ./GMailLoader.ts ***!
  \************************/
/*! no static exports found */
/*! exports used: GMailLoader */
/***/ (function(module, exports) {



/***/ }),

/***/ "./GMailMessageParser.ts":
/*!*******************************!*\
  !*** ./GMailMessageParser.ts ***!
  \*******************************/
/*! no static exports found */
/*! exports used: GMailMessageParser */
/***/ (function(module, exports) {



/***/ }),

/***/ "./GMailSyncer.node.ts":
/*!*****************************!*\
  !*** ./GMailSyncer.node.ts ***!
  \*****************************/
/*! exports provided: GMailSyncer */
/*! exports used: GMailSyncer */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GMailSyncer; });
/* harmony import */ var _o_worker_kit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @o/worker-kit */ "@o/worker-kit");
/* harmony import */ var _o_worker_kit__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_o_worker_kit__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash */ "lodash");
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _GMailBitFactory__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./GMailBitFactory */ "./GMailBitFactory.ts");
/* harmony import */ var _GMailBitFactory__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_GMailBitFactory__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _GMailLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./GMailLoader */ "./GMailLoader.ts");
/* harmony import */ var _GMailLoader__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_GMailLoader__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _GMailMessageParser__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./GMailMessageParser */ "./GMailMessageParser.ts");
/* harmony import */ var _GMailMessageParser__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_GMailMessageParser__WEBPACK_IMPORTED_MODULE_4__);






/**
 * Syncs GMail.
 */
const GMailSyncer = async (_ref) => {
  let {
    app,
    log,
    utils
  } = _ref;
  const data = app.data;
  const loader = new _GMailLoader__WEBPACK_IMPORTED_MODULE_3__["GMailLoader"](app, log, () => utils.updateAppData());
  const factory = new _GMailBitFactory__WEBPACK_IMPORTED_MODULE_2__["GMailBitFactory"](utils);
  /**
   * Handles a single thread.
   */

  const handleThread = async (thread, cursor, loadedCount, isLast) => {
    const lastSync = data.values.lastSync; // for the first ever synced thread we store its history id, and once sync is done,
    // we use this history to id to load further newly added or removed messages

    if (!lastSync.lastCursorHistoryId) {
      lastSync.lastCursorHistoryId = thread.historyId;
      log.info('looks like its the first syncing thread, set history id', lastSync);
      await utils.updateAppData();
    } // sync a thread


    await syncThread(thread); // in the case if its the last thread we need to cleanup last cursor stuff and save last synced date

    if (isLast) {
      log.info('looks like its the last thread in this sync, removing last cursor and source last sync date', lastSync);
      lastSync.historyId = lastSync.lastCursorHistoryId;
      lastSync.lastCursor = undefined;
      lastSync.lastCursorHistoryId = undefined;
      lastSync.lastCursorLoadedCount = undefined;
      await utils.updateAppData();
      return true;
    } // update last sync settings to make sure we continue from the last point in the case if application will stop


    if (lastSync.lastCursor !== cursor) {
      log.verbose('updating last cursor in settings', {
        cursor
      });
      lastSync.lastCursor = cursor;
      lastSync.lastCursorLoadedCount = loadedCount;
      await utils.updateAppData();
    }

    return true;
  };
  /**
   * Syncs a given thread.
   */


  const syncThread = async thread => {
    const participants = extractThreadParticipants(thread);
    const bit = factory.createMailBit(thread); // if email doesn't have body messages we don't need to sync it

    if (!bit) return;
    bit.people = participants.map(participant => factory.createPersonBit(participant));
    await utils.saveBits(bit.people);
    await utils.saveBit(bit);
    return true;
  };
  /**
   * Extracts all participants from a given gmail threads.
   */


  const extractThreadParticipants = thread => {
    const allParticipants = [];

    for (let message of thread.messages) {
      const parser = new _GMailMessageParser__WEBPACK_IMPORTED_MODULE_4__["GMailMessageParser"](message);
      const participants = parser.getParticipants();

      for (let participant of participants) {
        const inAllParticipant = allParticipants.find(p => p.email === participant.email);

        if (inAllParticipant) {
          if (!inAllParticipant.name && participant.name) inAllParticipant.name = participant.name;
        } else {
          allParticipants.push(participant);
        }
      }
    }

    return allParticipants;
  }; // mail whitelister
  // load person because we need emails that we want to whitelist


  const people = await utils.loadBits({
    type: 'person',
    appIdentifiers: ['slack', 'github', 'drive', 'jira', 'confluence']
  });
  const emails = people.map(person => person.email).filter(email => email.indexOf('@') !== -1);
  log.info('emails from the person bits', emails); // next we find all gmail Apps to add those emails to their whitelists

  const Apps = await utils.loadApps({
    identifier: 'gmail'
  }); // update whitelist settings in Apps

  const newWhiteListedEmails = [];

  for (let App of Apps) {
    const values = App.data.values;
    const foundEmails = values.foundEmails || [];
    const whitelist = {};

    for (let email of emails) {
      if (foundEmails.indexOf(email) === -1) {
        whitelist[email] = true;
        newWhiteListedEmails.push(email);
      }
    }

    values.whitelist = whitelist;
    await utils.updateAppData();
  }

  log.info('newly whitelisted emails', newWhiteListedEmails); // gmail sync

  log.info('sync gmail based on settings', data.values); // setup default source configuration values

  if (!data.values.lastSync) data.values.lastSync = {};
  if (!data.values.max) data.values.max = 10000;
  if (!data.values.daysLimit) data.values.daysLimit = 330; // setup some local variables we are gonna work with

  const queryFilter = data.values.filter || "newer_than:" + data.values.daysLimit + "d";
  let lastSync = data.values.lastSync; // update last sync configuration

  log.info('updating sync sources');
  lastSync.usedQueryFilter = queryFilter;
  lastSync.usedDaysLimit = data.values.daysLimit;
  lastSync.usedMax = data.values.max;
  await utils.updateAppData(); // if user configuration has changed (max number of messages, days limitation or query filter)
  // we drop all bits to make complete sync again

  if (lastSync.usedMax !== undefined && data.values.max !== lastSync.usedMax || lastSync.usedQueryFilter !== undefined && queryFilter !== lastSync.usedQueryFilter || lastSync.usedDaysLimit !== undefined && data.values.daysLimit !== lastSync.usedDaysLimit) {
    log.info('last syncronization configuration mismatch, dropping bits and start sync from scratch');
    await utils.clearBits();
    data.values.lastSync = lastSync = {};
  } // we if we have last history id it means we already did a complete sync and now we are using
  // gmail's history api to get email events information and sync based on this information


  if (lastSync.historyId) {
    // load history
    const history = await loader.loadHistory(lastSync.historyId); // load threads for newly added / changed threads

    if (history.addedThreadIds.length) {
      log.timer('found added/changed messages in history', history.addedThreadIds.length); // convert added thread ids into thread objects and load their messages

      const addedThreads = await Promise.all(history.addedThreadIds.map(async threadId => {
        return {
          id: threadId,
          historyId: history.historyId,
          messages: null
        };
      }));
      await loader.loadMessages(addedThreads); // sync threads

      for (let thread of addedThreads) {
        await utils.isAborted();
        await Object(_o_worker_kit__WEBPACK_IMPORTED_MODULE_0__["sleep"])(10);
        await syncThread(thread);
      }

      log.timer('found added or changed messages in history');
    } else {
      log.info('no added or changed messages in history were found');
    } // load bits for removed threads and remove them


    if (history.removedThreadIds.length) {
      log.info('found actions in history for thread removals', history.removedThreadIds.length);
      const removedBits = await utils.loadBits({
        ids: history.removedThreadIds.map(threadId => utils.generateBitId(threadId))
      });
      await utils.removeBits(removedBits);
    } else {
      log.info('no removed messages in history were found');
    }

    lastSync.historyId = history.historyId;
    await utils.updateAppData();
  } else {
    // else this is a first time sync, load all threads
    await loader.loadThreads({
      count: data.values.max,
      queryFilter: queryFilter,
      pageToken: lastSync.lastCursor,
      loadedCount: lastSync.lastCursorLoadedCount || 0,
      handler: handleThread
    });
  } // load emails for whitelisted people separately
  // we don't make this operation on a first sync because we can miss newly added emails
  // this operation is relatively cheap, so for now we are okay with it


  if (data.values.whitelist) {
    log.info('checking whitelist', data.values.whitelist);
    const whitelistEmails = Object.keys(data.values.whitelist).filter(email => data.values.whitelist[email] === true);

    if (whitelistEmails.length > 0) {
      log.timer('load threads from whitelisted people', whitelistEmails); // we split emails into chunks because gmail api can't handle huge queries

      const emailChunks = Object(lodash__WEBPACK_IMPORTED_MODULE_1__["chunk"])(whitelistEmails, 100);

      for (let emls of emailChunks) {
        const whitelistFilter = emls.map(email => 'from:' + email).join(' OR ');
        await loader.loadThreads({
          count: data.values.max,
          queryFilter: whitelistFilter,
          loadedCount: 0,
          handler: syncThread
        });
      }

      log.timer('load threads from whitelisted people');
    } else {
      log.info('no enabled people in whitelist were found');
    }
  }
};

/***/ }),

/***/ "./GmailSettings.tsx":
/*!***************************!*\
  !*** ./GmailSettings.tsx ***!
  \***************************/
/*! no static exports found */
/*! exports used: GmailSettings */
/***/ (function(module, exports) {



/***/ }),

/***/ "./GmailSyncerWorker.node.ts":
/*!***********************************!*\
  !*** ./GmailSyncerWorker.node.ts ***!
  \***********************************/
/*! exports provided: GmailSyncerWorker */
/*! exports used: GmailSyncerWorker */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GmailSyncerWorker; });
/* harmony import */ var _o_worker_kit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @o/worker-kit */ "@o/worker-kit");
/* harmony import */ var _o_worker_kit__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_o_worker_kit__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _GMailSyncer_node__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./GMailSyncer.node */ "./GMailSyncer.node.ts");


const GmailSyncerWorker = async () => {
  const syncer = new _o_worker_kit__WEBPACK_IMPORTED_MODULE_0__["Syncer"]({
    id: 'gmail',
    appIdentifier: 'gmail',
    name: 'Gmail',
    runner: _GMailSyncer_node__WEBPACK_IMPORTED_MODULE_1__[/* GMailSyncer */ "a"],
    interval: 1000 * 60 * 5 // 5 minutes

  });
  await syncer.start();
};

/***/ }),

/***/ "./api.graph.node.ts":
/*!***************************!*\
  !*** ./api.graph.node.ts ***!
  \***************************/
/*! exports provided: graph */
/*! exports used: graph */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return graph; });
/* harmony import */ var gapi_to_graphql__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! gapi-to-graphql */ "gapi-to-graphql");
/* harmony import */ var gapi_to_graphql__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(gapi_to_graphql__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var gapi_to_graphql_google_apis_gmail_v1__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! gapi-to-graphql/google_apis/gmail-v1 */ "gapi-to-graphql/google_apis/gmail-v1");
/* harmony import */ var gapi_to_graphql_google_apis_gmail_v1__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(gapi_to_graphql_google_apis_gmail_v1__WEBPACK_IMPORTED_MODULE_1__);


async function graph() {
  return gapi_to_graphql__WEBPACK_IMPORTED_MODULE_0___default()({
    gapiAsJsonSchema: gapi_to_graphql_google_apis_gmail_v1__WEBPACK_IMPORTED_MODULE_1___default.a
  });
}

/***/ }),

/***/ "./api.node.ts":
/*!*********************!*\
  !*** ./api.node.ts ***!
  \*********************/
/*! exports provided: default */
/*! exports used: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony import */ var _o_kit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @o/kit */ "@o/kit");
/* harmony import */ var _o_kit__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_o_kit__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var googleapis__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! googleapis */ "googleapis");
/* harmony import */ var googleapis__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(googleapis__WEBPACK_IMPORTED_MODULE_1__);


const Config = Object(_o_kit__WEBPACK_IMPORTED_MODULE_0__["getGlobalConfig"])();
/* harmony default export */ __webpack_exports__["a"] = (app => {
  const oauth2Client = new googleapis__WEBPACK_IMPORTED_MODULE_1__["google"].auth.OAuth2('97251911865-qm0isevf5m3omuice4eg3s4uq9i99gcn.apps.googleusercontent.com', 'LLXP2Vq36socQtgXy_XQqLOW', Config.urls.auth + '/auth/gmail/callback');
  oauth2Client.setCredentials({
    access_token: app.token,
    refresh_token: app.data.values.oauth.refreshToken
  });
  const gmail = googleapis__WEBPACK_IMPORTED_MODULE_1__["google"].gmail({
    version: 'v1',
    auth: oauth2Client
  });
  return {
    createDraft(params, options) {
      return gmail.users.drafts.create(params, options);
    },

    deleteDraft(params, options) {
      return gmail.users.drafts.delete(params, options);
    },

    getDraft(params, options) {
      return gmail.users.drafts.get(params, options);
    },

    listDrafts(params, options) {
      return gmail.users.drafts.list(params, options);
    },

    sendDraft(params, options) {
      return gmail.users.drafts.send(params, options);
    },

    updateDraft(params, options) {
      return gmail.users.drafts.update(params, options);
    },

    getProfile(params, options) {
      return gmail.users.getProfile(params, options);
    },

    historyList(params, options) {
      return gmail.users.history.list(params, options);
    },

    createLabel(params, options) {
      return gmail.users.labels.create(params, options);
    },

    deleteLabel(params, options) {
      return gmail.users.labels.delete(params, options);
    },

    getLabel(params, options) {
      return gmail.users.labels.get(params, options);
    },

    listLabel(params, options) {
      return gmail.users.labels.list(params, options);
    },

    patchLabel(params, options) {
      return gmail.users.labels.patch(params, options);
    },

    updateLabel(params, options) {
      return gmail.users.labels.update(params, options);
    },

    getMessageAttachements(params, options) {
      return gmail.users.messages.attachments.get(params, options);
    },

    batchDeleteMessages(params, options) {
      return gmail.users.messages.batchDelete(params, options);
    },

    batchModifyMessages(params, options) {
      return gmail.users.messages.batchModify(params, options);
    },

    deleteMessage(params, options) {
      return gmail.users.messages.delete(params, options);
    },

    getMessage(params, options) {
      return gmail.users.messages.get(params, options);
    },

    importMessages(params, options) {
      return gmail.users.messages.import(params, options);
    },

    insertMessage(params, options) {
      return gmail.users.messages.insert(params, options);
    },

    listMessages(params, options) {
      return gmail.users.messages.list(params, options);
    },

    modifyMessage(params, options) {
      return gmail.users.messages.modify(params, options);
    },

    sendMessage(params, options) {
      return gmail.users.messages.send(params, options);
    },

    trashMessage(params, options) {
      return gmail.users.messages.trash(params, options);
    },

    untrashMessage(params, options) {
      return gmail.users.messages.untrash(params, options);
    },

    deleteThread(params, options) {
      return gmail.users.threads.delete(params, options);
    },

    getThread(params, options) {
      return gmail.users.threads.get(params, options);
    },

    listThreads(params, options) {
      return gmail.users.threads.list(params, options);
    },

    modifyThread(params, options) {
      return gmail.users.threads.modify(params, options);
    },

    trashThread(params, options) {
      return gmail.users.threads.trash(params, options);
    },

    untrashThread(params, options) {
      return gmail.users.threads.untrash(params, options);
    }

  };
});

/***/ }),

/***/ "./index.tsx":
/*!*******************!*\
  !*** ./index.tsx ***!
  \*******************/
/*! exports provided: default */
/*! all exports used */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _o_kit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @o/kit */ "@o/kit");
/* harmony import */ var _o_kit__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_o_kit__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _api_graph_node__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./api.graph.node */ "./api.graph.node.ts");
/* harmony import */ var _api_node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./api.node */ "./api.node.ts");
/* harmony import */ var _GMailLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./GMailLoader */ "./GMailLoader.ts");
/* harmony import */ var _GMailLoader__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_GMailLoader__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _GmailSettings__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./GmailSettings */ "./GmailSettings.tsx");
/* harmony import */ var _GmailSettings__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_GmailSettings__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _GmailSyncerWorker_node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./GmailSyncerWorker.node */ "./GmailSyncerWorker.node.ts");






/* harmony default export */ __webpack_exports__["default"] = (Object(_o_kit__WEBPACK_IMPORTED_MODULE_0__["createApp"])({
  id: 'gmail',
  name: 'Gmail',
  itemType: 'thread',
  auth: 'gmail',
  finishAuth: async (app, _values, oauth) => {
    const loader = new _GMailLoader__WEBPACK_IMPORTED_MODULE_3__["GMailLoader"](app);
    const profile = await loader.loadProfile();
    app.name = profile.emailAddress;
    app.data.values.oauth.secret = oauth.credentials.clientSecret;
    app.data.values.oauth.clientId = oauth.credentials.clientID;
    return app;
  },
  settings: _GmailSettings__WEBPACK_IMPORTED_MODULE_4__["GmailSettings"],
  workers: [_GmailSyncerWorker_node__WEBPACK_IMPORTED_MODULE_5__[/* GmailSyncerWorker */ "a"]],
  api: _api_node__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"],
  graph: _api_graph_node__WEBPACK_IMPORTED_MODULE_1__[/* graph */ "a"],
  icon: "\n<svg version=\"1.1\" id=\"Layer_1\" x=\"0px\" y=\"0px\" viewBox=\"0 0 512 512\" style=\"enable-background:new 0 0 512 512;\">\n  <g>\n    <polygon style=\"fill:#F2F2F2;\" points=\"484.973,122.808 452.288,451.017 59.712,451.017 33.379,129.16 256,253.802 \t\"/>\n    <polygon style=\"fill:#F2F2F2;\" points=\"473.886,60.983 256,265.659 38.114,60.983 256,60.983 \t\"/>\n  </g>\n  <path style=\"fill:#F14336;\" d=\"M59.712,155.493v295.524H24.139C10.812,451.017,0,440.206,0,426.878V111.967l39,1.063L59.712,155.493\n    z\"/>\n  <path style=\"fill:#D32E2A;\" d=\"M512,111.967v314.912c0,13.327-10.812,24.139-24.152,24.139h-35.56V155.493l19.692-46.525\n    L512,111.967z\"/>\n  <path style=\"fill:#F14336;\" d=\"M512,85.122v26.845l-59.712,43.526L256,298.561L59.712,155.493L0,111.967V85.122\n    c0-13.327,10.812-24.139,24.139-24.139h13.975L256,219.792L473.886,60.983h13.962C501.188,60.983,512,71.794,512,85.122z\"/>\n  <polygon style=\"fill:#D32E2A;\" points=\"59.712,155.493 0,146.235 0,111.967 \"/>\n</svg>\n  ".trim()
}));

/***/ }),

/***/ 0:
/*!*************************!*\
  !*** multi ./index.tsx ***!
  \*************************/
/*! no static exports found */
/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__(/*! /Users/nw/projects/motion/orbit/apps/gmail-app/index.tsx */"./index.tsx");


/***/ }),

/***/ "@o/kit":
/*!*************************!*\
  !*** external "@o/kit" ***!
  \*************************/
/*! no static exports found */
/*! exports used: createApp, getGlobalConfig */
/***/ (function(module, exports) {

module.exports = require("@o/kit");

/***/ }),

/***/ "@o/worker-kit":
/*!********************************!*\
  !*** external "@o/worker-kit" ***!
  \********************************/
/*! no static exports found */
/*! exports used: Syncer, sleep */
/***/ (function(module, exports) {

module.exports = require("@o/worker-kit");

/***/ }),

/***/ "gapi-to-graphql":
/*!**********************************!*\
  !*** external "gapi-to-graphql" ***!
  \**********************************/
/*! no static exports found */
/*! exports used: default */
/***/ (function(module, exports) {

module.exports = require("gapi-to-graphql");

/***/ }),

/***/ "gapi-to-graphql/google_apis/gmail-v1":
/*!*******************************************************!*\
  !*** external "gapi-to-graphql/google_apis/gmail-v1" ***!
  \*******************************************************/
/*! no static exports found */
/*! exports used: default */
/***/ (function(module, exports) {

module.exports = require("gapi-to-graphql/google_apis/gmail-v1");

/***/ }),

/***/ "googleapis":
/*!*****************************!*\
  !*** external "googleapis" ***!
  \*****************************/
/*! no static exports found */
/*! exports used: google */
/***/ (function(module, exports) {

module.exports = require("googleapis");

/***/ }),

/***/ "lodash":
/*!*************************!*\
  !*** external "lodash" ***!
  \*************************/
/*! no static exports found */
/*! exports used: chunk */
/***/ (function(module, exports) {

module.exports = require("lodash");

/***/ })

/******/ });
});
//# sourceMappingURL=index.node.js.map