// กับข้าวคุณแม่ — Menu data + i18n
// Exposed on window so other Babel scripts can read them.

// ─── Translation strings ───────────────────────────────────────
const T = {
  th: {
    // brand
    brand: 'กับข้าวคุณแม่',
    tagline: 'ตำรับคุณแม่ ทำสดทุกจาน',

    // welcome
    welcome_hi: 'สวัสดีค่ะ',
    welcome_table: 'โต๊ะที่',
    welcome_start: 'เริ่มสั่งอาหาร',
    welcome_note: 'สแกน QR ที่โต๊ะแล้วเริ่มสั่งได้เลย',

    // nav
    nav_menu: 'เมนู', nav_cart: 'ตะกร้า', nav_order: 'ออเดอร์', nav_history: 'ประวัติ',

    // menu
    menu_title: 'เมนูวันนี้',
    menu_search: 'ค้นหาเมนู...',
    cat_all: 'ทั้งหมด',
    layout_grid: 'ตาราง',
    layout_list: 'รายการ',
    popular: 'ยอดนิยม',
    spicy: 'เผ็ด',

    // item detail
    format: 'เลือกรูปแบบ',
    format_rice: 'ราดข้าว',
    format_dish: 'กับข้าว',
    format_rice_sub: 'มาพร้อมข้าวสวยร้อน ๆ',
    format_dish_sub: 'จานเดียว ไม่มีข้าว',
    protein: 'เลือกเนื้อสัตว์',
    addons: 'เพิ่ม Add-on',
    spice: 'ระดับความเผ็ด',
    spice_none: 'ไม่เผ็ด',
    spice_mild: 'น้อย',
    spice_med: 'กลาง',
    spice_hot: 'มาก',
    extras: 'คำขอเพิ่มเติม',
    note_ph: 'เช่น ไม่ใส่ผัก / แยกซอส',
    qty: 'จำนวน',
    add_to_cart: 'เพิ่มลงตะกร้า',
    required: 'ต้องเลือก',
    optional: 'ไม่บังคับ',
    base_price: 'ราคาเริ่มต้น',

    // proteins
    p_pork: 'หมู', p_chicken: 'ไก่', p_beef: 'เนื้อ', p_seafood: 'ทะเล',
    p_pork_minced: 'หมูสับ',

    // add-ons (also used as keys)
    ao_fried_egg: 'ไข่ดาว',
    ao_omelet: 'ไข่เจียว',
    ao_no_veg: 'ไม่ใส่ผัก',
    ao_fish_sauce: 'รับพริกน้ำปลา',
    ao_utensils: 'รับช้อนซ่อม',
    free: 'ฟรี',

    // cart
    cart_title: 'ตะกร้าของคุณ',
    cart_empty: 'ยังไม่มีรายการในตะกร้า',
    cart_empty_sub: 'ไปเลือกเมนูที่อยากกินกันเถอะ',
    cart_browse: 'ดูเมนู',
    subtotal: 'ยอดรวม',
    service: 'ค่าบริการ',
    total: 'รวมทั้งสิ้น',
    checkout: 'สั่งซื้อ',
    remove: 'ลบ',
    edit: 'แก้ไข',

    // checkout
    checkout_title: 'ชำระเงิน',
    pay_method: 'วิธีชำระเงิน',
    pay_qr: 'QR PromptPay',
    pay_qr_sub: 'สแกนจ่ายผ่านแอปธนาคาร',
    pay_cash: 'เงินสด',
    pay_cash_sub: 'จ่ายที่เคาน์เตอร์',
    confirm: 'ยืนยันสั่งซื้อ',
    scan_qr: 'สแกนเพื่อชำระเงิน',
    amount: 'จำนวนเงิน',
    paid: 'ชำระแล้ว',
    mark_paid: 'แจ้งชำระแล้ว',

    // order status
    status_title: 'สถานะออเดอร์',
    status_received: 'รับออเดอร์',
    status_cooking: 'กำลังทำ',
    status_ready: 'เสร็จแล้ว',
    status_served: 'เสิร์ฟ',
    eta: 'เวลาที่คาด',
    order_no: 'ออเดอร์ที่',
    table: 'โต๊ะ',
    items: 'รายการ',
    receipt: 'ดูใบเสร็จ',
    order_more: 'สั่งเพิ่ม',

    // receipt
    receipt_title: 'ใบเสร็จ',
    receipt_thanks: 'ขอบคุณที่อุดหนุนค่ะ',
    receipt_no: 'เลขที่',
    receipt_date: 'วันที่',
    print: 'พิมพ์ใบเสร็จ',
    share_slip: 'แชร์สลิป',

    // history
    history_title: 'ประวัติการสั่ง',
    history_empty: 'ยังไม่มีประวัติการสั่ง',
    today: 'วันนี้',

    // misc
    baht: '฿',
    bahts: ' บาท',
    plus: '+',
    qty_short: 'x',
    back: 'ย้อนกลับ',
  },
  en: {
    brand: 'Mom\u2019s Kitchen',
    tagline: 'Mom\u2019s recipes, freshly cooked',
    welcome_hi: 'Hello',
    welcome_table: 'Table',
    welcome_start: 'Start ordering',
    welcome_note: 'Scan the QR on your table and order away.',
    nav_menu: 'Menu', nav_cart: 'Cart', nav_order: 'Order', nav_history: 'History',
    menu_title: 'Today\u2019s menu',
    menu_search: 'Search menu…',
    cat_all: 'All',
    layout_grid: 'Grid',
    layout_list: 'List',
    popular: 'Popular',
    spicy: 'Spicy',
    format: 'Choose style',
    format_rice: 'Over rice',
    format_dish: 'Side dish',
    format_rice_sub: 'Served with hot jasmine rice',
    format_dish_sub: 'Dish only, no rice',
    protein: 'Choose protein',
    addons: 'Add-ons',
    spice: 'Spice level',
    spice_none: 'None',
    spice_mild: 'Mild',
    spice_med: 'Medium',
    spice_hot: 'Hot',
    extras: 'Special requests',
    note_ph: 'e.g. no veggies / sauce on side',
    qty: 'Quantity',
    add_to_cart: 'Add to cart',
    required: 'Required',
    optional: 'Optional',
    base_price: 'From',
    p_pork: 'Pork', p_chicken: 'Chicken', p_beef: 'Beef', p_seafood: 'Seafood',
    p_pork_minced: 'Minced pork',
    ao_fried_egg: 'Fried egg',
    ao_omelet: 'Omelet',
    ao_no_veg: 'No veggies',
    ao_fish_sauce: 'Chili fish sauce',
    ao_utensils: 'Cutlery',
    free: 'Free',
    cart_title: 'Your cart',
    cart_empty: 'Your cart is empty',
    cart_empty_sub: 'Let\u2019s find something to eat.',
    cart_browse: 'Browse menu',
    subtotal: 'Subtotal',
    service: 'Service',
    total: 'Total',
    checkout: 'Checkout',
    remove: 'Remove',
    edit: 'Edit',
    checkout_title: 'Payment',
    pay_method: 'Payment method',
    pay_qr: 'QR PromptPay',
    pay_qr_sub: 'Scan via banking app',
    pay_cash: 'Cash',
    pay_cash_sub: 'Pay at the counter',
    confirm: 'Confirm order',
    scan_qr: 'Scan to pay',
    amount: 'Amount',
    paid: 'Paid',
    mark_paid: 'I have paid',
    status_title: 'Order status',
    status_received: 'Received',
    status_cooking: 'Cooking',
    status_ready: 'Ready',
    status_served: 'Served',
    eta: 'Est. time',
    order_no: 'Order',
    table: 'Table',
    items: 'items',
    receipt: 'View receipt',
    order_more: 'Order more',
    receipt_title: 'Receipt',
    receipt_thanks: 'Thank you for dining with us',
    receipt_no: 'No.',
    receipt_date: 'Date',
    print: 'Print receipt',
    share_slip: 'Share slip',
    history_title: 'Order history',
    history_empty: 'No past orders yet',
    today: 'Today',
    baht: '฿',
    bahts: ' baht',
    plus: '+',
    qty_short: 'x',
    back: 'Back',
  }
};

// ─── Categories ────────────────────────────────────────────────
const CATEGORIES = [
  { id: 'all',    th: 'ทั้งหมด',     en: 'All',         emoji: null,  c1: '#F5EBD7', c2: '#ECD9B6' },
  { id: 'pad',    th: 'ผัด',         en: 'Stir-fried',  emoji: null,  c1: '#FBE3D2', c2: '#F0C9A8' },
  { id: 'tom',    th: 'ต้ม',         en: 'Soup',        emoji: null,  c1: '#FDE6BD', c2: '#F2CE83' },
  { id: 'tod',    th: 'ทอด',         en: 'Fried',       emoji: null,  c1: '#F5E1B8', c2: '#E8C079' },
  { id: 'yum',    th: 'ยำ',          en: 'Salad',       emoji: null,  c1: '#DFE7CC', c2: '#B8C996' },
  { id: 'drink',  th: 'เครื่องดื่ม',   en: 'Drinks',      emoji: null,  c1: '#E2D6F0', c2: '#C5B0DC' },
];

// ─── Proteins (option groups) ──────────────────────────────────
const PROTEIN_FULL = [
  { id: 'pork',    key: 'p_pork',    delta: 0 },
  { id: 'chicken', key: 'p_chicken', delta: 0 },
  { id: 'beef',    key: 'p_beef',    delta: 10 },
  { id: 'seafood', key: 'p_seafood', delta: 20 },
];

const PROTEIN_MINCED_SEAFOOD = [
  { id: 'pork_minced', key: 'p_pork_minced', delta: 0 },
  { id: 'seafood',     key: 'p_seafood',     delta: 20 },
];

// ─── Menu items ────────────────────────────────────────────────
// hasFormat: true → ราดข้าว / กับข้าว toggle (raat khao adds 0; gap khao adds -5 because no rice)
// proteinGroup: which protein options
const MENU = [
  {
    id: 'kapow',
    th: 'กะเพรา', en: 'Pad Kra Pao',
    cat: 'pad', basePrice: 60, popular: true, spicy: 3,
    descTh: 'ผัดกระเพรารสจัดจ้าน ใบกะเพราหอม ๆ',
    descEn: 'Stir-fried with holy basil, garlic and chili',
    hasFormat: true, proteinGroup: 'full',
    c1: '#FBE3D2', c2: '#E08254',
  },
  {
    id: 'fried_rice',
    th: 'ข้าวผัด', en: 'Fried Rice',
    cat: 'pad', basePrice: 60, popular: true, spicy: 0,
    descTh: 'ข้าวผัดหอม ๆ ไข่ฟู หอมใหญ่ ต้นหอม',
    descEn: 'Classic fried rice with egg, onion and scallion',
    hasFormat: false, proteinGroup: 'full',
    c1: '#FBE9D2', c2: '#E8B473',
  },
  {
    id: 'pad_kratiem',
    th: 'ผัดกระเทียม', en: 'Garlic Stir-fry',
    cat: 'pad', basePrice: 60, popular: false, spicy: 1,
    descTh: 'ผัดกระเทียมเจียวหอมฟุ้ง โรยพริกไทย',
    descEn: 'Stir-fried with crispy garlic and pepper',
    hasFormat: true, proteinGroup: 'full',
    c1: '#F5E1B8', c2: '#D4A446',
  },
  {
    id: 'cabbage',
    th: 'กะหล่ำปลีผัดน้ำปลา', en: 'Cabbage in Fish Sauce',
    cat: 'pad', basePrice: 50, popular: false, spicy: 1,
    descTh: 'กะหล่ำผัดน้ำปลา หวานกรอบ กระเทียมเจียว',
    descEn: 'Wok-tossed cabbage with fish sauce and garlic',
    hasFormat: true, proteinGroup: null,
    c1: '#DFE7CC', c2: '#A2B66E',
  },
  {
    id: 'moo_korn',
    th: 'หมูก้อนทอด', en: 'Crispy Pork Bites',
    cat: 'tod', basePrice: 70, popular: true, spicy: 0,
    descTh: 'หมูสามชั้นทอดเหลือง กรอบนอกนุ่มใน',
    descEn: 'Golden-fried pork belly, crispy outside, tender inside',
    hasFormat: true, proteinGroup: null,
    c1: '#F5E1B8', c2: '#C28236',
  },
  {
    id: 'cashew_chicken',
    th: 'ไก่ผัดเม็ดมะม่วง', en: 'Cashew Chicken',
    cat: 'pad', basePrice: 80, popular: true, spicy: 2,
    descTh: 'ไก่ผัดพริกเผา เม็ดมะม่วงกรอบ ๆ หอม',
    descEn: 'Chicken stir-fried with cashews and dried chilies',
    hasFormat: true, proteinGroup: null,
    c1: '#FDE6BD', c2: '#D89738',
  },
  {
    id: 'yum_woonsen',
    th: 'ยำวุ้นเส้น', en: 'Glass Noodle Salad',
    cat: 'yum', basePrice: 70, popular: true, spicy: 3,
    descTh: 'วุ้นเส้นยำรสแซ่บ มะนาวสด พริกขี้หนู',
    descEn: 'Spicy glass noodle salad with lime and chili',
    hasFormat: false, proteinGroup: 'minced_seafood',
    c1: '#DFE7CC', c2: '#7E9847',
  },
  {
    id: 'tom_yum',
    th: 'ต้มยำ', en: 'Tom Yum',
    cat: 'tom', basePrice: 80, popular: false, spicy: 3,
    descTh: 'น้ำซุปต้มยำหอม ๆ ข่า ตะไคร้ ใบมะกรูด',
    descEn: 'Hot & sour soup with galangal, lemongrass, lime leaves',
    hasFormat: false, proteinGroup: 'minced_seafood',
    c1: '#FBE3D2', c2: '#C24B2D',
  },
  {
    id: 'tom_jued',
    th: 'ต้มจืดเต้าหู้หมูสับ', en: 'Clear Soup',
    cat: 'tom', basePrice: 60, popular: false, spicy: 0,
    descTh: 'ต้มจืดน้ำใส เต้าหู้ไข่ หมูสับ ต้นหอม',
    descEn: 'Clear soup with tofu, minced pork and scallion',
    hasFormat: false, proteinGroup: null,
    c1: '#ECDFC4', c2: '#C0A86A',
  },
  {
    id: 'thai_tea',
    th: 'ชาเย็น', en: 'Thai Iced Tea',
    cat: 'drink', basePrice: 25, popular: true, spicy: 0,
    descTh: 'ชาไทยหอม ๆ ข้น ๆ หวานมัน',
    descEn: 'Sweet creamy Thai iced tea',
    hasFormat: false, proteinGroup: null,
    c1: '#FBE0BD', c2: '#D88440',
  },
  {
    id: 'iced_coffee',
    th: 'กาแฟเย็น', en: 'Iced Coffee',
    cat: 'drink', basePrice: 30, popular: false, spicy: 0,
    descTh: 'กาแฟโบราณ หอมเข้ม หวานพอดี',
    descEn: 'Traditional Thai iced coffee',
    hasFormat: false, proteinGroup: null,
    c1: '#E8D5B7', c2: '#7A4F2A',
  },
  {
    id: 'water',
    th: 'น้ำเปล่า', en: 'Bottled water',
    cat: 'drink', basePrice: 10, popular: false, spicy: 0,
    descTh: 'น้ำดื่มเย็น ๆ ขวด 600 มล.',
    descEn: 'Chilled bottled water 600ml',
    hasFormat: false, proteinGroup: null,
    c1: '#E0EBEF', c2: '#A9C6D1',
  },
  {
    id: 'ice',
    th: 'น้ำแข็ง', en: 'Ice',
    cat: 'drink', basePrice: 3, popular: false, spicy: 0,
    descTh: 'น้ำแข็งถ้วย',
    descEn: 'Cup of ice',
    hasFormat: false, proteinGroup: null,
    c1: '#D6EEF5', c2: '#8EC8DC',
  },
];

// ─── Add-ons ───────────────────────────────────────────────────
const ADDONS = [
  { id: 'fried_egg',  key: 'ao_fried_egg',  price: 10 },
  { id: 'omelet',     key: 'ao_omelet',     price: 15 },
  { id: 'no_veg',     key: 'ao_no_veg',     price: 0 },
  { id: 'fish_sauce', key: 'ao_fish_sauce', price: 0 },
  { id: 'utensils',   key: 'ao_utensils',   price: 0 },
];

const SPICE_LEVELS = [
  { id: 'none', key: 'spice_none', icons: 0 },
  { id: 'mild', key: 'spice_mild', icons: 1 },
  { id: 'med',  key: 'spice_med',  icons: 2 },
  { id: 'hot',  key: 'spice_hot',  icons: 3 },
];

// ─── Pre-built mock order history ──────────────────────────────
// Order history visible to the diner this visit.
const MOCK_HISTORY = [
  {
    id: 'A-0421',
    date: '20 พ.ค. 2026',
    dateEn: 'May 20, 2026',
    table: 12,
    total: 245,
    items: [
      { name: { th: 'กะเพราหมู ราดข้าว', en: 'Pad Kra Pao Pork on rice' }, qty: 1, price: 65 },
      { name: { th: 'ยำวุ้นเส้นทะเล', en: 'Glass noodle salad — seafood' }, qty: 1, price: 90 },
      { name: { th: 'ไข่ดาว', en: 'Fried egg' }, qty: 2, price: 20 },
      { name: { th: 'ชาเย็น', en: 'Thai iced tea' }, qty: 2, price: 50 },
    ],
  },
  {
    id: 'A-0388',
    date: '14 พ.ค. 2026',
    dateEn: 'May 14, 2026',
    table: 5,
    total: 175,
    items: [
      { name: { th: 'ข้าวผัดไก่', en: 'Chicken fried rice' }, qty: 1, price: 60 },
      { name: { th: 'หมูก้อนทอด', en: 'Crispy pork bites' }, qty: 1, price: 70 },
      { name: { th: 'กาแฟเย็น', en: 'Iced coffee' }, qty: 1, price: 30 },
      { name: { th: 'น้ำเปล่า', en: 'Bottled water' }, qty: 1, price: 15 },
    ],
  },
];

// expose to other Babel files
Object.assign(window, {
  T, CATEGORIES, MENU, ADDONS, SPICE_LEVELS,
  PROTEIN_FULL, PROTEIN_MINCED_SEAFOOD, MOCK_HISTORY,
});
