{"ast":null,"code":"\"use strict\";\n\nvar _defineProperty = require(\"@babel/runtime/helpers/defineProperty\");\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nvar __importDefault = this && this.__importDefault || function (mod) {\n  return mod && mod.__esModule ? mod : {\n    \"default\": mod\n  };\n};\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nexports.useSelectedLog = exports.useLogs = exports.LogContext = void 0;\nvar react_1 = __importDefault(require(\"react\"));\nvar react_native_1 = require(\"react-native-web/dist/index\");\nvar LogBoxLog_1 = require(\"./LogBoxLog\");\nexports.LogContext = react_1.default.createContext(null);\nfunction useLogs() {\n  var logs = react_1.default.useContext(exports.LogContext);\n  if (!logs) {\n    if (react_native_1.Platform.OS === \"web\" && typeof window !== \"undefined\") {\n      var expoCliStaticErrorElement = document.getElementById(\"_expo-static-error\");\n      if (expoCliStaticErrorElement === null || expoCliStaticErrorElement === void 0 ? void 0 : expoCliStaticErrorElement.textContent) {\n        var raw = JSON.parse(expoCliStaticErrorElement.textContent);\n        return _objectSpread(_objectSpread({}, raw), {}, {\n          logs: raw.logs.map(function (raw) {\n            return new LogBoxLog_1.LogBoxLog(raw);\n          })\n        });\n      }\n    }\n    throw new Error(\"useLogs must be used within a LogProvider\");\n  }\n  return logs;\n}\nexports.useLogs = useLogs;\nfunction useSelectedLog() {\n  var _useLogs = useLogs(),\n    selectedLogIndex = _useLogs.selectedLogIndex,\n    logs = _useLogs.logs;\n  return logs[selectedLogIndex];\n}\nexports.useSelectedLog = useSelectedLog;","map":{"version":3,"sources":["../../../src/error-overlay/Data/LogContext.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,IAAA,OAAA,GAAA,eAAA,CAAA,OAAA,CAAA,OAAA,CAAA,CAAA;AAA0B,IAAA,cAAA,GAAA,OAAA;AAG1B,IAAA,WAAA,GAAA,OAAA,cAAA,CAAA;AAIa,OAAA,CAAA,UAAU,GAAG,OAAA,CAAA,OAAK,CAAC,aAAa,CAInC,IAAI,CAAC;AAEf,SAAgB,OAAO,CAAA,EAAA;EAKrB,IAAM,IAAI,GAAG,OAAA,CAAA,OAAK,CAAC,UAAU,CAAC,OAAA,CAAA,UAAU,CAAC;EACzC,IAAI,CAAC,IAAI,EAAE;IACT,IAAI,cAAA,CAAA,QAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;MAE1D,IAAM,yBAAyB,GAC7B,QAAQ,CAAC,cAAc,CAAC,oBAAoB,CAAC;MAC/C,IAAI,yBAAyB,KAAA,IAAA,IAAzB,yBAAyB,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAzB,yBAAyB,CAAE,WAAW,EAAE;QAC1C,IAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAC,WAAW,CAAC;QAC7D,OAAA,aAAA,CAAA,aAAA,KACK,GAAG;UACN,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,UAAC,GAAQ;YAAA,OAAK,IAAI,WAAA,CAAA,SAAS,CAAC,GAAG,CAAC;UAAA;QAAC;MAEvD;IACF;IAED,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC;EAC7D;EACD,OAAO,IAAI;AACb;AAvBA,OAAA,CAAA,OAAA,GAAA,OAAA;AAyBA,SAAgB,cAAc,CAAA,EAAA;EAC5B,IAAA,QAAA,GAAmC,OAAO,CAAA,CAAE;IAApC,gBAAgB,GAAA,QAAA,CAAhB,gBAAgB;IAAE,IAAI,GAAA,QAAA,CAAJ,IAAI;EAC9B,OAAO,IAAI,CAAC,gBAAgB,CAAC;AAC/B;AAHA,OAAA,CAAA,cAAA,GAAA,cAAA","sourcesContent":["import React from \"react\";\nimport { Platform } from \"react-native\";\n\nimport { LogBoxLog } from \"./LogBoxLog\";\n\n// Context provider for Array<LogBoxLog>\n\nexport const LogContext = React.createContext<{\n  selectedLogIndex: number;\n  isDisabled: boolean;\n  logs: LogBoxLog[];\n} | null>(null);\n\nexport function useLogs(): {\n  selectedLogIndex: number;\n  isDisabled: boolean;\n  logs: LogBoxLog[];\n} {\n  const logs = React.useContext(LogContext);\n  if (!logs) {\n    if (Platform.OS === \"web\" && typeof window !== \"undefined\") {\n      // Logbox data that is pre-fetched on the dev server and rendered here.\n      const expoCliStaticErrorElement =\n        document.getElementById(\"_expo-static-error\");\n      if (expoCliStaticErrorElement?.textContent) {\n        const raw = JSON.parse(expoCliStaticErrorElement.textContent);\n        return {\n          ...raw,\n          logs: raw.logs.map((raw: any) => new LogBoxLog(raw)),\n        };\n      }\n    }\n\n    throw new Error(\"useLogs must be used within a LogProvider\");\n  }\n  return logs;\n}\n\nexport function useSelectedLog() {\n  const { selectedLogIndex, logs } = useLogs();\n  return logs[selectedLogIndex];\n}\n"],"sourceRoot":""},"metadata":{},"sourceType":"script"}