{"version":3,"file":"_randomString.mjs","names":[],"sources":["../../src/internal/_randomString.ts"],"sourcesContent":["import type { OpenApi } from \"@typia/interface\";\n\nimport { _randomInteger } from \"./_randomInteger\";\n\nconst DEFAULT_MIN_LENGTH = 5;\nconst DEFAULT_RANGE = 5;\n\n/**\n * Generate a random lowercase string within the schema's length bounds.\n *\n * The default length is five to ten characters.\n *\n * The optional source supplies draws in [0, 1); it defaults to the platform\n * source resolved when this helper is called. Nested draws use the same\n * source.\n *\n * @evidence contracts/common.md#principled-implementation The length is drawn between the schema's bounds with default floor five and range five and every character is a random lowercase letter, so the result satisfies the selected length bounds. Format-specific syntax belongs to the separate format generators; this helper does not infer an unrecognized format from its lowercase alphabet.\n * @evidence contracts/common.md#clear-and-simple-design One function over the integer generator.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The alphabet and defaults are constants of the generator.\n * @evidence contracts/common.md#meaningful-documentation The doc states the alphabet and the default length.\n */\nexport const _randomString = (\n  props: OpenApi.IJsonSchema.IString,\n  source: () => number = Math.random,\n) => {\n  const minimum: number =\n    props.minLength ??\n    Math.min(props.maxLength ?? DEFAULT_MIN_LENGTH, DEFAULT_MIN_LENGTH);\n  const length: number = _randomInteger(\n    {\n      type: \"integer\",\n      minimum,\n      maximum: props.maxLength ?? minimum + DEFAULT_RANGE,\n    },\n    source,\n  );\n  return new Array(length)\n    .fill(0)\n    .map(() => ALPHABETS[random(source)])\n    .join(\"\");\n};\n\nconst ALPHABETS = \"abcdefghijklmnopqrstuvwxyz\";\n\nconst random = (source: () => number) =>\n  _randomInteger(\n    {\n      type: \"integer\",\n      minimum: 0,\n      maximum: ALPHABETS.length - 1,\n    },\n    source,\n  );\n"],"mappings":";;AAIA,MAAM,qBAAqB;AAC3B,MAAM,gBAAgB;;;;;;;;;;;;;;;AAgBtB,MAAa,iBACX,OACA,SAAuB,KAAK,WACzB;CACH,MAAM,UACJ,MAAM,aACN,KAAK,IAAI,MAAM,aAAa,oBAAoB,kBAAkB;CACpE,MAAM,SAAiB,eACrB;EACE,MAAM;EACN;EACA,SAAS,MAAM,aAAa,UAAU;CACxC,GACA,MACF;CACA,OAAO,IAAI,MAAM,MAAM,CAAC,CACrB,KAAK,CAAC,CAAC,CACP,UAAU,UAAU,OAAO,MAAM,EAAE,CAAC,CACpC,KAAK,EAAE;AACZ;AAEA,MAAM,YAAY;AAElB,MAAM,UAAU,WACd,eACE;CACE,MAAM;CACN,SAAS;CACT,SAAS;AACX,GACA,MACF"}