{
  "version": 3,
  "sources": ["../Source/Record/index.ts", "../Source/Record/Record.ts"],
  "sourcesContent": ["/**\n * Utilities for working with {@link Record | Records}.\n *\n * @note This is intended to be a small collection of helpers; consider\n * {@link https://effect-ts.github.io/effect/typeclass/data/Record.ts.html | the Record module in effect}\n * as a \"primary\" module for tools for working with Records.\n *\n * @module @sorrell/utilities/record\n */\n/**\n * @file      index.ts\n * @author    Gage Sorrell <gage@sorrell.sh>\n * @copyright (c) 2026 Gage Sorrell\n * @license   MIT\n */\nexport * from \"./Record.ts\";\nexport type { RecordNonNullable as NonNullable } from \"./Record.Meta.ts\";\nexport * from \"./Record.Types.ts\";\n", "/**\n * @file      Record.ts\n * @author    Gage Sorrell <gage@sorrell.sh>\n * @copyright (c) 2026 Gage Sorrell\n * @license   MIT\n */\nimport type { FlatMapper, FromPath, Mapper, Path, Walkable } from \"./Record.Types.ts\";\nimport type { Ref } from \"../Miscellaneous/Utility.Types.ts\";\n// @TODO Write example for `SetPropertyFromPath`.\n/* eslint-disable jsdoc/require-example */\n/**\n * Set a value within a given {@link InRecord | Record} at a given {@link Path} to be a given\n * {@link Value}.\n *\n * @param InRecord - The {@link Record} that holds the value with path {@link Path} to be retrieved\n * by this function.\n * @param Path - The {@link PathType} that describes the property to be retrieved by this.\n * @param Value - The value to be set at the given {@link Path} of the given {@link InRecord | Record}.\n *\n * @throws {Error} An {@link Error} iff the given {@link Path} is an {@link Array}, rather than a\n * `.`-delimited `string`.\n */\nexport function SetPropertyFromPath<RecordType extends Walkable, PathType extends Path<RecordType>>(InRecord: RecordType, Path: PathType, Value: FromPath<RecordType, PathType>): void {\n    type FProperty = FromPath<RecordType, PathType>;\n    if (Array.isArray(Path)) {\n        throw new Error(\"SetPropertyFromPath does not support Array-based paths yet.\");\n    }\n    const PathSplit: Array<string> = Path.split(\".\");\n    const Last: string | undefined = PathSplit.pop();\n    if (Last === undefined) {\n        return;\n    }\n    if (PathSplit.length === 0) {\n        if (!Array.isArray(Path)) {\n            ((InRecord.Ref as Record<string, unknown>)[(Path as string)]) = Value;\n        }\n    }\n    const Recurrence = (In: unknown): unknown | undefined => {\n        const NextPropertyNameBase: string | undefined = PathSplit.shift();\n        if (NextPropertyNameBase !== undefined) {\n            const NextPropertyName: string | number = isNaN(parseInt(NextPropertyNameBase))\n                ? NextPropertyNameBase\n                : parseInt(NextPropertyNameBase);\n            const Out: unknown = (In as Record<string, unknown>)[NextPropertyName] as unknown;\n            return Recurrence(Out);\n        }\n        else {\n            return In;\n        }\n    };\n    const PropertyRef: Ref<FProperty> = Recurrence(InRecord) as Ref<FProperty>;\n    const LastTyped: string | number = isNaN(parseInt(Last))\n        ? Last\n        : parseInt(Last);\n    (PropertyRef.Ref as Record<string, unknown>)[LastTyped] = Value;\n}\n;\n/* eslint-enable jsdoc/require-example */\n// @TODO Write example for `GetPropertyFromPath`.\n/* eslint-disable jsdoc/require-example */\n/**\n * Get a value within a given {@link InRecord | Record} at a given {@link Path}.\n *\n * @param InRecord - The {@link Record} that holds the value with path {@link Path} to be retrieved\n * by this function.\n * @param Path - The {@link PathType} that describes the property to be retrieved by this.\n *\n * @throws {Error} An {@link Error} iff the given {@link Path} is an {@link Array}, rather than a\n * `.`-delimited `string`.\n *\n * @returns {FromPath<RecordType, PathType>} The value in the {@link InRecord} at the given {@link Path}.\n */\nexport function GetPropertyFromPath<RecordType extends Record<string, unknown>, PathType extends Path<RecordType>>(InRecord: RecordType, Path: PathType): FromPath<RecordType, PathType> {\n    if (Array.isArray(Path)) {\n        throw new Error(\"GetPropertyFromPath does not support Array-based paths yet.\");\n    }\n    const PathSplit: Array<string> = Path.split(\".\");\n    const Recurrence = (In: unknown, Index: number = 0): unknown => {\n        const Key: string | number | undefined = isNaN(parseInt(PathSplit[Index] || \"\"))\n            ? PathSplit[Index]\n            : parseInt(PathSplit[Index] || \"\");\n        if (Key !== undefined) {\n            const Next: unknown = (In as Record<string, unknown>)[Key];\n            if (Index !== PathSplit.length - 1) {\n                return Recurrence(Next, Index + 1);\n            }\n            else {\n                return Next;\n            }\n        }\n        else {\n            return undefined;\n        }\n    };\n    return Recurrence(InRecord) as FromPath<RecordType, PathType>;\n}\n;\n/* eslint-enable jsdoc/require-example */\n/**\n * Creates a {@link Ref} of a given {@link Type}.  Useful for passing\n * primitives to functions by-reference.\n *\n * @template Type - The type of the value wrapped by the returned {@link Ref}.\n *\n * @returns {Ref<Type>} A {@link Ref} of the given {@link Type}.\n */\nexport function MakeRef<Type>(): Ref<Type> {\n    return {\n        Ref: undefined\n    } as Ref<Type>;\n}\n;\n// @TODO Write example for `MapRecord`.\n/* eslint-disable jsdoc/require-example */\n/**\n * Maps a {@link Record} to an {@link Array}.\n *\n * @param InRecord - The {@link Record} over which this function maps.\n * @param InFunction - The {@link FlatMapTransformer | transformer} that maps\n * the record to an {@link Array}.\n *\n * @returns {Array<ElementType>} An {@link Array} of elements, mapped from the given {@link InRecord}.\n */\nexport function Map<KeyType extends PropertyKey, PropertyType, ElementType>(InRecord: Record<KeyType, PropertyType>, InFunction: Mapper<KeyType, PropertyType, ElementType>): Array<ElementType> {\n    return Object.keys(InRecord).map((InKey: string, Index: number): ElementType => {\n        const Key: KeyType = InKey as KeyType;\n        return InFunction(Key, InRecord[Key], Index);\n    });\n}\n;\n/* eslint-enable jsdoc/require-example */\n// @TODO Write example for `FlatMap`.\n/* eslint-disable jsdoc/require-example */\n/**\n * Maps a {@link Record} to an {@link Array}.\n *\n * @param InRecord - The {@link Record} over which this function maps.\n * @param InFunction - The {@link FlatMapTransformer | transformer} that maps\n * the record to an {@link Array}.\n *\n * @returns {Array<ElementType>} An {@link Array} of elements, mapped from the given {@link InRecord}.\n */\nexport function FlatMap<KeyType extends PropertyKey, PropertyType, ElementType>(InRecord: Record<KeyType, PropertyType>, InFunction: FlatMapper<KeyType, PropertyType, ElementType>): Array<ElementType> {\n    return Object.keys(InRecord).flatMap((InKey: string, Index: number): Array<ElementType> => {\n        const Key: KeyType = InKey as KeyType;\n        const Transform: ElementType | Array<ElementType> = InFunction(Key, InRecord[Key], Index);\n        return Array.isArray(Transform)\n            ? Transform\n            : [Transform];\n    });\n}\n/* eslint-enable jsdoc/require-example */\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACsBO,SAAS,oBAAoF,UAAsB,MAAgB,OAA6C;AAEnL,MAAI,MAAM,QAAQ,IAAI,GAAG;AACrB,UAAM,IAAI,MAAM,6DAA6D;AAAA,EACjF;AACA,QAAM,YAA2B,KAAK,MAAM,GAAG;AAC/C,QAAM,OAA2B,UAAU,IAAI;AAC/C,MAAI,SAAS,QAAW;AACpB;AAAA,EACJ;AACA,MAAI,UAAU,WAAW,GAAG;AACxB,QAAI,CAAC,MAAM,QAAQ,IAAI,GAAG;AACtB,MAAE,SAAS,IAAiC,IAAe,IAAK;AAAA,IACpE;AAAA,EACJ;AACA,QAAM,aAAa,CAAC,OAAqC;AACrD,UAAM,uBAA2C,UAAU,MAAM;AACjE,QAAI,yBAAyB,QAAW;AACpC,YAAM,mBAAoC,MAAM,SAAS,oBAAoB,CAAC,IACxE,uBACA,SAAS,oBAAoB;AACnC,YAAM,MAAgB,GAA+B,gBAAgB;AACrE,aAAO,WAAW,GAAG;AAAA,IACzB,OACK;AACD,aAAO;AAAA,IACX;AAAA,EACJ;AACA,QAAM,cAA8B,WAAW,QAAQ;AACvD,QAAM,YAA6B,MAAM,SAAS,IAAI,CAAC,IACjD,OACA,SAAS,IAAI;AACnB,EAAC,YAAY,IAAgC,SAAS,IAAI;AAC9D;AAiBO,SAAS,oBAAmG,UAAsB,MAAgD;AACrL,MAAI,MAAM,QAAQ,IAAI,GAAG;AACrB,UAAM,IAAI,MAAM,6DAA6D;AAAA,EACjF;AACA,QAAM,YAA2B,KAAK,MAAM,GAAG;AAC/C,QAAM,aAAa,CAAC,IAAa,QAAgB,MAAe;AAC5D,UAAM,MAAmC,MAAM,SAAS,UAAU,KAAK,KAAK,EAAE,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