{"version":3,"file":"hashMap.mjs","names":[],"sources":["../../../esm/Schema/api/hashMap.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/collection/immutable/HashMap/api\";\nimport * as tsplus_module_6 from \"@fncts/base/data/function/api\";\nimport * as tsplus_module_7 from \"@fncts/base/collection/immutable/HashMap/definition\";\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/base/data/Either/api\";\nimport * as tsplus_module_12 from \"@fncts/base/collection/immutable/Vector/internal\";\nimport * as tsplus_module_13 from \"@fncts/schema/Parser/definition\";\nimport * as tsplus_module_14 from \"@fncts/test/control/Gen/api\";\nexport const hashMap = hashMap_1;\nexport const hashMapFromRecord = hashMapFromRecord_1;\n/**\n * @tsplus static fncts.schema.SchemaOps hashMap\n */\nfunction hashMap_1(key, value) {\n    return tsplus_module_4.annotate(tsplus_module_1.GenHook, gen)(tsplus_module_4.annotate(tsplus_module_1.Identifier, `HashMap<${tsplus_module_2.show()(key)}, ${tsplus_module_2.show()(value)}>`)(tsplus_module_4.declaration(tsplus_module_3.vector(key, value), hashMapParser(true), hashMapParser(false))));\n}\n/**\n * @tsplus static fncts.schema.SchemaOps hashMapFromRecord\n */\nfunction hashMapFromRecord_1(key, value) {\n    return tsplus_module_4.transform(hashMap_1(key, value), (input) => {\n        const out = tsplus_module_5.beginMutation(tsplus_module_5.empty());\n        for (const [k, v] of Object.entries(input)) {\n            tsplus_module_5.set(k, v)(out);\n        }\n        return tsplus_module_5.endMutation(out);\n    }, (input) => {\n        const out = {};\n        tsplus_module_5.forEachWithIndex((k, v) => {\n            out[k] = v;\n        })(input);\n        return out;\n    })(tsplus_module_4.record(key, value));\n}\n/**\n * @tsplus derive fncts.schema.Schema[fncts.HashMap]<_> 10\n */\nexport function deriveHashMap(\n// @ts-expect-error\n...[key, value]) {\n    return hashMapFromRecord_1(key, value);\n}\nfunction hashMapParser(isDecoding) {\n    return (key, value) => {\n        const schema = hashMap_1(key, value);\n        return tsplus_module_13.make((u, options) => {\n            if (!tsplus_module_7.isHashMap(u)) {\n                return tsplus_module_9.fail(tsplus_module_8.typeError(schema.ast, u));\n            }\n            const allErrors = options?.allErrors;\n            const errors = tsplus_module_3.emptyPushable();\n            const out = tsplus_module_5.beginMutation(tsplus_module_5.empty());\n            const keyParser = isDecoding ? tsplus_module_10.decode(key) : tsplus_module_10.encode(key);\n            const valueParser = isDecoding ? tsplus_module_10.decode(value) : tsplus_module_10.encode(value);\n            for (const [k, v] of u) {\n                const tk = keyParser(k, options);\n                void 0;\n                if (tsplus_module_11.isLeft(tk)) {\n                    tsplus_module_12.push(tsplus_module_8.keyError(key.ast, k, tk.left))(errors);\n                    if (!allErrors) {\n                        return tsplus_module_9.fail(tsplus_module_8.iterableError(schema.ast, u, errors));\n                    }\n                }\n                const tv = valueParser(v, options);\n                void 0;\n                if (tsplus_module_11.isLeft(tv)) {\n                    tsplus_module_12.push(tsplus_module_8.keyError(key.ast, k, tv.left))(errors);\n                    if (!allErrors) {\n                        return tsplus_module_9.fail(tsplus_module_8.iterableError(schema.ast, u, errors));\n                    }\n                }\n                if (tsplus_module_11.isLeft(tk) || tsplus_module_11.isLeft(tv)) {\n                    continue;\n                }\n                tsplus_module_5.set(tk.right, tv.right)(out);\n            }\n            return tsplus_module_3.isNonEmpty(errors)\n                ? tsplus_module_9.fail(tsplus_module_8.iterableError(schema.ast, u, errors))\n                : tsplus_module_9.succeed(tsplus_module_5.endMutation(out));\n        });\n    };\n}\nfunction gen(key, value) {\n    return tsplus_module_14.map((pairs) => tsplus_module_5.from(pairs))(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