Rocky_Mountain_Vending/.pnpm-store/v10/files/e0/00ec5311e9622f9578625c059ebcf83cad96f4d8bc23cef82864925ea1a9151356bef5024358abe7ec3bf8eb3eba91bc5e1b36ecca91548f0ff8cdda8ee105
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

88 lines
2 KiB
Text

'use strict';
const Prompt = require('../prompt');
const { isPrimitive, hasColor } = require('../utils');
class BooleanPrompt extends Prompt {
constructor(options) {
super(options);
this.cursorHide();
}
async initialize() {
let initial = await this.resolve(this.initial, this.state);
this.input = await this.cast(initial);
await super.initialize();
}
dispatch(ch) {
if (!this.isValue(ch)) return this.alert();
this.input = ch;
return this.submit();
}
format(value) {
let { styles, state } = this;
return !state.submitted ? styles.primary(value) : styles.success(value);
}
cast(input) {
return this.isTrue(input);
}
isTrue(input) {
return /^[ty1]/i.test(input);
}
isFalse(input) {
return /^[fn0]/i.test(input);
}
isValue(value) {
return isPrimitive(value) && (this.isTrue(value) || this.isFalse(value));
}
async hint() {
if (this.state.status === 'pending') {
let hint = await this.element('hint');
if (!hasColor(hint)) {
return this.styles.muted(hint);
}
return hint;
}
}
async render() {
let { input, size } = this.state;
let prefix = await this.prefix();
let sep = await this.separator();
let msg = await this.message();
let hint = this.styles.muted(this.default);
let promptLine = [prefix, msg, hint, sep].filter(Boolean).join(' ');
this.state.prompt = promptLine;
let header = await this.header();
let value = this.value = this.cast(input);
let output = await this.format(value);
let help = (await this.error()) || (await this.hint());
let footer = await this.footer();
if (help && !promptLine.includes(help)) output += ' ' + help;
promptLine += ' ' + output;
this.clear(size);
this.write([header, promptLine, footer].filter(Boolean).join('\n'));
this.restore();
}
set value(value) {
super.value = value;
}
get value() {
return this.cast(super.value);
}
}
module.exports = BooleanPrompt;