{"version":3,"file":"_randomFormatRegex.mjs","names":[],"sources":["../../src/internal/_randomFormatRegex.ts"],"sourcesContent":["import { _randomString } from \"./_randomString\";\nimport {\n  _ILengthProps,\n  _randomLengthPick,\n  _randomLengthWindow,\n} from \"./_randomStringLength\";\n\n/**\n * Generate a regular expression source of literal characters.\n *\n * @evidence contracts/common.md#principled-implementation Every character the string generator emits is a literal in regular expression syntax, so a string of any length, including the empty one, compiles; an unconstrained draw is a plain random string and a constrained one fixes the length first.\n * @evidence contracts/common.md#clear-and-simple-design One function.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The argument is reasoned from the alphabet.\n * @evidence contracts/common.md#meaningful-documentation An inline comment explains the literal alphabet.\n */\nexport const _randomFormatRegex = (props?: _ILengthProps): string => {\n  // Every character `_randomString` emits is a literal in regular expression\n  // syntax, so a source of any length — including the empty source `new\n  // RegExp(\"\")` accepts — compiles. An unconstrained draw is therefore an\n  // unconstrained string, and a constrained one fixes the length first.\n  if (props?.minLength === undefined && props?.maxLength === undefined)\n    return _randomString({ type: \"string\" });\n  const length: number = _randomLengthPick(\n    _randomLengthWindow(props, { minimum: 0, spread: 16 }),\n  );\n  return _randomString({\n    type: \"string\",\n    minLength: length,\n    maxLength: length,\n  });\n};\n"],"mappings":";;;;;;;;;;;AAeA,MAAa,sBAAsB,UAAkC;CAKnE,IAAI,OAAO,cAAc,KAAA,KAAa,OAAO,cAAc,KAAA,GACzD,OAAO,cAAc,EAAE,MAAM,SAAS,CAAC;CACzC,MAAM,SAAiB,kBACrB,oBAAoB,OAAO;EAAE,SAAS;EAAG,QAAQ;CAAG,CAAC,CACvD;CACA,OAAO,cAAc;EACnB,MAAM;EACN,WAAW;EACX,WAAW;CACb,CAAC;AACH"}