// aerOS Guest v2 — UI primitives. All take theme `C` (from buildTheme) + animate flag.
const { useState: _c2S, useEffect: _c2E, useRef: _c2R } = React;
function G2Btn({ children, onClick, C, variant = 'primary', size = 'md', full, icon, iconRight, disabled, style }) {
const [h, setH] = _c2S(false);
const sz = { sm: { h: 38, px: 15, fs: 13.5 }, md: { h: 48, px: 18, fs: 15 }, lg: { h: 56, px: 22, fs: 16.5 } }[size];
const variants = {
primary: { background: `linear-gradient(180deg, ${C.accent}, ${C.accentDark})`, color: C.accentInk, boxShadow: `0 8px 22px -8px ${C.accent}` },
soft: { background: C.accentSoft, color: C.onAccentSoft },
ghost: { background: 'transparent', color: C.ink, border: `1.5px solid ${C.line2}` },
dark: { background: C.ink, color: C.bg },
};
return (
);
}
function G2Chip({ children, active, onClick, C, icon, count }) {
return (
);
}
// Badge for chef/popular/new/spicy/signature
const BADGE_META = {
chef: { key: 'chefPick', icon: 'star', color: '#E0A82E' },
popular: { key: 'popularBadge', icon: 'flame', color: '#E0492F' },
new: { key: 'newBadge', icon: 'sparkles', color: '#3E9D6B' },
signature: { key: 'signature', icon: 'star', color: '#6C5CE0' },
spicy: { key: 'spicyBadge', icon: 'flame', color: '#E0492F' },
};
function G2Badge({ kind, t, small }) {
const m = BADGE_META[kind]; if (!m) return null;
return (
{Icon[m.icon]({ size: small ? 10 : 11 })}{t[m.key]}
);
}
// Diet dots (veg/vegan/gf/spicy)
const DIET_META = { veg: { c: '#5FAE5F', icon: 'leaf', label: 'V' }, vegan: { c: '#3E9D6B', icon: 'leaf', label: 'VG' }, gf: { c: '#C99A3E', icon: null, label: 'GF' }, spicy: { c: '#E0492F', icon: 'flame', label: null } };
function G2Diet({ ids, C, size = 'md' }) {
if (!ids || !ids.length) return null;
const s = size === 'sm' ? 18 : 22;
return (
{ids.map(id => {
const m = DIET_META[id]; if (!m) return null;
return {m.icon && !m.label ? Icon[m.icon]({ size: size === 'sm' ? 11 : 13 }) : m.label};
})}
);
}
// Photo: gradient placeholder OR for upload mode
function G2Photo({ id, color, ratio = 1, radius = 14, C, t, photoMode, icon, src, style }) {
const wrap = { position: 'relative', width: '100%', paddingTop: (1 / ratio * 100) + '%', borderRadius: radius, overflow: 'hidden', ...style };
// Real image when present (backend menu_det_img / outlet / spa image).
if (src) {
return (
);
}
if (photoMode === 'upload') {
return (
);
}
return (
{(icon || Icon.utensils)({ size: 26 })}
);
}
function G2Stepper({ value, onChange, C, min = 1, size = 'md' }) {
const s = size === 'sm' ? 30 : 36;
const btn = (label, fn, dis) => ;
return (
{btn(Icon.minus, () => onChange(Math.max(min, value - 1)), value <= min)}
{value}
{btn(Icon.plus, () => onChange(value + 1))}
);
}
// Bottom sheet
function G2Sheet({ open, onClose, C, children, full, animate = true }) {
_c2E(() => { if (!open) return; const k = e => e.key === 'Escape' && onClose(); window.addEventListener('keydown', k); return () => window.removeEventListener('keydown', k); }, [open, onClose]);
if (!open) return null;
return (
{ if (e.target === e.currentTarget) onClose(); }} style={{ position: 'absolute', inset: 0, background: 'rgba(10,8,5,0.55)', backdropFilter: 'blur(3px)', display: 'flex', alignItems: 'flex-end', zIndex: 80, animation: animate ? 'g2fade .22s ease' : 'none' }}>
);
}
function G2Toast({ msg, C }) {
if (!msg) return null;
return {Icon.checkCircle({ size: 17 })}{msg}
;
}
// segmented toggle (in-screen, e.g. language)
function G2Seg({ value, onChange, options, C }) {
return (
{options.map(([v, l]) => (
))}
);
}
// Allergen icons — simple recognizable glyphs (stroke = currentColor)
const _ai = (children) => ({ size = 18 } = {}) => React.createElement('svg', { width: size, height: size, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 1.6, strokeLinecap: 'round', strokeLinejoin: 'round' }, children);
const ALLERGEN_ICON = {
gluten: _ai([React.createElement('path', { key: 0, d: 'M12 3v18' }), React.createElement('path', { key: 1, d: 'M12 7c-2-2-4-2-4-2s0 2 2 3 2 1 2 1 0-1 0-2zM12 7c2-2 4-2 4-2s0 2-2 3-2 1-2 1' }), React.createElement('path', { key: 2, d: 'M12 12c-2-2-4-2-4-2s0 2 2 3 2 1 2 1zM12 12c2-2 4-2 4-2s0 2-2 3-2 1-2 1' }), React.createElement('path', { key: 3, d: 'M12 17c-2-2-4-2-4-2s0 2 2 3 2 1 2 1zM12 17c2-2 4-2 4-2s0 2-2 3-2 1-2 1' })]),
milk: _ai([React.createElement('path', { key: 0, d: 'M8 3h8M8 3v3l-1.5 3a3 3 0 0 0-.5 1.6V19a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V10.6a3 3 0 0 0-.5-1.6L16 6V3', transform: 'translate(-2 0)' }), React.createElement('path', { key: 1, d: 'M6 13h8', transform: 'translate(0 0)' })]),
egg: _ai([React.createElement('path', { key: 0, d: 'M12 3c3.5 0 6 5 6 9a6 6 0 0 1-12 0c0-4 2.5-9 6-9z' })]),
nuts: _ai([React.createElement('path', { key: 0, d: 'M7 8a5 5 0 0 1 10 0c0 4-2 5-2 8a3 3 0 0 1-6 0c0-3-2-4-2-8z' }), React.createElement('path', { key: 1, d: 'M9 9c1 1 5 1 6 0M9 13c1 1 5 1 6 0' })]),
fish: _ai([React.createElement('path', { key: 0, d: 'M3 12c3-4 8-5 12-5 0 0 4 2 6 5-2 3-6 5-6 5-4 0-9-1-12-5z' }), React.createElement('path', { key: 1, d: 'M3 12c-1-1-1-3-1-3M3 12c-1 1-1 3-1 3' }), React.createElement('circle', { key: 2, cx: 16, cy: 11, r: 0.6, fill: 'currentColor' })]),
soy: _ai([React.createElement('path', { key: 0, d: 'M6 6c6 0 8 4 8 8M14 14a4 4 0 1 1-8 0 4 4 0 0 1 8 0z' }), React.createElement('circle', { key: 1, cx: 16, cy: 7, r: 2.4 })]),
sesame: _ai([React.createElement('ellipse', { key: 0, cx: 8, cy: 9, rx: 2, ry: 3, transform: 'rotate(-25 8 9)' }), React.createElement('ellipse', { key: 1, cx: 15, cy: 11, rx: 2, ry: 3, transform: 'rotate(20 15 11)' }), React.createElement('ellipse', { key: 2, cx: 11, cy: 15, rx: 2, ry: 3, transform: 'rotate(-10 11 15)' })]),
shellfish: _ai([React.createElement('path', { key: 0, d: 'M6 7c4 0 9 2 12 6 1 1 0 3-2 3-5 0-11-3-11-7 0-1 1-2 1-2z' }), React.createElement('path', { key: 1, d: 'M6 7c-1-1-2-3-1-4M9 8c0-2 1-3 1-3' }), React.createElement('circle', { key: 2, cx: 8, cy: 10, r: 0.6, fill: 'currentColor' })]),
};
function G2AllergenChip({ id, t, C, onInfo }) {
const ic = ALLERGEN_ICON[((window.G2DATA.ALLERGEN_ICOKEY || {})[id]) || id] || Icon.info;
return (
{ic({ size: 17 })}
{window.G2DATA.ALLERGENS[id]}
);
}
Object.assign(window, { G2Btn, G2Chip, G2Badge, G2Diet, G2Photo, G2Stepper, G2Sheet, G2Toast, G2Seg, BADGE_META, DIET_META, ALLERGEN_ICON, G2AllergenChip });