{"version":3,"file":"set.mjs","names":[],"sources":["../../../esm/Schema/api/set.js"],"sourcesContent":["import * 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/function/api\";\nimport * as tsplus_module_6 from \"@fncts/schema/Parser/api\";\nimport * as tsplus_module_7 from \"@fncts/schema/ParseError/ParseError\";\nimport * as tsplus_module_8 from \"@fncts/schema/ParseResult\";\nimport * as tsplus_module_9 from \"@fncts/base/data/Either/api\";\nimport * as tsplus_module_10 from \"@fncts/base/collection/immutable/Vector/internal\";\nimport * as tsplus_module_11 from \"@fncts/schema/Parser/definition\";\nimport * as tsplus_module_12 from \"@fncts/test/control/Gen/api\";\nexport const set = set_1;\nexport const setFromArray = setFromArray_1;\n/**\n * @tsplus static fncts.schema.SchemaOps map\n */\nfunction set_1(value) {\n    return tsplus_module_4.annotate(tsplus_module_1.GenHook, gen)(tsplus_module_4.annotate(tsplus_module_1.Identifier, `Set<${tsplus_module_2.show()(value)}>`)(tsplus_module_4.declaration(tsplus_module_3.vector(value), setParser(true), setParser(false))));\n}\n/**\n * @tsplus static fncts.schema.SchemaOps mapFromRecord\n */\nfunction setFromArray_1(value) {\n    return tsplus_module_4.transform(set_1(value), (input) => {\n        return new Set(input);\n    }, (input) => {\n        return Array.from(input);\n    })(tsplus_module_4.array(value));\n}\n/**\n * @tsplus derive fncts.schema.Schema[fncts.Set]<_> 10\n */\nexport function deriveSet(...[value]) {\n    return setFromArray_1(value);\n}\nfunction setParser(isDecoding) {\n    return (value) => {\n        const schema = set_1(value);\n        const parseValue = isDecoding ? tsplus_module_6.decode(value) : tsplus_module_6.encode(value);\n        return tsplus_module_11.make((u, options) => {\n            if (!(u instanceof Set)) {\n                return tsplus_module_8.fail(tsplus_module_7.typeError(schema.ast, u));\n            }\n            const allErrors = options?.allErrors;\n            const errors = tsplus_module_3.emptyPushable();\n            const out = new Set();\n            for (const v of u) {\n                const tv = parseValue(v, options);\n                void 0;\n                if (tsplus_module_9.isLeft(tv)) {\n                    tsplus_module_10.push(tsplus_module_7.keyError(value.ast, v, tv.left))(errors);\n                    if (!allErrors) {\n                        return tsplus_module_8.fail(tsplus_module_7.iterableError(schema.ast, u, errors));\n                    }\n                    continue;\n                }\n                out.add(tv.right);\n            }\n            return tsplus_module_3.isNonEmpty(errors)\n                ? tsplus_module_8.fail(tsplus_module_7.iterableError(schema.ast, u, errors))\n                : tsplus_module_8.succeed(out);\n        });\n    };\n}\nfunction gen(value) {\n    return tsplus_module_12.map((values) => new Set(values))(tsplus_module_12.array(value));\n}\n//# sourceMappingURL=set.js.map"],"mappings":";;;;;;;;;;;;;AAYA,MAAa,MAAM;AACnB,MAAa,eAAe;;;;AAI5B,SAAS,MAAM,OAAO;AAClB,QAAO,gBAAgB,SAAS,gBAAgB,SAAS,IAAI,CAAC,gBAAgB,SAAS,gBAAgB,YAAY,OAAO,gBAAgB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,YAAY,gBAAgB,OAAO,MAAM,EAAE,UAAU,KAAK,EAAE,UAAU,MAAM,CAAC,CAAC,CAAC;;;;;AAK/P,SAAS,eAAe,OAAO;AAC3B,QAAO,gBAAgB,UAAU,MAAM,MAAM,GAAG,UAAU;AACtD,SAAO,IAAI,IAAI,MAAM;KACrB,UAAU;AACV,SAAO,MAAM,KAAK,MAAM;GAC1B,CAAC,gBAAgB,MAAM,MAAM,CAAC;;;;;AAKpC,SAAgB,UAAU,GAAG,CAAC,QAAQ;AAClC,QAAO,eAAe,MAAM;;AAEhC,SAAS,UAAU,YAAY;AAC3B,SAAQ,UAAU;EACd,MAAM,SAAS,MAAM,MAAM;EAC3B,MAAM,aAAa,aAAa,gBAAgB,OAAO,MAAM,GAAG,gBAAgB,OAAO,MAAM;AAC7F,SAAO,iBAA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