1 | {"version":3,"names":["checkSerializableWithoutCircularReference","o","seen","location","undefined","serializable","Object","prototype","toString","call","Array","isArray","reason","String","has","add","i","length","childResult","Set","key","checkSerializable"],"sources":["checkSerializable.tsx"],"sourcesContent":["const checkSerializableWithoutCircularReference = (\n o: { [key: string]: any },\n seen: Set<any>,\n location: (string | number)[]\n):\n | { serializable: true }\n | {\n serializable: false;\n location: (string | number)[];\n reason: string;\n } => {\n if (\n o === undefined ||\n o === null ||\n typeof o === 'boolean' ||\n typeof o === 'number' ||\n typeof o === 'string'\n ) {\n return { serializable: true };\n }\n\n if (\n Object.prototype.toString.call(o) !== '[object Object]' &&\n !Array.isArray(o)\n ) {\n return {\n serializable: false,\n location,\n reason: typeof o === 'function' ? 'Function' : String(o),\n };\n }\n\n if (seen.has(o)) {\n return {\n serializable: false,\n reason: 'Circular reference',\n location,\n };\n }\n\n seen.add(o);\n\n if (Array.isArray(o)) {\n for (let i = 0; i < o.length; i++) {\n const childResult = checkSerializableWithoutCircularReference(\n o[i],\n new Set<any>(seen),\n [...location, i]\n );\n\n if (!childResult.serializable) {\n return childResult;\n }\n }\n } else {\n for (const key in o) {\n const childResult = checkSerializableWithoutCircularReference(\n o[key],\n new Set<any>(seen),\n [...location, key]\n );\n\n if (!childResult.serializable) {\n return childResult;\n }\n }\n }\n\n return { serializable: true };\n};\n\nexport default function checkSerializable(o: { [key: string]: any }) {\n return checkSerializableWithoutCircularReference(o, new Set<any>(), []);\n}\n"],"mappings":"AAAA,MAAMA,yCAAyC,GAAG,CAChDC,CADgD,EAEhDC,IAFgD,EAGhDC,QAHgD,KAUzC;EACP,IACEF,CAAC,KAAKG,SAAN,IACAH,CAAC,KAAK,IADN,IAEA,OAAOA,CAAP,KAAa,SAFb,IAGA,OAAOA,CAAP,KAAa,QAHb,IAIA,OAAOA,CAAP,KAAa,QALf,EAME;IACA,OAAO;MAAEI,YAAY,EAAE;IAAhB,CAAP;EACD;;EAED,IACEC,MAAM,CAACC,SAAP,CAAiBC,Q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