@synnaxlabs/x 0.16.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +3 -3
- package/dist/deep/equal.d.ts.map +1 -1
- package/dist/deep/merge.d.ts.map +1 -1
- package/dist/x.cjs.map +1 -1
- package/dist/x.js.map +1 -1
- package/package.json +3 -3
- package/src/deep/equal.ts +11 -7
- package/src/deep/merge.ts +1 -4
package/dist/x.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"x.cjs","sources":["../../../node_modules/.pnpm/nanoid@3.3.7/node_modules/nanoid/non-secure/index.js","../src/primitive.ts","../src/compare/compare.ts","../../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs","../src/spatial/base.ts","../src/spatial/bounds/bounds.ts","../src/spatial/direction/direction.ts","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-camelcase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-snakecase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-pascalcase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-dotcase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-pathcase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-textcase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-sentencecase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-headercase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-kebabcase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/extends/utils.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/extends/lowercase-keys-object/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/extends/uppercase-keys-object/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/extends/camelcase-keys-object/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/extends/snakecase-keys-object/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/extends/pascalcase-keys-object/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/extends/kebabcase-keys-object/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/index.js","../src/case.ts","../src/spatial/location/location.ts","../src/spatial/xy/xy.ts","../src/spatial/box/box.ts","../src/spatial/dimensions/dimensions.ts","../src/clamp.ts","../src/spatial/scale/scale.ts","../src/spatial/position/position.ts","../src/telem/telem.ts","../src/telem/series.ts","../src/record.ts","../src/renderable.ts","../src/identity.ts","../src/runtime/detect.ts","../src/runtime/os.ts","../src/deep/copy.ts","../src/deep/delete.ts","../src/deep/path.ts","../src/deep/merge.ts","../src/deep/equal.ts","../src/deep/memo.ts","../src/deep/difference.ts","../src/debounce.ts","../src/unique.ts","../src/url/url.ts","../src/toArray.ts","../src/search.ts","../src/worker/worker.ts","../src/binary/encoder.ts","../src/observe/observe.ts","../src/change/change.ts","../src/shallowCopy.ts","../src/invert.ts","../src/migrate/migrate.ts"],"sourcesContent":["let urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\nlet customAlphabet = (alphabet, defaultSize = 21) => {\n return (size = defaultSize) => {\n let id = ''\n let i = size\n while (i--) {\n id += alphabet[(Math.random() * alphabet.length) | 0]\n }\n return id\n }\n}\nlet nanoid = (size = 21) => {\n let id = ''\n let i = size\n while (i--) {\n id += urlAlphabet[(Math.random() * 64) | 0]\n }\n return id\n}\nexport { nanoid, customAlphabet }\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Key } from \"@/record\";\n\nexport type Primitive =\n | string\n | number\n | bigint\n | boolean\n | Stringer\n | null\n | undefined;\n\nexport interface Stringer {\n toString: () => string;\n}\n\nexport const isStringer = (value: unknown): boolean =>\n value != null && typeof value === \"object\" && \"toString\" in value;\n\nexport type PrimitiveRecord = Record<Key, Primitive>;\n\nexport const primitiveIsZero = (value: Primitive): boolean => {\n if (isStringer(value)) return value?.toString().length === 0;\n switch (typeof value) {\n case \"string\":\n return value.length === 0;\n case \"number\":\n return value === 0;\n case \"bigint\":\n return value === 0n;\n case \"boolean\":\n return !value;\n case \"undefined\":\n return true;\n case \"object\":\n return value === null;\n }\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Primitive, isStringer, type PrimitiveRecord } from \"@/primitive\";\nimport { type spatial } from \"@/spatial\";\n\nexport type CompareF<T> = (a: T, b: T) => number;\n\n/**\n * Creates the appropriate compare function for sorting the given\n * primitive type.\n *\n * @param v The primitive value to create a compare function for.\n * This is used to determine the type of comparison to perform.\n * @param reverse Whether to reverse the sort order.\n */\nexport const newF = <T extends Primitive>(\n v: T,\n reverse: boolean = false,\n): CompareF<T> => {\n const t = isStringer(v) ? \"stringer\" : typeof v;\n let f: CompareF<T>;\n switch (t) {\n case \"string\":\n f = (a: T, b: T) => (a as string).localeCompare(b as string);\n break;\n case \"stringer\":\n f = (a: T, b: T) =>\n (a as string).toString().localeCompare((b as string).toString());\n break;\n case \"number\":\n f = (a: T, b: T) => (a as number) - (b as number);\n break;\n case \"bigint\":\n f = (a: T, b: T) => ((a as bigint) - (b as bigint) > BigInt(0) ? 1 : -1);\n break;\n case \"boolean\":\n f = (a: T, b: T) => Number(a) - Number(b);\n break;\n default:\n console.warn(\"sortFunc: unknown type\");\n return () => -1;\n }\n return reverse ? reverseF(f) : f;\n};\n\n/**\n * Creates a compare function that compares the field of the given object.\n *\n * @param key The key of the field to compare.\n * @param value The object to compare the field of. This is used to determine the type of\n * comparison to perform.\n * @param reverse Whether to reverse the sort order.\n */\nexport const newFieldF = <T extends PrimitiveRecord>(\n key: keyof T,\n value: T,\n reverse?: boolean,\n): CompareF<T> => {\n const f = newF(value[key], reverse);\n return (a: T, b: T) => f(a[key], b[key]);\n};\n\n/**\n * Compares the two primitive arrays.\n * @param a The first array to compare.\n * @param b The second array to compare.\n * @returns The array with the greater length if the array lengths are not equal. If the\n * arrays are the same length, returns 0 if all elements are equal, otherwise returns -1.\n */\nexport const primitiveArrays = <T extends Primitive>(\n a: readonly T[] | T[],\n b: readonly T[] | T[],\n): number => {\n if (a.length !== b.length) return a.length - b.length;\n return a.every((v, i) => v === b[i]) ? 0 : -1;\n};\n\nexport const unorderedPrimitiveArrays = <T extends Primitive>(\n a: readonly T[] | T[],\n b: readonly T[] | T[],\n): number => {\n if (a.length !== b.length) return a.length - b.length;\n if (a.length === 0) return 0;\n const compareF = newF(a[0]);\n const aSorted = [...a].sort(compareF);\n const bSorted = [...b].sort(compareF);\n return aSorted.every((v, i) => v === bSorted[i]) ? 0 : -1;\n};\n\nexport const order = (a: spatial.Order, b: spatial.Order): number => {\n if (a === b) return 0;\n if (a === \"first\" && b === \"last\") return 1;\n return -1;\n};\n\n/** @returns the reverse of the given compare function. */\nexport const reverseF =\n <T>(f: CompareF<T>): CompareF<T> =>\n (a: T, b: T) =>\n f(b, a);\n\n/** The equal return value of a compare function. */\nexport const EQUAL = 0;\n\n/** The less than return value of a compare function. */\nexport const LESS_THAN = -1;\n\n/** The greater than return value of a compare function. */\nexport const GREATER_THAN = 1;\n\nexport const isLessThan = (n: number): boolean => n < EQUAL;\n\nexport const isGreaterThan = (n: number): boolean => n > EQUAL;\n\nexport const isGreaterThanEqual = (n: number): boolean => n >= EQUAL;\n","var util;\n(function (util) {\n util.assertEqual = (val) => val;\n function assertIs(_arg) { }\n util.assertIs = assertIs;\n function assertNever(_x) {\n throw new Error();\n }\n util.assertNever = assertNever;\n util.arrayToEnum = (items) => {\n const obj = {};\n for (const item of items) {\n obj[item] = item;\n }\n return obj;\n };\n util.getValidEnumValues = (obj) => {\n const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== \"number\");\n const filtered = {};\n for (const k of validKeys) {\n filtered[k] = obj[k];\n }\n return util.objectValues(filtered);\n };\n util.objectValues = (obj) => {\n return util.objectKeys(obj).map(function (e) {\n return obj[e];\n });\n };\n util.objectKeys = typeof Object.keys === \"function\" // eslint-disable-line ban/ban\n ? (obj) => Object.keys(obj) // eslint-disable-line ban/ban\n : (object) => {\n const keys = [];\n for (const key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n keys.push(key);\n }\n }\n return keys;\n };\n util.find = (arr, checker) => {\n for (const item of arr) {\n if (checker(item))\n return item;\n }\n return undefined;\n };\n util.isInteger = typeof Number.isInteger === \"function\"\n ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban\n : (val) => typeof val === \"number\" && isFinite(val) && Math.floor(val) === val;\n function joinValues(array, separator = \" | \") {\n return array\n .map((val) => (typeof val === \"string\" ? `'${val}'` : val))\n .join(separator);\n }\n util.joinValues = joinValues;\n util.jsonStringifyReplacer = (_, value) => {\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n return value;\n };\n})(util || (util = {}));\nvar objectUtil;\n(function (objectUtil) {\n objectUtil.mergeShapes = (first, second) => {\n return {\n ...first,\n ...second, // second overwrites first\n };\n };\n})(objectUtil || (objectUtil = {}));\nconst ZodParsedType = util.arrayToEnum([\n \"string\",\n \"nan\",\n \"number\",\n \"integer\",\n \"float\",\n \"boolean\",\n \"date\",\n \"bigint\",\n \"symbol\",\n \"function\",\n \"undefined\",\n \"null\",\n \"array\",\n \"object\",\n \"unknown\",\n \"promise\",\n \"void\",\n \"never\",\n \"map\",\n \"set\",\n]);\nconst getParsedType = (data) => {\n const t = typeof data;\n switch (t) {\n case \"undefined\":\n return ZodParsedType.undefined;\n case \"string\":\n return ZodParsedType.string;\n case \"number\":\n return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;\n case \"boolean\":\n return ZodParsedType.boolean;\n case \"function\":\n return ZodParsedType.function;\n case \"bigint\":\n return ZodParsedType.bigint;\n case \"symbol\":\n return ZodParsedType.symbol;\n case \"object\":\n if (Array.isArray(data)) {\n return ZodParsedType.array;\n }\n if (data === null) {\n return ZodParsedType.null;\n }\n if (data.then &&\n typeof data.then === \"function\" &&\n data.catch &&\n typeof data.catch === \"function\") {\n return ZodParsedType.promise;\n }\n if (typeof Map !== \"undefined\" && data instanceof Map) {\n return ZodParsedType.map;\n }\n if (typeof Set !== \"undefined\" && data instanceof Set) {\n return ZodParsedType.set;\n }\n if (typeof Date !== \"undefined\" && data instanceof Date) {\n return ZodParsedType.date;\n }\n return ZodParsedType.object;\n default:\n return ZodParsedType.unknown;\n }\n};\n\nconst ZodIssueCode = util.arrayToEnum([\n \"invalid_type\",\n \"invalid_literal\",\n \"custom\",\n \"invalid_union\",\n \"invalid_union_discriminator\",\n \"invalid_enum_value\",\n \"unrecognized_keys\",\n \"invalid_arguments\",\n \"invalid_return_type\",\n \"invalid_date\",\n \"invalid_string\",\n \"too_small\",\n \"too_big\",\n \"invalid_intersection_types\",\n \"not_multiple_of\",\n \"not_finite\",\n]);\nconst quotelessJson = (obj) => {\n const json = JSON.stringify(obj, null, 2);\n return json.replace(/\"([^\"]+)\":/g, \"$1:\");\n};\nclass ZodError extends Error {\n constructor(issues) {\n super();\n this.issues = [];\n this.addIssue = (sub) => {\n this.issues = [...this.issues, sub];\n };\n this.addIssues = (subs = []) => {\n this.issues = [...this.issues, ...subs];\n };\n const actualProto = new.target.prototype;\n if (Object.setPrototypeOf) {\n // eslint-disable-next-line ban/ban\n Object.setPrototypeOf(this, actualProto);\n }\n else {\n this.__proto__ = actualProto;\n }\n this.name = \"ZodError\";\n this.issues = issues;\n }\n get errors() {\n return this.issues;\n }\n format(_mapper) {\n const mapper = _mapper ||\n function (issue) {\n return issue.message;\n };\n const fieldErrors = { _errors: [] };\n const processError = (error) => {\n for (const issue of error.issues) {\n if (issue.code === \"invalid_union\") {\n issue.unionErrors.map(processError);\n }\n else if (issue.code === \"invalid_return_type\") {\n processError(issue.returnTypeError);\n }\n else if (issue.code === \"invalid_arguments\") {\n processError(issue.argumentsError);\n }\n else if (issue.path.length === 0) {\n fieldErrors._errors.push(mapper(issue));\n }\n else {\n let curr = fieldErrors;\n let i = 0;\n while (i < issue.path.length) {\n const el = issue.path[i];\n const terminal = i === issue.path.length - 1;\n if (!terminal) {\n curr[el] = curr[el] || { _errors: [] };\n // if (typeof el === \"string\") {\n // curr[el] = curr[el] || { _errors: [] };\n // } else if (typeof el === \"number\") {\n // const errorArray: any = [];\n // errorArray._errors = [];\n // curr[el] = curr[el] || errorArray;\n // }\n }\n else {\n curr[el] = curr[el] || { _errors: [] };\n curr[el]._errors.push(mapper(issue));\n }\n curr = curr[el];\n i++;\n }\n }\n }\n };\n processError(this);\n return fieldErrors;\n }\n toString() {\n return this.message;\n }\n get message() {\n return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);\n }\n get isEmpty() {\n return this.issues.length === 0;\n }\n flatten(mapper = (issue) => issue.message) {\n const fieldErrors = {};\n const formErrors = [];\n for (const sub of this.issues) {\n if (sub.path.length > 0) {\n fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];\n fieldErrors[sub.path[0]].push(mapper(sub));\n }\n else {\n formErrors.push(mapper(sub));\n }\n }\n return { formErrors, fieldErrors };\n }\n get formErrors() {\n return this.flatten();\n }\n}\nZodError.create = (issues) => {\n const error = new ZodError(issues);\n return error;\n};\n\nconst errorMap = (issue, _ctx) => {\n let message;\n switch (issue.code) {\n case ZodIssueCode.invalid_type:\n if (issue.received === ZodParsedType.undefined) {\n message = \"Required\";\n }\n else {\n message = `Expected ${issue.expected}, received ${issue.received}`;\n }\n break;\n case ZodIssueCode.invalid_literal:\n message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;\n break;\n case ZodIssueCode.unrecognized_keys:\n message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, \", \")}`;\n break;\n case ZodIssueCode.invalid_union:\n message = `Invalid input`;\n break;\n case ZodIssueCode.invalid_union_discriminator:\n message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;\n break;\n case ZodIssueCode.invalid_enum_value:\n message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;\n break;\n case ZodIssueCode.invalid_arguments:\n message = `Invalid function arguments`;\n break;\n case ZodIssueCode.invalid_return_type:\n message = `Invalid function return type`;\n break;\n case ZodIssueCode.invalid_date:\n message = `Invalid date`;\n break;\n case ZodIssueCode.invalid_string:\n if (typeof issue.validation === \"object\") {\n if (\"includes\" in issue.validation) {\n message = `Invalid input: must include \"${issue.validation.includes}\"`;\n if (typeof issue.validation.position === \"number\") {\n message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;\n }\n }\n else if (\"startsWith\" in issue.validation) {\n message = `Invalid input: must start with \"${issue.validation.startsWith}\"`;\n }\n else if (\"endsWith\" in issue.validation) {\n message = `Invalid input: must end with \"${issue.validation.endsWith}\"`;\n }\n else {\n util.assertNever(issue.validation);\n }\n }\n else if (issue.validation !== \"regex\") {\n message = `Invalid ${issue.validation}`;\n }\n else {\n message = \"Invalid\";\n }\n break;\n case ZodIssueCode.too_small:\n if (issue.type === \"array\")\n message = `Array must contain ${issue.exact ? \"exactly\" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;\n else if (issue.type === \"string\")\n message = `String must contain ${issue.exact ? \"exactly\" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;\n else if (issue.type === \"number\")\n message = `Number must be ${issue.exact\n ? `exactly equal to `\n : issue.inclusive\n ? `greater than or equal to `\n : `greater than `}${issue.minimum}`;\n else if (issue.type === \"date\")\n message = `Date must be ${issue.exact\n ? `exactly equal to `\n : issue.inclusive\n ? `greater than or equal to `\n : `greater than `}${new Date(Number(issue.minimum))}`;\n else\n message = \"Invalid input\";\n break;\n case ZodIssueCode.too_big:\n if (issue.type === \"array\")\n message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;\n else if (issue.type === \"string\")\n message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;\n else if (issue.type === \"number\")\n message = `Number must be ${issue.exact\n ? `exactly`\n : issue.inclusive\n ? `less than or equal to`\n : `less than`} ${issue.maximum}`;\n else if (issue.type === \"bigint\")\n message = `BigInt must be ${issue.exact\n ? `exactly`\n : issue.inclusive\n ? `less than or equal to`\n : `less than`} ${issue.maximum}`;\n else if (issue.type === \"date\")\n message = `Date must be ${issue.exact\n ? `exactly`\n : issue.inclusive\n ? `smaller than or equal to`\n : `smaller than`} ${new Date(Number(issue.maximum))}`;\n else\n message = \"Invalid input\";\n break;\n case ZodIssueCode.custom:\n message = `Invalid input`;\n break;\n case ZodIssueCode.invalid_intersection_types:\n message = `Intersection results could not be merged`;\n break;\n case ZodIssueCode.not_multiple_of:\n message = `Number must be a multiple of ${issue.multipleOf}`;\n break;\n case ZodIssueCode.not_finite:\n message = \"Number must be finite\";\n break;\n default:\n message = _ctx.defaultError;\n util.assertNever(issue);\n }\n return { message };\n};\n\nlet overrideErrorMap = errorMap;\nfunction setErrorMap(map) {\n overrideErrorMap = map;\n}\nfunction getErrorMap() {\n return overrideErrorMap;\n}\n\nconst makeIssue = (params) => {\n const { data, path, errorMaps, issueData } = params;\n const fullPath = [...path, ...(issueData.path || [])];\n const fullIssue = {\n ...issueData,\n path: fullPath,\n };\n let errorMessage = \"\";\n const maps = errorMaps\n .filter((m) => !!m)\n .slice()\n .reverse();\n for (const map of maps) {\n errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;\n }\n return {\n ...issueData,\n path: fullPath,\n message: issueData.message || errorMessage,\n };\n};\nconst EMPTY_PATH = [];\nfunction addIssueToContext(ctx, issueData) {\n const issue = makeIssue({\n issueData: issueData,\n data: ctx.data,\n path: ctx.path,\n errorMaps: [\n ctx.common.contextualErrorMap,\n ctx.schemaErrorMap,\n getErrorMap(),\n errorMap, // then global default map\n ].filter((x) => !!x),\n });\n ctx.common.issues.push(issue);\n}\nclass ParseStatus {\n constructor() {\n this.value = \"valid\";\n }\n dirty() {\n if (this.value === \"valid\")\n this.value = \"dirty\";\n }\n abort() {\n if (this.value !== \"aborted\")\n this.value = \"aborted\";\n }\n static mergeArray(status, results) {\n const arrayValue = [];\n for (const s of results) {\n if (s.status === \"aborted\")\n return INVALID;\n if (s.status === \"dirty\")\n status.dirty();\n arrayValue.push(s.value);\n }\n return { status: status.value, value: arrayValue };\n }\n static async mergeObjectAsync(status, pairs) {\n const syncPairs = [];\n for (const pair of pairs) {\n syncPairs.push({\n key: await pair.key,\n value: await pair.value,\n });\n }\n return ParseStatus.mergeObjectSync(status, syncPairs);\n }\n static mergeObjectSync(status, pairs) {\n const finalObject = {};\n for (const pair of pairs) {\n const { key, value } = pair;\n if (key.status === \"aborted\")\n return INVALID;\n if (value.status === \"aborted\")\n return INVALID;\n if (key.status === \"dirty\")\n status.dirty();\n if (value.status === \"dirty\")\n status.dirty();\n if (key.value !== \"__proto__\" &&\n (typeof value.value !== \"undefined\" || pair.alwaysSet)) {\n finalObject[key.value] = value.value;\n }\n }\n return { status: status.value, value: finalObject };\n }\n}\nconst INVALID = Object.freeze({\n status: \"aborted\",\n});\nconst DIRTY = (value) => ({ status: \"dirty\", value });\nconst OK = (value) => ({ status: \"valid\", value });\nconst isAborted = (x) => x.status === \"aborted\";\nconst isDirty = (x) => x.status === \"dirty\";\nconst isValid = (x) => x.status === \"valid\";\nconst isAsync = (x) => typeof Promise !== \"undefined\" && x instanceof Promise;\n\nvar errorUtil;\n(function (errorUtil) {\n errorUtil.errToObj = (message) => typeof message === \"string\" ? { message } : message || {};\n errorUtil.toString = (message) => typeof message === \"string\" ? message : message === null || message === void 0 ? void 0 : message.message;\n})(errorUtil || (errorUtil = {}));\n\nclass ParseInputLazyPath {\n constructor(parent, value, path, key) {\n this._cachedPath = [];\n this.parent = parent;\n this.data = value;\n this._path = path;\n this._key = key;\n }\n get path() {\n if (!this._cachedPath.length) {\n if (this._key instanceof Array) {\n this._cachedPath.push(...this._path, ...this._key);\n }\n else {\n this._cachedPath.push(...this._path, this._key);\n }\n }\n return this._cachedPath;\n }\n}\nconst handleResult = (ctx, result) => {\n if (isValid(result)) {\n return { success: true, data: result.value };\n }\n else {\n if (!ctx.common.issues.length) {\n throw new Error(\"Validation failed but no issues detected.\");\n }\n return {\n success: false,\n get error() {\n if (this._error)\n return this._error;\n const error = new ZodError(ctx.common.issues);\n this._error = error;\n return this._error;\n },\n };\n }\n};\nfunction processCreateParams(params) {\n if (!params)\n return {};\n const { errorMap, invalid_type_error, required_error, description } = params;\n if (errorMap && (invalid_type_error || required_error)) {\n throw new Error(`Can't use \"invalid_type_error\" or \"required_error\" in conjunction with custom error map.`);\n }\n if (errorMap)\n return { errorMap: errorMap, description };\n const customMap = (iss, ctx) => {\n if (iss.code !== \"invalid_type\")\n return { message: ctx.defaultError };\n if (typeof ctx.data === \"undefined\") {\n return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };\n }\n return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };\n };\n return { errorMap: customMap, description };\n}\nclass ZodType {\n constructor(def) {\n /** Alias of safeParseAsync */\n this.spa = this.safeParseAsync;\n this._def = def;\n this.parse = this.parse.bind(this);\n this.safeParse = this.safeParse.bind(this);\n this.parseAsync = this.parseAsync.bind(this);\n this.safeParseAsync = this.safeParseAsync.bind(this);\n this.spa = this.spa.bind(this);\n this.refine = this.refine.bind(this);\n this.refinement = this.refinement.bind(this);\n this.superRefine = this.superRefine.bind(this);\n this.optional = this.optional.bind(this);\n this.nullable = this.nullable.bind(this);\n this.nullish = this.nullish.bind(this);\n this.array = this.array.bind(this);\n this.promise = this.promise.bind(this);\n this.or = this.or.bind(this);\n this.and = this.and.bind(this);\n this.transform = this.transform.bind(this);\n this.brand = this.brand.bind(this);\n this.default = this.default.bind(this);\n this.catch = this.catch.bind(this);\n this.describe = this.describe.bind(this);\n this.pipe = this.pipe.bind(this);\n this.readonly = this.readonly.bind(this);\n this.isNullable = this.isNullable.bind(this);\n this.isOptional = this.isOptional.bind(this);\n }\n get description() {\n return this._def.description;\n }\n _getType(input) {\n return getParsedType(input.data);\n }\n _getOrReturnCtx(input, ctx) {\n return (ctx || {\n common: input.parent.common,\n data: input.data,\n parsedType: getParsedType(input.data),\n schemaErrorMap: this._def.errorMap,\n path: input.path,\n parent: input.parent,\n });\n }\n _processInputParams(input) {\n return {\n status: new ParseStatus(),\n ctx: {\n common: input.parent.common,\n data: input.data,\n parsedType: getParsedType(input.data),\n schemaErrorMap: this._def.errorMap,\n path: input.path,\n parent: input.parent,\n },\n };\n }\n _parseSync(input) {\n const result = this._parse(input);\n if (isAsync(result)) {\n throw new Error(\"Synchronous parse encountered promise.\");\n }\n return result;\n }\n _parseAsync(input) {\n const result = this._parse(input);\n return Promise.resolve(result);\n }\n parse(data, params) {\n const result = this.safeParse(data, params);\n if (result.success)\n return result.data;\n throw result.error;\n }\n safeParse(data, params) {\n var _a;\n const ctx = {\n common: {\n issues: [],\n async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,\n contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,\n },\n path: (params === null || params === void 0 ? void 0 : params.path) || [],\n schemaErrorMap: this._def.errorMap,\n parent: null,\n data,\n parsedType: getParsedType(data),\n };\n const result = this._parseSync({ data, path: ctx.path, parent: ctx });\n return handleResult(ctx, result);\n }\n async parseAsync(data, params) {\n const result = await this.safeParseAsync(data, params);\n if (result.success)\n return result.data;\n throw result.error;\n }\n async safeParseAsync(data, params) {\n const ctx = {\n common: {\n issues: [],\n contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,\n async: true,\n },\n path: (params === null || params === void 0 ? void 0 : params.path) || [],\n schemaErrorMap: this._def.errorMap,\n parent: null,\n data,\n parsedType: getParsedType(data),\n };\n const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });\n const result = await (isAsync(maybeAsyncResult)\n ? maybeAsyncResult\n : Promise.resolve(maybeAsyncResult));\n return handleResult(ctx, result);\n }\n refine(check, message) {\n const getIssueProperties = (val) => {\n if (typeof message === \"string\" || typeof message === \"undefined\") {\n return { message };\n }\n else if (typeof message === \"function\") {\n return message(val);\n }\n else {\n return message;\n }\n };\n return this._refinement((val, ctx) => {\n const result = check(val);\n const setError = () => ctx.addIssue({\n code: ZodIssueCode.custom,\n ...getIssueProperties(val),\n });\n if (typeof Promise !== \"undefined\" && result instanceof Promise) {\n return result.then((data) => {\n if (!data) {\n setError();\n return false;\n }\n else {\n return true;\n }\n });\n }\n if (!result) {\n setError();\n return false;\n }\n else {\n return true;\n }\n });\n }\n refinement(check, refinementData) {\n return this._refinement((val, ctx) => {\n if (!check(val)) {\n ctx.addIssue(typeof refinementData === \"function\"\n ? refinementData(val, ctx)\n : refinementData);\n return false;\n }\n else {\n return true;\n }\n });\n }\n _refinement(refinement) {\n return new ZodEffects({\n schema: this,\n typeName: ZodFirstPartyTypeKind.ZodEffects,\n effect: { type: \"refinement\", refinement },\n });\n }\n superRefine(refinement) {\n return this._refinement(refinement);\n }\n optional() {\n return ZodOptional.create(this, this._def);\n }\n nullable() {\n return ZodNullable.create(this, this._def);\n }\n nullish() {\n return this.nullable().optional();\n }\n array() {\n return ZodArray.create(this, this._def);\n }\n promise() {\n return ZodPromise.create(this, this._def);\n }\n or(option) {\n return ZodUnion.create([this, option], this._def);\n }\n and(incoming) {\n return ZodIntersection.create(this, incoming, this._def);\n }\n transform(transform) {\n return new ZodEffects({\n ...processCreateParams(this._def),\n schema: this,\n typeName: ZodFirstPartyTypeKind.ZodEffects,\n effect: { type: \"transform\", transform },\n });\n }\n default(def) {\n const defaultValueFunc = typeof def === \"function\" ? def : () => def;\n return new ZodDefault({\n ...processCreateParams(this._def),\n innerType: this,\n defaultValue: defaultValueFunc,\n typeName: ZodFirstPartyTypeKind.ZodDefault,\n });\n }\n brand() {\n return new ZodBranded({\n typeName: ZodFirstPartyTypeKind.ZodBranded,\n type: this,\n ...processCreateParams(this._def),\n });\n }\n catch(def) {\n const catchValueFunc = typeof def === \"function\" ? def : () => def;\n return new ZodCatch({\n ...processCreateParams(this._def),\n innerType: this,\n catchValue: catchValueFunc,\n typeName: ZodFirstPartyTypeKind.ZodCatch,\n });\n }\n describe(description) {\n const This = this.constructor;\n return new This({\n ...this._def,\n description,\n });\n }\n pipe(target) {\n return ZodPipeline.create(this, target);\n }\n readonly() {\n return ZodReadonly.create(this);\n }\n isOptional() {\n return this.safeParse(undefined).success;\n }\n isNullable() {\n return this.safeParse(null).success;\n }\n}\nconst cuidRegex = /^c[^\\s-]{8,}$/i;\nconst cuid2Regex = /^[a-z][a-z0-9]*$/;\nconst ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;\n// const uuidRegex =\n// /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;\nconst uuidRegex = /^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/i;\n// from https://stackoverflow.com/a/46181/1550155\n// old version: too slow, didn't support unicode\n// const emailRegex = /^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))$/i;\n//old email regex\n// const emailRegex = /^(([^<>()[\\].,;:\\s@\"]+(\\.[^<>()[\\].,;:\\s@\"]+)*)|(\".+\"))@((?!-)([^<>()[\\].,;:\\s@\"]+\\.)+[^<>()[\\].,;:\\s@\"]{1,})[^-<>()[\\].,;:\\s@\"]$/i;\n// eslint-disable-next-line\n// const emailRegex =\n// /^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\])|(\\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\\.[A-Za-z]{2,})+))$/;\n// const emailRegex =\n// /^[a-zA-Z0-9\\.\\!\\#\\$\\%\\&\\'\\*\\+\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~\\-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;\n// const emailRegex =\n// /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])$/i;\nconst emailRegex = /^(?!\\.)(?!.*\\.\\.)([A-Z0-9_+-\\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\\-]*\\.)+[A-Z]{2,}$/i;\n// const emailRegex =\n// /^[a-z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\\.[a-z0-9\\-]+)*$/i;\n// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression\nconst _emojiRegex = `^(\\\\p{Extended_Pictographic}|\\\\p{Emoji_Component})+$`;\nlet emojiRegex;\nconst ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/;\nconst ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;\n// Adapted from https://stackoverflow.com/a/3143231\nconst datetimeRegex = (args) => {\n if (args.precision) {\n if (args.offset) {\n return new RegExp(`^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}\\\\.\\\\d{${args.precision}}(([+-]\\\\d{2}(:?\\\\d{2})?)|Z)$`);\n }\n else {\n return new RegExp(`^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}\\\\.\\\\d{${args.precision}}Z$`);\n }\n }\n else if (args.precision === 0) {\n if (args.offset) {\n return new RegExp(`^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}(([+-]\\\\d{2}(:?\\\\d{2})?)|Z)$`);\n }\n else {\n return new RegExp(`^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}Z$`);\n }\n }\n else {\n if (args.offset) {\n return new RegExp(`^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}(\\\\.\\\\d+)?(([+-]\\\\d{2}(:?\\\\d{2})?)|Z)$`);\n }\n else {\n return new RegExp(`^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}(\\\\.\\\\d+)?Z$`);\n }\n }\n};\nfunction isValidIP(ip, version) {\n if ((version === \"v4\" || !version) && ipv4Regex.test(ip)) {\n return true;\n }\n if ((version === \"v6\" || !version) && ipv6Regex.test(ip)) {\n return true;\n }\n return false;\n}\nclass ZodString extends ZodType {\n _parse(input) {\n if (this._def.coerce) {\n input.data = String(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.string) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.string,\n received: ctx.parsedType,\n }\n //\n );\n return INVALID;\n }\n const status = new ParseStatus();\n let ctx = undefined;\n for (const check of this._def.checks) {\n if (check.kind === \"min\") {\n if (input.data.length < check.value) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: check.value,\n type: \"string\",\n inclusive: true,\n exact: false,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"max\") {\n if (input.data.length > check.value) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: check.value,\n type: \"string\",\n inclusive: true,\n exact: false,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"length\") {\n const tooBig = input.data.length > check.value;\n const tooSmall = input.data.length < check.value;\n if (tooBig || tooSmall) {\n ctx = this._getOrReturnCtx(input, ctx);\n if (tooBig) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: check.value,\n type: \"string\",\n inclusive: true,\n exact: true,\n message: check.message,\n });\n }\n else if (tooSmall) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: check.value,\n type: \"string\",\n inclusive: true,\n exact: true,\n message: check.message,\n });\n }\n status.dirty();\n }\n }\n else if (check.kind === \"email\") {\n if (!emailRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"email\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"emoji\") {\n if (!emojiRegex) {\n emojiRegex = new RegExp(_emojiRegex, \"u\");\n }\n if (!emojiRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"emoji\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"uuid\") {\n if (!uuidRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"uuid\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"cuid\") {\n if (!cuidRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"cuid\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"cuid2\") {\n if (!cuid2Regex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"cuid2\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"ulid\") {\n if (!ulidRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"ulid\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"url\") {\n try {\n new URL(input.data);\n }\n catch (_a) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"url\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"regex\") {\n check.regex.lastIndex = 0;\n const testResult = check.regex.test(input.data);\n if (!testResult) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"regex\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"trim\") {\n input.data = input.data.trim();\n }\n else if (check.kind === \"includes\") {\n if (!input.data.includes(check.value, check.position)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: { includes: check.value, position: check.position },\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"toLowerCase\") {\n input.data = input.data.toLowerCase();\n }\n else if (check.kind === \"toUpperCase\") {\n input.data = input.data.toUpperCase();\n }\n else if (check.kind === \"startsWith\") {\n if (!input.data.startsWith(check.value)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: { startsWith: check.value },\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"endsWith\") {\n if (!input.data.endsWith(check.value)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: { endsWith: check.value },\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"datetime\") {\n const regex = datetimeRegex(check);\n if (!regex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: \"datetime\",\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"ip\") {\n if (!isValidIP(input.data, check.version)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"ip\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else {\n util.assertNever(check);\n }\n }\n return { status: status.value, value: input.data };\n }\n _regex(regex, validation, message) {\n return this.refinement((data) => regex.test(data), {\n validation,\n code: ZodIssueCode.invalid_string,\n ...errorUtil.errToObj(message),\n });\n }\n _addCheck(check) {\n return new ZodString({\n ...this._def,\n checks: [...this._def.checks, check],\n });\n }\n email(message) {\n return this._addCheck({ kind: \"email\", ...errorUtil.errToObj(message) });\n }\n url(message) {\n return this._addCheck({ kind: \"url\", ...errorUtil.errToObj(message) });\n }\n emoji(message) {\n return this._addCheck({ kind: \"emoji\", ...errorUtil.errToObj(message) });\n }\n uuid(message) {\n return this._addCheck({ kind: \"uuid\", ...errorUtil.errToObj(message) });\n }\n cuid(message) {\n return this._addCheck({ kind: \"cuid\", ...errorUtil.errToObj(message) });\n }\n cuid2(message) {\n return this._addCheck({ kind: \"cuid2\", ...errorUtil.errToObj(message) });\n }\n ulid(message) {\n return this._addCheck({ kind: \"ulid\", ...errorUtil.errToObj(message) });\n }\n ip(options) {\n return this._addCheck({ kind: \"ip\", ...errorUtil.errToObj(options) });\n }\n datetime(options) {\n var _a;\n if (typeof options === \"string\") {\n return this._addCheck({\n kind: \"datetime\",\n precision: null,\n offset: false,\n message: options,\n });\n }\n return this._addCheck({\n kind: \"datetime\",\n precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === \"undefined\" ? null : options === null || options === void 0 ? void 0 : options.precision,\n offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,\n ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),\n });\n }\n regex(regex, message) {\n return this._addCheck({\n kind: \"regex\",\n regex: regex,\n ...errorUtil.errToObj(message),\n });\n }\n includes(value, options) {\n return this._addCheck({\n kind: \"includes\",\n value: value,\n position: options === null || options === void 0 ? void 0 : options.position,\n ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),\n });\n }\n startsWith(value, message) {\n return this._addCheck({\n kind: \"startsWith\",\n value: value,\n ...errorUtil.errToObj(message),\n });\n }\n endsWith(value, message) {\n return this._addCheck({\n kind: \"endsWith\",\n value: value,\n ...errorUtil.errToObj(message),\n });\n }\n min(minLength, message) {\n return this._addCheck({\n kind: \"min\",\n value: minLength,\n ...errorUtil.errToObj(message),\n });\n }\n max(maxLength, message) {\n return this._addCheck({\n kind: \"max\",\n value: maxLength,\n ...errorUtil.errToObj(message),\n });\n }\n length(len, message) {\n return this._addCheck({\n kind: \"length\",\n value: len,\n ...errorUtil.errToObj(message),\n });\n }\n /**\n * @deprecated Use z.string().min(1) instead.\n * @see {@link ZodString.min}\n */\n nonempty(message) {\n return this.min(1, errorUtil.errToObj(message));\n }\n trim() {\n return new ZodString({\n ...this._def,\n checks: [...this._def.checks, { kind: \"trim\" }],\n });\n }\n toLowerCase() {\n return new ZodString({\n ...this._def,\n checks: [...this._def.checks, { kind: \"toLowerCase\" }],\n });\n }\n toUpperCase() {\n return new ZodString({\n ...this._def,\n checks: [...this._def.checks, { kind: \"toUpperCase\" }],\n });\n }\n get isDatetime() {\n return !!this._def.checks.find((ch) => ch.kind === \"datetime\");\n }\n get isEmail() {\n return !!this._def.checks.find((ch) => ch.kind === \"email\");\n }\n get isURL() {\n return !!this._def.checks.find((ch) => ch.kind === \"url\");\n }\n get isEmoji() {\n return !!this._def.checks.find((ch) => ch.kind === \"emoji\");\n }\n get isUUID() {\n return !!this._def.checks.find((ch) => ch.kind === \"uuid\");\n }\n get isCUID() {\n return !!this._def.checks.find((ch) => ch.kind === \"cuid\");\n }\n get isCUID2() {\n return !!this._def.checks.find((ch) => ch.kind === \"cuid2\");\n }\n get isULID() {\n return !!this._def.checks.find((ch) => ch.kind === \"ulid\");\n }\n get isIP() {\n return !!this._def.checks.find((ch) => ch.kind === \"ip\");\n }\n get minLength() {\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"min\") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n }\n return min;\n }\n get maxLength() {\n let max = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"max\") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return max;\n }\n}\nZodString.create = (params) => {\n var _a;\n return new ZodString({\n checks: [],\n typeName: ZodFirstPartyTypeKind.ZodString,\n coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,\n ...processCreateParams(params),\n });\n};\n// https://stackoverflow.com/questions/3966484/why-does-modulus-operator-return-fractional-number-in-javascript/31711034#31711034\nfunction floatSafeRemainder(val, step) {\n const valDecCount = (val.toString().split(\".\")[1] || \"\").length;\n const stepDecCount = (step.toString().split(\".\")[1] || \"\").length;\n const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;\n const valInt = parseInt(val.toFixed(decCount).replace(\".\", \"\"));\n const stepInt = parseInt(step.toFixed(decCount).replace(\".\", \"\"));\n return (valInt % stepInt) / Math.pow(10, decCount);\n}\nclass ZodNumber extends ZodType {\n constructor() {\n super(...arguments);\n this.min = this.gte;\n this.max = this.lte;\n this.step = this.multipleOf;\n }\n _parse(input) {\n if (this._def.coerce) {\n input.data = Number(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.number) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.number,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n let ctx = undefined;\n const status = new ParseStatus();\n for (const check of this._def.checks) {\n if (check.kind === \"int\") {\n if (!util.isInteger(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: \"integer\",\n received: \"float\",\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"min\") {\n const tooSmall = check.inclusive\n ? input.data < check.value\n : input.data <= check.value;\n if (tooSmall) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: check.value,\n type: \"number\",\n inclusive: check.inclusive,\n exact: false,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"max\") {\n const tooBig = check.inclusive\n ? input.data > check.value\n : input.data >= check.value;\n if (tooBig) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: check.value,\n type: \"number\",\n inclusive: check.inclusive,\n exact: false,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"multipleOf\") {\n if (floatSafeRemainder(input.data, check.value) !== 0) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.not_multiple_of,\n multipleOf: check.value,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"finite\") {\n if (!Number.isFinite(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.not_finite,\n message: check.message,\n });\n status.dirty();\n }\n }\n else {\n util.assertNever(check);\n }\n }\n return { status: status.value, value: input.data };\n }\n gte(value, message) {\n return this.setLimit(\"min\", value, true, errorUtil.toString(message));\n }\n gt(value, message) {\n return this.setLimit(\"min\", value, false, errorUtil.toString(message));\n }\n lte(value, message) {\n return this.setLimit(\"max\", value, true, errorUtil.toString(message));\n }\n lt(value, message) {\n return this.setLimit(\"max\", value, false, errorUtil.toString(message));\n }\n setLimit(kind, value, inclusive, message) {\n return new ZodNumber({\n ...this._def,\n checks: [\n ...this._def.checks,\n {\n kind,\n value,\n inclusive,\n message: errorUtil.toString(message),\n },\n ],\n });\n }\n _addCheck(check) {\n return new ZodNumber({\n ...this._def,\n checks: [...this._def.checks, check],\n });\n }\n int(message) {\n return this._addCheck({\n kind: \"int\",\n message: errorUtil.toString(message),\n });\n }\n positive(message) {\n return this._addCheck({\n kind: \"min\",\n value: 0,\n inclusive: false,\n message: errorUtil.toString(message),\n });\n }\n negative(message) {\n return this._addCheck({\n kind: \"max\",\n value: 0,\n inclusive: false,\n message: errorUtil.toString(message),\n });\n }\n nonpositive(message) {\n return this._addCheck({\n kind: \"max\",\n value: 0,\n inclusive: true,\n message: errorUtil.toString(message),\n });\n }\n nonnegative(message) {\n return this._addCheck({\n kind: \"min\",\n value: 0,\n inclusive: true,\n message: errorUtil.toString(message),\n });\n }\n multipleOf(value, message) {\n return this._addCheck({\n kind: \"multipleOf\",\n value: value,\n message: errorUtil.toString(message),\n });\n }\n finite(message) {\n return this._addCheck({\n kind: \"finite\",\n message: errorUtil.toString(message),\n });\n }\n safe(message) {\n return this._addCheck({\n kind: \"min\",\n inclusive: true,\n value: Number.MIN_SAFE_INTEGER,\n message: errorUtil.toString(message),\n })._addCheck({\n kind: \"max\",\n inclusive: true,\n value: Number.MAX_SAFE_INTEGER,\n message: errorUtil.toString(message),\n });\n }\n get minValue() {\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"min\") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n }\n return min;\n }\n get maxValue() {\n let max = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"max\") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return max;\n }\n get isInt() {\n return !!this._def.checks.find((ch) => ch.kind === \"int\" ||\n (ch.kind === \"multipleOf\" && util.isInteger(ch.value)));\n }\n get isFinite() {\n let max = null, min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"finite\" ||\n ch.kind === \"int\" ||\n ch.kind === \"multipleOf\") {\n return true;\n }\n else if (ch.kind === \"min\") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n else if (ch.kind === \"max\") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return Number.isFinite(min) && Number.isFinite(max);\n }\n}\nZodNumber.create = (params) => {\n return new ZodNumber({\n checks: [],\n typeName: ZodFirstPartyTypeKind.ZodNumber,\n coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,\n ...processCreateParams(params),\n });\n};\nclass ZodBigInt extends ZodType {\n constructor() {\n super(...arguments);\n this.min = this.gte;\n this.max = this.lte;\n }\n _parse(input) {\n if (this._def.coerce) {\n input.data = BigInt(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.bigint) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.bigint,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n let ctx = undefined;\n const status = new ParseStatus();\n for (const check of this._def.checks) {\n if (check.kind === \"min\") {\n const tooSmall = check.inclusive\n ? input.data < check.value\n : input.data <= check.value;\n if (tooSmall) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n type: \"bigint\",\n minimum: check.value,\n inclusive: check.inclusive,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"max\") {\n const tooBig = check.inclusive\n ? input.data > check.value\n : input.data >= check.value;\n if (tooBig) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n type: \"bigint\",\n maximum: check.value,\n inclusive: check.inclusive,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"multipleOf\") {\n if (input.data % check.value !== BigInt(0)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.not_multiple_of,\n multipleOf: check.value,\n message: check.message,\n });\n status.dirty();\n }\n }\n else {\n util.assertNever(check);\n }\n }\n return { status: status.value, value: input.data };\n }\n gte(value, message) {\n return this.setLimit(\"min\", value, true, errorUtil.toString(message));\n }\n gt(value, message) {\n return this.setLimit(\"min\", value, false, errorUtil.toString(message));\n }\n lte(value, message) {\n return this.setLimit(\"max\", value, true, errorUtil.toString(message));\n }\n lt(value, message) {\n return this.setLimit(\"max\", value, false, errorUtil.toString(message));\n }\n setLimit(kind, value, inclusive, message) {\n return new ZodBigInt({\n ...this._def,\n checks: [\n ...this._def.checks,\n {\n kind,\n value,\n inclusive,\n message: errorUtil.toString(message),\n },\n ],\n });\n }\n _addCheck(check) {\n return new ZodBigInt({\n ...this._def,\n checks: [...this._def.checks, check],\n });\n }\n positive(message) {\n return this._addCheck({\n kind: \"min\",\n value: BigInt(0),\n inclusive: false,\n message: errorUtil.toString(message),\n });\n }\n negative(message) {\n return this._addCheck({\n kind: \"max\",\n value: BigInt(0),\n inclusive: false,\n message: errorUtil.toString(message),\n });\n }\n nonpositive(message) {\n return this._addCheck({\n kind: \"max\",\n value: BigInt(0),\n inclusive: true,\n message: errorUtil.toString(message),\n });\n }\n nonnegative(message) {\n return this._addCheck({\n kind: \"min\",\n value: BigInt(0),\n inclusive: true,\n message: errorUtil.toString(message),\n });\n }\n multipleOf(value, message) {\n return this._addCheck({\n kind: \"multipleOf\",\n value,\n message: errorUtil.toString(message),\n });\n }\n get minValue() {\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"min\") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n }\n return min;\n }\n get maxValue() {\n let max = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"max\") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return max;\n }\n}\nZodBigInt.create = (params) => {\n var _a;\n return new ZodBigInt({\n checks: [],\n typeName: ZodFirstPartyTypeKind.ZodBigInt,\n coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,\n ...processCreateParams(params),\n });\n};\nclass ZodBoolean extends ZodType {\n _parse(input) {\n if (this._def.coerce) {\n input.data = Boolean(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.boolean) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.boolean,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n return OK(input.data);\n }\n}\nZodBoolean.create = (params) => {\n return new ZodBoolean({\n typeName: ZodFirstPartyTypeKind.ZodBoolean,\n coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,\n ...processCreateParams(params),\n });\n};\nclass ZodDate extends ZodType {\n _parse(input) {\n if (this._def.coerce) {\n input.data = new Date(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.date) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.date,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n if (isNaN(input.data.getTime())) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_date,\n });\n return INVALID;\n }\n const status = new ParseStatus();\n let ctx = undefined;\n for (const check of this._def.checks) {\n if (check.kind === \"min\") {\n if (input.data.getTime() < check.value) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n message: check.message,\n inclusive: true,\n exact: false,\n minimum: check.value,\n type: \"date\",\n });\n status.dirty();\n }\n }\n else if (check.kind === \"max\") {\n if (input.data.getTime() > check.value) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n message: check.message,\n inclusive: true,\n exact: false,\n maximum: check.value,\n type: \"date\",\n });\n status.dirty();\n }\n }\n else {\n util.assertNever(check);\n }\n }\n return {\n status: status.value,\n value: new Date(input.data.getTime()),\n };\n }\n _addCheck(check) {\n return new ZodDate({\n ...this._def,\n checks: [...this._def.checks, check],\n });\n }\n min(minDate, message) {\n return this._addCheck({\n kind: \"min\",\n value: minDate.getTime(),\n message: errorUtil.toString(message),\n });\n }\n max(maxDate, message) {\n return this._addCheck({\n kind: \"max\",\n value: maxDate.getTime(),\n message: errorUtil.toString(message),\n });\n }\n get minDate() {\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"min\") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n }\n return min != null ? new Date(min) : null;\n }\n get maxDate() {\n let max = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"max\") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return max != null ? new Date(max) : null;\n }\n}\nZodDate.create = (params) => {\n return new ZodDate({\n checks: [],\n coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,\n typeName: ZodFirstPartyTypeKind.ZodDate,\n ...processCreateParams(params),\n });\n};\nclass ZodSymbol extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.symbol) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.symbol,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n return OK(input.data);\n }\n}\nZodSymbol.create = (params) => {\n return new ZodSymbol({\n typeName: ZodFirstPartyTypeKind.ZodSymbol,\n ...processCreateParams(params),\n });\n};\nclass ZodUndefined extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.undefined) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.undefined,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n return OK(input.data);\n }\n}\nZodUndefined.create = (params) => {\n return new ZodUndefined({\n typeName: ZodFirstPartyTypeKind.ZodUndefined,\n ...processCreateParams(params),\n });\n};\nclass ZodNull extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.null) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.null,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n return OK(input.data);\n }\n}\nZodNull.create = (params) => {\n return new ZodNull({\n typeName: ZodFirstPartyTypeKind.ZodNull,\n ...processCreateParams(params),\n });\n};\nclass ZodAny extends ZodType {\n constructor() {\n super(...arguments);\n // to prevent instances of other classes from extending ZodAny. this causes issues with catchall in ZodObject.\n this._any = true;\n }\n _parse(input) {\n return OK(input.data);\n }\n}\nZodAny.create = (params) => {\n return new ZodAny({\n typeName: ZodFirstPartyTypeKind.ZodAny,\n ...processCreateParams(params),\n });\n};\nclass ZodUnknown extends ZodType {\n constructor() {\n super(...arguments);\n // required\n this._unknown = true;\n }\n _parse(input) {\n return OK(input.data);\n }\n}\nZodUnknown.create = (params) => {\n return new ZodUnknown({\n typeName: ZodFirstPartyTypeKind.ZodUnknown,\n ...processCreateParams(params),\n });\n};\nclass ZodNever extends ZodType {\n _parse(input) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.never,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n}\nZodNever.create = (params) => {\n return new ZodNever({\n typeName: ZodFirstPartyTypeKind.ZodNever,\n ...processCreateParams(params),\n });\n};\nclass ZodVoid extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.undefined) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.void,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n return OK(input.data);\n }\n}\nZodVoid.create = (params) => {\n return new ZodVoid({\n typeName: ZodFirstPartyTypeKind.ZodVoid,\n ...processCreateParams(params),\n });\n};\nclass ZodArray extends ZodType {\n _parse(input) {\n const { ctx, status } = this._processInputParams(input);\n const def = this._def;\n if (ctx.parsedType !== ZodParsedType.array) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.array,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n if (def.exactLength !== null) {\n const tooBig = ctx.data.length > def.exactLength.value;\n const tooSmall = ctx.data.length < def.exactLength.value;\n if (tooBig || tooSmall) {\n addIssueToContext(ctx, {\n code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,\n minimum: (tooSmall ? def.exactLength.value : undefined),\n maximum: (tooBig ? def.exactLength.value : undefined),\n type: \"array\",\n inclusive: true,\n exact: true,\n message: def.exactLength.message,\n });\n status.dirty();\n }\n }\n if (def.minLength !== null) {\n if (ctx.data.length < def.minLength.value) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: def.minLength.value,\n type: \"array\",\n inclusive: true,\n exact: false,\n message: def.minLength.message,\n });\n status.dirty();\n }\n }\n if (def.maxLength !== null) {\n if (ctx.data.length > def.maxLength.value) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: def.maxLength.value,\n type: \"array\",\n inclusive: true,\n exact: false,\n message: def.maxLength.message,\n });\n status.dirty();\n }\n }\n if (ctx.common.async) {\n return Promise.all([...ctx.data].map((item, i) => {\n return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));\n })).then((result) => {\n return ParseStatus.mergeArray(status, result);\n });\n }\n const result = [...ctx.data].map((item, i) => {\n return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));\n });\n return ParseStatus.mergeArray(status, result);\n }\n get element() {\n return this._def.type;\n }\n min(minLength, message) {\n return new ZodArray({\n ...this._def,\n minLength: { value: minLength, message: errorUtil.toString(message) },\n });\n }\n max(maxLength, message) {\n return new ZodArray({\n ...this._def,\n maxLength: { value: maxLength, message: errorUtil.toString(message) },\n });\n }\n length(len, message) {\n return new ZodArray({\n ...this._def,\n exactLength: { value: len, message: errorUtil.toString(message) },\n });\n }\n nonempty(message) {\n return this.min(1, message);\n }\n}\nZodArray.create = (schema, params) => {\n return new ZodArray({\n type: schema,\n minLength: null,\n maxLength: null,\n exactLength: null,\n typeName: ZodFirstPartyTypeKind.ZodArray,\n ...processCreateParams(params),\n });\n};\nfunction deepPartialify(schema) {\n if (schema instanceof ZodObject) {\n const newShape = {};\n for (const key in schema.shape) {\n const fieldSchema = schema.shape[key];\n newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));\n }\n return new ZodObject({\n ...schema._def,\n shape: () => newShape,\n });\n }\n else if (schema instanceof ZodArray) {\n return new ZodArray({\n ...schema._def,\n type: deepPartialify(schema.element),\n });\n }\n else if (schema instanceof ZodOptional) {\n return ZodOptional.create(deepPartialify(schema.unwrap()));\n }\n else if (schema instanceof ZodNullable) {\n return ZodNullable.create(deepPartialify(schema.unwrap()));\n }\n else if (schema instanceof ZodTuple) {\n return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));\n }\n else {\n return schema;\n }\n}\nclass ZodObject extends ZodType {\n constructor() {\n super(...arguments);\n this._cached = null;\n /**\n * @deprecated In most cases, this is no longer needed - unknown properties are now silently stripped.\n * If you want to pass through unknown properties, use `.passthrough()` instead.\n */\n this.nonstrict = this.passthrough;\n // extend<\n // Augmentation extends ZodRawShape,\n // NewOutput extends util.flatten<{\n // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation\n // ? Augmentation[k][\"_output\"]\n // : k extends keyof Output\n // ? Output[k]\n // : never;\n // }>,\n // NewInput extends util.flatten<{\n // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation\n // ? Augmentation[k][\"_input\"]\n // : k extends keyof Input\n // ? Input[k]\n // : never;\n // }>\n // >(\n // augmentation: Augmentation\n // ): ZodObject<\n // extendShape<T, Augmentation>,\n // UnknownKeys,\n // Catchall,\n // NewOutput,\n // NewInput\n // > {\n // return new ZodObject({\n // ...this._def,\n // shape: () => ({\n // ...this._def.shape(),\n // ...augmentation,\n // }),\n // }) as any;\n // }\n /**\n * @deprecated Use `.extend` instead\n * */\n this.augment = this.extend;\n }\n _getCached() {\n if (this._cached !== null)\n return this._cached;\n const shape = this._def.shape();\n const keys = util.objectKeys(shape);\n return (this._cached = { shape, keys });\n }\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.object) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.object,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n const { status, ctx } = this._processInputParams(input);\n const { shape, keys: shapeKeys } = this._getCached();\n const extraKeys = [];\n if (!(this._def.catchall instanceof ZodNever &&\n this._def.unknownKeys === \"strip\")) {\n for (const key in ctx.data) {\n if (!shapeKeys.includes(key)) {\n extraKeys.push(key);\n }\n }\n }\n const pairs = [];\n for (const key of shapeKeys) {\n const keyValidator = shape[key];\n const value = ctx.data[key];\n pairs.push({\n key: { status: \"valid\", value: key },\n value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),\n alwaysSet: key in ctx.data,\n });\n }\n if (this._def.catchall instanceof ZodNever) {\n const unknownKeys = this._def.unknownKeys;\n if (unknownKeys === \"passthrough\") {\n for (const key of extraKeys) {\n pairs.push({\n key: { status: \"valid\", value: key },\n value: { status: \"valid\", value: ctx.data[key] },\n });\n }\n }\n else if (unknownKeys === \"strict\") {\n if (extraKeys.length > 0) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.unrecognized_keys,\n keys: extraKeys,\n });\n status.dirty();\n }\n }\n else if (unknownKeys === \"strip\") ;\n else {\n throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);\n }\n }\n else {\n // run catchall validation\n const catchall = this._def.catchall;\n for (const key of extraKeys) {\n const value = ctx.data[key];\n pairs.push({\n key: { status: \"valid\", value: key },\n value: catchall._parse(new ParseInputLazyPath(ctx, value, ctx.path, key) //, ctx.child(key), value, getParsedType(value)\n ),\n alwaysSet: key in ctx.data,\n });\n }\n }\n if (ctx.common.async) {\n return Promise.resolve()\n .then(async () => {\n const syncPairs = [];\n for (const pair of pairs) {\n const key = await pair.key;\n syncPairs.push({\n key,\n value: await pair.value,\n alwaysSet: pair.alwaysSet,\n });\n }\n return syncPairs;\n })\n .then((syncPairs) => {\n return ParseStatus.mergeObjectSync(status, syncPairs);\n });\n }\n else {\n return ParseStatus.mergeObjectSync(status, pairs);\n }\n }\n get shape() {\n return this._def.shape();\n }\n strict(message) {\n errorUtil.errToObj;\n return new ZodObject({\n ...this._def,\n unknownKeys: \"strict\",\n ...(message !== undefined\n ? {\n errorMap: (issue, ctx) => {\n var _a, _b, _c, _d;\n const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;\n if (issue.code === \"unrecognized_keys\")\n return {\n message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError,\n };\n return {\n message: defaultError,\n };\n },\n }\n : {}),\n });\n }\n strip() {\n return new ZodObject({\n ...this._def,\n unknownKeys: \"strip\",\n });\n }\n passthrough() {\n return new ZodObject({\n ...this._def,\n unknownKeys: \"passthrough\",\n });\n }\n // const AugmentFactory =\n // <Def extends ZodObjectDef>(def: Def) =>\n // <Augmentation extends ZodRawShape>(\n // augmentation: Augmentation\n // ): ZodObject<\n // extendShape<ReturnType<Def[\"shape\"]>, Augmentation>,\n // Def[\"unknownKeys\"],\n // Def[\"catchall\"]\n // > => {\n // return new ZodObject({\n // ...def,\n // shape: () => ({\n // ...def.shape(),\n // ...augmentation,\n // }),\n // }) as any;\n // };\n extend(augmentation) {\n return new ZodObject({\n ...this._def,\n shape: () => ({\n ...this._def.shape(),\n ...augmentation,\n }),\n });\n }\n /**\n * Prior to zod@1.0.12 there was a bug in the\n * inferred type of merged objects. Please\n * upgrade if you are experiencing issues.\n */\n merge(merging) {\n const merged = new ZodObject({\n unknownKeys: merging._def.unknownKeys,\n catchall: merging._def.catchall,\n shape: () => ({\n ...this._def.shape(),\n ...merging._def.shape(),\n }),\n typeName: ZodFirstPartyTypeKind.ZodObject,\n });\n return merged;\n }\n // merge<\n // Incoming extends AnyZodObject,\n // Augmentation extends Incoming[\"shape\"],\n // NewOutput extends {\n // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation\n // ? Augmentation[k][\"_output\"]\n // : k extends keyof Output\n // ? Output[k]\n // : never;\n // },\n // NewInput extends {\n // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation\n // ? Augmentation[k][\"_input\"]\n // : k extends keyof Input\n // ? Input[k]\n // : never;\n // }\n // >(\n // merging: Incoming\n // ): ZodObject<\n // extendShape<T, ReturnType<Incoming[\"_def\"][\"shape\"]>>,\n // Incoming[\"_def\"][\"unknownKeys\"],\n // Incoming[\"_def\"][\"catchall\"],\n // NewOutput,\n // NewInput\n // > {\n // const merged: any = new ZodObject({\n // unknownKeys: merging._def.unknownKeys,\n // catchall: merging._def.catchall,\n // shape: () =>\n // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),\n // typeName: ZodFirstPartyTypeKind.ZodObject,\n // }) as any;\n // return merged;\n // }\n setKey(key, schema) {\n return this.augment({ [key]: schema });\n }\n // merge<Incoming extends AnyZodObject>(\n // merging: Incoming\n // ): //ZodObject<T & Incoming[\"_shape\"], UnknownKeys, Catchall> = (merging) => {\n // ZodObject<\n // extendShape<T, ReturnType<Incoming[\"_def\"][\"shape\"]>>,\n // Incoming[\"_def\"][\"unknownKeys\"],\n // Incoming[\"_def\"][\"catchall\"]\n // > {\n // // const mergedShape = objectUtil.mergeShapes(\n // // this._def.shape(),\n // // merging._def.shape()\n // // );\n // const merged: any = new ZodObject({\n // unknownKeys: merging._def.unknownKeys,\n // catchall: merging._def.catchall,\n // shape: () =>\n // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),\n // typeName: ZodFirstPartyTypeKind.ZodObject,\n // }) as any;\n // return merged;\n // }\n catchall(index) {\n return new ZodObject({\n ...this._def,\n catchall: index,\n });\n }\n pick(mask) {\n const shape = {};\n util.objectKeys(mask).forEach((key) => {\n if (mask[key] && this.shape[key]) {\n shape[key] = this.shape[key];\n }\n });\n return new ZodObject({\n ...this._def,\n shape: () => shape,\n });\n }\n omit(mask) {\n const shape = {};\n util.objectKeys(this.shape).forEach((key) => {\n if (!mask[key]) {\n shape[key] = this.shape[key];\n }\n });\n return new ZodObject({\n ...this._def,\n shape: () => shape,\n });\n }\n /**\n * @deprecated\n */\n deepPartial() {\n return deepPartialify(this);\n }\n partial(mask) {\n const newShape = {};\n util.objectKeys(this.shape).forEach((key) => {\n const fieldSchema = this.shape[key];\n if (mask && !mask[key]) {\n newShape[key] = fieldSchema;\n }\n else {\n newShape[key] = fieldSchema.optional();\n }\n });\n return new ZodObject({\n ...this._def,\n shape: () => newShape,\n });\n }\n required(mask) {\n const newShape = {};\n util.objectKeys(this.shape).forEach((key) => {\n if (mask && !mask[key]) {\n newShape[key] = this.shape[key];\n }\n else {\n const fieldSchema = this.shape[key];\n let newField = fieldSchema;\n while (newField instanceof ZodOptional) {\n newField = newField._def.innerType;\n }\n newShape[key] = newField;\n }\n });\n return new ZodObject({\n ...this._def,\n shape: () => newShape,\n });\n }\n keyof() {\n return createZodEnum(util.objectKeys(this.shape));\n }\n}\nZodObject.create = (shape, params) => {\n return new ZodObject({\n shape: () => shape,\n unknownKeys: \"strip\",\n catchall: ZodNever.create(),\n typeName: ZodFirstPartyTypeKind.ZodObject,\n ...processCreateParams(params),\n });\n};\nZodObject.strictCreate = (shape, params) => {\n return new ZodObject({\n shape: () => shape,\n unknownKeys: \"strict\",\n catchall: ZodNever.create(),\n typeName: ZodFirstPartyTypeKind.ZodObject,\n ...processCreateParams(params),\n });\n};\nZodObject.lazycreate = (shape, params) => {\n return new ZodObject({\n shape,\n unknownKeys: \"strip\",\n catchall: ZodNever.create(),\n typeName: ZodFirstPartyTypeKind.ZodObject,\n ...processCreateParams(params),\n });\n};\nclass ZodUnion extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n const options = this._def.options;\n function handleResults(results) {\n // return first issue-free validation if it exists\n for (const result of results) {\n if (result.result.status === \"valid\") {\n return result.result;\n }\n }\n for (const result of results) {\n if (result.result.status === \"dirty\") {\n // add issues from dirty option\n ctx.common.issues.push(...result.ctx.common.issues);\n return result.result;\n }\n }\n // return invalid\n const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_union,\n unionErrors,\n });\n return INVALID;\n }\n if (ctx.common.async) {\n return Promise.all(options.map(async (option) => {\n const childCtx = {\n ...ctx,\n common: {\n ...ctx.common,\n issues: [],\n },\n parent: null,\n };\n return {\n result: await option._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: childCtx,\n }),\n ctx: childCtx,\n };\n })).then(handleResults);\n }\n else {\n let dirty = undefined;\n const issues = [];\n for (const option of options) {\n const childCtx = {\n ...ctx,\n common: {\n ...ctx.common,\n issues: [],\n },\n parent: null,\n };\n const result = option._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: childCtx,\n });\n if (result.status === \"valid\") {\n return result;\n }\n else if (result.status === \"dirty\" && !dirty) {\n dirty = { result, ctx: childCtx };\n }\n if (childCtx.common.issues.length) {\n issues.push(childCtx.common.issues);\n }\n }\n if (dirty) {\n ctx.common.issues.push(...dirty.ctx.common.issues);\n return dirty.result;\n }\n const unionErrors = issues.map((issues) => new ZodError(issues));\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_union,\n unionErrors,\n });\n return INVALID;\n }\n }\n get options() {\n return this._def.options;\n }\n}\nZodUnion.create = (types, params) => {\n return new ZodUnion({\n options: types,\n typeName: ZodFirstPartyTypeKind.ZodUnion,\n ...processCreateParams(params),\n });\n};\n/////////////////////////////////////////////////////\n/////////////////////////////////////////////////////\n////////// //////////\n////////// ZodDiscriminatedUnion //////////\n////////// //////////\n/////////////////////////////////////////////////////\n/////////////////////////////////////////////////////\nconst getDiscriminator = (type) => {\n if (type instanceof ZodLazy) {\n return getDiscriminator(type.schema);\n }\n else if (type instanceof ZodEffects) {\n return getDiscriminator(type.innerType());\n }\n else if (type instanceof ZodLiteral) {\n return [type.value];\n }\n else if (type instanceof ZodEnum) {\n return type.options;\n }\n else if (type instanceof ZodNativeEnum) {\n // eslint-disable-next-line ban/ban\n return Object.keys(type.enum);\n }\n else if (type instanceof ZodDefault) {\n return getDiscriminator(type._def.innerType);\n }\n else if (type instanceof ZodUndefined) {\n return [undefined];\n }\n else if (type instanceof ZodNull) {\n return [null];\n }\n else {\n return null;\n }\n};\nclass ZodDiscriminatedUnion extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.object) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.object,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n const discriminator = this.discriminator;\n const discriminatorValue = ctx.data[discriminator];\n const option = this.optionsMap.get(discriminatorValue);\n if (!option) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_union_discriminator,\n options: Array.from(this.optionsMap.keys()),\n path: [discriminator],\n });\n return INVALID;\n }\n if (ctx.common.async) {\n return option._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n });\n }\n else {\n return option._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n });\n }\n }\n get discriminator() {\n return this._def.discriminator;\n }\n get options() {\n return this._def.options;\n }\n get optionsMap() {\n return this._def.optionsMap;\n }\n /**\n * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.\n * However, it only allows a union of objects, all of which need to share a discriminator property. This property must\n * have a different value for each object in the union.\n * @param discriminator the name of the discriminator property\n * @param types an array of object schemas\n * @param params\n */\n static create(discriminator, options, params) {\n // Get all the valid discriminator values\n const optionsMap = new Map();\n // try {\n for (const type of options) {\n const discriminatorValues = getDiscriminator(type.shape[discriminator]);\n if (!discriminatorValues) {\n throw new Error(`A discriminator value for key \\`${discriminator}\\` could not be extracted from all schema options`);\n }\n for (const value of discriminatorValues) {\n if (optionsMap.has(value)) {\n throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);\n }\n optionsMap.set(value, type);\n }\n }\n return new ZodDiscriminatedUnion({\n typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,\n discriminator,\n options,\n optionsMap,\n ...processCreateParams(params),\n });\n }\n}\nfunction mergeValues(a, b) {\n const aType = getParsedType(a);\n const bType = getParsedType(b);\n if (a === b) {\n return { valid: true, data: a };\n }\n else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {\n const bKeys = util.objectKeys(b);\n const sharedKeys = util\n .objectKeys(a)\n .filter((key) => bKeys.indexOf(key) !== -1);\n const newObj = { ...a, ...b };\n for (const key of sharedKeys) {\n const sharedValue = mergeValues(a[key], b[key]);\n if (!sharedValue.valid) {\n return { valid: false };\n }\n newObj[key] = sharedValue.data;\n }\n return { valid: true, data: newObj };\n }\n else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {\n if (a.length !== b.length) {\n return { valid: false };\n }\n const newArray = [];\n for (let index = 0; index < a.length; index++) {\n const itemA = a[index];\n const itemB = b[index];\n const sharedValue = mergeValues(itemA, itemB);\n if (!sharedValue.valid) {\n return { valid: false };\n }\n newArray.push(sharedValue.data);\n }\n return { valid: true, data: newArray };\n }\n else if (aType === ZodParsedType.date &&\n bType === ZodParsedType.date &&\n +a === +b) {\n return { valid: true, data: a };\n }\n else {\n return { valid: false };\n }\n}\nclass ZodIntersection extends ZodType {\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n const handleParsed = (parsedLeft, parsedRight) => {\n if (isAborted(parsedLeft) || isAborted(parsedRight)) {\n return INVALID;\n }\n const merged = mergeValues(parsedLeft.value, parsedRight.value);\n if (!merged.valid) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_intersection_types,\n });\n return INVALID;\n }\n if (isDirty(parsedLeft) || isDirty(parsedRight)) {\n status.dirty();\n }\n return { status: status.value, value: merged.data };\n };\n if (ctx.common.async) {\n return Promise.all([\n this._def.left._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n }),\n this._def.right._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n }),\n ]).then(([left, right]) => handleParsed(left, right));\n }\n else {\n return handleParsed(this._def.left._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n }), this._def.right._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n }));\n }\n }\n}\nZodIntersection.create = (left, right, params) => {\n return new ZodIntersection({\n left: left,\n right: right,\n typeName: ZodFirstPartyTypeKind.ZodIntersection,\n ...processCreateParams(params),\n });\n};\nclass ZodTuple extends ZodType {\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.array) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.array,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n if (ctx.data.length < this._def.items.length) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: this._def.items.length,\n inclusive: true,\n exact: false,\n type: \"array\",\n });\n return INVALID;\n }\n const rest = this._def.rest;\n if (!rest && ctx.data.length > this._def.items.length) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: this._def.items.length,\n inclusive: true,\n exact: false,\n type: \"array\",\n });\n status.dirty();\n }\n const items = [...ctx.data]\n .map((item, itemIndex) => {\n const schema = this._def.items[itemIndex] || this._def.rest;\n if (!schema)\n return null;\n return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));\n })\n .filter((x) => !!x); // filter nulls\n if (ctx.common.async) {\n return Promise.all(items).then((results) => {\n return ParseStatus.mergeArray(status, results);\n });\n }\n else {\n return ParseStatus.mergeArray(status, items);\n }\n }\n get items() {\n return this._def.items;\n }\n rest(rest) {\n return new ZodTuple({\n ...this._def,\n rest,\n });\n }\n}\nZodTuple.create = (schemas, params) => {\n if (!Array.isArray(schemas)) {\n throw new Error(\"You must pass an array of schemas to z.tuple([ ... ])\");\n }\n return new ZodTuple({\n items: schemas,\n typeName: ZodFirstPartyTypeKind.ZodTuple,\n rest: null,\n ...processCreateParams(params),\n });\n};\nclass ZodRecord extends ZodType {\n get keySchema() {\n return this._def.keyType;\n }\n get valueSchema() {\n return this._def.valueType;\n }\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.object) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.object,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n const pairs = [];\n const keyType = this._def.keyType;\n const valueType = this._def.valueType;\n for (const key in ctx.data) {\n pairs.push({\n key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),\n value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),\n });\n }\n if (ctx.common.async) {\n return ParseStatus.mergeObjectAsync(status, pairs);\n }\n else {\n return ParseStatus.mergeObjectSync(status, pairs);\n }\n }\n get element() {\n return this._def.valueType;\n }\n static create(first, second, third) {\n if (second instanceof ZodType) {\n return new ZodRecord({\n keyType: first,\n valueType: second,\n typeName: ZodFirstPartyTypeKind.ZodRecord,\n ...processCreateParams(third),\n });\n }\n return new ZodRecord({\n keyType: ZodString.create(),\n valueType: first,\n typeName: ZodFirstPartyTypeKind.ZodRecord,\n ...processCreateParams(second),\n });\n }\n}\nclass ZodMap extends ZodType {\n get keySchema() {\n return this._def.keyType;\n }\n get valueSchema() {\n return this._def.valueType;\n }\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.map) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.map,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n const keyType = this._def.keyType;\n const valueType = this._def.valueType;\n const pairs = [...ctx.data.entries()].map(([key, value], index) => {\n return {\n key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, \"key\"])),\n value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, \"value\"])),\n };\n });\n if (ctx.common.async) {\n const finalMap = new Map();\n return Promise.resolve().then(async () => {\n for (const pair of pairs) {\n const key = await pair.key;\n const value = await pair.value;\n if (key.status === \"aborted\" || value.status === \"aborted\") {\n return INVALID;\n }\n if (key.status === \"dirty\" || value.status === \"dirty\") {\n status.dirty();\n }\n finalMap.set(key.value, value.value);\n }\n return { status: status.value, value: finalMap };\n });\n }\n else {\n const finalMap = new Map();\n for (const pair of pairs) {\n const key = pair.key;\n const value = pair.value;\n if (key.status === \"aborted\" || value.status === \"aborted\") {\n return INVALID;\n }\n if (key.status === \"dirty\" || value.status === \"dirty\") {\n status.dirty();\n }\n finalMap.set(key.value, value.value);\n }\n return { status: status.value, value: finalMap };\n }\n }\n}\nZodMap.create = (keyType, valueType, params) => {\n return new ZodMap({\n valueType,\n keyType,\n typeName: ZodFirstPartyTypeKind.ZodMap,\n ...processCreateParams(params),\n });\n};\nclass ZodSet extends ZodType {\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.set) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.set,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n const def = this._def;\n if (def.minSize !== null) {\n if (ctx.data.size < def.minSize.value) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: def.minSize.value,\n type: \"set\",\n inclusive: true,\n exact: false,\n message: def.minSize.message,\n });\n status.dirty();\n }\n }\n if (def.maxSize !== null) {\n if (ctx.data.size > def.maxSize.value) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: def.maxSize.value,\n type: \"set\",\n inclusive: true,\n exact: false,\n message: def.maxSize.message,\n });\n status.dirty();\n }\n }\n const valueType = this._def.valueType;\n function finalizeSet(elements) {\n const parsedSet = new Set();\n for (const element of elements) {\n if (element.status === \"aborted\")\n return INVALID;\n if (element.status === \"dirty\")\n status.dirty();\n parsedSet.add(element.value);\n }\n return { status: status.value, value: parsedSet };\n }\n const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));\n if (ctx.common.async) {\n return Promise.all(elements).then((elements) => finalizeSet(elements));\n }\n else {\n return finalizeSet(elements);\n }\n }\n min(minSize, message) {\n return new ZodSet({\n ...this._def,\n minSize: { value: minSize, message: errorUtil.toString(message) },\n });\n }\n max(maxSize, message) {\n return new ZodSet({\n ...this._def,\n maxSize: { value: maxSize, message: errorUtil.toString(message) },\n });\n }\n size(size, message) {\n return this.min(size, message).max(size, message);\n }\n nonempty(message) {\n return this.min(1, message);\n }\n}\nZodSet.create = (valueType, params) => {\n return new ZodSet({\n valueType,\n minSize: null,\n maxSize: null,\n typeName: ZodFirstPartyTypeKind.ZodSet,\n ...processCreateParams(params),\n });\n};\nclass ZodFunction extends ZodType {\n constructor() {\n super(...arguments);\n this.validate = this.implement;\n }\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.function) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.function,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n function makeArgsIssue(args, error) {\n return makeIssue({\n data: args,\n path: ctx.path,\n errorMaps: [\n ctx.common.contextualErrorMap,\n ctx.schemaErrorMap,\n getErrorMap(),\n errorMap,\n ].filter((x) => !!x),\n issueData: {\n code: ZodIssueCode.invalid_arguments,\n argumentsError: error,\n },\n });\n }\n function makeReturnsIssue(returns, error) {\n return makeIssue({\n data: returns,\n path: ctx.path,\n errorMaps: [\n ctx.common.contextualErrorMap,\n ctx.schemaErrorMap,\n getErrorMap(),\n errorMap,\n ].filter((x) => !!x),\n issueData: {\n code: ZodIssueCode.invalid_return_type,\n returnTypeError: error,\n },\n });\n }\n const params = { errorMap: ctx.common.contextualErrorMap };\n const fn = ctx.data;\n if (this._def.returns instanceof ZodPromise) {\n // Would love a way to avoid disabling this rule, but we need\n // an alias (using an arrow function was what caused 2651).\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const me = this;\n return OK(async function (...args) {\n const error = new ZodError([]);\n const parsedArgs = await me._def.args\n .parseAsync(args, params)\n .catch((e) => {\n error.addIssue(makeArgsIssue(args, e));\n throw error;\n });\n const result = await Reflect.apply(fn, this, parsedArgs);\n const parsedReturns = await me._def.returns._def.type\n .parseAsync(result, params)\n .catch((e) => {\n error.addIssue(makeReturnsIssue(result, e));\n throw error;\n });\n return parsedReturns;\n });\n }\n else {\n // Would love a way to avoid disabling this rule, but we need\n // an alias (using an arrow function was what caused 2651).\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const me = this;\n return OK(function (...args) {\n const parsedArgs = me._def.args.safeParse(args, params);\n if (!parsedArgs.success) {\n throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);\n }\n const result = Reflect.apply(fn, this, parsedArgs.data);\n const parsedReturns = me._def.returns.safeParse(result, params);\n if (!parsedReturns.success) {\n throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);\n }\n return parsedReturns.data;\n });\n }\n }\n parameters() {\n return this._def.args;\n }\n returnType() {\n return this._def.returns;\n }\n args(...items) {\n return new ZodFunction({\n ...this._def,\n args: ZodTuple.create(items).rest(ZodUnknown.create()),\n });\n }\n returns(returnType) {\n return new ZodFunction({\n ...this._def,\n returns: returnType,\n });\n }\n implement(func) {\n const validatedFunc = this.parse(func);\n return validatedFunc;\n }\n strictImplement(func) {\n const validatedFunc = this.parse(func);\n return validatedFunc;\n }\n static create(args, returns, params) {\n return new ZodFunction({\n args: (args\n ? args\n : ZodTuple.create([]).rest(ZodUnknown.create())),\n returns: returns || ZodUnknown.create(),\n typeName: ZodFirstPartyTypeKind.ZodFunction,\n ...processCreateParams(params),\n });\n }\n}\nclass ZodLazy extends ZodType {\n get schema() {\n return this._def.getter();\n }\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n const lazySchema = this._def.getter();\n return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });\n }\n}\nZodLazy.create = (getter, params) => {\n return new ZodLazy({\n getter: getter,\n typeName: ZodFirstPartyTypeKind.ZodLazy,\n ...processCreateParams(params),\n });\n};\nclass ZodLiteral extends ZodType {\n _parse(input) {\n if (input.data !== this._def.value) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n received: ctx.data,\n code: ZodIssueCode.invalid_literal,\n expected: this._def.value,\n });\n return INVALID;\n }\n return { status: \"valid\", value: input.data };\n }\n get value() {\n return this._def.value;\n }\n}\nZodLiteral.create = (value, params) => {\n return new ZodLiteral({\n value: value,\n typeName: ZodFirstPartyTypeKind.ZodLiteral,\n ...processCreateParams(params),\n });\n};\nfunction createZodEnum(values, params) {\n return new ZodEnum({\n values,\n typeName: ZodFirstPartyTypeKind.ZodEnum,\n ...processCreateParams(params),\n });\n}\nclass ZodEnum extends ZodType {\n _parse(input) {\n if (typeof input.data !== \"string\") {\n const ctx = this._getOrReturnCtx(input);\n const expectedValues = this._def.values;\n addIssueToContext(ctx, {\n expected: util.joinValues(expectedValues),\n received: ctx.parsedType,\n code: ZodIssueCode.invalid_type,\n });\n return INVALID;\n }\n if (this._def.values.indexOf(input.data) === -1) {\n const ctx = this._getOrReturnCtx(input);\n const expectedValues = this._def.values;\n addIssueToContext(ctx, {\n received: ctx.data,\n code: ZodIssueCode.invalid_enum_value,\n options: expectedValues,\n });\n return INVALID;\n }\n return OK(input.data);\n }\n get options() {\n return this._def.values;\n }\n get enum() {\n const enumValues = {};\n for (const val of this._def.values) {\n enumValues[val] = val;\n }\n return enumValues;\n }\n get Values() {\n const enumValues = {};\n for (const val of this._def.values) {\n enumValues[val] = val;\n }\n return enumValues;\n }\n get Enum() {\n const enumValues = {};\n for (const val of this._def.values) {\n enumValues[val] = val;\n }\n return enumValues;\n }\n extract(values) {\n return ZodEnum.create(values);\n }\n exclude(values) {\n return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));\n }\n}\nZodEnum.create = createZodEnum;\nclass ZodNativeEnum extends ZodType {\n _parse(input) {\n const nativeEnumValues = util.getValidEnumValues(this._def.values);\n const ctx = this._getOrReturnCtx(input);\n if (ctx.parsedType !== ZodParsedType.string &&\n ctx.parsedType !== ZodParsedType.number) {\n const expectedValues = util.objectValues(nativeEnumValues);\n addIssueToContext(ctx, {\n expected: util.joinValues(expectedValues),\n received: ctx.parsedType,\n code: ZodIssueCode.invalid_type,\n });\n return INVALID;\n }\n if (nativeEnumValues.indexOf(input.data) === -1) {\n const expectedValues = util.objectValues(nativeEnumValues);\n addIssueToContext(ctx, {\n received: ctx.data,\n code: ZodIssueCode.invalid_enum_value,\n options: expectedValues,\n });\n return INVALID;\n }\n return OK(input.data);\n }\n get enum() {\n return this._def.values;\n }\n}\nZodNativeEnum.create = (values, params) => {\n return new ZodNativeEnum({\n values: values,\n typeName: ZodFirstPartyTypeKind.ZodNativeEnum,\n ...processCreateParams(params),\n });\n};\nclass ZodPromise extends ZodType {\n unwrap() {\n return this._def.type;\n }\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.promise &&\n ctx.common.async === false) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.promise,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n const promisified = ctx.parsedType === ZodParsedType.promise\n ? ctx.data\n : Promise.resolve(ctx.data);\n return OK(promisified.then((data) => {\n return this._def.type.parseAsync(data, {\n path: ctx.path,\n errorMap: ctx.common.contextualErrorMap,\n });\n }));\n }\n}\nZodPromise.create = (schema, params) => {\n return new ZodPromise({\n type: schema,\n typeName: ZodFirstPartyTypeKind.ZodPromise,\n ...processCreateParams(params),\n });\n};\nclass ZodEffects extends ZodType {\n innerType() {\n return this._def.schema;\n }\n sourceType() {\n return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects\n ? this._def.schema.sourceType()\n : this._def.schema;\n }\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n const effect = this._def.effect || null;\n const checkCtx = {\n addIssue: (arg) => {\n addIssueToContext(ctx, arg);\n if (arg.fatal) {\n status.abort();\n }\n else {\n status.dirty();\n }\n },\n get path() {\n return ctx.path;\n },\n };\n checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);\n if (effect.type === \"preprocess\") {\n const processed = effect.transform(ctx.data, checkCtx);\n if (ctx.common.issues.length) {\n return {\n status: \"dirty\",\n value: ctx.data,\n };\n }\n if (ctx.common.async) {\n return Promise.resolve(processed).then((processed) => {\n return this._def.schema._parseAsync({\n data: processed,\n path: ctx.path,\n parent: ctx,\n });\n });\n }\n else {\n return this._def.schema._parseSync({\n data: processed,\n path: ctx.path,\n parent: ctx,\n });\n }\n }\n if (effect.type === \"refinement\") {\n const executeRefinement = (acc\n // effect: RefinementEffect<any>\n ) => {\n const result = effect.refinement(acc, checkCtx);\n if (ctx.common.async) {\n return Promise.resolve(result);\n }\n if (result instanceof Promise) {\n throw new Error(\"Async refinement encountered during synchronous parse operation. Use .parseAsync instead.\");\n }\n return acc;\n };\n if (ctx.common.async === false) {\n const inner = this._def.schema._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n });\n if (inner.status === \"aborted\")\n return INVALID;\n if (inner.status === \"dirty\")\n status.dirty();\n // return value is ignored\n executeRefinement(inner.value);\n return { status: status.value, value: inner.value };\n }\n else {\n return this._def.schema\n ._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx })\n .then((inner) => {\n if (inner.status === \"aborted\")\n return INVALID;\n if (inner.status === \"dirty\")\n status.dirty();\n return executeRefinement(inner.value).then(() => {\n return { status: status.value, value: inner.value };\n });\n });\n }\n }\n if (effect.type === \"transform\") {\n if (ctx.common.async === false) {\n const base = this._def.schema._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n });\n if (!isValid(base))\n return base;\n const result = effect.transform(base.value, checkCtx);\n if (result instanceof Promise) {\n throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);\n }\n return { status: status.value, value: result };\n }\n else {\n return this._def.schema\n ._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx })\n .then((base) => {\n if (!isValid(base))\n return base;\n return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));\n });\n }\n }\n util.assertNever(effect);\n }\n}\nZodEffects.create = (schema, effect, params) => {\n return new ZodEffects({\n schema,\n typeName: ZodFirstPartyTypeKind.ZodEffects,\n effect,\n ...processCreateParams(params),\n });\n};\nZodEffects.createWithPreprocess = (preprocess, schema, params) => {\n return new ZodEffects({\n schema,\n effect: { type: \"preprocess\", transform: preprocess },\n typeName: ZodFirstPartyTypeKind.ZodEffects,\n ...processCreateParams(params),\n });\n};\nclass ZodOptional extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType === ZodParsedType.undefined) {\n return OK(undefined);\n }\n return this._def.innerType._parse(input);\n }\n unwrap() {\n return this._def.innerType;\n }\n}\nZodOptional.create = (type, params) => {\n return new ZodOptional({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodOptional,\n ...processCreateParams(params),\n });\n};\nclass ZodNullable extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType === ZodParsedType.null) {\n return OK(null);\n }\n return this._def.innerType._parse(input);\n }\n unwrap() {\n return this._def.innerType;\n }\n}\nZodNullable.create = (type, params) => {\n return new ZodNullable({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodNullable,\n ...processCreateParams(params),\n });\n};\nclass ZodDefault extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n let data = ctx.data;\n if (ctx.parsedType === ZodParsedType.undefined) {\n data = this._def.defaultValue();\n }\n return this._def.innerType._parse({\n data,\n path: ctx.path,\n parent: ctx,\n });\n }\n removeDefault() {\n return this._def.innerType;\n }\n}\nZodDefault.create = (type, params) => {\n return new ZodDefault({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodDefault,\n defaultValue: typeof params.default === \"function\"\n ? params.default\n : () => params.default,\n ...processCreateParams(params),\n });\n};\nclass ZodCatch extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n // newCtx is used to not collect issues from inner types in ctx\n const newCtx = {\n ...ctx,\n common: {\n ...ctx.common,\n issues: [],\n },\n };\n const result = this._def.innerType._parse({\n data: newCtx.data,\n path: newCtx.path,\n parent: {\n ...newCtx,\n },\n });\n if (isAsync(result)) {\n return result.then((result) => {\n return {\n status: \"valid\",\n value: result.status === \"valid\"\n ? result.value\n : this._def.catchValue({\n get error() {\n return new ZodError(newCtx.common.issues);\n },\n input: newCtx.data,\n }),\n };\n });\n }\n else {\n return {\n status: \"valid\",\n value: result.status === \"valid\"\n ? result.value\n : this._def.catchValue({\n get error() {\n return new ZodError(newCtx.common.issues);\n },\n input: newCtx.data,\n }),\n };\n }\n }\n removeCatch() {\n return this._def.innerType;\n }\n}\nZodCatch.create = (type, params) => {\n return new ZodCatch({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodCatch,\n catchValue: typeof params.catch === \"function\" ? params.catch : () => params.catch,\n ...processCreateParams(params),\n });\n};\nclass ZodNaN extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.nan) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.nan,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n return { status: \"valid\", value: input.data };\n }\n}\nZodNaN.create = (params) => {\n return new ZodNaN({\n typeName: ZodFirstPartyTypeKind.ZodNaN,\n ...processCreateParams(params),\n });\n};\nconst BRAND = Symbol(\"zod_brand\");\nclass ZodBranded extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n const data = ctx.data;\n return this._def.type._parse({\n data,\n path: ctx.path,\n parent: ctx,\n });\n }\n unwrap() {\n return this._def.type;\n }\n}\nclass ZodPipeline extends ZodType {\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.common.async) {\n const handleAsync = async () => {\n const inResult = await this._def.in._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n });\n if (inResult.status === \"aborted\")\n return INVALID;\n if (inResult.status === \"dirty\") {\n status.dirty();\n return DIRTY(inResult.value);\n }\n else {\n return this._def.out._parseAsync({\n data: inResult.value,\n path: ctx.path,\n parent: ctx,\n });\n }\n };\n return handleAsync();\n }\n else {\n const inResult = this._def.in._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n });\n if (inResult.status === \"aborted\")\n return INVALID;\n if (inResult.status === \"dirty\") {\n status.dirty();\n return {\n status: \"dirty\",\n value: inResult.value,\n };\n }\n else {\n return this._def.out._parseSync({\n data: inResult.value,\n path: ctx.path,\n parent: ctx,\n });\n }\n }\n }\n static create(a, b) {\n return new ZodPipeline({\n in: a,\n out: b,\n typeName: ZodFirstPartyTypeKind.ZodPipeline,\n });\n }\n}\nclass ZodReadonly extends ZodType {\n _parse(input) {\n const result = this._def.innerType._parse(input);\n if (isValid(result)) {\n result.value = Object.freeze(result.value);\n }\n return result;\n }\n}\nZodReadonly.create = (type, params) => {\n return new ZodReadonly({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodReadonly,\n ...processCreateParams(params),\n });\n};\nconst custom = (check, params = {}, \n/**\n * @deprecated\n *\n * Pass `fatal` into the params object instead:\n *\n * ```ts\n * z.string().custom((val) => val.length > 5, { fatal: false })\n * ```\n *\n */\nfatal) => {\n if (check)\n return ZodAny.create().superRefine((data, ctx) => {\n var _a, _b;\n if (!check(data)) {\n const p = typeof params === \"function\"\n ? params(data)\n : typeof params === \"string\"\n ? { message: params }\n : params;\n const _fatal = (_b = (_a = p.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;\n const p2 = typeof p === \"string\" ? { message: p } : p;\n ctx.addIssue({ code: \"custom\", ...p2, fatal: _fatal });\n }\n });\n return ZodAny.create();\n};\nconst late = {\n object: ZodObject.lazycreate,\n};\nvar ZodFirstPartyTypeKind;\n(function (ZodFirstPartyTypeKind) {\n ZodFirstPartyTypeKind[\"ZodString\"] = \"ZodString\";\n ZodFirstPartyTypeKind[\"ZodNumber\"] = \"ZodNumber\";\n ZodFirstPartyTypeKind[\"ZodNaN\"] = \"ZodNaN\";\n ZodFirstPartyTypeKind[\"ZodBigInt\"] = \"ZodBigInt\";\n ZodFirstPartyTypeKind[\"ZodBoolean\"] = \"ZodBoolean\";\n ZodFirstPartyTypeKind[\"ZodDate\"] = \"ZodDate\";\n ZodFirstPartyTypeKind[\"ZodSymbol\"] = \"ZodSymbol\";\n ZodFirstPartyTypeKind[\"ZodUndefined\"] = \"ZodUndefined\";\n ZodFirstPartyTypeKind[\"ZodNull\"] = \"ZodNull\";\n ZodFirstPartyTypeKind[\"ZodAny\"] = \"ZodAny\";\n ZodFirstPartyTypeKind[\"ZodUnknown\"] = \"ZodUnknown\";\n ZodFirstPartyTypeKind[\"ZodNever\"] = \"ZodNever\";\n ZodFirstPartyTypeKind[\"ZodVoid\"] = \"ZodVoid\";\n ZodFirstPartyTypeKind[\"ZodArray\"] = \"ZodArray\";\n ZodFirstPartyTypeKind[\"ZodObject\"] = \"ZodObject\";\n ZodFirstPartyTypeKind[\"ZodUnion\"] = \"ZodUnion\";\n ZodFirstPartyTypeKind[\"ZodDiscriminatedUnion\"] = \"ZodDiscriminatedUnion\";\n ZodFirstPartyTypeKind[\"ZodIntersection\"] = \"ZodIntersection\";\n ZodFirstPartyTypeKind[\"ZodTuple\"] = \"ZodTuple\";\n ZodFirstPartyTypeKind[\"ZodRecord\"] = \"ZodRecord\";\n ZodFirstPartyTypeKind[\"ZodMap\"] = \"ZodMap\";\n ZodFirstPartyTypeKind[\"ZodSet\"] = \"ZodSet\";\n ZodFirstPartyTypeKind[\"ZodFunction\"] = \"ZodFunction\";\n ZodFirstPartyTypeKind[\"ZodLazy\"] = \"ZodLazy\";\n ZodFirstPartyTypeKind[\"ZodLiteral\"] = \"ZodLiteral\";\n ZodFirstPartyTypeKind[\"ZodEnum\"] = \"ZodEnum\";\n ZodFirstPartyTypeKind[\"ZodEffects\"] = \"ZodEffects\";\n ZodFirstPartyTypeKind[\"ZodNativeEnum\"] = \"ZodNativeEnum\";\n ZodFirstPartyTypeKind[\"ZodOptional\"] = \"ZodOptional\";\n ZodFirstPartyTypeKind[\"ZodNullable\"] = \"ZodNullable\";\n ZodFirstPartyTypeKind[\"ZodDefault\"] = \"ZodDefault\";\n ZodFirstPartyTypeKind[\"ZodCatch\"] = \"ZodCatch\";\n ZodFirstPartyTypeKind[\"ZodPromise\"] = \"ZodPromise\";\n ZodFirstPartyTypeKind[\"ZodBranded\"] = \"ZodBranded\";\n ZodFirstPartyTypeKind[\"ZodPipeline\"] = \"ZodPipeline\";\n ZodFirstPartyTypeKind[\"ZodReadonly\"] = \"ZodReadonly\";\n})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));\nconst instanceOfType = (\n// const instanceOfType = <T extends new (...args: any[]) => any>(\ncls, params = {\n message: `Input not instance of ${cls.name}`,\n}) => custom((data) => data instanceof cls, params);\nconst stringType = ZodString.create;\nconst numberType = ZodNumber.create;\nconst nanType = ZodNaN.create;\nconst bigIntType = ZodBigInt.create;\nconst booleanType = ZodBoolean.create;\nconst dateType = ZodDate.create;\nconst symbolType = ZodSymbol.create;\nconst undefinedType = ZodUndefined.create;\nconst nullType = ZodNull.create;\nconst anyType = ZodAny.create;\nconst unknownType = ZodUnknown.create;\nconst neverType = ZodNever.create;\nconst voidType = ZodVoid.create;\nconst arrayType = ZodArray.create;\nconst objectType = ZodObject.create;\nconst strictObjectType = ZodObject.strictCreate;\nconst unionType = ZodUnion.create;\nconst discriminatedUnionType = ZodDiscriminatedUnion.create;\nconst intersectionType = ZodIntersection.create;\nconst tupleType = ZodTuple.create;\nconst recordType = ZodRecord.create;\nconst mapType = ZodMap.create;\nconst setType = ZodSet.create;\nconst functionType = ZodFunction.create;\nconst lazyType = ZodLazy.create;\nconst literalType = ZodLiteral.create;\nconst enumType = ZodEnum.create;\nconst nativeEnumType = ZodNativeEnum.create;\nconst promiseType = ZodPromise.create;\nconst effectsType = ZodEffects.create;\nconst optionalType = ZodOptional.create;\nconst nullableType = ZodNullable.create;\nconst preprocessType = ZodEffects.createWithPreprocess;\nconst pipelineType = ZodPipeline.create;\nconst ostring = () => stringType().optional();\nconst onumber = () => numberType().optional();\nconst oboolean = () => booleanType().optional();\nconst coerce = {\n string: ((arg) => ZodString.create({ ...arg, coerce: true })),\n number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),\n boolean: ((arg) => ZodBoolean.create({\n ...arg,\n coerce: true,\n })),\n bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),\n date: ((arg) => ZodDate.create({ ...arg, coerce: true })),\n};\nconst NEVER = INVALID;\n\nvar z = /*#__PURE__*/Object.freeze({\n __proto__: null,\n defaultErrorMap: errorMap,\n setErrorMap: setErrorMap,\n getErrorMap: getErrorMap,\n makeIssue: makeIssue,\n EMPTY_PATH: EMPTY_PATH,\n addIssueToContext: addIssueToContext,\n ParseStatus: ParseStatus,\n INVALID: INVALID,\n DIRTY: DIRTY,\n OK: OK,\n isAborted: isAborted,\n isDirty: isDirty,\n isValid: isValid,\n isAsync: isAsync,\n get util () { return util; },\n get objectUtil () { return objectUtil; },\n ZodParsedType: ZodParsedType,\n getParsedType: getParsedType,\n ZodType: ZodType,\n ZodString: ZodString,\n ZodNumber: ZodNumber,\n ZodBigInt: ZodBigInt,\n ZodBoolean: ZodBoolean,\n ZodDate: ZodDate,\n ZodSymbol: ZodSymbol,\n ZodUndefined: ZodUndefined,\n ZodNull: ZodNull,\n ZodAny: ZodAny,\n ZodUnknown: ZodUnknown,\n ZodNever: ZodNever,\n ZodVoid: ZodVoid,\n ZodArray: ZodArray,\n ZodObject: ZodObject,\n ZodUnion: ZodUnion,\n ZodDiscriminatedUnion: ZodDiscriminatedUnion,\n ZodIntersection: ZodIntersection,\n ZodTuple: ZodTuple,\n ZodRecord: ZodRecord,\n ZodMap: ZodMap,\n ZodSet: ZodSet,\n ZodFunction: ZodFunction,\n ZodLazy: ZodLazy,\n ZodLiteral: ZodLiteral,\n ZodEnum: ZodEnum,\n ZodNativeEnum: ZodNativeEnum,\n ZodPromise: ZodPromise,\n ZodEffects: ZodEffects,\n ZodTransformer: ZodEffects,\n ZodOptional: ZodOptional,\n ZodNullable: ZodNullable,\n ZodDefault: ZodDefault,\n ZodCatch: ZodCatch,\n ZodNaN: ZodNaN,\n BRAND: BRAND,\n ZodBranded: ZodBranded,\n ZodPipeline: ZodPipeline,\n ZodReadonly: ZodReadonly,\n custom: custom,\n Schema: ZodType,\n ZodSchema: ZodType,\n late: late,\n get ZodFirstPartyTypeKind () { return ZodFirstPartyTypeKind; },\n coerce: coerce,\n any: anyType,\n array: arrayType,\n bigint: bigIntType,\n boolean: booleanType,\n date: dateType,\n discriminatedUnion: discriminatedUnionType,\n effect: effectsType,\n 'enum': enumType,\n 'function': functionType,\n 'instanceof': instanceOfType,\n intersection: intersectionType,\n lazy: lazyType,\n literal: literalType,\n map: mapType,\n nan: nanType,\n nativeEnum: nativeEnumType,\n never: neverType,\n 'null': nullType,\n nullable: nullableType,\n number: numberType,\n object: objectType,\n oboolean: oboolean,\n onumber: onumber,\n optional: optionalType,\n ostring: ostring,\n pipeline: pipelineType,\n preprocess: preprocessType,\n promise: promiseType,\n record: recordType,\n set: setType,\n strictObject: strictObjectType,\n string: stringType,\n symbol: symbolType,\n transformer: effectsType,\n tuple: tupleType,\n 'undefined': undefinedType,\n union: unionType,\n unknown: unknownType,\n 'void': voidType,\n NEVER: NEVER,\n ZodIssueCode: ZodIssueCode,\n quotelessJson: quotelessJson,\n ZodError: ZodError\n});\n\nexport { BRAND, DIRTY, EMPTY_PATH, INVALID, NEVER, OK, ParseStatus, ZodType as Schema, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodBranded, ZodCatch, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEnum, ZodError, ZodFirstPartyTypeKind, ZodFunction, ZodIntersection, ZodIssueCode, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodParsedType, ZodPipeline, ZodPromise, ZodReadonly, ZodRecord, ZodType as ZodSchema, ZodSet, ZodString, ZodSymbol, ZodEffects as ZodTransformer, ZodTuple, ZodType, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, addIssueToContext, anyType as any, arrayType as array, bigIntType as bigint, booleanType as boolean, coerce, custom, dateType as date, z as default, errorMap as defaultErrorMap, discriminatedUnionType as discriminatedUnion, effectsType as effect, enumType as enum, functionType as function, getErrorMap, getParsedType, instanceOfType as instanceof, intersectionType as intersection, isAborted, isAsync, isDirty, isValid, late, lazyType as lazy, literalType as literal, makeIssue, mapType as map, nanType as nan, nativeEnumType as nativeEnum, neverType as never, nullType as null, nullableType as nullable, numberType as number, objectType as object, objectUtil, oboolean, onumber, optionalType as optional, ostring, pipelineType as pipeline, preprocessType as preprocess, promiseType as promise, quotelessJson, recordType as record, setType as set, setErrorMap, strictObjectType as strictObject, stringType as string, symbolType as symbol, effectsType as transformer, tupleType as tuple, undefinedType as undefined, unionType as union, unknownType as unknown, util, voidType as void, z };\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nexport const numberCouple = z.tuple([z.number(), z.number()]);\nexport type NumberCouple = z.infer<typeof numberCouple>;\n\n// Dimensions\n\nexport const dimensions = z.object({ width: z.number(), height: z.number() });\nexport type Dimensions = z.infer<typeof dimensions>;\nexport const signedDimensions = z.object({\n signedWidth: z.number(),\n signedHeight: z.number(),\n});\nexport const DIMENSIONS = [\"width\", \"height\"] as const;\nexport const dimension = z.enum(DIMENSIONS);\nexport type Dimension = (typeof DIMENSIONS)[number];\nexport const ALIGNMENTS = [\"start\", \"center\", \"end\"] as const;\nexport const SIGNED_DIMENSIONS = [\"signedWidth\", \"signedHeight\"] as const;\nexport const signedDimension = z.enum(SIGNED_DIMENSIONS);\nexport type SignedDimension = (typeof SIGNED_DIMENSIONS)[number];\n\n// XY\n\nexport const xy = z.object({ x: z.number(), y: z.number() });\nexport type XY = z.infer<typeof xy>;\nexport const clientXY = z.object({ clientX: z.number(), clientY: z.number() });\nexport type ClientXY = z.infer<typeof clientXY>;\n\n// Direction\n\nexport const DIRECTIONS = [\"x\", \"y\"] as const;\nexport const direction = z.enum(DIRECTIONS);\nexport type Direction = z.infer<typeof direction>;\n\n// Location\n\nexport const OUTER_LOCATIONS = [\"top\", \"right\", \"bottom\", \"left\"] as const;\nexport const outerLocation = z.enum(OUTER_LOCATIONS);\nexport type OuterLocation = (typeof OUTER_LOCATIONS)[number];\nexport const X_LOCATIONS = [\"left\", \"right\"] as const;\nexport const xLocation = z.enum(X_LOCATIONS);\nexport type XLocation = (typeof X_LOCATIONS)[number];\nexport const Y_LOCATIONS = [\"top\", \"bottom\"] as const;\nexport const yLocation = z.enum(Y_LOCATIONS);\nexport type YLocation = (typeof Y_LOCATIONS)[number];\nexport const CENTER_LOCATIONS = [\"center\"] as const;\nexport const centerlocation = z.enum(CENTER_LOCATIONS);\nexport type CenterLocation = (typeof CENTER_LOCATIONS)[number];\nexport const LOCATIONS = [...OUTER_LOCATIONS, ...CENTER_LOCATIONS] as const;\nexport const location = z.enum(LOCATIONS);\nexport type Location = z.infer<typeof location>;\n\n// Alignment\n\nexport const alignment = z.enum(ALIGNMENTS);\nexport type Alignment = (typeof ALIGNMENTS)[number];\nexport const ORDERS = [\"first\", \"last\"] as const;\nexport const order = z.enum(ORDERS);\nexport type Order = (typeof ORDERS)[number];\n\n// Bounds\n\nexport const bounds = z.object({ lower: z.number(), upper: z.number() });\nexport type Bounds = z.infer<typeof bounds>;\n\nexport const crudeBounds = z.union([bounds, numberCouple]);\nexport type CrudeBounds = z.infer<typeof crudeBounds>;\nexport const crudeDirection = z.union([direction, location]);\nexport type CrudeDirection = z.infer<typeof crudeDirection>;\nexport const crudeLocation = z.union([direction, location, z.instanceof(String)]);\nexport type CrudeLocation = z.infer<typeof crudeLocation>;\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Bounds, bounds, type CrudeBounds } from \"@/spatial/base\";\n\nexport { type Bounds, bounds };\n\nexport type Crude = CrudeBounds;\n\nexport const construct = (lower: number | Crude, upper?: number): Bounds => {\n const b = { lower: 0, upper: 0 };\n if (typeof lower === \"number\") {\n if (upper != null) {\n b.lower = lower;\n b.upper = upper;\n } else {\n b.lower = 0;\n b.upper = lower;\n }\n } else if (Array.isArray(lower)) {\n [b.lower, b.upper] = lower;\n } else {\n b.lower = lower.lower;\n b.upper = lower.upper;\n }\n return makeValid(b);\n};\n\nexport const ZERO = { lower: 0, upper: 0 };\n\nexport const INFINITE = { lower: -Infinity, upper: Infinity };\n\nexport const DECIMAL = { lower: 0, upper: 1 };\n\nexport const CLIP = { lower: -1, upper: 1 };\n\nexport const equals = (_a?: Bounds, _b?: Bounds): boolean => {\n if (_a == null && _b == null) return true;\n if (_a == null || _b == null) return false;\n const a = construct(_a);\n const b = construct(_b);\n return a?.lower === b?.lower && a?.upper === b?.upper;\n}\n\nexport const makeValid = (a: Bounds): Bounds => {\n if (a.lower > a.upper) return { lower: a.upper, upper: a.lower };\n return a;\n};\n\nexport const clamp = (bounds: Crude, target: number): number => {\n const _bounds = construct(bounds);\n if (target < _bounds.lower) return _bounds.lower;\n if (target >= _bounds.upper) return _bounds.upper - 1;\n return target;\n};\n\nexport const contains = (bounds: Crude, target: number | CrudeBounds): boolean => {\n const _bounds = construct(bounds);\n if (typeof target === \"number\") return target >= _bounds.lower && target < _bounds.upper;\n const _target = construct(target);\n return _target.lower >= _bounds.lower && _target.upper <= _bounds.upper;\n}\n\nexport const overlapsWith = (a: Crude, b: Crude): boolean => {\n const _a = construct(a);\n const _b = construct(b);\n if (_a.lower ==_b.lower) return true;\n if (_b.upper == _a.lower || _b.lower == _a.upper) return false;\n return contains(_a, _b.upper) \n || contains(_a, _b.lower) \n || contains(_b, _a.upper) \n || contains(_b, _a.lower);\n}\n\nexport const span = (a: Crude): number => {\n const _a = construct(a);\n return _a.upper - _a.lower;\n}\n\nexport const isZero = (a: Crude): boolean => {\n const _a = construct(a);\n return _a.lower === 0 && _a.upper === 0;\n}\n\nexport const spanIsZero = (a: Crude): boolean => span(a) === 0;\n\nexport const isFinite = (a: Crude): boolean => {\n const _a = construct(a);\n return Number.isFinite(_a.lower) && Number.isFinite(_a.upper);\n}\n\nexport const max = (bounds: Crude[]): Bounds => ({\n lower: Math.min(...bounds.map((b) => construct(b).lower)),\n upper: Math.max(...bounds.map((b) => construct(b).upper)),\n});\n\nexport const min = (bounds: Crude[]): Bounds => ({\n lower: Math.max(...bounds.map((b) => construct(b).lower)),\n upper: Math.min(...bounds.map((b) => construct(b).upper)),\n});\n\nexport const constructArray = (bounds: Crude): number[] => {\n const _bounds = construct(bounds);\n return Array.from({ length: span(bounds) }, (_, i) => i + _bounds.lower);\n}\n\nexport const findInsertPosition = (bounds: Crude[], target: number): { index: number, position: number } => {\n const _bounds = bounds.map(construct);\n const index = _bounds.findIndex((b, i) => contains(b, target) || target < _bounds[i].lower);\n if (index === -1) return { index: bounds.length, position: 0 };\n const b = _bounds[index];\n if (contains(b, target)) return { index, position: target - b.lower };\n return {index: index, position: 0};\n}\n\n\n/**\n * A plan for inserting a new bound into an ordered array of bounds.\n */\nexport interface InsertionPlan {\n /** How much to increase the lower bound of the new bound or decrease the upper bound\n * of the previous bound. */\n removeBefore: number;\n /** How much to decrease the upper bound of the new bound or increase the lower bound\n * of the next bound. */\n removeAfter: number;\n /** The index at which to insert the new bound. */\n insertInto: number;\n /** The number of bounds to remove from the array. */\n deleteInBetween: number;\n}\n\nconst ZERO_PLAN: InsertionPlan = {\n removeBefore: 0,\n removeAfter: 0,\n insertInto: 0,\n deleteInBetween: 0,\n}\n\n/**\n * Build a plan for inserting a new bound into an ordered array of bounds. This function\n * is particularly useful for inserting a new array into a sorted array of array of arrays\n * that may overlap. The plan is used to determine how to splice the new array into the\n * existing array. The following are important constraints:\n * \n * \n * 1. If the new bound is entirely contained within an existing bound, the new bound\n * is not inserted and the plan is null.\n * \n * @param bounds - An ordered array of bounds, where each bound is valid (i.e., lower <= upper)\n * and the lower bound of each bound is less than the upper bound of the next bound.\n * @param value - The new bound to insert.\n * @returns A plan for inserting the new bound into the array of bounds, or null if the\n * new bound is entirely contained within an existing bound. See the {@link InsertionPlan}\n * type for more details.\n */\nexport const buildInsertionPlan = (bounds: Crude[], value: Crude):InsertionPlan | null => {\n const _bounds = bounds.map(construct);\n const _target = construct(value);\n // No bounds to insert into, so just insert the new bound at the beginning of the array.\n if (_bounds.length === 0) return ZERO_PLAN;\n const lower = findInsertPosition(bounds, _target.lower);\n const upper = findInsertPosition(bounds, _target.upper);\n // Greater than all bounds,\n if (lower.index == bounds.length) return { ...ZERO_PLAN, insertInto: bounds.length };\n // Less than all bounds,\n if (upper.index == 0) return {\n ...ZERO_PLAN,\n removeAfter: upper.position\n }\n if (lower.index === upper.index) {\n // The case where the bound is entirely contained within an existing bound.\n if (lower.position !== 0 && upper.position !== 0)\n return null;\n return {\n removeAfter: upper.position,\n removeBefore: lower.position,\n insertInto: lower.index,\n deleteInBetween: 0,\n }\n }\n let deleteInBetween = (upper.index - lower.index)\n let insertInto = lower.index;\n let removeBefore = span(_bounds[lower.index]) - lower.position;\n // If we're overlapping with the previous bound, we need to slice out one less\n // and insert one further up.\n if (lower.position != 0) {\n deleteInBetween -= 1;\n insertInto += 1;\n // We're not overlapping with the previous bound, so don't need to remove anything\n } else removeBefore = 0;\n return {\n removeBefore,\n removeAfter: upper.position,\n insertInto, \n deleteInBetween,\n }\n}\n\n\nexport const insert = (bounds: Crude[], value: Crude): Crude[] => {\n const plan = buildInsertionPlan(bounds, value);\n if (plan == null) return bounds;\n const _target = construct(value);\n _target.lower += plan.removeBefore;\n _target.upper -= plan.removeAfter;\n bounds.splice(plan.insertInto, plan.deleteInBetween, _target);\n return bounds.map(construct);\n}\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport {\n type Dimension,\n type Direction,\n type Location,\n type direction,\n DIRECTIONS,\n Y_LOCATIONS,\n type YLocation,\n type SignedDimension,\n crudeDirection,\n type CrudeDirection,\n} from \"@/spatial/base\";\n\nexport type { Direction, direction };\n\nexport const crude = crudeDirection;\n\nexport type Crude = CrudeDirection;\n\nexport const construct = (c: Crude): Direction => {\n if (DIRECTIONS.includes(c as Direction)) return c as Direction;\n if (Y_LOCATIONS.includes(c as YLocation)) return \"y\";\n else return \"x\";\n};\n\nexport const swap = (direction: CrudeDirection): Direction =>\n construct(direction) === \"x\" ? \"y\" : \"x\";\n\nexport const dimension = (direction: CrudeDirection): Dimension =>\n construct(direction) === \"x\" ? \"width\" : \"height\";\n\nexport const location = (direction: CrudeDirection): Location =>\n construct(direction) === \"x\" ? \"left\" : \"top\";\n\nexport const isDirection = (c: unknown): c is Direction => crude.safeParse(c).success;\n\nexport const signedDimension = (direction: CrudeDirection): SignedDimension =>\n construct(direction) === \"x\" ? \"signedWidth\" : \"signedHeight\";\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toCamelCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n return String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/[^A-Za-z0-9]+/g, '$')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + \"$\" + b; })\n .toLowerCase()\n .replace(/(\\$)(\\w)/g, function (m, a, b) { return b.toUpperCase(); });\n}\nexports.default = toCamelCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toSnakeCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n return String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + '_' + b.toLowerCase(); })\n .replace(/[^A-Za-z0-9]+|_+/g, '_')\n .toLowerCase();\n}\nexports.default = toSnakeCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toPascalCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n return String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '$')\n .replace(/[^A-Za-z0-9]+/g, '$')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + \"$\" + b; })\n .toLowerCase()\n .replace(/(\\$)(\\w?)/g, function (m, a, b) { return b.toUpperCase(); });\n}\nexports.default = toPascalCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toDotCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n return String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + \"_\" + b.toLowerCase(); })\n .replace(/[^A-Za-z0-9]+|_+/g, '.')\n .toLowerCase();\n}\nexports.default = toDotCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toPathCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n return String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + \"_\" + b.toLowerCase(); })\n .replace(/[^A-Za-z0-9]+|_+/g, '/')\n .toLowerCase();\n}\nexports.default = toPathCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toTextCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n return String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + '_' + b.toLowerCase(); })\n .replace(/[^A-Za-z0-9]+|_+/g, ' ')\n .toLowerCase();\n}\nexports.default = toTextCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toSentenceCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n var textcase = String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + \"_\" + b.toLowerCase(); })\n .replace(/[^A-Za-z0-9]+|_+/g, ' ')\n .toLowerCase();\n return textcase.charAt(0).toUpperCase() + textcase.slice(1);\n}\nexports.default = toSentenceCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toHeaderCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n return String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + \"_\" + b.toLowerCase(); })\n .replace(/[^A-Za-z0-9]+|_+/g, ' ')\n .toLowerCase()\n .replace(/( ?)(\\w+)( ?)/g, function (m, a, b, c) { return a + b.charAt(0).toUpperCase() + b.slice(1) + c; });\n}\nexports.default = toHeaderCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toKebabCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n return String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + \"_\" + b.toLowerCase(); })\n .replace(/[^A-Za-z0-9]+|_+/g, '-')\n .toLowerCase();\n}\nexports.default = toKebabCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.belongToTypes = exports.isValidObject = exports.isArrayObject = exports.validateOptions = exports.DefaultOption = void 0;\n/**\n * Default options for convert function. This option is not recursive.\n */\nexports.DefaultOption = {\n recursive: false,\n recursiveInArray: false,\n keepTypesOnRecursion: []\n};\nexports.validateOptions = function (opt) {\n if (opt === void 0) { opt = exports.DefaultOption; }\n if (opt.recursive == null) {\n opt = exports.DefaultOption;\n }\n else if (opt.recursiveInArray == null) {\n opt.recursiveInArray = false;\n }\n return opt;\n};\nexports.isArrayObject = function (obj) { return obj != null && Array.isArray(obj); };\nexports.isValidObject = function (obj) { return obj != null && typeof obj === 'object' && !Array.isArray(obj); };\nexports.belongToTypes = function (obj, types) { return (types || []).some(function (Type) { return obj instanceof Type; }); };\n","\"use strict\";\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar utils_1 = require(\"../utils\");\n/**\n * Convert string keys in an object to lowercase format.\n * @param obj: object to convert keys. If `obj` isn't a json object, `null` is returned.\n * @param opt: (optional) Options parameter, default is non-recursive.\n */\nfunction lowerKeys(obj, opt) {\n if (opt === void 0) { opt = utils_1.DefaultOption; }\n if (!utils_1.isValidObject(obj))\n return null;\n opt = utils_1.validateOptions(opt);\n var res = {};\n Object.keys(obj).forEach(function (key) {\n var value = obj[key];\n var nkey = key.toLowerCase();\n if (opt.recursive) {\n if (utils_1.isValidObject(value)) {\n if (!utils_1.belongToTypes(value, opt.keepTypesOnRecursion)) {\n value = lowerKeys(value, opt);\n }\n }\n else if (opt.recursiveInArray && utils_1.isArrayObject(value)) {\n value = __spreadArrays(value).map(function (v) {\n var ret = v;\n if (utils_1.isValidObject(v)) {\n // object in array\n if (!utils_1.belongToTypes(ret, opt.keepTypesOnRecursion)) {\n ret = lowerKeys(v, opt);\n }\n }\n else if (utils_1.isArrayObject(v)) {\n // array in array\n // workaround by using an object holding array value\n var temp = lowerKeys({ key: v }, opt);\n ret = temp.key;\n }\n return ret;\n });\n }\n }\n res[nkey] = value;\n });\n return res;\n}\nexports.default = lowerKeys;\n","\"use strict\";\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar utils_1 = require(\"../utils\");\n/**\n * Convert string keys in an object to UPPERCASE format.\n * @param obj: object to convert keys. If `obj` isn't a json object, `null` is returned.\n * @param opt: (optional) Options parameter, default is non-recursive.\n */\nfunction upperKeys(obj, opt) {\n if (opt === void 0) { opt = utils_1.DefaultOption; }\n if (!utils_1.isValidObject(obj))\n return null;\n opt = utils_1.validateOptions(opt);\n var res = {};\n Object.keys(obj).forEach(function (key) {\n var value = obj[key];\n var nkey = key.toUpperCase();\n if (opt.recursive) {\n if (utils_1.isValidObject(value)) {\n if (!utils_1.belongToTypes(value, opt.keepTypesOnRecursion)) {\n value = upperKeys(value, opt);\n }\n }\n else if (opt.recursiveInArray && utils_1.isArrayObject(value)) {\n value = __spreadArrays(value).map(function (v) {\n var ret = v;\n if (utils_1.isValidObject(v)) {\n // object in array\n if (!utils_1.belongToTypes(ret, opt.keepTypesOnRecursion)) {\n ret = upperKeys(v, opt);\n }\n }\n else if (utils_1.isArrayObject(v)) {\n // array in array\n // workaround by using an object holding array value\n var temp = upperKeys({ key: v }, opt);\n ret = temp.key;\n }\n return ret;\n });\n }\n }\n res[nkey] = value;\n });\n return res;\n}\nexports.default = upperKeys;\n","\"use strict\";\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar utils_1 = require(\"../utils\");\nvar js_camelcase_1 = require(\"../../js-camelcase\");\n/**\n * Convert string keys in an object to camelCase format.\n * @param obj: object to convert keys. If `obj` isn't a json object, `null` is returned.\n * @param opt: (optional) Options parameter, default is non-recursive.\n */\nfunction camelKeys(obj, opt) {\n if (opt === void 0) { opt = utils_1.DefaultOption; }\n if (!utils_1.isValidObject(obj))\n return null;\n opt = utils_1.validateOptions(opt);\n var res = {};\n Object.keys(obj).forEach(function (key) {\n var value = obj[key];\n var nkey = js_camelcase_1.default(key);\n if (opt.recursive) {\n if (utils_1.isValidObject(value)) {\n if (!utils_1.belongToTypes(value, opt.keepTypesOnRecursion)) {\n value = camelKeys(value, opt);\n }\n }\n else if (opt.recursiveInArray && utils_1.isArrayObject(value)) {\n value = __spreadArrays(value).map(function (v) {\n var ret = v;\n if (utils_1.isValidObject(v)) {\n // object in array\n if (!utils_1.belongToTypes(ret, opt.keepTypesOnRecursion)) {\n ret = camelKeys(v, opt);\n }\n }\n else if (utils_1.isArrayObject(v)) {\n // array in array\n // workaround by using an object holding array value\n var temp = camelKeys({ key: v }, opt);\n ret = temp.key;\n }\n return ret;\n });\n }\n }\n res[nkey] = value;\n });\n return res;\n}\nexports.default = camelKeys;\n","\"use strict\";\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar utils_1 = require(\"../utils\");\nvar js_snakecase_1 = require(\"../../js-snakecase\");\n/**\n * Convert string keys in an object to snake_case format.\n * @param obj: object to convert keys. If `obj` isn't a json object, `null` is returned.\n * @param opt: (optional) Options parameter, default is non-recursive.\n */\nfunction snakeKeys(obj, opt) {\n if (opt === void 0) { opt = utils_1.DefaultOption; }\n if (!utils_1.isValidObject(obj))\n return null;\n opt = utils_1.validateOptions(opt);\n var res = {};\n Object.keys(obj).forEach(function (key) {\n var value = obj[key];\n var nkey = js_snakecase_1.default(key);\n if (opt.recursive) {\n if (utils_1.isValidObject(value)) {\n if (!utils_1.belongToTypes(value, opt.keepTypesOnRecursion)) {\n value = snakeKeys(value, opt);\n }\n }\n else if (opt.recursiveInArray && utils_1.isArrayObject(value)) {\n value = __spreadArrays(value).map(function (v) {\n var ret = v;\n if (utils_1.isValidObject(v)) {\n // object in array\n if (!utils_1.belongToTypes(ret, opt.keepTypesOnRecursion)) {\n ret = snakeKeys(v, opt);\n }\n }\n else if (utils_1.isArrayObject(v)) {\n // array in array\n // workaround by using an object holding array value\n var temp = snakeKeys({ key: v }, opt);\n ret = temp.key;\n }\n return ret;\n });\n }\n }\n res[nkey] = value;\n });\n return res;\n}\nexports.default = snakeKeys;\n","\"use strict\";\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar utils_1 = require(\"../utils\");\nvar js_pascalcase_1 = require(\"../../js-pascalcase\");\n/**\n * Convert string keys in an object to PascalCase format.\n * @param obj: object to convert keys. If `obj` isn't a json object, `null` is returned.\n * @param opt: (optional) Options parameter, default is non-recursive.\n */\nfunction pascalKeys(obj, opt) {\n if (opt === void 0) { opt = utils_1.DefaultOption; }\n if (!utils_1.isValidObject(obj))\n return null;\n opt = utils_1.validateOptions(opt);\n var res = {};\n Object.keys(obj).forEach(function (key) {\n var value = obj[key];\n var nkey = js_pascalcase_1.default(key);\n if (opt.recursive) {\n if (utils_1.isValidObject(value)) {\n if (!utils_1.belongToTypes(value, opt.keepTypesOnRecursion)) {\n value = pascalKeys(value, opt);\n }\n }\n else if (opt.recursiveInArray && utils_1.isArrayObject(value)) {\n value = __spreadArrays(value).map(function (v) {\n var ret = v;\n if (utils_1.isValidObject(v)) {\n // object in array\n if (!utils_1.belongToTypes(ret, opt.keepTypesOnRecursion)) {\n ret = pascalKeys(v, opt);\n }\n }\n else if (utils_1.isArrayObject(v)) {\n // array in array\n // workaround by using an object holding array value\n var temp = pascalKeys({ key: v }, opt);\n ret = temp.key;\n }\n return ret;\n });\n }\n }\n res[nkey] = value;\n });\n return res;\n}\nexports.default = pascalKeys;\n","\"use strict\";\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar utils_1 = require(\"../utils\");\nvar js_kebabcase_1 = require(\"../../js-kebabcase\");\n/**\n * Convert string keys in an object to kebab-case format.\n * @param obj: object to convert keys. If `obj` isn't a json object, `null` is returned.\n * @param opt: (optional) Options parameter, default is non-recursive.\n */\nfunction kebabKeys(obj, opt) {\n if (opt === void 0) { opt = utils_1.DefaultOption; }\n if (!utils_1.isValidObject(obj))\n return null;\n opt = utils_1.validateOptions(opt);\n var res = {};\n Object.keys(obj).forEach(function (key) {\n var value = obj[key];\n var nkey = js_kebabcase_1.default(key);\n if (opt.recursive) {\n if (utils_1.isValidObject(value)) {\n if (!utils_1.belongToTypes(value, opt.keepTypesOnRecursion)) {\n value = kebabKeys(value, opt);\n }\n }\n else if (opt.recursiveInArray && utils_1.isArrayObject(value)) {\n value = __spreadArrays(value).map(function (v) {\n var ret = v;\n if (utils_1.isValidObject(v)) {\n // object in array\n if (!utils_1.belongToTypes(ret, opt.keepTypesOnRecursion)) {\n ret = kebabKeys(v, opt);\n }\n }\n else if (utils_1.isArrayObject(v)) {\n // array in array\n // workaround by using an object holding array value\n var temp = kebabKeys({ key: v }, opt);\n ret = temp.key;\n }\n return ret;\n });\n }\n }\n res[nkey] = value;\n });\n return res;\n}\nexports.default = kebabKeys;\n","\"use strict\";\n/**\n * Author: <Ha Huynh> https://github.com/huynhsamha\n * Github: https://github.com/huynhsamha/js-convert-case\n * NPM Package: https://www.npmjs.com/package/js-convert-case\n */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.kebabKeys = exports.pascalKeys = exports.snakeKeys = exports.camelKeys = exports.upperKeys = exports.lowerKeys = exports.toLowerCase = exports.toUpperCase = exports.toKebabCase = exports.toHeaderCase = exports.toSentenceCase = exports.toTextCase = exports.toPathCase = exports.toDotCase = exports.toPascalCase = exports.toSnakeCase = exports.toCamelCase = void 0;\nvar js_camelcase_1 = require(\"./modules/js-camelcase\");\nexports.toCamelCase = js_camelcase_1.default;\nvar js_snakecase_1 = require(\"./modules/js-snakecase\");\nexports.toSnakeCase = js_snakecase_1.default;\nvar js_pascalcase_1 = require(\"./modules/js-pascalcase\");\nexports.toPascalCase = js_pascalcase_1.default;\nvar js_dotcase_1 = require(\"./modules/js-dotcase\");\nexports.toDotCase = js_dotcase_1.default;\nvar js_pathcase_1 = require(\"./modules/js-pathcase\");\nexports.toPathCase = js_pathcase_1.default;\nvar js_textcase_1 = require(\"./modules/js-textcase\");\nexports.toTextCase = js_textcase_1.default;\nvar js_sentencecase_1 = require(\"./modules/js-sentencecase\");\nexports.toSentenceCase = js_sentencecase_1.default;\nvar js_headercase_1 = require(\"./modules/js-headercase\");\nexports.toHeaderCase = js_headercase_1.default;\nvar js_kebabcase_1 = require(\"./modules/js-kebabcase\");\nexports.toKebabCase = js_kebabcase_1.default;\nvar lowercase_keys_object_1 = require(\"./modules/extends/lowercase-keys-object\");\nexports.lowerKeys = lowercase_keys_object_1.default;\nvar uppercase_keys_object_1 = require(\"./modules/extends/uppercase-keys-object\");\nexports.upperKeys = uppercase_keys_object_1.default;\nvar camelcase_keys_object_1 = require(\"./modules/extends/camelcase-keys-object\");\nexports.camelKeys = camelcase_keys_object_1.default;\nvar snakecase_keys_object_1 = require(\"./modules/extends/snakecase-keys-object\");\nexports.snakeKeys = snakecase_keys_object_1.default;\nvar pascalcase_keys_object_1 = require(\"./modules/extends/pascalcase-keys-object\");\nexports.pascalKeys = pascalcase_keys_object_1.default;\nvar kebabcase_keys_object_1 = require(\"./modules/extends/kebabcase-keys-object\");\nexports.kebabKeys = kebabcase_keys_object_1.default;\nvar toLowerCase = function (str) { return String(str || '').toLowerCase(); };\nexports.toLowerCase = toLowerCase;\nvar toUpperCase = function (str) { return String(str || '').toUpperCase(); };\nexports.toUpperCase = toUpperCase;\nvar jsConvert = {\n toCamelCase: js_camelcase_1.default,\n toSnakeCase: js_snakecase_1.default,\n toPascalCase: js_pascalcase_1.default,\n toDotCase: js_dotcase_1.default,\n toPathCase: js_pathcase_1.default,\n toTextCase: js_textcase_1.default,\n toSentenceCase: js_sentencecase_1.default,\n toHeaderCase: js_headercase_1.default,\n toKebabCase: js_kebabcase_1.default,\n toUpperCase: toUpperCase,\n toLowerCase: toLowerCase,\n lowerKeys: lowercase_keys_object_1.default,\n upperKeys: uppercase_keys_object_1.default,\n camelKeys: camelcase_keys_object_1.default,\n snakeKeys: snakecase_keys_object_1.default,\n pascalKeys: pascalcase_keys_object_1.default,\n kebabKeys: kebabcase_keys_object_1.default\n};\nexports.default = jsConvert;\n","module.exports = require('./lib');\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { camelKeys as _camelKeys, snakeKeys as _snakeKeys } from \"js-convert-case\";\n\nconst options = {\n recursive: true,\n recursiveInArray: true,\n keepTypesOnRecursion: [Number, String, Uint8Array],\n};\n\nconst snakeKeys = <T>(entity: T): T => _snakeKeys(entity, options) as T;\n\nconst camelKeys = <T>(entity: T): T => _camelKeys(entity, options) as T;\n\nexport namespace Case {\n export const toSnake = snakeKeys;\n export const toCamel = camelKeys;\n export const capitalize = (str: string): string =>\n str[0].toUpperCase() + str.slice(1);\n}\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nimport { Case } from \"@/case\";\nimport {\n location,\n type Location,\n xLocation,\n yLocation,\n DIRECTIONS,\n X_LOCATIONS,\n Y_LOCATIONS,\n CENTER_LOCATIONS,\n type XLocation,\n type OuterLocation,\n type YLocation,\n outerLocation,\n type Direction,\n crudeLocation,\n type CrudeLocation,\n centerlocation,\n type CenterLocation,\n} from \"@/spatial/base\";\n\nexport {\n location,\n type Location,\n X_LOCATIONS,\n Y_LOCATIONS,\n CENTER_LOCATIONS,\n outerLocation as outer,\n};\n\nexport const x = xLocation;\nexport const y = yLocation;\n\nexport type X = XLocation;\nexport type Y = YLocation;\nexport type Outer = OuterLocation;\nexport type Center = CenterLocation;\n\nconst SWAPPED: Record<Location, Location> = {\n top: \"bottom\",\n right: \"left\",\n bottom: \"top\",\n left: \"right\",\n center: \"center\",\n};\n\nconst ROTATE_90: Record<Location, Location> = {\n top: \"left\",\n right: \"top\",\n bottom: \"right\",\n left: \"bottom\",\n center: \"center\",\n};\n\nexport const crude = crudeLocation;\n\nexport type Crude = CrudeLocation;\n\nexport const construct = (cl: Crude): Location => {\n if (cl instanceof String) return cl as Location;\n if (!DIRECTIONS.includes(cl as Direction)) return cl as Location;\n else if (cl === \"x\") return \"left\";\n else return \"top\";\n};\n\nexport const swap = (cl: Crude): Location => SWAPPED[construct(cl)];\n\nexport const rotate90 = (cl: Crude): Location => ROTATE_90[construct(cl)];\n\nexport const direction = (cl: Crude): Direction => {\n const l = construct(cl);\n if (l === \"top\" || l === \"bottom\") return \"y\";\n return \"x\";\n};\n\nexport const xy = z.object({\n x: xLocation.or(centerlocation),\n y: yLocation.or(centerlocation),\n});\nexport const corner = z.object({ x: xLocation, y: yLocation });\n\nexport type XY = z.infer<typeof xy>;\nexport type CornerXY = z.infer<typeof corner>;\nexport type CornerXYString = \"topLeft\" | \"topRight\" | \"bottomLeft\" | \"bottomRight\";\n\nexport const TOP_LEFT: CornerXY = Object.freeze({ x: \"left\", y: \"top\" });\nexport const TOP_RIGHT: CornerXY = Object.freeze({ x: \"right\", y: \"top\" });\nexport const BOTTOM_LEFT: CornerXY = Object.freeze({ x: \"left\", y: \"bottom\" });\nexport const BOTTOM_RIGHT: CornerXY = Object.freeze({ x: \"right\", y: \"bottom\" });\nexport const CENTER: XY = Object.freeze({ x: \"center\", y: \"center\" });\nexport const TOP_CENTER: XY = Object.freeze({ x: \"center\", y: \"top\" });\nexport const BOTTOM_CENTER: XY = Object.freeze({ x: \"center\", y: \"bottom\" });\nexport const RIGHT_CENTER: XY = Object.freeze({ x: \"right\", y: \"center\" });\nexport const LEFT_CENTER: XY = Object.freeze({ x: \"left\", y: \"center\" });\nexport const XY_LOCATIONS: readonly XY[] = Object.freeze([\n LEFT_CENTER,\n RIGHT_CENTER,\n TOP_CENTER,\n BOTTOM_CENTER,\n TOP_LEFT,\n TOP_RIGHT,\n BOTTOM_LEFT,\n BOTTOM_RIGHT,\n CENTER,\n]);\n\nexport const xyEquals = (a: XY, b: XY): boolean => a.x === b.x && a.y === b.y;\n\nexport const xyMatches = (a: XY, l: Partial<XY> | Location): boolean => {\n if (typeof l === \"object\") {\n let ok = true;\n if (\"x\" in l) {\n const ok_ = a.x === l.x;\n if (!ok_) ok = false;\n }\n if (\"y\" in l) {\n const ok_ = a.y === l.y;\n if (!ok_) ok = false;\n }\n return ok;\n }\n return a.x === l || a.y === l;\n};\n\nexport const xyCouple = (a: XY): [Location, Location] => [a.x, a.y];\n\nexport const isX = (a: Crude): a is XLocation | CenterLocation =>\n direction(construct(a)) === \"x\";\n\nexport const isY = (a: Crude): a is YLocation => direction(construct(a)) === \"y\";\n\nexport const xyToString = (a: XY): string => `${a.x}${Case.capitalize(a.y)}`;\n\nexport const constructXY = (x: Crude | XY, y?: Crude): XY => {\n let parsedX: Location;\n let parsedY: Location;\n if (typeof x === \"object\" && \"x\" in x) {\n parsedX = x.x;\n parsedY = x.y;\n } else {\n parsedX = construct(x);\n parsedY = construct(y ?? x);\n }\n if (\n direction(parsedX) === direction(parsedY) &&\n parsedX !== \"center\" &&\n parsedY !== \"center\"\n )\n throw new Error(\n `[XYLocation] - encountered two locations with the same direction: ${parsedX.toString()} - ${parsedY.toString()}`,\n );\n const xy = { ...CENTER };\n if (parsedX === \"center\") {\n if (isX(parsedY)) [xy.x, xy.y] = [parsedY, parsedX];\n else [xy.x, xy.y] = [parsedX, parsedY];\n } else if (parsedY === \"center\") {\n if (isX(parsedX)) [xy.x, xy.y] = [parsedX, parsedY];\n else [xy.x, xy.y] = [parsedY, parsedX];\n } else if (isX(parsedX)) [xy.x, xy.y] = [parsedX, parsedY as YLocation];\n else [xy.x, xy.y] = [parsedY as XLocation, parsedX as YLocation];\n return xy;\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nimport {\n clientXY,\n dimensions,\n numberCouple,\n xy,\n type NumberCouple,\n type ClientXY,\n type XY,\n signedDimensions,\n type Direction,\n} from \"@/spatial/base\";\n\nexport { clientXY, xy, type ClientXY as Client, type XY };\n\n/** A crude representation of a {@link XY} coordinate as a zod schema. */\nexport const crudeZ = z.union([\n z.number(),\n xy,\n numberCouple,\n dimensions,\n signedDimensions,\n clientXY,\n]);\n\n/** A crude representation of a {@link XY} coordinate. */\nexport type Crude = z.infer<typeof crudeZ>;\n\n/**\n * @constructs XY\n * @param x - A crude representation of the XY coordinate as a number, number couple,\n * dimensions, signed dimensions, or mouse event. If it's a mouse event, the clientX and\n * clientY coordinates are preferred over the x and y coordinates.\n * @param y - If x is a number, the y coordinate. If x is a number and this argument is\n * not given, the y coordinate is assumed to be the same as the x coordinate.\n */\nexport const construct = (x: Crude | Direction, y?: number): XY => {\n if (typeof x === \"string\") {\n if (y === undefined) throw new Error(\"The y coordinate must be given.\");\n if (x === \"x\") return { x: y, y: 0 };\n return { x: 0, y };\n }\n // The order in which we execute these checks is very important.\n if (typeof x === \"number\") return { x, y: y ?? x };\n if (Array.isArray(x)) return { x: x[0], y: x[1] };\n if (\"signedWidth\" in x) return { x: x.signedWidth, y: x.signedHeight };\n if (\"clientX\" in x) return { x: x.clientX, y: x.clientY };\n if (\"width\" in x) return { x: x.width, y: x.height };\n return { x: x.x, y: x.y };\n};\n\n/** An x and y coordinate of zero */\nexport const ZERO = { x: 0, y: 0 };\n\n/** An x and y coordinate of one */\nexport const ONE = { x: 1, y: 1 };\n\n/** An x and y coordinate of infinity */\nexport const INFINITY = { x: Infinity, y: Infinity };\n\n/** An x and y coordinate of NaN */\nexport const NAN = { x: NaN, y: NaN };\n\n/** @returns true if the two XY coordinates are semantically equal. */\nexport const equals = (a: Crude, b: Crude, threshold: number = 0): boolean => {\n const a_ = construct(a);\n const b_ = construct(b);\n if (threshold === 0) return a_.x === b_.x && a_.y === b_.y;\n return Math.abs(a_.x - b_.x) <= threshold && Math.abs(a_.y - b_.y) <= threshold;\n};\n\n/** Is zero is true if the XY coordinate has a semantic x and y value of zero. */\nexport const isZero = (c: Crude): boolean => equals(c, ZERO);\n\n/**\n * @returns the given coordinate scaled by the given factors. If only one factor is given,\n * the y factor is assumed to be the same as the x factor.\n */\nexport const scale = (c: Crude, x: number, y: number = x): XY => {\n const p = construct(c);\n return { x: p.x * x, y: p.y * y };\n};\n\n/** @returns the given coordinate translated in the X direction by the given amount. */\nexport const translateX = (c: Crude, x: number): XY => {\n const p = construct(c);\n return { x: p.x + x, y: p.y };\n};\n\n/** @returns the given coordinate translated in the Y direction by the given amount. */\nexport const translateY = (c: Crude, y: number): XY => {\n const p = construct(c);\n return { x: p.x, y: p.y + y };\n};\n\ninterface Translate {\n /** @returns the sum of the given coordinates. */\n (a: Crude, b: Crude, ...cb: Crude[]): XY;\n /** @returns the coordinates translated in the given direction by the given value. */\n (a: Crude, direction: Direction, value: number): XY;\n}\n\nexport const translate: Translate = (a, b, v, ...cb): XY => {\n if (typeof b === \"string\" && typeof v === \"number\") {\n if (b === \"x\") return translateX(a, v);\n return translateY(a, v);\n }\n return [a, b, v ?? ZERO, ...cb].reduce((p: XY, c) => {\n const xy = construct(c as Crude);\n return { x: p.x + xy.x, y: p.y + xy.y };\n }, ZERO);\n};\n\n/**\n * @returns the given coordinate the given direction set to the given value.\n * @example set({ x: 1, y: 2 }, \"x\", 3) // { x: 3, y: 2 }\n */\nexport const set = (c: Crude, direction: Direction, value: number): XY => {\n const xy = construct(c);\n if (direction === \"x\") return { x: value, y: xy.y };\n return { x: xy.x, y: value };\n};\n\n/** @returns the magnitude of the distance between the two given coordinates. */\nexport const distance = (ca: Crude, cb: Crude): number => {\n const a = construct(ca);\n const b = construct(cb);\n return Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2);\n};\n\n/** @returns the magnitude of the x distance between the two given coordinates. */\nexport const xDistance = (ca: Crude, cb: Crude): number => {\n const a = construct(ca);\n const b = construct(cb);\n return Math.abs(a.x - b.x);\n};\n\n/** @returns the magnitude of the y distance between the two given coordinates. */\nexport const yDistance = (ca: Crude, cb: Crude): number => {\n const a = construct(ca);\n const b = construct(cb);\n return Math.abs(a.y - b.y);\n};\n\n/**\n * @returns the translation that would need to be applied to move the first coordinate\n * to the second coordinate.\n */\nexport const translation = (ca: Crude, cb: Crude): XY => {\n const a = construct(ca);\n const b = construct(cb);\n return { x: b.x - a.x, y: b.y - a.y };\n};\n\n/** @returns true if both the x and y coordinates of the given coordinate are NaN. */\nexport const isNan = (a: Crude): boolean => {\n const xy = construct(a);\n return Number.isNaN(xy.x) || Number.isNaN(xy.y);\n};\n\n/** @returns true if both the x and y coordinates of the given coordinate are finite. */\nexport const isFinite = (a: Crude): boolean => {\n const xy = construct(a);\n return Number.isFinite(xy.x) && Number.isFinite(xy.y);\n};\n\n/** @returns the coordinate represented as a couple of the form [x, y]. */\nexport const couple = (a: Crude): NumberCouple => {\n const xy = construct(a);\n return [xy.x, xy.y];\n};\n\n/** @returns the coordinate represented as css properties in the form { left, top }. */\nexport const css = (a: Crude): { left: number; top: number } => {\n const xy = construct(a);\n return { left: xy.x, top: xy.y };\n};\n\nexport const truncate = (a: Crude, precision: number = 0): XY => {\n const xy = construct(a);\n return { x: Number(xy.x.toFixed(precision)), y: Number(xy.y.toFixed(precision)) };\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { unknown, z } from \"zod\";\n\nimport type * as bounds from \"@/spatial/bounds/bounds\";\nimport type * as dimensions from \"@/spatial/dimensions/dimensions\";\nimport * as direction from \"@/spatial/direction/direction\";\nimport * as location from \"@/spatial/location/location\";\nimport * as xy from \"@/spatial/xy/xy\";\n\nconst cssPos = z.union([z.number(), z.string()]);\n\nconst cssBox = z.object({\n top: cssPos,\n left: cssPos,\n width: cssPos,\n height: cssPos,\n});\nconst domRect = z.object({\n left: z.number(),\n top: z.number(),\n right: z.number(),\n bottom: z.number(),\n});\nexport const box = z.object({\n one: xy.xy,\n two: xy.xy,\n root: location.corner,\n});\n\nexport type Box = z.infer<typeof box>;\nexport type CSS = z.infer<typeof cssBox>;\nexport type DOMRect = z.infer<typeof domRect>;\n\nexport type Crude = DOMRect | Box | { getBoundingClientRect: () => DOMRect };\n\n/** A box centered at (0,0) with a width and height of 0. */\nexport const ZERO = { one: xy.ZERO, two: xy.ZERO, root: location.TOP_LEFT };\n\n/**\n * A box centered at (0,0) with a width and height of 1, and rooted in the\n * bottom left. Note that pixel space is typically rooted in the top left.\n */\nexport const DECIMAL = { one: xy.ZERO, two: xy.ONE, root: location.BOTTOM_LEFT };\n\nexport const copy = (b: Box, root?: location.CornerXY): Box => ({\n one: b.one,\n two: b.two,\n root: root ?? b.root,\n});\n\n/**\n * Box represents a general box in 2D space. It typically represents a bounding box\n * for a DOM element, but can also represent a box in clip space or decimal space.\n *\n * It'simportant to note that the behavior of a Box varies depending on its coordinate\n * system.Make sure you're aware of which coordinate system you're using.\n *\n * Many of the properties and methods on a Box access the same semantic value. The\n * different accessors are there for ease of use and semantics.\n */\nexport const construct = (\n first: number | DOMRect | xy.XY | Box | { getBoundingClientRect: () => DOMRect },\n second?: number | xy.XY | dimensions.Dimensions | dimensions.Signed,\n width: number = 0,\n height: number = 0,\n coordinateRoot?: location.CornerXY,\n): Box => {\n const b: Box = {\n one: { ...xy.ZERO },\n two: { ...xy.ZERO },\n root: coordinateRoot ?? location.TOP_LEFT,\n };\n\n if (typeof first === \"number\") {\n if (typeof second !== \"number\")\n throw new Error(\"Box constructor called with invalid arguments\");\n b.one = { x: first, y: second };\n b.two = { x: b.one.x + width, y: b.one.y + height };\n return b;\n }\n\n if (\"one\" in first && \"two\" in first && \"root\" in first)\n return { ...first, root: coordinateRoot ?? first.root };\n\n if (\"getBoundingClientRect\" in first) first = first.getBoundingClientRect();\n if (\"left\" in first) {\n b.one = { x: first.left, y: first.top };\n b.two = { x: first.right, y: first.bottom };\n return b;\n }\n\n b.one = first;\n if (second == null) b.two = { x: b.one.x + width, y: b.one.y + height };\n else if (typeof second === \"number\")\n b.two = { x: b.one.x + second, y: b.one.y + width };\n else if (\"width\" in second)\n b.two = {\n x: b.one.x + second.width,\n y: b.one.y + second.height,\n };\n else if (\"signedWidth\" in second)\n b.two = {\n x: b.one.x + second.signedWidth,\n y: b.one.y + second.signedHeight,\n };\n else b.two = second;\n return b;\n};\n\nexport interface Resize {\n /** \n * Sets the dimensions of the box to the given dimensions.\n * @example resize(b, { width: 10, height: 10 }) // Sets the box to a 10x10 box.\n */\n (b: Crude, dims: dimensions.Dimensions | dimensions.Signed): Box;\n /** \n * Sets the dimension along the given direction to the given amount. \n * @example resize(b, \"x\", 10) // Sets the width of the box to 10.\n * @example resize(b, \"y\", 10) // Sets the height of the box to 10.\n */\n (b: Crude, direction: direction.Direction, amount: number): Box;\n}\n\nexport const resize: Resize = (\n b: Crude, \n dims: dimensions.Dimensions | dimensions.Signed | direction.Direction, \n amount?: number,\n): Box => {\n const b_ = construct(b);\n if (typeof dims === \"string\") {\n if (amount == null) throw new Error(\"Invalid arguments for resize\");\n const dir = direction.construct(dims);\n return construct(\n b_.one,\n undefined,\n dir === \"x\" ? amount : width(b_),\n dir === \"y\" ? amount : height(b_),\n b_.root,\n );\n }\n return construct(b_.one, dims, undefined, undefined, b_.root);\n}\n\n/**\n * Checks if a box contains a point or another box.\n *\n * @param value - The point or box to check.\n * @returns true if the box inclusively contains the point or box and false otherwise.\n */\nexport const contains = (b: Crude, value: Box | xy.XY): boolean => {\n const b_ = construct(b);\n if (\"one\" in value)\n return (\n left(value) >= left(b_) &&\n right(value) <= right(b_) &&\n top(value) >= top(b_) &&\n bottom(value) <= bottom(b_)\n );\n return (\n value.x >= left(b_) &&\n value.x <= right(b_) &&\n value.y >= top(b_) &&\n value.y <= bottom(b_)\n );\n};\n\n/**\n * @returns true if the given box is semantically equal to this box and false otherwise.\n */\nexport const equals = (a: Box, b: Box): boolean =>\n xy.equals(a.one, b.one) &&\n xy.equals(a.two, b.two) &&\n location.xyEquals(a.root, b.root);\n\n/**\n * @returns the dimensions of the box. Note that these dimensions are guaranteed to\n * be positive. To get the signed dimensions, use the `signedDims` property.\n */\nexport const dims = (b: Box): dimensions.Dimensions => ({\n width: width(b),\n height: height(b),\n});\n\n/**\n * @returns the dimensions of the box. Note that these dimensions may be negative.\n * To get the unsigned dimensions, use the `dims` property.\n */\nexport const signedDims = (b: Box): dimensions.Signed => ({\n signedWidth: signedWidth(b),\n signedHeight: signedHeight(b),\n});\n\n/**\n * @returns the css representation of the box.\n */\nexport const css = (b: Box): CSS => ({\n top: top(b),\n left: left(b),\n width: width(b),\n height: height(b),\n});\n\nexport const dim = (\n b: Crude,\n dir: direction.Crude,\n signed: boolean = false,\n): number => {\n const dim: number =\n direction.construct(dir) === \"y\" ? signedHeight(b) : signedWidth(b);\n return signed ? dim : Math.abs(dim);\n};\n\n/** @returns the pont corresponding to the given corner of the box. */\nexport const xyLoc = (b: Crude, l: location.XY): xy.XY => {\n const b_ = construct(b);\n return {\n x: l.x === \"center\" ? center(b_).x : loc(b_, l.x),\n y: l.y === \"center\" ? center(b_).y : loc(b_, l.y),\n };\n};\n\n/**\n * @returns a one dimensional coordinate corresponding to the location of the given\n * side of the box i.e. the x coordinate of the left side, the y coordinate of the\n * top side, etc.\n */\nexport const loc = (b: Crude, loc: location.Location): number => {\n const b_ = construct(b);\n const f = location.xyCouple(b_.root).includes(loc) ? Math.min : Math.max;\n return location.X_LOCATIONS.includes(loc as location.X)\n ? f(b_.one.x, b_.two.x)\n : f(b_.one.y, b_.two.y);\n};\n\nexport const locPoint = (b: Box, loc_: location.Location): xy.XY => {\n const l = loc(b, loc_);\n if (location.X_LOCATIONS.includes(loc_ as location.X))\n return { x: l, y: center(b).y };\n return { x: center(b).x, y: l };\n};\n\nexport const isZero = (b: Box): boolean => {\n return b.one.x === b.two.x && b.one.y === b.two.y;\n};\n\nexport const width = (b: Crude): number => dim(b, \"x\");\n\nexport const height = (b: Crude): number => dim(b, \"y\");\n\nexport const signedWidth = (b: Crude): number => {\n const b_ = construct(b);\n return b_.two.x - b_.one.x;\n};\n\nexport const signedHeight = (b: Crude): number => {\n const b_ = construct(b);\n return b_.two.y - b_.one.y;\n};\n\nexport const topLeft = (b: Crude): xy.XY => xyLoc(b, location.TOP_LEFT);\n\nexport const topRight = (b: Crude): xy.XY => xyLoc(b, location.TOP_RIGHT);\n\nexport const bottomLeft = (b: Crude): xy.XY => xyLoc(b, location.BOTTOM_LEFT);\n\nexport const bottomRight = (b: Crude): xy.XY => xyLoc(b, location.BOTTOM_RIGHT);\n\nexport const right = (b: Crude): number => loc(b, \"right\");\n\nexport const bottom = (b: Crude): number => loc(b, \"bottom\");\n\nexport const left = (b: Crude): number => loc(b, \"left\");\n\nexport const top = (b: Crude): number => loc(b, \"top\");\n\nexport const center = (b: Crude): xy.XY =>\n xy.translate(topLeft(b), {\n x: signedWidth(b) / 2,\n y: signedHeight(b) / 2,\n });\n\nexport const x = (b: Crude): number => {\n const b_ = construct(b);\n return b_.root.x === \"left\" ? left(b_) : right(b_);\n};\n\nexport const y = (b: Crude): number => {\n const b_ = construct(b);\n return b_.root.y === \"top\" ? top(b_) : bottom(b_);\n};\n\nexport const root = (b: Crude): xy.XY => ({ x: x(b), y: y(b) });\n\nexport const xBounds = (b: Crude): bounds.Bounds => {\n const b_ = construct(b);\n return { lower: b_.one.x, upper: b_.two.x };\n};\n\nexport const yBounds = (b: Crude): bounds.Bounds => {\n const b_ = construct(b);\n return { lower: b_.one.y, upper: b_.two.y };\n};\n\nexport const reRoot = (b: Box, corner: location.CornerXY): Box => copy(b, corner);\n\n/**\n * Reposition a box so that it is visible within a given bound.\n *\n * @param target The box to reposition - Only works if the root is topLeft\n * @param bound The box to reposition within - Only works if the root is topLeft\n *\n * @returns the repsoitioned box and a boolean indicating if the box was repositioned\n * or not.\n */\nexport const positionSoVisible = (target_: Crude, bound_: Crude): [Box, boolean] => {\n const target = construct(target_);\n const bound = construct(bound_);\n if (contains(bound, target)) return [target, false];\n let nextPos: xy.XY;\n if (right(target) > width(target))\n nextPos = xy.construct({ x: x(target) - width(target), y: y(target) });\n else nextPos = xy.construct({ x: x(target), y: y(target) - height(target) });\n return [construct(nextPos, dims(target)), true];\n};\n\n/**\n * Reposition a box so that it is centered within a given bound.\n *\n * @param target The box to reposition - Only works if the root is topLeft\n * @param bound The box to reposition within - Only works if the root is topLeft\n * @returns the repsoitioned box\n */\nexport const positionInCenter = (target_: Crude, bound_: Crude): Box => {\n const target = construct(target_);\n const bound = construct(bound_);\n const x_ = x(bound) + (width(bound) - width(target)) / 2;\n const y_ = y(bound) + (height(bound) - height(target)) / 2;\n return construct({ x: x_, y: y_ }, dims(target));\n};\n\nexport const isBox = (value: unknown): value is Box => {\n if (typeof value !== \"object\" || value == null) return false;\n return \"one\" in value && \"two\" in value && \"root\" in value;\n};\n\nexport const aspect = (b: Box): number => width(b) / height(b);\n\ninterface Translate {\n /** @returns the box translated by the given coordinates. */\n (b: Crude, t: xy.Crude): Box;\n /** @returns the box translated in the given direction by the given amount. */\n (b: Crude, direction: direction.Direction, amount: number): Box;\n}\n\nexport const translate = (b: Crude, t: xy.XY | direction.Direction, amount?: number): Box => {\n if (typeof t === \"string\") {\n if (amount == null) throw new Error(`Undefined amount passed into box.translate`);\n const dir = direction.construct(t);\n t = xy.construct(dir, amount);\n }\n const b_ = construct(b);\n return construct(\n xy.translate(b_.one, t),\n xy.translate(b_.two, t),\n undefined,\n undefined,\n b_.root,\n );\n};\n\nexport const intersect = (a: Box, b: Box): Box => {\n const x = Math.max(left(a), left(b));\n const y = Math.max(top(a), top(b));\n const x2 = Math.min(right(a), right(b));\n const y2 = Math.min(bottom(a), bottom(b));\n return construct({ x, y }, { x: x2, y: y2 }, undefined, undefined, a.root);\n};\n\nexport const area = (b: Box): number => width(b) * height(b);\n\nexport const truncate = (b: Box, precision: number = 0): Box => {\n const b_ = construct(b);\n return construct(\n xy.truncate(b_.one, precision),\n xy.truncate(b_.two, precision),\n undefined,\n undefined,\n b_.root,\n );\n};\n\nexport const constructWithAlternateRoot = (\n x: number,\n y: number,\n width: number,\n height: number,\n currRoot: location.XY,\n newRoot: location.CornerXY,\n): Box => {\n const first = { x, y };\n const second = { x: x + width, y: y + height };\n if (currRoot.x !== newRoot.x) {\n if (currRoot.x === \"center\") {\n first.x -= width / 2;\n second.x -= width / 2;\n } else {\n first.x -= width;\n second.x -= width;\n }\n }\n if (currRoot.y !== newRoot.y) {\n if (currRoot.y === \"center\") {\n first.y -= height / 2;\n second.y -= height / 2;\n } else {\n first.y -= height;\n second.y -= height;\n }\n }\n return construct(first, second, undefined, undefined, newRoot);\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nimport { dimensions, xy, type Dimensions, numberCouple } from \"@/spatial/base\";\n\nexport { dimensions, type Dimensions };\n\nexport const signed = z.object({ signedWidth: z.number(), signedHeight: z.number() });\nexport const crude = z.union([dimensions, signed, xy, numberCouple]);\nexport type Crude = z.infer<typeof crude>;\n\nexport const ZERO = { width: 0, height: 0 };\nexport const DECIMAL = { width: 1, height: 1 };\n\nexport const construct = (width: number | Crude, height?: number): Dimensions => {\n if (typeof width === \"number\") return { width, height: height ?? width };\n if (Array.isArray(width)) return { width: width[0], height: width[1] };\n if (\"x\" in width) return { width: width.x, height: width.y };\n if (\"signedWidth\" in width)\n return { width: width.signedWidth, height: width.signedHeight };\n return { ...width };\n};\n\nexport type Signed = z.infer<typeof signed>;\n\nexport const equals = (ca: Crude, cb?: Crude | null): boolean => {\n if (cb == null) return false;\n const a = construct(ca);\n const b = construct(cb);\n return a.width === b.width && a.height === b.height;\n};\n\nexport const swap = (ca: Crude): Dimensions => {\n const a = construct(ca);\n return { width: a.height, height: a.width };\n};\n\nexport const svgViewBox = (ca: Crude): string => {\n const a = construct(ca);\n return `0 0 ${a.width} ${a.height}`;\n};\n\nexport const couple = (ca: Crude): [number, number] => {\n const a = construct(ca);\n return [a.width, a.height];\n};\n\nexport const max = (crude: Crude[]): Dimensions => ({\n width: Math.max(...crude.map((c) => construct(c).width)),\n height: Math.max(...crude.map((c) => construct(c).height)),\n});\n\nexport const min = (crude: Crude[]): Dimensions => ({\n width: Math.min(...crude.map((c) => construct(c).width)),\n height: Math.min(...crude.map((c) => construct(c).height)),\n});\n\nexport const scale = (ca: Crude, factor: number): Dimensions => {\n const a = construct(ca);\n return { width: a.width * factor, height: a.height * factor };\n}","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nexport const clamp = (value: number, min?: number, max?: number): number => {\n if (min != null) value = Math.max(value, min);\n if (max != null) value = Math.min(value, max);\n return value;\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nimport { clamp } from \"@/clamp\";\nimport * as bounds from \"@/spatial/bounds/bounds\";\nimport { type Box, isBox } from \"@/spatial/box/box\";\nimport * as box from \"@/spatial/box/box\";\nimport type * as dims from \"@/spatial/dimensions/dimensions\";\nimport * as location from \"@/spatial/location/location\";\nimport * as xy from \"@/spatial/xy/xy\";\n\nexport const crudeXYTransform = z.object({ offset: xy.crudeZ, scale: xy.crudeZ });\n\nexport type XYTransformT = z.infer<typeof crudeXYTransform>;\n\nexport type BoundVariant = \"domain\" | \"range\";\n\ntype ValueType = \"position\" | \"dimension\";\n\ntype Operation = (\n currScale: bounds.Bounds | null,\n type: ValueType,\n number: number,\n reverse: boolean,\n) => OperationReturn;\n\ntype OperationReturn = [bounds.Bounds | null, number];\n\ninterface TypedOperation extends Operation {\n type: \"translate\" | \"magnify\" | \"scale\" | \"invert\" | \"clamp\" | \"re-bound\";\n}\n\nconst curriedTranslate =\n (translate: number): Operation =>\n (currScale, type, v, reverse) => {\n if (type === \"dimension\") return [currScale, v];\n return [currScale, reverse ? v - translate : v + translate];\n };\n\nconst curriedMagnify =\n (magnify: number): Operation =>\n (currScale, _type, v, reverse) => [currScale, reverse ? v / magnify : v * magnify];\n\nconst curriedScale =\n (bound: bounds.Bounds): Operation =>\n (currScale, type, v) => {\n if (currScale === null) return [bound, v];\n const { lower: prevLower, upper: prevUpper } = currScale;\n const { lower: nextLower, upper: nextUpper } = bound;\n const prevRange = prevUpper - prevLower;\n const nextRange = nextUpper - nextLower;\n if (type === \"dimension\") return [bound, v * (nextRange / prevRange)];\n const nextV = (v - prevLower) * (nextRange / prevRange) + nextLower;\n return [bound, nextV];\n };\n\nconst curriedReBound =\n (bound: bounds.Bounds): Operation =>\n (currScale, type, v) => [bound, v];\n\nconst curriedInvert = (): Operation => (currScale, type, v) => {\n if (currScale === null) throw new Error(\"cannot invert without bounds\");\n if (type === \"dimension\") return [currScale, v];\n const { lower, upper } = currScale;\n return [currScale, upper - (v - lower)];\n};\n\nconst curriedClamp =\n (bound: bounds.Bounds): Operation =>\n (currScale, _, v) => {\n const { lower, upper } = bound;\n v = clamp(v, lower, upper);\n return [currScale, v];\n };\n\nexport class Scale {\n ops: TypedOperation[] = [];\n currBounds: bounds.Bounds | null = null;\n currType: ValueType | null = null;\n private reversed = false;\n\n constructor() {\n this.ops = [];\n }\n\n static translate(value: number): Scale {\n return new Scale().translate(value);\n }\n\n static magnify(value: number): Scale {\n return new Scale().magnify(value);\n }\n\n static scale(lowerOrBound: number | bounds.Bounds, upper?: number): Scale {\n return new Scale().scale(lowerOrBound, upper);\n }\n\n translate(value: number): Scale {\n const next = this.new();\n const f = curriedTranslate(value) as TypedOperation;\n f.type = \"translate\";\n next.ops.push(f);\n return next;\n }\n\n magnify(value: number): Scale {\n const next = this.new();\n const f = curriedMagnify(value) as TypedOperation;\n f.type = \"magnify\";\n next.ops.push(f);\n return next;\n }\n\n scale(lowerOrBound: number | bounds.Bounds, upper?: number): Scale {\n const b = bounds.construct(lowerOrBound, upper);\n const next = this.new();\n const f = curriedScale(b) as TypedOperation;\n f.type = \"scale\";\n next.ops.push(f);\n return next;\n }\n\n clamp(lowerOrBound: number | bounds.Bounds, upper?: number): Scale {\n const b = bounds.construct(lowerOrBound, upper);\n const next = this.new();\n const f = curriedClamp(b) as TypedOperation;\n f.type = \"clamp\";\n next.ops.push(f);\n return next;\n }\n\n reBound(lowerOrBound: number | bounds.Bounds, upper?: number): Scale {\n const b = bounds.construct(lowerOrBound, upper);\n const next = this.new();\n const f = curriedReBound(b) as TypedOperation;\n f.type = \"re-bound\";\n next.ops.push(f);\n return next;\n }\n\n invert(): Scale {\n const f = curriedInvert() as TypedOperation;\n f.type = \"invert\";\n const next = this.new();\n next.ops.push(f);\n return next;\n }\n\n pos(v: number): number {\n return this.exec(\"position\", v);\n }\n\n dim(v: number): number {\n return this.exec(\"dimension\", v);\n }\n\n private new(): Scale {\n const scale = new Scale();\n scale.ops = this.ops.slice();\n scale.reversed = this.reversed;\n return scale;\n }\n\n private exec(vt: ValueType, v: number): number {\n this.currBounds = null;\n return this.ops.reduce<OperationReturn>(\n ([b, v]: OperationReturn, op: Operation): OperationReturn =>\n op(b, vt, v, this.reversed),\n [null, v],\n )[1];\n }\n\n reverse(): Scale {\n const scale = this.new();\n scale.ops.reverse();\n // Switch the order of the operations to place scale operation 'BEFORE' the subsequent\n // non - scale operations for example, if we have a reversed [scale A, scale B,\n // translate A, magnify, translate B, scale C] we want to reverse it to [scale C,\n // scale B, translate B, magnify, translate A, scale A]\n const swaps: Array<[number, number]> = [];\n scale.ops.forEach((op, i) => {\n if (op.type === \"scale\" || swaps.some(([low, high]) => i >= low && i <= high))\n return;\n const nextScale = scale.ops.findIndex((op, j) => op.type === \"scale\" && j > i);\n if (nextScale === -1) return;\n swaps.push([i, nextScale]);\n });\n swaps.forEach(([low, high]) => {\n const s = scale.ops.slice(low, high);\n s.unshift(scale.ops[high]);\n scale.ops.splice(low, high - low + 1, ...s);\n });\n scale.reversed = !scale.reversed;\n return scale;\n }\n\n static readonly IDENTITY = new Scale();\n}\n\nexport const xyScaleToTransform = (scale: XY): XYTransformT => ({\n scale: {\n x: scale.x.dim(1),\n y: scale.y.dim(1),\n },\n offset: {\n x: scale.x.pos(0),\n y: scale.y.pos(0),\n },\n});\n\nexport class XY {\n x: Scale;\n y: Scale;\n currRoot: location.CornerXY | null;\n\n constructor(\n x: Scale = new Scale(),\n y: Scale = new Scale(),\n root: location.CornerXY | null = null,\n ) {\n this.x = x;\n this.y = y;\n this.currRoot = root;\n }\n\n static translate(xy: number | xy.XY, y?: number): XY {\n return new XY().translate(xy, y);\n }\n\n static translateX(x: number): XY {\n return new XY().translateX(x);\n }\n\n static translateY(y: number): XY {\n return new XY().translateY(y);\n }\n\n static clamp(box: Box): XY {\n return new XY().clamp(box);\n }\n\n static magnify(xy: xy.XY): XY {\n return new XY().magnify(xy);\n }\n\n static scale(box: dims.Dimensions | Box): XY {\n return new XY().scale(box);\n }\n\n static reBound(box: Box): XY {\n return new XY().reBound(box);\n }\n\n translate(cp: number | xy.Crude, y?: number): XY {\n const _xy = xy.construct(cp, y);\n const next = this.copy();\n next.x = this.x.translate(_xy.x);\n next.y = this.y.translate(_xy.y);\n return next;\n }\n\n translateX(x: number): XY {\n const next = this.copy();\n next.x = this.x.translate(x);\n return next;\n }\n\n translateY(y: number): XY {\n const next = this.copy();\n next.y = this.y.translate(y);\n return next;\n }\n\n magnify(xy: xy.XY): XY {\n const next = this.copy();\n next.x = this.x.magnify(xy.x);\n next.y = this.y.magnify(xy.y);\n return next;\n }\n\n scale(b: Box | dims.Dimensions): XY {\n const next = this.copy();\n if (isBox(b)) {\n const prevRoot = this.currRoot;\n next.currRoot = b.root;\n if (prevRoot != null && !location.xyEquals(prevRoot, b.root)) {\n if (prevRoot.x !== b.root.x) next.x = next.x.invert();\n if (prevRoot.y !== b.root.y) next.y = next.y.invert();\n }\n next.x = next.x.scale(box.xBounds(b));\n next.y = next.y.scale(box.yBounds(b));\n return next;\n }\n next.x = next.x.scale(b.width);\n next.y = next.y.scale(b.height);\n return next;\n }\n\n reBound(b: Box): XY {\n const next = this.copy();\n next.x = this.x.reBound(box.xBounds(b));\n next.y = this.y.reBound(box.yBounds(b));\n return next;\n }\n\n clamp(b: Box): XY {\n const next = this.copy();\n next.x = this.x.clamp(box.xBounds(b));\n next.y = this.y.clamp(box.yBounds(b));\n return next;\n }\n\n copy(): XY {\n const n = new XY();\n n.currRoot = this.currRoot;\n n.x = this.x;\n n.y = this.y;\n return n;\n }\n\n reverse(): XY {\n const next = this.copy();\n next.x = this.x.reverse();\n next.y = this.y.reverse();\n return next;\n }\n\n pos(xy: xy.XY): xy.XY {\n return { x: this.x.pos(xy.x), y: this.y.pos(xy.y) };\n }\n\n box(b: Box): Box {\n return box.construct(\n this.pos(b.one),\n this.pos(b.two),\n 0,\n 0,\n this.currRoot ?? b.root,\n );\n }\n\n static readonly IDENTITY = new XY();\n}\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Alignment, type XLocation, type YLocation } from \"@/spatial/base\";\nimport { box } from \"@/spatial/box\";\nimport { direction } from \"@/spatial/direction\";\nimport { location } from \"@/spatial/location\";\nimport { xy } from \"@/spatial/xy\";\n\nexport const posititonSoVisible = (target: HTMLElement, p: xy.XY): [xy.XY, boolean] => {\n const { width, height } = target.getBoundingClientRect();\n const { innerWidth, innerHeight } = window;\n let changed = false;\n let nextXY = xy.construct(p);\n if (p.x + width > innerWidth) {\n nextXY = xy.translateX(nextXY, -width);\n changed = true;\n }\n if (p.y + height > innerHeight) {\n nextXY = xy.translateY(nextXY, -height);\n changed = true;\n }\n return [nextXY, changed];\n};\n\nexport interface DialogProps {\n container: box.Crude;\n target: box.Crude;\n dialog: box.Crude;\n alignments?: Alignment[];\n initial?: location.Outer | Partial<location.XY> | location.XY;\n prefer?: Array<location.Outer | Partial<location.XY> | location.XY>;\n disable?: Array<location.Location | Partial<location.XY>>;\n}\n\nconst parseLocationOptions = (\n initial?: location.Outer | Partial<location.XY> | location.XY,\n): Partial<location.XY> => {\n if (initial == null) return { x: undefined, y: undefined };\n const parsedXYLoc = location.xy.safeParse(initial);\n if (parsedXYLoc.success) return parsedXYLoc.data;\n const parsedLoc = location.location.safeParse(initial);\n if (parsedLoc.success) {\n const isX = direction.construct(parsedLoc.data) === \"x\";\n return isX\n ? { x: parsedLoc.data as XLocation, y: undefined }\n : { x: undefined, y: parsedLoc.data as YLocation };\n }\n return initial as Partial<location.XY>;\n};\n\nexport interface DialogReturn {\n location: location.XY;\n adjustedDialog: box.Box;\n}\n\nexport const dialog = ({\n container: containerCrude,\n target: targetCrude,\n dialog: dialogCrude,\n initial,\n prefer,\n alignments = [\"start\"],\n disable = [],\n}: DialogProps): DialogReturn => {\n const initialLocs = parseLocationOptions(initial);\n\n let options = location.XY_LOCATIONS;\n if (prefer != null) {\n const parsedPrefer = prefer.map((p) => parseLocationOptions(p));\n options = options.slice().sort((a, b) => {\n const hasPreferA = parsedPrefer.findIndex((p) => location.xyMatches(a, p));\n const hasPreferB = parsedPrefer.findIndex((p) => location.xyMatches(b, p));\n if (hasPreferA > -1 && hasPreferB > -1) return hasPreferA - hasPreferB;\n if (hasPreferA > -1) return -1;\n if (hasPreferB > -1) return 1;\n return 0;\n });\n }\n const mappedOptions = options\n .filter(\n (l) =>\n !location.xyEquals(l, location.CENTER) &&\n (initialLocs.x == null || l.x === initialLocs.x) &&\n (initialLocs.y == null || l.y === initialLocs.y) &&\n !disable.some((d) => location.xyMatches(l, d)),\n )\n .map((l) => alignments?.map((a) => [l, a]))\n .flat() as Array<[location.XY, Alignment]>;\n\n const container = box.construct(containerCrude);\n const target = box.construct(targetCrude);\n const dialog = box.construct(dialogCrude);\n\n // maximum value of a number in js\n let bestOptionArea = -Infinity;\n const res: DialogReturn = { location: location.CENTER, adjustedDialog: dialog };\n mappedOptions.forEach(([option, alignment]) => {\n const [adjustedBox, area] = evaluateOption({\n option,\n alignment,\n container,\n target,\n dialog,\n });\n if (area > bestOptionArea) {\n bestOptionArea = area;\n res.location = option;\n res.adjustedDialog = adjustedBox;\n }\n });\n\n return res;\n};\n\ninterface EvaluateOptionProps {\n option: location.XY;\n alignment: Alignment;\n container: box.Box;\n target: box.Box;\n dialog: box.Box;\n}\n\nconst evaluateOption = ({\n option,\n alignment,\n container,\n target,\n dialog,\n}: EvaluateOptionProps): [box.Box, number] => {\n const root = getRoot(option, alignment);\n const targetPoint = box.xyLoc(target, option);\n const dialogBox = box.constructWithAlternateRoot(\n targetPoint.x,\n targetPoint.y,\n box.width(dialog),\n box.height(dialog),\n root,\n location.TOP_LEFT,\n );\n const area = box.area(box.intersect(dialogBox, container));\n return [dialogBox, area];\n};\n\nconst X_ALIGNMENT_MAP: Record<Alignment, location.X | location.Center> = {\n start: \"left\",\n center: \"center\",\n end: \"right\",\n};\n\nconst Y_ALIGNMENT_MAP: Record<Alignment, location.Y | location.Center> = {\n start: \"bottom\",\n center: \"center\",\n end: \"top\",\n};\n\nexport const getRoot = (option: location.XY, alignment: Alignment): location.XY => {\n const out: location.XY = { x: \"center\", y: \"center\" };\n if (option.y !== \"center\") {\n out.y = location.swap(option.y) as location.Y;\n const swapper = option.x === \"left\" ? location.swap : (v: location.Location) => v;\n out.x = swapper(X_ALIGNMENT_MAP[alignment]) as location.X;\n } else {\n out.x = location.swap(option.x) as location.X;\n out.y = Y_ALIGNMENT_MAP[alignment];\n }\n return out;\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nimport { type Stringer } from \"@/primitive\";\nimport { addSamples } from \"@/telem/series\";\n\nexport type TZInfo = \"UTC\" | \"local\";\n\nexport type TimeStampStringFormat =\n | \"ISO\"\n | \"ISODate\"\n | \"ISOTime\"\n | \"time\"\n | \"preciseTime\"\n | \"date\"\n | \"preciseDate\"\n | \"shortDate\"\n | \"dateTime\";\n\nexport type DateComponents = [number?, number?, number?];\n\nconst remainder = <T extends TimeStamp | TimeSpan>(\n value: T,\n divisor: TimeSpan | TimeStamp,\n): T => {\n const ts = new TimeStamp(divisor);\n if (\n ![\n TimeSpan.DAY,\n TimeSpan.HOUR,\n TimeSpan.MINUTE,\n TimeSpan.SECOND,\n TimeSpan.MILLISECOND,\n TimeSpan.MICROSECOND,\n TimeSpan.NANOSECOND,\n ].some((s) => s.equals(ts))\n ) {\n throw new Error(\n \"Invalid argument for remainder. Must be an even TimeSpan or Timestamp\",\n );\n }\n const v = value.valueOf() % ts.valueOf();\n return (value instanceof TimeStamp ? new TimeStamp(v) : new TimeSpan(v)) as T;\n};\n\n/**\n * Represents a UTC timestamp. Synnax uses a nanosecond precision int64 timestamp.\n *\n * DISCLAIMER: JavaScript stores all numbers as 64-bit floating point numbers, so we expect a\n * expect a precision drop from nanoseconds to quarter microseconds when communicating\n * with the server. If this is a problem, please file an issue with the Synnax team.\n * Caveat emptor.\n *\n * @param value - The timestamp value to parse. This can be any of the following:\n *\n * 1. A number representing the number of milliseconds since the Unix epoch.\n * 2. A javascript Date object.\n * 3. An array of numbers satisfying the DateComponents type, where the first element is the\n * year, the second is the month, and the third is the day. To incraase resolution\n * when using this method, use the add method. It's important to note that this initializes\n * a timestamp at midnight UTC, regardless of the timezone specified.\n * 4. An ISO compliant date or date time string. The time zone component is ignored.\n *\n * @param tzInfo - The timezone to use when parsing the timestamp. This can be either \"UTC\" or\n * \"local\". This parameter is ignored if the value is a Date object or a DateComponents array.\n *\n * @example ts = new TimeStamp(1 * TimeSpan.HOUR) // 1 hour after the Unix epoch\n * @example ts = new TimeStamp([2021, 1, 1]) // 1/1/2021 at midnight UTC\n * @example ts = new TimeStamp([2021, 1, 1]).add(1 * TimeSpan.HOUR) // 1/1/2021 at 1am UTC\n * @example ts = new TimeStamp(\"2021-01-01T12:30:00Z\") // 1/1/2021 at 12:30pm UTC\n */\nexport class TimeStamp implements Stringer {\n private readonly value: bigint;\n readonly encodeValue: true = true;\n\n constructor(value?: CrudeTimeStamp, tzInfo: TZInfo = \"UTC\") {\n if (value == null) this.value = TimeStamp.now().valueOf();\n else if (value instanceof Date)\n this.value = BigInt(value.getTime()) * TimeStamp.MILLISECOND.valueOf();\n else if (typeof value === \"string\")\n this.value = TimeStamp.parseDateTimeString(value, tzInfo).valueOf();\n else if (Array.isArray(value)) this.value = TimeStamp.parseDate(value);\n else {\n let offset: bigint = BigInt(0);\n if (value instanceof Number) value = value.valueOf();\n if (tzInfo === \"local\") offset = TimeStamp.utcOffset.valueOf();\n if (typeof value === \"number\") {\n if (isFinite(value)) value = Math.trunc(value);\n else {\n if (isNaN(value)) value = 0;\n if (value === Infinity) value = TimeStamp.MAX;\n else value = TimeStamp.MIN;\n }\n }\n this.value = BigInt(value.valueOf()) + offset;\n }\n }\n\n private static parseDate([year = 1970, month = 1, day = 1]: DateComponents): bigint {\n const date = new Date(year, month - 1, day, 0, 0, 0, 0);\n // We truncate here to only get the date component regardless of the time zone.\n return new TimeStamp(BigInt(date.getTime()) * TimeStamp.MILLISECOND.valueOf())\n .truncate(TimeStamp.DAY)\n .valueOf();\n }\n\n encode(): string {\n return this.value.toString();\n }\n\n valueOf(): bigint {\n return this.value;\n }\n\n private static parseTimeString(time: string, tzInfo: TZInfo = \"UTC\"): bigint {\n const [hours, minutes, mbeSeconds] = time.split(\":\");\n let seconds = \"00\";\n let milliseconds: string | undefined = \"00\";\n if (mbeSeconds != null) [seconds, milliseconds] = mbeSeconds.split(\".\");\n let base = TimeStamp.hours(parseInt(hours ?? \"00\", 10))\n .add(TimeStamp.minutes(parseInt(minutes ?? \"00\", 10)))\n .add(TimeStamp.seconds(parseInt(seconds ?? \"00\", 10)))\n .add(TimeStamp.milliseconds(parseInt(milliseconds ?? \"00\", 10)));\n if (tzInfo === \"local\") base = base.add(TimeStamp.utcOffset);\n return base.valueOf();\n }\n\n private static parseDateTimeString(str: string, tzInfo: TZInfo = \"UTC\"): bigint {\n if (!str.includes(\"/\") && !str.includes(\"-\"))\n return TimeStamp.parseTimeString(str, tzInfo);\n const d = new Date(str);\n // Essential to note that this makes the date midnight in UTC! Not local!\n // As a result, we need to add the tzInfo offset back in.\n if (!str.includes(\":\")) d.setUTCHours(0, 0, 0, 0);\n return new TimeStamp(\n BigInt(d.getTime()) * TimeStamp.MILLISECOND.valueOf(),\n tzInfo,\n ).valueOf();\n }\n\n fString(format: TimeStampStringFormat = \"ISO\", tzInfo: TZInfo = \"UTC\"): string {\n switch (format) {\n case \"ISODate\":\n return this.toISOString(tzInfo).slice(0, 10);\n case \"ISOTime\":\n return this.toISOString(tzInfo).slice(11, 23);\n case \"time\":\n return this.timeString(false, tzInfo);\n case \"preciseTime\":\n return this.timeString(true, tzInfo);\n case \"date\":\n return this.dateString(tzInfo);\n case \"preciseDate\":\n return `${this.dateString(tzInfo)} ${this.timeString(true, tzInfo)}`;\n case \"dateTime\":\n return `${this.dateString(tzInfo)} ${this.timeString(false, tzInfo)}`;\n default:\n return this.toISOString(tzInfo);\n }\n }\n\n private toISOString(tzInfo: TZInfo = \"UTC\"): string {\n if (tzInfo === \"UTC\") return this.date().toISOString();\n return this.sub(TimeStamp.utcOffset).date().toISOString();\n }\n\n private timeString(milliseconds: boolean = false, tzInfo: TZInfo = \"UTC\"): string {\n const iso = this.toISOString(tzInfo);\n return milliseconds ? iso.slice(11, 23) : iso.slice(11, 19);\n }\n\n private dateString(tzInfo: TZInfo = \"UTC\"): string {\n const date = this.date();\n const month = date.toLocaleString(\"default\", { month: \"short\" });\n const day = date.toLocaleString(\"default\", { day: \"numeric\" });\n return `${month} ${day}`;\n }\n\n static get utcOffset(): TimeSpan {\n return new TimeSpan(\n BigInt(new Date().getTimezoneOffset()) * TimeStamp.MINUTE.valueOf(),\n );\n }\n\n /**\n * @returns a TimeSpan representing the amount time elapsed since\n * the other timestamp.\n * @param other - The other timestamp.\n */\n static since(other: TimeStamp): TimeSpan {\n return new TimeStamp().span(other);\n }\n\n /** @returns A JavaScript Date object representing the TimeStamp. */\n date(): Date {\n return new Date(this.milliseconds());\n }\n\n /**\n * Checks if the TimeStamp is equal to another TimeStamp.\n *\n * @param other - The other TimeStamp to compare to.\n * @returns True if the TimeStamps are equal, false otherwise.\n */\n equals(other: CrudeTimeStamp): boolean {\n return this.valueOf() === new TimeStamp(other).valueOf();\n }\n\n /**\n * Creates a TimeSpan representing the duration between the two timestamps.\n *\n * @param other - The other TimeStamp to compare to.\n * @returns A TimeSpan representing the duration between the two timestamps.\n * The span is guaranteed to be positive.\n */\n span(other: CrudeTimeStamp): TimeSpan {\n return this.range(other).span;\n }\n\n /**\n * Creates a TimeRange spanning the given TimeStamp.\n *\n * @param other - The other TimeStamp to compare to.\n * @returns A TimeRange spanning the given TimeStamp that is guaranteed to be\n * valid, regardless of the TimeStamp order.\n */\n range(other: CrudeTimeStamp): TimeRange {\n return new TimeRange(this, other).makeValid();\n }\n\n /**\n * Creates a TimeRange starting at the TimeStamp and spanning the given\n * TimeSpan.\n *\n * @param other - The TimeSpan to span.\n * @returns A TimeRange starting at the TimeStamp and spanning the given\n * TimeSpan. The TimeRange is guaranteed to be valid.\n */\n spanRange(other: CrudeTimeSpan): TimeRange {\n return this.range(this.add(other)).makeValid();\n }\n\n /**\n * Checks if the TimeStamp represents the unix epoch.\n *\n * @returns True if the TimeStamp represents the unix epoch, false otherwise.\n */\n get isZero(): boolean {\n return this.valueOf() === BigInt(0);\n }\n\n /**\n * Checks if the TimeStamp is after the given TimeStamp.\n *\n * @param other - The other TimeStamp to compare to.\n * @returns True if the TimeStamp is after the given TimeStamp, false\n * otherwise.\n */\n after(other: CrudeTimeStamp): boolean {\n return this.valueOf() > new TimeStamp(other).valueOf();\n }\n\n /**\n * Checks if the TimeStamp is after or equal to the given TimeStamp.\n *\n * @param other - The other TimeStamp to compare to.\n * @returns True if the TimeStamp is after or equal to the given TimeStamp,\n * false otherwise.\n */\n afterEq(other: CrudeTimeStamp): boolean {\n return this.valueOf() >= new TimeStamp(other).valueOf();\n }\n\n /**\n * Checks if the TimeStamp is before the given TimeStamp.\n *\n * @param other - The other TimeStamp to compare to.\n * @returns True if the TimeStamp is before the given TimeStamp, false\n * otherwise.\n */\n before(other: CrudeTimeStamp): boolean {\n return this.valueOf() < new TimeStamp(other).valueOf();\n }\n\n /**\n * Checks if TimeStamp is before or equal to the current timestamp.\n *\n * @param other - The other TimeStamp to compare to.\n * @returns True if TimeStamp is before or equal to the current timestamp,\n * false otherwise.\n */\n beforeEq(other: CrudeTimeStamp): boolean {\n return this.valueOf() <= new TimeStamp(other).valueOf();\n }\n\n /**\n * Adds a TimeSpan to the TimeStamp.\n *\n * @param span - The TimeSpan to add.\n * @returns A new TimeStamp representing the sum of the TimeStamp and\n * TimeSpan.\n */\n add(span: CrudeTimeSpan): TimeStamp {\n return new TimeStamp(this.valueOf() + BigInt(span.valueOf()));\n }\n\n /**\n * Subtracts a TimeSpan from the TimeStamp.\n *\n * @param span - The TimeSpan to subtract.\n * @returns A new TimeStamp representing the difference of the TimeStamp and\n * TimeSpan.\n */\n sub(span: CrudeTimeSpan): TimeStamp {\n return new TimeStamp(this.valueOf() - BigInt(span.valueOf()));\n }\n\n /**\n * @returns The number of milliseconds since the unix epoch.\n */\n milliseconds(): number {\n return Number(this.valueOf() / TimeStamp.MILLISECOND.valueOf());\n }\n\n toString(): string {\n return this.date().toISOString();\n }\n\n /**\n * @returns A new TimeStamp that is the remainder of the TimeStamp divided by the\n * given span. This is useful in cases where you want only part of a TimeStamp's value\n * i.e. the hours, minutes, seconds, milliseconds, microseconds, and nanoseconds but\n * not the days, years, etc.\n *\n * @param divisor - The TimeSpan to divide by. Must be an even TimeSpan or TimeStamp. Even\n * means it must be a day, hour, minute, second, millisecond, or microsecond, etc.\n *\n * @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day\n */\n remainder(divisor: TimeSpan | TimeStamp): TimeStamp {\n return remainder(this, divisor);\n }\n\n /** @returns true if the day portion TimeStamp is today, false otherwise. */\n get isToday(): boolean {\n return this.truncate(TimeSpan.DAY).equals(TimeStamp.now().truncate(TimeSpan.DAY));\n }\n\n truncate(span: TimeSpan | TimeStamp): TimeStamp {\n return this.sub(this.remainder(span));\n }\n\n /**\n * @returns A new TimeStamp representing the current time in UTC. It's important to\n * note that this TimeStamp is only accurate to the millisecond level (that's the best\n * JavaScript can do).\n */\n static now(): TimeStamp {\n return new TimeStamp(new Date());\n }\n\n static max(...timestamps: CrudeTimeStamp[]): TimeStamp {\n let max = TimeStamp.MIN;\n for (const ts of timestamps) {\n const t = new TimeStamp(ts);\n if (t.after(max)) max = t;\n }\n return max;\n }\n\n static min(...timestamps: CrudeTimeStamp[]): TimeStamp {\n let min = TimeStamp.MAX;\n for (const ts of timestamps) {\n const t = new TimeStamp(ts);\n if (t.before(min)) min = t;\n }\n return min;\n }\n\n /** @returns a new TimeStamp n nanoseconds after the unix epoch */\n static nanoseconds(value: number): TimeStamp {\n return new TimeStamp(value);\n }\n\n /* One nanosecond after the unix epoch */\n static readonly NANOSECOND = TimeStamp.nanoseconds(1);\n\n /** @returns a new TimeStamp n microseconds after the unix epoch */\n static microseconds(value: number): TimeStamp {\n return TimeStamp.nanoseconds(value * 1000);\n }\n\n /** One microsecond after the unix epoch */\n static readonly MICROSECOND = TimeStamp.microseconds(1);\n\n /** @returns a new TimeStamp n milliseconds after the unix epoch */\n static milliseconds(value: number): TimeStamp {\n return TimeStamp.microseconds(value * 1000);\n }\n\n /** One millisecond after the unix epoch */\n static readonly MILLISECOND = TimeStamp.milliseconds(1);\n\n /** @returns a new TimeStamp n seconds after the unix epoch */\n static seconds(value: number): TimeStamp {\n return TimeStamp.milliseconds(value * 1000);\n }\n\n /** One second after the unix epoch */\n static readonly SECOND = TimeStamp.seconds(1);\n\n /** @returns a new TimeStamp n minutes after the unix epoch */\n static minutes(value: number): TimeStamp {\n return TimeStamp.seconds(value * 60);\n }\n\n /** One minute after the unix epoch */\n static readonly MINUTE = TimeStamp.minutes(1);\n\n /** @returns a new TimeStamp n hours after the unix epoch */\n static hours(value: number): TimeStamp {\n return TimeStamp.minutes(value * 60);\n }\n\n /** One hour after the unix epoch */\n static readonly HOUR = TimeStamp.hours(1);\n\n /** @returns a new TimeStamp n days after the unix epoch */\n static days(value: number): TimeStamp {\n return TimeStamp.hours(value * 24);\n }\n\n /** One day after the unix epoch */\n static readonly DAY = TimeStamp.days(1);\n\n /** The maximum possible value for a timestamp */\n static readonly MAX = new TimeStamp((1n << 63n) - 1n);\n\n /** The minimum possible value for a timestamp */\n static readonly MIN = new TimeStamp(0);\n\n /** The unix epoch */\n static readonly ZERO = new TimeStamp(0);\n\n /** A zod schema for validating timestamps */\n static readonly z = z.union([\n z.object({ value: z.bigint() }).transform((v) => new TimeStamp(v.value)),\n z.string().transform((n) => new TimeStamp(BigInt(n))),\n z.instanceof(Number).transform((n) => new TimeStamp(n)),\n z.number().transform((n) => new TimeStamp(n)),\n z.instanceof(TimeStamp),\n ]);\n}\n\n/** TimeSpan represents a nanosecond precision duration. */\nexport class TimeSpan implements Stringer {\n private readonly value: bigint;\n readonly encodeValue: true = true;\n\n constructor(value: CrudeTimeSpan) {\n if (typeof value === \"number\") value = Math.trunc(value.valueOf());\n this.value = BigInt(value.valueOf());\n }\n\n encode(): string {\n return this.value.toString();\n }\n\n valueOf(): bigint {\n return this.value;\n }\n\n lessThan(other: CrudeTimeSpan): boolean {\n return this.valueOf() < new TimeSpan(other).valueOf();\n }\n\n greaterThan(other: CrudeTimeSpan): boolean {\n return this.valueOf() > new TimeSpan(other).valueOf();\n }\n\n lessThanOrEqual(other: CrudeTimeSpan): boolean {\n return this.valueOf() <= new TimeSpan(other).valueOf();\n }\n\n greaterThanOrEqual(other: CrudeTimeSpan): boolean {\n return this.valueOf() >= new TimeSpan(other).valueOf();\n }\n\n remainder(divisor: TimeSpan): TimeSpan {\n return remainder(this, divisor);\n }\n\n truncate(span: TimeSpan): TimeSpan {\n return new TimeSpan(\n BigInt(Math.trunc(Number(this.valueOf() / span.valueOf()))) * span.valueOf(),\n );\n }\n\n toString(): string {\n const totalDays = this.truncate(TimeSpan.DAY);\n const totalHours = this.truncate(TimeSpan.HOUR);\n const totalMinutes = this.truncate(TimeSpan.MINUTE);\n const totalSeconds = this.truncate(TimeSpan.SECOND);\n const totalMilliseconds = this.truncate(TimeSpan.MILLISECOND);\n const totalMicroseconds = this.truncate(TimeSpan.MICROSECOND);\n const totalNanoseconds = this.truncate(TimeSpan.NANOSECOND);\n const days = totalDays;\n const hours = totalHours.sub(totalDays);\n const minutes = totalMinutes.sub(totalHours);\n const seconds = totalSeconds.sub(totalMinutes);\n const milliseconds = totalMilliseconds.sub(totalSeconds);\n const microseconds = totalMicroseconds.sub(totalMilliseconds);\n const nanoseconds = totalNanoseconds.sub(totalMicroseconds);\n\n let str = \"\";\n if (!days.isZero) str += `${days.days}d `;\n if (!hours.isZero) str += `${hours.hours}h `;\n if (!minutes.isZero) str += `${minutes.minutes}m `;\n if (!seconds.isZero) str += `${seconds.seconds}s `;\n if (!milliseconds.isZero) str += `${milliseconds.milliseconds}ms `;\n if (!microseconds.isZero) str += `${microseconds.microseconds}µs `;\n if (!nanoseconds.isZero) str += `${nanoseconds.nanoseconds}ns`;\n return str.trim();\n }\n\n /** @returns the decimal number of days in the timespan */\n get days(): number {\n return Number(this.valueOf() / TimeSpan.DAY.valueOf());\n }\n\n /** @returns the decimal number of hours in the timespan */\n get hours(): number {\n return Number(this.valueOf() / TimeSpan.HOUR.valueOf());\n }\n\n /** @returns the decimal number of minutes in the timespan */\n get minutes(): number {\n return Number(this.valueOf() / TimeSpan.MINUTE.valueOf());\n }\n\n /** @returns The number of seconds in the TimeSpan. */\n get seconds(): number {\n return Number(this.valueOf() / TimeSpan.SECOND.valueOf());\n }\n\n /** @returns The number of milliseconds in the TimeSpan. */\n get milliseconds(): number {\n return Number(this.valueOf() / TimeSpan.MILLISECOND.valueOf());\n }\n\n get microseconds(): number {\n return Number(this.valueOf() / TimeSpan.MICROSECOND.valueOf());\n }\n\n get nanoseconds(): number {\n return Number(this.valueOf());\n }\n\n /**\n * Checks if the TimeSpan represents a zero duration.\n *\n * @returns True if the TimeSpan represents a zero duration, false otherwise.\n */\n get isZero(): boolean {\n return this.valueOf() === BigInt(0);\n }\n\n /**\n * Checks if the TimeSpan is equal to another TimeSpan.\n *\n * @returns True if the TimeSpans are equal, false otherwise.\n */\n equals(other: CrudeTimeSpan): boolean {\n return this.valueOf() === new TimeSpan(other).valueOf();\n }\n\n /**\n * Adds a TimeSpan to the TimeSpan.\n *\n * @returns A new TimeSpan representing the sum of the two TimeSpans.\n */\n add(other: CrudeTimeSpan): TimeSpan {\n return new TimeSpan(this.valueOf() + new TimeSpan(other).valueOf());\n }\n\n /**\n * Creates a TimeSpan representing the duration between the two timestamps.\n *\n * @param other\n */\n sub(other: CrudeTimeSpan): TimeSpan {\n return new TimeSpan(this.valueOf() - new TimeSpan(other).valueOf());\n }\n\n /**\n * Creates a TimeSpan representing the given number of nanoseconds.\n *\n * @param value - The number of nanoseconds.\n * @returns A TimeSpan representing the given number of nanoseconds.\n */\n static nanoseconds(value: number = 1): TimeSpan {\n return new TimeSpan(value);\n }\n\n /** A nanosecond. */\n static readonly NANOSECOND = TimeSpan.nanoseconds(1);\n\n /**\n * Creates a TimeSpan representing the given number of microseconds.\n *\n * @param value - The number of microseconds.\n * @returns A TimeSpan representing the given number of microseconds.\n */\n static microseconds(value: number = 1): TimeSpan {\n return TimeSpan.nanoseconds(value * 1000);\n }\n\n /** A microsecond. */\n static readonly MICROSECOND = TimeSpan.microseconds(1);\n\n /**\n * Creates a TimeSpan representing the given number of milliseconds.\n *\n * @param value - The number of milliseconds.\n * @returns A TimeSpan representing the given number of milliseconds.\n */\n static milliseconds(value: number = 1): TimeSpan {\n return TimeSpan.microseconds(value * 1000);\n }\n\n /** A millisecond. */\n static readonly MILLISECOND = TimeSpan.milliseconds(1);\n\n /**\n * Creates a TimeSpan representing the given number of seconds.\n *\n * @param value - The number of seconds.\n * @returns A TimeSpan representing the given number of seconds.\n */\n static seconds(value: number = 1): TimeSpan {\n return TimeSpan.milliseconds(value * 1000);\n }\n\n /** A second. */\n static readonly SECOND = TimeSpan.seconds(1);\n\n /**\n * Creates a TimeSpan representing the given number of minutes.\n *\n * @param value - The number of minutes.\n * @returns A TimeSpan representing the given number of minutes.\n */\n static minutes(value: number): TimeSpan {\n return TimeSpan.seconds(value.valueOf() * 60);\n }\n\n /** A minute. */\n static readonly MINUTE = TimeSpan.minutes(1);\n\n /**\n * Creates a TimeSpan representing the given number of hours.\n *\n * @param value - The number of hours.\n * @returns A TimeSpan representing the given number of hours.\n */\n static hours(value: number): TimeSpan {\n return TimeSpan.minutes(value * 60);\n }\n\n /** Represents an hour. */\n static readonly HOUR = TimeSpan.hours(1);\n\n /**\n * Creates a TimeSpan representing the given number of days.\n *\n * @param value - The number of days.\n * @returns A TimeSpan representing the given number of days.\n */\n static days(value: number): TimeSpan {\n return TimeSpan.hours(value * 24);\n }\n\n /** Represents a day. */\n static readonly DAY = TimeSpan.days(1);\n\n /** The maximum possible value for a TimeSpan. */\n static readonly MAX = new TimeSpan((1n << 63n) - 1n);\n\n /** The minimum possible value for a TimeSpan. */\n static readonly MIN = new TimeSpan(0);\n\n /** The zero value for a TimeSpan. */\n static readonly ZERO = new TimeSpan(0);\n\n /** A zod schema for validating and transforming timespans */\n static readonly z = z.union([\n z.object({ value: z.bigint() }).transform((v) => new TimeSpan(v.value)),\n z.string().transform((n) => new TimeSpan(BigInt(n))),\n z.instanceof(Number).transform((n) => new TimeSpan(n)),\n z.number().transform((n) => new TimeSpan(n)),\n z.instanceof(TimeSpan),\n ]);\n}\n\n/** Rate represents a data rate in Hz. */\nexport class Rate extends Number implements Stringer {\n constructor(value: CrudeRate) {\n if (value instanceof Number) super(value.valueOf());\n else super(value);\n }\n\n /** @returns a pretty string representation of the rate in the format \"X Hz\". */\n toString(): string {\n return `${this.valueOf()} Hz`;\n }\n\n /** @returns The number of seconds in the Rate. */\n equals(other: CrudeRate): boolean {\n return this.valueOf() === new Rate(other).valueOf();\n }\n\n /**\n * Calculates the period of the Rate as a TimeSpan.\n *\n * @returns A TimeSpan representing the period of the Rate.\n */\n get period(): TimeSpan {\n return TimeSpan.seconds(1 / this.valueOf());\n }\n\n /**\n * Calculates the number of samples in the given TimeSpan at this rate.\n *\n * @param duration - The duration to calculate the sample count from.\n * @returns The number of samples in the given TimeSpan at this rate.\n */\n sampleCount(duration: CrudeTimeSpan): number {\n return new TimeSpan(duration).seconds * this.valueOf();\n }\n\n /**\n * Calculates the number of bytes in the given TimeSpan at this rate.\n *\n * @param span - The duration to calculate the byte count from.\n * @param density - The density of the data in bytes per sample.\n * @returns The number of bytes in the given TimeSpan at this rate.\n */\n byteCount(span: CrudeTimeSpan, density: CrudeDensity): number {\n return this.sampleCount(span) * new Density(density).valueOf();\n }\n\n /**\n * Calculates a TimeSpan given the number of samples at this rate.\n *\n * @param sampleCount - The number of samples in the span.\n * @returns A TimeSpan that corresponds to the given number of samples.\n */\n span(sampleCount: number): TimeSpan {\n return TimeSpan.seconds(sampleCount / this.valueOf());\n }\n\n /**\n * Calculates a TimeSpan given the number of bytes at this rate.\n *\n * @param size - The number of bytes in the span.\n * @param density - The density of the data in bytes per sample.\n * @returns A TimeSpan that corresponds to the given number of bytes.\n */\n byteSpan(size: Size, density: CrudeDensity): TimeSpan {\n return this.span(size.valueOf() / density.valueOf());\n }\n\n /**\n * Creates a Rate representing the given number of Hz.\n *\n * @param value - The number of Hz.\n * @returns A Rate representing the given number of Hz.\n */\n static hz(value: number): Rate {\n return new Rate(value);\n }\n\n /**\n * Creates a Rate representing the given number of kHz.\n *\n * @param value - The number of kHz.\n * @returns A Rate representing the given number of kHz.\n */\n static khz(value: number): Rate {\n return Rate.hz(value * 1000);\n }\n\n /** A zod schema for validating and transforming rates */\n static readonly z = z.union([\n z.number().transform((n) => new Rate(n)),\n z.instanceof(Number).transform((n) => new Rate(n)),\n z.instanceof(Rate),\n ]);\n}\n\n/** Density represents the number of bytes in a value. */\nexport class Density extends Number implements Stringer {\n /**\n * Creates a Density representing the given number of bytes per value.\n *\n * @class\n * @param value - The number of bytes per value.\n * @returns A Density representing the given number of bytes per value.\n */\n constructor(value: CrudeDensity) {\n if (value instanceof Number) super(value.valueOf());\n else super(value);\n }\n\n length(size: Size): number {\n return size.valueOf() / this.valueOf();\n }\n\n size(sampleCount: number): Size {\n return new Size(sampleCount * this.valueOf());\n }\n\n /** Unknown/Invalid Density. */\n static readonly UNKNOWN = new Density(0);\n /** 128 bits per value. */\n static readonly BIT128 = new Density(16);\n /** 64 bits per value. */\n static readonly BIT64 = new Density(8);\n /** 32 bits per value. */\n static readonly BIT32 = new Density(4);\n /** 16 bits per value. */\n static readonly BIT16 = new Density(2);\n /** 8 bits per value. */\n static readonly BIT8 = new Density(1);\n\n /** A zod schema for validating and transforming densities */\n static readonly z = z.union([\n z.number().transform((n) => new Density(n)),\n z.instanceof(Number).transform((n) => new Density(n)),\n z.instanceof(Density),\n ]);\n}\n\n/**\n * TimeRange is a range of time marked by a start and end timestamp. A TimeRange\n * is start inclusive and end exclusive.\n *\n * @property start - A TimeStamp representing the start of the range.\n * @property end - A Timestamp representing the end of the range.\n */\nexport class TimeRange implements Stringer {\n /**\n * The starting TimeStamp of the TimeRange.\n *\n * Note that this value is not guaranteed to be before or equal to the ending value.\n * To ensure that this is the case, call TimeRange.make_valid().\n *\n * In most cases, operations should treat start as inclusive.\n */\n start: TimeStamp;\n\n /**\n * The starting TimeStamp of the TimeRange.\n *\n * Note that this value is not guaranteed to be before or equal to the ending value.\n * To ensure that this is the case, call TimeRange.make_valid().\n *\n * In most cases, operations should treat end as exclusive.\n */\n end: TimeStamp;\n\n constructor(tr: CrudeTimeRange);\n\n constructor(start: CrudeTimeStamp, end: CrudeTimeStamp);\n\n /**\n * Creates a TimeRange from the given start and end TimeStamps.\n *\n * @param start - A TimeStamp representing the start of the range.\n * @param end - A TimeStamp representing the end of the range.\n */\n constructor(start: CrudeTimeStamp | CrudeTimeRange, end?: CrudeTimeStamp) {\n if (typeof start === \"object\" && \"start\" in start) {\n this.start = new TimeStamp(start.start);\n this.end = new TimeStamp(start.end);\n } else {\n this.start = new TimeStamp(start);\n this.end = new TimeStamp(end);\n }\n }\n\n /** @returns The TimeSpan occupied by the TimeRange. */\n get span(): TimeSpan {\n return new TimeSpan(this.end.valueOf() - this.start.valueOf());\n }\n\n /**\n * Checks if the timestamp is valid i.e. the start is before the end.\n *\n * @returns True if the TimeRange is valid.\n */\n get isValid(): boolean {\n return this.start.valueOf() <= this.end.valueOf();\n }\n\n /**\n * Makes sure the TimeRange is valid i.e. the start is before the end.\n *\n * @returns A TimeRange that is valid.\n */\n makeValid(): TimeRange {\n return this.isValid ? this : this.swap();\n }\n\n /**\n * Checks if the TimeRange has a zero span.\n *\n * @returns True if the TimeRange has a zero span.\n */\n get isZero(): boolean {\n return this.span.isZero;\n }\n\n /**\n * Creates a new TimeRange with the start and end swapped.\n *\n * @returns A TimeRange with the start and end swapped.\n */\n swap(): TimeRange {\n return new TimeRange(this.end, this.start);\n }\n\n /**\n * Checks if the TimeRange is equal to the given TimeRange.\n *\n * @param other - The TimeRange to compare to.\n * @returns True if the TimeRange is equal to the given TimeRange.\n */\n equals(other: TimeRange): boolean {\n return this.start.equals(other.start) && this.end.equals(other.end);\n }\n\n toString(): string {\n return `${this.start.toString()} - ${this.end.toString()}`;\n }\n\n toPrettyString(): string {\n return `${this.start.fString(\"preciseDate\")} - ${this.span.toString()}`;\n }\n\n /**\n * Checks if if the two time ranges overlap. If the two time ranges are equal, returns\n * true. If the start of one range is equal to the end of the other, returns false.\n * Just follow the rule [start, end) i.e. start is inclusive and end is exclusive.\n *\n * @param other - The other TimeRange to compare to.\n * @returns True if the two TimeRanges overlap, false otherwise.\n */\n overlapsWith(other: TimeRange): boolean {\n other = other.makeValid();\n const rng = this.makeValid();\n if (other.start.equals(rng.start)) return true;\n if (other.end.equals(this.start) || other.start.equals(this.end)) return false;\n return (\n this.contains(other.end) ||\n this.contains(other.start) ||\n other.contains(this.start) ||\n other.contains(this.end)\n );\n }\n\n contains(other: TimeRange): boolean;\n\n contains(ts: CrudeTimeStamp): boolean;\n\n contains(other: TimeRange | CrudeTimeStamp): boolean {\n if (other instanceof TimeRange)\n return this.contains(other.start) && this.contains(other.end);\n return this.start.beforeEq(other) && this.end.after(other);\n }\n\n boundBy(other: TimeRange): TimeRange {\n const next = new TimeRange(this.start, this.end);\n if (other.start.after(this.start)) next.start = other.start;\n if (other.start.after(this.end)) next.end = other.start;\n if (other.end.before(this.end)) next.end = other.end;\n if (other.end.before(this.start)) next.start = other.end;\n return next;\n }\n\n /** The maximum possible time range. */\n static readonly MAX = new TimeRange(TimeStamp.MIN, TimeStamp.MAX);\n\n /** The minimum possible time range. */\n static readonly MIN = new TimeRange(TimeStamp.MAX, TimeStamp.MIN);\n\n /** A zero time range. */\n static readonly ZERO = new TimeRange(TimeStamp.ZERO, TimeStamp.ZERO);\n\n /** A zod schema for validating and transforming time ranges */\n static readonly z = z.union([\n z\n .object({ start: TimeStamp.z, end: TimeStamp.z })\n .transform((v) => new TimeRange(v.start, v.end)),\n z.instanceof(TimeRange),\n ]);\n}\n\n/** DataType is a string that represents a data type. */\nexport class DataType extends String implements Stringer {\n constructor(value: CrudeDataType) {\n if (\n value instanceof DataType ||\n typeof value === \"string\" ||\n typeof value.valueOf() === \"string\"\n ) {\n super(value.valueOf());\n return;\n } else {\n const t = DataType.ARRAY_CONSTRUCTOR_DATA_TYPES.get(value.constructor.name);\n if (t != null) {\n super(t.valueOf());\n return;\n }\n }\n super(DataType.UNKNOWN.valueOf());\n throw new Error(`unable to find data type for ${value.toString()}`);\n }\n\n /**\n * @returns the TypedArray constructor for the DataType.\n */\n get Array(): TypedArrayConstructor {\n const v = DataType.ARRAY_CONSTRUCTORS.get(this.toString());\n if (v == null)\n throw new Error(`unable to find array constructor for ${this.valueOf()}`);\n return v;\n }\n\n equals(other: DataType): boolean {\n return this.valueOf() === other.valueOf();\n }\n\n /** @returns a string representation of the DataType. */\n toString(): string {\n return this.valueOf();\n }\n\n get isVariable(): boolean {\n return this.equals(DataType.JSON) || this.equals(DataType.STRING);\n }\n\n get isNumeric(): boolean {\n return !this.isVariable && !this.equals(DataType.UUID);\n }\n\n get isInteger(): boolean {\n return this.toString().startsWith(\"int\");\n }\n\n get isFloat(): boolean {\n return this.toString().startsWith(\"float\");\n }\n\n get density(): Density {\n const v = DataType.DENSITIES.get(this.toString());\n if (v == null) throw new Error(`unable to find density for ${this.valueOf()}`);\n return v;\n }\n\n /**\n * Checks whether the given TypedArray is of the same type as the DataType.\n *\n * @param array - The TypedArray to check.\n * @returns True if the TypedArray is of the same type as the DataType.\n */\n checkArray(array: TypedArray): boolean {\n return array.constructor === this.Array;\n }\n\n toJSON(): string {\n return this.toString();\n }\n\n get usesBigInt(): boolean {\n return DataType.BIG_INT_TYPES.some((t) => t.equals(this));\n }\n\n /** Represents an Unknown/Invalid DataType. */\n static readonly UNKNOWN = new DataType(\"unknown\");\n /** Represents a 64-bit floating point value. */\n static readonly FLOAT64 = new DataType(\"float64\");\n /** Represents a 32-bit floating point value. */\n static readonly FLOAT32 = new DataType(\"float32\");\n /** Represents a 64-bit signed integer value. */\n static readonly INT64 = new DataType(\"int64\");\n /** Represents a 32-bit signed integer value. */\n static readonly INT32 = new DataType(\"int32\");\n /** Represents a 16-bit signed integer value. */\n static readonly INT16 = new DataType(\"int16\");\n /** Represents a 8-bit signed integer value. */\n static readonly INT8 = new DataType(\"int8\");\n /** Represents a 64-bit unsigned integer value. */\n static readonly UINT64 = new DataType(\"uint64\");\n /** Represents a 32-bit unsigned integer value. */\n static readonly UINT32 = new DataType(\"uint32\");\n /** Represents a 16-bit unsigned integer value. */\n static readonly UINT16 = new DataType(\"uint16\");\n /** Represents a 8-bit unsigned integer value. */\n static readonly UINT8 = new DataType(\"uint8\");\n /** Represents a boolean value. Alias for UINT8. */\n static readonly BOOLEAN = this.UINT8;\n /** Represents a 64-bit unix epoch. */\n static readonly TIMESTAMP = new DataType(\"timestamp\");\n /** Represents a UUID data type */\n static readonly UUID = new DataType(\"uuid\");\n /** Represents a string data type. Strings have an unknown density, and are separate\n * by a newline character. */\n static readonly STRING = new DataType(\"string\");\n /** Represents a JSON data type. JSON has an unknown density, and is separated by a\n * newline character. */\n static readonly JSON = new DataType(\"json\");\n\n static readonly ARRAY_CONSTRUCTORS: Map<string, TypedArrayConstructor> = new Map<\n string,\n TypedArrayConstructor\n >([\n [DataType.UINT8.toString(), Uint8Array],\n [DataType.UINT16.toString(), Uint16Array],\n [DataType.UINT32.toString(), Uint32Array],\n [DataType.UINT64.toString(), BigUint64Array],\n [DataType.FLOAT32.toString(), Float32Array],\n [DataType.FLOAT64.toString(), Float64Array],\n [DataType.INT8.toString(), Int8Array],\n [DataType.INT16.toString(), Int16Array],\n [DataType.INT32.toString(), Int32Array],\n [DataType.INT64.toString(), BigInt64Array],\n [DataType.TIMESTAMP.toString(), BigInt64Array],\n [DataType.STRING.toString(), Uint8Array],\n [DataType.JSON.toString(), Uint8Array],\n [DataType.UUID.toString(), Uint8Array],\n ]);\n\n static readonly ARRAY_CONSTRUCTOR_DATA_TYPES: Map<string, DataType> = new Map<\n string,\n DataType\n >([\n [Uint8Array.name, DataType.UINT8],\n [Uint16Array.name, DataType.UINT16],\n [Uint32Array.name, DataType.UINT32],\n [BigUint64Array.name, DataType.UINT64],\n [Float32Array.name, DataType.FLOAT32],\n [Float64Array.name, DataType.FLOAT64],\n [Int8Array.name, DataType.INT8],\n [Int16Array.name, DataType.INT16],\n [Int32Array.name, DataType.INT32],\n [BigInt64Array.name, DataType.INT64],\n ]);\n\n static readonly DENSITIES = new Map<string, Density>([\n [DataType.UINT8.toString(), Density.BIT8],\n [DataType.UINT16.toString(), Density.BIT16],\n [DataType.UINT32.toString(), Density.BIT32],\n [DataType.UINT64.toString(), Density.BIT64],\n [DataType.FLOAT32.toString(), Density.BIT32],\n [DataType.FLOAT64.toString(), Density.BIT64],\n [DataType.INT8.toString(), Density.BIT8],\n [DataType.INT16.toString(), Density.BIT16],\n [DataType.INT32.toString(), Density.BIT32],\n [DataType.INT64.toString(), Density.BIT64],\n [DataType.TIMESTAMP.toString(), Density.BIT64],\n [DataType.STRING.toString(), Density.UNKNOWN],\n [DataType.JSON.toString(), Density.UNKNOWN],\n [DataType.UUID.toString(), Density.BIT128],\n ]);\n\n /** All the data types. */\n static readonly ALL = [\n DataType.UNKNOWN,\n DataType.FLOAT64,\n DataType.FLOAT32,\n DataType.INT64,\n DataType.INT32,\n DataType.INT16,\n DataType.INT8,\n DataType.UINT64,\n DataType.UINT32,\n DataType.UINT16,\n DataType.UINT8,\n DataType.TIMESTAMP,\n DataType.UUID,\n DataType.STRING,\n DataType.JSON,\n ];\n\n static readonly BIG_INT_TYPES = [DataType.INT64, DataType.UINT64, DataType.TIMESTAMP];\n\n /** A zod schema for a DataType. */\n static readonly z = z.union([\n z.string().transform((v) => new DataType(v)),\n z.instanceof(DataType),\n ]);\n}\n\n/**\n * The Size of an elementy in bytes.\n */\nexport class Size extends Number implements Stringer {\n constructor(value: CrudeSize) {\n super(value.valueOf());\n }\n\n /** @returns true if the Size is larger than the other size. */\n largerThan(other: CrudeSize): boolean {\n return this.valueOf() > other.valueOf();\n }\n\n /** @returns true if the Size is smaller than the other sisze. */\n smallerThan(other: CrudeSize): boolean {\n return this.valueOf() < other.valueOf();\n }\n\n add(other: CrudeSize): Size {\n return Size.bytes(this.valueOf() + other.valueOf());\n }\n\n sub(other: CrudeSize): Size {\n return Size.bytes(this.valueOf() - other.valueOf());\n }\n\n truncate(span: CrudeSize): Size {\n return new Size(Math.trunc(this.valueOf() / span.valueOf()) * span.valueOf());\n }\n\n remainder(span: CrudeSize): Size {\n return Size.bytes(this.valueOf() % span.valueOf());\n }\n\n get gigabytes(): number {\n return this.valueOf() / Size.GIGABYTE.valueOf();\n }\n\n get megabytes(): number {\n return this.valueOf() / Size.MEGABYTE.valueOf();\n }\n\n get kilobytes(): number {\n return this.valueOf() / Size.KILOBYTE.valueOf();\n }\n\n get terabytes(): number {\n return this.valueOf() / Size.TERABYTE.valueOf();\n }\n\n toString(): string {\n const totalTB = this.truncate(Size.TERABYTE);\n const totalGB = this.truncate(Size.GIGABYTE);\n const totalMB = this.truncate(Size.MEGABYTE);\n const totalKB = this.truncate(Size.KILOBYTE);\n const totalB = this.truncate(Size.BYTE);\n const tb = totalTB;\n const gb = totalGB.sub(totalTB);\n const mb = totalMB.sub(totalGB);\n const kb = totalKB.sub(totalMB);\n const bytes = totalB.sub(totalKB);\n let str = \"\";\n if (!tb.isZero) str += `${tb.terabytes}TB `;\n if (!gb.isZero) str += `${gb.gigabytes}GB `;\n if (!mb.isZero) str += `${mb.megabytes}MB `;\n if (!kb.isZero) str += `${kb.kilobytes}KB `;\n if (!bytes.isZero || str === \"\") str += `${bytes.valueOf()}B`;\n return str.trim();\n }\n\n /**\n * Creates a Size from the given number of bytes.\n *\n * @param value - The number of bytes.\n * @returns A Size representing the given number of bytes.\n */\n static bytes(value: CrudeSize = 1): Size {\n return new Size(value);\n }\n\n /** A single byte */\n static readonly BYTE = new Size(1);\n\n /**\n * Creates a Size from the given number if kilobytes.\n *\n * @param value - The number of kilobytes.\n * @returns A Size representing the given number of kilobytes.\n */\n static kilobytes(value: CrudeSize = 1): Size {\n return Size.bytes(value.valueOf() * 1e3);\n }\n\n /** A kilobyte */\n static readonly KILOBYTE = Size.kilobytes(1);\n\n /**\n * Creates a Size from the given number of megabytes.\n *\n * @param value - The number of megabytes.\n * @returns A Size representing the given number of megabytes.\n */\n static megabytes(value: CrudeSize = 1): Size {\n return Size.kilobytes(value.valueOf() * 1e3);\n }\n\n /** A megabyte */\n static readonly MEGABYTE = Size.megabytes(1);\n\n /**\n * Creates a Size from the given number of gigabytes.\n *\n * @param value - The number of gigabytes.\n * @returns A Size representing the given number of gigabytes.\n */\n static gigabytes(value: CrudeSize = 1): Size {\n return Size.megabytes(value.valueOf() * 1e3);\n }\n\n /** A gigabyte */\n static readonly GIGABYTE = Size.gigabytes(1);\n\n /**\n * Creates a Size from the given number of terabytes.\n *\n * @param value - The number of terabytes.\n * @returns A Size representing the given number of terabytes.\n */\n static terabytes(value: CrudeSize): Size {\n return Size.gigabytes(value.valueOf() * 1e3);\n }\n\n /** A terabyte. */\n static readonly TERABYTE = Size.terabytes(1);\n\n /** The zero value for Size */\n static readonly ZERO = new Size(0);\n\n /** A zod schema for a Size. */\n static readonly z = z.union([\n z.number().transform((v) => new Size(v)),\n z.instanceof(Size),\n ]);\n\n get isZero(): boolean {\n return this.valueOf() === 0;\n }\n}\n\nexport type CrudeTimeStamp =\n | bigint\n | BigInt\n | TimeStamp\n | TimeSpan\n | number\n | Date\n | string\n | DateComponents\n | Number;\nexport type TimeStampT = number;\nexport type CrudeTimeSpan = bigint | BigInt | TimeSpan | TimeStamp | number | Number;\nexport type TimeSpanT = number;\nexport type CrudeRate = Rate | number | Number;\nexport type RateT = number;\nexport type CrudeDensity = Density | number | Number;\nexport type DensityT = number;\nexport type CrudeDataType = DataType | string | TypedArray;\nexport type DataTypeT = string;\nexport type CrudeSize = Size | number | Number;\nexport type SizeT = number;\nexport interface CrudeTimeRange {\n start: CrudeTimeStamp;\n end: CrudeTimeStamp;\n}\n\nexport const typedArrayZ = z.union([\n z.instanceof(Uint8Array),\n z.instanceof(Uint16Array),\n z.instanceof(Uint32Array),\n z.instanceof(BigUint64Array),\n z.instanceof(Float32Array),\n z.instanceof(Float64Array),\n z.instanceof(Int8Array),\n z.instanceof(Int16Array),\n z.instanceof(Int32Array),\n z.instanceof(BigInt64Array),\n]);\n\nexport type TypedArray = z.infer<typeof typedArrayZ>;\n\ntype TypedArrayConstructor =\n | Uint8ArrayConstructor\n | Uint16ArrayConstructor\n | Uint32ArrayConstructor\n | BigUint64ArrayConstructor\n | Float32ArrayConstructor\n | Float64ArrayConstructor\n | Int8ArrayConstructor\n | Int16ArrayConstructor\n | Int32ArrayConstructor\n | BigInt64ArrayConstructor;\nexport type NumericTelemValue = number | bigint;\nexport type TelemValue =\n | number\n | bigint\n | string\n | boolean\n | Date\n | TimeStamp\n | TimeSpan;\n\nexport const isTelemValue = (value: unknown): value is TelemValue => {\n const ot = typeof value;\n return (\n ot === \"string\" ||\n ot === \"number\" ||\n ot === \"boolean\" ||\n ot === \"bigint\" ||\n value instanceof TimeStamp ||\n value instanceof TimeSpan ||\n value instanceof Date\n );\n};\n\nexport const convertDataType = (\n source: DataType,\n target: DataType,\n value: NumericTelemValue,\n offset: number | bigint = 0,\n): NumericTelemValue => {\n if (source.usesBigInt && !target.usesBigInt) return Number(value) - Number(offset);\n if (!source.usesBigInt && target.usesBigInt) return BigInt(value) - BigInt(offset);\n return addSamples(value, -offset);\n};\n","/* eslint-disable @typescript-eslint/no-misused-new */\n// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { nanoid } from \"nanoid/non-secure\";\nimport { type z } from \"zod\";\n\nimport { compare } from \"@/compare\";\nimport { bounds } from \"@/spatial\";\nimport { type GLBufferController, type GLBufferUsage } from \"@/telem/gl\";\nimport {\n convertDataType,\n DataType,\n type TypedArray,\n type Rate,\n Size,\n TimeRange,\n TimeStamp,\n type CrudeDataType,\n type TelemValue,\n isTelemValue,\n TimeSpan,\n type CrudeTimeStamp,\n type NumericTelemValue,\n} from \"@/telem/telem\";\n\ninterface GL {\n control: GLBufferController | null;\n buffer: WebGLBuffer | null;\n prevBuffer: number;\n bufferUsage: GLBufferUsage;\n}\n\nexport interface SeriesDigest {\n key: string;\n dataType: string;\n sampleOffset: NumericTelemValue;\n alignment: bounds.Bounds;\n timeRange?: string;\n length: number;\n capacity: number;\n}\n\ninterface BaseSeriesProps {\n dataType?: CrudeDataType;\n timeRange?: TimeRange;\n sampleOffset?: NumericTelemValue;\n glBufferUsage?: GLBufferUsage;\n alignment?: number;\n key?: string;\n}\n\nexport type CrudeSeries =\n | Series\n | ArrayBuffer\n | TypedArray\n | string[]\n | number[]\n | boolean[]\n | unknown[]\n | TimeStamp[]\n | Date[]\n | TelemValue;\n\nexport const isCrudeSeries = (value: unknown): value is CrudeSeries => {\n if (value == null) return false;\n if (Array.isArray(value)) return true;\n if (value instanceof ArrayBuffer) return true;\n if (ArrayBuffer.isView(value) && !(value instanceof DataView)) return true;\n if (value instanceof Series) return true;\n return isTelemValue(value);\n};\n\nexport interface SeriesProps extends BaseSeriesProps {\n data: CrudeSeries;\n}\n\nexport interface SeriesAllocProps extends BaseSeriesProps {\n capacity: number;\n dataType: CrudeDataType;\n}\n\nconst FULL_BUFFER = -1;\n\nexport interface SeriesMemInfo {\n key: string;\n length: number;\n byteLength: Size;\n glBuffer: boolean;\n}\n\n/**\n * Series is a strongly typed array of telemetry samples backed by an underlying binary\n * buffer.\n */\nexport class Series<T extends TelemValue = TelemValue> {\n key: string = \"\";\n /** The data type of the array */\n readonly dataType: DataType;\n /**\n * A sample offset that can be used to shift the values of all samples upwards or\n * downwards. Typically used to convert arrays to lower precision while preserving\n * the relative range of actual values.\n */\n sampleOffset: NumericTelemValue;\n /**\n * Stores information about the buffer state of this array into a WebGL buffer.\n */\n private readonly gl: GL;\n /** The underlying data. */\n private readonly _data: ArrayBufferLike;\n readonly _timeRange?: TimeRange;\n readonly alignment: number = 0;\n /** A cached minimum value. */\n private _cachedMin?: NumericTelemValue;\n /** A cached maximum value. */\n private _cachedMax?: NumericTelemValue;\n /** The write position of the buffer. */\n private writePos: number = FULL_BUFFER;\n /** Tracks the number of entities currently using this array. */\n private _refCount: number = 0;\n private _cachedLength?: number;\n\n constructor(props: SeriesProps | CrudeSeries) {\n if (isCrudeSeries(props)) props = { data: props };\n const {\n dataType,\n timeRange,\n sampleOffset = 0,\n glBufferUsage = \"static\",\n alignment = 0,\n key = nanoid(),\n } = props;\n const { data } = props;\n\n if (data instanceof Series) {\n this.key = data.key;\n this.dataType = data.dataType;\n this.sampleOffset = data.sampleOffset;\n this.gl = data.gl;\n this._data = data._data;\n this._timeRange = data._timeRange;\n this.alignment = data.alignment;\n this._cachedMin = data._cachedMin;\n this._cachedMax = data._cachedMax;\n this.writePos = data.writePos;\n this._refCount = data._refCount;\n this._cachedLength = data._cachedLength;\n return;\n }\n const isSingle = isTelemValue(data);\n const isArray = Array.isArray(data);\n\n if (dataType != null) this.dataType = new DataType(dataType);\n else {\n if (data instanceof ArrayBuffer)\n throw new Error(\n \"cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.\",\n );\n else if (isArray || isSingle) {\n let first: TelemValue | unknown = data as TelemValue;\n if (!isSingle) {\n if (data.length === 0)\n throw new Error(\n \"cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.\",\n );\n first = data[0];\n }\n if (typeof first === \"string\") this.dataType = DataType.STRING;\n else if (typeof first === \"number\") this.dataType = DataType.FLOAT64;\n else if (typeof first === \"bigint\") this.dataType = DataType.INT64;\n else if (typeof first === \"boolean\") this.dataType = DataType.BOOLEAN;\n else if (\n first instanceof TimeStamp ||\n first instanceof Date ||\n first instanceof TimeStamp\n )\n this.dataType = DataType.TIMESTAMP;\n else if (typeof first === \"object\") this.dataType = DataType.JSON;\n else\n throw new Error(\n `cannot infer data type of ${typeof first} when constructing a Series from a JS array`,\n );\n } else this.dataType = new DataType(data);\n }\n\n if (!isArray && !isSingle) this._data = data;\n else {\n let data_ = isSingle ? [data] : data;\n const first = data_[0];\n if (\n first instanceof TimeStamp ||\n first instanceof Date ||\n first instanceof TimeSpan\n )\n data_ = data_.map((v) => new TimeStamp(v as CrudeTimeStamp).valueOf());\n if (this.dataType.equals(DataType.STRING)) {\n this._cachedLength = data_.length;\n this._data = new TextEncoder().encode(data_.join(\"\\n\") + \"\\n\");\n } else if (this.dataType.equals(DataType.JSON)) {\n this._cachedLength = data_.length;\n this._data = new TextEncoder().encode(\n data_.map((d) => JSON.stringify(d)).join(\"\\n\") + \"\\n\",\n );\n } else this._data = new this.dataType.Array(data_ as number[] & bigint[]).buffer;\n }\n\n this.key = key;\n this.alignment = alignment;\n this.sampleOffset = sampleOffset ?? 0;\n this._timeRange = timeRange;\n this.gl = {\n control: null,\n buffer: null,\n prevBuffer: 0,\n bufferUsage: glBufferUsage,\n };\n }\n\n static alloc({ capacity: length, dataType, ...props }: SeriesAllocProps): Series {\n if (length === 0)\n throw new Error(\"[Series] - cannot allocate an array of length 0\");\n const data = new new DataType(dataType).Array(length);\n const arr = new Series({\n data: data.buffer,\n dataType,\n ...props,\n });\n arr.writePos = 0;\n return arr;\n }\n\n static generateTimestamps(length: number, rate: Rate, start: TimeStamp): Series {\n const timeRange = start.spanRange(rate.span(length));\n const data = new BigInt64Array(length);\n for (let i = 0; i < length; i++) {\n data[i] = BigInt(start.add(rate.span(i)).valueOf());\n }\n return new Series({ data, dataType: DataType.TIMESTAMP, timeRange });\n }\n\n get refCount(): number {\n return this._refCount;\n }\n\n static fromStrings(data: string[], timeRange?: TimeRange): Series {\n const buffer = new TextEncoder().encode(data.join(\"\\n\") + \"\\n\");\n return new Series({ data: buffer, dataType: DataType.STRING, timeRange });\n }\n\n static fromJSON<T>(data: T[], timeRange?: TimeRange): Series {\n const buffer = new TextEncoder().encode(\n data.map((d) => JSON.stringify(d)).join(\"\\n\") + \"\\n\",\n );\n return new Series({ data: buffer, dataType: DataType.JSON, timeRange });\n }\n\n acquire(gl?: GLBufferController): void {\n this._refCount++;\n if (gl != null) this.updateGLBuffer(gl);\n }\n\n release(): void {\n this._refCount--;\n if (this._refCount === 0 && this.gl.control != null)\n this.maybeGarbageCollectGLBuffer(this.gl.control);\n else if (this._refCount < 0)\n throw new Error(\"cannot release an array with a negative reference count\");\n }\n\n /**\n * Writes the given series to this series. If the series being written exceeds the\n * remaining of series being written to, only the portion that fits will be written.\n * @param other the series to write to this series. The data type of the series written\n * must be the same as the data type of the series being written to.\n * @returns the number of samples written. If the entire series fits, this value is\n * equal to the length of the series being written.\n */\n write(other: Series): number {\n if (!other.dataType.equals(this.dataType))\n throw new Error(\"buffer must be of the same type as this array\");\n\n // We've filled the entire underlying buffer\n if (this.writePos === FULL_BUFFER) return 0;\n const available = this.capacity - this.writePos;\n\n const toWrite = available < other.length ? other.slice(0, available) : other;\n this.underlyingData.set(toWrite.data as ArrayLike<any>, this.writePos);\n this.maybeRecomputeMinMax(toWrite);\n this._cachedLength = undefined;\n this.writePos += toWrite.length;\n return toWrite.length;\n }\n\n /** @returns the underlying buffer backing this array. */\n get buffer(): ArrayBufferLike {\n return this._data;\n }\n\n private get underlyingData(): TypedArray {\n return new this.dataType.Array(this._data);\n }\n\n /** @returns a native typed array with the proper data type. */\n get data(): TypedArray {\n if (this.writePos === FULL_BUFFER) return this.underlyingData;\n return new this.dataType.Array(this._data, 0, this.writePos);\n }\n\n toStrings(): string[] {\n if (!this.dataType.equals(DataType.STRING))\n throw new Error(\"cannot convert non-string series to strings\");\n return new TextDecoder().decode(this.buffer).split(\"\\n\").slice(0, -1);\n }\n\n toUUIDs(): string[] {\n if (!this.dataType.equals(DataType.UUID))\n throw new Error(\"cannot convert non-uuid series to uuids\");\n const den = DataType.UUID.density.valueOf();\n const r = Array(this.length);\n\n for (let i = 0; i < this.length; i++) {\n const v = this.buffer.slice(i * den, (i + 1) * den);\n const id = Array.from(new Uint8Array(v), (b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\")\n .replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, \"$1-$2-$3-$4-$5\");\n r[i] = id;\n }\n return r;\n }\n\n parseJSON<Z extends z.ZodTypeAny>(schema: Z): Array<z.output<Z>> {\n if (!this.dataType.equals(DataType.JSON))\n throw new Error(\"cannot convert non-string series to strings\");\n return new TextDecoder()\n .decode(this.buffer)\n .split(\"\\n\")\n .slice(0, -1)\n .map((s) => schema.parse(JSON.parse(s)));\n }\n\n /** @returns the time range of this array. */\n get timeRange(): TimeRange {\n if (this._timeRange == null) throw new Error(\"time range not set on series\");\n return this._timeRange;\n }\n\n /** @returns the capacity of the series in bytes. */\n get byteCapacity(): Size {\n return new Size(this.buffer.byteLength);\n }\n\n /** @returns the capacity of the series in samples. */\n get capacity(): number {\n return this.dataType.density.length(this.byteCapacity);\n }\n\n /** @returns the length of the series in bytes. */\n get byteLength(): Size {\n if (this.writePos === FULL_BUFFER) return this.byteCapacity;\n return this.dataType.density.size(this.writePos);\n }\n\n /** @returns the number of samples in this array. */\n get length(): number {\n if (this._cachedLength != null) return this._cachedLength;\n if (this.dataType.isVariable) return this.calculateCachedLength();\n if (this.writePos === FULL_BUFFER) return this.data.length;\n return this.writePos;\n }\n\n private calculateCachedLength(): number {\n if (!this.dataType.isVariable)\n throw new Error(\"cannot calculate length of a non-variable length data type\");\n let cl = 0;\n this.data.forEach((v) => {\n if (v === 10) cl++;\n });\n this._cachedLength = cl;\n return cl;\n }\n\n /**\n * Creates a new array with a different data type.\n * @param target the data type to convert to.\n * @param sampleOffset an offset to apply to each sample. This can help with precision\n * issues when converting between data types.\n *\n * WARNING: This method is expensive and copies the entire underlying array. There\n * also may be untimely precision issues when converting between data types.\n */\n convert(target: DataType, sampleOffset: NumericTelemValue = 0): Series {\n if (this.dataType.equals(target)) return this;\n const data = new target.Array(this.length);\n for (let i = 0; i < this.length; i++) {\n data[i] = convertDataType(this.dataType, target, this.data[i], sampleOffset);\n }\n return new Series({\n data: data.buffer,\n dataType: target,\n timeRange: this._timeRange,\n sampleOffset,\n glBufferUsage: this.gl.bufferUsage,\n alignment: this.alignment,\n });\n }\n\n private calcRawMax(): NumericTelemValue {\n if (this.length === 0) return -Infinity;\n if (this.dataType.equals(DataType.TIMESTAMP)) {\n this._cachedMax = this.data[this.data.length - 1];\n } else if (this.dataType.usesBigInt) {\n const d = this.data as BigInt64Array;\n this._cachedMax = d.reduce((a, b) => (a > b ? a : b));\n } else {\n const d = this.data as Float64Array;\n this._cachedMax = d.reduce((a, b) => (a > b ? a : b));\n }\n return this._cachedMax;\n }\n\n /** @returns the maximum value in the array */\n get max(): NumericTelemValue {\n if (this.dataType.isVariable)\n throw new Error(\"cannot calculate maximum on a variable length data type\");\n if (this.writePos === 0) return -Infinity;\n else if (this._cachedMax == null) this._cachedMax = this.calcRawMax();\n return addSamples(this._cachedMax, this.sampleOffset);\n }\n\n private calcRawMin(): NumericTelemValue {\n if (this.length === 0) return Infinity;\n if (this.dataType.equals(DataType.TIMESTAMP)) {\n this._cachedMin = this.data[0];\n } else if (this.dataType.usesBigInt) {\n const d = this.data as BigInt64Array;\n this._cachedMin = d.reduce((a, b) => (a < b ? a : b));\n } else {\n const d = this.data as Float64Array;\n this._cachedMin = d.reduce((a, b) => (a < b ? a : b));\n }\n return this._cachedMin;\n }\n\n /** @returns the minimum value in the array */\n get min(): NumericTelemValue {\n if (this.dataType.isVariable)\n throw new Error(\"cannot calculate minimum on a variable length data type\");\n if (this.writePos === 0) return Infinity;\n else if (this._cachedMin == null) this._cachedMin = this.calcRawMin();\n return addSamples(this._cachedMin, this.sampleOffset);\n }\n\n /** @returns the bounds of this array. */\n get bounds(): bounds.Bounds {\n return bounds.construct(Number(this.min), Number(this.max));\n }\n\n private maybeRecomputeMinMax(update: Series): void {\n if (this._cachedMin != null) {\n const min = update._cachedMin ?? update.calcRawMin();\n if (min < this._cachedMin) this._cachedMin = min;\n }\n if (this._cachedMax != null) {\n const max = update._cachedMax ?? update.calcRawMax();\n if (max > this._cachedMax) this._cachedMax = max;\n }\n }\n\n enrich(): void {\n let _ = this.max;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _ = this.min;\n }\n\n get range(): NumericTelemValue {\n return addSamples(this.max, -this.min);\n }\n\n at(index: number, required: true): T;\n\n at(index: number, required?: false): T | undefined;\n\n at(index: number, required?: boolean): T | undefined {\n if (this.dataType.isVariable) return this.atVariable(index, required ?? false);\n if (index < 0) index = this.length + index;\n const v = this.data[index];\n if (v == null) {\n if (required === true) throw new Error(`[series] - no value at index ${index}`);\n return undefined;\n }\n return addSamples(v, this.sampleOffset) as T;\n }\n\n private atVariable(index: number, required: boolean): T | undefined {\n if (index < 0) index = this.length + index;\n let start = 0;\n let end = 0;\n for (let i = 0; i < this.data.length; i++) {\n if (this.data[i] === 10) {\n if (index === 0) {\n end = i;\n break;\n }\n start = i + 1;\n index--;\n }\n }\n if (end === 0) end = this.data.length;\n if (start >= end || index > 0) {\n if (required) throw new Error(`[series] - no value at index ${index}`);\n return undefined;\n }\n const slice = this.data.slice(start, end);\n if (this.dataType.equals(DataType.STRING))\n return new TextDecoder().decode(slice) as unknown as T;\n return JSON.parse(new TextDecoder().decode(slice)) as unknown as T;\n }\n\n /**\n * @returns the index of the first sample that is greater than or equal to the given value.\n * The underlying array must be sorted. If it is not, the behavior of this method is undefined.\n * @param value the value to search for.\n */\n binarySearch(value: NumericTelemValue): number {\n let left = 0;\n let right = this.length - 1;\n const cf = compare.newF(value);\n while (left <= right) {\n const mid = Math.floor((left + right) / 2);\n const cmp = cf(this.at(mid, true) as NumericTelemValue, value);\n if (cmp === 0) return mid;\n if (cmp < 0) left = mid + 1;\n else right = mid - 1;\n }\n return left;\n }\n\n updateGLBuffer(gl: GLBufferController): void {\n this.gl.control = gl;\n if (!this.dataType.equals(DataType.FLOAT32))\n throw new Error(\"Only FLOAT32 arrays can be used in WebGL\");\n const { buffer, bufferUsage, prevBuffer } = this.gl;\n\n // If no buffer has been created yet, create one.\n if (buffer == null) this.gl.buffer = gl.createBuffer();\n // If the current write position is the same as the previous buffer, we're already\n // up date.\n if (this.writePos === prevBuffer) return;\n\n // Bind the buffer.\n gl.bindBuffer(gl.ARRAY_BUFFER, this.gl.buffer);\n\n // This means we only need to buffer part of the array.\n if (this.writePos !== FULL_BUFFER) {\n if (prevBuffer === 0) {\n gl.bufferData(gl.ARRAY_BUFFER, this.byteCapacity.valueOf(), gl.STATIC_DRAW);\n }\n const byteOffset = this.dataType.density.size(prevBuffer).valueOf();\n const slice = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);\n gl.bufferSubData(gl.ARRAY_BUFFER, byteOffset, slice.buffer);\n this.gl.prevBuffer = this.writePos;\n } else {\n // This means we can buffer the entire array in a single go.\n gl.bufferData(\n gl.ARRAY_BUFFER,\n this.buffer,\n bufferUsage === \"static\" ? gl.STATIC_DRAW : gl.DYNAMIC_DRAW,\n );\n this.gl.prevBuffer = FULL_BUFFER;\n }\n }\n\n as(jsType: \"string\"): Series<string>;\n\n as(jsType: \"number\"): Series<number>;\n\n as(jsType: \"bigint\"): Series<bigint>;\n\n as<T extends TelemValue>(jsType: \"string\" | \"number\" | \"bigint\"): Series<T> {\n if (jsType === \"string\") {\n if (!this.dataType.equals(DataType.STRING))\n throw new Error(\n `cannot convert series of type ${this.dataType.toString()} to string`,\n );\n return this as unknown as Series<T>;\n }\n if (jsType === \"number\") {\n if (!this.dataType.isNumeric)\n throw new Error(\n `cannot convert series of type ${this.dataType.toString()} to number`,\n );\n return this as unknown as Series<T>;\n }\n if (jsType === \"bigint\") {\n if (!this.dataType.equals(DataType.INT64))\n throw new Error(\n `cannot convert series of type ${this.dataType.toString()} to bigint`,\n );\n return this as unknown as Series<T>;\n }\n throw new Error(`cannot convert series to ${jsType as string}`);\n }\n\n get digest(): SeriesDigest {\n return {\n key: this.key,\n dataType: this.dataType.toString(),\n sampleOffset: this.sampleOffset,\n alignment: this.alignmentBounds,\n timeRange: this._timeRange?.toString(),\n length: this.length,\n capacity: this.capacity,\n };\n }\n\n get memInfo(): SeriesMemInfo {\n return {\n key: this.key,\n length: this.length,\n byteLength: this.byteLength,\n glBuffer: this.gl.buffer != null,\n };\n }\n\n get alignmentBounds(): bounds.Bounds {\n return bounds.construct(this.alignment, this.alignment + this.length);\n }\n\n private maybeGarbageCollectGLBuffer(gl: GLBufferController): void {\n if (this.gl.buffer == null) return;\n gl.deleteBuffer(this.gl.buffer);\n this.gl.buffer = null;\n this.gl.prevBuffer = 0;\n this.gl.control = null;\n }\n\n get glBuffer(): WebGLBuffer {\n if (this.gl.buffer == null) throw new Error(\"gl buffer not initialized\");\n if (!(this.gl.prevBuffer === this.writePos)) console.warn(\"buffer not updated\");\n return this.gl.buffer;\n }\n\n [Symbol.iterator](): Iterator<T> {\n if (this.dataType.isVariable) {\n const s = new StringSeriesIterator(this);\n if (this.dataType.equals(DataType.JSON)) {\n return new JSONSeriesIterator(s) as Iterator<T>;\n }\n return s as Iterator<T>;\n }\n return new FixedSeriesIterator(this) as Iterator<T>;\n }\n\n slice(start: number, end?: number): Series {\n if (start <= 0 && (end == null || end >= this.length)) return this;\n const data = this.data.slice(start, end);\n return new Series({\n data,\n dataType: this.dataType,\n timeRange: this._timeRange,\n sampleOffset: this.sampleOffset,\n glBufferUsage: this.gl.bufferUsage,\n alignment: this.alignment + start,\n });\n }\n\n reAlign(alignment: number): Series {\n return new Series({\n data: this.buffer,\n dataType: this.dataType,\n timeRange: TimeRange.ZERO,\n sampleOffset: this.sampleOffset,\n glBufferUsage: \"static\",\n alignment,\n });\n }\n}\n\nclass StringSeriesIterator implements Iterator<string> {\n private readonly series: Series;\n private index: number;\n private readonly decoder: TextDecoder;\n\n constructor(series: Series) {\n if (!series.dataType.isVariable)\n throw new Error(\n \"cannot create a variable series iterator for a non-variable series\",\n );\n this.series = series;\n this.index = 0;\n this.decoder = new TextDecoder();\n }\n\n next(): IteratorResult<string> {\n const start = this.index;\n const data = this.series.data;\n while (this.index < data.length && data[this.index] !== 10) this.index++;\n const end = this.index;\n if (start === end) return { done: true, value: undefined };\n this.index++;\n const s = this.decoder.decode(this.series.buffer.slice(start, end));\n return { done: false, value: s };\n }\n\n [Symbol.iterator](): Iterator<TelemValue> {\n return this;\n }\n}\n\nclass JSONSeriesIterator implements Iterator<unknown> {\n private readonly wrapped: Iterator<string>;\n\n constructor(wrapped: Iterator<string>) {\n this.wrapped = wrapped;\n }\n\n next(): IteratorResult<object> {\n const next = this.wrapped.next();\n if (next.done === true) return { done: true, value: undefined };\n return { done: false, value: JSON.parse(next.value) };\n }\n\n [Symbol.iterator](): Iterator<object> {\n return this;\n }\n\n [Symbol.toStringTag] = \"JSONSeriesIterator\";\n}\n\nclass FixedSeriesIterator implements Iterator<NumericTelemValue> {\n series: Series;\n index: number;\n constructor(series: Series) {\n this.series = series;\n this.index = 0;\n }\n\n next(): IteratorResult<NumericTelemValue> {\n if (this.index >= this.series.length) return { done: true, value: undefined };\n return {\n done: false,\n value: this.series.at(this.index++, true) as NumericTelemValue,\n };\n }\n\n [Symbol.iterator](): Iterator<NumericTelemValue> {\n return this;\n }\n\n [Symbol.toStringTag] = \"SeriesIterator\";\n}\n\nexport const addSamples = (\n a: NumericTelemValue,\n b: NumericTelemValue,\n): NumericTelemValue => {\n if (typeof a === \"bigint\" && typeof b === \"bigint\") return a + b;\n if (typeof a === \"number\" && typeof b === \"number\") return a + b;\n if (b === 0) return a;\n if (a === 0) return b;\n return Number(a) + Number(b);\n};\n\nexport class MultiSeries<T extends TelemValue = TelemValue> implements Iterable<T> {\n readonly series: Array<Series<T>>;\n\n constructor(series: Array<Series<T>>) {\n if (series.length !== 0) {\n const type = series[0].dataType;\n for (let i = 1; i < series.length; i++)\n if (!series[i].dataType.equals(type))\n throw new Error(\"[multi-series] - series must have the same data type\");\n }\n this.series = series;\n }\n\n as(jsType: \"string\"): MultiSeries<string>;\n\n as(jsType: \"number\"): MultiSeries<number>;\n\n as(jsType: \"bigint\"): MultiSeries<bigint>;\n\n as<T extends TelemValue>(dataType: CrudeDataType): MultiSeries<T> {\n if (!new DataType(dataType).equals(this.dataType))\n throw new Error(\n `cannot convert series of type ${this.dataType.toString()} to ${dataType.toString()}`,\n );\n return this as unknown as MultiSeries<T>;\n }\n\n get dataType(): DataType {\n if (this.series.length === 0) return DataType.UNKNOWN;\n return this.series[0].dataType;\n }\n\n get timeRange(): TimeRange {\n if (this.series.length === 0) return TimeRange.ZERO;\n return new TimeRange(\n this.series[0].timeRange.start,\n this.series[this.series.length - 1].timeRange.end,\n );\n }\n\n push(series: Series<T>): void {\n this.series.push(series);\n }\n\n get length(): number {\n return this.series.reduce((a, b) => a + b.length, 0);\n }\n\n at(index: number, required: true): T;\n\n at(index: number, required?: false): T | undefined;\n\n at(index: number, required: boolean = false): T | undefined {\n if (index < 0) index = this.length + index;\n for (const ser of this.series) {\n if (index < ser.length) return ser.at(index, required as true);\n index -= ser.length;\n }\n if (required) throw new Error(`[series] - no value at index ${index}`);\n return undefined;\n }\n\n get byteLength(): Size {\n return new Size(this.series.reduce((a, b) => a + b.byteLength.valueOf(), 0));\n }\n\n get data(): TypedArray {\n const buf = new this.dataType.Array(this.length);\n let offset = 0;\n for (const ser of this.series) {\n buf.set(ser.data as ArrayLike<any>, offset);\n offset += ser.length;\n }\n return new this.dataType.Array(buf);\n }\n\n [Symbol.iterator](): Iterator<T> {\n if (this.series.length === 0)\n return {\n next(): IteratorResult<T> {\n return { done: true, value: undefined };\n },\n };\n return new MultiSeriesIterator<T>(this.series);\n }\n}\n\nclass MultiSeriesIterator<T extends TelemValue = TelemValue> implements Iterator<T> {\n private readonly series: Array<Series<T>>;\n private seriesIndex: number;\n private internal: Iterator<T>;\n\n constructor(series: Array<Series<T>>) {\n this.series = series;\n this.seriesIndex = 0;\n this.internal = series[0][Symbol.iterator]();\n }\n\n next(): IteratorResult<T> {\n const next = this.internal.next();\n if (next.done === false) return next;\n if (this.seriesIndex === this.series.length - 1)\n return { done: true, value: undefined };\n this.internal = this.series[++this.seriesIndex][Symbol.iterator]();\n return this.next();\n }\n\n [Symbol.iterator](): Iterator<TelemValue | unknown> {\n return this;\n }\n\n [Symbol.toStringTag] = \"MultiSeriesIterator\";\n}\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nexport type Key = string | number | symbol;\n\nexport type UnknownRecord = { [key: Key]: unknown };\n\nexport type Keyed<K extends Key> = { key: K };\n\nexport const unknownRecordZ = z.record(\n z.union([z.number(), z.string(), z.symbol()]),\n z.unknown(),\n);\n\nexport type Entries<T> = {\n [K in keyof T]: [K, T[K]];\n}[keyof T][];\n\nexport const getEntries = <T extends Record<Key, unknown>>(obj: T): Entries<T> =>\n Object.entries(obj) as Entries<T>;\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Stringer } from \"@/primitive\";\n\nexport type PureRenderableValue = string | number | undefined;\nexport type RenderableValue = PureRenderableValue | Stringer;\n\nexport const convertRenderV = (value: RenderableValue): string | number | undefined => {\n if (value === undefined || typeof value === \"string\" || typeof value === \"number\")\n return value;\n if (value.toString === undefined) throw new Error(\"invalid renderer\");\n return value.toString();\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type UnknownRecord } from \"@/record\";\n\nexport const isObject = <T extends UnknownRecord = UnknownRecord>(\n item?: unknown,\n): item is T => item != null && typeof item === \"object\" && !Array.isArray(item);\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\n/** JavaScript runtime environments. */\nexport type Runtime = \"browser\" | \"node\" | \"webworker\";\n\n/**\n * Does best effort detection of the runtime environment.\n *\n * @returns The runtime environment.\n */\nexport const detect = (): Runtime => {\n if (\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n typeof process !== \"undefined\" &&\n process.versions != null &&\n process.versions.node != null\n )\n return \"node\";\n\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n if (typeof window === \"undefined\" || window.document === undefined)\n return \"webworker\";\n\n return \"browser\";\n};\n\nexport const RUNTIME = detect();\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nexport const OPERATING_SYSTEMS = [\"MacOS\", \"Windows\", \"Linux\", \"Docker\"] as const;\nexport const osZ = z.enum(OPERATING_SYSTEMS);\nexport type OS = (typeof OPERATING_SYSTEMS)[number];\n\nexport interface GetOSProps {\n force?: OS;\n default?: OS;\n}\n\nlet os: OS | undefined;\n\nconst evalOS = (): OS | undefined => {\n if (typeof window === \"undefined\") return undefined;\n const userAgent = window.navigator.userAgent.toLowerCase();\n if (userAgent.includes(\"mac\")) return \"MacOS\";\n else if (userAgent.includes(\"win\")) return \"Windows\";\n else if (userAgent.includes(\"linux\")) return \"Linux\";\n return undefined;\n};\n\nexport const getOS = (props: GetOSProps = {}): OS | undefined => {\n const { force, default: default_ } = props;\n if (force != null) return force;\n if (os != null) return os;\n os = evalOS();\n return os ?? default_;\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nexport const copy = <T>(obj: T): T =>\n JSON.parse(JSON.stringify(obj));\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Key } from \"@/deep/path\";\n\nexport const deleteD = <T extends any, D extends number = 5>(\n target: T,\n ...keys: Array<Key<T, D>>\n): T => {\n keys.forEach((key) => {\n let curr: any = target;\n const arr = key.split(\".\");\n arr.forEach((k, i) => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n if (i === arr.length - 1) delete curr[k];\n else curr = curr[k];\n });\n });\n return target;\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Join } from \"@/join\";\nimport { UnknownRecord } from \"@/record\";\n\ntype Prev = [\n never,\n 0,\n 1,\n 2,\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14,\n 15,\n 16,\n 17,\n 18,\n 19,\n 20,\n ...Array<0>,\n];\n\nexport type Key<T, D extends number = 5> = [D] extends [never]\n ? never\n : T extends object\n ? {\n [K in keyof T]-?: K extends string | number\n ? `${K}` | Join<K, Key<T[K], Prev[D]>>\n : never;\n }[keyof T]\n : \"\";\n\nexport type Get = \n&(<T>(obj: T, path: string, allowNull: true) => unknown | null) \n&(<T>(obj: T, path: string, allowNull?: boolean) => unknown) \n\nexport const get: Get = <V>(obj: V, path: string, allowNull: boolean = false): unknown | null => {\n const parts = (path as string).split(\".\");\n if (parts.length === 1 && parts[0] === \"\") return obj;\n let result: UnknownRecord = obj as UnknownRecord;\n for (const part of parts) {\n const v = result[part];\n if (v == null) {\n if (allowNull) return null;\n throw new Error(`Path ${path} does not exist. ${part} is null`);\n }\n result = v as UnknownRecord;\n }\n return result;\n}\n\nexport const set = <V>(obj: V, path: string, value: unknown): void => {\n const parts = (path as string).split(\".\");\n let result: UnknownRecord = obj as UnknownRecord;\n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i];\n if (result[part] == null) {\n throw new Error(`Path ${path} does not exist`);\n }\n result = result[part] as UnknownRecord;\n }\n result[parts[parts.length - 1]] = value;\n}\n\nexport const element = (path: string, index: number): string => {\n const parts = path.split(\".\");\n if (index < 0) return parts[parts.length + index];\n return parts[index];\n}\n\nexport const join = (path: string[]): string => path.join(\".\");\n\nexport const has = <V>(obj: V, path: string): boolean => {\n try {\n get<V>(obj, path);\n return true;\n } catch {\n return false;\n }\n}","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Partial } from \"@/deep/partial\";\nimport { isObject } from \"@/identity\";\n\nexport const merge = <T>(\n base: T,\n ...objects: Array<Partial<T>>\n): T => {\n if (objects.length === 0) return base;\n const source = objects.shift();\n\n if (isObject(base) && isObject(source)) {\n for (const key in source) {\n try {\n if (isObject(source[key])) {\n if (!(key in base)) Object.assign(base, { [key]: {} });\n merge(base[key], source[key]);\n } else {\n Object.assign(base, { [key]: source[key] });\n }\n } catch (e) {\n if (e instanceof TypeError) {\n throw new TypeError(`.${key}: ${e.message}`);\n }\n throw e;\n }\n }\n }\n\n return merge(base, ...objects);\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { Primitive } from \"@/primitive\";\n\ninterface DeepEqualBaseRecord {\n equals?: (other: any) => boolean;\n}\n\nexport const equal = <T extends unknown | DeepEqualBaseRecord | DeepEqualBaseRecord[] | Primitive[]>(a: T, b: T): boolean => {\n const aIsArray = Array.isArray(a);\n const bIsArray = Array.isArray(b);\n if (aIsArray !== bIsArray) return false;\n if (aIsArray && bIsArray) {\n const aArr = a as DeepEqualBaseRecord[];\n const bArr = b as DeepEqualBaseRecord[];\n if (aArr.length !== bArr.length) return false;\n for (let i = 0; i < aArr.length; i++) \n if (!equal(aArr[i], bArr[i])) return false;\n return true;\n }\n if (a == null || b == null || typeof a !== \"object\" || typeof b !== \"object\") return a === b;\n if (\"equals\" in a) \n return (a.equals as (other: any) => boolean)(b);\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) return false;\n for (const key of aKeys) {\n // @ts-expect-error\n const aVal = a[key];\n // @ts-expect-error\n const bVal = b[key];\n if (typeof aVal === \"object\" && typeof bVal === \"object\") {\n if (!equal(aVal, bVal)) return false;\n } else if (aVal !== bVal) return false;\n }\n return true;\n};\n\nexport const partialEqual = <T extends unknown | DeepEqualBaseRecord | Primitive>(\n base: T,\n partial: Partial<T>,\n): boolean => {\n if (typeof base !== \"object\" || base == null) return base === partial;\n const baseKeys = Object.keys(base);\n const partialKeys = Object.keys(partial);\n if (partialKeys.length > baseKeys.length) return false;\n for (const key of partialKeys) {\n // @ts-expect-error\n const baseVal = base[key];\n // @ts-expect-error\n const partialVal = partial[key];\n if (typeof baseVal === \"object\" && typeof partialVal === \"object\") {\n if (!partialEqual(baseVal, partialVal)) return false;\n } else if (baseVal !== partialVal) return false;\n }\n return true;\n};\n","// Copyright 2024 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { equal } from \"@/deep/equal\"\n\n\nexport const memo = <F extends (...args: any[]) => any>(func: F): F => {\n let prevArgs: Parameters<F> = undefined as any\n let prevResult: ReturnType<F> = undefined as any\n const v = ((...args: Parameters<F>) => {\n if (equal(prevArgs, args)) return prevResult\n const result = func(...args)\n prevArgs = args\n prevResult = result\n return result\n })\n return v as F;\n}\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\n\ntype PathValueTuple = [any, any];\n\nexport const difference = (obj1: Record<string, any>, obj2: Record<string, any>, path: string = ''): Record<string, PathValueTuple> => {\n const diffMap: Record<string, PathValueTuple> = {};\n\n const compare = (a: any, b: any, currentPath: string) => {\n if (typeof a !== typeof b || a === null || b === null) {\n diffMap[currentPath] = [a, b];\n return;\n }\n\n if (typeof a === 'object' && typeof b === 'object') {\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) {\n diffMap[currentPath] = [a, b];\n return;\n }\n for (let i = 0; i < a.length; i++) {\n compare(a[i], b[i], `${currentPath}[${i}]`);\n }\n } else {\n const keys = new Set([...Object.keys(a), ...Object.keys(b)]);\n keys.forEach(key => {\n compare(a[key], b[key], currentPath ? `${currentPath}.${key}` : key);\n });\n }\n } else {\n if (a !== b) {\n diffMap[currentPath] = [a, b];\n }\n }\n };\n\n compare(obj1, obj2, path);\n return diffMap;\n}\n\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nexport const debounce = <F extends (...args: any[]) => void>(\n func: F,\n waitFor: number\n): F => {\n let timeout: ReturnType<typeof setTimeout> | null = null;\n if (waitFor === 0) return func;\n\n const debounced = (...args: Parameters<F>): void => {\n if (timeout !== null) {\n clearTimeout(timeout);\n timeout = null;\n }\n timeout = setTimeout(() => func(...args), waitFor);\n };\n\n return debounced as F;\n};\n\nexport const throttle = <F extends (...args: any[]) => void>(\n func: F,\n waitFor: number\n): F => {\n let timeout: ReturnType<typeof setTimeout> | null = null;\n if (waitFor === 0) return func;\n\n const throttled = (...args: Parameters<F>): void => {\n if (timeout === null) {\n timeout = setTimeout(() => {\n func(...args);\n timeout = null;\n }, waitFor);\n }\n };\n\n return throttled as F;\n}","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nexport const unique = <V>(values: V[] | readonly V[]): V[] => [...new Set(values)];\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\ninterface URLProps {\n host: string;\n port: number;\n protocol?: string;\n pathPrefix?: string;\n params?: string;\n}\n\n/** @returns the paths joined with a single slash */\nconst joinPaths = (...paths: string[]): string => paths.map(formatPath).join(\"\");\n\n/** ensures that a path is correctly formatted for joining */\nconst formatPath = (path: string): string => {\n if (!path.endsWith(\"/\")) path += \"/\";\n if (path.startsWith(\"/\")) path = path.slice(1);\n return path;\n};\n\n/** removes the trailing slash from a path */\nconst removeTrailingSlash = (path: string): string =>\n path.endsWith(\"/\") ? path.slice(0, -1) : path;\n\n/**\n * Builds a query string from a record.\n * @param record - The record to build the query string from. If the record is null,\n * an empty string is returned.\n * @returns the query string.\n */\nexport const buildQueryString = (\n request: Record<string, unknown>,\n prefix: string = \"\"\n): string => {\n if (request === null) return \"\";\n return (\n \"?\" +\n Object.entries(request)\n .filter(([, value]) => {\n if (value === undefined || value === null) return false;\n if (Array.isArray(value)) return value.length > 0;\n return true;\n })\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n .map(([key, value]) => `${prefix}${key}=${value}`)\n .join(\"&\")\n );\n};\n\n/**\n * URL is a simple class for building and extending URLs.\n */\nexport class URL {\n protocol: string;\n host: string;\n port: number;\n path: string;\n\n /**\n * @param host - The hostname or IP address of the server.\n * @param port - The port number of the server.\n * @param protocol - The protocol to use for all requests. Defaults to \"\".\n * @param pathPrefix - A path prefix to use for all requests. Defaults to \"\".\n */\n constructor({ host, port, protocol = \"\", pathPrefix = \"\" }: URLProps) {\n this.protocol = protocol;\n this.host = host;\n this.port = port;\n this.path = formatPath(pathPrefix);\n }\n\n /**\n * Replaces creates a new URL with the specified properties replaced.\n * @param props - The properties to replace.\n * @returns a new URL.\n */\n replace(props: Partial<URLProps>): URL {\n return new URL({\n host: props.host ?? this.host,\n port: props.port ?? this.port,\n protocol: props.protocol ?? this.protocol,\n pathPrefix: props.pathPrefix ?? this.path,\n });\n }\n\n /**\n * Creates a new url with the given path appended to the current path.\n * @param path - the path to append to the URL.\n * @returns a new URL.\n */\n child(path: string): URL {\n return new URL({\n ...this,\n pathPrefix: joinPaths(this.path, path),\n });\n }\n\n /** @returns a string representation of the url */\n toString(): string {\n return removeTrailingSlash(\n `${this.protocol}://${this.host}:${this.port}/${this.path}`\n );\n }\n\n static readonly UNKNOWN = new URL({ host: \"unknown\", port: 0 });\n}\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nexport const toArray = <T>(value: T | T[]): T[] =>\n Array.isArray(value) ? value : [value];\n\nexport const nullToArr = <T>(value: T | T[] | null): T[] =>\n Array.isArray(value) ? value : value === null ? [] : [value];","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type CompareF } from \"@/compare/compare\";\nimport { type Key, type Keyed } from \"@/record\";\n\nconst binary = <T>(arr: T[], target: T, compare: CompareF<T>): number => {\n let left = 0;\n let right = arr.length - 1;\n while (left <= right) {\n const mid = Math.floor((left + right) / 2);\n const cmp = compare(arr[mid], target);\n if (cmp === 0) return mid;\n if (cmp < 0) left = mid + 1;\n else right = mid - 1;\n }\n return -1;\n};\n\nexport const Search = {\n binary,\n};\n\nexport interface TermSearcher<T, K extends Key, E extends Keyed<K>> {\n search: (term: T) => E[];\n retrieve: (keys: K[]) => E[];\n page: (offset: number, limit: number) => E[];\n}\n\nexport interface AsyncTermSearcher<T, K extends Key, E extends Keyed<K>> {\n search: (term: T) => Promise<E[]>;\n retrieve: (keys: K[]) => Promise<E[]>;\n page: (offset: number, limit: number) => Promise<E[]>;\n}\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nexport interface Sender<T> {\n send: (value: T, transfer?: Transferable[]) => void;\n}\n\nexport interface Handler<T> {\n handle: (handler: (value: T) => void) => void;\n}\n\nexport interface SenderHandler<I, O> extends Sender<I>, Handler<O> {}\n\ninterface TypedWorkerMessage {\n type: string;\n payload: any;\n}\n\ntype SendFunc = (value: any, transfer?: Transferable[]) => void;\ntype HandlerFunc = (value: any) => void;\n\nexport class RoutedWorker {\n sender: SendFunc;\n handlers: Map<string, TypedWorker<any>>;\n\n constructor(send: SendFunc) {\n this.sender = send;\n this.handlers = new Map();\n }\n\n handle({ data }: { data: TypedWorkerMessage }): void {\n const handler = this.handlers.get(data.type)?.handler;\n if (handler == null) console.warn(`No handler for ${data.type}`);\n else handler(data.payload);\n }\n\n route<RQ, RS = RQ>(type: string): TypedWorker<RQ, RS> {\n const send = typedSend(type, this.sender);\n const t = new TypedWorker<RQ, RS>(send);\n this.handlers.set(type, t);\n return t;\n }\n}\n\nconst typedSend =\n (type: string, send: SendFunc): SendFunc =>\n (payload: any, transfer?: Transferable[]) => {\n return send({ type, payload }, transfer);\n };\n\nexport class TypedWorker<RQ, RS = RQ> implements SenderHandler<RQ, RS> {\n private readonly _send: SendFunc;\n handler: HandlerFunc | null;\n\n constructor(send: SendFunc) {\n this._send = send;\n this.handler = null;\n }\n\n send(payload: RQ, transfer: Transferable[] = []): void {\n this._send(payload, transfer);\n }\n\n handle(handler: (payload: RS) => void): void {\n this.handler = handler;\n }\n}\n\nexport const createMockWorkers = (): [RoutedWorker, RoutedWorker] => {\n let a: RoutedWorker, b: RoutedWorker;\n const aSend = (value: any, transfer?: Transferable[]): void => {\n b.handle({ data: value });\n };\n const bSend = (value: any, transfer?: Transferable[]): void => {\n a.handle({ data: value });\n };\n a = new RoutedWorker(aSend);\n b = new RoutedWorker(bSend);\n return [a, b];\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ZodSchema, type z } from \"zod\";\n\nimport { Case } from \"@/case\";\nimport { isObject } from \"@/identity\";\n\n/**\n * EncoderDecoder is an entity that encodes and decodes messages to and from a\n * binary format.\n */\nexport interface EncoderDecoder {\n /** The HTTP content type of the encoder */\n contentType: string;\n\n /**\n * Encodes the given payload into a binary representation.\n *\n * @param payload - The payload to encode.\n * @returns An ArrayBuffer containing the encoded payload.\n */\n encode: (payload: unknown) => ArrayBuffer;\n\n /**\n * Decodes the given binary representation into a type checked payload.\n *\n * @param data - The data to decode.\n * @param schema - The schema to decode the data with.\n */\n decode: <P>(data: Uint8Array | ArrayBuffer, schema?: ZodSchema<P>) => P;\n}\n\n/** JSONEncoderDecoder is a JSON implementation of EncoderDecoder. */\nexport class JSONEncoderDecoder implements EncoderDecoder {\n contentType = \"application/json\";\n readonly decoder: TextDecoder;\n\n constructor() {\n this.decoder = new TextDecoder();\n }\n\n encode(payload: unknown): ArrayBuffer {\n const json = JSON.stringify(Case.toSnake(payload), (_, v) => {\n if (ArrayBuffer.isView(v)) return Array.from(v as Uint8Array);\n if (isObject(v) && \"encode_value\" in v) {\n if (typeof v.value === \"bigint\") return v.value.toString();\n return v.value;\n }\n if (typeof v === \"bigint\") return v.toString();\n return v;\n });\n return new TextEncoder().encode(json);\n }\n\n decode<P extends z.ZodTypeAny>(\n data: Uint8Array | ArrayBuffer,\n schema?: P,\n ): z.output<P> {\n const unpacked = Case.toCamel(JSON.parse(this.decoder.decode(data)));\n return schema != null ? schema.parse(unpacked) : (unpacked as P);\n }\n\n static registerCustomType(): void {}\n}\n\nexport const ENCODERS: EncoderDecoder[] = [new JSONEncoderDecoder()];\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Destructor } from \"@/destructor\";\n\nexport type Handler<T> = (value: T) => void;\n\nexport interface Observable<T> {\n onChange: (handler: Handler<T>) => Destructor;\n}\n\nexport class Observer<T> implements Observable<T> {\n private readonly handlers: Map<Handler<T>, null>;\n\n constructor(handlers?: Map<Handler<T>, null>) {\n this.handlers = handlers ?? new Map();\n }\n\n onChange(handler: Handler<T>): Destructor {\n this.handlers.set(handler, null);\n return () => this.handlers.delete(handler);\n }\n\n notify(value: T): void {\n this.handlers.forEach((_, handler) => handler(value));\n }\n}\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nexport type Variant = \"set\" | \"delete\";\n\nexport const Z = <V extends z.ZodTypeAny>(value: V) =>\n z.object({\n variant: z.enum([\"set\", \"delete\"]),\n key: z.string(),\n value,\n });\n\nexport type Set<K, V> = {\n variant: \"set\";\n key: K;\n value: V;\n};\n\nexport type Delete<K, V> = {\n variant: \"delete\";\n key: K;\n value?: V;\n};\n\nexport type Change<K, V> = Set<K, V> | Delete<K, V>;","\n// Copyright 2024 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nexport const shallowCopy = <T extends unknown>(obj: T): T => {\n if (Array.isArray(obj)) return [...obj] as T;\n if (typeof obj === \"object\" && obj !== null) return { ...obj } as T;\n return obj;\n}\n","export const invert = (condition: boolean): -1 | 1 => (condition ? -1 : 1);\n","import { z } from \"zod\";\n\nimport { compare } from \"@/compare\";\n\nexport const semVerZ = z.string().regex(/^\\d+\\.\\d+\\.\\d+$/);\n\nexport type SemVer = z.infer<typeof semVerZ>;\n\nconst compareSemVer: compare.CompareF<string> = (a, b) => {\n const semA = semVerZ.parse(a);\n const semB = semVerZ.parse(b);\n const [aMajor, aMinor, aPatch] = semA.split(\".\").map(Number);\n const [bMajor, bMinor, bPatch] = semB.split(\".\").map(Number);\n if (aMajor !== bMajor) return aMajor - bMajor;\n if (aMinor !== bMinor) return aMinor - bMinor;\n return aPatch - bPatch;\n};\n\nconst semVerNewer = (a: SemVer, b: SemVer): boolean =>\n compare.isGreaterThan(compareSemVer(a, b));\n\nexport const migratable = z.object({\n version: semVerZ,\n});\n\nexport interface Migratable extends z.infer<typeof migratable> {}\n\nexport type Migration<I = unknown, O = unknown> = (\n migratable: Migratable & I,\n) => Migratable & O;\n\nexport type Migrations = Record<string, Migration<any, any>>;\n\nexport const migrator = <I = unknown, O = unknown>(\n migrations: Migrations,\n): Migration<I, O> => {\n const latestVersion = Object.keys(migrations).sort(compareSemVer).pop() ?? \"\";\n const migLength = Object.keys(migrations).length;\n const f = (old: Migratable): Migratable => {\n if (migLength === 0 || semVerNewer(old.version, latestVersion)) return old;\n const version = old.version;\n const migration = migrations[version];\n const new_: Migratable = migration(old);\n return f(new_);\n };\n return f as unknown as Migration<I, O>;\n};\n"],"names":["urlAlphabet","nanoid","size","id","i","isStringer","value","primitiveIsZero","newF","v","reverse","t","f","a","b","reverseF","newFieldF","key","primitiveArrays","unorderedPrimitiveArrays","compareF","aSorted","bSorted","order","EQUAL","LESS_THAN","GREATER_THAN","isLessThan","n","isGreaterThan","isGreaterThanEqual","util","val","assertIs","_arg","assertNever","_x","items","obj","item","validKeys","k","filtered","e","object","keys","arr","checker","joinValues","array","separator","_","objectUtil","first","second","ZodParsedType","getParsedType","data","ZodIssueCode","quotelessJson","ZodError","issues","sub","subs","actualProto","_mapper","mapper","issue","fieldErrors","processError","error","curr","el","formErrors","errorMap","_ctx","message","overrideErrorMap","setErrorMap","map","getErrorMap","makeIssue","params","path","errorMaps","issueData","fullPath","fullIssue","errorMessage","maps","m","EMPTY_PATH","addIssueToContext","ctx","x","ParseStatus","status","results","arrayValue","INVALID","pairs","syncPairs","pair","finalObject","DIRTY","OK","isAborted","isDirty","isValid","isAsync","errorUtil","ParseInputLazyPath","parent","handleResult","result","processCreateParams","invalid_type_error","required_error","description","iss","ZodType","def","input","_a","maybeAsyncResult","check","getIssueProperties","setError","refinementData","refinement","ZodEffects","ZodFirstPartyTypeKind","ZodOptional","ZodNullable","ZodArray","ZodPromise","option","ZodUnion","incoming","ZodIntersection","transform","defaultValueFunc","ZodDefault","ZodBranded","catchValueFunc","ZodCatch","This","target","ZodPipeline","ZodReadonly","cuidRegex","cuid2Regex","ulidRegex","uuidRegex","emailRegex","_emojiRegex","emojiRegex","ipv4Regex","ipv6Regex","datetimeRegex","args","isValidIP","ip","version","ZodString","tooBig","tooSmall","regex","validation","options","minLength","maxLength","len","ch","min","max","floatSafeRemainder","step","valDecCount","stepDecCount","decCount","valInt","stepInt","ZodNumber","kind","inclusive","ZodBigInt","ZodBoolean","ZodDate","minDate","maxDate","ZodSymbol","ZodUndefined","ZodNull","ZodAny","ZodUnknown","ZodNever","ZodVoid","schema","deepPartialify","ZodObject","newShape","fieldSchema","ZodTuple","shape","shapeKeys","extraKeys","keyValidator","unknownKeys","catchall","_b","_c","_d","defaultError","augmentation","merging","index","mask","newField","createZodEnum","handleResults","unionErrors","childCtx","dirty","types","getDiscriminator","type","ZodLazy","ZodLiteral","ZodEnum","ZodNativeEnum","ZodDiscriminatedUnion","discriminator","discriminatorValue","optionsMap","discriminatorValues","mergeValues","aType","bType","bKeys","sharedKeys","newObj","sharedValue","newArray","itemA","itemB","handleParsed","parsedLeft","parsedRight","merged","left","right","itemIndex","rest","schemas","ZodRecord","keyType","valueType","third","ZodMap","finalMap","ZodSet","finalizeSet","elements","parsedSet","element","minSize","maxSize","ZodFunction","makeArgsIssue","makeReturnsIssue","returns","fn","me","parsedArgs","parsedReturns","returnType","func","getter","values","expectedValues","enumValues","opt","nativeEnumValues","promisified","effect","checkCtx","arg","processed","executeRefinement","acc","inner","base","preprocess","newCtx","ZodNaN","BRAND","inResult","custom","fatal","p","_fatal","p2","late","instanceOfType","cls","stringType","numberType","nanType","bigIntType","booleanType","dateType","symbolType","undefinedType","nullType","anyType","unknownType","neverType","voidType","arrayType","objectType","strictObjectType","unionType","discriminatedUnionType","intersectionType","tupleType","recordType","mapType","setType","functionType","lazyType","literalType","enumType","nativeEnumType","promiseType","effectsType","optionalType","nullableType","preprocessType","pipelineType","ostring","onumber","oboolean","coerce","NEVER","z","numberCouple","dimensions","signedDimensions","DIMENSIONS","ALIGNMENTS","SIGNED_DIMENSIONS","xy","clientXY","DIRECTIONS","direction","OUTER_LOCATIONS","outerLocation","X_LOCATIONS","xLocation","Y_LOCATIONS","yLocation","CENTER_LOCATIONS","centerlocation","LOCATIONS","location","alignment","ORDERS","bounds","crudeDirection","crudeLocation","construct","lower","upper","makeValid","ZERO","INFINITE","DECIMAL","CLIP","equals","clamp","_bounds","contains","_target","overlapsWith","span","isZero","spanIsZero","isFinite","constructArray","findInsertPosition","ZERO_PLAN","buildInsertionPlan","deleteInBetween","insertInto","removeBefore","insert","plan","crude","c","swap","dimension","isDirection","signedDimension","jsCamelcase","toCamelCase","str","jsSnakecase","toSnakeCase","jsPascalcase","toPascalCase","jsDotcase","toDotCase","jsPathcase","toPathCase","jsTextcase","toTextCase","jsSentencecase","toSentenceCase","textcase","jsHeadercase","toHeaderCase","jsKebabcase","toKebabCase","exports","Type","__spreadArrays","this","s","il","r","j","jl","lowercaseKeysObject","utils_1","require$$0","lowerKeys","res","nkey","ret","temp","uppercaseKeysObject","upperKeys","camelcaseKeysObject","js_camelcase_1","require$$1","camelKeys","snakecaseKeysObject","js_snakecase_1","snakeKeys","pascalcaseKeysObject","js_pascalcase_1","pascalKeys","kebabcaseKeysObject","js_kebabcase_1","kebabKeys","lib","require$$2","js_dotcase_1","require$$3","js_pathcase_1","require$$4","js_textcase_1","require$$5","js_sentencecase_1","require$$6","js_headercase_1","require$$7","require$$8","lowercase_keys_object_1","require$$9","uppercase_keys_object_1","require$$10","camelcase_keys_object_1","require$$11","snakecase_keys_object_1","require$$12","pascalcase_keys_object_1","require$$13","kebabcase_keys_object_1","require$$14","toLowerCase","toUpperCase","jsConvert","jsConvertCase","entity","_snakeKeys","_camelKeys","Case","y","SWAPPED","ROTATE_90","cl","rotate90","l","corner","TOP_LEFT","TOP_RIGHT","BOTTOM_LEFT","BOTTOM_RIGHT","CENTER","TOP_CENTER","BOTTOM_CENTER","RIGHT_CENTER","LEFT_CENTER","XY_LOCATIONS","xyEquals","xyMatches","ok","xyCouple","isX","isY","xyToString","constructXY","parsedX","parsedY","crudeZ","ONE","INFINITY","NAN","threshold","a_","b_","scale","translateX","translateY","translate","cb","set","distance","ca","xDistance","yDistance","translation","isNan","couple","css","truncate","precision","cssPos","box","xy.xy","location.corner","xy.ZERO","location.TOP_LEFT","xy.ONE","location.BOTTOM_LEFT","copy","root","width","height","coordinateRoot","resize","dims","amount","dir","direction.construct","top","bottom","xy.equals","location.xyEquals","signedDims","signedWidth","signedHeight","dim","signed","xyLoc","center","loc","location.xyCouple","location.X_LOCATIONS","locPoint","loc_","topLeft","topRight","location.TOP_RIGHT","bottomLeft","bottomRight","location.BOTTOM_RIGHT","xy.translate","xBounds","yBounds","reRoot","positionSoVisible","target_","bound_","bound","nextPos","xy.construct","positionInCenter","x_","y_","isBox","aspect","intersect","x2","y2","area","xy.truncate","constructWithAlternateRoot","currRoot","newRoot","svgViewBox","factor","crudeXYTransform","xy.crudeZ","curriedTranslate","currScale","curriedMagnify","magnify","_type","curriedScale","prevLower","prevUpper","nextLower","nextUpper","prevRange","nextRange","nextV","curriedReBound","curriedInvert","curriedClamp","_Scale","__publicField","lowerOrBound","next","bounds.construct","vt","op","swaps","low","high","nextScale","Scale","xyScaleToTransform","_XY","cp","_xy","prevRoot","box.xBounds","box.yBounds","box.construct","XY","posititonSoVisible","innerWidth","innerHeight","changed","nextXY","xy.translateX","xy.translateY","parseLocationOptions","initial","parsedXYLoc","location.xy","parsedLoc","location.location","dialog","containerCrude","targetCrude","dialogCrude","prefer","alignments","disable","initialLocs","location.XY_LOCATIONS","parsedPrefer","hasPreferA","location.xyMatches","hasPreferB","mappedOptions","location.CENTER","d","container","bestOptionArea","adjustedBox","evaluateOption","getRoot","targetPoint","box.xyLoc","dialogBox","box.constructWithAlternateRoot","box.width","box.height","box.area","box.intersect","X_ALIGNMENT_MAP","Y_ALIGNMENT_MAP","out","location.swap","swapper","remainder","divisor","ts","TimeStamp","TimeSpan","_TimeStamp","tzInfo","offset","year","month","day","date","time","hours","minutes","mbeSeconds","seconds","milliseconds","format","iso","other","TimeRange","timestamps","_TimeSpan","totalDays","totalHours","totalMinutes","totalSeconds","totalMilliseconds","totalMicroseconds","totalNanoseconds","days","microseconds","nanoseconds","_Rate","duration","density","Density","sampleCount","Rate","_Density","Size","_TimeRange","start","end","rng","_DataType","DataType","_Size","totalTB","totalGB","totalMB","totalKB","totalB","tb","gb","mb","kb","bytes","typedArrayZ","isTelemValue","ot","convertDataType","source","addSamples","isCrudeSeries","Series","FULL_BUFFER","props","dataType","timeRange","sampleOffset","glBufferUsage","isSingle","isArray","data_","length","rate","buffer","gl","available","toWrite","den","update","required","slice","cf","compare.newF","mid","cmp","bufferUsage","prevBuffer","byteOffset","jsType","StringSeriesIterator","JSONSeriesIterator","FixedSeriesIterator","series","wrapped","MultiSeries","ser","buf","MultiSeriesIterator","unknownRecordZ","getEntries","convertRenderV","isObject","detect","RUNTIME","OPERATING_SYSTEMS","osZ","os","evalOS","userAgent","getOS","force","default_","deleteD","get","allowNull","parts","part","join","has","merge","objects","equal","aIsArray","bIsArray","aArr","bArr","aKeys","aVal","bVal","partialEqual","partial","baseKeys","partialKeys","baseVal","partialVal","memo","prevArgs","prevResult","difference","obj1","obj2","diffMap","compare","currentPath","debounce","waitFor","timeout","throttle","unique","joinPaths","paths","formatPath","removeTrailingSlash","buildQueryString","request","prefix","URL$1","host","port","protocol","pathPrefix","toArray","nullToArr","binary","Search","RoutedWorker","send","handler","typedSend","TypedWorker","payload","transfer","createMockWorkers","aSend","bSend","JSONEncoderDecoder","json","unpacked","ENCODERS","Observer","handlers","Z","shallowCopy","invert","condition","semVerZ","compareSemVer","semA","semB","aMajor","aMinor","aPatch","bMajor","bMinor","bPatch","semVerNewer","compare.isGreaterThan","migratable","migrator","migrations","latestVersion","migLength","old","migration","new_"],"mappings":"4PAAA,IAAIA,GACF,mEAWEC,GAAS,CAACC,EAAO,KAAO,CAC1B,IAAIC,EAAK,GACLC,EAAIF,EACR,KAAOE,KACLD,GAAMH,GAAa,KAAK,OAAQ,EAAG,GAAM,CAAC,EAE5C,OAAOG,CACT,ECKa,MAAAE,GAAcC,GACzBA,GAAS,MAAQ,OAAOA,GAAU,UAAY,aAAcA,EAIjDC,GAAmBD,GAA8B,CAC5D,GAAID,GAAWC,CAAK,EAAU,OAAAA,GAAA,YAAAA,EAAO,WAAW,UAAW,EAC3D,OAAQ,OAAOA,EAAO,CACpB,IAAK,SACH,OAAOA,EAAM,SAAW,EAC1B,IAAK,SACH,OAAOA,IAAU,EACnB,IAAK,SACH,OAAOA,IAAU,GACnB,IAAK,UACH,MAAO,CAACA,EACV,IAAK,YACI,MAAA,GACT,IAAK,SACH,OAAOA,IAAU,IACrB,CACF,ECvBaE,GAAO,CAClBC,EACAC,EAAmB,KACH,CAChB,MAAMC,EAAIN,GAAWI,CAAC,EAAI,WAAa,OAAOA,EAC1C,IAAAG,EACJ,OAAQD,EAAG,CACT,IAAK,SACHC,EAAI,CAACC,EAAMC,IAAUD,EAAa,cAAcC,CAAW,EAC3D,MACF,IAAK,WACCF,EAAA,CAACC,EAAMC,IACRD,EAAa,SAAW,EAAA,cAAeC,EAAa,SAAA,CAAU,EACjE,MACF,IA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MAAM,iBAAiB,EAInDwhB,GAA0C,CAACp2B,EAAGC,IAAM,CAClD,MAAAo2B,EAAOF,GAAQ,MAAMn2B,CAAC,EACtBs2B,EAAOH,GAAQ,MAAMl2B,CAAC,EACtB,CAACs2B,EAAQC,EAAQC,CAAM,EAAIJ,EAAK,MAAM,GAAG,EAAE,IAAI,MAAM,EACrD,CAACK,EAAQC,EAAQC,CAAM,EAAIN,EAAK,MAAM,GAAG,EAAE,IAAI,MAAM,EAC3D,OAAIC,IAAWG,EAAeH,EAASG,EACnCF,IAAWG,EAAeH,EAASG,EAChCF,EAASG,CAClB,EAEMC,GAAc,CAAC72B,EAAWC,IAC9B62B,GAAsBV,GAAcp2B,EAAGC,CAAC,CAAC,EAE9B82B,GAAaniB,EAAE,OAAO,CACjC,QAASuhB,EACX,CAAC,EAUYa,GACXC,GACoB,CACd,MAAAC,EAAgB,OAAO,KAAKD,CAAU,EAAE,KAAKb,EAAa,EAAE,IAAS,GAAA,GACrEe,EAAY,OAAO,KAAKF,CAAU,EAAE,OACpCl3B,EAAKq3B,GAAgC,CACzC,GAAID,IAAc,GAAKN,GAAYO,EAAI,QAASF,CAAa,EAAU,OAAAE,EACvE,MAAM9tB,EAAU8tB,EAAI,QACdC,EAAYJ,EAAW3tB,CAAO,EAC9BguB,EAAmBD,EAAUD,CAAG,EACtC,OAAOr3B,EAAEu3B,CAAI,CAAA,EAER,OAAAv3B,CACT","x_google_ignoreList":[0,3,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]}
|
|
1
|
+
{"version":3,"file":"x.cjs","sources":["../../../node_modules/.pnpm/nanoid@3.3.7/node_modules/nanoid/non-secure/index.js","../src/primitive.ts","../src/compare/compare.ts","../../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs","../src/spatial/base.ts","../src/spatial/bounds/bounds.ts","../src/spatial/direction/direction.ts","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-camelcase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-snakecase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-pascalcase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-dotcase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-pathcase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-textcase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-sentencecase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-headercase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/js-kebabcase/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/extends/utils.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/extends/lowercase-keys-object/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/extends/uppercase-keys-object/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/extends/camelcase-keys-object/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/extends/snakecase-keys-object/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/extends/pascalcase-keys-object/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/modules/extends/kebabcase-keys-object/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/lib/index.js","../../../node_modules/.pnpm/js-convert-case@4.2.0/node_modules/js-convert-case/index.js","../src/case.ts","../src/spatial/location/location.ts","../src/spatial/xy/xy.ts","../src/spatial/box/box.ts","../src/spatial/dimensions/dimensions.ts","../src/clamp.ts","../src/spatial/scale/scale.ts","../src/spatial/position/position.ts","../src/telem/telem.ts","../src/telem/series.ts","../src/record.ts","../src/renderable.ts","../src/identity.ts","../src/runtime/detect.ts","../src/runtime/os.ts","../src/deep/copy.ts","../src/deep/delete.ts","../src/deep/path.ts","../src/deep/merge.ts","../src/deep/equal.ts","../src/deep/memo.ts","../src/deep/difference.ts","../src/debounce.ts","../src/unique.ts","../src/url/url.ts","../src/toArray.ts","../src/search.ts","../src/worker/worker.ts","../src/binary/encoder.ts","../src/observe/observe.ts","../src/change/change.ts","../src/shallowCopy.ts","../src/invert.ts","../src/migrate/migrate.ts"],"sourcesContent":["let urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\nlet customAlphabet = (alphabet, defaultSize = 21) => {\n return (size = defaultSize) => {\n let id = ''\n let i = size\n while (i--) {\n id += alphabet[(Math.random() * alphabet.length) | 0]\n }\n return id\n }\n}\nlet nanoid = (size = 21) => {\n let id = ''\n let i = size\n while (i--) {\n id += urlAlphabet[(Math.random() * 64) | 0]\n }\n return id\n}\nexport { nanoid, customAlphabet }\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Key } from \"@/record\";\n\nexport type Primitive =\n | string\n | number\n | bigint\n | boolean\n | Stringer\n | null\n | undefined;\n\nexport interface Stringer {\n toString: () => string;\n}\n\nexport const isStringer = (value: unknown): boolean =>\n value != null && typeof value === \"object\" && \"toString\" in value;\n\nexport type PrimitiveRecord = Record<Key, Primitive>;\n\nexport const primitiveIsZero = (value: Primitive): boolean => {\n if (isStringer(value)) return value?.toString().length === 0;\n switch (typeof value) {\n case \"string\":\n return value.length === 0;\n case \"number\":\n return value === 0;\n case \"bigint\":\n return value === 0n;\n case \"boolean\":\n return !value;\n case \"undefined\":\n return true;\n case \"object\":\n return value === null;\n }\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Primitive, isStringer, type PrimitiveRecord } from \"@/primitive\";\nimport { type spatial } from \"@/spatial\";\n\nexport type CompareF<T> = (a: T, b: T) => number;\n\n/**\n * Creates the appropriate compare function for sorting the given\n * primitive type.\n *\n * @param v The primitive value to create a compare function for.\n * This is used to determine the type of comparison to perform.\n * @param reverse Whether to reverse the sort order.\n */\nexport const newF = <T extends Primitive>(\n v: T,\n reverse: boolean = false,\n): CompareF<T> => {\n const t = isStringer(v) ? \"stringer\" : typeof v;\n let f: CompareF<T>;\n switch (t) {\n case \"string\":\n f = (a: T, b: T) => (a as string).localeCompare(b as string);\n break;\n case \"stringer\":\n f = (a: T, b: T) =>\n (a as string).toString().localeCompare((b as string).toString());\n break;\n case \"number\":\n f = (a: T, b: T) => (a as number) - (b as number);\n break;\n case \"bigint\":\n f = (a: T, b: T) => ((a as bigint) - (b as bigint) > BigInt(0) ? 1 : -1);\n break;\n case \"boolean\":\n f = (a: T, b: T) => Number(a) - Number(b);\n break;\n default:\n console.warn(\"sortFunc: unknown type\");\n return () => -1;\n }\n return reverse ? reverseF(f) : f;\n};\n\n/**\n * Creates a compare function that compares the field of the given object.\n *\n * @param key The key of the field to compare.\n * @param value The object to compare the field of. This is used to determine the type of\n * comparison to perform.\n * @param reverse Whether to reverse the sort order.\n */\nexport const newFieldF = <T extends PrimitiveRecord>(\n key: keyof T,\n value: T,\n reverse?: boolean,\n): CompareF<T> => {\n const f = newF(value[key], reverse);\n return (a: T, b: T) => f(a[key], b[key]);\n};\n\n/**\n * Compares the two primitive arrays.\n * @param a The first array to compare.\n * @param b The second array to compare.\n * @returns The array with the greater length if the array lengths are not equal. If the\n * arrays are the same length, returns 0 if all elements are equal, otherwise returns -1.\n */\nexport const primitiveArrays = <T extends Primitive>(\n a: readonly T[] | T[],\n b: readonly T[] | T[],\n): number => {\n if (a.length !== b.length) return a.length - b.length;\n return a.every((v, i) => v === b[i]) ? 0 : -1;\n};\n\nexport const unorderedPrimitiveArrays = <T extends Primitive>(\n a: readonly T[] | T[],\n b: readonly T[] | T[],\n): number => {\n if (a.length !== b.length) return a.length - b.length;\n if (a.length === 0) return 0;\n const compareF = newF(a[0]);\n const aSorted = [...a].sort(compareF);\n const bSorted = [...b].sort(compareF);\n return aSorted.every((v, i) => v === bSorted[i]) ? 0 : -1;\n};\n\nexport const order = (a: spatial.Order, b: spatial.Order): number => {\n if (a === b) return 0;\n if (a === \"first\" && b === \"last\") return 1;\n return -1;\n};\n\n/** @returns the reverse of the given compare function. */\nexport const reverseF =\n <T>(f: CompareF<T>): CompareF<T> =>\n (a: T, b: T) =>\n f(b, a);\n\n/** The equal return value of a compare function. */\nexport const EQUAL = 0;\n\n/** The less than return value of a compare function. */\nexport const LESS_THAN = -1;\n\n/** The greater than return value of a compare function. */\nexport const GREATER_THAN = 1;\n\nexport const isLessThan = (n: number): boolean => n < EQUAL;\n\nexport const isGreaterThan = (n: number): boolean => n > EQUAL;\n\nexport const isGreaterThanEqual = (n: number): boolean => n >= EQUAL;\n","var util;\n(function (util) {\n util.assertEqual = (val) => val;\n function assertIs(_arg) { }\n util.assertIs = assertIs;\n function assertNever(_x) {\n throw new Error();\n }\n util.assertNever = assertNever;\n util.arrayToEnum = (items) => {\n const obj = {};\n for (const item of items) {\n obj[item] = item;\n }\n return obj;\n };\n util.getValidEnumValues = (obj) => {\n const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== \"number\");\n const filtered = {};\n for (const k of validKeys) {\n filtered[k] = obj[k];\n }\n return util.objectValues(filtered);\n };\n util.objectValues = (obj) => {\n return util.objectKeys(obj).map(function (e) {\n return obj[e];\n });\n };\n util.objectKeys = typeof Object.keys === \"function\" // eslint-disable-line ban/ban\n ? (obj) => Object.keys(obj) // eslint-disable-line ban/ban\n : (object) => {\n const keys = [];\n for (const key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n keys.push(key);\n }\n }\n return keys;\n };\n util.find = (arr, checker) => {\n for (const item of arr) {\n if (checker(item))\n return item;\n }\n return undefined;\n };\n util.isInteger = typeof Number.isInteger === \"function\"\n ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban\n : (val) => typeof val === \"number\" && isFinite(val) && Math.floor(val) === val;\n function joinValues(array, separator = \" | \") {\n return array\n .map((val) => (typeof val === \"string\" ? `'${val}'` : val))\n .join(separator);\n }\n util.joinValues = joinValues;\n util.jsonStringifyReplacer = (_, value) => {\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n return value;\n };\n})(util || (util = {}));\nvar objectUtil;\n(function (objectUtil) {\n objectUtil.mergeShapes = (first, second) => {\n return {\n ...first,\n ...second, // second overwrites first\n };\n };\n})(objectUtil || (objectUtil = {}));\nconst ZodParsedType = util.arrayToEnum([\n \"string\",\n \"nan\",\n \"number\",\n \"integer\",\n \"float\",\n \"boolean\",\n \"date\",\n \"bigint\",\n \"symbol\",\n \"function\",\n \"undefined\",\n \"null\",\n \"array\",\n \"object\",\n \"unknown\",\n \"promise\",\n \"void\",\n \"never\",\n \"map\",\n \"set\",\n]);\nconst getParsedType = (data) => {\n const t = typeof data;\n switch (t) {\n case \"undefined\":\n return ZodParsedType.undefined;\n case \"string\":\n return ZodParsedType.string;\n case \"number\":\n return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;\n case \"boolean\":\n return ZodParsedType.boolean;\n case \"function\":\n return ZodParsedType.function;\n case \"bigint\":\n return ZodParsedType.bigint;\n case \"symbol\":\n return ZodParsedType.symbol;\n case \"object\":\n if (Array.isArray(data)) {\n return ZodParsedType.array;\n }\n if (data === null) {\n return ZodParsedType.null;\n }\n if (data.then &&\n typeof data.then === \"function\" &&\n data.catch &&\n typeof data.catch === \"function\") {\n return ZodParsedType.promise;\n }\n if (typeof Map !== \"undefined\" && data instanceof Map) {\n return ZodParsedType.map;\n }\n if (typeof Set !== \"undefined\" && data instanceof Set) {\n return ZodParsedType.set;\n }\n if (typeof Date !== \"undefined\" && data instanceof Date) {\n return ZodParsedType.date;\n }\n return ZodParsedType.object;\n default:\n return ZodParsedType.unknown;\n }\n};\n\nconst ZodIssueCode = util.arrayToEnum([\n \"invalid_type\",\n \"invalid_literal\",\n \"custom\",\n \"invalid_union\",\n \"invalid_union_discriminator\",\n \"invalid_enum_value\",\n \"unrecognized_keys\",\n \"invalid_arguments\",\n \"invalid_return_type\",\n \"invalid_date\",\n \"invalid_string\",\n \"too_small\",\n \"too_big\",\n \"invalid_intersection_types\",\n \"not_multiple_of\",\n \"not_finite\",\n]);\nconst quotelessJson = (obj) => {\n const json = JSON.stringify(obj, null, 2);\n return json.replace(/\"([^\"]+)\":/g, \"$1:\");\n};\nclass ZodError extends Error {\n constructor(issues) {\n super();\n this.issues = [];\n this.addIssue = (sub) => {\n this.issues = [...this.issues, sub];\n };\n this.addIssues = (subs = []) => {\n this.issues = [...this.issues, ...subs];\n };\n const actualProto = new.target.prototype;\n if (Object.setPrototypeOf) {\n // eslint-disable-next-line ban/ban\n Object.setPrototypeOf(this, actualProto);\n }\n else {\n this.__proto__ = actualProto;\n }\n this.name = \"ZodError\";\n this.issues = issues;\n }\n get errors() {\n return this.issues;\n }\n format(_mapper) {\n const mapper = _mapper ||\n function (issue) {\n return issue.message;\n };\n const fieldErrors = { _errors: [] };\n const processError = (error) => {\n for (const issue of error.issues) {\n if (issue.code === \"invalid_union\") {\n issue.unionErrors.map(processError);\n }\n else if (issue.code === \"invalid_return_type\") {\n processError(issue.returnTypeError);\n }\n else if (issue.code === \"invalid_arguments\") {\n processError(issue.argumentsError);\n }\n else if (issue.path.length === 0) {\n fieldErrors._errors.push(mapper(issue));\n }\n else {\n let curr = fieldErrors;\n let i = 0;\n while (i < issue.path.length) {\n const el = issue.path[i];\n const terminal = i === issue.path.length - 1;\n if (!terminal) {\n curr[el] = curr[el] || { _errors: [] };\n // if (typeof el === \"string\") {\n // curr[el] = curr[el] || { _errors: [] };\n // } else if (typeof el === \"number\") {\n // const errorArray: any = [];\n // errorArray._errors = [];\n // curr[el] = curr[el] || errorArray;\n // }\n }\n else {\n curr[el] = curr[el] || { _errors: [] };\n curr[el]._errors.push(mapper(issue));\n }\n curr = curr[el];\n i++;\n }\n }\n }\n };\n processError(this);\n return fieldErrors;\n }\n toString() {\n return this.message;\n }\n get message() {\n return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);\n }\n get isEmpty() {\n return this.issues.length === 0;\n }\n flatten(mapper = (issue) => issue.message) {\n const fieldErrors = {};\n const formErrors = [];\n for (const sub of this.issues) {\n if (sub.path.length > 0) {\n fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];\n fieldErrors[sub.path[0]].push(mapper(sub));\n }\n else {\n formErrors.push(mapper(sub));\n }\n }\n return { formErrors, fieldErrors };\n }\n get formErrors() {\n return this.flatten();\n }\n}\nZodError.create = (issues) => {\n const error = new ZodError(issues);\n return error;\n};\n\nconst errorMap = (issue, _ctx) => {\n let message;\n switch (issue.code) {\n case ZodIssueCode.invalid_type:\n if (issue.received === ZodParsedType.undefined) {\n message = \"Required\";\n }\n else {\n message = `Expected ${issue.expected}, received ${issue.received}`;\n }\n break;\n case ZodIssueCode.invalid_literal:\n message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;\n break;\n case ZodIssueCode.unrecognized_keys:\n message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, \", \")}`;\n break;\n case ZodIssueCode.invalid_union:\n message = `Invalid input`;\n break;\n case ZodIssueCode.invalid_union_discriminator:\n message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;\n break;\n case ZodIssueCode.invalid_enum_value:\n message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;\n break;\n case ZodIssueCode.invalid_arguments:\n message = `Invalid function arguments`;\n break;\n case ZodIssueCode.invalid_return_type:\n message = `Invalid function return type`;\n break;\n case ZodIssueCode.invalid_date:\n message = `Invalid date`;\n break;\n case ZodIssueCode.invalid_string:\n if (typeof issue.validation === \"object\") {\n if (\"includes\" in issue.validation) {\n message = `Invalid input: must include \"${issue.validation.includes}\"`;\n if (typeof issue.validation.position === \"number\") {\n message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;\n }\n }\n else if (\"startsWith\" in issue.validation) {\n message = `Invalid input: must start with \"${issue.validation.startsWith}\"`;\n }\n else if (\"endsWith\" in issue.validation) {\n message = `Invalid input: must end with \"${issue.validation.endsWith}\"`;\n }\n else {\n util.assertNever(issue.validation);\n }\n }\n else if (issue.validation !== \"regex\") {\n message = `Invalid ${issue.validation}`;\n }\n else {\n message = \"Invalid\";\n }\n break;\n case ZodIssueCode.too_small:\n if (issue.type === \"array\")\n message = `Array must contain ${issue.exact ? \"exactly\" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;\n else if (issue.type === \"string\")\n message = `String must contain ${issue.exact ? \"exactly\" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;\n else if (issue.type === \"number\")\n message = `Number must be ${issue.exact\n ? `exactly equal to `\n : issue.inclusive\n ? `greater than or equal to `\n : `greater than `}${issue.minimum}`;\n else if (issue.type === \"date\")\n message = `Date must be ${issue.exact\n ? `exactly equal to `\n : issue.inclusive\n ? `greater than or equal to `\n : `greater than `}${new Date(Number(issue.minimum))}`;\n else\n message = \"Invalid input\";\n break;\n case ZodIssueCode.too_big:\n if (issue.type === \"array\")\n message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;\n else if (issue.type === \"string\")\n message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;\n else if (issue.type === \"number\")\n message = `Number must be ${issue.exact\n ? `exactly`\n : issue.inclusive\n ? `less than or equal to`\n : `less than`} ${issue.maximum}`;\n else if (issue.type === \"bigint\")\n message = `BigInt must be ${issue.exact\n ? `exactly`\n : issue.inclusive\n ? `less than or equal to`\n : `less than`} ${issue.maximum}`;\n else if (issue.type === \"date\")\n message = `Date must be ${issue.exact\n ? `exactly`\n : issue.inclusive\n ? `smaller than or equal to`\n : `smaller than`} ${new Date(Number(issue.maximum))}`;\n else\n message = \"Invalid input\";\n break;\n case ZodIssueCode.custom:\n message = `Invalid input`;\n break;\n case ZodIssueCode.invalid_intersection_types:\n message = `Intersection results could not be merged`;\n break;\n case ZodIssueCode.not_multiple_of:\n message = `Number must be a multiple of ${issue.multipleOf}`;\n break;\n case ZodIssueCode.not_finite:\n message = \"Number must be finite\";\n break;\n default:\n message = _ctx.defaultError;\n util.assertNever(issue);\n }\n return { message };\n};\n\nlet overrideErrorMap = errorMap;\nfunction setErrorMap(map) {\n overrideErrorMap = map;\n}\nfunction getErrorMap() {\n return overrideErrorMap;\n}\n\nconst makeIssue = (params) => {\n const { data, path, errorMaps, issueData } = params;\n const fullPath = [...path, ...(issueData.path || [])];\n const fullIssue = {\n ...issueData,\n path: fullPath,\n };\n let errorMessage = \"\";\n const maps = errorMaps\n .filter((m) => !!m)\n .slice()\n .reverse();\n for (const map of maps) {\n errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;\n }\n return {\n ...issueData,\n path: fullPath,\n message: issueData.message || errorMessage,\n };\n};\nconst EMPTY_PATH = [];\nfunction addIssueToContext(ctx, issueData) {\n const issue = makeIssue({\n issueData: issueData,\n data: ctx.data,\n path: ctx.path,\n errorMaps: [\n ctx.common.contextualErrorMap,\n ctx.schemaErrorMap,\n getErrorMap(),\n errorMap, // then global default map\n ].filter((x) => !!x),\n });\n ctx.common.issues.push(issue);\n}\nclass ParseStatus {\n constructor() {\n this.value = \"valid\";\n }\n dirty() {\n if (this.value === \"valid\")\n this.value = \"dirty\";\n }\n abort() {\n if (this.value !== \"aborted\")\n this.value = \"aborted\";\n }\n static mergeArray(status, results) {\n const arrayValue = [];\n for (const s of results) {\n if (s.status === \"aborted\")\n return INVALID;\n if (s.status === \"dirty\")\n status.dirty();\n arrayValue.push(s.value);\n }\n return { status: status.value, value: arrayValue };\n }\n static async mergeObjectAsync(status, pairs) {\n const syncPairs = [];\n for (const pair of pairs) {\n syncPairs.push({\n key: await pair.key,\n value: await pair.value,\n });\n }\n return ParseStatus.mergeObjectSync(status, syncPairs);\n }\n static mergeObjectSync(status, pairs) {\n const finalObject = {};\n for (const pair of pairs) {\n const { key, value } = pair;\n if (key.status === \"aborted\")\n return INVALID;\n if (value.status === \"aborted\")\n return INVALID;\n if (key.status === \"dirty\")\n status.dirty();\n if (value.status === \"dirty\")\n status.dirty();\n if (key.value !== \"__proto__\" &&\n (typeof value.value !== \"undefined\" || pair.alwaysSet)) {\n finalObject[key.value] = value.value;\n }\n }\n return { status: status.value, value: finalObject };\n }\n}\nconst INVALID = Object.freeze({\n status: \"aborted\",\n});\nconst DIRTY = (value) => ({ status: \"dirty\", value });\nconst OK = (value) => ({ status: \"valid\", value });\nconst isAborted = (x) => x.status === \"aborted\";\nconst isDirty = (x) => x.status === \"dirty\";\nconst isValid = (x) => x.status === \"valid\";\nconst isAsync = (x) => typeof Promise !== \"undefined\" && x instanceof Promise;\n\nvar errorUtil;\n(function (errorUtil) {\n errorUtil.errToObj = (message) => typeof message === \"string\" ? { message } : message || {};\n errorUtil.toString = (message) => typeof message === \"string\" ? message : message === null || message === void 0 ? void 0 : message.message;\n})(errorUtil || (errorUtil = {}));\n\nclass ParseInputLazyPath {\n constructor(parent, value, path, key) {\n this._cachedPath = [];\n this.parent = parent;\n this.data = value;\n this._path = path;\n this._key = key;\n }\n get path() {\n if (!this._cachedPath.length) {\n if (this._key instanceof Array) {\n this._cachedPath.push(...this._path, ...this._key);\n }\n else {\n this._cachedPath.push(...this._path, this._key);\n }\n }\n return this._cachedPath;\n }\n}\nconst handleResult = (ctx, result) => {\n if (isValid(result)) {\n return { success: true, data: result.value };\n }\n else {\n if (!ctx.common.issues.length) {\n throw new Error(\"Validation failed but no issues detected.\");\n }\n return {\n success: false,\n get error() {\n if (this._error)\n return this._error;\n const error = new ZodError(ctx.common.issues);\n this._error = error;\n return this._error;\n },\n };\n }\n};\nfunction processCreateParams(params) {\n if (!params)\n return {};\n const { errorMap, invalid_type_error, required_error, description } = params;\n if (errorMap && (invalid_type_error || required_error)) {\n throw new Error(`Can't use \"invalid_type_error\" or \"required_error\" in conjunction with custom error map.`);\n }\n if (errorMap)\n return { errorMap: errorMap, description };\n const customMap = (iss, ctx) => {\n if (iss.code !== \"invalid_type\")\n return { message: ctx.defaultError };\n if (typeof ctx.data === \"undefined\") {\n return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };\n }\n return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };\n };\n return { errorMap: customMap, description };\n}\nclass ZodType {\n constructor(def) {\n /** Alias of safeParseAsync */\n this.spa = this.safeParseAsync;\n this._def = def;\n this.parse = this.parse.bind(this);\n this.safeParse = this.safeParse.bind(this);\n this.parseAsync = this.parseAsync.bind(this);\n this.safeParseAsync = this.safeParseAsync.bind(this);\n this.spa = this.spa.bind(this);\n this.refine = this.refine.bind(this);\n this.refinement = this.refinement.bind(this);\n this.superRefine = this.superRefine.bind(this);\n this.optional = this.optional.bind(this);\n this.nullable = this.nullable.bind(this);\n this.nullish = this.nullish.bind(this);\n this.array = this.array.bind(this);\n this.promise = this.promise.bind(this);\n this.or = this.or.bind(this);\n this.and = this.and.bind(this);\n this.transform = this.transform.bind(this);\n this.brand = this.brand.bind(this);\n this.default = this.default.bind(this);\n this.catch = this.catch.bind(this);\n this.describe = this.describe.bind(this);\n this.pipe = this.pipe.bind(this);\n this.readonly = this.readonly.bind(this);\n this.isNullable = this.isNullable.bind(this);\n this.isOptional = this.isOptional.bind(this);\n }\n get description() {\n return this._def.description;\n }\n _getType(input) {\n return getParsedType(input.data);\n }\n _getOrReturnCtx(input, ctx) {\n return (ctx || {\n common: input.parent.common,\n data: input.data,\n parsedType: getParsedType(input.data),\n schemaErrorMap: this._def.errorMap,\n path: input.path,\n parent: input.parent,\n });\n }\n _processInputParams(input) {\n return {\n status: new ParseStatus(),\n ctx: {\n common: input.parent.common,\n data: input.data,\n parsedType: getParsedType(input.data),\n schemaErrorMap: this._def.errorMap,\n path: input.path,\n parent: input.parent,\n },\n };\n }\n _parseSync(input) {\n const result = this._parse(input);\n if (isAsync(result)) {\n throw new Error(\"Synchronous parse encountered promise.\");\n }\n return result;\n }\n _parseAsync(input) {\n const result = this._parse(input);\n return Promise.resolve(result);\n }\n parse(data, params) {\n const result = this.safeParse(data, params);\n if (result.success)\n return result.data;\n throw result.error;\n }\n safeParse(data, params) {\n var _a;\n const ctx = {\n common: {\n issues: [],\n async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,\n contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,\n },\n path: (params === null || params === void 0 ? void 0 : params.path) || [],\n schemaErrorMap: this._def.errorMap,\n parent: null,\n data,\n parsedType: getParsedType(data),\n };\n const result = this._parseSync({ data, path: ctx.path, parent: ctx });\n return handleResult(ctx, result);\n }\n async parseAsync(data, params) {\n const result = await this.safeParseAsync(data, params);\n if (result.success)\n return result.data;\n throw result.error;\n }\n async safeParseAsync(data, params) {\n const ctx = {\n common: {\n issues: [],\n contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,\n async: true,\n },\n path: (params === null || params === void 0 ? void 0 : params.path) || [],\n schemaErrorMap: this._def.errorMap,\n parent: null,\n data,\n parsedType: getParsedType(data),\n };\n const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });\n const result = await (isAsync(maybeAsyncResult)\n ? maybeAsyncResult\n : Promise.resolve(maybeAsyncResult));\n return handleResult(ctx, result);\n }\n refine(check, message) {\n const getIssueProperties = (val) => {\n if (typeof message === \"string\" || typeof message === \"undefined\") {\n return { message };\n }\n else if (typeof message === \"function\") {\n return message(val);\n }\n else {\n return message;\n }\n };\n return this._refinement((val, ctx) => {\n const result = check(val);\n const setError = () => ctx.addIssue({\n code: ZodIssueCode.custom,\n ...getIssueProperties(val),\n });\n if (typeof Promise !== \"undefined\" && result instanceof Promise) {\n return result.then((data) => {\n if (!data) {\n setError();\n return false;\n }\n else {\n return true;\n }\n });\n }\n if (!result) {\n setError();\n return false;\n }\n else {\n return true;\n }\n });\n }\n refinement(check, refinementData) {\n return this._refinement((val, ctx) => {\n if (!check(val)) {\n ctx.addIssue(typeof refinementData === \"function\"\n ? refinementData(val, ctx)\n : refinementData);\n return false;\n }\n else {\n return true;\n }\n });\n }\n _refinement(refinement) {\n return new ZodEffects({\n schema: this,\n typeName: ZodFirstPartyTypeKind.ZodEffects,\n effect: { type: \"refinement\", refinement },\n });\n }\n superRefine(refinement) {\n return this._refinement(refinement);\n }\n optional() {\n return ZodOptional.create(this, this._def);\n }\n nullable() {\n return ZodNullable.create(this, this._def);\n }\n nullish() {\n return this.nullable().optional();\n }\n array() {\n return ZodArray.create(this, this._def);\n }\n promise() {\n return ZodPromise.create(this, this._def);\n }\n or(option) {\n return ZodUnion.create([this, option], this._def);\n }\n and(incoming) {\n return ZodIntersection.create(this, incoming, this._def);\n }\n transform(transform) {\n return new ZodEffects({\n ...processCreateParams(this._def),\n schema: this,\n typeName: ZodFirstPartyTypeKind.ZodEffects,\n effect: { type: \"transform\", transform },\n });\n }\n default(def) {\n const defaultValueFunc = typeof def === \"function\" ? def : () => def;\n return new ZodDefault({\n ...processCreateParams(this._def),\n innerType: this,\n defaultValue: defaultValueFunc,\n typeName: ZodFirstPartyTypeKind.ZodDefault,\n });\n }\n brand() {\n return new ZodBranded({\n typeName: ZodFirstPartyTypeKind.ZodBranded,\n type: this,\n ...processCreateParams(this._def),\n });\n }\n catch(def) {\n const catchValueFunc = typeof def === \"function\" ? def : () => def;\n return new ZodCatch({\n ...processCreateParams(this._def),\n innerType: this,\n catchValue: catchValueFunc,\n typeName: ZodFirstPartyTypeKind.ZodCatch,\n });\n }\n describe(description) {\n const This = this.constructor;\n return new This({\n ...this._def,\n description,\n });\n }\n pipe(target) {\n return ZodPipeline.create(this, target);\n }\n readonly() {\n return ZodReadonly.create(this);\n }\n isOptional() {\n return this.safeParse(undefined).success;\n }\n isNullable() {\n return this.safeParse(null).success;\n }\n}\nconst cuidRegex = /^c[^\\s-]{8,}$/i;\nconst cuid2Regex = /^[a-z][a-z0-9]*$/;\nconst ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;\n// const uuidRegex =\n// /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;\nconst uuidRegex = /^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/i;\n// from https://stackoverflow.com/a/46181/1550155\n// old version: too slow, didn't support unicode\n// const emailRegex = /^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))$/i;\n//old email regex\n// const emailRegex = /^(([^<>()[\\].,;:\\s@\"]+(\\.[^<>()[\\].,;:\\s@\"]+)*)|(\".+\"))@((?!-)([^<>()[\\].,;:\\s@\"]+\\.)+[^<>()[\\].,;:\\s@\"]{1,})[^-<>()[\\].,;:\\s@\"]$/i;\n// eslint-disable-next-line\n// const emailRegex =\n// /^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\])|(\\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\\.[A-Za-z]{2,})+))$/;\n// const emailRegex =\n// /^[a-zA-Z0-9\\.\\!\\#\\$\\%\\&\\'\\*\\+\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~\\-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;\n// const emailRegex =\n// /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])$/i;\nconst emailRegex = /^(?!\\.)(?!.*\\.\\.)([A-Z0-9_+-\\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\\-]*\\.)+[A-Z]{2,}$/i;\n// const emailRegex =\n// /^[a-z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\\.[a-z0-9\\-]+)*$/i;\n// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression\nconst _emojiRegex = `^(\\\\p{Extended_Pictographic}|\\\\p{Emoji_Component})+$`;\nlet emojiRegex;\nconst ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/;\nconst ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;\n// Adapted from https://stackoverflow.com/a/3143231\nconst datetimeRegex = (args) => {\n if (args.precision) {\n if (args.offset) {\n return new RegExp(`^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}\\\\.\\\\d{${args.precision}}(([+-]\\\\d{2}(:?\\\\d{2})?)|Z)$`);\n }\n else {\n return new RegExp(`^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}\\\\.\\\\d{${args.precision}}Z$`);\n }\n }\n else if (args.precision === 0) {\n if (args.offset) {\n return new RegExp(`^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}(([+-]\\\\d{2}(:?\\\\d{2})?)|Z)$`);\n }\n else {\n return new RegExp(`^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}Z$`);\n }\n }\n else {\n if (args.offset) {\n return new RegExp(`^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}(\\\\.\\\\d+)?(([+-]\\\\d{2}(:?\\\\d{2})?)|Z)$`);\n }\n else {\n return new RegExp(`^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}(\\\\.\\\\d+)?Z$`);\n }\n }\n};\nfunction isValidIP(ip, version) {\n if ((version === \"v4\" || !version) && ipv4Regex.test(ip)) {\n return true;\n }\n if ((version === \"v6\" || !version) && ipv6Regex.test(ip)) {\n return true;\n }\n return false;\n}\nclass ZodString extends ZodType {\n _parse(input) {\n if (this._def.coerce) {\n input.data = String(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.string) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.string,\n received: ctx.parsedType,\n }\n //\n );\n return INVALID;\n }\n const status = new ParseStatus();\n let ctx = undefined;\n for (const check of this._def.checks) {\n if (check.kind === \"min\") {\n if (input.data.length < check.value) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: check.value,\n type: \"string\",\n inclusive: true,\n exact: false,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"max\") {\n if (input.data.length > check.value) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: check.value,\n type: \"string\",\n inclusive: true,\n exact: false,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"length\") {\n const tooBig = input.data.length > check.value;\n const tooSmall = input.data.length < check.value;\n if (tooBig || tooSmall) {\n ctx = this._getOrReturnCtx(input, ctx);\n if (tooBig) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: check.value,\n type: \"string\",\n inclusive: true,\n exact: true,\n message: check.message,\n });\n }\n else if (tooSmall) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: check.value,\n type: \"string\",\n inclusive: true,\n exact: true,\n message: check.message,\n });\n }\n status.dirty();\n }\n }\n else if (check.kind === \"email\") {\n if (!emailRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"email\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"emoji\") {\n if (!emojiRegex) {\n emojiRegex = new RegExp(_emojiRegex, \"u\");\n }\n if (!emojiRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"emoji\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"uuid\") {\n if (!uuidRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"uuid\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"cuid\") {\n if (!cuidRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"cuid\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"cuid2\") {\n if (!cuid2Regex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"cuid2\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"ulid\") {\n if (!ulidRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"ulid\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"url\") {\n try {\n new URL(input.data);\n }\n catch (_a) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"url\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"regex\") {\n check.regex.lastIndex = 0;\n const testResult = check.regex.test(input.data);\n if (!testResult) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"regex\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"trim\") {\n input.data = input.data.trim();\n }\n else if (check.kind === \"includes\") {\n if (!input.data.includes(check.value, check.position)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: { includes: check.value, position: check.position },\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"toLowerCase\") {\n input.data = input.data.toLowerCase();\n }\n else if (check.kind === \"toUpperCase\") {\n input.data = input.data.toUpperCase();\n }\n else if (check.kind === \"startsWith\") {\n if (!input.data.startsWith(check.value)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: { startsWith: check.value },\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"endsWith\") {\n if (!input.data.endsWith(check.value)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: { endsWith: check.value },\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"datetime\") {\n const regex = datetimeRegex(check);\n if (!regex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: \"datetime\",\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"ip\") {\n if (!isValidIP(input.data, check.version)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: \"ip\",\n code: ZodIssueCode.invalid_string,\n message: check.message,\n });\n status.dirty();\n }\n }\n else {\n util.assertNever(check);\n }\n }\n return { status: status.value, value: input.data };\n }\n _regex(regex, validation, message) {\n return this.refinement((data) => regex.test(data), {\n validation,\n code: ZodIssueCode.invalid_string,\n ...errorUtil.errToObj(message),\n });\n }\n _addCheck(check) {\n return new ZodString({\n ...this._def,\n checks: [...this._def.checks, check],\n });\n }\n email(message) {\n return this._addCheck({ kind: \"email\", ...errorUtil.errToObj(message) });\n }\n url(message) {\n return this._addCheck({ kind: \"url\", ...errorUtil.errToObj(message) });\n }\n emoji(message) {\n return this._addCheck({ kind: \"emoji\", ...errorUtil.errToObj(message) });\n }\n uuid(message) {\n return this._addCheck({ kind: \"uuid\", ...errorUtil.errToObj(message) });\n }\n cuid(message) {\n return this._addCheck({ kind: \"cuid\", ...errorUtil.errToObj(message) });\n }\n cuid2(message) {\n return this._addCheck({ kind: \"cuid2\", ...errorUtil.errToObj(message) });\n }\n ulid(message) {\n return this._addCheck({ kind: \"ulid\", ...errorUtil.errToObj(message) });\n }\n ip(options) {\n return this._addCheck({ kind: \"ip\", ...errorUtil.errToObj(options) });\n }\n datetime(options) {\n var _a;\n if (typeof options === \"string\") {\n return this._addCheck({\n kind: \"datetime\",\n precision: null,\n offset: false,\n message: options,\n });\n }\n return this._addCheck({\n kind: \"datetime\",\n precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === \"undefined\" ? null : options === null || options === void 0 ? void 0 : options.precision,\n offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,\n ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),\n });\n }\n regex(regex, message) {\n return this._addCheck({\n kind: \"regex\",\n regex: regex,\n ...errorUtil.errToObj(message),\n });\n }\n includes(value, options) {\n return this._addCheck({\n kind: \"includes\",\n value: value,\n position: options === null || options === void 0 ? void 0 : options.position,\n ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),\n });\n }\n startsWith(value, message) {\n return this._addCheck({\n kind: \"startsWith\",\n value: value,\n ...errorUtil.errToObj(message),\n });\n }\n endsWith(value, message) {\n return this._addCheck({\n kind: \"endsWith\",\n value: value,\n ...errorUtil.errToObj(message),\n });\n }\n min(minLength, message) {\n return this._addCheck({\n kind: \"min\",\n value: minLength,\n ...errorUtil.errToObj(message),\n });\n }\n max(maxLength, message) {\n return this._addCheck({\n kind: \"max\",\n value: maxLength,\n ...errorUtil.errToObj(message),\n });\n }\n length(len, message) {\n return this._addCheck({\n kind: \"length\",\n value: len,\n ...errorUtil.errToObj(message),\n });\n }\n /**\n * @deprecated Use z.string().min(1) instead.\n * @see {@link ZodString.min}\n */\n nonempty(message) {\n return this.min(1, errorUtil.errToObj(message));\n }\n trim() {\n return new ZodString({\n ...this._def,\n checks: [...this._def.checks, { kind: \"trim\" }],\n });\n }\n toLowerCase() {\n return new ZodString({\n ...this._def,\n checks: [...this._def.checks, { kind: \"toLowerCase\" }],\n });\n }\n toUpperCase() {\n return new ZodString({\n ...this._def,\n checks: [...this._def.checks, { kind: \"toUpperCase\" }],\n });\n }\n get isDatetime() {\n return !!this._def.checks.find((ch) => ch.kind === \"datetime\");\n }\n get isEmail() {\n return !!this._def.checks.find((ch) => ch.kind === \"email\");\n }\n get isURL() {\n return !!this._def.checks.find((ch) => ch.kind === \"url\");\n }\n get isEmoji() {\n return !!this._def.checks.find((ch) => ch.kind === \"emoji\");\n }\n get isUUID() {\n return !!this._def.checks.find((ch) => ch.kind === \"uuid\");\n }\n get isCUID() {\n return !!this._def.checks.find((ch) => ch.kind === \"cuid\");\n }\n get isCUID2() {\n return !!this._def.checks.find((ch) => ch.kind === \"cuid2\");\n }\n get isULID() {\n return !!this._def.checks.find((ch) => ch.kind === \"ulid\");\n }\n get isIP() {\n return !!this._def.checks.find((ch) => ch.kind === \"ip\");\n }\n get minLength() {\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"min\") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n }\n return min;\n }\n get maxLength() {\n let max = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"max\") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return max;\n }\n}\nZodString.create = (params) => {\n var _a;\n return new ZodString({\n checks: [],\n typeName: ZodFirstPartyTypeKind.ZodString,\n coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,\n ...processCreateParams(params),\n });\n};\n// https://stackoverflow.com/questions/3966484/why-does-modulus-operator-return-fractional-number-in-javascript/31711034#31711034\nfunction floatSafeRemainder(val, step) {\n const valDecCount = (val.toString().split(\".\")[1] || \"\").length;\n const stepDecCount = (step.toString().split(\".\")[1] || \"\").length;\n const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;\n const valInt = parseInt(val.toFixed(decCount).replace(\".\", \"\"));\n const stepInt = parseInt(step.toFixed(decCount).replace(\".\", \"\"));\n return (valInt % stepInt) / Math.pow(10, decCount);\n}\nclass ZodNumber extends ZodType {\n constructor() {\n super(...arguments);\n this.min = this.gte;\n this.max = this.lte;\n this.step = this.multipleOf;\n }\n _parse(input) {\n if (this._def.coerce) {\n input.data = Number(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.number) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.number,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n let ctx = undefined;\n const status = new ParseStatus();\n for (const check of this._def.checks) {\n if (check.kind === \"int\") {\n if (!util.isInteger(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: \"integer\",\n received: \"float\",\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"min\") {\n const tooSmall = check.inclusive\n ? input.data < check.value\n : input.data <= check.value;\n if (tooSmall) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: check.value,\n type: \"number\",\n inclusive: check.inclusive,\n exact: false,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"max\") {\n const tooBig = check.inclusive\n ? input.data > check.value\n : input.data >= check.value;\n if (tooBig) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: check.value,\n type: \"number\",\n inclusive: check.inclusive,\n exact: false,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"multipleOf\") {\n if (floatSafeRemainder(input.data, check.value) !== 0) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.not_multiple_of,\n multipleOf: check.value,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"finite\") {\n if (!Number.isFinite(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.not_finite,\n message: check.message,\n });\n status.dirty();\n }\n }\n else {\n util.assertNever(check);\n }\n }\n return { status: status.value, value: input.data };\n }\n gte(value, message) {\n return this.setLimit(\"min\", value, true, errorUtil.toString(message));\n }\n gt(value, message) {\n return this.setLimit(\"min\", value, false, errorUtil.toString(message));\n }\n lte(value, message) {\n return this.setLimit(\"max\", value, true, errorUtil.toString(message));\n }\n lt(value, message) {\n return this.setLimit(\"max\", value, false, errorUtil.toString(message));\n }\n setLimit(kind, value, inclusive, message) {\n return new ZodNumber({\n ...this._def,\n checks: [\n ...this._def.checks,\n {\n kind,\n value,\n inclusive,\n message: errorUtil.toString(message),\n },\n ],\n });\n }\n _addCheck(check) {\n return new ZodNumber({\n ...this._def,\n checks: [...this._def.checks, check],\n });\n }\n int(message) {\n return this._addCheck({\n kind: \"int\",\n message: errorUtil.toString(message),\n });\n }\n positive(message) {\n return this._addCheck({\n kind: \"min\",\n value: 0,\n inclusive: false,\n message: errorUtil.toString(message),\n });\n }\n negative(message) {\n return this._addCheck({\n kind: \"max\",\n value: 0,\n inclusive: false,\n message: errorUtil.toString(message),\n });\n }\n nonpositive(message) {\n return this._addCheck({\n kind: \"max\",\n value: 0,\n inclusive: true,\n message: errorUtil.toString(message),\n });\n }\n nonnegative(message) {\n return this._addCheck({\n kind: \"min\",\n value: 0,\n inclusive: true,\n message: errorUtil.toString(message),\n });\n }\n multipleOf(value, message) {\n return this._addCheck({\n kind: \"multipleOf\",\n value: value,\n message: errorUtil.toString(message),\n });\n }\n finite(message) {\n return this._addCheck({\n kind: \"finite\",\n message: errorUtil.toString(message),\n });\n }\n safe(message) {\n return this._addCheck({\n kind: \"min\",\n inclusive: true,\n value: Number.MIN_SAFE_INTEGER,\n message: errorUtil.toString(message),\n })._addCheck({\n kind: \"max\",\n inclusive: true,\n value: Number.MAX_SAFE_INTEGER,\n message: errorUtil.toString(message),\n });\n }\n get minValue() {\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"min\") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n }\n return min;\n }\n get maxValue() {\n let max = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"max\") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return max;\n }\n get isInt() {\n return !!this._def.checks.find((ch) => ch.kind === \"int\" ||\n (ch.kind === \"multipleOf\" && util.isInteger(ch.value)));\n }\n get isFinite() {\n let max = null, min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"finite\" ||\n ch.kind === \"int\" ||\n ch.kind === \"multipleOf\") {\n return true;\n }\n else if (ch.kind === \"min\") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n else if (ch.kind === \"max\") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return Number.isFinite(min) && Number.isFinite(max);\n }\n}\nZodNumber.create = (params) => {\n return new ZodNumber({\n checks: [],\n typeName: ZodFirstPartyTypeKind.ZodNumber,\n coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,\n ...processCreateParams(params),\n });\n};\nclass ZodBigInt extends ZodType {\n constructor() {\n super(...arguments);\n this.min = this.gte;\n this.max = this.lte;\n }\n _parse(input) {\n if (this._def.coerce) {\n input.data = BigInt(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.bigint) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.bigint,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n let ctx = undefined;\n const status = new ParseStatus();\n for (const check of this._def.checks) {\n if (check.kind === \"min\") {\n const tooSmall = check.inclusive\n ? input.data < check.value\n : input.data <= check.value;\n if (tooSmall) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n type: \"bigint\",\n minimum: check.value,\n inclusive: check.inclusive,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"max\") {\n const tooBig = check.inclusive\n ? input.data > check.value\n : input.data >= check.value;\n if (tooBig) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n type: \"bigint\",\n maximum: check.value,\n inclusive: check.inclusive,\n message: check.message,\n });\n status.dirty();\n }\n }\n else if (check.kind === \"multipleOf\") {\n if (input.data % check.value !== BigInt(0)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.not_multiple_of,\n multipleOf: check.value,\n message: check.message,\n });\n status.dirty();\n }\n }\n else {\n util.assertNever(check);\n }\n }\n return { status: status.value, value: input.data };\n }\n gte(value, message) {\n return this.setLimit(\"min\", value, true, errorUtil.toString(message));\n }\n gt(value, message) {\n return this.setLimit(\"min\", value, false, errorUtil.toString(message));\n }\n lte(value, message) {\n return this.setLimit(\"max\", value, true, errorUtil.toString(message));\n }\n lt(value, message) {\n return this.setLimit(\"max\", value, false, errorUtil.toString(message));\n }\n setLimit(kind, value, inclusive, message) {\n return new ZodBigInt({\n ...this._def,\n checks: [\n ...this._def.checks,\n {\n kind,\n value,\n inclusive,\n message: errorUtil.toString(message),\n },\n ],\n });\n }\n _addCheck(check) {\n return new ZodBigInt({\n ...this._def,\n checks: [...this._def.checks, check],\n });\n }\n positive(message) {\n return this._addCheck({\n kind: \"min\",\n value: BigInt(0),\n inclusive: false,\n message: errorUtil.toString(message),\n });\n }\n negative(message) {\n return this._addCheck({\n kind: \"max\",\n value: BigInt(0),\n inclusive: false,\n message: errorUtil.toString(message),\n });\n }\n nonpositive(message) {\n return this._addCheck({\n kind: \"max\",\n value: BigInt(0),\n inclusive: true,\n message: errorUtil.toString(message),\n });\n }\n nonnegative(message) {\n return this._addCheck({\n kind: \"min\",\n value: BigInt(0),\n inclusive: true,\n message: errorUtil.toString(message),\n });\n }\n multipleOf(value, message) {\n return this._addCheck({\n kind: \"multipleOf\",\n value,\n message: errorUtil.toString(message),\n });\n }\n get minValue() {\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"min\") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n }\n return min;\n }\n get maxValue() {\n let max = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"max\") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return max;\n }\n}\nZodBigInt.create = (params) => {\n var _a;\n return new ZodBigInt({\n checks: [],\n typeName: ZodFirstPartyTypeKind.ZodBigInt,\n coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,\n ...processCreateParams(params),\n });\n};\nclass ZodBoolean extends ZodType {\n _parse(input) {\n if (this._def.coerce) {\n input.data = Boolean(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.boolean) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.boolean,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n return OK(input.data);\n }\n}\nZodBoolean.create = (params) => {\n return new ZodBoolean({\n typeName: ZodFirstPartyTypeKind.ZodBoolean,\n coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,\n ...processCreateParams(params),\n });\n};\nclass ZodDate extends ZodType {\n _parse(input) {\n if (this._def.coerce) {\n input.data = new Date(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.date) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.date,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n if (isNaN(input.data.getTime())) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_date,\n });\n return INVALID;\n }\n const status = new ParseStatus();\n let ctx = undefined;\n for (const check of this._def.checks) {\n if (check.kind === \"min\") {\n if (input.data.getTime() < check.value) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n message: check.message,\n inclusive: true,\n exact: false,\n minimum: check.value,\n type: \"date\",\n });\n status.dirty();\n }\n }\n else if (check.kind === \"max\") {\n if (input.data.getTime() > check.value) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n message: check.message,\n inclusive: true,\n exact: false,\n maximum: check.value,\n type: \"date\",\n });\n status.dirty();\n }\n }\n else {\n util.assertNever(check);\n }\n }\n return {\n status: status.value,\n value: new Date(input.data.getTime()),\n };\n }\n _addCheck(check) {\n return new ZodDate({\n ...this._def,\n checks: [...this._def.checks, check],\n });\n }\n min(minDate, message) {\n return this._addCheck({\n kind: \"min\",\n value: minDate.getTime(),\n message: errorUtil.toString(message),\n });\n }\n max(maxDate, message) {\n return this._addCheck({\n kind: \"max\",\n value: maxDate.getTime(),\n message: errorUtil.toString(message),\n });\n }\n get minDate() {\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"min\") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n }\n return min != null ? new Date(min) : null;\n }\n get maxDate() {\n let max = null;\n for (const ch of this._def.checks) {\n if (ch.kind === \"max\") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return max != null ? new Date(max) : null;\n }\n}\nZodDate.create = (params) => {\n return new ZodDate({\n checks: [],\n coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,\n typeName: ZodFirstPartyTypeKind.ZodDate,\n ...processCreateParams(params),\n });\n};\nclass ZodSymbol extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.symbol) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.symbol,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n return OK(input.data);\n }\n}\nZodSymbol.create = (params) => {\n return new ZodSymbol({\n typeName: ZodFirstPartyTypeKind.ZodSymbol,\n ...processCreateParams(params),\n });\n};\nclass ZodUndefined extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.undefined) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.undefined,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n return OK(input.data);\n }\n}\nZodUndefined.create = (params) => {\n return new ZodUndefined({\n typeName: ZodFirstPartyTypeKind.ZodUndefined,\n ...processCreateParams(params),\n });\n};\nclass ZodNull extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.null) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.null,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n return OK(input.data);\n }\n}\nZodNull.create = (params) => {\n return new ZodNull({\n typeName: ZodFirstPartyTypeKind.ZodNull,\n ...processCreateParams(params),\n });\n};\nclass ZodAny extends ZodType {\n constructor() {\n super(...arguments);\n // to prevent instances of other classes from extending ZodAny. this causes issues with catchall in ZodObject.\n this._any = true;\n }\n _parse(input) {\n return OK(input.data);\n }\n}\nZodAny.create = (params) => {\n return new ZodAny({\n typeName: ZodFirstPartyTypeKind.ZodAny,\n ...processCreateParams(params),\n });\n};\nclass ZodUnknown extends ZodType {\n constructor() {\n super(...arguments);\n // required\n this._unknown = true;\n }\n _parse(input) {\n return OK(input.data);\n }\n}\nZodUnknown.create = (params) => {\n return new ZodUnknown({\n typeName: ZodFirstPartyTypeKind.ZodUnknown,\n ...processCreateParams(params),\n });\n};\nclass ZodNever extends ZodType {\n _parse(input) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.never,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n}\nZodNever.create = (params) => {\n return new ZodNever({\n typeName: ZodFirstPartyTypeKind.ZodNever,\n ...processCreateParams(params),\n });\n};\nclass ZodVoid extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.undefined) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.void,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n return OK(input.data);\n }\n}\nZodVoid.create = (params) => {\n return new ZodVoid({\n typeName: ZodFirstPartyTypeKind.ZodVoid,\n ...processCreateParams(params),\n });\n};\nclass ZodArray extends ZodType {\n _parse(input) {\n const { ctx, status } = this._processInputParams(input);\n const def = this._def;\n if (ctx.parsedType !== ZodParsedType.array) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.array,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n if (def.exactLength !== null) {\n const tooBig = ctx.data.length > def.exactLength.value;\n const tooSmall = ctx.data.length < def.exactLength.value;\n if (tooBig || tooSmall) {\n addIssueToContext(ctx, {\n code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,\n minimum: (tooSmall ? def.exactLength.value : undefined),\n maximum: (tooBig ? def.exactLength.value : undefined),\n type: \"array\",\n inclusive: true,\n exact: true,\n message: def.exactLength.message,\n });\n status.dirty();\n }\n }\n if (def.minLength !== null) {\n if (ctx.data.length < def.minLength.value) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: def.minLength.value,\n type: \"array\",\n inclusive: true,\n exact: false,\n message: def.minLength.message,\n });\n status.dirty();\n }\n }\n if (def.maxLength !== null) {\n if (ctx.data.length > def.maxLength.value) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: def.maxLength.value,\n type: \"array\",\n inclusive: true,\n exact: false,\n message: def.maxLength.message,\n });\n status.dirty();\n }\n }\n if (ctx.common.async) {\n return Promise.all([...ctx.data].map((item, i) => {\n return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));\n })).then((result) => {\n return ParseStatus.mergeArray(status, result);\n });\n }\n const result = [...ctx.data].map((item, i) => {\n return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));\n });\n return ParseStatus.mergeArray(status, result);\n }\n get element() {\n return this._def.type;\n }\n min(minLength, message) {\n return new ZodArray({\n ...this._def,\n minLength: { value: minLength, message: errorUtil.toString(message) },\n });\n }\n max(maxLength, message) {\n return new ZodArray({\n ...this._def,\n maxLength: { value: maxLength, message: errorUtil.toString(message) },\n });\n }\n length(len, message) {\n return new ZodArray({\n ...this._def,\n exactLength: { value: len, message: errorUtil.toString(message) },\n });\n }\n nonempty(message) {\n return this.min(1, message);\n }\n}\nZodArray.create = (schema, params) => {\n return new ZodArray({\n type: schema,\n minLength: null,\n maxLength: null,\n exactLength: null,\n typeName: ZodFirstPartyTypeKind.ZodArray,\n ...processCreateParams(params),\n });\n};\nfunction deepPartialify(schema) {\n if (schema instanceof ZodObject) {\n const newShape = {};\n for (const key in schema.shape) {\n const fieldSchema = schema.shape[key];\n newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));\n }\n return new ZodObject({\n ...schema._def,\n shape: () => newShape,\n });\n }\n else if (schema instanceof ZodArray) {\n return new ZodArray({\n ...schema._def,\n type: deepPartialify(schema.element),\n });\n }\n else if (schema instanceof ZodOptional) {\n return ZodOptional.create(deepPartialify(schema.unwrap()));\n }\n else if (schema instanceof ZodNullable) {\n return ZodNullable.create(deepPartialify(schema.unwrap()));\n }\n else if (schema instanceof ZodTuple) {\n return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));\n }\n else {\n return schema;\n }\n}\nclass ZodObject extends ZodType {\n constructor() {\n super(...arguments);\n this._cached = null;\n /**\n * @deprecated In most cases, this is no longer needed - unknown properties are now silently stripped.\n * If you want to pass through unknown properties, use `.passthrough()` instead.\n */\n this.nonstrict = this.passthrough;\n // extend<\n // Augmentation extends ZodRawShape,\n // NewOutput extends util.flatten<{\n // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation\n // ? Augmentation[k][\"_output\"]\n // : k extends keyof Output\n // ? Output[k]\n // : never;\n // }>,\n // NewInput extends util.flatten<{\n // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation\n // ? Augmentation[k][\"_input\"]\n // : k extends keyof Input\n // ? Input[k]\n // : never;\n // }>\n // >(\n // augmentation: Augmentation\n // ): ZodObject<\n // extendShape<T, Augmentation>,\n // UnknownKeys,\n // Catchall,\n // NewOutput,\n // NewInput\n // > {\n // return new ZodObject({\n // ...this._def,\n // shape: () => ({\n // ...this._def.shape(),\n // ...augmentation,\n // }),\n // }) as any;\n // }\n /**\n * @deprecated Use `.extend` instead\n * */\n this.augment = this.extend;\n }\n _getCached() {\n if (this._cached !== null)\n return this._cached;\n const shape = this._def.shape();\n const keys = util.objectKeys(shape);\n return (this._cached = { shape, keys });\n }\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.object) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.object,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n const { status, ctx } = this._processInputParams(input);\n const { shape, keys: shapeKeys } = this._getCached();\n const extraKeys = [];\n if (!(this._def.catchall instanceof ZodNever &&\n this._def.unknownKeys === \"strip\")) {\n for (const key in ctx.data) {\n if (!shapeKeys.includes(key)) {\n extraKeys.push(key);\n }\n }\n }\n const pairs = [];\n for (const key of shapeKeys) {\n const keyValidator = shape[key];\n const value = ctx.data[key];\n pairs.push({\n key: { status: \"valid\", value: key },\n value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),\n alwaysSet: key in ctx.data,\n });\n }\n if (this._def.catchall instanceof ZodNever) {\n const unknownKeys = this._def.unknownKeys;\n if (unknownKeys === \"passthrough\") {\n for (const key of extraKeys) {\n pairs.push({\n key: { status: \"valid\", value: key },\n value: { status: \"valid\", value: ctx.data[key] },\n });\n }\n }\n else if (unknownKeys === \"strict\") {\n if (extraKeys.length > 0) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.unrecognized_keys,\n keys: extraKeys,\n });\n status.dirty();\n }\n }\n else if (unknownKeys === \"strip\") ;\n else {\n throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);\n }\n }\n else {\n // run catchall validation\n const catchall = this._def.catchall;\n for (const key of extraKeys) {\n const value = ctx.data[key];\n pairs.push({\n key: { status: \"valid\", value: key },\n value: catchall._parse(new ParseInputLazyPath(ctx, value, ctx.path, key) //, ctx.child(key), value, getParsedType(value)\n ),\n alwaysSet: key in ctx.data,\n });\n }\n }\n if (ctx.common.async) {\n return Promise.resolve()\n .then(async () => {\n const syncPairs = [];\n for (const pair of pairs) {\n const key = await pair.key;\n syncPairs.push({\n key,\n value: await pair.value,\n alwaysSet: pair.alwaysSet,\n });\n }\n return syncPairs;\n })\n .then((syncPairs) => {\n return ParseStatus.mergeObjectSync(status, syncPairs);\n });\n }\n else {\n return ParseStatus.mergeObjectSync(status, pairs);\n }\n }\n get shape() {\n return this._def.shape();\n }\n strict(message) {\n errorUtil.errToObj;\n return new ZodObject({\n ...this._def,\n unknownKeys: \"strict\",\n ...(message !== undefined\n ? {\n errorMap: (issue, ctx) => {\n var _a, _b, _c, _d;\n const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;\n if (issue.code === \"unrecognized_keys\")\n return {\n message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError,\n };\n return {\n message: defaultError,\n };\n },\n }\n : {}),\n });\n }\n strip() {\n return new ZodObject({\n ...this._def,\n unknownKeys: \"strip\",\n });\n }\n passthrough() {\n return new ZodObject({\n ...this._def,\n unknownKeys: \"passthrough\",\n });\n }\n // const AugmentFactory =\n // <Def extends ZodObjectDef>(def: Def) =>\n // <Augmentation extends ZodRawShape>(\n // augmentation: Augmentation\n // ): ZodObject<\n // extendShape<ReturnType<Def[\"shape\"]>, Augmentation>,\n // Def[\"unknownKeys\"],\n // Def[\"catchall\"]\n // > => {\n // return new ZodObject({\n // ...def,\n // shape: () => ({\n // ...def.shape(),\n // ...augmentation,\n // }),\n // }) as any;\n // };\n extend(augmentation) {\n return new ZodObject({\n ...this._def,\n shape: () => ({\n ...this._def.shape(),\n ...augmentation,\n }),\n });\n }\n /**\n * Prior to zod@1.0.12 there was a bug in the\n * inferred type of merged objects. Please\n * upgrade if you are experiencing issues.\n */\n merge(merging) {\n const merged = new ZodObject({\n unknownKeys: merging._def.unknownKeys,\n catchall: merging._def.catchall,\n shape: () => ({\n ...this._def.shape(),\n ...merging._def.shape(),\n }),\n typeName: ZodFirstPartyTypeKind.ZodObject,\n });\n return merged;\n }\n // merge<\n // Incoming extends AnyZodObject,\n // Augmentation extends Incoming[\"shape\"],\n // NewOutput extends {\n // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation\n // ? Augmentation[k][\"_output\"]\n // : k extends keyof Output\n // ? Output[k]\n // : never;\n // },\n // NewInput extends {\n // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation\n // ? Augmentation[k][\"_input\"]\n // : k extends keyof Input\n // ? Input[k]\n // : never;\n // }\n // >(\n // merging: Incoming\n // ): ZodObject<\n // extendShape<T, ReturnType<Incoming[\"_def\"][\"shape\"]>>,\n // Incoming[\"_def\"][\"unknownKeys\"],\n // Incoming[\"_def\"][\"catchall\"],\n // NewOutput,\n // NewInput\n // > {\n // const merged: any = new ZodObject({\n // unknownKeys: merging._def.unknownKeys,\n // catchall: merging._def.catchall,\n // shape: () =>\n // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),\n // typeName: ZodFirstPartyTypeKind.ZodObject,\n // }) as any;\n // return merged;\n // }\n setKey(key, schema) {\n return this.augment({ [key]: schema });\n }\n // merge<Incoming extends AnyZodObject>(\n // merging: Incoming\n // ): //ZodObject<T & Incoming[\"_shape\"], UnknownKeys, Catchall> = (merging) => {\n // ZodObject<\n // extendShape<T, ReturnType<Incoming[\"_def\"][\"shape\"]>>,\n // Incoming[\"_def\"][\"unknownKeys\"],\n // Incoming[\"_def\"][\"catchall\"]\n // > {\n // // const mergedShape = objectUtil.mergeShapes(\n // // this._def.shape(),\n // // merging._def.shape()\n // // );\n // const merged: any = new ZodObject({\n // unknownKeys: merging._def.unknownKeys,\n // catchall: merging._def.catchall,\n // shape: () =>\n // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),\n // typeName: ZodFirstPartyTypeKind.ZodObject,\n // }) as any;\n // return merged;\n // }\n catchall(index) {\n return new ZodObject({\n ...this._def,\n catchall: index,\n });\n }\n pick(mask) {\n const shape = {};\n util.objectKeys(mask).forEach((key) => {\n if (mask[key] && this.shape[key]) {\n shape[key] = this.shape[key];\n }\n });\n return new ZodObject({\n ...this._def,\n shape: () => shape,\n });\n }\n omit(mask) {\n const shape = {};\n util.objectKeys(this.shape).forEach((key) => {\n if (!mask[key]) {\n shape[key] = this.shape[key];\n }\n });\n return new ZodObject({\n ...this._def,\n shape: () => shape,\n });\n }\n /**\n * @deprecated\n */\n deepPartial() {\n return deepPartialify(this);\n }\n partial(mask) {\n const newShape = {};\n util.objectKeys(this.shape).forEach((key) => {\n const fieldSchema = this.shape[key];\n if (mask && !mask[key]) {\n newShape[key] = fieldSchema;\n }\n else {\n newShape[key] = fieldSchema.optional();\n }\n });\n return new ZodObject({\n ...this._def,\n shape: () => newShape,\n });\n }\n required(mask) {\n const newShape = {};\n util.objectKeys(this.shape).forEach((key) => {\n if (mask && !mask[key]) {\n newShape[key] = this.shape[key];\n }\n else {\n const fieldSchema = this.shape[key];\n let newField = fieldSchema;\n while (newField instanceof ZodOptional) {\n newField = newField._def.innerType;\n }\n newShape[key] = newField;\n }\n });\n return new ZodObject({\n ...this._def,\n shape: () => newShape,\n });\n }\n keyof() {\n return createZodEnum(util.objectKeys(this.shape));\n }\n}\nZodObject.create = (shape, params) => {\n return new ZodObject({\n shape: () => shape,\n unknownKeys: \"strip\",\n catchall: ZodNever.create(),\n typeName: ZodFirstPartyTypeKind.ZodObject,\n ...processCreateParams(params),\n });\n};\nZodObject.strictCreate = (shape, params) => {\n return new ZodObject({\n shape: () => shape,\n unknownKeys: \"strict\",\n catchall: ZodNever.create(),\n typeName: ZodFirstPartyTypeKind.ZodObject,\n ...processCreateParams(params),\n });\n};\nZodObject.lazycreate = (shape, params) => {\n return new ZodObject({\n shape,\n unknownKeys: \"strip\",\n catchall: ZodNever.create(),\n typeName: ZodFirstPartyTypeKind.ZodObject,\n ...processCreateParams(params),\n });\n};\nclass ZodUnion extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n const options = this._def.options;\n function handleResults(results) {\n // return first issue-free validation if it exists\n for (const result of results) {\n if (result.result.status === \"valid\") {\n return result.result;\n }\n }\n for (const result of results) {\n if (result.result.status === \"dirty\") {\n // add issues from dirty option\n ctx.common.issues.push(...result.ctx.common.issues);\n return result.result;\n }\n }\n // return invalid\n const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_union,\n unionErrors,\n });\n return INVALID;\n }\n if (ctx.common.async) {\n return Promise.all(options.map(async (option) => {\n const childCtx = {\n ...ctx,\n common: {\n ...ctx.common,\n issues: [],\n },\n parent: null,\n };\n return {\n result: await option._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: childCtx,\n }),\n ctx: childCtx,\n };\n })).then(handleResults);\n }\n else {\n let dirty = undefined;\n const issues = [];\n for (const option of options) {\n const childCtx = {\n ...ctx,\n common: {\n ...ctx.common,\n issues: [],\n },\n parent: null,\n };\n const result = option._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: childCtx,\n });\n if (result.status === \"valid\") {\n return result;\n }\n else if (result.status === \"dirty\" && !dirty) {\n dirty = { result, ctx: childCtx };\n }\n if (childCtx.common.issues.length) {\n issues.push(childCtx.common.issues);\n }\n }\n if (dirty) {\n ctx.common.issues.push(...dirty.ctx.common.issues);\n return dirty.result;\n }\n const unionErrors = issues.map((issues) => new ZodError(issues));\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_union,\n unionErrors,\n });\n return INVALID;\n }\n }\n get options() {\n return this._def.options;\n }\n}\nZodUnion.create = (types, params) => {\n return new ZodUnion({\n options: types,\n typeName: ZodFirstPartyTypeKind.ZodUnion,\n ...processCreateParams(params),\n });\n};\n/////////////////////////////////////////////////////\n/////////////////////////////////////////////////////\n////////// //////////\n////////// ZodDiscriminatedUnion //////////\n////////// //////////\n/////////////////////////////////////////////////////\n/////////////////////////////////////////////////////\nconst getDiscriminator = (type) => {\n if (type instanceof ZodLazy) {\n return getDiscriminator(type.schema);\n }\n else if (type instanceof ZodEffects) {\n return getDiscriminator(type.innerType());\n }\n else if (type instanceof ZodLiteral) {\n return [type.value];\n }\n else if (type instanceof ZodEnum) {\n return type.options;\n }\n else if (type instanceof ZodNativeEnum) {\n // eslint-disable-next-line ban/ban\n return Object.keys(type.enum);\n }\n else if (type instanceof ZodDefault) {\n return getDiscriminator(type._def.innerType);\n }\n else if (type instanceof ZodUndefined) {\n return [undefined];\n }\n else if (type instanceof ZodNull) {\n return [null];\n }\n else {\n return null;\n }\n};\nclass ZodDiscriminatedUnion extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.object) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.object,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n const discriminator = this.discriminator;\n const discriminatorValue = ctx.data[discriminator];\n const option = this.optionsMap.get(discriminatorValue);\n if (!option) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_union_discriminator,\n options: Array.from(this.optionsMap.keys()),\n path: [discriminator],\n });\n return INVALID;\n }\n if (ctx.common.async) {\n return option._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n });\n }\n else {\n return option._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n });\n }\n }\n get discriminator() {\n return this._def.discriminator;\n }\n get options() {\n return this._def.options;\n }\n get optionsMap() {\n return this._def.optionsMap;\n }\n /**\n * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.\n * However, it only allows a union of objects, all of which need to share a discriminator property. This property must\n * have a different value for each object in the union.\n * @param discriminator the name of the discriminator property\n * @param types an array of object schemas\n * @param params\n */\n static create(discriminator, options, params) {\n // Get all the valid discriminator values\n const optionsMap = new Map();\n // try {\n for (const type of options) {\n const discriminatorValues = getDiscriminator(type.shape[discriminator]);\n if (!discriminatorValues) {\n throw new Error(`A discriminator value for key \\`${discriminator}\\` could not be extracted from all schema options`);\n }\n for (const value of discriminatorValues) {\n if (optionsMap.has(value)) {\n throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);\n }\n optionsMap.set(value, type);\n }\n }\n return new ZodDiscriminatedUnion({\n typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,\n discriminator,\n options,\n optionsMap,\n ...processCreateParams(params),\n });\n }\n}\nfunction mergeValues(a, b) {\n const aType = getParsedType(a);\n const bType = getParsedType(b);\n if (a === b) {\n return { valid: true, data: a };\n }\n else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {\n const bKeys = util.objectKeys(b);\n const sharedKeys = util\n .objectKeys(a)\n .filter((key) => bKeys.indexOf(key) !== -1);\n const newObj = { ...a, ...b };\n for (const key of sharedKeys) {\n const sharedValue = mergeValues(a[key], b[key]);\n if (!sharedValue.valid) {\n return { valid: false };\n }\n newObj[key] = sharedValue.data;\n }\n return { valid: true, data: newObj };\n }\n else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {\n if (a.length !== b.length) {\n return { valid: false };\n }\n const newArray = [];\n for (let index = 0; index < a.length; index++) {\n const itemA = a[index];\n const itemB = b[index];\n const sharedValue = mergeValues(itemA, itemB);\n if (!sharedValue.valid) {\n return { valid: false };\n }\n newArray.push(sharedValue.data);\n }\n return { valid: true, data: newArray };\n }\n else if (aType === ZodParsedType.date &&\n bType === ZodParsedType.date &&\n +a === +b) {\n return { valid: true, data: a };\n }\n else {\n return { valid: false };\n }\n}\nclass ZodIntersection extends ZodType {\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n const handleParsed = (parsedLeft, parsedRight) => {\n if (isAborted(parsedLeft) || isAborted(parsedRight)) {\n return INVALID;\n }\n const merged = mergeValues(parsedLeft.value, parsedRight.value);\n if (!merged.valid) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_intersection_types,\n });\n return INVALID;\n }\n if (isDirty(parsedLeft) || isDirty(parsedRight)) {\n status.dirty();\n }\n return { status: status.value, value: merged.data };\n };\n if (ctx.common.async) {\n return Promise.all([\n this._def.left._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n }),\n this._def.right._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n }),\n ]).then(([left, right]) => handleParsed(left, right));\n }\n else {\n return handleParsed(this._def.left._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n }), this._def.right._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n }));\n }\n }\n}\nZodIntersection.create = (left, right, params) => {\n return new ZodIntersection({\n left: left,\n right: right,\n typeName: ZodFirstPartyTypeKind.ZodIntersection,\n ...processCreateParams(params),\n });\n};\nclass ZodTuple extends ZodType {\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.array) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.array,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n if (ctx.data.length < this._def.items.length) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: this._def.items.length,\n inclusive: true,\n exact: false,\n type: \"array\",\n });\n return INVALID;\n }\n const rest = this._def.rest;\n if (!rest && ctx.data.length > this._def.items.length) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: this._def.items.length,\n inclusive: true,\n exact: false,\n type: \"array\",\n });\n status.dirty();\n }\n const items = [...ctx.data]\n .map((item, itemIndex) => {\n const schema = this._def.items[itemIndex] || this._def.rest;\n if (!schema)\n return null;\n return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));\n })\n .filter((x) => !!x); // filter nulls\n if (ctx.common.async) {\n return Promise.all(items).then((results) => {\n return ParseStatus.mergeArray(status, results);\n });\n }\n else {\n return ParseStatus.mergeArray(status, items);\n }\n }\n get items() {\n return this._def.items;\n }\n rest(rest) {\n return new ZodTuple({\n ...this._def,\n rest,\n });\n }\n}\nZodTuple.create = (schemas, params) => {\n if (!Array.isArray(schemas)) {\n throw new Error(\"You must pass an array of schemas to z.tuple([ ... ])\");\n }\n return new ZodTuple({\n items: schemas,\n typeName: ZodFirstPartyTypeKind.ZodTuple,\n rest: null,\n ...processCreateParams(params),\n });\n};\nclass ZodRecord extends ZodType {\n get keySchema() {\n return this._def.keyType;\n }\n get valueSchema() {\n return this._def.valueType;\n }\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.object) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.object,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n const pairs = [];\n const keyType = this._def.keyType;\n const valueType = this._def.valueType;\n for (const key in ctx.data) {\n pairs.push({\n key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),\n value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),\n });\n }\n if (ctx.common.async) {\n return ParseStatus.mergeObjectAsync(status, pairs);\n }\n else {\n return ParseStatus.mergeObjectSync(status, pairs);\n }\n }\n get element() {\n return this._def.valueType;\n }\n static create(first, second, third) {\n if (second instanceof ZodType) {\n return new ZodRecord({\n keyType: first,\n valueType: second,\n typeName: ZodFirstPartyTypeKind.ZodRecord,\n ...processCreateParams(third),\n });\n }\n return new ZodRecord({\n keyType: ZodString.create(),\n valueType: first,\n typeName: ZodFirstPartyTypeKind.ZodRecord,\n ...processCreateParams(second),\n });\n }\n}\nclass ZodMap extends ZodType {\n get keySchema() {\n return this._def.keyType;\n }\n get valueSchema() {\n return this._def.valueType;\n }\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.map) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.map,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n const keyType = this._def.keyType;\n const valueType = this._def.valueType;\n const pairs = [...ctx.data.entries()].map(([key, value], index) => {\n return {\n key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, \"key\"])),\n value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, \"value\"])),\n };\n });\n if (ctx.common.async) {\n const finalMap = new Map();\n return Promise.resolve().then(async () => {\n for (const pair of pairs) {\n const key = await pair.key;\n const value = await pair.value;\n if (key.status === \"aborted\" || value.status === \"aborted\") {\n return INVALID;\n }\n if (key.status === \"dirty\" || value.status === \"dirty\") {\n status.dirty();\n }\n finalMap.set(key.value, value.value);\n }\n return { status: status.value, value: finalMap };\n });\n }\n else {\n const finalMap = new Map();\n for (const pair of pairs) {\n const key = pair.key;\n const value = pair.value;\n if (key.status === \"aborted\" || value.status === \"aborted\") {\n return INVALID;\n }\n if (key.status === \"dirty\" || value.status === \"dirty\") {\n status.dirty();\n }\n finalMap.set(key.value, value.value);\n }\n return { status: status.value, value: finalMap };\n }\n }\n}\nZodMap.create = (keyType, valueType, params) => {\n return new ZodMap({\n valueType,\n keyType,\n typeName: ZodFirstPartyTypeKind.ZodMap,\n ...processCreateParams(params),\n });\n};\nclass ZodSet extends ZodType {\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.set) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.set,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n const def = this._def;\n if (def.minSize !== null) {\n if (ctx.data.size < def.minSize.value) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: def.minSize.value,\n type: \"set\",\n inclusive: true,\n exact: false,\n message: def.minSize.message,\n });\n status.dirty();\n }\n }\n if (def.maxSize !== null) {\n if (ctx.data.size > def.maxSize.value) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: def.maxSize.value,\n type: \"set\",\n inclusive: true,\n exact: false,\n message: def.maxSize.message,\n });\n status.dirty();\n }\n }\n const valueType = this._def.valueType;\n function finalizeSet(elements) {\n const parsedSet = new Set();\n for (const element of elements) {\n if (element.status === \"aborted\")\n return INVALID;\n if (element.status === \"dirty\")\n status.dirty();\n parsedSet.add(element.value);\n }\n return { status: status.value, value: parsedSet };\n }\n const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));\n if (ctx.common.async) {\n return Promise.all(elements).then((elements) => finalizeSet(elements));\n }\n else {\n return finalizeSet(elements);\n }\n }\n min(minSize, message) {\n return new ZodSet({\n ...this._def,\n minSize: { value: minSize, message: errorUtil.toString(message) },\n });\n }\n max(maxSize, message) {\n return new ZodSet({\n ...this._def,\n maxSize: { value: maxSize, message: errorUtil.toString(message) },\n });\n }\n size(size, message) {\n return this.min(size, message).max(size, message);\n }\n nonempty(message) {\n return this.min(1, message);\n }\n}\nZodSet.create = (valueType, params) => {\n return new ZodSet({\n valueType,\n minSize: null,\n maxSize: null,\n typeName: ZodFirstPartyTypeKind.ZodSet,\n ...processCreateParams(params),\n });\n};\nclass ZodFunction extends ZodType {\n constructor() {\n super(...arguments);\n this.validate = this.implement;\n }\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.function) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.function,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n function makeArgsIssue(args, error) {\n return makeIssue({\n data: args,\n path: ctx.path,\n errorMaps: [\n ctx.common.contextualErrorMap,\n ctx.schemaErrorMap,\n getErrorMap(),\n errorMap,\n ].filter((x) => !!x),\n issueData: {\n code: ZodIssueCode.invalid_arguments,\n argumentsError: error,\n },\n });\n }\n function makeReturnsIssue(returns, error) {\n return makeIssue({\n data: returns,\n path: ctx.path,\n errorMaps: [\n ctx.common.contextualErrorMap,\n ctx.schemaErrorMap,\n getErrorMap(),\n errorMap,\n ].filter((x) => !!x),\n issueData: {\n code: ZodIssueCode.invalid_return_type,\n returnTypeError: error,\n },\n });\n }\n const params = { errorMap: ctx.common.contextualErrorMap };\n const fn = ctx.data;\n if (this._def.returns instanceof ZodPromise) {\n // Would love a way to avoid disabling this rule, but we need\n // an alias (using an arrow function was what caused 2651).\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const me = this;\n return OK(async function (...args) {\n const error = new ZodError([]);\n const parsedArgs = await me._def.args\n .parseAsync(args, params)\n .catch((e) => {\n error.addIssue(makeArgsIssue(args, e));\n throw error;\n });\n const result = await Reflect.apply(fn, this, parsedArgs);\n const parsedReturns = await me._def.returns._def.type\n .parseAsync(result, params)\n .catch((e) => {\n error.addIssue(makeReturnsIssue(result, e));\n throw error;\n });\n return parsedReturns;\n });\n }\n else {\n // Would love a way to avoid disabling this rule, but we need\n // an alias (using an arrow function was what caused 2651).\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const me = this;\n return OK(function (...args) {\n const parsedArgs = me._def.args.safeParse(args, params);\n if (!parsedArgs.success) {\n throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);\n }\n const result = Reflect.apply(fn, this, parsedArgs.data);\n const parsedReturns = me._def.returns.safeParse(result, params);\n if (!parsedReturns.success) {\n throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);\n }\n return parsedReturns.data;\n });\n }\n }\n parameters() {\n return this._def.args;\n }\n returnType() {\n return this._def.returns;\n }\n args(...items) {\n return new ZodFunction({\n ...this._def,\n args: ZodTuple.create(items).rest(ZodUnknown.create()),\n });\n }\n returns(returnType) {\n return new ZodFunction({\n ...this._def,\n returns: returnType,\n });\n }\n implement(func) {\n const validatedFunc = this.parse(func);\n return validatedFunc;\n }\n strictImplement(func) {\n const validatedFunc = this.parse(func);\n return validatedFunc;\n }\n static create(args, returns, params) {\n return new ZodFunction({\n args: (args\n ? args\n : ZodTuple.create([]).rest(ZodUnknown.create())),\n returns: returns || ZodUnknown.create(),\n typeName: ZodFirstPartyTypeKind.ZodFunction,\n ...processCreateParams(params),\n });\n }\n}\nclass ZodLazy extends ZodType {\n get schema() {\n return this._def.getter();\n }\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n const lazySchema = this._def.getter();\n return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });\n }\n}\nZodLazy.create = (getter, params) => {\n return new ZodLazy({\n getter: getter,\n typeName: ZodFirstPartyTypeKind.ZodLazy,\n ...processCreateParams(params),\n });\n};\nclass ZodLiteral extends ZodType {\n _parse(input) {\n if (input.data !== this._def.value) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n received: ctx.data,\n code: ZodIssueCode.invalid_literal,\n expected: this._def.value,\n });\n return INVALID;\n }\n return { status: \"valid\", value: input.data };\n }\n get value() {\n return this._def.value;\n }\n}\nZodLiteral.create = (value, params) => {\n return new ZodLiteral({\n value: value,\n typeName: ZodFirstPartyTypeKind.ZodLiteral,\n ...processCreateParams(params),\n });\n};\nfunction createZodEnum(values, params) {\n return new ZodEnum({\n values,\n typeName: ZodFirstPartyTypeKind.ZodEnum,\n ...processCreateParams(params),\n });\n}\nclass ZodEnum extends ZodType {\n _parse(input) {\n if (typeof input.data !== \"string\") {\n const ctx = this._getOrReturnCtx(input);\n const expectedValues = this._def.values;\n addIssueToContext(ctx, {\n expected: util.joinValues(expectedValues),\n received: ctx.parsedType,\n code: ZodIssueCode.invalid_type,\n });\n return INVALID;\n }\n if (this._def.values.indexOf(input.data) === -1) {\n const ctx = this._getOrReturnCtx(input);\n const expectedValues = this._def.values;\n addIssueToContext(ctx, {\n received: ctx.data,\n code: ZodIssueCode.invalid_enum_value,\n options: expectedValues,\n });\n return INVALID;\n }\n return OK(input.data);\n }\n get options() {\n return this._def.values;\n }\n get enum() {\n const enumValues = {};\n for (const val of this._def.values) {\n enumValues[val] = val;\n }\n return enumValues;\n }\n get Values() {\n const enumValues = {};\n for (const val of this._def.values) {\n enumValues[val] = val;\n }\n return enumValues;\n }\n get Enum() {\n const enumValues = {};\n for (const val of this._def.values) {\n enumValues[val] = val;\n }\n return enumValues;\n }\n extract(values) {\n return ZodEnum.create(values);\n }\n exclude(values) {\n return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));\n }\n}\nZodEnum.create = createZodEnum;\nclass ZodNativeEnum extends ZodType {\n _parse(input) {\n const nativeEnumValues = util.getValidEnumValues(this._def.values);\n const ctx = this._getOrReturnCtx(input);\n if (ctx.parsedType !== ZodParsedType.string &&\n ctx.parsedType !== ZodParsedType.number) {\n const expectedValues = util.objectValues(nativeEnumValues);\n addIssueToContext(ctx, {\n expected: util.joinValues(expectedValues),\n received: ctx.parsedType,\n code: ZodIssueCode.invalid_type,\n });\n return INVALID;\n }\n if (nativeEnumValues.indexOf(input.data) === -1) {\n const expectedValues = util.objectValues(nativeEnumValues);\n addIssueToContext(ctx, {\n received: ctx.data,\n code: ZodIssueCode.invalid_enum_value,\n options: expectedValues,\n });\n return INVALID;\n }\n return OK(input.data);\n }\n get enum() {\n return this._def.values;\n }\n}\nZodNativeEnum.create = (values, params) => {\n return new ZodNativeEnum({\n values: values,\n typeName: ZodFirstPartyTypeKind.ZodNativeEnum,\n ...processCreateParams(params),\n });\n};\nclass ZodPromise extends ZodType {\n unwrap() {\n return this._def.type;\n }\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.promise &&\n ctx.common.async === false) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.promise,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n const promisified = ctx.parsedType === ZodParsedType.promise\n ? ctx.data\n : Promise.resolve(ctx.data);\n return OK(promisified.then((data) => {\n return this._def.type.parseAsync(data, {\n path: ctx.path,\n errorMap: ctx.common.contextualErrorMap,\n });\n }));\n }\n}\nZodPromise.create = (schema, params) => {\n return new ZodPromise({\n type: schema,\n typeName: ZodFirstPartyTypeKind.ZodPromise,\n ...processCreateParams(params),\n });\n};\nclass ZodEffects extends ZodType {\n innerType() {\n return this._def.schema;\n }\n sourceType() {\n return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects\n ? this._def.schema.sourceType()\n : this._def.schema;\n }\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n const effect = this._def.effect || null;\n const checkCtx = {\n addIssue: (arg) => {\n addIssueToContext(ctx, arg);\n if (arg.fatal) {\n status.abort();\n }\n else {\n status.dirty();\n }\n },\n get path() {\n return ctx.path;\n },\n };\n checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);\n if (effect.type === \"preprocess\") {\n const processed = effect.transform(ctx.data, checkCtx);\n if (ctx.common.issues.length) {\n return {\n status: \"dirty\",\n value: ctx.data,\n };\n }\n if (ctx.common.async) {\n return Promise.resolve(processed).then((processed) => {\n return this._def.schema._parseAsync({\n data: processed,\n path: ctx.path,\n parent: ctx,\n });\n });\n }\n else {\n return this._def.schema._parseSync({\n data: processed,\n path: ctx.path,\n parent: ctx,\n });\n }\n }\n if (effect.type === \"refinement\") {\n const executeRefinement = (acc\n // effect: RefinementEffect<any>\n ) => {\n const result = effect.refinement(acc, checkCtx);\n if (ctx.common.async) {\n return Promise.resolve(result);\n }\n if (result instanceof Promise) {\n throw new Error(\"Async refinement encountered during synchronous parse operation. Use .parseAsync instead.\");\n }\n return acc;\n };\n if (ctx.common.async === false) {\n const inner = this._def.schema._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n });\n if (inner.status === \"aborted\")\n return INVALID;\n if (inner.status === \"dirty\")\n status.dirty();\n // return value is ignored\n executeRefinement(inner.value);\n return { status: status.value, value: inner.value };\n }\n else {\n return this._def.schema\n ._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx })\n .then((inner) => {\n if (inner.status === \"aborted\")\n return INVALID;\n if (inner.status === \"dirty\")\n status.dirty();\n return executeRefinement(inner.value).then(() => {\n return { status: status.value, value: inner.value };\n });\n });\n }\n }\n if (effect.type === \"transform\") {\n if (ctx.common.async === false) {\n const base = this._def.schema._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n });\n if (!isValid(base))\n return base;\n const result = effect.transform(base.value, checkCtx);\n if (result instanceof Promise) {\n throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);\n }\n return { status: status.value, value: result };\n }\n else {\n return this._def.schema\n ._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx })\n .then((base) => {\n if (!isValid(base))\n return base;\n return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));\n });\n }\n }\n util.assertNever(effect);\n }\n}\nZodEffects.create = (schema, effect, params) => {\n return new ZodEffects({\n schema,\n typeName: ZodFirstPartyTypeKind.ZodEffects,\n effect,\n ...processCreateParams(params),\n });\n};\nZodEffects.createWithPreprocess = (preprocess, schema, params) => {\n return new ZodEffects({\n schema,\n effect: { type: \"preprocess\", transform: preprocess },\n typeName: ZodFirstPartyTypeKind.ZodEffects,\n ...processCreateParams(params),\n });\n};\nclass ZodOptional extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType === ZodParsedType.undefined) {\n return OK(undefined);\n }\n return this._def.innerType._parse(input);\n }\n unwrap() {\n return this._def.innerType;\n }\n}\nZodOptional.create = (type, params) => {\n return new ZodOptional({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodOptional,\n ...processCreateParams(params),\n });\n};\nclass ZodNullable extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType === ZodParsedType.null) {\n return OK(null);\n }\n return this._def.innerType._parse(input);\n }\n unwrap() {\n return this._def.innerType;\n }\n}\nZodNullable.create = (type, params) => {\n return new ZodNullable({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodNullable,\n ...processCreateParams(params),\n });\n};\nclass ZodDefault extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n let data = ctx.data;\n if (ctx.parsedType === ZodParsedType.undefined) {\n data = this._def.defaultValue();\n }\n return this._def.innerType._parse({\n data,\n path: ctx.path,\n parent: ctx,\n });\n }\n removeDefault() {\n return this._def.innerType;\n }\n}\nZodDefault.create = (type, params) => {\n return new ZodDefault({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodDefault,\n defaultValue: typeof params.default === \"function\"\n ? params.default\n : () => params.default,\n ...processCreateParams(params),\n });\n};\nclass ZodCatch extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n // newCtx is used to not collect issues from inner types in ctx\n const newCtx = {\n ...ctx,\n common: {\n ...ctx.common,\n issues: [],\n },\n };\n const result = this._def.innerType._parse({\n data: newCtx.data,\n path: newCtx.path,\n parent: {\n ...newCtx,\n },\n });\n if (isAsync(result)) {\n return result.then((result) => {\n return {\n status: \"valid\",\n value: result.status === \"valid\"\n ? result.value\n : this._def.catchValue({\n get error() {\n return new ZodError(newCtx.common.issues);\n },\n input: newCtx.data,\n }),\n };\n });\n }\n else {\n return {\n status: \"valid\",\n value: result.status === \"valid\"\n ? result.value\n : this._def.catchValue({\n get error() {\n return new ZodError(newCtx.common.issues);\n },\n input: newCtx.data,\n }),\n };\n }\n }\n removeCatch() {\n return this._def.innerType;\n }\n}\nZodCatch.create = (type, params) => {\n return new ZodCatch({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodCatch,\n catchValue: typeof params.catch === \"function\" ? params.catch : () => params.catch,\n ...processCreateParams(params),\n });\n};\nclass ZodNaN extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.nan) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.nan,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n return { status: \"valid\", value: input.data };\n }\n}\nZodNaN.create = (params) => {\n return new ZodNaN({\n typeName: ZodFirstPartyTypeKind.ZodNaN,\n ...processCreateParams(params),\n });\n};\nconst BRAND = Symbol(\"zod_brand\");\nclass ZodBranded extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n const data = ctx.data;\n return this._def.type._parse({\n data,\n path: ctx.path,\n parent: ctx,\n });\n }\n unwrap() {\n return this._def.type;\n }\n}\nclass ZodPipeline extends ZodType {\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.common.async) {\n const handleAsync = async () => {\n const inResult = await this._def.in._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n });\n if (inResult.status === \"aborted\")\n return INVALID;\n if (inResult.status === \"dirty\") {\n status.dirty();\n return DIRTY(inResult.value);\n }\n else {\n return this._def.out._parseAsync({\n data: inResult.value,\n path: ctx.path,\n parent: ctx,\n });\n }\n };\n return handleAsync();\n }\n else {\n const inResult = this._def.in._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx,\n });\n if (inResult.status === \"aborted\")\n return INVALID;\n if (inResult.status === \"dirty\") {\n status.dirty();\n return {\n status: \"dirty\",\n value: inResult.value,\n };\n }\n else {\n return this._def.out._parseSync({\n data: inResult.value,\n path: ctx.path,\n parent: ctx,\n });\n }\n }\n }\n static create(a, b) {\n return new ZodPipeline({\n in: a,\n out: b,\n typeName: ZodFirstPartyTypeKind.ZodPipeline,\n });\n }\n}\nclass ZodReadonly extends ZodType {\n _parse(input) {\n const result = this._def.innerType._parse(input);\n if (isValid(result)) {\n result.value = Object.freeze(result.value);\n }\n return result;\n }\n}\nZodReadonly.create = (type, params) => {\n return new ZodReadonly({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodReadonly,\n ...processCreateParams(params),\n });\n};\nconst custom = (check, params = {}, \n/**\n * @deprecated\n *\n * Pass `fatal` into the params object instead:\n *\n * ```ts\n * z.string().custom((val) => val.length > 5, { fatal: false })\n * ```\n *\n */\nfatal) => {\n if (check)\n return ZodAny.create().superRefine((data, ctx) => {\n var _a, _b;\n if (!check(data)) {\n const p = typeof params === \"function\"\n ? params(data)\n : typeof params === \"string\"\n ? { message: params }\n : params;\n const _fatal = (_b = (_a = p.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;\n const p2 = typeof p === \"string\" ? { message: p } : p;\n ctx.addIssue({ code: \"custom\", ...p2, fatal: _fatal });\n }\n });\n return ZodAny.create();\n};\nconst late = {\n object: ZodObject.lazycreate,\n};\nvar ZodFirstPartyTypeKind;\n(function (ZodFirstPartyTypeKind) {\n ZodFirstPartyTypeKind[\"ZodString\"] = \"ZodString\";\n ZodFirstPartyTypeKind[\"ZodNumber\"] = \"ZodNumber\";\n ZodFirstPartyTypeKind[\"ZodNaN\"] = \"ZodNaN\";\n ZodFirstPartyTypeKind[\"ZodBigInt\"] = \"ZodBigInt\";\n ZodFirstPartyTypeKind[\"ZodBoolean\"] = \"ZodBoolean\";\n ZodFirstPartyTypeKind[\"ZodDate\"] = \"ZodDate\";\n ZodFirstPartyTypeKind[\"ZodSymbol\"] = \"ZodSymbol\";\n ZodFirstPartyTypeKind[\"ZodUndefined\"] = \"ZodUndefined\";\n ZodFirstPartyTypeKind[\"ZodNull\"] = \"ZodNull\";\n ZodFirstPartyTypeKind[\"ZodAny\"] = \"ZodAny\";\n ZodFirstPartyTypeKind[\"ZodUnknown\"] = \"ZodUnknown\";\n ZodFirstPartyTypeKind[\"ZodNever\"] = \"ZodNever\";\n ZodFirstPartyTypeKind[\"ZodVoid\"] = \"ZodVoid\";\n ZodFirstPartyTypeKind[\"ZodArray\"] = \"ZodArray\";\n ZodFirstPartyTypeKind[\"ZodObject\"] = \"ZodObject\";\n ZodFirstPartyTypeKind[\"ZodUnion\"] = \"ZodUnion\";\n ZodFirstPartyTypeKind[\"ZodDiscriminatedUnion\"] = \"ZodDiscriminatedUnion\";\n ZodFirstPartyTypeKind[\"ZodIntersection\"] = \"ZodIntersection\";\n ZodFirstPartyTypeKind[\"ZodTuple\"] = \"ZodTuple\";\n ZodFirstPartyTypeKind[\"ZodRecord\"] = \"ZodRecord\";\n ZodFirstPartyTypeKind[\"ZodMap\"] = \"ZodMap\";\n ZodFirstPartyTypeKind[\"ZodSet\"] = \"ZodSet\";\n ZodFirstPartyTypeKind[\"ZodFunction\"] = \"ZodFunction\";\n ZodFirstPartyTypeKind[\"ZodLazy\"] = \"ZodLazy\";\n ZodFirstPartyTypeKind[\"ZodLiteral\"] = \"ZodLiteral\";\n ZodFirstPartyTypeKind[\"ZodEnum\"] = \"ZodEnum\";\n ZodFirstPartyTypeKind[\"ZodEffects\"] = \"ZodEffects\";\n ZodFirstPartyTypeKind[\"ZodNativeEnum\"] = \"ZodNativeEnum\";\n ZodFirstPartyTypeKind[\"ZodOptional\"] = \"ZodOptional\";\n ZodFirstPartyTypeKind[\"ZodNullable\"] = \"ZodNullable\";\n ZodFirstPartyTypeKind[\"ZodDefault\"] = \"ZodDefault\";\n ZodFirstPartyTypeKind[\"ZodCatch\"] = \"ZodCatch\";\n ZodFirstPartyTypeKind[\"ZodPromise\"] = \"ZodPromise\";\n ZodFirstPartyTypeKind[\"ZodBranded\"] = \"ZodBranded\";\n ZodFirstPartyTypeKind[\"ZodPipeline\"] = \"ZodPipeline\";\n ZodFirstPartyTypeKind[\"ZodReadonly\"] = \"ZodReadonly\";\n})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));\nconst instanceOfType = (\n// const instanceOfType = <T extends new (...args: any[]) => any>(\ncls, params = {\n message: `Input not instance of ${cls.name}`,\n}) => custom((data) => data instanceof cls, params);\nconst stringType = ZodString.create;\nconst numberType = ZodNumber.create;\nconst nanType = ZodNaN.create;\nconst bigIntType = ZodBigInt.create;\nconst booleanType = ZodBoolean.create;\nconst dateType = ZodDate.create;\nconst symbolType = ZodSymbol.create;\nconst undefinedType = ZodUndefined.create;\nconst nullType = ZodNull.create;\nconst anyType = ZodAny.create;\nconst unknownType = ZodUnknown.create;\nconst neverType = ZodNever.create;\nconst voidType = ZodVoid.create;\nconst arrayType = ZodArray.create;\nconst objectType = ZodObject.create;\nconst strictObjectType = ZodObject.strictCreate;\nconst unionType = ZodUnion.create;\nconst discriminatedUnionType = ZodDiscriminatedUnion.create;\nconst intersectionType = ZodIntersection.create;\nconst tupleType = ZodTuple.create;\nconst recordType = ZodRecord.create;\nconst mapType = ZodMap.create;\nconst setType = ZodSet.create;\nconst functionType = ZodFunction.create;\nconst lazyType = ZodLazy.create;\nconst literalType = ZodLiteral.create;\nconst enumType = ZodEnum.create;\nconst nativeEnumType = ZodNativeEnum.create;\nconst promiseType = ZodPromise.create;\nconst effectsType = ZodEffects.create;\nconst optionalType = ZodOptional.create;\nconst nullableType = ZodNullable.create;\nconst preprocessType = ZodEffects.createWithPreprocess;\nconst pipelineType = ZodPipeline.create;\nconst ostring = () => stringType().optional();\nconst onumber = () => numberType().optional();\nconst oboolean = () => booleanType().optional();\nconst coerce = {\n string: ((arg) => ZodString.create({ ...arg, coerce: true })),\n number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),\n boolean: ((arg) => ZodBoolean.create({\n ...arg,\n coerce: true,\n })),\n bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),\n date: ((arg) => ZodDate.create({ ...arg, coerce: true })),\n};\nconst NEVER = INVALID;\n\nvar z = /*#__PURE__*/Object.freeze({\n __proto__: null,\n defaultErrorMap: errorMap,\n setErrorMap: setErrorMap,\n getErrorMap: getErrorMap,\n makeIssue: makeIssue,\n EMPTY_PATH: EMPTY_PATH,\n addIssueToContext: addIssueToContext,\n ParseStatus: ParseStatus,\n INVALID: INVALID,\n DIRTY: DIRTY,\n OK: OK,\n isAborted: isAborted,\n isDirty: isDirty,\n isValid: isValid,\n isAsync: isAsync,\n get util () { return util; },\n get objectUtil () { return objectUtil; },\n ZodParsedType: ZodParsedType,\n getParsedType: getParsedType,\n ZodType: ZodType,\n ZodString: ZodString,\n ZodNumber: ZodNumber,\n ZodBigInt: ZodBigInt,\n ZodBoolean: ZodBoolean,\n ZodDate: ZodDate,\n ZodSymbol: ZodSymbol,\n ZodUndefined: ZodUndefined,\n ZodNull: ZodNull,\n ZodAny: ZodAny,\n ZodUnknown: ZodUnknown,\n ZodNever: ZodNever,\n ZodVoid: ZodVoid,\n ZodArray: ZodArray,\n ZodObject: ZodObject,\n ZodUnion: ZodUnion,\n ZodDiscriminatedUnion: ZodDiscriminatedUnion,\n ZodIntersection: ZodIntersection,\n ZodTuple: ZodTuple,\n ZodRecord: ZodRecord,\n ZodMap: ZodMap,\n ZodSet: ZodSet,\n ZodFunction: ZodFunction,\n ZodLazy: ZodLazy,\n ZodLiteral: ZodLiteral,\n ZodEnum: ZodEnum,\n ZodNativeEnum: ZodNativeEnum,\n ZodPromise: ZodPromise,\n ZodEffects: ZodEffects,\n ZodTransformer: ZodEffects,\n ZodOptional: ZodOptional,\n ZodNullable: ZodNullable,\n ZodDefault: ZodDefault,\n ZodCatch: ZodCatch,\n ZodNaN: ZodNaN,\n BRAND: BRAND,\n ZodBranded: ZodBranded,\n ZodPipeline: ZodPipeline,\n ZodReadonly: ZodReadonly,\n custom: custom,\n Schema: ZodType,\n ZodSchema: ZodType,\n late: late,\n get ZodFirstPartyTypeKind () { return ZodFirstPartyTypeKind; },\n coerce: coerce,\n any: anyType,\n array: arrayType,\n bigint: bigIntType,\n boolean: booleanType,\n date: dateType,\n discriminatedUnion: discriminatedUnionType,\n effect: effectsType,\n 'enum': enumType,\n 'function': functionType,\n 'instanceof': instanceOfType,\n intersection: intersectionType,\n lazy: lazyType,\n literal: literalType,\n map: mapType,\n nan: nanType,\n nativeEnum: nativeEnumType,\n never: neverType,\n 'null': nullType,\n nullable: nullableType,\n number: numberType,\n object: objectType,\n oboolean: oboolean,\n onumber: onumber,\n optional: optionalType,\n ostring: ostring,\n pipeline: pipelineType,\n preprocess: preprocessType,\n promise: promiseType,\n record: recordType,\n set: setType,\n strictObject: strictObjectType,\n string: stringType,\n symbol: symbolType,\n transformer: effectsType,\n tuple: tupleType,\n 'undefined': undefinedType,\n union: unionType,\n unknown: unknownType,\n 'void': voidType,\n NEVER: NEVER,\n ZodIssueCode: ZodIssueCode,\n quotelessJson: quotelessJson,\n ZodError: ZodError\n});\n\nexport { BRAND, DIRTY, EMPTY_PATH, INVALID, NEVER, OK, ParseStatus, ZodType as Schema, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodBranded, ZodCatch, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEnum, ZodError, ZodFirstPartyTypeKind, ZodFunction, ZodIntersection, ZodIssueCode, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodParsedType, ZodPipeline, ZodPromise, ZodReadonly, ZodRecord, ZodType as ZodSchema, ZodSet, ZodString, ZodSymbol, ZodEffects as ZodTransformer, ZodTuple, ZodType, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, addIssueToContext, anyType as any, arrayType as array, bigIntType as bigint, booleanType as boolean, coerce, custom, dateType as date, z as default, errorMap as defaultErrorMap, discriminatedUnionType as discriminatedUnion, effectsType as effect, enumType as enum, functionType as function, getErrorMap, getParsedType, instanceOfType as instanceof, intersectionType as intersection, isAborted, isAsync, isDirty, isValid, late, lazyType as lazy, literalType as literal, makeIssue, mapType as map, nanType as nan, nativeEnumType as nativeEnum, neverType as never, nullType as null, nullableType as nullable, numberType as number, objectType as object, objectUtil, oboolean, onumber, optionalType as optional, ostring, pipelineType as pipeline, preprocessType as preprocess, promiseType as promise, quotelessJson, recordType as record, setType as set, setErrorMap, strictObjectType as strictObject, stringType as string, symbolType as symbol, effectsType as transformer, tupleType as tuple, undefinedType as undefined, unionType as union, unknownType as unknown, util, voidType as void, z };\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nexport const numberCouple = z.tuple([z.number(), z.number()]);\nexport type NumberCouple = z.infer<typeof numberCouple>;\n\n// Dimensions\n\nexport const dimensions = z.object({ width: z.number(), height: z.number() });\nexport type Dimensions = z.infer<typeof dimensions>;\nexport const signedDimensions = z.object({\n signedWidth: z.number(),\n signedHeight: z.number(),\n});\nexport const DIMENSIONS = [\"width\", \"height\"] as const;\nexport const dimension = z.enum(DIMENSIONS);\nexport type Dimension = (typeof DIMENSIONS)[number];\nexport const ALIGNMENTS = [\"start\", \"center\", \"end\"] as const;\nexport const SIGNED_DIMENSIONS = [\"signedWidth\", \"signedHeight\"] as const;\nexport const signedDimension = z.enum(SIGNED_DIMENSIONS);\nexport type SignedDimension = (typeof SIGNED_DIMENSIONS)[number];\n\n// XY\n\nexport const xy = z.object({ x: z.number(), y: z.number() });\nexport type XY = z.infer<typeof xy>;\nexport const clientXY = z.object({ clientX: z.number(), clientY: z.number() });\nexport type ClientXY = z.infer<typeof clientXY>;\n\n// Direction\n\nexport const DIRECTIONS = [\"x\", \"y\"] as const;\nexport const direction = z.enum(DIRECTIONS);\nexport type Direction = z.infer<typeof direction>;\n\n// Location\n\nexport const OUTER_LOCATIONS = [\"top\", \"right\", \"bottom\", \"left\"] as const;\nexport const outerLocation = z.enum(OUTER_LOCATIONS);\nexport type OuterLocation = (typeof OUTER_LOCATIONS)[number];\nexport const X_LOCATIONS = [\"left\", \"right\"] as const;\nexport const xLocation = z.enum(X_LOCATIONS);\nexport type XLocation = (typeof X_LOCATIONS)[number];\nexport const Y_LOCATIONS = [\"top\", \"bottom\"] as const;\nexport const yLocation = z.enum(Y_LOCATIONS);\nexport type YLocation = (typeof Y_LOCATIONS)[number];\nexport const CENTER_LOCATIONS = [\"center\"] as const;\nexport const centerlocation = z.enum(CENTER_LOCATIONS);\nexport type CenterLocation = (typeof CENTER_LOCATIONS)[number];\nexport const LOCATIONS = [...OUTER_LOCATIONS, ...CENTER_LOCATIONS] as const;\nexport const location = z.enum(LOCATIONS);\nexport type Location = z.infer<typeof location>;\n\n// Alignment\n\nexport const alignment = z.enum(ALIGNMENTS);\nexport type Alignment = (typeof ALIGNMENTS)[number];\nexport const ORDERS = [\"first\", \"last\"] as const;\nexport const order = z.enum(ORDERS);\nexport type Order = (typeof ORDERS)[number];\n\n// Bounds\n\nexport const bounds = z.object({ lower: z.number(), upper: z.number() });\nexport type Bounds = z.infer<typeof bounds>;\n\nexport const crudeBounds = z.union([bounds, numberCouple]);\nexport type CrudeBounds = z.infer<typeof crudeBounds>;\nexport const crudeDirection = z.union([direction, location]);\nexport type CrudeDirection = z.infer<typeof crudeDirection>;\nexport const crudeLocation = z.union([direction, location, z.instanceof(String)]);\nexport type CrudeLocation = z.infer<typeof crudeLocation>;\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Bounds, bounds, type CrudeBounds } from \"@/spatial/base\";\n\nexport { type Bounds, bounds };\n\nexport type Crude = CrudeBounds;\n\nexport const construct = (lower: number | Crude, upper?: number): Bounds => {\n const b = { lower: 0, upper: 0 };\n if (typeof lower === \"number\") {\n if (upper != null) {\n b.lower = lower;\n b.upper = upper;\n } else {\n b.lower = 0;\n b.upper = lower;\n }\n } else if (Array.isArray(lower)) {\n [b.lower, b.upper] = lower;\n } else {\n b.lower = lower.lower;\n b.upper = lower.upper;\n }\n return makeValid(b);\n};\n\nexport const ZERO = { lower: 0, upper: 0 };\n\nexport const INFINITE = { lower: -Infinity, upper: Infinity };\n\nexport const DECIMAL = { lower: 0, upper: 1 };\n\nexport const CLIP = { lower: -1, upper: 1 };\n\nexport const equals = (_a?: Bounds, _b?: Bounds): boolean => {\n if (_a == null && _b == null) return true;\n if (_a == null || _b == null) return false;\n const a = construct(_a);\n const b = construct(_b);\n return a?.lower === b?.lower && a?.upper === b?.upper;\n}\n\nexport const makeValid = (a: Bounds): Bounds => {\n if (a.lower > a.upper) return { lower: a.upper, upper: a.lower };\n return a;\n};\n\nexport const clamp = (bounds: Crude, target: number): number => {\n const _bounds = construct(bounds);\n if (target < _bounds.lower) return _bounds.lower;\n if (target >= _bounds.upper) return _bounds.upper - 1;\n return target;\n};\n\nexport const contains = (bounds: Crude, target: number | CrudeBounds): boolean => {\n const _bounds = construct(bounds);\n if (typeof target === \"number\") return target >= _bounds.lower && target < _bounds.upper;\n const _target = construct(target);\n return _target.lower >= _bounds.lower && _target.upper <= _bounds.upper;\n}\n\nexport const overlapsWith = (a: Crude, b: Crude): boolean => {\n const _a = construct(a);\n const _b = construct(b);\n if (_a.lower ==_b.lower) return true;\n if (_b.upper == _a.lower || _b.lower == _a.upper) return false;\n return contains(_a, _b.upper) \n || contains(_a, _b.lower) \n || contains(_b, _a.upper) \n || contains(_b, _a.lower);\n}\n\nexport const span = (a: Crude): number => {\n const _a = construct(a);\n return _a.upper - _a.lower;\n}\n\nexport const isZero = (a: Crude): boolean => {\n const _a = construct(a);\n return _a.lower === 0 && _a.upper === 0;\n}\n\nexport const spanIsZero = (a: Crude): boolean => span(a) === 0;\n\nexport const isFinite = (a: Crude): boolean => {\n const _a = construct(a);\n return Number.isFinite(_a.lower) && Number.isFinite(_a.upper);\n}\n\nexport const max = (bounds: Crude[]): Bounds => ({\n lower: Math.min(...bounds.map((b) => construct(b).lower)),\n upper: Math.max(...bounds.map((b) => construct(b).upper)),\n});\n\nexport const min = (bounds: Crude[]): Bounds => ({\n lower: Math.max(...bounds.map((b) => construct(b).lower)),\n upper: Math.min(...bounds.map((b) => construct(b).upper)),\n});\n\nexport const constructArray = (bounds: Crude): number[] => {\n const _bounds = construct(bounds);\n return Array.from({ length: span(bounds) }, (_, i) => i + _bounds.lower);\n}\n\nexport const findInsertPosition = (bounds: Crude[], target: number): { index: number, position: number } => {\n const _bounds = bounds.map(construct);\n const index = _bounds.findIndex((b, i) => contains(b, target) || target < _bounds[i].lower);\n if (index === -1) return { index: bounds.length, position: 0 };\n const b = _bounds[index];\n if (contains(b, target)) return { index, position: target - b.lower };\n return {index: index, position: 0};\n}\n\n\n/**\n * A plan for inserting a new bound into an ordered array of bounds.\n */\nexport interface InsertionPlan {\n /** How much to increase the lower bound of the new bound or decrease the upper bound\n * of the previous bound. */\n removeBefore: number;\n /** How much to decrease the upper bound of the new bound or increase the lower bound\n * of the next bound. */\n removeAfter: number;\n /** The index at which to insert the new bound. */\n insertInto: number;\n /** The number of bounds to remove from the array. */\n deleteInBetween: number;\n}\n\nconst ZERO_PLAN: InsertionPlan = {\n removeBefore: 0,\n removeAfter: 0,\n insertInto: 0,\n deleteInBetween: 0,\n}\n\n/**\n * Build a plan for inserting a new bound into an ordered array of bounds. This function\n * is particularly useful for inserting a new array into a sorted array of array of arrays\n * that may overlap. The plan is used to determine how to splice the new array into the\n * existing array. The following are important constraints:\n * \n * \n * 1. If the new bound is entirely contained within an existing bound, the new bound\n * is not inserted and the plan is null.\n * \n * @param bounds - An ordered array of bounds, where each bound is valid (i.e., lower <= upper)\n * and the lower bound of each bound is less than the upper bound of the next bound.\n * @param value - The new bound to insert.\n * @returns A plan for inserting the new bound into the array of bounds, or null if the\n * new bound is entirely contained within an existing bound. See the {@link InsertionPlan}\n * type for more details.\n */\nexport const buildInsertionPlan = (bounds: Crude[], value: Crude):InsertionPlan | null => {\n const _bounds = bounds.map(construct);\n const _target = construct(value);\n // No bounds to insert into, so just insert the new bound at the beginning of the array.\n if (_bounds.length === 0) return ZERO_PLAN;\n const lower = findInsertPosition(bounds, _target.lower);\n const upper = findInsertPosition(bounds, _target.upper);\n // Greater than all bounds,\n if (lower.index == bounds.length) return { ...ZERO_PLAN, insertInto: bounds.length };\n // Less than all bounds,\n if (upper.index == 0) return {\n ...ZERO_PLAN,\n removeAfter: upper.position\n }\n if (lower.index === upper.index) {\n // The case where the bound is entirely contained within an existing bound.\n if (lower.position !== 0 && upper.position !== 0)\n return null;\n return {\n removeAfter: upper.position,\n removeBefore: lower.position,\n insertInto: lower.index,\n deleteInBetween: 0,\n }\n }\n let deleteInBetween = (upper.index - lower.index)\n let insertInto = lower.index;\n let removeBefore = span(_bounds[lower.index]) - lower.position;\n // If we're overlapping with the previous bound, we need to slice out one less\n // and insert one further up.\n if (lower.position != 0) {\n deleteInBetween -= 1;\n insertInto += 1;\n // We're not overlapping with the previous bound, so don't need to remove anything\n } else removeBefore = 0;\n return {\n removeBefore,\n removeAfter: upper.position,\n insertInto, \n deleteInBetween,\n }\n}\n\n\nexport const insert = (bounds: Crude[], value: Crude): Crude[] => {\n const plan = buildInsertionPlan(bounds, value);\n if (plan == null) return bounds;\n const _target = construct(value);\n _target.lower += plan.removeBefore;\n _target.upper -= plan.removeAfter;\n bounds.splice(plan.insertInto, plan.deleteInBetween, _target);\n return bounds.map(construct);\n}\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport {\n type Dimension,\n type Direction,\n type Location,\n type direction,\n DIRECTIONS,\n Y_LOCATIONS,\n type YLocation,\n type SignedDimension,\n crudeDirection,\n type CrudeDirection,\n} from \"@/spatial/base\";\n\nexport type { Direction, direction };\n\nexport const crude = crudeDirection;\n\nexport type Crude = CrudeDirection;\n\nexport const construct = (c: Crude): Direction => {\n if (DIRECTIONS.includes(c as Direction)) return c as Direction;\n if (Y_LOCATIONS.includes(c as YLocation)) return \"y\";\n else return \"x\";\n};\n\nexport const swap = (direction: CrudeDirection): Direction =>\n construct(direction) === \"x\" ? \"y\" : \"x\";\n\nexport const dimension = (direction: CrudeDirection): Dimension =>\n construct(direction) === \"x\" ? \"width\" : \"height\";\n\nexport const location = (direction: CrudeDirection): Location =>\n construct(direction) === \"x\" ? \"left\" : \"top\";\n\nexport const isDirection = (c: unknown): c is Direction => crude.safeParse(c).success;\n\nexport const signedDimension = (direction: CrudeDirection): SignedDimension =>\n construct(direction) === \"x\" ? \"signedWidth\" : \"signedHeight\";\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toCamelCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n return String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/[^A-Za-z0-9]+/g, '$')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + \"$\" + b; })\n .toLowerCase()\n .replace(/(\\$)(\\w)/g, function (m, a, b) { return b.toUpperCase(); });\n}\nexports.default = toCamelCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toSnakeCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n return String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + '_' + b.toLowerCase(); })\n .replace(/[^A-Za-z0-9]+|_+/g, '_')\n .toLowerCase();\n}\nexports.default = toSnakeCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toPascalCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n return String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '$')\n .replace(/[^A-Za-z0-9]+/g, '$')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + \"$\" + b; })\n .toLowerCase()\n .replace(/(\\$)(\\w?)/g, function (m, a, b) { return b.toUpperCase(); });\n}\nexports.default = toPascalCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toDotCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n return String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + \"_\" + b.toLowerCase(); })\n .replace(/[^A-Za-z0-9]+|_+/g, '.')\n .toLowerCase();\n}\nexports.default = toDotCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toPathCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n return String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + \"_\" + b.toLowerCase(); })\n .replace(/[^A-Za-z0-9]+|_+/g, '/')\n .toLowerCase();\n}\nexports.default = toPathCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toTextCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n return String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + '_' + b.toLowerCase(); })\n .replace(/[^A-Za-z0-9]+|_+/g, ' ')\n .toLowerCase();\n}\nexports.default = toTextCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toSentenceCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n var textcase = String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + \"_\" + b.toLowerCase(); })\n .replace(/[^A-Za-z0-9]+|_+/g, ' ')\n .toLowerCase();\n return textcase.charAt(0).toUpperCase() + textcase.slice(1);\n}\nexports.default = toSentenceCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toHeaderCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n return String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + \"_\" + b.toLowerCase(); })\n .replace(/[^A-Za-z0-9]+|_+/g, ' ')\n .toLowerCase()\n .replace(/( ?)(\\w+)( ?)/g, function (m, a, b, c) { return a + b.charAt(0).toUpperCase() + b.slice(1) + c; });\n}\nexports.default = toHeaderCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction toKebabCase(str) {\n if (str === void 0) { str = ''; }\n if (!str)\n return '';\n return String(str)\n .replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, '')\n .replace(/([a-z])([A-Z])/g, function (m, a, b) { return a + \"_\" + b.toLowerCase(); })\n .replace(/[^A-Za-z0-9]+|_+/g, '-')\n .toLowerCase();\n}\nexports.default = toKebabCase;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.belongToTypes = exports.isValidObject = exports.isArrayObject = exports.validateOptions = exports.DefaultOption = void 0;\n/**\n * Default options for convert function. This option is not recursive.\n */\nexports.DefaultOption = {\n recursive: false,\n recursiveInArray: false,\n keepTypesOnRecursion: []\n};\nexports.validateOptions = function (opt) {\n if (opt === void 0) { opt = exports.DefaultOption; }\n if (opt.recursive == null) {\n opt = exports.DefaultOption;\n }\n else if (opt.recursiveInArray == null) {\n opt.recursiveInArray = false;\n }\n return opt;\n};\nexports.isArrayObject = function (obj) { return obj != null && Array.isArray(obj); };\nexports.isValidObject = function (obj) { return obj != null && typeof obj === 'object' && !Array.isArray(obj); };\nexports.belongToTypes = function (obj, types) { return (types || []).some(function (Type) { return obj instanceof Type; }); };\n","\"use strict\";\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar utils_1 = require(\"../utils\");\n/**\n * Convert string keys in an object to lowercase format.\n * @param obj: object to convert keys. If `obj` isn't a json object, `null` is returned.\n * @param opt: (optional) Options parameter, default is non-recursive.\n */\nfunction lowerKeys(obj, opt) {\n if (opt === void 0) { opt = utils_1.DefaultOption; }\n if (!utils_1.isValidObject(obj))\n return null;\n opt = utils_1.validateOptions(opt);\n var res = {};\n Object.keys(obj).forEach(function (key) {\n var value = obj[key];\n var nkey = key.toLowerCase();\n if (opt.recursive) {\n if (utils_1.isValidObject(value)) {\n if (!utils_1.belongToTypes(value, opt.keepTypesOnRecursion)) {\n value = lowerKeys(value, opt);\n }\n }\n else if (opt.recursiveInArray && utils_1.isArrayObject(value)) {\n value = __spreadArrays(value).map(function (v) {\n var ret = v;\n if (utils_1.isValidObject(v)) {\n // object in array\n if (!utils_1.belongToTypes(ret, opt.keepTypesOnRecursion)) {\n ret = lowerKeys(v, opt);\n }\n }\n else if (utils_1.isArrayObject(v)) {\n // array in array\n // workaround by using an object holding array value\n var temp = lowerKeys({ key: v }, opt);\n ret = temp.key;\n }\n return ret;\n });\n }\n }\n res[nkey] = value;\n });\n return res;\n}\nexports.default = lowerKeys;\n","\"use strict\";\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar utils_1 = require(\"../utils\");\n/**\n * Convert string keys in an object to UPPERCASE format.\n * @param obj: object to convert keys. If `obj` isn't a json object, `null` is returned.\n * @param opt: (optional) Options parameter, default is non-recursive.\n */\nfunction upperKeys(obj, opt) {\n if (opt === void 0) { opt = utils_1.DefaultOption; }\n if (!utils_1.isValidObject(obj))\n return null;\n opt = utils_1.validateOptions(opt);\n var res = {};\n Object.keys(obj).forEach(function (key) {\n var value = obj[key];\n var nkey = key.toUpperCase();\n if (opt.recursive) {\n if (utils_1.isValidObject(value)) {\n if (!utils_1.belongToTypes(value, opt.keepTypesOnRecursion)) {\n value = upperKeys(value, opt);\n }\n }\n else if (opt.recursiveInArray && utils_1.isArrayObject(value)) {\n value = __spreadArrays(value).map(function (v) {\n var ret = v;\n if (utils_1.isValidObject(v)) {\n // object in array\n if (!utils_1.belongToTypes(ret, opt.keepTypesOnRecursion)) {\n ret = upperKeys(v, opt);\n }\n }\n else if (utils_1.isArrayObject(v)) {\n // array in array\n // workaround by using an object holding array value\n var temp = upperKeys({ key: v }, opt);\n ret = temp.key;\n }\n return ret;\n });\n }\n }\n res[nkey] = value;\n });\n return res;\n}\nexports.default = upperKeys;\n","\"use strict\";\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar utils_1 = require(\"../utils\");\nvar js_camelcase_1 = require(\"../../js-camelcase\");\n/**\n * Convert string keys in an object to camelCase format.\n * @param obj: object to convert keys. If `obj` isn't a json object, `null` is returned.\n * @param opt: (optional) Options parameter, default is non-recursive.\n */\nfunction camelKeys(obj, opt) {\n if (opt === void 0) { opt = utils_1.DefaultOption; }\n if (!utils_1.isValidObject(obj))\n return null;\n opt = utils_1.validateOptions(opt);\n var res = {};\n Object.keys(obj).forEach(function (key) {\n var value = obj[key];\n var nkey = js_camelcase_1.default(key);\n if (opt.recursive) {\n if (utils_1.isValidObject(value)) {\n if (!utils_1.belongToTypes(value, opt.keepTypesOnRecursion)) {\n value = camelKeys(value, opt);\n }\n }\n else if (opt.recursiveInArray && utils_1.isArrayObject(value)) {\n value = __spreadArrays(value).map(function (v) {\n var ret = v;\n if (utils_1.isValidObject(v)) {\n // object in array\n if (!utils_1.belongToTypes(ret, opt.keepTypesOnRecursion)) {\n ret = camelKeys(v, opt);\n }\n }\n else if (utils_1.isArrayObject(v)) {\n // array in array\n // workaround by using an object holding array value\n var temp = camelKeys({ key: v }, opt);\n ret = temp.key;\n }\n return ret;\n });\n }\n }\n res[nkey] = value;\n });\n return res;\n}\nexports.default = camelKeys;\n","\"use strict\";\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar utils_1 = require(\"../utils\");\nvar js_snakecase_1 = require(\"../../js-snakecase\");\n/**\n * Convert string keys in an object to snake_case format.\n * @param obj: object to convert keys. If `obj` isn't a json object, `null` is returned.\n * @param opt: (optional) Options parameter, default is non-recursive.\n */\nfunction snakeKeys(obj, opt) {\n if (opt === void 0) { opt = utils_1.DefaultOption; }\n if (!utils_1.isValidObject(obj))\n return null;\n opt = utils_1.validateOptions(opt);\n var res = {};\n Object.keys(obj).forEach(function (key) {\n var value = obj[key];\n var nkey = js_snakecase_1.default(key);\n if (opt.recursive) {\n if (utils_1.isValidObject(value)) {\n if (!utils_1.belongToTypes(value, opt.keepTypesOnRecursion)) {\n value = snakeKeys(value, opt);\n }\n }\n else if (opt.recursiveInArray && utils_1.isArrayObject(value)) {\n value = __spreadArrays(value).map(function (v) {\n var ret = v;\n if (utils_1.isValidObject(v)) {\n // object in array\n if (!utils_1.belongToTypes(ret, opt.keepTypesOnRecursion)) {\n ret = snakeKeys(v, opt);\n }\n }\n else if (utils_1.isArrayObject(v)) {\n // array in array\n // workaround by using an object holding array value\n var temp = snakeKeys({ key: v }, opt);\n ret = temp.key;\n }\n return ret;\n });\n }\n }\n res[nkey] = value;\n });\n return res;\n}\nexports.default = snakeKeys;\n","\"use strict\";\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar utils_1 = require(\"../utils\");\nvar js_pascalcase_1 = require(\"../../js-pascalcase\");\n/**\n * Convert string keys in an object to PascalCase format.\n * @param obj: object to convert keys. If `obj` isn't a json object, `null` is returned.\n * @param opt: (optional) Options parameter, default is non-recursive.\n */\nfunction pascalKeys(obj, opt) {\n if (opt === void 0) { opt = utils_1.DefaultOption; }\n if (!utils_1.isValidObject(obj))\n return null;\n opt = utils_1.validateOptions(opt);\n var res = {};\n Object.keys(obj).forEach(function (key) {\n var value = obj[key];\n var nkey = js_pascalcase_1.default(key);\n if (opt.recursive) {\n if (utils_1.isValidObject(value)) {\n if (!utils_1.belongToTypes(value, opt.keepTypesOnRecursion)) {\n value = pascalKeys(value, opt);\n }\n }\n else if (opt.recursiveInArray && utils_1.isArrayObject(value)) {\n value = __spreadArrays(value).map(function (v) {\n var ret = v;\n if (utils_1.isValidObject(v)) {\n // object in array\n if (!utils_1.belongToTypes(ret, opt.keepTypesOnRecursion)) {\n ret = pascalKeys(v, opt);\n }\n }\n else if (utils_1.isArrayObject(v)) {\n // array in array\n // workaround by using an object holding array value\n var temp = pascalKeys({ key: v }, opt);\n ret = temp.key;\n }\n return ret;\n });\n }\n }\n res[nkey] = value;\n });\n return res;\n}\nexports.default = pascalKeys;\n","\"use strict\";\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar utils_1 = require(\"../utils\");\nvar js_kebabcase_1 = require(\"../../js-kebabcase\");\n/**\n * Convert string keys in an object to kebab-case format.\n * @param obj: object to convert keys. If `obj` isn't a json object, `null` is returned.\n * @param opt: (optional) Options parameter, default is non-recursive.\n */\nfunction kebabKeys(obj, opt) {\n if (opt === void 0) { opt = utils_1.DefaultOption; }\n if (!utils_1.isValidObject(obj))\n return null;\n opt = utils_1.validateOptions(opt);\n var res = {};\n Object.keys(obj).forEach(function (key) {\n var value = obj[key];\n var nkey = js_kebabcase_1.default(key);\n if (opt.recursive) {\n if (utils_1.isValidObject(value)) {\n if (!utils_1.belongToTypes(value, opt.keepTypesOnRecursion)) {\n value = kebabKeys(value, opt);\n }\n }\n else if (opt.recursiveInArray && utils_1.isArrayObject(value)) {\n value = __spreadArrays(value).map(function (v) {\n var ret = v;\n if (utils_1.isValidObject(v)) {\n // object in array\n if (!utils_1.belongToTypes(ret, opt.keepTypesOnRecursion)) {\n ret = kebabKeys(v, opt);\n }\n }\n else if (utils_1.isArrayObject(v)) {\n // array in array\n // workaround by using an object holding array value\n var temp = kebabKeys({ key: v }, opt);\n ret = temp.key;\n }\n return ret;\n });\n }\n }\n res[nkey] = value;\n });\n return res;\n}\nexports.default = kebabKeys;\n","\"use strict\";\n/**\n * Author: <Ha Huynh> https://github.com/huynhsamha\n * Github: https://github.com/huynhsamha/js-convert-case\n * NPM Package: https://www.npmjs.com/package/js-convert-case\n */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.kebabKeys = exports.pascalKeys = exports.snakeKeys = exports.camelKeys = exports.upperKeys = exports.lowerKeys = exports.toLowerCase = exports.toUpperCase = exports.toKebabCase = exports.toHeaderCase = exports.toSentenceCase = exports.toTextCase = exports.toPathCase = exports.toDotCase = exports.toPascalCase = exports.toSnakeCase = exports.toCamelCase = void 0;\nvar js_camelcase_1 = require(\"./modules/js-camelcase\");\nexports.toCamelCase = js_camelcase_1.default;\nvar js_snakecase_1 = require(\"./modules/js-snakecase\");\nexports.toSnakeCase = js_snakecase_1.default;\nvar js_pascalcase_1 = require(\"./modules/js-pascalcase\");\nexports.toPascalCase = js_pascalcase_1.default;\nvar js_dotcase_1 = require(\"./modules/js-dotcase\");\nexports.toDotCase = js_dotcase_1.default;\nvar js_pathcase_1 = require(\"./modules/js-pathcase\");\nexports.toPathCase = js_pathcase_1.default;\nvar js_textcase_1 = require(\"./modules/js-textcase\");\nexports.toTextCase = js_textcase_1.default;\nvar js_sentencecase_1 = require(\"./modules/js-sentencecase\");\nexports.toSentenceCase = js_sentencecase_1.default;\nvar js_headercase_1 = require(\"./modules/js-headercase\");\nexports.toHeaderCase = js_headercase_1.default;\nvar js_kebabcase_1 = require(\"./modules/js-kebabcase\");\nexports.toKebabCase = js_kebabcase_1.default;\nvar lowercase_keys_object_1 = require(\"./modules/extends/lowercase-keys-object\");\nexports.lowerKeys = lowercase_keys_object_1.default;\nvar uppercase_keys_object_1 = require(\"./modules/extends/uppercase-keys-object\");\nexports.upperKeys = uppercase_keys_object_1.default;\nvar camelcase_keys_object_1 = require(\"./modules/extends/camelcase-keys-object\");\nexports.camelKeys = camelcase_keys_object_1.default;\nvar snakecase_keys_object_1 = require(\"./modules/extends/snakecase-keys-object\");\nexports.snakeKeys = snakecase_keys_object_1.default;\nvar pascalcase_keys_object_1 = require(\"./modules/extends/pascalcase-keys-object\");\nexports.pascalKeys = pascalcase_keys_object_1.default;\nvar kebabcase_keys_object_1 = require(\"./modules/extends/kebabcase-keys-object\");\nexports.kebabKeys = kebabcase_keys_object_1.default;\nvar toLowerCase = function (str) { return String(str || '').toLowerCase(); };\nexports.toLowerCase = toLowerCase;\nvar toUpperCase = function (str) { return String(str || '').toUpperCase(); };\nexports.toUpperCase = toUpperCase;\nvar jsConvert = {\n toCamelCase: js_camelcase_1.default,\n toSnakeCase: js_snakecase_1.default,\n toPascalCase: js_pascalcase_1.default,\n toDotCase: js_dotcase_1.default,\n toPathCase: js_pathcase_1.default,\n toTextCase: js_textcase_1.default,\n toSentenceCase: js_sentencecase_1.default,\n toHeaderCase: js_headercase_1.default,\n toKebabCase: js_kebabcase_1.default,\n toUpperCase: toUpperCase,\n toLowerCase: toLowerCase,\n lowerKeys: lowercase_keys_object_1.default,\n upperKeys: uppercase_keys_object_1.default,\n camelKeys: camelcase_keys_object_1.default,\n snakeKeys: snakecase_keys_object_1.default,\n pascalKeys: pascalcase_keys_object_1.default,\n kebabKeys: kebabcase_keys_object_1.default\n};\nexports.default = jsConvert;\n","module.exports = require('./lib');\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { camelKeys as _camelKeys, snakeKeys as _snakeKeys } from \"js-convert-case\";\n\nconst options = {\n recursive: true,\n recursiveInArray: true,\n keepTypesOnRecursion: [Number, String, Uint8Array],\n};\n\nconst snakeKeys = <T>(entity: T): T => _snakeKeys(entity, options) as T;\n\nconst camelKeys = <T>(entity: T): T => _camelKeys(entity, options) as T;\n\nexport namespace Case {\n export const toSnake = snakeKeys;\n export const toCamel = camelKeys;\n export const capitalize = (str: string): string =>\n str[0].toUpperCase() + str.slice(1);\n}\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nimport { Case } from \"@/case\";\nimport {\n location,\n type Location,\n xLocation,\n yLocation,\n DIRECTIONS,\n X_LOCATIONS,\n Y_LOCATIONS,\n CENTER_LOCATIONS,\n type XLocation,\n type OuterLocation,\n type YLocation,\n outerLocation,\n type Direction,\n crudeLocation,\n type CrudeLocation,\n centerlocation,\n type CenterLocation,\n} from \"@/spatial/base\";\n\nexport {\n location,\n type Location,\n X_LOCATIONS,\n Y_LOCATIONS,\n CENTER_LOCATIONS,\n outerLocation as outer,\n};\n\nexport const x = xLocation;\nexport const y = yLocation;\n\nexport type X = XLocation;\nexport type Y = YLocation;\nexport type Outer = OuterLocation;\nexport type Center = CenterLocation;\n\nconst SWAPPED: Record<Location, Location> = {\n top: \"bottom\",\n right: \"left\",\n bottom: \"top\",\n left: \"right\",\n center: \"center\",\n};\n\nconst ROTATE_90: Record<Location, Location> = {\n top: \"left\",\n right: \"top\",\n bottom: \"right\",\n left: \"bottom\",\n center: \"center\",\n};\n\nexport const crude = crudeLocation;\n\nexport type Crude = CrudeLocation;\n\nexport const construct = (cl: Crude): Location => {\n if (cl instanceof String) return cl as Location;\n if (!DIRECTIONS.includes(cl as Direction)) return cl as Location;\n else if (cl === \"x\") return \"left\";\n else return \"top\";\n};\n\nexport const swap = (cl: Crude): Location => SWAPPED[construct(cl)];\n\nexport const rotate90 = (cl: Crude): Location => ROTATE_90[construct(cl)];\n\nexport const direction = (cl: Crude): Direction => {\n const l = construct(cl);\n if (l === \"top\" || l === \"bottom\") return \"y\";\n return \"x\";\n};\n\nexport const xy = z.object({\n x: xLocation.or(centerlocation),\n y: yLocation.or(centerlocation),\n});\nexport const corner = z.object({ x: xLocation, y: yLocation });\n\nexport type XY = z.infer<typeof xy>;\nexport type CornerXY = z.infer<typeof corner>;\nexport type CornerXYString = \"topLeft\" | \"topRight\" | \"bottomLeft\" | \"bottomRight\";\n\nexport const TOP_LEFT: CornerXY = Object.freeze({ x: \"left\", y: \"top\" });\nexport const TOP_RIGHT: CornerXY = Object.freeze({ x: \"right\", y: \"top\" });\nexport const BOTTOM_LEFT: CornerXY = Object.freeze({ x: \"left\", y: \"bottom\" });\nexport const BOTTOM_RIGHT: CornerXY = Object.freeze({ x: \"right\", y: \"bottom\" });\nexport const CENTER: XY = Object.freeze({ x: \"center\", y: \"center\" });\nexport const TOP_CENTER: XY = Object.freeze({ x: \"center\", y: \"top\" });\nexport const BOTTOM_CENTER: XY = Object.freeze({ x: \"center\", y: \"bottom\" });\nexport const RIGHT_CENTER: XY = Object.freeze({ x: \"right\", y: \"center\" });\nexport const LEFT_CENTER: XY = Object.freeze({ x: \"left\", y: \"center\" });\nexport const XY_LOCATIONS: readonly XY[] = Object.freeze([\n LEFT_CENTER,\n RIGHT_CENTER,\n TOP_CENTER,\n BOTTOM_CENTER,\n TOP_LEFT,\n TOP_RIGHT,\n BOTTOM_LEFT,\n BOTTOM_RIGHT,\n CENTER,\n]);\n\nexport const xyEquals = (a: XY, b: XY): boolean => a.x === b.x && a.y === b.y;\n\nexport const xyMatches = (a: XY, l: Partial<XY> | Location): boolean => {\n if (typeof l === \"object\") {\n let ok = true;\n if (\"x\" in l) {\n const ok_ = a.x === l.x;\n if (!ok_) ok = false;\n }\n if (\"y\" in l) {\n const ok_ = a.y === l.y;\n if (!ok_) ok = false;\n }\n return ok;\n }\n return a.x === l || a.y === l;\n};\n\nexport const xyCouple = (a: XY): [Location, Location] => [a.x, a.y];\n\nexport const isX = (a: Crude): a is XLocation | CenterLocation =>\n direction(construct(a)) === \"x\";\n\nexport const isY = (a: Crude): a is YLocation => direction(construct(a)) === \"y\";\n\nexport const xyToString = (a: XY): string => `${a.x}${Case.capitalize(a.y)}`;\n\nexport const constructXY = (x: Crude | XY, y?: Crude): XY => {\n let parsedX: Location;\n let parsedY: Location;\n if (typeof x === \"object\" && \"x\" in x) {\n parsedX = x.x;\n parsedY = x.y;\n } else {\n parsedX = construct(x);\n parsedY = construct(y ?? x);\n }\n if (\n direction(parsedX) === direction(parsedY) &&\n parsedX !== \"center\" &&\n parsedY !== \"center\"\n )\n throw new Error(\n `[XYLocation] - encountered two locations with the same direction: ${parsedX.toString()} - ${parsedY.toString()}`,\n );\n const xy = { ...CENTER };\n if (parsedX === \"center\") {\n if (isX(parsedY)) [xy.x, xy.y] = [parsedY, parsedX];\n else [xy.x, xy.y] = [parsedX, parsedY];\n } else if (parsedY === \"center\") {\n if (isX(parsedX)) [xy.x, xy.y] = [parsedX, parsedY];\n else [xy.x, xy.y] = [parsedY, parsedX];\n } else if (isX(parsedX)) [xy.x, xy.y] = [parsedX, parsedY as YLocation];\n else [xy.x, xy.y] = [parsedY as XLocation, parsedX as YLocation];\n return xy;\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nimport {\n clientXY,\n dimensions,\n numberCouple,\n xy,\n type NumberCouple,\n type ClientXY,\n type XY,\n signedDimensions,\n type Direction,\n} from \"@/spatial/base\";\n\nexport { clientXY, xy, type ClientXY as Client, type XY };\n\n/** A crude representation of a {@link XY} coordinate as a zod schema. */\nexport const crudeZ = z.union([\n z.number(),\n xy,\n numberCouple,\n dimensions,\n signedDimensions,\n clientXY,\n]);\n\n/** A crude representation of a {@link XY} coordinate. */\nexport type Crude = z.infer<typeof crudeZ>;\n\n/**\n * @constructs XY\n * @param x - A crude representation of the XY coordinate as a number, number couple,\n * dimensions, signed dimensions, or mouse event. If it's a mouse event, the clientX and\n * clientY coordinates are preferred over the x and y coordinates.\n * @param y - If x is a number, the y coordinate. If x is a number and this argument is\n * not given, the y coordinate is assumed to be the same as the x coordinate.\n */\nexport const construct = (x: Crude | Direction, y?: number): XY => {\n if (typeof x === \"string\") {\n if (y === undefined) throw new Error(\"The y coordinate must be given.\");\n if (x === \"x\") return { x: y, y: 0 };\n return { x: 0, y };\n }\n // The order in which we execute these checks is very important.\n if (typeof x === \"number\") return { x, y: y ?? x };\n if (Array.isArray(x)) return { x: x[0], y: x[1] };\n if (\"signedWidth\" in x) return { x: x.signedWidth, y: x.signedHeight };\n if (\"clientX\" in x) return { x: x.clientX, y: x.clientY };\n if (\"width\" in x) return { x: x.width, y: x.height };\n return { x: x.x, y: x.y };\n};\n\n/** An x and y coordinate of zero */\nexport const ZERO = { x: 0, y: 0 };\n\n/** An x and y coordinate of one */\nexport const ONE = { x: 1, y: 1 };\n\n/** An x and y coordinate of infinity */\nexport const INFINITY = { x: Infinity, y: Infinity };\n\n/** An x and y coordinate of NaN */\nexport const NAN = { x: NaN, y: NaN };\n\n/** @returns true if the two XY coordinates are semantically equal. */\nexport const equals = (a: Crude, b: Crude, threshold: number = 0): boolean => {\n const a_ = construct(a);\n const b_ = construct(b);\n if (threshold === 0) return a_.x === b_.x && a_.y === b_.y;\n return Math.abs(a_.x - b_.x) <= threshold && Math.abs(a_.y - b_.y) <= threshold;\n};\n\n/** Is zero is true if the XY coordinate has a semantic x and y value of zero. */\nexport const isZero = (c: Crude): boolean => equals(c, ZERO);\n\n/**\n * @returns the given coordinate scaled by the given factors. If only one factor is given,\n * the y factor is assumed to be the same as the x factor.\n */\nexport const scale = (c: Crude, x: number, y: number = x): XY => {\n const p = construct(c);\n return { x: p.x * x, y: p.y * y };\n};\n\n/** @returns the given coordinate translated in the X direction by the given amount. */\nexport const translateX = (c: Crude, x: number): XY => {\n const p = construct(c);\n return { x: p.x + x, y: p.y };\n};\n\n/** @returns the given coordinate translated in the Y direction by the given amount. */\nexport const translateY = (c: Crude, y: number): XY => {\n const p = construct(c);\n return { x: p.x, y: p.y + y };\n};\n\ninterface Translate {\n /** @returns the sum of the given coordinates. */\n (a: Crude, b: Crude, ...cb: Crude[]): XY;\n /** @returns the coordinates translated in the given direction by the given value. */\n (a: Crude, direction: Direction, value: number): XY;\n}\n\nexport const translate: Translate = (a, b, v, ...cb): XY => {\n if (typeof b === \"string\" && typeof v === \"number\") {\n if (b === \"x\") return translateX(a, v);\n return translateY(a, v);\n }\n return [a, b, v ?? ZERO, ...cb].reduce((p: XY, c) => {\n const xy = construct(c as Crude);\n return { x: p.x + xy.x, y: p.y + xy.y };\n }, ZERO);\n};\n\n/**\n * @returns the given coordinate the given direction set to the given value.\n * @example set({ x: 1, y: 2 }, \"x\", 3) // { x: 3, y: 2 }\n */\nexport const set = (c: Crude, direction: Direction, value: number): XY => {\n const xy = construct(c);\n if (direction === \"x\") return { x: value, y: xy.y };\n return { x: xy.x, y: value };\n};\n\n/** @returns the magnitude of the distance between the two given coordinates. */\nexport const distance = (ca: Crude, cb: Crude): number => {\n const a = construct(ca);\n const b = construct(cb);\n return Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2);\n};\n\n/** @returns the magnitude of the x distance between the two given coordinates. */\nexport const xDistance = (ca: Crude, cb: Crude): number => {\n const a = construct(ca);\n const b = construct(cb);\n return Math.abs(a.x - b.x);\n};\n\n/** @returns the magnitude of the y distance between the two given coordinates. */\nexport const yDistance = (ca: Crude, cb: Crude): number => {\n const a = construct(ca);\n const b = construct(cb);\n return Math.abs(a.y - b.y);\n};\n\n/**\n * @returns the translation that would need to be applied to move the first coordinate\n * to the second coordinate.\n */\nexport const translation = (ca: Crude, cb: Crude): XY => {\n const a = construct(ca);\n const b = construct(cb);\n return { x: b.x - a.x, y: b.y - a.y };\n};\n\n/** @returns true if both the x and y coordinates of the given coordinate are NaN. */\nexport const isNan = (a: Crude): boolean => {\n const xy = construct(a);\n return Number.isNaN(xy.x) || Number.isNaN(xy.y);\n};\n\n/** @returns true if both the x and y coordinates of the given coordinate are finite. */\nexport const isFinite = (a: Crude): boolean => {\n const xy = construct(a);\n return Number.isFinite(xy.x) && Number.isFinite(xy.y);\n};\n\n/** @returns the coordinate represented as a couple of the form [x, y]. */\nexport const couple = (a: Crude): NumberCouple => {\n const xy = construct(a);\n return [xy.x, xy.y];\n};\n\n/** @returns the coordinate represented as css properties in the form { left, top }. */\nexport const css = (a: Crude): { left: number; top: number } => {\n const xy = construct(a);\n return { left: xy.x, top: xy.y };\n};\n\nexport const truncate = (a: Crude, precision: number = 0): XY => {\n const xy = construct(a);\n return { x: Number(xy.x.toFixed(precision)), y: Number(xy.y.toFixed(precision)) };\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { unknown, z } from \"zod\";\n\nimport type * as bounds from \"@/spatial/bounds/bounds\";\nimport type * as dimensions from \"@/spatial/dimensions/dimensions\";\nimport * as direction from \"@/spatial/direction/direction\";\nimport * as location from \"@/spatial/location/location\";\nimport * as xy from \"@/spatial/xy/xy\";\n\nconst cssPos = z.union([z.number(), z.string()]);\n\nconst cssBox = z.object({\n top: cssPos,\n left: cssPos,\n width: cssPos,\n height: cssPos,\n});\nconst domRect = z.object({\n left: z.number(),\n top: z.number(),\n right: z.number(),\n bottom: z.number(),\n});\nexport const box = z.object({\n one: xy.xy,\n two: xy.xy,\n root: location.corner,\n});\n\nexport type Box = z.infer<typeof box>;\nexport type CSS = z.infer<typeof cssBox>;\nexport type DOMRect = z.infer<typeof domRect>;\n\nexport type Crude = DOMRect | Box | { getBoundingClientRect: () => DOMRect };\n\n/** A box centered at (0,0) with a width and height of 0. */\nexport const ZERO = { one: xy.ZERO, two: xy.ZERO, root: location.TOP_LEFT };\n\n/**\n * A box centered at (0,0) with a width and height of 1, and rooted in the\n * bottom left. Note that pixel space is typically rooted in the top left.\n */\nexport const DECIMAL = { one: xy.ZERO, two: xy.ONE, root: location.BOTTOM_LEFT };\n\nexport const copy = (b: Box, root?: location.CornerXY): Box => ({\n one: b.one,\n two: b.two,\n root: root ?? b.root,\n});\n\n/**\n * Box represents a general box in 2D space. It typically represents a bounding box\n * for a DOM element, but can also represent a box in clip space or decimal space.\n *\n * It'simportant to note that the behavior of a Box varies depending on its coordinate\n * system.Make sure you're aware of which coordinate system you're using.\n *\n * Many of the properties and methods on a Box access the same semantic value. The\n * different accessors are there for ease of use and semantics.\n */\nexport const construct = (\n first: number | DOMRect | xy.XY | Box | { getBoundingClientRect: () => DOMRect },\n second?: number | xy.XY | dimensions.Dimensions | dimensions.Signed,\n width: number = 0,\n height: number = 0,\n coordinateRoot?: location.CornerXY,\n): Box => {\n const b: Box = {\n one: { ...xy.ZERO },\n two: { ...xy.ZERO },\n root: coordinateRoot ?? location.TOP_LEFT,\n };\n\n if (typeof first === \"number\") {\n if (typeof second !== \"number\")\n throw new Error(\"Box constructor called with invalid arguments\");\n b.one = { x: first, y: second };\n b.two = { x: b.one.x + width, y: b.one.y + height };\n return b;\n }\n\n if (\"one\" in first && \"two\" in first && \"root\" in first)\n return { ...first, root: coordinateRoot ?? first.root };\n\n if (\"getBoundingClientRect\" in first) first = first.getBoundingClientRect();\n if (\"left\" in first) {\n b.one = { x: first.left, y: first.top };\n b.two = { x: first.right, y: first.bottom };\n return b;\n }\n\n b.one = first;\n if (second == null) b.two = { x: b.one.x + width, y: b.one.y + height };\n else if (typeof second === \"number\")\n b.two = { x: b.one.x + second, y: b.one.y + width };\n else if (\"width\" in second)\n b.two = {\n x: b.one.x + second.width,\n y: b.one.y + second.height,\n };\n else if (\"signedWidth\" in second)\n b.two = {\n x: b.one.x + second.signedWidth,\n y: b.one.y + second.signedHeight,\n };\n else b.two = second;\n return b;\n};\n\nexport interface Resize {\n /** \n * Sets the dimensions of the box to the given dimensions.\n * @example resize(b, { width: 10, height: 10 }) // Sets the box to a 10x10 box.\n */\n (b: Crude, dims: dimensions.Dimensions | dimensions.Signed): Box;\n /** \n * Sets the dimension along the given direction to the given amount. \n * @example resize(b, \"x\", 10) // Sets the width of the box to 10.\n * @example resize(b, \"y\", 10) // Sets the height of the box to 10.\n */\n (b: Crude, direction: direction.Direction, amount: number): Box;\n}\n\nexport const resize: Resize = (\n b: Crude, \n dims: dimensions.Dimensions | dimensions.Signed | direction.Direction, \n amount?: number,\n): Box => {\n const b_ = construct(b);\n if (typeof dims === \"string\") {\n if (amount == null) throw new Error(\"Invalid arguments for resize\");\n const dir = direction.construct(dims);\n return construct(\n b_.one,\n undefined,\n dir === \"x\" ? amount : width(b_),\n dir === \"y\" ? amount : height(b_),\n b_.root,\n );\n }\n return construct(b_.one, dims, undefined, undefined, b_.root);\n}\n\n/**\n * Checks if a box contains a point or another box.\n *\n * @param value - The point or box to check.\n * @returns true if the box inclusively contains the point or box and false otherwise.\n */\nexport const contains = (b: Crude, value: Box | xy.XY): boolean => {\n const b_ = construct(b);\n if (\"one\" in value)\n return (\n left(value) >= left(b_) &&\n right(value) <= right(b_) &&\n top(value) >= top(b_) &&\n bottom(value) <= bottom(b_)\n );\n return (\n value.x >= left(b_) &&\n value.x <= right(b_) &&\n value.y >= top(b_) &&\n value.y <= bottom(b_)\n );\n};\n\n/**\n * @returns true if the given box is semantically equal to this box and false otherwise.\n */\nexport const equals = (a: Box, b: Box): boolean =>\n xy.equals(a.one, b.one) &&\n xy.equals(a.two, b.two) &&\n location.xyEquals(a.root, b.root);\n\n/**\n * @returns the dimensions of the box. Note that these dimensions are guaranteed to\n * be positive. To get the signed dimensions, use the `signedDims` property.\n */\nexport const dims = (b: Box): dimensions.Dimensions => ({\n width: width(b),\n height: height(b),\n});\n\n/**\n * @returns the dimensions of the box. Note that these dimensions may be negative.\n * To get the unsigned dimensions, use the `dims` property.\n */\nexport const signedDims = (b: Box): dimensions.Signed => ({\n signedWidth: signedWidth(b),\n signedHeight: signedHeight(b),\n});\n\n/**\n * @returns the css representation of the box.\n */\nexport const css = (b: Box): CSS => ({\n top: top(b),\n left: left(b),\n width: width(b),\n height: height(b),\n});\n\nexport const dim = (\n b: Crude,\n dir: direction.Crude,\n signed: boolean = false,\n): number => {\n const dim: number =\n direction.construct(dir) === \"y\" ? signedHeight(b) : signedWidth(b);\n return signed ? dim : Math.abs(dim);\n};\n\n/** @returns the pont corresponding to the given corner of the box. */\nexport const xyLoc = (b: Crude, l: location.XY): xy.XY => {\n const b_ = construct(b);\n return {\n x: l.x === \"center\" ? center(b_).x : loc(b_, l.x),\n y: l.y === \"center\" ? center(b_).y : loc(b_, l.y),\n };\n};\n\n/**\n * @returns a one dimensional coordinate corresponding to the location of the given\n * side of the box i.e. the x coordinate of the left side, the y coordinate of the\n * top side, etc.\n */\nexport const loc = (b: Crude, loc: location.Location): number => {\n const b_ = construct(b);\n const f = location.xyCouple(b_.root).includes(loc) ? Math.min : Math.max;\n return location.X_LOCATIONS.includes(loc as location.X)\n ? f(b_.one.x, b_.two.x)\n : f(b_.one.y, b_.two.y);\n};\n\nexport const locPoint = (b: Box, loc_: location.Location): xy.XY => {\n const l = loc(b, loc_);\n if (location.X_LOCATIONS.includes(loc_ as location.X))\n return { x: l, y: center(b).y };\n return { x: center(b).x, y: l };\n};\n\nexport const isZero = (b: Box): boolean => {\n return b.one.x === b.two.x && b.one.y === b.two.y;\n};\n\nexport const width = (b: Crude): number => dim(b, \"x\");\n\nexport const height = (b: Crude): number => dim(b, \"y\");\n\nexport const signedWidth = (b: Crude): number => {\n const b_ = construct(b);\n return b_.two.x - b_.one.x;\n};\n\nexport const signedHeight = (b: Crude): number => {\n const b_ = construct(b);\n return b_.two.y - b_.one.y;\n};\n\nexport const topLeft = (b: Crude): xy.XY => xyLoc(b, location.TOP_LEFT);\n\nexport const topRight = (b: Crude): xy.XY => xyLoc(b, location.TOP_RIGHT);\n\nexport const bottomLeft = (b: Crude): xy.XY => xyLoc(b, location.BOTTOM_LEFT);\n\nexport const bottomRight = (b: Crude): xy.XY => xyLoc(b, location.BOTTOM_RIGHT);\n\nexport const right = (b: Crude): number => loc(b, \"right\");\n\nexport const bottom = (b: Crude): number => loc(b, \"bottom\");\n\nexport const left = (b: Crude): number => loc(b, \"left\");\n\nexport const top = (b: Crude): number => loc(b, \"top\");\n\nexport const center = (b: Crude): xy.XY =>\n xy.translate(topLeft(b), {\n x: signedWidth(b) / 2,\n y: signedHeight(b) / 2,\n });\n\nexport const x = (b: Crude): number => {\n const b_ = construct(b);\n return b_.root.x === \"left\" ? left(b_) : right(b_);\n};\n\nexport const y = (b: Crude): number => {\n const b_ = construct(b);\n return b_.root.y === \"top\" ? top(b_) : bottom(b_);\n};\n\nexport const root = (b: Crude): xy.XY => ({ x: x(b), y: y(b) });\n\nexport const xBounds = (b: Crude): bounds.Bounds => {\n const b_ = construct(b);\n return { lower: b_.one.x, upper: b_.two.x };\n};\n\nexport const yBounds = (b: Crude): bounds.Bounds => {\n const b_ = construct(b);\n return { lower: b_.one.y, upper: b_.two.y };\n};\n\nexport const reRoot = (b: Box, corner: location.CornerXY): Box => copy(b, corner);\n\n/**\n * Reposition a box so that it is visible within a given bound.\n *\n * @param target The box to reposition - Only works if the root is topLeft\n * @param bound The box to reposition within - Only works if the root is topLeft\n *\n * @returns the repsoitioned box and a boolean indicating if the box was repositioned\n * or not.\n */\nexport const positionSoVisible = (target_: Crude, bound_: Crude): [Box, boolean] => {\n const target = construct(target_);\n const bound = construct(bound_);\n if (contains(bound, target)) return [target, false];\n let nextPos: xy.XY;\n if (right(target) > width(target))\n nextPos = xy.construct({ x: x(target) - width(target), y: y(target) });\n else nextPos = xy.construct({ x: x(target), y: y(target) - height(target) });\n return [construct(nextPos, dims(target)), true];\n};\n\n/**\n * Reposition a box so that it is centered within a given bound.\n *\n * @param target The box to reposition - Only works if the root is topLeft\n * @param bound The box to reposition within - Only works if the root is topLeft\n * @returns the repsoitioned box\n */\nexport const positionInCenter = (target_: Crude, bound_: Crude): Box => {\n const target = construct(target_);\n const bound = construct(bound_);\n const x_ = x(bound) + (width(bound) - width(target)) / 2;\n const y_ = y(bound) + (height(bound) - height(target)) / 2;\n return construct({ x: x_, y: y_ }, dims(target));\n};\n\nexport const isBox = (value: unknown): value is Box => {\n if (typeof value !== \"object\" || value == null) return false;\n return \"one\" in value && \"two\" in value && \"root\" in value;\n};\n\nexport const aspect = (b: Box): number => width(b) / height(b);\n\ninterface Translate {\n /** @returns the box translated by the given coordinates. */\n (b: Crude, t: xy.Crude): Box;\n /** @returns the box translated in the given direction by the given amount. */\n (b: Crude, direction: direction.Direction, amount: number): Box;\n}\n\nexport const translate = (b: Crude, t: xy.XY | direction.Direction, amount?: number): Box => {\n if (typeof t === \"string\") {\n if (amount == null) throw new Error(`Undefined amount passed into box.translate`);\n const dir = direction.construct(t);\n t = xy.construct(dir, amount);\n }\n const b_ = construct(b);\n return construct(\n xy.translate(b_.one, t),\n xy.translate(b_.two, t),\n undefined,\n undefined,\n b_.root,\n );\n};\n\nexport const intersect = (a: Box, b: Box): Box => {\n const x = Math.max(left(a), left(b));\n const y = Math.max(top(a), top(b));\n const x2 = Math.min(right(a), right(b));\n const y2 = Math.min(bottom(a), bottom(b));\n return construct({ x, y }, { x: x2, y: y2 }, undefined, undefined, a.root);\n};\n\nexport const area = (b: Box): number => width(b) * height(b);\n\nexport const truncate = (b: Box, precision: number = 0): Box => {\n const b_ = construct(b);\n return construct(\n xy.truncate(b_.one, precision),\n xy.truncate(b_.two, precision),\n undefined,\n undefined,\n b_.root,\n );\n};\n\nexport const constructWithAlternateRoot = (\n x: number,\n y: number,\n width: number,\n height: number,\n currRoot: location.XY,\n newRoot: location.CornerXY,\n): Box => {\n const first = { x, y };\n const second = { x: x + width, y: y + height };\n if (currRoot.x !== newRoot.x) {\n if (currRoot.x === \"center\") {\n first.x -= width / 2;\n second.x -= width / 2;\n } else {\n first.x -= width;\n second.x -= width;\n }\n }\n if (currRoot.y !== newRoot.y) {\n if (currRoot.y === \"center\") {\n first.y -= height / 2;\n second.y -= height / 2;\n } else {\n first.y -= height;\n second.y -= height;\n }\n }\n return construct(first, second, undefined, undefined, newRoot);\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nimport { dimensions, xy, type Dimensions, numberCouple } from \"@/spatial/base\";\n\nexport { dimensions, type Dimensions };\n\nexport const signed = z.object({ signedWidth: z.number(), signedHeight: z.number() });\nexport const crude = z.union([dimensions, signed, xy, numberCouple]);\nexport type Crude = z.infer<typeof crude>;\n\nexport const ZERO = { width: 0, height: 0 };\nexport const DECIMAL = { width: 1, height: 1 };\n\nexport const construct = (width: number | Crude, height?: number): Dimensions => {\n if (typeof width === \"number\") return { width, height: height ?? width };\n if (Array.isArray(width)) return { width: width[0], height: width[1] };\n if (\"x\" in width) return { width: width.x, height: width.y };\n if (\"signedWidth\" in width)\n return { width: width.signedWidth, height: width.signedHeight };\n return { ...width };\n};\n\nexport type Signed = z.infer<typeof signed>;\n\nexport const equals = (ca: Crude, cb?: Crude | null): boolean => {\n if (cb == null) return false;\n const a = construct(ca);\n const b = construct(cb);\n return a.width === b.width && a.height === b.height;\n};\n\nexport const swap = (ca: Crude): Dimensions => {\n const a = construct(ca);\n return { width: a.height, height: a.width };\n};\n\nexport const svgViewBox = (ca: Crude): string => {\n const a = construct(ca);\n return `0 0 ${a.width} ${a.height}`;\n};\n\nexport const couple = (ca: Crude): [number, number] => {\n const a = construct(ca);\n return [a.width, a.height];\n};\n\nexport const max = (crude: Crude[]): Dimensions => ({\n width: Math.max(...crude.map((c) => construct(c).width)),\n height: Math.max(...crude.map((c) => construct(c).height)),\n});\n\nexport const min = (crude: Crude[]): Dimensions => ({\n width: Math.min(...crude.map((c) => construct(c).width)),\n height: Math.min(...crude.map((c) => construct(c).height)),\n});\n\nexport const scale = (ca: Crude, factor: number): Dimensions => {\n const a = construct(ca);\n return { width: a.width * factor, height: a.height * factor };\n}","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nexport const clamp = (value: number, min?: number, max?: number): number => {\n if (min != null) value = Math.max(value, min);\n if (max != null) value = Math.min(value, max);\n return value;\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nimport { clamp } from \"@/clamp\";\nimport * as bounds from \"@/spatial/bounds/bounds\";\nimport { type Box, isBox } from \"@/spatial/box/box\";\nimport * as box from \"@/spatial/box/box\";\nimport type * as dims from \"@/spatial/dimensions/dimensions\";\nimport * as location from \"@/spatial/location/location\";\nimport * as xy from \"@/spatial/xy/xy\";\n\nexport const crudeXYTransform = z.object({ offset: xy.crudeZ, scale: xy.crudeZ });\n\nexport type XYTransformT = z.infer<typeof crudeXYTransform>;\n\nexport type BoundVariant = \"domain\" | \"range\";\n\ntype ValueType = \"position\" | \"dimension\";\n\ntype Operation = (\n currScale: bounds.Bounds | null,\n type: ValueType,\n number: number,\n reverse: boolean,\n) => OperationReturn;\n\ntype OperationReturn = [bounds.Bounds | null, number];\n\ninterface TypedOperation extends Operation {\n type: \"translate\" | \"magnify\" | \"scale\" | \"invert\" | \"clamp\" | \"re-bound\";\n}\n\nconst curriedTranslate =\n (translate: number): Operation =>\n (currScale, type, v, reverse) => {\n if (type === \"dimension\") return [currScale, v];\n return [currScale, reverse ? v - translate : v + translate];\n };\n\nconst curriedMagnify =\n (magnify: number): Operation =>\n (currScale, _type, v, reverse) => [currScale, reverse ? v / magnify : v * magnify];\n\nconst curriedScale =\n (bound: bounds.Bounds): Operation =>\n (currScale, type, v) => {\n if (currScale === null) return [bound, v];\n const { lower: prevLower, upper: prevUpper } = currScale;\n const { lower: nextLower, upper: nextUpper } = bound;\n const prevRange = prevUpper - prevLower;\n const nextRange = nextUpper - nextLower;\n if (type === \"dimension\") return [bound, v * (nextRange / prevRange)];\n const nextV = (v - prevLower) * (nextRange / prevRange) + nextLower;\n return [bound, nextV];\n };\n\nconst curriedReBound =\n (bound: bounds.Bounds): Operation =>\n (currScale, type, v) => [bound, v];\n\nconst curriedInvert = (): Operation => (currScale, type, v) => {\n if (currScale === null) throw new Error(\"cannot invert without bounds\");\n if (type === \"dimension\") return [currScale, v];\n const { lower, upper } = currScale;\n return [currScale, upper - (v - lower)];\n};\n\nconst curriedClamp =\n (bound: bounds.Bounds): Operation =>\n (currScale, _, v) => {\n const { lower, upper } = bound;\n v = clamp(v, lower, upper);\n return [currScale, v];\n };\n\nexport class Scale {\n ops: TypedOperation[] = [];\n currBounds: bounds.Bounds | null = null;\n currType: ValueType | null = null;\n private reversed = false;\n\n constructor() {\n this.ops = [];\n }\n\n static translate(value: number): Scale {\n return new Scale().translate(value);\n }\n\n static magnify(value: number): Scale {\n return new Scale().magnify(value);\n }\n\n static scale(lowerOrBound: number | bounds.Bounds, upper?: number): Scale {\n return new Scale().scale(lowerOrBound, upper);\n }\n\n translate(value: number): Scale {\n const next = this.new();\n const f = curriedTranslate(value) as TypedOperation;\n f.type = \"translate\";\n next.ops.push(f);\n return next;\n }\n\n magnify(value: number): Scale {\n const next = this.new();\n const f = curriedMagnify(value) as TypedOperation;\n f.type = \"magnify\";\n next.ops.push(f);\n return next;\n }\n\n scale(lowerOrBound: number | bounds.Bounds, upper?: number): Scale {\n const b = bounds.construct(lowerOrBound, upper);\n const next = this.new();\n const f = curriedScale(b) as TypedOperation;\n f.type = \"scale\";\n next.ops.push(f);\n return next;\n }\n\n clamp(lowerOrBound: number | bounds.Bounds, upper?: number): Scale {\n const b = bounds.construct(lowerOrBound, upper);\n const next = this.new();\n const f = curriedClamp(b) as TypedOperation;\n f.type = \"clamp\";\n next.ops.push(f);\n return next;\n }\n\n reBound(lowerOrBound: number | bounds.Bounds, upper?: number): Scale {\n const b = bounds.construct(lowerOrBound, upper);\n const next = this.new();\n const f = curriedReBound(b) as TypedOperation;\n f.type = \"re-bound\";\n next.ops.push(f);\n return next;\n }\n\n invert(): Scale {\n const f = curriedInvert() as TypedOperation;\n f.type = \"invert\";\n const next = this.new();\n next.ops.push(f);\n return next;\n }\n\n pos(v: number): number {\n return this.exec(\"position\", v);\n }\n\n dim(v: number): number {\n return this.exec(\"dimension\", v);\n }\n\n private new(): Scale {\n const scale = new Scale();\n scale.ops = this.ops.slice();\n scale.reversed = this.reversed;\n return scale;\n }\n\n private exec(vt: ValueType, v: number): number {\n this.currBounds = null;\n return this.ops.reduce<OperationReturn>(\n ([b, v]: OperationReturn, op: Operation): OperationReturn =>\n op(b, vt, v, this.reversed),\n [null, v],\n )[1];\n }\n\n reverse(): Scale {\n const scale = this.new();\n scale.ops.reverse();\n // Switch the order of the operations to place scale operation 'BEFORE' the subsequent\n // non - scale operations for example, if we have a reversed [scale A, scale B,\n // translate A, magnify, translate B, scale C] we want to reverse it to [scale C,\n // scale B, translate B, magnify, translate A, scale A]\n const swaps: Array<[number, number]> = [];\n scale.ops.forEach((op, i) => {\n if (op.type === \"scale\" || swaps.some(([low, high]) => i >= low && i <= high))\n return;\n const nextScale = scale.ops.findIndex((op, j) => op.type === \"scale\" && j > i);\n if (nextScale === -1) return;\n swaps.push([i, nextScale]);\n });\n swaps.forEach(([low, high]) => {\n const s = scale.ops.slice(low, high);\n s.unshift(scale.ops[high]);\n scale.ops.splice(low, high - low + 1, ...s);\n });\n scale.reversed = !scale.reversed;\n return scale;\n }\n\n static readonly IDENTITY = new Scale();\n}\n\nexport const xyScaleToTransform = (scale: XY): XYTransformT => ({\n scale: {\n x: scale.x.dim(1),\n y: scale.y.dim(1),\n },\n offset: {\n x: scale.x.pos(0),\n y: scale.y.pos(0),\n },\n});\n\nexport class XY {\n x: Scale;\n y: Scale;\n currRoot: location.CornerXY | null;\n\n constructor(\n x: Scale = new Scale(),\n y: Scale = new Scale(),\n root: location.CornerXY | null = null,\n ) {\n this.x = x;\n this.y = y;\n this.currRoot = root;\n }\n\n static translate(xy: number | xy.XY, y?: number): XY {\n return new XY().translate(xy, y);\n }\n\n static translateX(x: number): XY {\n return new XY().translateX(x);\n }\n\n static translateY(y: number): XY {\n return new XY().translateY(y);\n }\n\n static clamp(box: Box): XY {\n return new XY().clamp(box);\n }\n\n static magnify(xy: xy.XY): XY {\n return new XY().magnify(xy);\n }\n\n static scale(box: dims.Dimensions | Box): XY {\n return new XY().scale(box);\n }\n\n static reBound(box: Box): XY {\n return new XY().reBound(box);\n }\n\n translate(cp: number | xy.Crude, y?: number): XY {\n const _xy = xy.construct(cp, y);\n const next = this.copy();\n next.x = this.x.translate(_xy.x);\n next.y = this.y.translate(_xy.y);\n return next;\n }\n\n translateX(x: number): XY {\n const next = this.copy();\n next.x = this.x.translate(x);\n return next;\n }\n\n translateY(y: number): XY {\n const next = this.copy();\n next.y = this.y.translate(y);\n return next;\n }\n\n magnify(xy: xy.XY): XY {\n const next = this.copy();\n next.x = this.x.magnify(xy.x);\n next.y = this.y.magnify(xy.y);\n return next;\n }\n\n scale(b: Box | dims.Dimensions): XY {\n const next = this.copy();\n if (isBox(b)) {\n const prevRoot = this.currRoot;\n next.currRoot = b.root;\n if (prevRoot != null && !location.xyEquals(prevRoot, b.root)) {\n if (prevRoot.x !== b.root.x) next.x = next.x.invert();\n if (prevRoot.y !== b.root.y) next.y = next.y.invert();\n }\n next.x = next.x.scale(box.xBounds(b));\n next.y = next.y.scale(box.yBounds(b));\n return next;\n }\n next.x = next.x.scale(b.width);\n next.y = next.y.scale(b.height);\n return next;\n }\n\n reBound(b: Box): XY {\n const next = this.copy();\n next.x = this.x.reBound(box.xBounds(b));\n next.y = this.y.reBound(box.yBounds(b));\n return next;\n }\n\n clamp(b: Box): XY {\n const next = this.copy();\n next.x = this.x.clamp(box.xBounds(b));\n next.y = this.y.clamp(box.yBounds(b));\n return next;\n }\n\n copy(): XY {\n const n = new XY();\n n.currRoot = this.currRoot;\n n.x = this.x;\n n.y = this.y;\n return n;\n }\n\n reverse(): XY {\n const next = this.copy();\n next.x = this.x.reverse();\n next.y = this.y.reverse();\n return next;\n }\n\n pos(xy: xy.XY): xy.XY {\n return { x: this.x.pos(xy.x), y: this.y.pos(xy.y) };\n }\n\n box(b: Box): Box {\n return box.construct(\n this.pos(b.one),\n this.pos(b.two),\n 0,\n 0,\n this.currRoot ?? b.root,\n );\n }\n\n static readonly IDENTITY = new XY();\n}\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Alignment, type XLocation, type YLocation } from \"@/spatial/base\";\nimport { box } from \"@/spatial/box\";\nimport { direction } from \"@/spatial/direction\";\nimport { location } from \"@/spatial/location\";\nimport { xy } from \"@/spatial/xy\";\n\nexport const posititonSoVisible = (target: HTMLElement, p: xy.XY): [xy.XY, boolean] => {\n const { width, height } = target.getBoundingClientRect();\n const { innerWidth, innerHeight } = window;\n let changed = false;\n let nextXY = xy.construct(p);\n if (p.x + width > innerWidth) {\n nextXY = xy.translateX(nextXY, -width);\n changed = true;\n }\n if (p.y + height > innerHeight) {\n nextXY = xy.translateY(nextXY, -height);\n changed = true;\n }\n return [nextXY, changed];\n};\n\nexport interface DialogProps {\n container: box.Crude;\n target: box.Crude;\n dialog: box.Crude;\n alignments?: Alignment[];\n initial?: location.Outer | Partial<location.XY> | location.XY;\n prefer?: Array<location.Outer | Partial<location.XY> | location.XY>;\n disable?: Array<location.Location | Partial<location.XY>>;\n}\n\nconst parseLocationOptions = (\n initial?: location.Outer | Partial<location.XY> | location.XY,\n): Partial<location.XY> => {\n if (initial == null) return { x: undefined, y: undefined };\n const parsedXYLoc = location.xy.safeParse(initial);\n if (parsedXYLoc.success) return parsedXYLoc.data;\n const parsedLoc = location.location.safeParse(initial);\n if (parsedLoc.success) {\n const isX = direction.construct(parsedLoc.data) === \"x\";\n return isX\n ? { x: parsedLoc.data as XLocation, y: undefined }\n : { x: undefined, y: parsedLoc.data as YLocation };\n }\n return initial as Partial<location.XY>;\n};\n\nexport interface DialogReturn {\n location: location.XY;\n adjustedDialog: box.Box;\n}\n\nexport const dialog = ({\n container: containerCrude,\n target: targetCrude,\n dialog: dialogCrude,\n initial,\n prefer,\n alignments = [\"start\"],\n disable = [],\n}: DialogProps): DialogReturn => {\n const initialLocs = parseLocationOptions(initial);\n\n let options = location.XY_LOCATIONS;\n if (prefer != null) {\n const parsedPrefer = prefer.map((p) => parseLocationOptions(p));\n options = options.slice().sort((a, b) => {\n const hasPreferA = parsedPrefer.findIndex((p) => location.xyMatches(a, p));\n const hasPreferB = parsedPrefer.findIndex((p) => location.xyMatches(b, p));\n if (hasPreferA > -1 && hasPreferB > -1) return hasPreferA - hasPreferB;\n if (hasPreferA > -1) return -1;\n if (hasPreferB > -1) return 1;\n return 0;\n });\n }\n const mappedOptions = options\n .filter(\n (l) =>\n !location.xyEquals(l, location.CENTER) &&\n (initialLocs.x == null || l.x === initialLocs.x) &&\n (initialLocs.y == null || l.y === initialLocs.y) &&\n !disable.some((d) => location.xyMatches(l, d)),\n )\n .map((l) => alignments?.map((a) => [l, a]))\n .flat() as Array<[location.XY, Alignment]>;\n\n const container = box.construct(containerCrude);\n const target = box.construct(targetCrude);\n const dialog = box.construct(dialogCrude);\n\n // maximum value of a number in js\n let bestOptionArea = -Infinity;\n const res: DialogReturn = { location: location.CENTER, adjustedDialog: dialog };\n mappedOptions.forEach(([option, alignment]) => {\n const [adjustedBox, area] = evaluateOption({\n option,\n alignment,\n container,\n target,\n dialog,\n });\n if (area > bestOptionArea) {\n bestOptionArea = area;\n res.location = option;\n res.adjustedDialog = adjustedBox;\n }\n });\n\n return res;\n};\n\ninterface EvaluateOptionProps {\n option: location.XY;\n alignment: Alignment;\n container: box.Box;\n target: box.Box;\n dialog: box.Box;\n}\n\nconst evaluateOption = ({\n option,\n alignment,\n container,\n target,\n dialog,\n}: EvaluateOptionProps): [box.Box, number] => {\n const root = getRoot(option, alignment);\n const targetPoint = box.xyLoc(target, option);\n const dialogBox = box.constructWithAlternateRoot(\n targetPoint.x,\n targetPoint.y,\n box.width(dialog),\n box.height(dialog),\n root,\n location.TOP_LEFT,\n );\n const area = box.area(box.intersect(dialogBox, container));\n return [dialogBox, area];\n};\n\nconst X_ALIGNMENT_MAP: Record<Alignment, location.X | location.Center> = {\n start: \"left\",\n center: \"center\",\n end: \"right\",\n};\n\nconst Y_ALIGNMENT_MAP: Record<Alignment, location.Y | location.Center> = {\n start: \"bottom\",\n center: \"center\",\n end: \"top\",\n};\n\nexport const getRoot = (option: location.XY, alignment: Alignment): location.XY => {\n const out: location.XY = { x: \"center\", y: \"center\" };\n if (option.y !== \"center\") {\n out.y = location.swap(option.y) as location.Y;\n const swapper = option.x === \"left\" ? location.swap : (v: location.Location) => v;\n out.x = swapper(X_ALIGNMENT_MAP[alignment]) as location.X;\n } else {\n out.x = location.swap(option.x) as location.X;\n out.y = Y_ALIGNMENT_MAP[alignment];\n }\n return out;\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nimport { type Stringer } from \"@/primitive\";\nimport { addSamples } from \"@/telem/series\";\n\nexport type TZInfo = \"UTC\" | \"local\";\n\nexport type TimeStampStringFormat =\n | \"ISO\"\n | \"ISODate\"\n | \"ISOTime\"\n | \"time\"\n | \"preciseTime\"\n | \"date\"\n | \"preciseDate\"\n | \"shortDate\"\n | \"dateTime\";\n\nexport type DateComponents = [number?, number?, number?];\n\nconst remainder = <T extends TimeStamp | TimeSpan>(\n value: T,\n divisor: TimeSpan | TimeStamp,\n): T => {\n const ts = new TimeStamp(divisor);\n if (\n ![\n TimeSpan.DAY,\n TimeSpan.HOUR,\n TimeSpan.MINUTE,\n TimeSpan.SECOND,\n TimeSpan.MILLISECOND,\n TimeSpan.MICROSECOND,\n TimeSpan.NANOSECOND,\n ].some((s) => s.equals(ts))\n ) {\n throw new Error(\n \"Invalid argument for remainder. Must be an even TimeSpan or Timestamp\",\n );\n }\n const v = value.valueOf() % ts.valueOf();\n return (value instanceof TimeStamp ? new TimeStamp(v) : new TimeSpan(v)) as T;\n};\n\n/**\n * Represents a UTC timestamp. Synnax uses a nanosecond precision int64 timestamp.\n *\n * DISCLAIMER: JavaScript stores all numbers as 64-bit floating point numbers, so we expect a\n * expect a precision drop from nanoseconds to quarter microseconds when communicating\n * with the server. If this is a problem, please file an issue with the Synnax team.\n * Caveat emptor.\n *\n * @param value - The timestamp value to parse. This can be any of the following:\n *\n * 1. A number representing the number of milliseconds since the Unix epoch.\n * 2. A javascript Date object.\n * 3. An array of numbers satisfying the DateComponents type, where the first element is the\n * year, the second is the month, and the third is the day. To incraase resolution\n * when using this method, use the add method. It's important to note that this initializes\n * a timestamp at midnight UTC, regardless of the timezone specified.\n * 4. An ISO compliant date or date time string. The time zone component is ignored.\n *\n * @param tzInfo - The timezone to use when parsing the timestamp. This can be either \"UTC\" or\n * \"local\". This parameter is ignored if the value is a Date object or a DateComponents array.\n *\n * @example ts = new TimeStamp(1 * TimeSpan.HOUR) // 1 hour after the Unix epoch\n * @example ts = new TimeStamp([2021, 1, 1]) // 1/1/2021 at midnight UTC\n * @example ts = new TimeStamp([2021, 1, 1]).add(1 * TimeSpan.HOUR) // 1/1/2021 at 1am UTC\n * @example ts = new TimeStamp(\"2021-01-01T12:30:00Z\") // 1/1/2021 at 12:30pm UTC\n */\nexport class TimeStamp implements Stringer {\n private readonly value: bigint;\n readonly encodeValue: true = true;\n\n constructor(value?: CrudeTimeStamp, tzInfo: TZInfo = \"UTC\") {\n if (value == null) this.value = TimeStamp.now().valueOf();\n else if (value instanceof Date)\n this.value = BigInt(value.getTime()) * TimeStamp.MILLISECOND.valueOf();\n else if (typeof value === \"string\")\n this.value = TimeStamp.parseDateTimeString(value, tzInfo).valueOf();\n else if (Array.isArray(value)) this.value = TimeStamp.parseDate(value);\n else {\n let offset: bigint = BigInt(0);\n if (value instanceof Number) value = value.valueOf();\n if (tzInfo === \"local\") offset = TimeStamp.utcOffset.valueOf();\n if (typeof value === \"number\") {\n if (isFinite(value)) value = Math.trunc(value);\n else {\n if (isNaN(value)) value = 0;\n if (value === Infinity) value = TimeStamp.MAX;\n else value = TimeStamp.MIN;\n }\n }\n this.value = BigInt(value.valueOf()) + offset;\n }\n }\n\n private static parseDate([year = 1970, month = 1, day = 1]: DateComponents): bigint {\n const date = new Date(year, month - 1, day, 0, 0, 0, 0);\n // We truncate here to only get the date component regardless of the time zone.\n return new TimeStamp(BigInt(date.getTime()) * TimeStamp.MILLISECOND.valueOf())\n .truncate(TimeStamp.DAY)\n .valueOf();\n }\n\n encode(): string {\n return this.value.toString();\n }\n\n valueOf(): bigint {\n return this.value;\n }\n\n private static parseTimeString(time: string, tzInfo: TZInfo = \"UTC\"): bigint {\n const [hours, minutes, mbeSeconds] = time.split(\":\");\n let seconds = \"00\";\n let milliseconds: string | undefined = \"00\";\n if (mbeSeconds != null) [seconds, milliseconds] = mbeSeconds.split(\".\");\n let base = TimeStamp.hours(parseInt(hours ?? \"00\", 10))\n .add(TimeStamp.minutes(parseInt(minutes ?? \"00\", 10)))\n .add(TimeStamp.seconds(parseInt(seconds ?? \"00\", 10)))\n .add(TimeStamp.milliseconds(parseInt(milliseconds ?? \"00\", 10)));\n if (tzInfo === \"local\") base = base.add(TimeStamp.utcOffset);\n return base.valueOf();\n }\n\n private static parseDateTimeString(str: string, tzInfo: TZInfo = \"UTC\"): bigint {\n if (!str.includes(\"/\") && !str.includes(\"-\"))\n return TimeStamp.parseTimeString(str, tzInfo);\n const d = new Date(str);\n // Essential to note that this makes the date midnight in UTC! Not local!\n // As a result, we need to add the tzInfo offset back in.\n if (!str.includes(\":\")) d.setUTCHours(0, 0, 0, 0);\n return new TimeStamp(\n BigInt(d.getTime()) * TimeStamp.MILLISECOND.valueOf(),\n tzInfo,\n ).valueOf();\n }\n\n fString(format: TimeStampStringFormat = \"ISO\", tzInfo: TZInfo = \"UTC\"): string {\n switch (format) {\n case \"ISODate\":\n return this.toISOString(tzInfo).slice(0, 10);\n case \"ISOTime\":\n return this.toISOString(tzInfo).slice(11, 23);\n case \"time\":\n return this.timeString(false, tzInfo);\n case \"preciseTime\":\n return this.timeString(true, tzInfo);\n case \"date\":\n return this.dateString(tzInfo);\n case \"preciseDate\":\n return `${this.dateString(tzInfo)} ${this.timeString(true, tzInfo)}`;\n case \"dateTime\":\n return `${this.dateString(tzInfo)} ${this.timeString(false, tzInfo)}`;\n default:\n return this.toISOString(tzInfo);\n }\n }\n\n private toISOString(tzInfo: TZInfo = \"UTC\"): string {\n if (tzInfo === \"UTC\") return this.date().toISOString();\n return this.sub(TimeStamp.utcOffset).date().toISOString();\n }\n\n private timeString(milliseconds: boolean = false, tzInfo: TZInfo = \"UTC\"): string {\n const iso = this.toISOString(tzInfo);\n return milliseconds ? iso.slice(11, 23) : iso.slice(11, 19);\n }\n\n private dateString(tzInfo: TZInfo = \"UTC\"): string {\n const date = this.date();\n const month = date.toLocaleString(\"default\", { month: \"short\" });\n const day = date.toLocaleString(\"default\", { day: \"numeric\" });\n return `${month} ${day}`;\n }\n\n static get utcOffset(): TimeSpan {\n return new TimeSpan(\n BigInt(new Date().getTimezoneOffset()) * TimeStamp.MINUTE.valueOf(),\n );\n }\n\n /**\n * @returns a TimeSpan representing the amount time elapsed since\n * the other timestamp.\n * @param other - The other timestamp.\n */\n static since(other: TimeStamp): TimeSpan {\n return new TimeStamp().span(other);\n }\n\n /** @returns A JavaScript Date object representing the TimeStamp. */\n date(): Date {\n return new Date(this.milliseconds());\n }\n\n /**\n * Checks if the TimeStamp is equal to another TimeStamp.\n *\n * @param other - The other TimeStamp to compare to.\n * @returns True if the TimeStamps are equal, false otherwise.\n */\n equals(other: CrudeTimeStamp): boolean {\n return this.valueOf() === new TimeStamp(other).valueOf();\n }\n\n /**\n * Creates a TimeSpan representing the duration between the two timestamps.\n *\n * @param other - The other TimeStamp to compare to.\n * @returns A TimeSpan representing the duration between the two timestamps.\n * The span is guaranteed to be positive.\n */\n span(other: CrudeTimeStamp): TimeSpan {\n return this.range(other).span;\n }\n\n /**\n * Creates a TimeRange spanning the given TimeStamp.\n *\n * @param other - The other TimeStamp to compare to.\n * @returns A TimeRange spanning the given TimeStamp that is guaranteed to be\n * valid, regardless of the TimeStamp order.\n */\n range(other: CrudeTimeStamp): TimeRange {\n return new TimeRange(this, other).makeValid();\n }\n\n /**\n * Creates a TimeRange starting at the TimeStamp and spanning the given\n * TimeSpan.\n *\n * @param other - The TimeSpan to span.\n * @returns A TimeRange starting at the TimeStamp and spanning the given\n * TimeSpan. The TimeRange is guaranteed to be valid.\n */\n spanRange(other: CrudeTimeSpan): TimeRange {\n return this.range(this.add(other)).makeValid();\n }\n\n /**\n * Checks if the TimeStamp represents the unix epoch.\n *\n * @returns True if the TimeStamp represents the unix epoch, false otherwise.\n */\n get isZero(): boolean {\n return this.valueOf() === BigInt(0);\n }\n\n /**\n * Checks if the TimeStamp is after the given TimeStamp.\n *\n * @param other - The other TimeStamp to compare to.\n * @returns True if the TimeStamp is after the given TimeStamp, false\n * otherwise.\n */\n after(other: CrudeTimeStamp): boolean {\n return this.valueOf() > new TimeStamp(other).valueOf();\n }\n\n /**\n * Checks if the TimeStamp is after or equal to the given TimeStamp.\n *\n * @param other - The other TimeStamp to compare to.\n * @returns True if the TimeStamp is after or equal to the given TimeStamp,\n * false otherwise.\n */\n afterEq(other: CrudeTimeStamp): boolean {\n return this.valueOf() >= new TimeStamp(other).valueOf();\n }\n\n /**\n * Checks if the TimeStamp is before the given TimeStamp.\n *\n * @param other - The other TimeStamp to compare to.\n * @returns True if the TimeStamp is before the given TimeStamp, false\n * otherwise.\n */\n before(other: CrudeTimeStamp): boolean {\n return this.valueOf() < new TimeStamp(other).valueOf();\n }\n\n /**\n * Checks if TimeStamp is before or equal to the current timestamp.\n *\n * @param other - The other TimeStamp to compare to.\n * @returns True if TimeStamp is before or equal to the current timestamp,\n * false otherwise.\n */\n beforeEq(other: CrudeTimeStamp): boolean {\n return this.valueOf() <= new TimeStamp(other).valueOf();\n }\n\n /**\n * Adds a TimeSpan to the TimeStamp.\n *\n * @param span - The TimeSpan to add.\n * @returns A new TimeStamp representing the sum of the TimeStamp and\n * TimeSpan.\n */\n add(span: CrudeTimeSpan): TimeStamp {\n return new TimeStamp(this.valueOf() + BigInt(span.valueOf()));\n }\n\n /**\n * Subtracts a TimeSpan from the TimeStamp.\n *\n * @param span - The TimeSpan to subtract.\n * @returns A new TimeStamp representing the difference of the TimeStamp and\n * TimeSpan.\n */\n sub(span: CrudeTimeSpan): TimeStamp {\n return new TimeStamp(this.valueOf() - BigInt(span.valueOf()));\n }\n\n /**\n * @returns The number of milliseconds since the unix epoch.\n */\n milliseconds(): number {\n return Number(this.valueOf() / TimeStamp.MILLISECOND.valueOf());\n }\n\n toString(): string {\n return this.date().toISOString();\n }\n\n /**\n * @returns A new TimeStamp that is the remainder of the TimeStamp divided by the\n * given span. This is useful in cases where you want only part of a TimeStamp's value\n * i.e. the hours, minutes, seconds, milliseconds, microseconds, and nanoseconds but\n * not the days, years, etc.\n *\n * @param divisor - The TimeSpan to divide by. Must be an even TimeSpan or TimeStamp. Even\n * means it must be a day, hour, minute, second, millisecond, or microsecond, etc.\n *\n * @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day\n */\n remainder(divisor: TimeSpan | TimeStamp): TimeStamp {\n return remainder(this, divisor);\n }\n\n /** @returns true if the day portion TimeStamp is today, false otherwise. */\n get isToday(): boolean {\n return this.truncate(TimeSpan.DAY).equals(TimeStamp.now().truncate(TimeSpan.DAY));\n }\n\n truncate(span: TimeSpan | TimeStamp): TimeStamp {\n return this.sub(this.remainder(span));\n }\n\n /**\n * @returns A new TimeStamp representing the current time in UTC. It's important to\n * note that this TimeStamp is only accurate to the millisecond level (that's the best\n * JavaScript can do).\n */\n static now(): TimeStamp {\n return new TimeStamp(new Date());\n }\n\n static max(...timestamps: CrudeTimeStamp[]): TimeStamp {\n let max = TimeStamp.MIN;\n for (const ts of timestamps) {\n const t = new TimeStamp(ts);\n if (t.after(max)) max = t;\n }\n return max;\n }\n\n static min(...timestamps: CrudeTimeStamp[]): TimeStamp {\n let min = TimeStamp.MAX;\n for (const ts of timestamps) {\n const t = new TimeStamp(ts);\n if (t.before(min)) min = t;\n }\n return min;\n }\n\n /** @returns a new TimeStamp n nanoseconds after the unix epoch */\n static nanoseconds(value: number): TimeStamp {\n return new TimeStamp(value);\n }\n\n /* One nanosecond after the unix epoch */\n static readonly NANOSECOND = TimeStamp.nanoseconds(1);\n\n /** @returns a new TimeStamp n microseconds after the unix epoch */\n static microseconds(value: number): TimeStamp {\n return TimeStamp.nanoseconds(value * 1000);\n }\n\n /** One microsecond after the unix epoch */\n static readonly MICROSECOND = TimeStamp.microseconds(1);\n\n /** @returns a new TimeStamp n milliseconds after the unix epoch */\n static milliseconds(value: number): TimeStamp {\n return TimeStamp.microseconds(value * 1000);\n }\n\n /** One millisecond after the unix epoch */\n static readonly MILLISECOND = TimeStamp.milliseconds(1);\n\n /** @returns a new TimeStamp n seconds after the unix epoch */\n static seconds(value: number): TimeStamp {\n return TimeStamp.milliseconds(value * 1000);\n }\n\n /** One second after the unix epoch */\n static readonly SECOND = TimeStamp.seconds(1);\n\n /** @returns a new TimeStamp n minutes after the unix epoch */\n static minutes(value: number): TimeStamp {\n return TimeStamp.seconds(value * 60);\n }\n\n /** One minute after the unix epoch */\n static readonly MINUTE = TimeStamp.minutes(1);\n\n /** @returns a new TimeStamp n hours after the unix epoch */\n static hours(value: number): TimeStamp {\n return TimeStamp.minutes(value * 60);\n }\n\n /** One hour after the unix epoch */\n static readonly HOUR = TimeStamp.hours(1);\n\n /** @returns a new TimeStamp n days after the unix epoch */\n static days(value: number): TimeStamp {\n return TimeStamp.hours(value * 24);\n }\n\n /** One day after the unix epoch */\n static readonly DAY = TimeStamp.days(1);\n\n /** The maximum possible value for a timestamp */\n static readonly MAX = new TimeStamp((1n << 63n) - 1n);\n\n /** The minimum possible value for a timestamp */\n static readonly MIN = new TimeStamp(0);\n\n /** The unix epoch */\n static readonly ZERO = new TimeStamp(0);\n\n /** A zod schema for validating timestamps */\n static readonly z = z.union([\n z.object({ value: z.bigint() }).transform((v) => new TimeStamp(v.value)),\n z.string().transform((n) => new TimeStamp(BigInt(n))),\n z.instanceof(Number).transform((n) => new TimeStamp(n)),\n z.number().transform((n) => new TimeStamp(n)),\n z.instanceof(TimeStamp),\n ]);\n}\n\n/** TimeSpan represents a nanosecond precision duration. */\nexport class TimeSpan implements Stringer {\n private readonly value: bigint;\n readonly encodeValue: true = true;\n\n constructor(value: CrudeTimeSpan) {\n if (typeof value === \"number\") value = Math.trunc(value.valueOf());\n this.value = BigInt(value.valueOf());\n }\n\n encode(): string {\n return this.value.toString();\n }\n\n valueOf(): bigint {\n return this.value;\n }\n\n lessThan(other: CrudeTimeSpan): boolean {\n return this.valueOf() < new TimeSpan(other).valueOf();\n }\n\n greaterThan(other: CrudeTimeSpan): boolean {\n return this.valueOf() > new TimeSpan(other).valueOf();\n }\n\n lessThanOrEqual(other: CrudeTimeSpan): boolean {\n return this.valueOf() <= new TimeSpan(other).valueOf();\n }\n\n greaterThanOrEqual(other: CrudeTimeSpan): boolean {\n return this.valueOf() >= new TimeSpan(other).valueOf();\n }\n\n remainder(divisor: TimeSpan): TimeSpan {\n return remainder(this, divisor);\n }\n\n truncate(span: TimeSpan): TimeSpan {\n return new TimeSpan(\n BigInt(Math.trunc(Number(this.valueOf() / span.valueOf()))) * span.valueOf(),\n );\n }\n\n toString(): string {\n const totalDays = this.truncate(TimeSpan.DAY);\n const totalHours = this.truncate(TimeSpan.HOUR);\n const totalMinutes = this.truncate(TimeSpan.MINUTE);\n const totalSeconds = this.truncate(TimeSpan.SECOND);\n const totalMilliseconds = this.truncate(TimeSpan.MILLISECOND);\n const totalMicroseconds = this.truncate(TimeSpan.MICROSECOND);\n const totalNanoseconds = this.truncate(TimeSpan.NANOSECOND);\n const days = totalDays;\n const hours = totalHours.sub(totalDays);\n const minutes = totalMinutes.sub(totalHours);\n const seconds = totalSeconds.sub(totalMinutes);\n const milliseconds = totalMilliseconds.sub(totalSeconds);\n const microseconds = totalMicroseconds.sub(totalMilliseconds);\n const nanoseconds = totalNanoseconds.sub(totalMicroseconds);\n\n let str = \"\";\n if (!days.isZero) str += `${days.days}d `;\n if (!hours.isZero) str += `${hours.hours}h `;\n if (!minutes.isZero) str += `${minutes.minutes}m `;\n if (!seconds.isZero) str += `${seconds.seconds}s `;\n if (!milliseconds.isZero) str += `${milliseconds.milliseconds}ms `;\n if (!microseconds.isZero) str += `${microseconds.microseconds}µs `;\n if (!nanoseconds.isZero) str += `${nanoseconds.nanoseconds}ns`;\n return str.trim();\n }\n\n /** @returns the decimal number of days in the timespan */\n get days(): number {\n return Number(this.valueOf() / TimeSpan.DAY.valueOf());\n }\n\n /** @returns the decimal number of hours in the timespan */\n get hours(): number {\n return Number(this.valueOf() / TimeSpan.HOUR.valueOf());\n }\n\n /** @returns the decimal number of minutes in the timespan */\n get minutes(): number {\n return Number(this.valueOf() / TimeSpan.MINUTE.valueOf());\n }\n\n /** @returns The number of seconds in the TimeSpan. */\n get seconds(): number {\n return Number(this.valueOf() / TimeSpan.SECOND.valueOf());\n }\n\n /** @returns The number of milliseconds in the TimeSpan. */\n get milliseconds(): number {\n return Number(this.valueOf() / TimeSpan.MILLISECOND.valueOf());\n }\n\n get microseconds(): number {\n return Number(this.valueOf() / TimeSpan.MICROSECOND.valueOf());\n }\n\n get nanoseconds(): number {\n return Number(this.valueOf());\n }\n\n /**\n * Checks if the TimeSpan represents a zero duration.\n *\n * @returns True if the TimeSpan represents a zero duration, false otherwise.\n */\n get isZero(): boolean {\n return this.valueOf() === BigInt(0);\n }\n\n /**\n * Checks if the TimeSpan is equal to another TimeSpan.\n *\n * @returns True if the TimeSpans are equal, false otherwise.\n */\n equals(other: CrudeTimeSpan): boolean {\n return this.valueOf() === new TimeSpan(other).valueOf();\n }\n\n /**\n * Adds a TimeSpan to the TimeSpan.\n *\n * @returns A new TimeSpan representing the sum of the two TimeSpans.\n */\n add(other: CrudeTimeSpan): TimeSpan {\n return new TimeSpan(this.valueOf() + new TimeSpan(other).valueOf());\n }\n\n /**\n * Creates a TimeSpan representing the duration between the two timestamps.\n *\n * @param other\n */\n sub(other: CrudeTimeSpan): TimeSpan {\n return new TimeSpan(this.valueOf() - new TimeSpan(other).valueOf());\n }\n\n /**\n * Creates a TimeSpan representing the given number of nanoseconds.\n *\n * @param value - The number of nanoseconds.\n * @returns A TimeSpan representing the given number of nanoseconds.\n */\n static nanoseconds(value: number = 1): TimeSpan {\n return new TimeSpan(value);\n }\n\n /** A nanosecond. */\n static readonly NANOSECOND = TimeSpan.nanoseconds(1);\n\n /**\n * Creates a TimeSpan representing the given number of microseconds.\n *\n * @param value - The number of microseconds.\n * @returns A TimeSpan representing the given number of microseconds.\n */\n static microseconds(value: number = 1): TimeSpan {\n return TimeSpan.nanoseconds(value * 1000);\n }\n\n /** A microsecond. */\n static readonly MICROSECOND = TimeSpan.microseconds(1);\n\n /**\n * Creates a TimeSpan representing the given number of milliseconds.\n *\n * @param value - The number of milliseconds.\n * @returns A TimeSpan representing the given number of milliseconds.\n */\n static milliseconds(value: number = 1): TimeSpan {\n return TimeSpan.microseconds(value * 1000);\n }\n\n /** A millisecond. */\n static readonly MILLISECOND = TimeSpan.milliseconds(1);\n\n /**\n * Creates a TimeSpan representing the given number of seconds.\n *\n * @param value - The number of seconds.\n * @returns A TimeSpan representing the given number of seconds.\n */\n static seconds(value: number = 1): TimeSpan {\n return TimeSpan.milliseconds(value * 1000);\n }\n\n /** A second. */\n static readonly SECOND = TimeSpan.seconds(1);\n\n /**\n * Creates a TimeSpan representing the given number of minutes.\n *\n * @param value - The number of minutes.\n * @returns A TimeSpan representing the given number of minutes.\n */\n static minutes(value: number): TimeSpan {\n return TimeSpan.seconds(value.valueOf() * 60);\n }\n\n /** A minute. */\n static readonly MINUTE = TimeSpan.minutes(1);\n\n /**\n * Creates a TimeSpan representing the given number of hours.\n *\n * @param value - The number of hours.\n * @returns A TimeSpan representing the given number of hours.\n */\n static hours(value: number): TimeSpan {\n return TimeSpan.minutes(value * 60);\n }\n\n /** Represents an hour. */\n static readonly HOUR = TimeSpan.hours(1);\n\n /**\n * Creates a TimeSpan representing the given number of days.\n *\n * @param value - The number of days.\n * @returns A TimeSpan representing the given number of days.\n */\n static days(value: number): TimeSpan {\n return TimeSpan.hours(value * 24);\n }\n\n /** Represents a day. */\n static readonly DAY = TimeSpan.days(1);\n\n /** The maximum possible value for a TimeSpan. */\n static readonly MAX = new TimeSpan((1n << 63n) - 1n);\n\n /** The minimum possible value for a TimeSpan. */\n static readonly MIN = new TimeSpan(0);\n\n /** The zero value for a TimeSpan. */\n static readonly ZERO = new TimeSpan(0);\n\n /** A zod schema for validating and transforming timespans */\n static readonly z = z.union([\n z.object({ value: z.bigint() }).transform((v) => new TimeSpan(v.value)),\n z.string().transform((n) => new TimeSpan(BigInt(n))),\n z.instanceof(Number).transform((n) => new TimeSpan(n)),\n z.number().transform((n) => new TimeSpan(n)),\n z.instanceof(TimeSpan),\n ]);\n}\n\n/** Rate represents a data rate in Hz. */\nexport class Rate extends Number implements Stringer {\n constructor(value: CrudeRate) {\n if (value instanceof Number) super(value.valueOf());\n else super(value);\n }\n\n /** @returns a pretty string representation of the rate in the format \"X Hz\". */\n toString(): string {\n return `${this.valueOf()} Hz`;\n }\n\n /** @returns The number of seconds in the Rate. */\n equals(other: CrudeRate): boolean {\n return this.valueOf() === new Rate(other).valueOf();\n }\n\n /**\n * Calculates the period of the Rate as a TimeSpan.\n *\n * @returns A TimeSpan representing the period of the Rate.\n */\n get period(): TimeSpan {\n return TimeSpan.seconds(1 / this.valueOf());\n }\n\n /**\n * Calculates the number of samples in the given TimeSpan at this rate.\n *\n * @param duration - The duration to calculate the sample count from.\n * @returns The number of samples in the given TimeSpan at this rate.\n */\n sampleCount(duration: CrudeTimeSpan): number {\n return new TimeSpan(duration).seconds * this.valueOf();\n }\n\n /**\n * Calculates the number of bytes in the given TimeSpan at this rate.\n *\n * @param span - The duration to calculate the byte count from.\n * @param density - The density of the data in bytes per sample.\n * @returns The number of bytes in the given TimeSpan at this rate.\n */\n byteCount(span: CrudeTimeSpan, density: CrudeDensity): number {\n return this.sampleCount(span) * new Density(density).valueOf();\n }\n\n /**\n * Calculates a TimeSpan given the number of samples at this rate.\n *\n * @param sampleCount - The number of samples in the span.\n * @returns A TimeSpan that corresponds to the given number of samples.\n */\n span(sampleCount: number): TimeSpan {\n return TimeSpan.seconds(sampleCount / this.valueOf());\n }\n\n /**\n * Calculates a TimeSpan given the number of bytes at this rate.\n *\n * @param size - The number of bytes in the span.\n * @param density - The density of the data in bytes per sample.\n * @returns A TimeSpan that corresponds to the given number of bytes.\n */\n byteSpan(size: Size, density: CrudeDensity): TimeSpan {\n return this.span(size.valueOf() / density.valueOf());\n }\n\n /**\n * Creates a Rate representing the given number of Hz.\n *\n * @param value - The number of Hz.\n * @returns A Rate representing the given number of Hz.\n */\n static hz(value: number): Rate {\n return new Rate(value);\n }\n\n /**\n * Creates a Rate representing the given number of kHz.\n *\n * @param value - The number of kHz.\n * @returns A Rate representing the given number of kHz.\n */\n static khz(value: number): Rate {\n return Rate.hz(value * 1000);\n }\n\n /** A zod schema for validating and transforming rates */\n static readonly z = z.union([\n z.number().transform((n) => new Rate(n)),\n z.instanceof(Number).transform((n) => new Rate(n)),\n z.instanceof(Rate),\n ]);\n}\n\n/** Density represents the number of bytes in a value. */\nexport class Density extends Number implements Stringer {\n /**\n * Creates a Density representing the given number of bytes per value.\n *\n * @class\n * @param value - The number of bytes per value.\n * @returns A Density representing the given number of bytes per value.\n */\n constructor(value: CrudeDensity) {\n if (value instanceof Number) super(value.valueOf());\n else super(value);\n }\n\n length(size: Size): number {\n return size.valueOf() / this.valueOf();\n }\n\n size(sampleCount: number): Size {\n return new Size(sampleCount * this.valueOf());\n }\n\n /** Unknown/Invalid Density. */\n static readonly UNKNOWN = new Density(0);\n /** 128 bits per value. */\n static readonly BIT128 = new Density(16);\n /** 64 bits per value. */\n static readonly BIT64 = new Density(8);\n /** 32 bits per value. */\n static readonly BIT32 = new Density(4);\n /** 16 bits per value. */\n static readonly BIT16 = new Density(2);\n /** 8 bits per value. */\n static readonly BIT8 = new Density(1);\n\n /** A zod schema for validating and transforming densities */\n static readonly z = z.union([\n z.number().transform((n) => new Density(n)),\n z.instanceof(Number).transform((n) => new Density(n)),\n z.instanceof(Density),\n ]);\n}\n\n/**\n * TimeRange is a range of time marked by a start and end timestamp. A TimeRange\n * is start inclusive and end exclusive.\n *\n * @property start - A TimeStamp representing the start of the range.\n * @property end - A Timestamp representing the end of the range.\n */\nexport class TimeRange implements Stringer {\n /**\n * The starting TimeStamp of the TimeRange.\n *\n * Note that this value is not guaranteed to be before or equal to the ending value.\n * To ensure that this is the case, call TimeRange.make_valid().\n *\n * In most cases, operations should treat start as inclusive.\n */\n start: TimeStamp;\n\n /**\n * The starting TimeStamp of the TimeRange.\n *\n * Note that this value is not guaranteed to be before or equal to the ending value.\n * To ensure that this is the case, call TimeRange.make_valid().\n *\n * In most cases, operations should treat end as exclusive.\n */\n end: TimeStamp;\n\n constructor(tr: CrudeTimeRange);\n\n constructor(start: CrudeTimeStamp, end: CrudeTimeStamp);\n\n /**\n * Creates a TimeRange from the given start and end TimeStamps.\n *\n * @param start - A TimeStamp representing the start of the range.\n * @param end - A TimeStamp representing the end of the range.\n */\n constructor(start: CrudeTimeStamp | CrudeTimeRange, end?: CrudeTimeStamp) {\n if (typeof start === \"object\" && \"start\" in start) {\n this.start = new TimeStamp(start.start);\n this.end = new TimeStamp(start.end);\n } else {\n this.start = new TimeStamp(start);\n this.end = new TimeStamp(end);\n }\n }\n\n /** @returns The TimeSpan occupied by the TimeRange. */\n get span(): TimeSpan {\n return new TimeSpan(this.end.valueOf() - this.start.valueOf());\n }\n\n /**\n * Checks if the timestamp is valid i.e. the start is before the end.\n *\n * @returns True if the TimeRange is valid.\n */\n get isValid(): boolean {\n return this.start.valueOf() <= this.end.valueOf();\n }\n\n /**\n * Makes sure the TimeRange is valid i.e. the start is before the end.\n *\n * @returns A TimeRange that is valid.\n */\n makeValid(): TimeRange {\n return this.isValid ? this : this.swap();\n }\n\n /**\n * Checks if the TimeRange has a zero span.\n *\n * @returns True if the TimeRange has a zero span.\n */\n get isZero(): boolean {\n return this.span.isZero;\n }\n\n /**\n * Creates a new TimeRange with the start and end swapped.\n *\n * @returns A TimeRange with the start and end swapped.\n */\n swap(): TimeRange {\n return new TimeRange(this.end, this.start);\n }\n\n /**\n * Checks if the TimeRange is equal to the given TimeRange.\n *\n * @param other - The TimeRange to compare to.\n * @returns True if the TimeRange is equal to the given TimeRange.\n */\n equals(other: TimeRange): boolean {\n return this.start.equals(other.start) && this.end.equals(other.end);\n }\n\n toString(): string {\n return `${this.start.toString()} - ${this.end.toString()}`;\n }\n\n toPrettyString(): string {\n return `${this.start.fString(\"preciseDate\")} - ${this.span.toString()}`;\n }\n\n /**\n * Checks if if the two time ranges overlap. If the two time ranges are equal, returns\n * true. If the start of one range is equal to the end of the other, returns false.\n * Just follow the rule [start, end) i.e. start is inclusive and end is exclusive.\n *\n * @param other - The other TimeRange to compare to.\n * @returns True if the two TimeRanges overlap, false otherwise.\n */\n overlapsWith(other: TimeRange): boolean {\n other = other.makeValid();\n const rng = this.makeValid();\n if (other.start.equals(rng.start)) return true;\n if (other.end.equals(this.start) || other.start.equals(this.end)) return false;\n return (\n this.contains(other.end) ||\n this.contains(other.start) ||\n other.contains(this.start) ||\n other.contains(this.end)\n );\n }\n\n contains(other: TimeRange): boolean;\n\n contains(ts: CrudeTimeStamp): boolean;\n\n contains(other: TimeRange | CrudeTimeStamp): boolean {\n if (other instanceof TimeRange)\n return this.contains(other.start) && this.contains(other.end);\n return this.start.beforeEq(other) && this.end.after(other);\n }\n\n boundBy(other: TimeRange): TimeRange {\n const next = new TimeRange(this.start, this.end);\n if (other.start.after(this.start)) next.start = other.start;\n if (other.start.after(this.end)) next.end = other.start;\n if (other.end.before(this.end)) next.end = other.end;\n if (other.end.before(this.start)) next.start = other.end;\n return next;\n }\n\n /** The maximum possible time range. */\n static readonly MAX = new TimeRange(TimeStamp.MIN, TimeStamp.MAX);\n\n /** The minimum possible time range. */\n static readonly MIN = new TimeRange(TimeStamp.MAX, TimeStamp.MIN);\n\n /** A zero time range. */\n static readonly ZERO = new TimeRange(TimeStamp.ZERO, TimeStamp.ZERO);\n\n /** A zod schema for validating and transforming time ranges */\n static readonly z = z.union([\n z\n .object({ start: TimeStamp.z, end: TimeStamp.z })\n .transform((v) => new TimeRange(v.start, v.end)),\n z.instanceof(TimeRange),\n ]);\n}\n\n/** DataType is a string that represents a data type. */\nexport class DataType extends String implements Stringer {\n constructor(value: CrudeDataType) {\n if (\n value instanceof DataType ||\n typeof value === \"string\" ||\n typeof value.valueOf() === \"string\"\n ) {\n super(value.valueOf());\n return;\n } else {\n const t = DataType.ARRAY_CONSTRUCTOR_DATA_TYPES.get(value.constructor.name);\n if (t != null) {\n super(t.valueOf());\n return;\n }\n }\n super(DataType.UNKNOWN.valueOf());\n throw new Error(`unable to find data type for ${value.toString()}`);\n }\n\n /**\n * @returns the TypedArray constructor for the DataType.\n */\n get Array(): TypedArrayConstructor {\n const v = DataType.ARRAY_CONSTRUCTORS.get(this.toString());\n if (v == null)\n throw new Error(`unable to find array constructor for ${this.valueOf()}`);\n return v;\n }\n\n equals(other: DataType): boolean {\n return this.valueOf() === other.valueOf();\n }\n\n /** @returns a string representation of the DataType. */\n toString(): string {\n return this.valueOf();\n }\n\n get isVariable(): boolean {\n return this.equals(DataType.JSON) || this.equals(DataType.STRING);\n }\n\n get isNumeric(): boolean {\n return !this.isVariable && !this.equals(DataType.UUID);\n }\n\n get isInteger(): boolean {\n return this.toString().startsWith(\"int\");\n }\n\n get isFloat(): boolean {\n return this.toString().startsWith(\"float\");\n }\n\n get density(): Density {\n const v = DataType.DENSITIES.get(this.toString());\n if (v == null) throw new Error(`unable to find density for ${this.valueOf()}`);\n return v;\n }\n\n /**\n * Checks whether the given TypedArray is of the same type as the DataType.\n *\n * @param array - The TypedArray to check.\n * @returns True if the TypedArray is of the same type as the DataType.\n */\n checkArray(array: TypedArray): boolean {\n return array.constructor === this.Array;\n }\n\n toJSON(): string {\n return this.toString();\n }\n\n get usesBigInt(): boolean {\n return DataType.BIG_INT_TYPES.some((t) => t.equals(this));\n }\n\n /** Represents an Unknown/Invalid DataType. */\n static readonly UNKNOWN = new DataType(\"unknown\");\n /** Represents a 64-bit floating point value. */\n static readonly FLOAT64 = new DataType(\"float64\");\n /** Represents a 32-bit floating point value. */\n static readonly FLOAT32 = new DataType(\"float32\");\n /** Represents a 64-bit signed integer value. */\n static readonly INT64 = new DataType(\"int64\");\n /** Represents a 32-bit signed integer value. */\n static readonly INT32 = new DataType(\"int32\");\n /** Represents a 16-bit signed integer value. */\n static readonly INT16 = new DataType(\"int16\");\n /** Represents a 8-bit signed integer value. */\n static readonly INT8 = new DataType(\"int8\");\n /** Represents a 64-bit unsigned integer value. */\n static readonly UINT64 = new DataType(\"uint64\");\n /** Represents a 32-bit unsigned integer value. */\n static readonly UINT32 = new DataType(\"uint32\");\n /** Represents a 16-bit unsigned integer value. */\n static readonly UINT16 = new DataType(\"uint16\");\n /** Represents a 8-bit unsigned integer value. */\n static readonly UINT8 = new DataType(\"uint8\");\n /** Represents a boolean value. Alias for UINT8. */\n static readonly BOOLEAN = this.UINT8;\n /** Represents a 64-bit unix epoch. */\n static readonly TIMESTAMP = new DataType(\"timestamp\");\n /** Represents a UUID data type */\n static readonly UUID = new DataType(\"uuid\");\n /** Represents a string data type. Strings have an unknown density, and are separate\n * by a newline character. */\n static readonly STRING = new DataType(\"string\");\n /** Represents a JSON data type. JSON has an unknown density, and is separated by a\n * newline character. */\n static readonly JSON = new DataType(\"json\");\n\n static readonly ARRAY_CONSTRUCTORS: Map<string, TypedArrayConstructor> = new Map<\n string,\n TypedArrayConstructor\n >([\n [DataType.UINT8.toString(), Uint8Array],\n [DataType.UINT16.toString(), Uint16Array],\n [DataType.UINT32.toString(), Uint32Array],\n [DataType.UINT64.toString(), BigUint64Array],\n [DataType.FLOAT32.toString(), Float32Array],\n [DataType.FLOAT64.toString(), Float64Array],\n [DataType.INT8.toString(), Int8Array],\n [DataType.INT16.toString(), Int16Array],\n [DataType.INT32.toString(), Int32Array],\n [DataType.INT64.toString(), BigInt64Array],\n [DataType.TIMESTAMP.toString(), BigInt64Array],\n [DataType.STRING.toString(), Uint8Array],\n [DataType.JSON.toString(), Uint8Array],\n [DataType.UUID.toString(), Uint8Array],\n ]);\n\n static readonly ARRAY_CONSTRUCTOR_DATA_TYPES: Map<string, DataType> = new Map<\n string,\n DataType\n >([\n [Uint8Array.name, DataType.UINT8],\n [Uint16Array.name, DataType.UINT16],\n [Uint32Array.name, DataType.UINT32],\n [BigUint64Array.name, DataType.UINT64],\n [Float32Array.name, DataType.FLOAT32],\n [Float64Array.name, DataType.FLOAT64],\n [Int8Array.name, DataType.INT8],\n [Int16Array.name, DataType.INT16],\n [Int32Array.name, DataType.INT32],\n [BigInt64Array.name, DataType.INT64],\n ]);\n\n static readonly DENSITIES = new Map<string, Density>([\n [DataType.UINT8.toString(), Density.BIT8],\n [DataType.UINT16.toString(), Density.BIT16],\n [DataType.UINT32.toString(), Density.BIT32],\n [DataType.UINT64.toString(), Density.BIT64],\n [DataType.FLOAT32.toString(), Density.BIT32],\n [DataType.FLOAT64.toString(), Density.BIT64],\n [DataType.INT8.toString(), Density.BIT8],\n [DataType.INT16.toString(), Density.BIT16],\n [DataType.INT32.toString(), Density.BIT32],\n [DataType.INT64.toString(), Density.BIT64],\n [DataType.TIMESTAMP.toString(), Density.BIT64],\n [DataType.STRING.toString(), Density.UNKNOWN],\n [DataType.JSON.toString(), Density.UNKNOWN],\n [DataType.UUID.toString(), Density.BIT128],\n ]);\n\n /** All the data types. */\n static readonly ALL = [\n DataType.UNKNOWN,\n DataType.FLOAT64,\n DataType.FLOAT32,\n DataType.INT64,\n DataType.INT32,\n DataType.INT16,\n DataType.INT8,\n DataType.UINT64,\n DataType.UINT32,\n DataType.UINT16,\n DataType.UINT8,\n DataType.TIMESTAMP,\n DataType.UUID,\n DataType.STRING,\n DataType.JSON,\n ];\n\n static readonly BIG_INT_TYPES = [DataType.INT64, DataType.UINT64, DataType.TIMESTAMP];\n\n /** A zod schema for a DataType. */\n static readonly z = z.union([\n z.string().transform((v) => new DataType(v)),\n z.instanceof(DataType),\n ]);\n}\n\n/**\n * The Size of an elementy in bytes.\n */\nexport class Size extends Number implements Stringer {\n constructor(value: CrudeSize) {\n super(value.valueOf());\n }\n\n /** @returns true if the Size is larger than the other size. */\n largerThan(other: CrudeSize): boolean {\n return this.valueOf() > other.valueOf();\n }\n\n /** @returns true if the Size is smaller than the other sisze. */\n smallerThan(other: CrudeSize): boolean {\n return this.valueOf() < other.valueOf();\n }\n\n add(other: CrudeSize): Size {\n return Size.bytes(this.valueOf() + other.valueOf());\n }\n\n sub(other: CrudeSize): Size {\n return Size.bytes(this.valueOf() - other.valueOf());\n }\n\n truncate(span: CrudeSize): Size {\n return new Size(Math.trunc(this.valueOf() / span.valueOf()) * span.valueOf());\n }\n\n remainder(span: CrudeSize): Size {\n return Size.bytes(this.valueOf() % span.valueOf());\n }\n\n get gigabytes(): number {\n return this.valueOf() / Size.GIGABYTE.valueOf();\n }\n\n get megabytes(): number {\n return this.valueOf() / Size.MEGABYTE.valueOf();\n }\n\n get kilobytes(): number {\n return this.valueOf() / Size.KILOBYTE.valueOf();\n }\n\n get terabytes(): number {\n return this.valueOf() / Size.TERABYTE.valueOf();\n }\n\n toString(): string {\n const totalTB = this.truncate(Size.TERABYTE);\n const totalGB = this.truncate(Size.GIGABYTE);\n const totalMB = this.truncate(Size.MEGABYTE);\n const totalKB = this.truncate(Size.KILOBYTE);\n const totalB = this.truncate(Size.BYTE);\n const tb = totalTB;\n const gb = totalGB.sub(totalTB);\n const mb = totalMB.sub(totalGB);\n const kb = totalKB.sub(totalMB);\n const bytes = totalB.sub(totalKB);\n let str = \"\";\n if (!tb.isZero) str += `${tb.terabytes}TB `;\n if (!gb.isZero) str += `${gb.gigabytes}GB `;\n if (!mb.isZero) str += `${mb.megabytes}MB `;\n if (!kb.isZero) str += `${kb.kilobytes}KB `;\n if (!bytes.isZero || str === \"\") str += `${bytes.valueOf()}B`;\n return str.trim();\n }\n\n /**\n * Creates a Size from the given number of bytes.\n *\n * @param value - The number of bytes.\n * @returns A Size representing the given number of bytes.\n */\n static bytes(value: CrudeSize = 1): Size {\n return new Size(value);\n }\n\n /** A single byte */\n static readonly BYTE = new Size(1);\n\n /**\n * Creates a Size from the given number if kilobytes.\n *\n * @param value - The number of kilobytes.\n * @returns A Size representing the given number of kilobytes.\n */\n static kilobytes(value: CrudeSize = 1): Size {\n return Size.bytes(value.valueOf() * 1e3);\n }\n\n /** A kilobyte */\n static readonly KILOBYTE = Size.kilobytes(1);\n\n /**\n * Creates a Size from the given number of megabytes.\n *\n * @param value - The number of megabytes.\n * @returns A Size representing the given number of megabytes.\n */\n static megabytes(value: CrudeSize = 1): Size {\n return Size.kilobytes(value.valueOf() * 1e3);\n }\n\n /** A megabyte */\n static readonly MEGABYTE = Size.megabytes(1);\n\n /**\n * Creates a Size from the given number of gigabytes.\n *\n * @param value - The number of gigabytes.\n * @returns A Size representing the given number of gigabytes.\n */\n static gigabytes(value: CrudeSize = 1): Size {\n return Size.megabytes(value.valueOf() * 1e3);\n }\n\n /** A gigabyte */\n static readonly GIGABYTE = Size.gigabytes(1);\n\n /**\n * Creates a Size from the given number of terabytes.\n *\n * @param value - The number of terabytes.\n * @returns A Size representing the given number of terabytes.\n */\n static terabytes(value: CrudeSize): Size {\n return Size.gigabytes(value.valueOf() * 1e3);\n }\n\n /** A terabyte. */\n static readonly TERABYTE = Size.terabytes(1);\n\n /** The zero value for Size */\n static readonly ZERO = new Size(0);\n\n /** A zod schema for a Size. */\n static readonly z = z.union([\n z.number().transform((v) => new Size(v)),\n z.instanceof(Size),\n ]);\n\n get isZero(): boolean {\n return this.valueOf() === 0;\n }\n}\n\nexport type CrudeTimeStamp =\n | bigint\n | BigInt\n | TimeStamp\n | TimeSpan\n | number\n | Date\n | string\n | DateComponents\n | Number;\nexport type TimeStampT = number;\nexport type CrudeTimeSpan = bigint | BigInt | TimeSpan | TimeStamp | number | Number;\nexport type TimeSpanT = number;\nexport type CrudeRate = Rate | number | Number;\nexport type RateT = number;\nexport type CrudeDensity = Density | number | Number;\nexport type DensityT = number;\nexport type CrudeDataType = DataType | string | TypedArray;\nexport type DataTypeT = string;\nexport type CrudeSize = Size | number | Number;\nexport type SizeT = number;\nexport interface CrudeTimeRange {\n start: CrudeTimeStamp;\n end: CrudeTimeStamp;\n}\n\nexport const typedArrayZ = z.union([\n z.instanceof(Uint8Array),\n z.instanceof(Uint16Array),\n z.instanceof(Uint32Array),\n z.instanceof(BigUint64Array),\n z.instanceof(Float32Array),\n z.instanceof(Float64Array),\n z.instanceof(Int8Array),\n z.instanceof(Int16Array),\n z.instanceof(Int32Array),\n z.instanceof(BigInt64Array),\n]);\n\nexport type TypedArray = z.infer<typeof typedArrayZ>;\n\ntype TypedArrayConstructor =\n | Uint8ArrayConstructor\n | Uint16ArrayConstructor\n | Uint32ArrayConstructor\n | BigUint64ArrayConstructor\n | Float32ArrayConstructor\n | Float64ArrayConstructor\n | Int8ArrayConstructor\n | Int16ArrayConstructor\n | Int32ArrayConstructor\n | BigInt64ArrayConstructor;\nexport type NumericTelemValue = number | bigint;\nexport type TelemValue =\n | number\n | bigint\n | string\n | boolean\n | Date\n | TimeStamp\n | TimeSpan;\n\nexport const isTelemValue = (value: unknown): value is TelemValue => {\n const ot = typeof value;\n return (\n ot === \"string\" ||\n ot === \"number\" ||\n ot === \"boolean\" ||\n ot === \"bigint\" ||\n value instanceof TimeStamp ||\n value instanceof TimeSpan ||\n value instanceof Date\n );\n};\n\nexport const convertDataType = (\n source: DataType,\n target: DataType,\n value: NumericTelemValue,\n offset: number | bigint = 0,\n): NumericTelemValue => {\n if (source.usesBigInt && !target.usesBigInt) return Number(value) - Number(offset);\n if (!source.usesBigInt && target.usesBigInt) return BigInt(value) - BigInt(offset);\n return addSamples(value, -offset);\n};\n","/* eslint-disable @typescript-eslint/no-misused-new */\n// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { nanoid } from \"nanoid/non-secure\";\nimport { type z } from \"zod\";\n\nimport { compare } from \"@/compare\";\nimport { bounds } from \"@/spatial\";\nimport { type GLBufferController, type GLBufferUsage } from \"@/telem/gl\";\nimport {\n convertDataType,\n DataType,\n type TypedArray,\n type Rate,\n Size,\n TimeRange,\n TimeStamp,\n type CrudeDataType,\n type TelemValue,\n isTelemValue,\n TimeSpan,\n type CrudeTimeStamp,\n type NumericTelemValue,\n} from \"@/telem/telem\";\n\ninterface GL {\n control: GLBufferController | null;\n buffer: WebGLBuffer | null;\n prevBuffer: number;\n bufferUsage: GLBufferUsage;\n}\n\nexport interface SeriesDigest {\n key: string;\n dataType: string;\n sampleOffset: NumericTelemValue;\n alignment: bounds.Bounds;\n timeRange?: string;\n length: number;\n capacity: number;\n}\n\ninterface BaseSeriesProps {\n dataType?: CrudeDataType;\n timeRange?: TimeRange;\n sampleOffset?: NumericTelemValue;\n glBufferUsage?: GLBufferUsage;\n alignment?: number;\n key?: string;\n}\n\nexport type CrudeSeries =\n | Series\n | ArrayBuffer\n | TypedArray\n | string[]\n | number[]\n | boolean[]\n | unknown[]\n | TimeStamp[]\n | Date[]\n | TelemValue;\n\nexport const isCrudeSeries = (value: unknown): value is CrudeSeries => {\n if (value == null) return false;\n if (Array.isArray(value)) return true;\n if (value instanceof ArrayBuffer) return true;\n if (ArrayBuffer.isView(value) && !(value instanceof DataView)) return true;\n if (value instanceof Series) return true;\n return isTelemValue(value);\n};\n\nexport interface SeriesProps extends BaseSeriesProps {\n data: CrudeSeries;\n}\n\nexport interface SeriesAllocProps extends BaseSeriesProps {\n capacity: number;\n dataType: CrudeDataType;\n}\n\nconst FULL_BUFFER = -1;\n\nexport interface SeriesMemInfo {\n key: string;\n length: number;\n byteLength: Size;\n glBuffer: boolean;\n}\n\n/**\n * Series is a strongly typed array of telemetry samples backed by an underlying binary\n * buffer.\n */\nexport class Series<T extends TelemValue = TelemValue> {\n key: string = \"\";\n /** The data type of the array */\n readonly dataType: DataType;\n /**\n * A sample offset that can be used to shift the values of all samples upwards or\n * downwards. Typically used to convert arrays to lower precision while preserving\n * the relative range of actual values.\n */\n sampleOffset: NumericTelemValue;\n /**\n * Stores information about the buffer state of this array into a WebGL buffer.\n */\n private readonly gl: GL;\n /** The underlying data. */\n private readonly _data: ArrayBufferLike;\n readonly _timeRange?: TimeRange;\n readonly alignment: number = 0;\n /** A cached minimum value. */\n private _cachedMin?: NumericTelemValue;\n /** A cached maximum value. */\n private _cachedMax?: NumericTelemValue;\n /** The write position of the buffer. */\n private writePos: number = FULL_BUFFER;\n /** Tracks the number of entities currently using this array. */\n private _refCount: number = 0;\n private _cachedLength?: number;\n\n constructor(props: SeriesProps | CrudeSeries) {\n if (isCrudeSeries(props)) props = { data: props };\n const {\n dataType,\n timeRange,\n sampleOffset = 0,\n glBufferUsage = \"static\",\n alignment = 0,\n key = nanoid(),\n } = props;\n const { data } = props;\n\n if (data instanceof Series) {\n this.key = data.key;\n this.dataType = data.dataType;\n this.sampleOffset = data.sampleOffset;\n this.gl = data.gl;\n this._data = data._data;\n this._timeRange = data._timeRange;\n this.alignment = data.alignment;\n this._cachedMin = data._cachedMin;\n this._cachedMax = data._cachedMax;\n this.writePos = data.writePos;\n this._refCount = data._refCount;\n this._cachedLength = data._cachedLength;\n return;\n }\n const isSingle = isTelemValue(data);\n const isArray = Array.isArray(data);\n\n if (dataType != null) this.dataType = new DataType(dataType);\n else {\n if (data instanceof ArrayBuffer)\n throw new Error(\n \"cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.\",\n );\n else if (isArray || isSingle) {\n let first: TelemValue | unknown = data as TelemValue;\n if (!isSingle) {\n if (data.length === 0)\n throw new Error(\n \"cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.\",\n );\n first = data[0];\n }\n if (typeof first === \"string\") this.dataType = DataType.STRING;\n else if (typeof first === \"number\") this.dataType = DataType.FLOAT64;\n else if (typeof first === \"bigint\") this.dataType = DataType.INT64;\n else if (typeof first === \"boolean\") this.dataType = DataType.BOOLEAN;\n else if (\n first instanceof TimeStamp ||\n first instanceof Date ||\n first instanceof TimeStamp\n )\n this.dataType = DataType.TIMESTAMP;\n else if (typeof first === \"object\") this.dataType = DataType.JSON;\n else\n throw new Error(\n `cannot infer data type of ${typeof first} when constructing a Series from a JS array`,\n );\n } else this.dataType = new DataType(data);\n }\n\n if (!isArray && !isSingle) this._data = data;\n else {\n let data_ = isSingle ? [data] : data;\n const first = data_[0];\n if (\n first instanceof TimeStamp ||\n first instanceof Date ||\n first instanceof TimeSpan\n )\n data_ = data_.map((v) => new TimeStamp(v as CrudeTimeStamp).valueOf());\n if (this.dataType.equals(DataType.STRING)) {\n this._cachedLength = data_.length;\n this._data = new TextEncoder().encode(data_.join(\"\\n\") + \"\\n\");\n } else if (this.dataType.equals(DataType.JSON)) {\n this._cachedLength = data_.length;\n this._data = new TextEncoder().encode(\n data_.map((d) => JSON.stringify(d)).join(\"\\n\") + \"\\n\",\n );\n } else this._data = new this.dataType.Array(data_ as number[] & bigint[]).buffer;\n }\n\n this.key = key;\n this.alignment = alignment;\n this.sampleOffset = sampleOffset ?? 0;\n this._timeRange = timeRange;\n this.gl = {\n control: null,\n buffer: null,\n prevBuffer: 0,\n bufferUsage: glBufferUsage,\n };\n }\n\n static alloc({ capacity: length, dataType, ...props }: SeriesAllocProps): Series {\n if (length === 0)\n throw new Error(\"[Series] - cannot allocate an array of length 0\");\n const data = new new DataType(dataType).Array(length);\n const arr = new Series({\n data: data.buffer,\n dataType,\n ...props,\n });\n arr.writePos = 0;\n return arr;\n }\n\n static generateTimestamps(length: number, rate: Rate, start: TimeStamp): Series {\n const timeRange = start.spanRange(rate.span(length));\n const data = new BigInt64Array(length);\n for (let i = 0; i < length; i++) {\n data[i] = BigInt(start.add(rate.span(i)).valueOf());\n }\n return new Series({ data, dataType: DataType.TIMESTAMP, timeRange });\n }\n\n get refCount(): number {\n return this._refCount;\n }\n\n static fromStrings(data: string[], timeRange?: TimeRange): Series {\n const buffer = new TextEncoder().encode(data.join(\"\\n\") + \"\\n\");\n return new Series({ data: buffer, dataType: DataType.STRING, timeRange });\n }\n\n static fromJSON<T>(data: T[], timeRange?: TimeRange): Series {\n const buffer = new TextEncoder().encode(\n data.map((d) => JSON.stringify(d)).join(\"\\n\") + \"\\n\",\n );\n return new Series({ data: buffer, dataType: DataType.JSON, timeRange });\n }\n\n acquire(gl?: GLBufferController): void {\n this._refCount++;\n if (gl != null) this.updateGLBuffer(gl);\n }\n\n release(): void {\n this._refCount--;\n if (this._refCount === 0 && this.gl.control != null)\n this.maybeGarbageCollectGLBuffer(this.gl.control);\n else if (this._refCount < 0)\n throw new Error(\"cannot release an array with a negative reference count\");\n }\n\n /**\n * Writes the given series to this series. If the series being written exceeds the\n * remaining of series being written to, only the portion that fits will be written.\n * @param other the series to write to this series. The data type of the series written\n * must be the same as the data type of the series being written to.\n * @returns the number of samples written. If the entire series fits, this value is\n * equal to the length of the series being written.\n */\n write(other: Series): number {\n if (!other.dataType.equals(this.dataType))\n throw new Error(\"buffer must be of the same type as this array\");\n\n // We've filled the entire underlying buffer\n if (this.writePos === FULL_BUFFER) return 0;\n const available = this.capacity - this.writePos;\n\n const toWrite = available < other.length ? other.slice(0, available) : other;\n this.underlyingData.set(toWrite.data as ArrayLike<any>, this.writePos);\n this.maybeRecomputeMinMax(toWrite);\n this._cachedLength = undefined;\n this.writePos += toWrite.length;\n return toWrite.length;\n }\n\n /** @returns the underlying buffer backing this array. */\n get buffer(): ArrayBufferLike {\n return this._data;\n }\n\n private get underlyingData(): TypedArray {\n return new this.dataType.Array(this._data);\n }\n\n /** @returns a native typed array with the proper data type. */\n get data(): TypedArray {\n if (this.writePos === FULL_BUFFER) return this.underlyingData;\n return new this.dataType.Array(this._data, 0, this.writePos);\n }\n\n toStrings(): string[] {\n if (!this.dataType.equals(DataType.STRING))\n throw new Error(\"cannot convert non-string series to strings\");\n return new TextDecoder().decode(this.buffer).split(\"\\n\").slice(0, -1);\n }\n\n toUUIDs(): string[] {\n if (!this.dataType.equals(DataType.UUID))\n throw new Error(\"cannot convert non-uuid series to uuids\");\n const den = DataType.UUID.density.valueOf();\n const r = Array(this.length);\n\n for (let i = 0; i < this.length; i++) {\n const v = this.buffer.slice(i * den, (i + 1) * den);\n const id = Array.from(new Uint8Array(v), (b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\")\n .replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, \"$1-$2-$3-$4-$5\");\n r[i] = id;\n }\n return r;\n }\n\n parseJSON<Z extends z.ZodTypeAny>(schema: Z): Array<z.output<Z>> {\n if (!this.dataType.equals(DataType.JSON))\n throw new Error(\"cannot convert non-string series to strings\");\n return new TextDecoder()\n .decode(this.buffer)\n .split(\"\\n\")\n .slice(0, -1)\n .map((s) => schema.parse(JSON.parse(s)));\n }\n\n /** @returns the time range of this array. */\n get timeRange(): TimeRange {\n if (this._timeRange == null) throw new Error(\"time range not set on series\");\n return this._timeRange;\n }\n\n /** @returns the capacity of the series in bytes. */\n get byteCapacity(): Size {\n return new Size(this.buffer.byteLength);\n }\n\n /** @returns the capacity of the series in samples. */\n get capacity(): number {\n return this.dataType.density.length(this.byteCapacity);\n }\n\n /** @returns the length of the series in bytes. */\n get byteLength(): Size {\n if (this.writePos === FULL_BUFFER) return this.byteCapacity;\n return this.dataType.density.size(this.writePos);\n }\n\n /** @returns the number of samples in this array. */\n get length(): number {\n if (this._cachedLength != null) return this._cachedLength;\n if (this.dataType.isVariable) return this.calculateCachedLength();\n if (this.writePos === FULL_BUFFER) return this.data.length;\n return this.writePos;\n }\n\n private calculateCachedLength(): number {\n if (!this.dataType.isVariable)\n throw new Error(\"cannot calculate length of a non-variable length data type\");\n let cl = 0;\n this.data.forEach((v) => {\n if (v === 10) cl++;\n });\n this._cachedLength = cl;\n return cl;\n }\n\n /**\n * Creates a new array with a different data type.\n * @param target the data type to convert to.\n * @param sampleOffset an offset to apply to each sample. This can help with precision\n * issues when converting between data types.\n *\n * WARNING: This method is expensive and copies the entire underlying array. There\n * also may be untimely precision issues when converting between data types.\n */\n convert(target: DataType, sampleOffset: NumericTelemValue = 0): Series {\n if (this.dataType.equals(target)) return this;\n const data = new target.Array(this.length);\n for (let i = 0; i < this.length; i++) {\n data[i] = convertDataType(this.dataType, target, this.data[i], sampleOffset);\n }\n return new Series({\n data: data.buffer,\n dataType: target,\n timeRange: this._timeRange,\n sampleOffset,\n glBufferUsage: this.gl.bufferUsage,\n alignment: this.alignment,\n });\n }\n\n private calcRawMax(): NumericTelemValue {\n if (this.length === 0) return -Infinity;\n if (this.dataType.equals(DataType.TIMESTAMP)) {\n this._cachedMax = this.data[this.data.length - 1];\n } else if (this.dataType.usesBigInt) {\n const d = this.data as BigInt64Array;\n this._cachedMax = d.reduce((a, b) => (a > b ? a : b));\n } else {\n const d = this.data as Float64Array;\n this._cachedMax = d.reduce((a, b) => (a > b ? a : b));\n }\n return this._cachedMax;\n }\n\n /** @returns the maximum value in the array */\n get max(): NumericTelemValue {\n if (this.dataType.isVariable)\n throw new Error(\"cannot calculate maximum on a variable length data type\");\n if (this.writePos === 0) return -Infinity;\n else if (this._cachedMax == null) this._cachedMax = this.calcRawMax();\n return addSamples(this._cachedMax, this.sampleOffset);\n }\n\n private calcRawMin(): NumericTelemValue {\n if (this.length === 0) return Infinity;\n if (this.dataType.equals(DataType.TIMESTAMP)) {\n this._cachedMin = this.data[0];\n } else if (this.dataType.usesBigInt) {\n const d = this.data as BigInt64Array;\n this._cachedMin = d.reduce((a, b) => (a < b ? a : b));\n } else {\n const d = this.data as Float64Array;\n this._cachedMin = d.reduce((a, b) => (a < b ? a : b));\n }\n return this._cachedMin;\n }\n\n /** @returns the minimum value in the array */\n get min(): NumericTelemValue {\n if (this.dataType.isVariable)\n throw new Error(\"cannot calculate minimum on a variable length data type\");\n if (this.writePos === 0) return Infinity;\n else if (this._cachedMin == null) this._cachedMin = this.calcRawMin();\n return addSamples(this._cachedMin, this.sampleOffset);\n }\n\n /** @returns the bounds of this array. */\n get bounds(): bounds.Bounds {\n return bounds.construct(Number(this.min), Number(this.max));\n }\n\n private maybeRecomputeMinMax(update: Series): void {\n if (this._cachedMin != null) {\n const min = update._cachedMin ?? update.calcRawMin();\n if (min < this._cachedMin) this._cachedMin = min;\n }\n if (this._cachedMax != null) {\n const max = update._cachedMax ?? update.calcRawMax();\n if (max > this._cachedMax) this._cachedMax = max;\n }\n }\n\n enrich(): void {\n let _ = this.max;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _ = this.min;\n }\n\n get range(): NumericTelemValue {\n return addSamples(this.max, -this.min);\n }\n\n at(index: number, required: true): T;\n\n at(index: number, required?: false): T | undefined;\n\n at(index: number, required?: boolean): T | undefined {\n if (this.dataType.isVariable) return this.atVariable(index, required ?? false);\n if (index < 0) index = this.length + index;\n const v = this.data[index];\n if (v == null) {\n if (required === true) throw new Error(`[series] - no value at index ${index}`);\n return undefined;\n }\n return addSamples(v, this.sampleOffset) as T;\n }\n\n private atVariable(index: number, required: boolean): T | undefined {\n if (index < 0) index = this.length + index;\n let start = 0;\n let end = 0;\n for (let i = 0; i < this.data.length; i++) {\n if (this.data[i] === 10) {\n if (index === 0) {\n end = i;\n break;\n }\n start = i + 1;\n index--;\n }\n }\n if (end === 0) end = this.data.length;\n if (start >= end || index > 0) {\n if (required) throw new Error(`[series] - no value at index ${index}`);\n return undefined;\n }\n const slice = this.data.slice(start, end);\n if (this.dataType.equals(DataType.STRING))\n return new TextDecoder().decode(slice) as unknown as T;\n return JSON.parse(new TextDecoder().decode(slice)) as unknown as T;\n }\n\n /**\n * @returns the index of the first sample that is greater than or equal to the given value.\n * The underlying array must be sorted. If it is not, the behavior of this method is undefined.\n * @param value the value to search for.\n */\n binarySearch(value: NumericTelemValue): number {\n let left = 0;\n let right = this.length - 1;\n const cf = compare.newF(value);\n while (left <= right) {\n const mid = Math.floor((left + right) / 2);\n const cmp = cf(this.at(mid, true) as NumericTelemValue, value);\n if (cmp === 0) return mid;\n if (cmp < 0) left = mid + 1;\n else right = mid - 1;\n }\n return left;\n }\n\n updateGLBuffer(gl: GLBufferController): void {\n this.gl.control = gl;\n if (!this.dataType.equals(DataType.FLOAT32))\n throw new Error(\"Only FLOAT32 arrays can be used in WebGL\");\n const { buffer, bufferUsage, prevBuffer } = this.gl;\n\n // If no buffer has been created yet, create one.\n if (buffer == null) this.gl.buffer = gl.createBuffer();\n // If the current write position is the same as the previous buffer, we're already\n // up date.\n if (this.writePos === prevBuffer) return;\n\n // Bind the buffer.\n gl.bindBuffer(gl.ARRAY_BUFFER, this.gl.buffer);\n\n // This means we only need to buffer part of the array.\n if (this.writePos !== FULL_BUFFER) {\n if (prevBuffer === 0) {\n gl.bufferData(gl.ARRAY_BUFFER, this.byteCapacity.valueOf(), gl.STATIC_DRAW);\n }\n const byteOffset = this.dataType.density.size(prevBuffer).valueOf();\n const slice = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);\n gl.bufferSubData(gl.ARRAY_BUFFER, byteOffset, slice.buffer);\n this.gl.prevBuffer = this.writePos;\n } else {\n // This means we can buffer the entire array in a single go.\n gl.bufferData(\n gl.ARRAY_BUFFER,\n this.buffer,\n bufferUsage === \"static\" ? gl.STATIC_DRAW : gl.DYNAMIC_DRAW,\n );\n this.gl.prevBuffer = FULL_BUFFER;\n }\n }\n\n as(jsType: \"string\"): Series<string>;\n\n as(jsType: \"number\"): Series<number>;\n\n as(jsType: \"bigint\"): Series<bigint>;\n\n as<T extends TelemValue>(jsType: \"string\" | \"number\" | \"bigint\"): Series<T> {\n if (jsType === \"string\") {\n if (!this.dataType.equals(DataType.STRING))\n throw new Error(\n `cannot convert series of type ${this.dataType.toString()} to string`,\n );\n return this as unknown as Series<T>;\n }\n if (jsType === \"number\") {\n if (!this.dataType.isNumeric)\n throw new Error(\n `cannot convert series of type ${this.dataType.toString()} to number`,\n );\n return this as unknown as Series<T>;\n }\n if (jsType === \"bigint\") {\n if (!this.dataType.equals(DataType.INT64))\n throw new Error(\n `cannot convert series of type ${this.dataType.toString()} to bigint`,\n );\n return this as unknown as Series<T>;\n }\n throw new Error(`cannot convert series to ${jsType as string}`);\n }\n\n get digest(): SeriesDigest {\n return {\n key: this.key,\n dataType: this.dataType.toString(),\n sampleOffset: this.sampleOffset,\n alignment: this.alignmentBounds,\n timeRange: this._timeRange?.toString(),\n length: this.length,\n capacity: this.capacity,\n };\n }\n\n get memInfo(): SeriesMemInfo {\n return {\n key: this.key,\n length: this.length,\n byteLength: this.byteLength,\n glBuffer: this.gl.buffer != null,\n };\n }\n\n get alignmentBounds(): bounds.Bounds {\n return bounds.construct(this.alignment, this.alignment + this.length);\n }\n\n private maybeGarbageCollectGLBuffer(gl: GLBufferController): void {\n if (this.gl.buffer == null) return;\n gl.deleteBuffer(this.gl.buffer);\n this.gl.buffer = null;\n this.gl.prevBuffer = 0;\n this.gl.control = null;\n }\n\n get glBuffer(): WebGLBuffer {\n if (this.gl.buffer == null) throw new Error(\"gl buffer not initialized\");\n if (!(this.gl.prevBuffer === this.writePos)) console.warn(\"buffer not updated\");\n return this.gl.buffer;\n }\n\n [Symbol.iterator](): Iterator<T> {\n if (this.dataType.isVariable) {\n const s = new StringSeriesIterator(this);\n if (this.dataType.equals(DataType.JSON)) {\n return new JSONSeriesIterator(s) as Iterator<T>;\n }\n return s as Iterator<T>;\n }\n return new FixedSeriesIterator(this) as Iterator<T>;\n }\n\n slice(start: number, end?: number): Series {\n if (start <= 0 && (end == null || end >= this.length)) return this;\n const data = this.data.slice(start, end);\n return new Series({\n data,\n dataType: this.dataType,\n timeRange: this._timeRange,\n sampleOffset: this.sampleOffset,\n glBufferUsage: this.gl.bufferUsage,\n alignment: this.alignment + start,\n });\n }\n\n reAlign(alignment: number): Series {\n return new Series({\n data: this.buffer,\n dataType: this.dataType,\n timeRange: TimeRange.ZERO,\n sampleOffset: this.sampleOffset,\n glBufferUsage: \"static\",\n alignment,\n });\n }\n}\n\nclass StringSeriesIterator implements Iterator<string> {\n private readonly series: Series;\n private index: number;\n private readonly decoder: TextDecoder;\n\n constructor(series: Series) {\n if (!series.dataType.isVariable)\n throw new Error(\n \"cannot create a variable series iterator for a non-variable series\",\n );\n this.series = series;\n this.index = 0;\n this.decoder = new TextDecoder();\n }\n\n next(): IteratorResult<string> {\n const start = this.index;\n const data = this.series.data;\n while (this.index < data.length && data[this.index] !== 10) this.index++;\n const end = this.index;\n if (start === end) return { done: true, value: undefined };\n this.index++;\n const s = this.decoder.decode(this.series.buffer.slice(start, end));\n return { done: false, value: s };\n }\n\n [Symbol.iterator](): Iterator<TelemValue> {\n return this;\n }\n}\n\nclass JSONSeriesIterator implements Iterator<unknown> {\n private readonly wrapped: Iterator<string>;\n\n constructor(wrapped: Iterator<string>) {\n this.wrapped = wrapped;\n }\n\n next(): IteratorResult<object> {\n const next = this.wrapped.next();\n if (next.done === true) return { done: true, value: undefined };\n return { done: false, value: JSON.parse(next.value) };\n }\n\n [Symbol.iterator](): Iterator<object> {\n return this;\n }\n\n [Symbol.toStringTag] = \"JSONSeriesIterator\";\n}\n\nclass FixedSeriesIterator implements Iterator<NumericTelemValue> {\n series: Series;\n index: number;\n constructor(series: Series) {\n this.series = series;\n this.index = 0;\n }\n\n next(): IteratorResult<NumericTelemValue> {\n if (this.index >= this.series.length) return { done: true, value: undefined };\n return {\n done: false,\n value: this.series.at(this.index++, true) as NumericTelemValue,\n };\n }\n\n [Symbol.iterator](): Iterator<NumericTelemValue> {\n return this;\n }\n\n [Symbol.toStringTag] = \"SeriesIterator\";\n}\n\nexport const addSamples = (\n a: NumericTelemValue,\n b: NumericTelemValue,\n): NumericTelemValue => {\n if (typeof a === \"bigint\" && typeof b === \"bigint\") return a + b;\n if (typeof a === \"number\" && typeof b === \"number\") return a + b;\n if (b === 0) return a;\n if (a === 0) return b;\n return Number(a) + Number(b);\n};\n\nexport class MultiSeries<T extends TelemValue = TelemValue> implements Iterable<T> {\n readonly series: Array<Series<T>>;\n\n constructor(series: Array<Series<T>>) {\n if (series.length !== 0) {\n const type = series[0].dataType;\n for (let i = 1; i < series.length; i++)\n if (!series[i].dataType.equals(type))\n throw new Error(\"[multi-series] - series must have the same data type\");\n }\n this.series = series;\n }\n\n as(jsType: \"string\"): MultiSeries<string>;\n\n as(jsType: \"number\"): MultiSeries<number>;\n\n as(jsType: \"bigint\"): MultiSeries<bigint>;\n\n as<T extends TelemValue>(dataType: CrudeDataType): MultiSeries<T> {\n if (!new DataType(dataType).equals(this.dataType))\n throw new Error(\n `cannot convert series of type ${this.dataType.toString()} to ${dataType.toString()}`,\n );\n return this as unknown as MultiSeries<T>;\n }\n\n get dataType(): DataType {\n if (this.series.length === 0) return DataType.UNKNOWN;\n return this.series[0].dataType;\n }\n\n get timeRange(): TimeRange {\n if (this.series.length === 0) return TimeRange.ZERO;\n return new TimeRange(\n this.series[0].timeRange.start,\n this.series[this.series.length - 1].timeRange.end,\n );\n }\n\n push(series: Series<T>): void {\n this.series.push(series);\n }\n\n get length(): number {\n return this.series.reduce((a, b) => a + b.length, 0);\n }\n\n at(index: number, required: true): T;\n\n at(index: number, required?: false): T | undefined;\n\n at(index: number, required: boolean = false): T | undefined {\n if (index < 0) index = this.length + index;\n for (const ser of this.series) {\n if (index < ser.length) return ser.at(index, required as true);\n index -= ser.length;\n }\n if (required) throw new Error(`[series] - no value at index ${index}`);\n return undefined;\n }\n\n get byteLength(): Size {\n return new Size(this.series.reduce((a, b) => a + b.byteLength.valueOf(), 0));\n }\n\n get data(): TypedArray {\n const buf = new this.dataType.Array(this.length);\n let offset = 0;\n for (const ser of this.series) {\n buf.set(ser.data as ArrayLike<any>, offset);\n offset += ser.length;\n }\n return new this.dataType.Array(buf);\n }\n\n [Symbol.iterator](): Iterator<T> {\n if (this.series.length === 0)\n return {\n next(): IteratorResult<T> {\n return { done: true, value: undefined };\n },\n };\n return new MultiSeriesIterator<T>(this.series);\n }\n}\n\nclass MultiSeriesIterator<T extends TelemValue = TelemValue> implements Iterator<T> {\n private readonly series: Array<Series<T>>;\n private seriesIndex: number;\n private internal: Iterator<T>;\n\n constructor(series: Array<Series<T>>) {\n this.series = series;\n this.seriesIndex = 0;\n this.internal = series[0][Symbol.iterator]();\n }\n\n next(): IteratorResult<T> {\n const next = this.internal.next();\n if (next.done === false) return next;\n if (this.seriesIndex === this.series.length - 1)\n return { done: true, value: undefined };\n this.internal = this.series[++this.seriesIndex][Symbol.iterator]();\n return this.next();\n }\n\n [Symbol.iterator](): Iterator<TelemValue | unknown> {\n return this;\n }\n\n [Symbol.toStringTag] = \"MultiSeriesIterator\";\n}\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nexport type Key = string | number | symbol;\n\nexport type UnknownRecord = { [key: Key]: unknown };\n\nexport type Keyed<K extends Key> = { key: K };\n\nexport const unknownRecordZ = z.record(\n z.union([z.number(), z.string(), z.symbol()]),\n z.unknown(),\n);\n\nexport type Entries<T> = {\n [K in keyof T]: [K, T[K]];\n}[keyof T][];\n\nexport const getEntries = <T extends Record<Key, unknown>>(obj: T): Entries<T> =>\n Object.entries(obj) as Entries<T>;\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Stringer } from \"@/primitive\";\n\nexport type PureRenderableValue = string | number | undefined;\nexport type RenderableValue = PureRenderableValue | Stringer;\n\nexport const convertRenderV = (value: RenderableValue): string | number | undefined => {\n if (value === undefined || typeof value === \"string\" || typeof value === \"number\")\n return value;\n if (value.toString === undefined) throw new Error(\"invalid renderer\");\n return value.toString();\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type UnknownRecord } from \"@/record\";\n\nexport const isObject = <T extends UnknownRecord = UnknownRecord>(\n item?: unknown,\n): item is T => item != null && typeof item === \"object\" && !Array.isArray(item);\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\n/** JavaScript runtime environments. */\nexport type Runtime = \"browser\" | \"node\" | \"webworker\";\n\n/**\n * Does best effort detection of the runtime environment.\n *\n * @returns The runtime environment.\n */\nexport const detect = (): Runtime => {\n if (\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n typeof process !== \"undefined\" &&\n process.versions != null &&\n process.versions.node != null\n )\n return \"node\";\n\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n if (typeof window === \"undefined\" || window.document === undefined)\n return \"webworker\";\n\n return \"browser\";\n};\n\nexport const RUNTIME = detect();\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nexport const OPERATING_SYSTEMS = [\"MacOS\", \"Windows\", \"Linux\", \"Docker\"] as const;\nexport const osZ = z.enum(OPERATING_SYSTEMS);\nexport type OS = (typeof OPERATING_SYSTEMS)[number];\n\nexport interface GetOSProps {\n force?: OS;\n default?: OS;\n}\n\nlet os: OS | undefined;\n\nconst evalOS = (): OS | undefined => {\n if (typeof window === \"undefined\") return undefined;\n const userAgent = window.navigator.userAgent.toLowerCase();\n if (userAgent.includes(\"mac\")) return \"MacOS\";\n else if (userAgent.includes(\"win\")) return \"Windows\";\n else if (userAgent.includes(\"linux\")) return \"Linux\";\n return undefined;\n};\n\nexport const getOS = (props: GetOSProps = {}): OS | undefined => {\n const { force, default: default_ } = props;\n if (force != null) return force;\n if (os != null) return os;\n os = evalOS();\n return os ?? default_;\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nexport const copy = <T>(obj: T): T =>\n JSON.parse(JSON.stringify(obj));\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Key } from \"@/deep/path\";\n\nexport const deleteD = <T extends any, D extends number = 5>(\n target: T,\n ...keys: Array<Key<T, D>>\n): T => {\n keys.forEach((key) => {\n let curr: any = target;\n const arr = key.split(\".\");\n arr.forEach((k, i) => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n if (i === arr.length - 1) delete curr[k];\n else curr = curr[k];\n });\n });\n return target;\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Join } from \"@/join\";\nimport { UnknownRecord } from \"@/record\";\n\ntype Prev = [\n never,\n 0,\n 1,\n 2,\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14,\n 15,\n 16,\n 17,\n 18,\n 19,\n 20,\n ...Array<0>,\n];\n\nexport type Key<T, D extends number = 5> = [D] extends [never]\n ? never\n : T extends object\n ? {\n [K in keyof T]-?: K extends string | number\n ? `${K}` | Join<K, Key<T[K], Prev[D]>>\n : never;\n }[keyof T]\n : \"\";\n\nexport type Get = \n&(<T>(obj: T, path: string, allowNull: true) => unknown | null) \n&(<T>(obj: T, path: string, allowNull?: boolean) => unknown) \n\nexport const get: Get = <V>(obj: V, path: string, allowNull: boolean = false): unknown | null => {\n const parts = (path as string).split(\".\");\n if (parts.length === 1 && parts[0] === \"\") return obj;\n let result: UnknownRecord = obj as UnknownRecord;\n for (const part of parts) {\n const v = result[part];\n if (v == null) {\n if (allowNull) return null;\n throw new Error(`Path ${path} does not exist. ${part} is null`);\n }\n result = v as UnknownRecord;\n }\n return result;\n}\n\nexport const set = <V>(obj: V, path: string, value: unknown): void => {\n const parts = (path as string).split(\".\");\n let result: UnknownRecord = obj as UnknownRecord;\n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i];\n if (result[part] == null) {\n throw new Error(`Path ${path} does not exist`);\n }\n result = result[part] as UnknownRecord;\n }\n result[parts[parts.length - 1]] = value;\n}\n\nexport const element = (path: string, index: number): string => {\n const parts = path.split(\".\");\n if (index < 0) return parts[parts.length + index];\n return parts[index];\n}\n\nexport const join = (path: string[]): string => path.join(\".\");\n\nexport const has = <V>(obj: V, path: string): boolean => {\n try {\n get<V>(obj, path);\n return true;\n } catch {\n return false;\n }\n}","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Partial } from \"@/deep/partial\";\nimport { isObject } from \"@/identity\";\n\nexport const merge = <T>(base: T, ...objects: Array<Partial<T>>): T => {\n if (objects.length === 0) return base;\n const source = objects.shift();\n\n if (isObject(base) && isObject(source)) {\n for (const key in source) {\n try {\n if (isObject(source[key])) {\n if (!(key in base)) Object.assign(base, { [key]: {} });\n merge(base[key], source[key]);\n } else {\n Object.assign(base, { [key]: source[key] });\n }\n } catch (e) {\n if (e instanceof TypeError) {\n throw new TypeError(`.${key}: ${e.message}`);\n }\n throw e;\n }\n }\n }\n\n return merge(base, ...objects);\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Primitive } from \"@/primitive\";\n\ninterface DeepEqualBaseRecord {\n equals?: (other: any) => boolean;\n}\n\nexport const equal = <\n T extends unknown | DeepEqualBaseRecord | DeepEqualBaseRecord[] | Primitive[],\n>(\n a: T,\n b: T,\n): boolean => {\n const aIsArray = Array.isArray(a);\n const bIsArray = Array.isArray(b);\n if (aIsArray !== bIsArray) return false;\n if (aIsArray && bIsArray) {\n const aArr = a as DeepEqualBaseRecord[];\n const bArr = b as DeepEqualBaseRecord[];\n if (aArr.length !== bArr.length) return false;\n for (let i = 0; i < aArr.length; i++) if (!equal(aArr[i], bArr[i])) return false;\n return true;\n }\n if (a == null || b == null || typeof a !== \"object\" || typeof b !== \"object\")\n return a === b;\n if (\"equals\" in a) return (a.equals as (other: any) => boolean)(b);\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) return false;\n for (const key of aKeys) {\n // @ts-expect-error\n const aVal = a[key];\n // @ts-expect-error\n const bVal = b[key];\n if (typeof aVal === \"object\" && typeof bVal === \"object\") {\n if (!equal(aVal, bVal)) return false;\n } else if (aVal !== bVal) return false;\n }\n return true;\n};\n\nexport const partialEqual = <T extends unknown | DeepEqualBaseRecord | Primitive>(\n base: T,\n partial: Partial<T>,\n): boolean => {\n if (typeof base !== \"object\" || base == null) return base === partial;\n const baseKeys = Object.keys(base);\n const partialKeys = Object.keys(partial);\n if (partialKeys.length > baseKeys.length) return false;\n for (const key of partialKeys) {\n // @ts-expect-error\n const baseVal = base[key];\n // @ts-expect-error\n const partialVal = partial[key];\n if (typeof baseVal === \"object\" && typeof partialVal === \"object\") {\n if (!partialEqual(baseVal, partialVal)) return false;\n } else if (baseVal !== partialVal) return false;\n }\n return true;\n};\n","// Copyright 2024 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { equal } from \"@/deep/equal\"\n\n\nexport const memo = <F extends (...args: any[]) => any>(func: F): F => {\n let prevArgs: Parameters<F> = undefined as any\n let prevResult: ReturnType<F> = undefined as any\n const v = ((...args: Parameters<F>) => {\n if (equal(prevArgs, args)) return prevResult\n const result = func(...args)\n prevArgs = args\n prevResult = result\n return result\n })\n return v as F;\n}\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\n\ntype PathValueTuple = [any, any];\n\nexport const difference = (obj1: Record<string, any>, obj2: Record<string, any>, path: string = ''): Record<string, PathValueTuple> => {\n const diffMap: Record<string, PathValueTuple> = {};\n\n const compare = (a: any, b: any, currentPath: string) => {\n if (typeof a !== typeof b || a === null || b === null) {\n diffMap[currentPath] = [a, b];\n return;\n }\n\n if (typeof a === 'object' && typeof b === 'object') {\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) {\n diffMap[currentPath] = [a, b];\n return;\n }\n for (let i = 0; i < a.length; i++) {\n compare(a[i], b[i], `${currentPath}[${i}]`);\n }\n } else {\n const keys = new Set([...Object.keys(a), ...Object.keys(b)]);\n keys.forEach(key => {\n compare(a[key], b[key], currentPath ? `${currentPath}.${key}` : key);\n });\n }\n } else {\n if (a !== b) {\n diffMap[currentPath] = [a, b];\n }\n }\n };\n\n compare(obj1, obj2, path);\n return diffMap;\n}\n\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nexport const debounce = <F extends (...args: any[]) => void>(\n func: F,\n waitFor: number\n): F => {\n let timeout: ReturnType<typeof setTimeout> | null = null;\n if (waitFor === 0) return func;\n\n const debounced = (...args: Parameters<F>): void => {\n if (timeout !== null) {\n clearTimeout(timeout);\n timeout = null;\n }\n timeout = setTimeout(() => func(...args), waitFor);\n };\n\n return debounced as F;\n};\n\nexport const throttle = <F extends (...args: any[]) => void>(\n func: F,\n waitFor: number\n): F => {\n let timeout: ReturnType<typeof setTimeout> | null = null;\n if (waitFor === 0) return func;\n\n const throttled = (...args: Parameters<F>): void => {\n if (timeout === null) {\n timeout = setTimeout(() => {\n func(...args);\n timeout = null;\n }, waitFor);\n }\n };\n\n return throttled as F;\n}","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nexport const unique = <V>(values: V[] | readonly V[]): V[] => [...new Set(values)];\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\ninterface URLProps {\n host: string;\n port: number;\n protocol?: string;\n pathPrefix?: string;\n params?: string;\n}\n\n/** @returns the paths joined with a single slash */\nconst joinPaths = (...paths: string[]): string => paths.map(formatPath).join(\"\");\n\n/** ensures that a path is correctly formatted for joining */\nconst formatPath = (path: string): string => {\n if (!path.endsWith(\"/\")) path += \"/\";\n if (path.startsWith(\"/\")) path = path.slice(1);\n return path;\n};\n\n/** removes the trailing slash from a path */\nconst removeTrailingSlash = (path: string): string =>\n path.endsWith(\"/\") ? path.slice(0, -1) : path;\n\n/**\n * Builds a query string from a record.\n * @param record - The record to build the query string from. If the record is null,\n * an empty string is returned.\n * @returns the query string.\n */\nexport const buildQueryString = (\n request: Record<string, unknown>,\n prefix: string = \"\"\n): string => {\n if (request === null) return \"\";\n return (\n \"?\" +\n Object.entries(request)\n .filter(([, value]) => {\n if (value === undefined || value === null) return false;\n if (Array.isArray(value)) return value.length > 0;\n return true;\n })\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n .map(([key, value]) => `${prefix}${key}=${value}`)\n .join(\"&\")\n );\n};\n\n/**\n * URL is a simple class for building and extending URLs.\n */\nexport class URL {\n protocol: string;\n host: string;\n port: number;\n path: string;\n\n /**\n * @param host - The hostname or IP address of the server.\n * @param port - The port number of the server.\n * @param protocol - The protocol to use for all requests. Defaults to \"\".\n * @param pathPrefix - A path prefix to use for all requests. Defaults to \"\".\n */\n constructor({ host, port, protocol = \"\", pathPrefix = \"\" }: URLProps) {\n this.protocol = protocol;\n this.host = host;\n this.port = port;\n this.path = formatPath(pathPrefix);\n }\n\n /**\n * Replaces creates a new URL with the specified properties replaced.\n * @param props - The properties to replace.\n * @returns a new URL.\n */\n replace(props: Partial<URLProps>): URL {\n return new URL({\n host: props.host ?? this.host,\n port: props.port ?? this.port,\n protocol: props.protocol ?? this.protocol,\n pathPrefix: props.pathPrefix ?? this.path,\n });\n }\n\n /**\n * Creates a new url with the given path appended to the current path.\n * @param path - the path to append to the URL.\n * @returns a new URL.\n */\n child(path: string): URL {\n return new URL({\n ...this,\n pathPrefix: joinPaths(this.path, path),\n });\n }\n\n /** @returns a string representation of the url */\n toString(): string {\n return removeTrailingSlash(\n `${this.protocol}://${this.host}:${this.port}/${this.path}`\n );\n }\n\n static readonly UNKNOWN = new URL({ host: \"unknown\", port: 0 });\n}\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nexport const toArray = <T>(value: T | T[]): T[] =>\n Array.isArray(value) ? value : [value];\n\nexport const nullToArr = <T>(value: T | T[] | null): T[] =>\n Array.isArray(value) ? value : value === null ? [] : [value];","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type CompareF } from \"@/compare/compare\";\nimport { type Key, type Keyed } from \"@/record\";\n\nconst binary = <T>(arr: T[], target: T, compare: CompareF<T>): number => {\n let left = 0;\n let right = arr.length - 1;\n while (left <= right) {\n const mid = Math.floor((left + right) / 2);\n const cmp = compare(arr[mid], target);\n if (cmp === 0) return mid;\n if (cmp < 0) left = mid + 1;\n else right = mid - 1;\n }\n return -1;\n};\n\nexport const Search = {\n binary,\n};\n\nexport interface TermSearcher<T, K extends Key, E extends Keyed<K>> {\n search: (term: T) => E[];\n retrieve: (keys: K[]) => E[];\n page: (offset: number, limit: number) => E[];\n}\n\nexport interface AsyncTermSearcher<T, K extends Key, E extends Keyed<K>> {\n search: (term: T) => Promise<E[]>;\n retrieve: (keys: K[]) => Promise<E[]>;\n page: (offset: number, limit: number) => Promise<E[]>;\n}\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nexport interface Sender<T> {\n send: (value: T, transfer?: Transferable[]) => void;\n}\n\nexport interface Handler<T> {\n handle: (handler: (value: T) => void) => void;\n}\n\nexport interface SenderHandler<I, O> extends Sender<I>, Handler<O> {}\n\ninterface TypedWorkerMessage {\n type: string;\n payload: any;\n}\n\ntype SendFunc = (value: any, transfer?: Transferable[]) => void;\ntype HandlerFunc = (value: any) => void;\n\nexport class RoutedWorker {\n sender: SendFunc;\n handlers: Map<string, TypedWorker<any>>;\n\n constructor(send: SendFunc) {\n this.sender = send;\n this.handlers = new Map();\n }\n\n handle({ data }: { data: TypedWorkerMessage }): void {\n const handler = this.handlers.get(data.type)?.handler;\n if (handler == null) console.warn(`No handler for ${data.type}`);\n else handler(data.payload);\n }\n\n route<RQ, RS = RQ>(type: string): TypedWorker<RQ, RS> {\n const send = typedSend(type, this.sender);\n const t = new TypedWorker<RQ, RS>(send);\n this.handlers.set(type, t);\n return t;\n }\n}\n\nconst typedSend =\n (type: string, send: SendFunc): SendFunc =>\n (payload: any, transfer?: Transferable[]) => {\n return send({ type, payload }, transfer);\n };\n\nexport class TypedWorker<RQ, RS = RQ> implements SenderHandler<RQ, RS> {\n private readonly _send: SendFunc;\n handler: HandlerFunc | null;\n\n constructor(send: SendFunc) {\n this._send = send;\n this.handler = null;\n }\n\n send(payload: RQ, transfer: Transferable[] = []): void {\n this._send(payload, transfer);\n }\n\n handle(handler: (payload: RS) => void): void {\n this.handler = handler;\n }\n}\n\nexport const createMockWorkers = (): [RoutedWorker, RoutedWorker] => {\n let a: RoutedWorker, b: RoutedWorker;\n const aSend = (value: any, transfer?: Transferable[]): void => {\n b.handle({ data: value });\n };\n const bSend = (value: any, transfer?: Transferable[]): void => {\n a.handle({ data: value });\n };\n a = new RoutedWorker(aSend);\n b = new RoutedWorker(bSend);\n return [a, b];\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ZodSchema, type z } from \"zod\";\n\nimport { Case } from \"@/case\";\nimport { isObject } from \"@/identity\";\n\n/**\n * EncoderDecoder is an entity that encodes and decodes messages to and from a\n * binary format.\n */\nexport interface EncoderDecoder {\n /** The HTTP content type of the encoder */\n contentType: string;\n\n /**\n * Encodes the given payload into a binary representation.\n *\n * @param payload - The payload to encode.\n * @returns An ArrayBuffer containing the encoded payload.\n */\n encode: (payload: unknown) => ArrayBuffer;\n\n /**\n * Decodes the given binary representation into a type checked payload.\n *\n * @param data - The data to decode.\n * @param schema - The schema to decode the data with.\n */\n decode: <P>(data: Uint8Array | ArrayBuffer, schema?: ZodSchema<P>) => P;\n}\n\n/** JSONEncoderDecoder is a JSON implementation of EncoderDecoder. */\nexport class JSONEncoderDecoder implements EncoderDecoder {\n contentType = \"application/json\";\n readonly decoder: TextDecoder;\n\n constructor() {\n this.decoder = new TextDecoder();\n }\n\n encode(payload: unknown): ArrayBuffer {\n const json = JSON.stringify(Case.toSnake(payload), (_, v) => {\n if (ArrayBuffer.isView(v)) return Array.from(v as Uint8Array);\n if (isObject(v) && \"encode_value\" in v) {\n if (typeof v.value === \"bigint\") return v.value.toString();\n return v.value;\n }\n if (typeof v === \"bigint\") return v.toString();\n return v;\n });\n return new TextEncoder().encode(json);\n }\n\n decode<P extends z.ZodTypeAny>(\n data: Uint8Array | ArrayBuffer,\n schema?: P,\n ): z.output<P> {\n const unpacked = Case.toCamel(JSON.parse(this.decoder.decode(data)));\n return schema != null ? schema.parse(unpacked) : (unpacked as P);\n }\n\n static registerCustomType(): void {}\n}\n\nexport const ENCODERS: EncoderDecoder[] = [new JSONEncoderDecoder()];\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Destructor } from \"@/destructor\";\n\nexport type Handler<T> = (value: T) => void;\n\nexport interface Observable<T> {\n onChange: (handler: Handler<T>) => Destructor;\n}\n\nexport class Observer<T> implements Observable<T> {\n private readonly handlers: Map<Handler<T>, null>;\n\n constructor(handlers?: Map<Handler<T>, null>) {\n this.handlers = handlers ?? new Map();\n }\n\n onChange(handler: Handler<T>): Destructor {\n this.handlers.set(handler, null);\n return () => this.handlers.delete(handler);\n }\n\n notify(value: T): void {\n this.handlers.forEach((_, handler) => handler(value));\n }\n}\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { z } from \"zod\";\n\nexport type Variant = \"set\" | \"delete\";\n\nexport const Z = <V extends z.ZodTypeAny>(value: V) =>\n z.object({\n variant: z.enum([\"set\", \"delete\"]),\n key: z.string(),\n value,\n });\n\nexport type Set<K, V> = {\n variant: \"set\";\n key: K;\n value: V;\n};\n\nexport type Delete<K, V> = {\n variant: \"delete\";\n key: K;\n value?: V;\n};\n\nexport type Change<K, V> = Set<K, V> | Delete<K, V>;","\n// Copyright 2024 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nexport const shallowCopy = <T extends unknown>(obj: T): T => {\n if (Array.isArray(obj)) return [...obj] as T;\n if (typeof obj === \"object\" && obj !== null) return { ...obj } as T;\n return obj;\n}\n","export const invert = (condition: boolean): -1 | 1 => (condition ? -1 : 1);\n","import { z } from \"zod\";\n\nimport { compare } from \"@/compare\";\n\nexport const semVerZ = z.string().regex(/^\\d+\\.\\d+\\.\\d+$/);\n\nexport type SemVer = z.infer<typeof semVerZ>;\n\nconst compareSemVer: compare.CompareF<string> = (a, b) => {\n const semA = semVerZ.parse(a);\n const semB = semVerZ.parse(b);\n const [aMajor, aMinor, aPatch] = semA.split(\".\").map(Number);\n const [bMajor, bMinor, bPatch] = semB.split(\".\").map(Number);\n if (aMajor !== bMajor) return aMajor - bMajor;\n if (aMinor !== bMinor) return aMinor - bMinor;\n return aPatch - bPatch;\n};\n\nconst semVerNewer = (a: SemVer, b: SemVer): boolean =>\n compare.isGreaterThan(compareSemVer(a, b));\n\nexport const migratable = z.object({\n version: semVerZ,\n});\n\nexport interface Migratable extends z.infer<typeof migratable> {}\n\nexport type Migration<I = unknown, O = unknown> = (\n migratable: Migratable & I,\n) => Migratable & O;\n\nexport type Migrations = Record<string, Migration<any, any>>;\n\nexport const migrator = <I = unknown, O = unknown>(\n migrations: Migrations,\n): Migration<I, O> => {\n const latestVersion = Object.keys(migrations).sort(compareSemVer).pop() ?? \"\";\n const migLength = Object.keys(migrations).length;\n const f = (old: Migratable): Migratable => {\n if (migLength === 0 || semVerNewer(old.version, latestVersion)) return old;\n const version = old.version;\n const migration = migrations[version];\n const new_: Migratable = migration(old);\n return f(new_);\n };\n return f as unknown as Migration<I, O>;\n};\n"],"names":["urlAlphabet","nanoid","size","id","i","isStringer","value","primitiveIsZero","newF","v","reverse","t","f","a","b","reverseF","newFieldF","key","primitiveArrays","unorderedPrimitiveArrays","compareF","aSorted","bSorted","order","EQUAL","LESS_THAN","GREATER_THAN","isLessThan","n","isGreaterThan","isGreaterThanEqual","util","val","assertIs","_arg","assertNever","_x","items","obj","item","validKeys","k","filtered","e","object","keys","arr","checker","joinValues","array","separator","_","objectUtil","first","second","ZodParsedType","getParsedType","data","ZodIssueCode","quotelessJson","ZodError","issues","sub","subs","actualProto","_mapper","mapper","issue","fieldErrors","processError","error","curr","el","formErrors","errorMap","_ctx","message","overrideErrorMap","setErrorMap","map","getErrorMap","makeIssue","params","path","errorMaps","issueData","fullPath","fullIssue","errorMessage","maps","m","EMPTY_PATH","addIssueToContext","ctx","x","ParseStatus","status","results","arrayValue","INVALID","pairs","syncPairs","pair","finalObject","DIRTY","OK","isAborted","isDirty","isValid","isAsync","errorUtil","ParseInputLazyPath","parent","handleResult","result","processCreateParams","invalid_type_error","required_error","description","iss","ZodType","def","input","_a","maybeAsyncResult","check","getIssueProperties","setError","refinementData","refinement","ZodEffects","ZodFirstPartyTypeKind","ZodOptional","ZodNullable","ZodArray","ZodPromise","option","ZodUnion","incoming","ZodIntersection","transform","defaultValueFunc","ZodDefault","ZodBranded","catchValueFunc","ZodCatch","This","target","ZodPipeline","ZodReadonly","cuidRegex","cuid2Regex","ulidRegex","uuidRegex","emailRegex","_emojiRegex","emojiRegex","ipv4Regex","ipv6Regex","datetimeRegex","args","isValidIP","ip","version","ZodString","tooBig","tooSmall","regex","validation","options","minLength","maxLength","len","ch","min","max","floatSafeRemainder","step","valDecCount","stepDecCount","decCount","valInt","stepInt","ZodNumber","kind","inclusive","ZodBigInt","ZodBoolean","ZodDate","minDate","maxDate","ZodSymbol","ZodUndefined","ZodNull","ZodAny","ZodUnknown","ZodNever","ZodVoid","schema","deepPartialify","ZodObject","newShape","fieldSchema","ZodTuple","shape","shapeKeys","extraKeys","keyValidator","unknownKeys","catchall","_b","_c","_d","defaultError","augmentation","merging","index","mask","newField","createZodEnum","handleResults","unionErrors","childCtx","dirty","types","getDiscriminator","type","ZodLazy","ZodLiteral","ZodEnum","ZodNativeEnum","ZodDiscriminatedUnion","discriminator","discriminatorValue","optionsMap","discriminatorValues","mergeValues","aType","bType","bKeys","sharedKeys","newObj","sharedValue","newArray","itemA","itemB","handleParsed","parsedLeft","parsedRight","merged","left","right","itemIndex","rest","schemas","ZodRecord","keyType","valueType","third","ZodMap","finalMap","ZodSet","finalizeSet","elements","parsedSet","element","minSize","maxSize","ZodFunction","makeArgsIssue","makeReturnsIssue","returns","fn","me","parsedArgs","parsedReturns","returnType","func","getter","values","expectedValues","enumValues","opt","nativeEnumValues","promisified","effect","checkCtx","arg","processed","executeRefinement","acc","inner","base","preprocess","newCtx","ZodNaN","BRAND","inResult","custom","fatal","p","_fatal","p2","late","instanceOfType","cls","stringType","numberType","nanType","bigIntType","booleanType","dateType","symbolType","undefinedType","nullType","anyType","unknownType","neverType","voidType","arrayType","objectType","strictObjectType","unionType","discriminatedUnionType","intersectionType","tupleType","recordType","mapType","setType","functionType","lazyType","literalType","enumType","nativeEnumType","promiseType","effectsType","optionalType","nullableType","preprocessType","pipelineType","ostring","onumber","oboolean","coerce","NEVER","z","numberCouple","dimensions","signedDimensions","DIMENSIONS","ALIGNMENTS","SIGNED_DIMENSIONS","xy","clientXY","DIRECTIONS","direction","OUTER_LOCATIONS","outerLocation","X_LOCATIONS","xLocation","Y_LOCATIONS","yLocation","CENTER_LOCATIONS","centerlocation","LOCATIONS","location","alignment","ORDERS","bounds","crudeDirection","crudeLocation","construct","lower","upper","makeValid","ZERO","INFINITE","DECIMAL","CLIP","equals","clamp","_bounds","contains","_target","overlapsWith","span","isZero","spanIsZero","isFinite","constructArray","findInsertPosition","ZERO_PLAN","buildInsertionPlan","deleteInBetween","insertInto","removeBefore","insert","plan","crude","c","swap","dimension","isDirection","signedDimension","jsCamelcase","toCamelCase","str","jsSnakecase","toSnakeCase","jsPascalcase","toPascalCase","jsDotcase","toDotCase","jsPathcase","toPathCase","jsTextcase","toTextCase","jsSentencecase","toSentenceCase","textcase","jsHeadercase","toHeaderCase","jsKebabcase","toKebabCase","exports","Type","__spreadArrays","this","s","il","r","j","jl","lowercaseKeysObject","utils_1","require$$0","lowerKeys","res","nkey","ret","temp","uppercaseKeysObject","upperKeys","camelcaseKeysObject","js_camelcase_1","require$$1","camelKeys","snakecaseKeysObject","js_snakecase_1","snakeKeys","pascalcaseKeysObject","js_pascalcase_1","pascalKeys","kebabcaseKeysObject","js_kebabcase_1","kebabKeys","lib","require$$2","js_dotcase_1","require$$3","js_pathcase_1","require$$4","js_textcase_1","require$$5","js_sentencecase_1","require$$6","js_headercase_1","require$$7","require$$8","lowercase_keys_object_1","require$$9","uppercase_keys_object_1","require$$10","camelcase_keys_object_1","require$$11","snakecase_keys_object_1","require$$12","pascalcase_keys_object_1","require$$13","kebabcase_keys_object_1","require$$14","toLowerCase","toUpperCase","jsConvert","jsConvertCase","entity","_snakeKeys","_camelKeys","Case","y","SWAPPED","ROTATE_90","cl","rotate90","l","corner","TOP_LEFT","TOP_RIGHT","BOTTOM_LEFT","BOTTOM_RIGHT","CENTER","TOP_CENTER","BOTTOM_CENTER","RIGHT_CENTER","LEFT_CENTER","XY_LOCATIONS","xyEquals","xyMatches","ok","xyCouple","isX","isY","xyToString","constructXY","parsedX","parsedY","crudeZ","ONE","INFINITY","NAN","threshold","a_","b_","scale","translateX","translateY","translate","cb","set","distance","ca","xDistance","yDistance","translation","isNan","couple","css","truncate","precision","cssPos","box","xy.xy","location.corner","xy.ZERO","location.TOP_LEFT","xy.ONE","location.BOTTOM_LEFT","copy","root","width","height","coordinateRoot","resize","dims","amount","dir","direction.construct","top","bottom","xy.equals","location.xyEquals","signedDims","signedWidth","signedHeight","dim","signed","xyLoc","center","loc","location.xyCouple","location.X_LOCATIONS","locPoint","loc_","topLeft","topRight","location.TOP_RIGHT","bottomLeft","bottomRight","location.BOTTOM_RIGHT","xy.translate","xBounds","yBounds","reRoot","positionSoVisible","target_","bound_","bound","nextPos","xy.construct","positionInCenter","x_","y_","isBox","aspect","intersect","x2","y2","area","xy.truncate","constructWithAlternateRoot","currRoot","newRoot","svgViewBox","factor","crudeXYTransform","xy.crudeZ","curriedTranslate","currScale","curriedMagnify","magnify","_type","curriedScale","prevLower","prevUpper","nextLower","nextUpper","prevRange","nextRange","nextV","curriedReBound","curriedInvert","curriedClamp","_Scale","__publicField","lowerOrBound","next","bounds.construct","vt","op","swaps","low","high","nextScale","Scale","xyScaleToTransform","_XY","cp","_xy","prevRoot","box.xBounds","box.yBounds","box.construct","XY","posititonSoVisible","innerWidth","innerHeight","changed","nextXY","xy.translateX","xy.translateY","parseLocationOptions","initial","parsedXYLoc","location.xy","parsedLoc","location.location","dialog","containerCrude","targetCrude","dialogCrude","prefer","alignments","disable","initialLocs","location.XY_LOCATIONS","parsedPrefer","hasPreferA","location.xyMatches","hasPreferB","mappedOptions","location.CENTER","d","container","bestOptionArea","adjustedBox","evaluateOption","getRoot","targetPoint","box.xyLoc","dialogBox","box.constructWithAlternateRoot","box.width","box.height","box.area","box.intersect","X_ALIGNMENT_MAP","Y_ALIGNMENT_MAP","out","location.swap","swapper","remainder","divisor","ts","TimeStamp","TimeSpan","_TimeStamp","tzInfo","offset","year","month","day","date","time","hours","minutes","mbeSeconds","seconds","milliseconds","format","iso","other","TimeRange","timestamps","_TimeSpan","totalDays","totalHours","totalMinutes","totalSeconds","totalMilliseconds","totalMicroseconds","totalNanoseconds","days","microseconds","nanoseconds","_Rate","duration","density","Density","sampleCount","Rate","_Density","Size","_TimeRange","start","end","rng","_DataType","DataType","_Size","totalTB","totalGB","totalMB","totalKB","totalB","tb","gb","mb","kb","bytes","typedArrayZ","isTelemValue","ot","convertDataType","source","addSamples","isCrudeSeries","Series","FULL_BUFFER","props","dataType","timeRange","sampleOffset","glBufferUsage","isSingle","isArray","data_","length","rate","buffer","gl","available","toWrite","den","update","required","slice","cf","compare.newF","mid","cmp","bufferUsage","prevBuffer","byteOffset","jsType","StringSeriesIterator","JSONSeriesIterator","FixedSeriesIterator","series","wrapped","MultiSeries","ser","buf","MultiSeriesIterator","unknownRecordZ","getEntries","convertRenderV","isObject","detect","RUNTIME","OPERATING_SYSTEMS","osZ","os","evalOS","userAgent","getOS","force","default_","deleteD","get","allowNull","parts","part","join","has","merge","objects","equal","aIsArray","bIsArray","aArr","bArr","aKeys","aVal","bVal","partialEqual","partial","baseKeys","partialKeys","baseVal","partialVal","memo","prevArgs","prevResult","difference","obj1","obj2","diffMap","compare","currentPath","debounce","waitFor","timeout","throttle","unique","joinPaths","paths","formatPath","removeTrailingSlash","buildQueryString","request","prefix","URL$1","host","port","protocol","pathPrefix","toArray","nullToArr","binary","Search","RoutedWorker","send","handler","typedSend","TypedWorker","payload","transfer","createMockWorkers","aSend","bSend","JSONEncoderDecoder","json","unpacked","ENCODERS","Observer","handlers","Z","shallowCopy","invert","condition","semVerZ","compareSemVer","semA","semB","aMajor","aMinor","aPatch","bMajor","bMinor","bPatch","semVerNewer","compare.isGreaterThan","migratable","migrator","migrations","latestVersion","migLength","old","migration","new_"],"mappings":"4PAAA,IAAIA,GACF,mEAWEC,GAAS,CAACC,EAAO,KAAO,CAC1B,IAAIC,EAAK,GACLC,EAAIF,EACR,KAAOE,KACLD,GAAMH,GAAa,KAAK,OAAQ,EAAG,GAAM,CAAC,EAE5C,OAAOG,CACT,ECKa,MAAAE,GAAcC,GACzBA,GAAS,MAAQ,OAAOA,GAAU,UAAY,aAAcA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