{"version":3,"file":"_httpQueryReadBoolean.mjs","names":[],"sources":["../../src/internal/_httpQueryReadBoolean.ts"],"sourcesContent":["/**\n * Read one query value as a boolean.\n *\n * A missing value is absent, an empty value is true, `true` and `1` are true,\n * `false` and `0` are false, `null` is null and other text is kept for the\n * assertion to reject.\n *\n * @evidence contracts/common.md#principled-implementation A missing or undefined value is absent, `null` is null, an empty value is true (a present flag), `true` and `1` are true, `false` and `0` are false and other text is returned for the validator to reject; `undefined` is treated like null so a stand-in reader does not throw.\n * @evidence contracts/common.md#clear-and-simple-design One conditional chain.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The mapping is the query contract.\n * @evidence contracts/common.md#meaningful-documentation A comment states the mapping.\n */\nexport const _httpQueryReadBoolean = (\n  str: string | null,\n): boolean | null | undefined =>\n  // `undefined` is as absent as `null`, which the contract returns; a\n  // stand-in reader that answers `undefined` must not throw on `.length`.\n  str === null || str === undefined\n    ? undefined\n    : str === \"null\"\n      ? null\n      : str.length === 0\n        ? true\n        : str === \"true\" || str === \"1\"\n          ? true\n          : str === \"false\" || str === \"0\"\n            ? false\n            : (str as any); // wrong type\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAa,yBACX,QAIA,QAAQ,QAAQ,QAAQ,KAAA,IACpB,KAAA,IACA,QAAQ,SACN,OACA,IAAI,WAAW,IACb,OACA,QAAQ,UAAU,QAAQ,MACxB,OACA,QAAQ,WAAW,QAAQ,MACzB,QACC"}