{"ast":null,"code":"import _regeneratorRuntime from \"@babel/runtime/regenerator\";\nimport { v4 as uuidv4 } from 'uuid';\nvar INSTALLATION_ID_KEY = 'installationId';\nvar installationId = null;\nexport default function getInstallationIdAsync() {\n  return _regeneratorRuntime.async(function getInstallationIdAsync$(_context) {\n    while (1) {\n      switch (_context.prev = _context.next) {\n        case 0:\n          if (!installationId) {\n            _context.next = 2;\n            break;\n          }\n\n          return _context.abrupt(\"return\", installationId);\n\n        case 2:\n          _context.prev = 2;\n          installationId = localStorage.getItem(INSTALLATION_ID_KEY);\n\n          if (!installationId) {\n            _context.next = 6;\n            break;\n          }\n\n          return _context.abrupt(\"return\", installationId);\n\n        case 6:\n          _context.next = 10;\n          break;\n\n        case 8:\n          _context.prev = 8;\n          _context.t0 = _context[\"catch\"](2);\n\n        case 10:\n          installationId = uuidv4();\n\n          try {\n            localStorage.setItem(INSTALLATION_ID_KEY, installationId);\n          } catch (error) {\n            console.debug('[expo-notifications] Could not save installation ID in persisted storage, it will get reset.', error);\n          }\n\n          return _context.abrupt(\"return\", installationId);\n\n        case 13:\n        case \"end\":\n          return _context.stop();\n      }\n    }\n  }, null, null, [[2, 8]], Promise);\n}","map":{"version":3,"sources":["../../src/environment/getInstallationIdAsync.web.ts"],"names":[],"mappings":";AAAA,SAAS,EAAE,IAAI,MAAf,QAA6B,MAA7B;AAEA,IAAM,mBAAmB,GAAG,gBAA5B;AAEA,IAAI,cAAc,GAAkB,IAApC;AAEA,eAAe,SAAe,sBAAf;AAAA;AAAA;AAAA;AAAA;AAAA,eAET,cAFS;AAAA;AAAA;AAAA;;AAAA,2CAGJ,cAHI;;AAAA;AAAA;AAQX,UAAA,cAAc,GAAG,YAAY,CAAC,OAAb,CAAqB,mBAArB,CAAjB;;AARW,eASP,cATO;AAAA;AAAA;AAAA;;AAAA,2CAUF,cAVE;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAkBb,UAAA,cAAc,GAAG,MAAM,EAAvB;;AAEA,cAAI;AACF,YAAA,YAAY,CAAC,OAAb,CAAqB,mBAArB,EAA0C,cAA1C;AACD,WAFD,CAEE,OAAO,KAAP,EAAc;AACd,YAAA,OAAO,CAAC,KAAR,CACE,8FADF,EAEE,KAFF;AAID;;AA3BY,2CA6BN,cA7BM;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["import { v4 as uuidv4 } from 'uuid';\n\nconst INSTALLATION_ID_KEY = 'installationId';\n\nlet installationId: string | null = null;\n\nexport default async function getInstallationIdAsync() {\n  // Already cached value\n  if (installationId) {\n    return installationId;\n  }\n\n  try {\n    // No cached value, fetch from persisted storage\n    installationId = localStorage.getItem(INSTALLATION_ID_KEY);\n    if (installationId) {\n      return installationId;\n    }\n  } catch (error) {\n    // If we weren't able to fetch one (for whatever reason)\n    // let's create a new one.\n  }\n\n  // No persisted value, set the cached value...\n  installationId = uuidv4();\n  // ...and try to persist it. Ignore the errors.\n  try {\n    localStorage.setItem(INSTALLATION_ID_KEY, installationId);\n  } catch (error) {\n    console.debug(\n      '[expo-notifications] Could not save installation ID in persisted storage, it will get reset.',\n      error\n    );\n  }\n\n  return installationId;\n}\n"],"sourceRoot":""},"metadata":{},"sourceType":"module"}