import { Hype } from '@because/hype' import { define, stylesToCSS } from '@because/forge' import { baseStyles, initScript, theme } from '@because/toes/tools' import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs' import { join } from 'path' import type { Child } from 'hono/jsx' const TOES_DIR = process.env.TOES_DIR ?? join(process.env.HOME!, '.toes') const ENV_DIR = join(TOES_DIR, 'env') const GLOBAL_ENV_PATH = join(ENV_DIR, '_global.env') const app = new Hype({ prettyHTML: false }) const Badge = define('Badge', { base: 'span', fontSize: '11px', padding: '2px 6px', borderRadius: '3px', backgroundColor: theme('colors-bgSubtle'), color: theme('colors-textMuted'), fontFamily: theme('fonts-sans'), fontWeight: 'normal', marginLeft: '8px', }) const Button = define('Button', { base: 'button', padding: '6px 12px', fontSize: '13px', borderRadius: theme('radius-md'), border: `1px solid ${theme('colors-border')}`, backgroundColor: theme('colors-bgElement'), color: theme('colors-text'), cursor: 'pointer', states: { ':hover': { backgroundColor: theme('colors-bgHover'), }, }, }) const Container = define('Container', { fontFamily: theme('fonts-sans'), padding: '20px', paddingTop: 0, maxWidth: '800px', margin: '0 auto', color: theme('colors-text'), }) const DangerButton = define('DangerButton', { base: 'button', padding: '6px 12px', fontSize: '13px', borderRadius: theme('radius-md'), border: 'none', backgroundColor: theme('colors-error'), color: 'white', cursor: 'pointer', states: { ':hover': { opacity: 0.9, }, }, }) const EmptyState = define('EmptyState', { padding: '30px', textAlign: 'center', color: theme('colors-textMuted'), backgroundColor: theme('colors-bgSubtle'), borderRadius: theme('radius-md'), }) const EnvActions = define('EnvActions', { display: 'flex', gap: '8px', flexShrink: 0, }) const EnvItem = define('EnvItem', { padding: '12px 15px', borderBottom: `1px solid ${theme('colors-border')}`, display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '10px', states: { ':last-child': { borderBottom: 'none', }, }, }) const EnvKey = define('EnvKey', { fontFamily: theme('fonts-mono'), fontSize: '14px', fontWeight: 'bold', color: theme('colors-text'), }) const EnvList = define('EnvList', { listStyle: 'none', padding: 0, margin: 0, border: `1px solid ${theme('colors-border')}`, borderRadius: theme('radius-md'), overflow: 'hidden', }) const EnvValue = define('EnvValue', { fontFamily: theme('fonts-mono'), fontSize: '14px', color: theme('colors-textMuted'), flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', }) const ErrorBox = define('ErrorBox', { color: theme('colors-error'), padding: '20px', backgroundColor: theme('colors-bgElement'), borderRadius: theme('radius-md'), margin: '20px 0', }) const Form = define('Form', { base: 'form', display: 'flex', gap: '10px', marginTop: '15px', padding: '15px', backgroundColor: theme('colors-bgSubtle'), borderRadius: theme('radius-md'), }) const Hint = define('Hint', { fontSize: '12px', color: theme('colors-textMuted'), marginTop: '10px', }) const Input = define('Input', { base: 'input', flex: 1, padding: '8px 12px', fontSize: '14px', fontFamily: theme('fonts-mono'), borderRadius: theme('radius-md'), border: `1px solid ${theme('colors-border')}`, backgroundColor: theme('colors-bg'), color: theme('colors-text'), states: { ':focus': { outline: 'none', borderColor: theme('colors-primary'), }, }, }) const Tab = define('Tab', { base: 'a', padding: '8px 16px', fontSize: '13px', fontFamily: theme('fonts-sans'), color: theme('colors-textMuted'), textDecoration: 'none', borderBottom: '2px solid transparent', cursor: 'pointer', states: { ':hover': { color: theme('colors-text'), }, }, }) const TabActive = define('TabActive', { base: 'a', padding: '8px 16px', fontSize: '13px', fontFamily: theme('fonts-sans'), color: theme('colors-text'), textDecoration: 'none', borderBottom: `2px solid ${theme('colors-primary')}`, fontWeight: 'bold', cursor: 'default', }) const TabBar = define('TabBar', { display: 'flex', gap: '4px', borderBottom: `1px solid ${theme('colors-border')}`, marginBottom: '15px', }) interface EnvVar { key: string value: string } interface LayoutProps { title: string children: Child } const appEnvPath = (appName: string) => join(ENV_DIR, `${appName}.env`) function Layout({ title, children }: LayoutProps) { return ( {title}