{"version":3,"file":"interpreter.cjs","names":["tsplus_module_2","tsplus_module_1","DeclarationError","isUndefined","tsplus_module_3","isString","isNumber","isBoolean","isBigInt","isSymbol","isObject","tsplus_module_4","getTemplateLiteralRegex","tsplus_module_5","tsplus_module_7","tsplus_module_6","tsplus_module_9","getKeysForIndexSignature","ownKeys","getSearchTree","memoize"],"sources":["../../esm/Parser/interpreter.js"],"sourcesContent":["import * as tsplus_module_1 from \"@fncts/base/data/Either/api\";\nimport * as tsplus_module_2 from \"@fncts/schema/Parser/definition\";\nimport * as tsplus_module_3 from \"@fncts/schema/ParseResult\";\nimport * as tsplus_module_4 from \"@fncts/base/collection/immutable/Vector/api\";\nimport * as tsplus_module_5 from \"@fncts/base/data/Maybe/api\";\nimport * as tsplus_module_6 from \"@fncts/schema/AST\";\nimport * as tsplus_module_7 from \"@fncts/schema/ParseError/ParseError\";\nimport * as tsplus_module_8 from \"@fncts/base/collection/immutable/Vector/internal\";\nimport * as tsplus_module_9 from \"@fncts/base/data/Maybe/definition\";\nimport { globalValue } from \"@fncts/base/data/Global\";\nimport { isBigInt, isBoolean, isNumber, isObject, isRecord, isString, isSymbol, isUndefined, } from \"@fncts/base/util/predicates\";\nimport { concrete, getSearchTree } from \"../AST.js\";\nimport { DeclarationError, RefinementError, TransformationError } from \"../ParseError/ParseError.js\";\nimport { getKeysForIndexSignature, getTemplateLiteralRegex, memoize, ownKeys } from \"../utils.js\";\nconst decodeMemoMap = globalValue(Symbol.for(\"fncts.schema.Parser.decodeMemoMap\"), () => new WeakMap());\nconst encodeMemoMap = globalValue(Symbol.for(\"fncts.schema.Parser.encodeMemoMap\"), () => new WeakMap());\nfunction goMemo(ast, isDecoding) {\n    const memoMap = isDecoding ? decodeMemoMap : encodeMemoMap;\n    const memo = memoMap.get(ast);\n    if (memo) {\n        return memo;\n    }\n    const parser = go(ast, isDecoding);\n    memoMap.set(ast, parser);\n    return parser;\n}\nfunction go(ast, isDecoding) {\n    void 0;\n    switch (ast._tag) {\n        case 0 /* ASTTag.Declaration */: {\n            const parse = isDecoding ? ast.decode(...ast.typeParameters) : ast.encode(...ast.typeParameters);\n            return tsplus_module_2.make((input, options) => tsplus_module_1.mapLeft((error) => new DeclarationError(ast, input, error))(parse(input, options)));\n        }\n        case 1 /* ASTTag.Literal */:\n            return tsplus_module_2.fromRefinement(ast, (u) => u === ast.literal);\n        case 2 /* ASTTag.UniqueSymbol */:\n            return tsplus_module_2.fromRefinement(ast, (u) => u === ast.symbol);\n        case 3 /* ASTTag.UndefinedKeyword */:\n        case 4 /* ASTTag.VoidKeyword */:\n            return tsplus_module_2.fromRefinement(ast, isUndefined);\n        case 5 /* ASTTag.NeverKeyword */:\n            return tsplus_module_2.fromRefinement(ast, (_) => false);\n        case 6 /* ASTTag.UnknownKeyword */:\n        case 7 /* ASTTag.AnyKeyword */:\n            return tsplus_module_2.make(tsplus_module_3.succeed);\n        case 8 /* ASTTag.StringKeyword */:\n            return tsplus_module_2.fromRefinement(ast, isString);\n        case 9 /* ASTTag.NumberKeyword */:\n            return tsplus_module_2.fromRefinement(ast, isNumber);\n        case 10 /* ASTTag.BooleanKeyword */:\n            return tsplus_module_2.fromRefinement(ast, isBoolean);\n        case 11 /* ASTTag.BigIntKeyword */:\n            return tsplus_module_2.fromRefinement(ast, isBigInt);\n        case 12 /* ASTTag.SymbolKeyword */:\n            return tsplus_module_2.fromRefinement(ast, isSymbol);\n        case 13 /* ASTTag.ObjectKeyword */:\n            return tsplus_module_2.fromRefinement(ast, isObject);\n        case 14 /* ASTTag.Enum */:\n            return tsplus_module_2.fromRefinement(ast, (u) => tsplus_module_4.some(([_, value]) => value === u)(ast.enums));\n        case 15 /* ASTTag.TemplateLiteral */: {\n            const regex = getTemplateLiteralRegex(ast);\n            return tsplus_module_2.fromRefinement(ast, (u) => isString(u) && regex.test(u));\n        }\n        case 16 /* ASTTag.Tuple */: {\n            const elements = tsplus_module_4.map((e) => goMemo(e.type, isDecoding))(ast.elements);\n            const rest = tsplus_module_5.map((rest) => tsplus_module_4.map((ast) => goMemo(ast, isDecoding))(rest))(ast.rest);\n            return tsplus_module_2.make((input, options) => {\n                if (!Array.isArray(input)) {\n                    return tsplus_module_3.fail(tsplus_module_7.typeError(tsplus_module_6.unknownArray, input));\n                }\n                const output = [];\n                const errors = tsplus_module_4.emptyPushable();\n                const allErrors = options?.allErrors;\n                let i = 0;\n                for (; i < elements.length; i++) {\n                    if (input.length < i + 1) {\n                        if (!tsplus_module_4.unsafeGet(i)(ast.elements).isOptional) {\n                            const e = tsplus_module_7.indexError(i, tsplus_module_7.missingError);\n                            if (allErrors) {\n                                tsplus_module_8.push(e)(errors);\n                                continue;\n                            }\n                            else {\n                                return tsplus_module_3.fail(tsplus_module_7.tupleError(ast, input, tsplus_module_4.vector(e), output));\n                            }\n                        }\n                    }\n                    else {\n                        const parser = tsplus_module_4.unsafeGet(i)(elements);\n                        const t = parser(input[i], options);\n                        void 0;\n                        if (tsplus_module_1.isLeft(t)) {\n                            const e = tsplus_module_7.indexError(i, t.left);\n                            if (allErrors) {\n                                tsplus_module_8.push(e)(errors);\n                                continue;\n                            }\n                            else {\n                                return tsplus_module_3.fail(tsplus_module_7.tupleError(ast, input, tsplus_module_4.vector(e), output));\n                            }\n                        }\n                        output.push(t.right);\n                    }\n                }\n                if (tsplus_module_9.isJust(rest)) {\n                    const head = tsplus_module_4.unsafeHead(rest.value);\n                    const tail = tsplus_module_4.tail(rest.value);\n                    for (; i < input.length - tail.length; i++) {\n                        const t = head(input[i], options);\n                        void 0;\n                        if (tsplus_module_1.isLeft(t)) {\n                            const e = tsplus_module_7.indexError(i, t.left);\n                            if (allErrors) {\n                                tsplus_module_8.push(e)(errors);\n                                continue;\n                            }\n                            else {\n                                return tsplus_module_3.fail(tsplus_module_7.tupleError(ast, input, tsplus_module_4.vector(e), output));\n                            }\n                        }\n                        output.push(t.right);\n                    }\n                    for (let j = 0; j < tail.length; j++) {\n                        i += j;\n                        if (input.length < i + 1) {\n                            const e = tsplus_module_7.indexError(i, tsplus_module_7.missingError);\n                            if (allErrors) {\n                                tsplus_module_8.push(e)(errors);\n                                continue;\n                            }\n                            else {\n                                return tsplus_module_3.fail(tsplus_module_7.tupleError(ast, input, tsplus_module_4.vector(e), output));\n                            }\n                        }\n                        else {\n                            const t = tsplus_module_4.unsafeGet(j)(tail)(input[i], options);\n                            void 0;\n                            if (tsplus_module_1.isLeft(t)) {\n                                const e = tsplus_module_7.indexError(i, t.left);\n                                if (allErrors) {\n                                    tsplus_module_8.push(e)(errors);\n                                    continue;\n                                }\n                                else {\n                                    return tsplus_module_3.fail(tsplus_module_7.tupleError(ast, input, tsplus_module_4.vector(e), output));\n                                }\n                            }\n                            output.push(t.right);\n                        }\n                    }\n                }\n                else {\n                    const isUnexpectedAllowed = options?.isUnexpectedAllowed;\n                    for (; i < input.length; i++) {\n                        const e = tsplus_module_7.indexError(i, tsplus_module_7.unexpectedError(input[i]));\n                        if (!isUnexpectedAllowed) {\n                            if (allErrors) {\n                                tsplus_module_8.push(e)(errors);\n                                continue;\n                            }\n                            else {\n                                return tsplus_module_3.fail(tsplus_module_7.tupleError(ast, input, tsplus_module_4.vector(e), output));\n                            }\n                        }\n                    }\n                }\n                return tsplus_module_4.isNonEmpty(errors)\n                    ? tsplus_module_3.fail(tsplus_module_7.tupleError(ast, input, errors, output))\n                    : tsplus_module_3.succeed(output);\n            });\n        }\n        case 17 /* ASTTag.TypeLiteral */: {\n            if (ast.propertySignatures.length === 0 && ast.indexSignatures.length === 0) {\n                return tsplus_module_2.fromRefinement(ast, (u) => u !== null);\n            }\n            const propertySignatureTypes = tsplus_module_4.map((f) => goMemo(f.type, isDecoding))(ast.propertySignatures);\n            const indexSignatures = tsplus_module_4.map((is) => [goMemo(is.parameter, isDecoding), goMemo(is.type, isDecoding)])(ast.indexSignatures);\n            return tsplus_module_2.make((input, options) => {\n                if (!isRecord(input)) {\n                    return tsplus_module_3.fail(tsplus_module_7.typeError(tsplus_module_6.unknownRecord, input));\n                }\n                const output = {};\n                const expectedKeys = {};\n                const errors = tsplus_module_4.emptyPushable();\n                const allErrors = options?.allErrors;\n                for (let i = 0; i < propertySignatureTypes.length; i++) {\n                    const ps = tsplus_module_4.unsafeGet(i)(ast.propertySignatures);\n                    const parser = tsplus_module_4.unsafeGet(i)(propertySignatureTypes);\n                    const name = ps.name;\n                    expectedKeys[name] = null;\n                    if (!Object.prototype.hasOwnProperty.call(input, name)) {\n                        if (!ps.isOptional) {\n                            const e = tsplus_module_7.keyError(tsplus_module_6.createKey(name), name, tsplus_module_7.missingError);\n                            if (allErrors) {\n                                tsplus_module_8.push(e)(errors);\n                                continue;\n                            }\n                            else {\n                                return tsplus_module_3.fail(tsplus_module_7.typeLiteralError(ast, input, tsplus_module_4.vector(e), output));\n                            }\n                        }\n                    }\n                    else {\n                        const t = parser(input[name], options);\n                        void 0;\n                        if (tsplus_module_1.isLeft(t)) {\n                            const e = tsplus_module_7.keyError(tsplus_module_6.createKey(name), name, t.left);\n                            if (allErrors) {\n                                tsplus_module_8.push(e)(errors);\n                                continue;\n                            }\n                            else {\n                                return tsplus_module_3.fail(tsplus_module_7.typeLiteralError(ast, input, tsplus_module_4.vector(e), output));\n                            }\n                        }\n                        output[name] = t.right;\n                    }\n                }\n                if (indexSignatures.length > 0) {\n                    for (let i = 0; i < indexSignatures.length; i++) {\n                        const [parameter, type] = tsplus_module_4.unsafeGet(i)(indexSignatures);\n                        const keys = getKeysForIndexSignature(input, tsplus_module_4.unsafeGet(i)(ast.indexSignatures).parameter);\n                        for (const key of keys) {\n                            if (Object.prototype.hasOwnProperty.call(expectedKeys, key)) {\n                                continue;\n                            }\n                            let t = parameter(key, options);\n                            void 0;\n                            if (tsplus_module_1.isLeft(t)) {\n                                const e = tsplus_module_7.keyError(tsplus_module_6.createKey(key), key, t.left);\n                                if (allErrors) {\n                                    tsplus_module_8.push(e)(errors);\n                                    continue;\n                                }\n                                else {\n                                    return tsplus_module_3.fail(tsplus_module_7.typeLiteralError(ast, input, tsplus_module_4.vector(e), output));\n                                }\n                            }\n                            t = type(input[key], options);\n                            void 0;\n                            if (tsplus_module_1.isLeft(t)) {\n                                const e = tsplus_module_7.keyError(tsplus_module_6.createKey(key), key, t.left);\n                                tsplus_module_8.push(e)(errors);\n                                if (allErrors) {\n                                    continue;\n                                }\n                                else {\n                                    return tsplus_module_3.fail(tsplus_module_7.typeLiteralError(ast, input, tsplus_module_4.vector(e), output));\n                                }\n                            }\n                            output[key] = t.right;\n                        }\n                    }\n                }\n                else {\n                    const isUnexpectedAllowed = options?.isUnexpectedAllowed;\n                    for (const key of ownKeys(input)) {\n                        if (!Object.prototype.hasOwnProperty.call(expectedKeys, key)) {\n                            if (!isUnexpectedAllowed) {\n                                const e = tsplus_module_7.keyError(tsplus_module_6.createKey(key), key, tsplus_module_7.unexpectedError(input[key]));\n                                if (allErrors) {\n                                    tsplus_module_8.push(e)(errors);\n                                    continue;\n                                }\n                                else {\n                                    return tsplus_module_3.fail(tsplus_module_7.typeLiteralError(ast, input, tsplus_module_4.vector(e), output));\n                                }\n                            }\n                        }\n                    }\n                }\n                return tsplus_module_4.isNonEmpty(errors)\n                    ? tsplus_module_3.fail(tsplus_module_7.typeLiteralError(ast, input, errors, output))\n                    : tsplus_module_3.succeed(output);\n            });\n        }\n        case 18 /* ASTTag.Union */: {\n            const searchTree = getSearchTree(ast.types, isDecoding);\n            const ownKeys = Reflect.ownKeys(searchTree.keys);\n            const len = ownKeys.length;\n            const map = new Map();\n            tsplus_module_4.forEach((ast) => {\n                map.set(ast, goMemo(ast, isDecoding));\n            })(ast.types);\n            return tsplus_module_2.make((input, options) => {\n                const errors = tsplus_module_4.emptyPushable();\n                let candidates = [];\n                if (len > 0) {\n                    if (isRecord(input)) {\n                        for (let i = 0; i < len; i++) {\n                            const name = ownKeys[i];\n                            const buckets = searchTree.keys[name].buckets;\n                            if (Object.prototype.hasOwnProperty.call(input, name)) {\n                                const literal = String(input[name]);\n                                if (Object.prototype.hasOwnProperty.call(buckets, literal)) {\n                                    candidates = candidates.concat(buckets[literal]);\n                                }\n                                else {\n                                    const literals = tsplus_module_6.createUnion(tsplus_module_4.from(searchTree.keys[name].literals));\n                                    tsplus_module_8.push(tsplus_module_7.typeLiteralError(tsplus_module_6.createTypeLiteral(tsplus_module_4.vector(tsplus_module_6.createPropertySignature(name, literals, false, true)), tsplus_module_4.vector()), input, tsplus_module_4.vector(tsplus_module_7.keyError(tsplus_module_6.createKey(name), name, tsplus_module_7.typeError(searchTree.keys[name].ast, input[name])))))(errors);\n                                }\n                            }\n                            else {\n                                const literals = tsplus_module_6.createUnion(tsplus_module_4.from(searchTree.keys[name].literals));\n                                tsplus_module_8.push(tsplus_module_7.typeLiteralError(tsplus_module_6.createTypeLiteral(tsplus_module_4.vector(tsplus_module_6.createPropertySignature(name, literals, false, true)), tsplus_module_4.vector()), input, tsplus_module_4.vector(tsplus_module_7.keyError(tsplus_module_6.createKey(name), name, tsplus_module_7.missingError))))(errors);\n                            }\n                        }\n                    }\n                    else {\n                        tsplus_module_8.push(tsplus_module_7.typeError(tsplus_module_6.unknownRecord, input))(errors);\n                    }\n                }\n                if (searchTree.otherwise.length > 0) {\n                    candidates = candidates.concat(searchTree.otherwise);\n                }\n                for (let i = 0; i < candidates.length; i++) {\n                    const candidate = candidates[i];\n                    const pr = map.get(candidate)(input, options);\n                    void 0;\n                    if (tsplus_module_1.isRight(pr)) {\n                        return pr;\n                    }\n                    else {\n                        tsplus_module_8.push(tsplus_module_7.unionMemberError(candidate, pr.left))(errors);\n                    }\n                }\n                return tsplus_module_4.isNonEmpty(errors)\n                    ? errors.length === 1 && tsplus_module_4.unsafeGet(0)(errors)._tag === 1 /* ParseErrorTag.Type */\n                        ? tsplus_module_3.fail(tsplus_module_4.unsafeGet(0)(errors))\n                        : tsplus_module_3.fail(tsplus_module_7.unionError(ast, input, tsplus_module_4.from(errors)))\n                    : tsplus_module_3.fail(tsplus_module_7.typeError(tsplus_module_6.neverKeyword, input));\n            });\n        }\n        case 19 /* ASTTag.Lazy */: {\n            const f = () => goMemo(ast.getAST(), isDecoding);\n            const get = memoize(f);\n            return tsplus_module_2.make((a, options) => get()(a, options));\n        }\n        case 20 /* ASTTag.Refinement */: {\n            if (isDecoding) {\n                const from = goMemo(ast.from, isDecoding);\n                return tsplus_module_2.make((input, options) => tsplus_module_1.flatMap((a) => tsplus_module_1.mapLeft((failure) => tsplus_module_7.refinementError(ast, input, \"Predicate\", failure))(ast.decode(a, options)))(tsplus_module_1.mapLeft((failure) => tsplus_module_7.refinementError(ast, input, \"From\", failure))(from(input, options))));\n            }\n            else {\n                const from = goMemo(ast.from, true);\n                const to = goMemo(tsplus_module_6.getTo(ast.from), false);\n                return tsplus_module_2.make((input, options) => tsplus_module_1.flatMap((a) => from(a, options))(tsplus_module_1.flatMap((a) => ast.decode(a, options))(to(input, options))));\n            }\n        }\n        case 21 /* ASTTag.Transform */: {\n            const transformation = isDecoding ? ast.decode : ast.encode;\n            const from = isDecoding ? goMemo(ast.from, true) : goMemo(ast.to, false);\n            const to = isDecoding ? goMemo(ast.to, true) : goMemo(ast.from, false);\n            return tsplus_module_2.make((input, options) => tsplus_module_1.flatMap((a) => tsplus_module_1.mapLeft((failure) => tsplus_module_7.transformationError(ast, input, isDecoding ? \"Type\" : \"Encoded\", failure))(to(a, options)))(tsplus_module_1.flatMap((a) => tsplus_module_1.mapLeft((failure) => tsplus_module_7.transformationError(ast, input, \"Transformation\", failure))(transformation(a, options)))(tsplus_module_1.mapLeft((failure) => tsplus_module_7.transformationError(ast, input, isDecoding ? \"Encoded\" : \"Type\", failure))(from(input, options)))));\n        }\n        case 22 /* ASTTag.Validation */: {\n            return tsplus_module_2.make((u, options) => {\n                const missedBrands = tsplus_module_4.emptyPushable();\n                const allErrors = options?.allErrors;\n                for (const validation of ast.validation) {\n                    if (!validation.validate(u)) {\n                        tsplus_module_8.push(validation)(missedBrands);\n                        if (allErrors) {\n                            continue;\n                        }\n                        else {\n                            return tsplus_module_3.fail(tsplus_module_7.typeError(tsplus_module_6.createValidation(ast.from, missedBrands, ast.annotations), u));\n                        }\n                    }\n                }\n                return missedBrands.length > 0\n                    ? tsplus_module_3.fail(tsplus_module_7.typeError(tsplus_module_6.createValidation(ast.from, missedBrands, ast.annotations), u))\n                    : tsplus_module_3.succeed(u);\n            });\n        }\n    }\n}\nexport function parserFor(ast, isDecoding) {\n    return goMemo(ast, isDecoding);\n}\n//# sourceMappingURL=interpreter.js.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,iBAAA,GAAA,wBAAA,aAA4B,OAAO,IAAI,oCAAoC,wBAAQ,IAAI,SAAS,CAAC;AACvG,MAAM,iBAAA,GAAA,wBAAA,aAA4B,OAAO,IAAI,oCAAoC,wBAAQ,IAAI,SAAS,CAAC;AACvG,SAAS,OAAO,KAAK,YAAY;CAC7B,MAAM,UAAU,aAAa,gBAAgB;CAC7C,MAAM,OAAO,QAAQ,IAAI,IAAI;AAC7B,KAAI,KACA,QAAO;CAEX,MAAM,SAAS,GAAG,KAAK,WAAW;AAClC,SAAQ,IAAI,KAAK,OAAO;AACxB,QAAO;;AAEX,SAAS,GAAG,KAAK,YAAY;AAEzB,SAAQ,IAAI,MAAZ;EACI,KAAK,GAA4B;GAC7B,MAAM,QAAQ,aAAa,IAAI,OAAO,GAAG,IAAI,eAAe,GAAG,IAAI,OAAO,GAAG,IAAI,eAAe;AAChG,UAAOA,gCAAgB,MAAM,OAAO,YAAYC,4BAAgB,SAAS,UAAU,IAAIC,8BAAAA,iBAAiB,KAAK,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;;EAEvJ,KAAK,EACD,QAAOF,gCAAgB,eAAe,MAAM,MAAM,MAAM,IAAI,QAAQ;EACxE,KAAK,EACD,QAAOA,gCAAgB,eAAe,MAAM,MAAM,MAAM,IAAI,OAAO;EACvE,KAAK;EACL,KAAK,EACD,QAAOA,gCAAgB,eAAe,KAAKG,4BAAAA,YAAY;EAC3D,KAAK,EACD,QAAO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