{"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../src/utils/sleep.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAcrE","sourcesContent":["import { MAX_TIMER_DELAY_MS } from \"@kolisachint/hoocode-ai\";\n\n/**\n * Sleep helper that respects abort signal.\n *\n * The delay is clamped, because `setTimeout` holds it in a signed 32-bit\n * integer and anything larger is not rejected but silently replaced with 1ms.\n * A caller that computed a long wait — a backoff, a server-requested\n * retry-after — would get the shortest possible one instead, turning a pause\n * into a hot loop at exactly the moment the pause mattered most. Waiting 24\n * days instead of 28 is wrong too, but it is wrong in the direction that does\n * no damage, and callers with a genuinely long wait should be declining to\n * wait rather than sleeping through it.\n */\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal?.aborted) {\n\t\t\treject(new Error(\"Aborted\"));\n\t\t\treturn;\n\t\t}\n\n\t\tconst timeout = setTimeout(resolve, Math.min(Math.max(0, ms), MAX_TIMER_DELAY_MS));\n\n\t\tsignal?.addEventListener(\"abort\", () => {\n\t\t\tclearTimeout(timeout);\n\t\t\treject(new Error(\"Aborted\"));\n\t\t});\n\t});\n}\n"]}