{"version":3,"file":"PathFormatter.cjs","names":["tsplus_module_1","formatTypeError","tsplus_module_2","getMessage"],"sources":["../../esm/ParseError/PathFormatter.js"],"sourcesContent":["import * as tsplus_module_1 from \"@fncts/base/collection/Iterable/api\";\nimport * as tsplus_module_2 from \"@fncts/base/data/Maybe/destructors\";\nimport { formatTypeError, getMessage } from \"./TreeFormatter.js\";\n/**\n * @tsplus getter fncts.schema.ParseError flatten\n */\nexport function flatten(error) {\n    return go(error, []);\n    function go(error, path) {\n        switch (error._tag) {\n            case 10 /* ParseErrorTag.Tuple */: {\n                return getFlattenedParseError(error, path, () => tsplus_module_1.toArray(tsplus_module_1.flatMap((error) => go(error.error, path.concat(error.index)))(error.errors)));\n            }\n            case 11 /* ParseErrorTag.Union */: {\n                return getFlattenedParseError(error, path, () => tsplus_module_1.toArray(tsplus_module_1.flatMap((error) => {\n                    if (error._tag === 6 /* ParseErrorTag.UnionMember */) {\n                        return go(error.error, path);\n                    }\n                    else {\n                        return go(error, path);\n                    }\n                })(error.errors)));\n            }\n            case 9 /* ParseErrorTag.TypeLiteral */: {\n                return getFlattenedParseError(error, path, () => tsplus_module_1.toArray(tsplus_module_1.flatMap((key) => go(key.error, path.concat(key.key)))(error.errors)));\n            }\n            case 4 /* ParseErrorTag.Missing */: {\n                return [\n                    {\n                        type: error._tag,\n                        path: path,\n                        message: \"is missing\",\n                    },\n                ];\n            }\n            case 5 /* ParseErrorTag.Unexpected */: {\n                return [\n                    {\n                        type: error._tag,\n                        path: path,\n                        message: \"is unexpected\",\n                    },\n                ];\n            }\n            case 1 /* ParseErrorTag.Type */: {\n                return [\n                    {\n                        type: error._tag,\n                        path: path,\n                        message: formatTypeError(error),\n                    },\n                ];\n            }\n            case 0 /* ParseErrorTag.Declaration */:\n            case 8 /* ParseErrorTag.Transformation */:\n            case 7 /* ParseErrorTag.Refinement */: {\n                return getFlattenedParseError(error, path, () => go(error.error, path));\n            }\n            case 12 /* ParseErrorTag.Iterable */: {\n                return getFlattenedParseError(error, path, () => tsplus_module_1.toArray(tsplus_module_1.flatMap((error) => {\n                    switch (error._tag) {\n                        case 3 /* ParseErrorTag.Key */: {\n                            return go(error.error, path.concat(error.key));\n                        }\n                        case 2 /* ParseErrorTag.Index */: {\n                            return go(error.error, path.concat(error.index));\n                        }\n                    }\n                })(error.errors)));\n            }\n        }\n    }\n}\nfunction getFlattenedParseError(error, path, orElse) {\n    return tsplus_module_2.match(() => orElse(), (message) => {\n        return [\n            {\n                type: error._tag,\n                path,\n                message,\n            },\n        ];\n    })(getMessage(error));\n}\n//# sourceMappingURL=PathFormatter.js.map"],"mappings":";;;;;;;;;;;AAMA,SAAgB,QAAQ,OAAO;AAC3B,QAAO,GAAG,OAAO,EAAE,CAAC;CACpB,SAAS,GAAG,OAAO,MAAM;AACrB,UAAQ,MAAM,MAAd;GACI,KAAK,GACD,QAAO,uBAAuB,OAAO,YAAYA,oCAAgB,QAAQA,oCAAgB,SAAS,UAAU,GAAG,MAAM,OAAO,KAAK,OAAO,MAAM,MAAM,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,CAAC;GAE1K,KAAK,GACD,QAAO,uBAAuB,OAAO,YAAYA,oCAAgB,QAAQA,oCAAgB,SAAS,UAAU;AACxG,QAAI,MAAM,SAAS,EACf,QAAO,GAAG,MAAM,OAAO,KAAK;QAG5B,QAAO,GAAG,OAAO,KAAK;KAE5B,CAAC,MAAM,OAAO,CAAC,CAAC;GAEtB,KAAK,EACD,QAAO,uBAAuB,OAAO,YAAYA,oCAAgB,QAAQA,oCAAgB,SAAS,QAAQ,GAAG,IAAI,OAAO,KAAK,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,CAAC;GAElK,KAAK,EACD,QAAO,CACH;IACI,MAAM,MAAM;IACN;IACN,SAAS;IACZ,CACJ;GAEL,KAAK,EACD,QAAO,CACH;IACI,MAAM,MAAM;IACN;IACN,SAAS;IACZ,CACJ;GAEL,KAAK,EACD,QAAO,CACH;IACI,MAAM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