{"version":3,"file":"countdown-timer.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/countdown-timer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAElD,qBAAa,cAAc;IAMzB,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,QAAQ;IAPjB,OAAO,CAAC,UAAU,CAA6C;IAC/D,OAAO,CAAC,gBAAgB,CAAS;IAEjC,YACC,SAAS,EAAE,MAAM,EACT,GAAG,EAAE,GAAG,GAAG,SAAS,EACpB,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,EACjC,QAAQ,EAAE,MAAM,IAAI,EAe5B;IAED,OAAO,IAAI,IAAI,CAKd;CACD","sourcesContent":["/**\n * Reusable countdown timer for dialog components.\n */\n\nimport type { TUI } from \"@earendil-works/pi-tui\";\n\nexport class CountdownTimer {\n\tprivate intervalId: ReturnType<typeof setInterval> | undefined;\n\tprivate remainingSeconds: number;\n\n\tconstructor(\n\t\ttimeoutMs: number,\n\t\tprivate tui: TUI | undefined,\n\t\tprivate onTick: (seconds: number) => void,\n\t\tprivate onExpire: () => void,\n\t) {\n\t\tthis.remainingSeconds = Math.ceil(timeoutMs / 1000);\n\t\tthis.onTick(this.remainingSeconds);\n\n\t\tthis.intervalId = setInterval(() => {\n\t\t\tthis.remainingSeconds--;\n\t\t\tthis.onTick(this.remainingSeconds);\n\t\t\tthis.tui?.requestRender();\n\n\t\t\tif (this.remainingSeconds <= 0) {\n\t\t\t\tthis.dispose();\n\t\t\t\tthis.onExpire();\n\t\t\t}\n\t\t}, 1000);\n\t}\n\n\tdispose(): void {\n\t\tif (this.intervalId) {\n\t\t\tclearInterval(this.intervalId);\n\t\t\tthis.intervalId = undefined;\n\t\t}\n\t}\n}\n"]}