{"version":3,"file":"either.mjs","names":[],"sources":["../../../esm/Schema/api/either.js"],"sourcesContent":["const fileName_1 = \"(@fncts/schema) src/Schema/api/either.ts\";\nimport * as tsplus_module_1 from \"@fncts/schema/ASTAnnotation\";\nimport * as tsplus_module_2 from \"@fncts/schema/Show\";\nimport * as tsplus_module_3 from \"@fncts/base/collection/immutable/Vector/api\";\nimport * as tsplus_module_4 from \"@fncts/schema/Schema/api\";\nimport * as tsplus_module_5 from \"@fncts/base/data/Either/constructors\";\nimport * as tsplus_module_6 from \"@fncts/base/data/Either/api\";\nimport * as tsplus_module_7 from \"@fncts/base/data/function/api\";\nimport * as tsplus_module_8 from \"@fncts/schema/ParseError/ParseError\";\nimport * as tsplus_module_9 from \"@fncts/schema/ParseResult\";\nimport * as tsplus_module_10 from \"@fncts/schema/Parser/api\";\nimport * as tsplus_module_11 from \"@fncts/schema/Parser/definition\";\nexport const either = either_1;\nexport const eitherFromJson = eitherFromJson_1;\n/**\n * @tsplus static fncts.schema.SchemaOps either\n */\nfunction either_1(left, right) {\n    return tsplus_module_4.annotate(tsplus_module_1.Identifier, `Either<${tsplus_module_2.show()(left)}, ${tsplus_module_2.show()(right)}>`)(tsplus_module_4.declaration(tsplus_module_3.vector(left, right), eitherParser(true), eitherParser(false)));\n}\nfunction eitherJson(left, right) {\n    return tsplus_module_4.union(tsplus_module_4.struct({\n        _tag: tsplus_module_4.literal(\"Left\"),\n        left,\n    }), tsplus_module_4.struct({\n        _tag: tsplus_module_4.literal(\"Right\"),\n        right,\n    }));\n}\n/**\n * @tsplus static fncts.schema.SchemaOps eitherFromJson\n */\nfunction eitherFromJson_1(left, right) {\n    return tsplus_module_4.transform(either_1(left, right), (input) => {\n        if (input._tag === \"Left\") {\n            return tsplus_module_5.left(input.left, fileName_1 + \":34:27\");\n        }\n        else {\n            return tsplus_module_5.right(input.right, fileName_1 + \":36:28\");\n        }\n    }, (input) => {\n        void 0;\n        if (tsplus_module_6.isLeft(input)) {\n            return {\n                _tag: \"Left\",\n                left: input.left,\n            };\n        }\n        else {\n            return {\n                _tag: \"Right\",\n                right: input.right,\n            };\n        }\n    })(eitherJson(left, right));\n}\n/**\n * @tsplus derive fncts.schema.Schema[fncts.Either]<_> 10\n */\nexport function deriveEither(...[left, right]) {\n    return eitherFromJson_1(left, right);\n}\nfunction eitherParser(isDecoding) {\n    return (left, right) => {\n        const schema = either_1(left, right);\n        return tsplus_module_11.make((u, options) => {\n            if (!tsplus_module_6.isEither(u)) {\n                return tsplus_module_9.fail(tsplus_module_8.typeError(schema.ast, u));\n            }\n            void 0;\n            if (tsplus_module_6.isLeft(u)) {\n                const parse = isDecoding ? tsplus_module_10.decode(left) : tsplus_module_10.encode(left);\n                return tsplus_module_6.map(tsplus_module_5.left)(parse(u.left, options));\n            }\n            else {\n                const parse = isDecoding ? tsplus_module_10.decode(right) : tsplus_module_10.encode(right);\n                return tsplus_module_6.map(tsplus_module_5.right)(parse(u.right, options));\n            }\n        });\n    };\n}\n//# sourceMappingURL=either.js.map"],"mappings":";;;;;;;;;;;;AAAA,MAAM,aAAa;AAYnB,MAAa,SAAS;AACtB,MAAa,iBAAiB;;;;AAI9B,SAAS,SAAS,MAAM,OAAO;AAC3B,QAAO,gBAAgB,SAAS,gBAAgB,YAAY,UAAU,gBAAgB,MAAM,CAAC,KAAK,CAAC,IAAI,gBAAgB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,YAAY,gBAAgB,OAAO,MAAM,MAAM,EAAE,aAAa,KAAK,EAAE,aAAa,MAAM,CAAC,CAAC;;AAEvP,SAAS,WAAW,MAAM,OAAO;AAC7B,QAAO,gBAAgB,MAAM,gBAAgB,OAAO;EAChD,MAAM,gBAAgB,QAAQ,OAAO;EACrC;EACH,CAAC,EAAE,gBAAgB,OAAO;EACvB,MAAM,gBAAgB,QAAQ,QAAQ;EACtC;EACH,CAAC,CAAC;;;;;AAKP,SAAS,iBAAiB,MAAM,OAAO;AACnC,QAAO,gBAAgB,UAAU,SAAS,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