{"version":3,"file":"_httpFormDataReadBigint.mjs","names":[],"sources":["../../src/internal/_httpFormDataReadBigint.ts"],"sourcesContent":["/**\n * Read one form field as a bigint.\n *\n * A file passes through, blank text is absent, `null` is null and other text is\n * converted when it parses and kept as text otherwise, so the assertion rejects\n * it.\n *\n * @evidence contracts/common.md#principled-implementation A file is passed through for the validator to reject, a blank string is absent because `BigInt(\" \")` would read as zero, the text `null` is null, and other text is converted with BigInt where it parses and left as text where it does not, so the following assertion rejects it.\n * @evidence contracts/common.md#clear-and-simple-design One conditional chain and a private converter.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The blank-text rule follows the cited issue and is general.\n * @evidence contracts/common.md#meaningful-documentation A comment states the cases.\n */\nexport const _httpFormDataReadBigint = (\n  input: string | File | null,\n): bigint | null | undefined =>\n  input instanceof File\n    ? (input as any)\n    : // Blank text is absent, as the empty string always was: `BigInt(\" \")`\n      // is 0n, which would read a whitespace value as a real zero (#2448).\n      typeof input === \"string\" && input.trim().length !== 0\n      ? input === \"null\"\n        ? null\n        : (toBigint(input) as any)\n      : undefined;\n\nconst toBigint = (str: string): bigint | string => {\n  try {\n    return BigInt(str);\n  } catch {\n    return str;\n  }\n};\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAa,2BACX,UAEA,iBAAiB,OACZ,QAGD,OAAO,UAAU,YAAY,MAAM,KAAK,CAAC,CAAC,WAAW,IACnD,UAAU,SACR,OACC,SAAS,KAAK,IACjB,KAAA;AAER,MAAM,YAAY,QAAiC;CACjD,IAAI;EACF,OAAO,OAAO,GAAG;CACnB,QAAQ;EACN,OAAO;CACT;AACF"}