{"version":3,"sources":["../../source/schema/bigint/bigint.ts","../../source/schema/native/native.ts","../../source/schema/empty/empty.ts","../../source/schema/float/float.ts","../../source/schema/integer/integer.ts"],"names":["BUILT_IN_OBJECTS_SCHEMAS","BIGINT_ARRAY_TYPES","BIGINT64_ARRAY_SCHEMA","BIGUINT64_ARRAY_SCHEMA","BIGINT_ARRAY_SCHEMAS","validateBigIntArray","value","options","type","isBigIntArray","z","ARRAY_SCHEMA","validateArray","validateArrays","arrays","currentArray","EMPTY_ARRAY_SCHEMA","validateEmptyArray","array","isEmptyArray","FLOAT_ARRAY_BITS","FLOAT32_ARRAY_SCHEMA","FLOAT64_ARRAY_SCHEMA","FLOAT_ARRAY_SCHEMAS","validateFloatArray","bit","isFloatArray","INTEGER_ARRAY_TYPES","INTEGER_ARRAY_BITS","INTEGER_ARRAY_CATEGORIES","INT8_ARRAY_SCHEMA","INT16_ARRAY_SCHEMA","INT32_ARRAY_SCHEMA","INT_ARRAY_SCHEMAS","UINT8_ARRAY_SCHEMA","UINT8_CLAMPED_ARRAY_SCHEMA","UINT16_ARRAY_SCHEMA","UINT32_ARRAY_SCHEMA","UINT_ARRAY_SCHEMAS","INTEGER_ARRAY_SCHEMAS","isUnsigned","is8Bit","validateIntegerArray","clamped","isIntegerArray"],"mappings":"AAAA,OAAS,4BAAAA,MAAgC,yCAElC,IAAMC,EAAqB,CAAC,SAAU,UAAU,EAG1CC,EAAwBF,EAAyB,cACjDG,EAAyBH,EAAyB,eAElDI,EAAuB,CACnC,OAAQF,EACR,SAAUC,CACX,EAaO,SAASE,EACfC,EACAC,EACqC,CACrC,GAAM,CAAE,KAAAC,CAAK,EAAID,EAEjBH,EAAqBI,CAAI,EAAE,MAAMF,CAAK,CACvC,CAEO,SAASG,EACfH,EACAC,EAC6B,CAC7B,GAAM,CAAE,KAAAC,CAAK,EAAID,EAEjB,OAAOH,EAAqBI,CAAI,EAAE,UAAUF,CAAK,EAAE,OACpD,CCxCA,OAAS,KAAAI,MAAS,MA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,YAC/CqC,EAAsBrC,EAAyB,YAE/CsC,EAAqB,CACjC,EAAG,CAAE,SAAUJ,EAAoB,QAASC,CAA2B,EACvE,GAAI,CAAE,SAAUC,CAAoB,EACpC,GAAI,CAAE,SAAUC,CAAoB,CACrC,EAEaE,EAAwB,CACpC,OAAQN,EACR,SAAUK,CACX,EAkDO,SAASE,EAAWhC,EAA4C,CACtE,OAAOA,IAAS,UACjB,CAEO,SAASiC,EAAOhB,EAAgC,CACtD,OAAOA,IAAQ,CAChB,CAQO,SAASiB,GAKfpC,EACAC,EACiE,CACjE,GAAM,CAAE,KAAAC,EAAM,IAAAiB,CAAI,EAAIlB,EAEtB,GAAIiC,EAAWhC,CAAI,GAAKiC,EAAOhB,CAAG,EAAG,CACpC,GAAM,CAAE,QAAAkB,EAAU,EAAM,EAAIpC,EAE5BgC,EAAsB/B,CAAI,EAAEiB,CAAG,EAAEkB,EAAU,UAAY,UAAU,EAAE,MAAMrC,CAAK,OAE9EiC,EAAsB/B,CAAI,EAAEiB,CAAG,EAAE,SAAY,MAAMnB,CAAK,CAE1D,CAQO,SAASsC,GAKftC,EACAC,EACyD,CACzD,GAAM,CAAE,KAAAC,EAAM,IAAAiB,CAAI,EAAIlB,EAEtB,GAAIiC,EAAWhC,CAAI,GAAKiC,EAAOhB,CAAG,EAAG,CACpC,GAAM,CAAE,QAAAkB,EAAU,EAAM,EAAIpC,EAE5B,OAAOgC,EAAsB/B,CAAI,EAAEiB,CAAG,EAAEkB,EAAU,UAAY,UAAU,EAAE,UAAUrC,CAAK,EAAE,YAE3F,QAAOiC,EAAsB/B,CAAI,EAAEiB,CAAG,EAAE,SAAY,UAAUnB,CAAK,EAAE,OAEvE","sourcesContent":["import { BUILT_IN_OBJECTS_SCHEMAS } from \"@terminal-nerds/snippets-type/built-in\";\n\nexport const BIGINT_ARRAY_TYPES = [\"signed\", \"unsigned\"] as const;\nexport type BigIntArrayType = (typeof BIGINT_ARRAY_TYPES)[number];\n\nexport const BIGINT64_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.BigInt64Array;\nexport const BIGUINT64_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.BigUint64Array;\n\nexport const BIGINT_ARRAY_SCHEMAS = {\n\tsigned: BIGINT64_ARRAY_SCHEMA,\n\tunsigned: BIGUINT64_ARRAY_SCHEMA,\n} as const;\n\nexport interface BigIntArrays {\n\tsigned: BigInt64Array;\n\tunsigned: BigUint64Array;\n}\n\nexport type BigIntArray<Type extends BigIntArrayType> = BigIntArrays[Type];\n\ntype BigIntArrayOptions<Type extends BigIntArrayType> = {\n\ttype: Type;\n};\n\nexport function validateBigIntArray<Type extends BigIntArrayType>(\n\tvalue: unknown,\n\toptions: BigIntArrayOptions<Type>,\n): asserts value is BigIntArray<Type> {\n\tconst { type } = options;\n\n\tBIGINT_ARRAY_SCHEMAS[type].parse(value);\n}\n\nexport function isBigIntArray<Type extends BigIntArrayType>(\n\tvalue: unknown,\n\toptions: BigIntArrayOptions<Type>,\n): value is BigIntArray<Type> {\n\tconst { type } = options;\n\n\treturn BIGINT_ARRAY_SCHEMAS[type].safeParse(value).success;\n}\n","import { z } from \"zod\";\n\nexport const ARRAY_SCHEMA = z.array(z.any());\n\nexport type AnyArray = ReadonlyArray<unknown>;\n\nexport function validateArray(value: unknown): asserts value is AnyArray {\n\tARRAY_SCHEMA.parse(value);\n}\n\nexport function validateArrays(...arrays: AnyArray[]): void {\n\tfor (const currentArray of arrays) {\n\t\tvalidateArray(currentArray);\n\t}\n}\n","import { ARRAY_SCHEMA, validateArray } from \"../native/native.ts\";\n\nexport const EMPTY_ARRAY_SCHEMA = ARRAY_SCHEMA.length(0);\n\nexport type EmptyArray = [];\n\nexport function validateEmptyArray(array: Array<unknown> | readonly unknown[]): asserts array is EmptyArray {\n\tEMPTY_ARRAY_SCHEMA.parse(array);\n}\n\nexport function isEmptyArray(array: Array<unknown> | readonly unknown[]): array is EmptyArray {\n\tvalidateArray(array);\n\n\treturn EMPTY_ARRAY_SCHEMA.safeParse(array).success;\n}\n","import { BUILT_IN_OBJECTS_SCHEMAS } from \"@terminal-nerds/snippets-type/built-in\";\n\nexport const FLOAT_ARRAY_BITS = [32, 64] as const;\nexport type FloatArrayBit = (typeof FLOAT_ARRAY_BITS)[number];\n\nexport const FLOAT32_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Float32Array;\nexport const FLOAT64_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Float64Array;\n\nexport const FLOAT_ARRAY_SCHEMAS = {\n\t32: FLOAT32_ARRAY_SCHEMA,\n\t64: FLOAT64_ARRAY_SCHEMA,\n} as const;\n\nexport type FloatArrays = {\n\t32: Float32Array;\n\t64: Float64Array;\n};\n\nexport type FloatArray<Bit extends FloatArrayBit> = FloatArrays[Bit];\n\nexport interface FloatArrayOptions<Bit extends FloatArrayBit> {\n\tbit: Bit;\n}\n\nexport function validateFloatArray<Bit extends FloatArrayBit>(\n\tvalue: unknown,\n\toptions: FloatArrayOptions<Bit>,\n): asserts value is FloatArray<Bit> {\n\tconst { bit } = options;\n\n\tFLOAT_ARRAY_SCHEMAS[bit].parse(value);\n}\n\nexport function isFloatArray<Bit extends FloatArrayBit>(\n\tvalue: unknown,\n\toptions: FloatArrayOptions<Bit>,\n): value is FloatArray<Bit> {\n\tconst { bit } = options;\n\n\treturn FLOAT_ARRAY_SCHEMAS[bit].safeParse(value).success;\n}\n","import { BUILT_IN_OBJECTS_SCHEMAS } from \"@terminal-nerds/snippets-type/built-in\";\n\nexport const INTEGER_ARRAY_TYPES = [\"signed\", \"unsigned\"] as const;\nexport type IntegerArrayType = (typeof INTEGER_ARRAY_TYPES)[number];\n\nexport const INTEGER_ARRAY_BITS = [8, 16, 32] as const;\nexport type IntegerArrayBit = (typeof INTEGER_ARRAY_BITS)[number];\n\nexport const INTEGER_ARRAY_CATEGORIES = [\"clamped\", \"standard\"] as const;\nexport type IntegerArrayCategory = (typeof INTEGER_ARRAY_CATEGORIES)[number];\n\nexport const INT8_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Int8Array;\nexport const INT16_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Int16Array;\nexport const INT32_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Int32Array;\n\nexport const INT_ARRAY_SCHEMAS = {\n\t8: { standard: INT8_ARRAY_SCHEMA },\n\t16: { standard: INT16_ARRAY_SCHEMA },\n\t32: { standard: INT32_ARRAY_SCHEMA },\n} as const;\n\nexport const UINT8_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Uint8Array;\nexport const UINT8_CLAMPED_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Uint8ClampedArray;\nexport const UINT16_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Uint16Array;\nexport const UINT32_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Uint32Array;\n\nexport const UINT_ARRAY_SCHEMAS = {\n\t8: { standard: UINT8_ARRAY_SCHEMA, clamped: UINT8_CLAMPED_ARRAY_SCHEMA },\n\t16: { standard: UINT16_ARRAY_SCHEMA },\n\t32: { standard: UINT32_ARRAY_SCHEMA },\n} as const;\n\nexport const INTEGER_ARRAY_SCHEMAS = {\n\tsigned: INT_ARRAY_SCHEMAS,\n\tunsigned: UINT_ARRAY_SCHEMAS,\n} as const;\n\nexport interface IntegerArrays {\n\tsigned: {\n\t\t8: { standard: Int8Array };\n\t\t16: { standard: Int16Array };\n\t\t32: { standard: Int32Array };\n\t};\n\tunsigned: {\n\t\t8: { standard: Uint8Array; clamped: Uint8ClampedArray };\n\t\t16: { standard: Uint16Array };\n\t\t32: { standard: Uint32Array };\n\t};\n}\n\nexport type IntArray<Bit extends IntegerArrayBit> = IntegerArrays[\"signed\"][Bit][\"standard\"];\nexport type UintArray<Bit extends IntegerArrayBit, Category extends IntegerArrayCategory> = Bit extends 8\n\t? IntegerArrays[\"unsigned\"][8][Category]\n\t: IntegerArrays[\"unsigned\"][Bit][\"standard\"];\nexport type IntegerArray<\n\tType extends IntegerArrayType,\n\tBit extends IntegerArrayBit,\n\tCategory extends IntegerArrayCategory = Type extends \"unsigned\"\n\t\t? Bit extends 8\n\t\t\t? IntegerArrayCategory\n\t\t\t: \"standard\"\n\t\t: \"standard\",\n> = Type extends \"signed\" ? IntArray<Bit> : Type extends \"unsigned\" ? UintArray<Bit, Category> : never;\n\ntype IntArrayOptions<Type extends IntegerArrayType, Bit extends IntegerArrayBit> = {\n\ttype: Type;\n\tbit: Bit;\n};\n\ntype Uint8ArrayOptions<Clamped extends boolean | undefined = undefined> = {\n\ttype: \"unsigned\";\n\tclamped?: Clamped;\n\tbit: 8;\n};\n\nexport type IntegerArrayOptions<\n\tType extends IntegerArrayType,\n\tBit extends IntegerArrayBit,\n\tClamped extends boolean | undefined = undefined,\n> = Type extends \"unsigned\"\n\t? Bit extends 8\n\t\t? Uint8ArrayOptions<Type extends \"unsigned\" ? (Bit extends 8 ? Clamped : undefined) : undefined>\n\t\t: IntArrayOptions<Type, Bit>\n\t: IntArrayOptions<Type, Bit>;\n\nexport function isUnsigned(type: IntegerArrayType): type is \"unsigned\" {\n\treturn type === \"unsigned\";\n}\n\nexport function is8Bit(bit: IntegerArrayBit): bit is 8 {\n\treturn bit === 8;\n}\n\n/**\n * FIXME:\n * There's an unwanted case, where the passed options -`{ type: \"standard\", bit: 8 }`\n * the return value will be: `Uint8Array` | `Uint8ClampedArray`.\n * What is expected: it should pick one, and base it on the `clamped` optional key in options.\n */\nexport function validateIntegerArray<\n\tType extends IntegerArrayType,\n\tBit extends IntegerArrayBit,\n\tClamped extends boolean | undefined = undefined,\n>(\n\tvalue: unknown,\n\toptions: IntegerArrayOptions<Type, Bit, Clamped>,\n): asserts value is IntegerArray<Type, Bit, IntegerArrayCategory> {\n\tconst { type, bit } = options;\n\n\tif (isUnsigned(type) && is8Bit(bit)) {\n\t\tconst { clamped = false } = options as IntegerArrayOptions<\"unsigned\", 8, Clamped>;\n\n\t\tINTEGER_ARRAY_SCHEMAS[type][bit][clamped ? \"clamped\" : \"standard\"].parse(value);\n\t} else {\n\t\tINTEGER_ARRAY_SCHEMAS[type][bit][\"standard\"].parse(value);\n\t}\n}\n\n/**\n * FIXME:\n * There's an unwanted case, where the passed options -`{ type: \"standard\", bit: 8 }`\n * the return value will be: `Uint8Array` | `Uint8ClampedArray`.\n * What is expected: it should pick one, and base it on the `clamped` optional key in options.\n */\nexport function isIntegerArray<\n\tType extends IntegerArrayType,\n\tBit extends IntegerArrayBit,\n\tClamped extends boolean | undefined = undefined,\n>(\n\tvalue: unknown,\n\toptions: IntegerArrayOptions<Type, Bit, Clamped>,\n): value is IntegerArray<Type, Bit, IntegerArrayCategory> {\n\tconst { type, bit } = options;\n\n\tif (isUnsigned(type) && is8Bit(bit)) {\n\t\tconst { clamped = false } = options as IntegerArrayOptions<\"unsigned\", 8, Clamped>;\n\n\t\treturn INTEGER_ARRAY_SCHEMAS[type][bit][clamped ? \"clamped\" : \"standard\"].safeParse(value).success;\n\t} else {\n\t\treturn INTEGER_ARRAY_SCHEMAS[type][bit][\"standard\"].safeParse(value).success;\n\t}\n}\n"]}