// background.js
// MUST BE LOCATED IN ROOT
try {
  importScripts('js/faUtil.js');
} catch (e) {
  console.error(e);
}

// Handle what happens on install and update
chrome.runtime.onInstalled.addListener(async (details) => {
  try {
    //const client_id = "f2934e8c-52f2-4b48-88d1-f26e56626bbd"
    //const client_secret ="fa-secret-CA5997239D3EAFE7B4B60F" 
    const tag_list_field_tid = "586c2e4b-18ff-4e67-9a94-23be97ceae99"
    const client_id = "1e61961a-909c-413d-84aa-7a03ebbdc68d"
    const client_secret = "fa-secret-FDB11BE4D952C29CA1FE7A"

    // Create storage strucutre
    chrome.storage.sync.set({
      "profiles": [],
      "lists": {},
      "uid": "",
      "faKeys": {
        client_id,
        client_secret,
        tag_list_field_tid,
        source_tid: "55359e96-9daa-46d6-90c7-f1da4cb85ce1"
      },
      "tag_list_id": "",
      "lead_source_id": "",
      "access_token": "",
      "refresh_token": "",
      "frameURL": chrome.runtime.getURL("current.html"),
      "buttonImageURL": chrome.runtime.getURL("images/faIcon.svg"),
      "curProfile": null
    }, async () => {

    });

    // Show on install page
    chrome.tabs.create({
      url: chrome.runtime.getURL("install.html")
    });
  }
  catch (e) {
    console.log(e);
  }
});