{"version":3,"file":"map.cjs","names":["tsplus_module_4","tsplus_module_1","tsplus_module_2","tsplus_module_3","tsplus_module_11","tsplus_module_7","tsplus_module_6","tsplus_module_8","tsplus_module_9","tsplus_module_12"],"sources":["../../../esm/Schema/api/map.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/ParseError/ParseError\";\nimport * as tsplus_module_7 from \"@fncts/schema/ParseResult\";\nimport * as tsplus_module_8 from \"@fncts/schema/Parser/api\";\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 map = map_1;\nexport const mapFromRecord = mapFromRecord_1;\n/**\n * @tsplus static fncts.schema.SchemaOps map\n */\nfunction map_1(key, value) {\n    return tsplus_module_4.annotate(tsplus_module_1.GenHook, gen)(tsplus_module_4.annotate(tsplus_module_1.Identifier, `Map<${tsplus_module_2.show()(key)}, ${tsplus_module_2.show()(value)}>`)(tsplus_module_4.declaration(tsplus_module_3.vector(key, value), mapParser(true), mapParser(false))));\n}\n/**\n * @tsplus static fncts.schema.SchemaOps mapFromRecord\n */\nfunction mapFromRecord_1(key, value) {\n    return tsplus_module_4.transform(map_1(key, value), (input) => {\n        const out = new Map();\n        for (const [k, v] of Object.entries(input)) {\n            out.set(k, v);\n        }\n        return out;\n    }, (input) => {\n        const out = {};\n        input.forEach((v, k) => {\n            out[k] = v;\n        });\n        return out;\n    })(tsplus_module_4.record(key, value));\n}\n/**\n * @tsplus derive fncts.schema.Schema[fncts.Map]<_> 10\n */\nexport function deriveMap(\n// @ts-expect-error\n...[key, value]) {\n    return mapFromRecord_1(key, value);\n}\nfunction mapParser(isDecoding) {\n    return (key, value) => {\n        const schema = map_1(key, value);\n        return tsplus_module_11.make((u, options) => {\n            if (!(u instanceof Map)) {\n                return tsplus_module_7.fail(tsplus_module_6.typeError(schema.ast, u));\n            }\n            const allErrors = options?.allErrors;\n            const errors = tsplus_module_3.emptyPushable();\n            const out = new Map();\n            const keyParser = isDecoding ? tsplus_module_8.decode(key) : tsplus_module_8.encode(key);\n            const valueParser = isDecoding ? tsplus_module_8.decode(value) : tsplus_module_8.encode(value);\n            for (const [k, v] of u) {\n                const tk = keyParser(k, options);\n                void 0;\n                if (tsplus_module_9.isLeft(tk)) {\n                    tsplus_module_10.push(tsplus_module_6.keyError(key.ast, k, tk.left))(errors);\n                    if (!allErrors) {\n                        return tsplus_module_7.fail(tsplus_module_6.iterableError(schema.ast, u, errors));\n                    }\n                }\n                const tv = valueParser(v, options);\n                void 0;\n                if (tsplus_module_9.isLeft(tv)) {\n                    tsplus_module_10.push(tsplus_module_6.keyError(key.ast, k, tv.left))(errors);\n                    if (!allErrors) {\n                        return tsplus_module_7.fail(tsplus_module_6.iterableError(schema.ast, u, errors));\n                    }\n                }\n                if (tsplus_module_9.isLeft(tk) || tsplus_module_9.isLeft(tv)) {\n                    continue;\n                }\n                out.set(tk.right, tv.right);\n            }\n            return tsplus_module_3.isNonEmpty(errors)\n                ? tsplus_module_7.fail(tsplus_module_6.iterableError(schema.ast, u, errors))\n                : tsplus_module_7.succeed(out);\n        });\n    };\n}\nfunction gen(key, value) {\n    return tsplus_module_12.map((pairs) => new Map(pairs))(tsplus_module_12.array(tsplus_module_12.tuple(key, value)));\n}\n//# sourceMappingURL=map.js.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAa,MAAM;AACnB,MAAa,gBAAgB;;;;AAI7B,SAAS,MAAM,KAAK,OAAO;AACvB,QAAOA,yBAAg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