/* global React */
// ============================================================
// AIVO INTAKE FORM — Bilingual layer (English default / Hindi)
// ------------------------------------------------------------
// Single English->Hindi dictionary. tr(s) returns the Hindi
// string when language is "hi", otherwise the English original.
// Plan NAMES and input PLACEHOLDERS are intentionally NOT here
// (they stay English in both languages).
// ============================================================

const HI = {
  // ── Structural / chrome ──
  "Section": "खंड",
  "of": "/",
  "(Optional)": "(वैकल्पिक)",

  // ── Header ──
  "Registration confirmed": "रजिस्ट्रेशन पक्का हुआ",
  "Let's build your website.": "चलिए आपकी वेबसाइट बनाते हैं।",
  "Thank you.": "धन्यवाद।",
  "Step one": "पहला कदम",
  "Choose your plan": "अपना प्लान चुनें",

  // ── Plan descriptions (names stay English) ──
  "Clean, professional website — live in 3 days": "साफ़-सुथरी, प्रोफेशनल वेबसाइट — 3 दिन में लाइव",
  "SEO, social media, Google visibility": "SEO, सोशल मीडिया, Google पर पहचान",
  "Online store or booking system": "ऑनलाइन स्टोर या बुकिंग सिस्टम",
  "★ Most popular": "★ सबसे लोकप्रिय",
  "one-time": "एक बार",
  "Selected": "चुना गया",
  "Choose this plan": "यह प्लान चुनें",

  // ── Submit / ack / reassure ──
  "Submitting…": "सबमिट हो रहा है…",
  "Submit my details": "मेरी जानकारी सबमिट करें",
  "No spam, no pressure. Your details are used only to build your website.": "कोई स्पैम नहीं, कोई दबाव नहीं। आपकी जानकारी सिर्फ़ आपकी वेबसाइट बनाने के लिए इस्तेमाल होगी।",

  // ── Errors ──
  "Please upload your logo.": "कृपया अपना लोगो अपलोड करें।",
  "Please fill this in to continue.": "आगे बढ़ने के लिए कृपया यह भरें।",

  // ── Success screen ──
  "We've got everything we need.": "हमें वो सब मिल गया जो चाहिए था।",
  "Your details are received. We'll begin building your website preview — it will be ready within 3 days.": "आपकी जानकारी मिल गई है। हम आपकी वेबसाइट का प्रीव्यू बनाना शुरू कर रहे हैं — यह 3 दिन में तैयार हो जाएगा।",
  "Book your 15-minute preview call below. Pick any slot that works — the earliest available is 6 hours from now.": "नीचे अपनी 15-मिनट की प्रीव्यू कॉल बुक करें। जो भी समय सही लगे वो चुनें — सबसे जल्दी उपलब्ध समय अभी से 6 घंटे बाद है।",
  "Book my preview call": "मेरी प्रीव्यू कॉल बुक करें",
  "Questions? Message us on WhatsApp →": "कोई सवाल? हमें WhatsApp पर मैसेज करें →",

  // ── Options ──
  "Hindi": "हिंदी",
  "Both": "दोनों",
  "Yes": "हाँ",
  "No": "नहीं",
  "Show some prices": "कुछ कीमतें दिखाएं",
  "Yes — I want a payment option on the site": "हाँ — मुझे साइट पर पेमेंट का विकल्प चाहिए",
  "No — not needed": "नहीं — ज़रूरत नहीं",
  "Online store — I sell products": "ऑनलाइन स्टोर — मैं प्रोडक्ट बेचता/बेचती हूँ",
  "Booking system — customers book appointments": "बुकिंग सिस्टम — ग्राहक अपॉइंटमेंट बुक करते हैं",
  "Yes, I'll upload them": "हाँ, मैं अपलोड करूँगा/करूँगी",
  "No, you'll source them": "नहीं, आप इंतज़ाम करें",
  "Yes — set up a store": "हाँ — एक स्टोर बनाएं",
  "No — just showcase my products": "नहीं — सिर्फ़ मेरे प्रोडक्ट दिखाएं",
  "Not sure yet — advise me": "अभी तय नहीं — आप सलाह दें",
  "Morning (9am–12pm)": "सुबह (9–12 बजे)",
  "Afternoon (12pm–4pm)": "दोपहर (12–4 बजे)",
  "Evening (4pm–10pm)": "शाम (4–10 बजे)",
  "Any time": "कोई भी समय",
  "Monday": "सोमवार",
  "Tuesday": "मंगलवार",
  "Wednesday": "बुधवार",
  "Thursday": "गुरुवार",
  "Friday": "शुक्रवार",
  "Saturday": "शनिवार",
  "Sunday": "रविवार",

  // ── Section 1 — Business basics ──
  "Your business": "आपका व्यवसाय",
  "Tell us about your business": "अपने व्यवसाय के बारे में बताएं",
  "Business name": "व्यवसाय का नाम",
  "Exactly as you want it shown on the site.": "जैसा आप साइट पर दिखाना चाहते हैं, बिल्कुल वैसा ही।",
  "Business type / category": "व्यवसाय का प्रकार / श्रेणी",
  "City": "शहर",
  "Full address": "पूरा पता",
  "Tagline": "टैगलाइन",
  "Short phrase describing the business. Leave blank if none.": "व्यवसाय को बताने वाला छोटा वाक्य। न हो तो खाली छोड़ें।",
  "Year established": "स्थापना का वर्ष",
  "About your business": "अपने व्यवसाय के बारे में",
  "Tell us what you do, who you serve, and what makes your business special. Write it like you'd tell a friend.": "बताएं कि आप क्या करते हैं, किसके लिए करते हैं, और आपके व्यवसाय में खास क्या है। जैसे किसी दोस्त को बताते, वैसे ही लिखें।",

  // ── Section 2 — Contact ──
  "Contact details": "संपर्क जानकारी",
  "How should customers reach you?": "ग्राहक आप तक कैसे पहुँचें?",
  "These details will appear on your website — use the ones you want public.": "ये जानकारी आपकी वेबसाइट पर दिखेगी — वही दें जो आप सार्वजनिक रखना चाहते हैं।",
  "WhatsApp number": "WhatsApp नंबर",
  "Phone number": "फ़ोन नंबर",
  "Same as WhatsApp or a different number.": "WhatsApp जैसा ही या कोई अलग नंबर।",
  "Email address": "ईमेल पता",
  "The one you want on the website.": "जो आप वेबसाइट पर रखना चाहते हैं।",
  "Google Maps location": "Google Maps लोकेशन",
  "Paste the Google Maps link to your business — we'll add a map and a 'Get directions' button to your site.": "अपने व्यवसाय का Google Maps लिंक पेस्ट करें — हम आपकी साइट पर एक नक्शा और 'रास्ता दिखाएं' बटन जोड़ देंगे।",
  "Preferred website language": "वेबसाइट की पसंदीदा भाषा",

  // ── Section 3 — Services ──
  "What you offer": "आप क्या देते हैं",
  "What do you sell or offer?": "आप क्या बेचते या ऑफर करते हैं?",
  "List your main services or products": "अपनी मुख्य सेवाएं या प्रोडक्ट लिखें",
  "One per line.": "एक लाइन में एक।",
  "Your most popular or flagship service": "आपकी सबसे लोकप्रिय या मुख्य सेवा",
  "The one thing you're best known for.": "वो एक चीज़ जिसके लिए आप सबसे ज़्यादा जाने जाते हैं।",
  "Do you want prices shown on the website?": "क्या आप वेबसाइट पर कीमतें दिखाना चाहते हैं?",
  "List services with prices": "सेवाएं कीमतों के साथ लिखें",

  // ── Section 4 — Differentiator ──
  "Your edge": "आपकी ख़ासियत",
  "Why do customers choose you?": "ग्राहक आपको क्यों चुनते हैं?",
  "What sets you apart from others?": "आपको दूसरों से अलग क्या बनाता है?",
  "What do your regulars say? What do you do better?": "आपके नियमित ग्राहक क्या कहते हैं? आप क्या बेहतर करते हैं?",
  "Years of experience": "अनुभव के वर्ष",
  "Approx. clients served": "लगभग कितने ग्राहक संभाले",
  "Awards, certifications, or recognitions": "पुरस्कार, सर्टिफिकेट या सम्मान",
  "Local media, certifications, anything notable.": "स्थानीय मीडिया, सर्टिफिकेट, या कोई भी ख़ास बात।",
  "Testimonials or reviews to include": "शामिल करने के लिए ग्राहक की राय या रिव्यू",
  "Paste a quote or review from a happy customer.": "किसी खुश ग्राहक की बात या रिव्यू यहाँ पेस्ट करें।",

  // ── Section 5 — Customers ──
  "Your customers": "आपके ग्राहक",
  "Who comes to you?": "आपके पास कौन आता है?",
  "Who is your typical customer?": "आपका आम ग्राहक कौन है?",
  "Age, type — e.g. \"Married women 25–45 in our locality\" or \"College students\".": "उम्र, तरह — जैसे \"हमारे इलाके की 25–45 साल की महिलाएं\" या \"कॉलेज के छात्र\"।",
  "What problem do they come to you to solve?": "वे किस समस्या को हल करने आपके पास आते हैं?",
  "The main reason someone calls or walks in.": "किसी के कॉल करने या आने की मुख्य वजह।",

  // ── Section 6 — Visuals ──
  "Photos & brand": "फ़ोटो और ब्रांड",
  "Help us make it look like you": "इसे आपके जैसा दिखाने में हमारी मदद करें",
  "Logo file": "लोगो फ़ाइल",
  "Upload your logo": "अपना लोगो अपलोड करें",
  "Upload your logo so we can place it on your website.": "अपना लोगो अपलोड करें ताकि हम इसे आपकी वेबसाइट पर लगा सकें।",
  "Growth and Custom clients — a custom logo is included in your plan. Already have one you'd like us to use? Upload it here.": "Growth और Custom ग्राहकों के प्लान में कस्टम लोगो शामिल है। पहले से कोई लोगो है जिसे आप इस्तेमाल करवाना चाहते हैं? यहाँ अपलोड करें।",
  "Photos — shop, team, products, interior": "फ़ोटो — दुकान, टीम, प्रोडक्ट, अंदर का नज़ारा",
  "Add photos": "फ़ोटो जोड़ें",
  "Don't have any? No problem — we'll source visuals for you.": "कोई फ़ोटो नहीं है? कोई बात नहीं — हम आपके लिए तस्वीरें जुटा लेंगे।",
  "Brand colors": "ब्रांड के रंग",
  "2–3 websites you like the look of": "2–3 वेबसाइट जिनका लुक आपको पसंद है",
  "Links only — doesn't have to be your industry, just styles you like.": "सिर्फ़ लिंक — ज़रूरी नहीं कि आपके ही क्षेत्र की हों, बस जो स्टाइल पसंद हो।",

  // ── Section 7 — Social ──
  "Social media": "सोशल मीडिया",
  "Where else are you online?": "आप और कहाँ ऑनलाइन हैं?",
  "Share whatever you have — leave blank what you don't.": "जो भी हो साझा करें — जो नहीं है उसे खाली छोड़ दें।",
  "Instagram handle": "Instagram हैंडल",
  "Facebook page link": "Facebook पेज लिंक",
  "Google Business Profile link": "Google Business Profile लिंक",
  "The Google Maps link to your listing.": "आपकी लिस्टिंग का Google Maps लिंक।",
  "Any other platform": "कोई और प्लेटफ़ॉर्म",

  // ── Section 8a — Features ──
  "Your website features": "आपकी वेबसाइट की सुविधाएं",
  "A few more things for your plan": "आपके प्लान के लिए कुछ और बातें",
  "Do you want a photo gallery section?": "क्या आपको फ़ोटो गैलरी सेक्शन चाहिए?",
  "What should the gallery show?": "गैलरी में क्या दिखना चाहिए?",
  "Do you accept online payments from customers?": "क्या आप ग्राहकों से ऑनलाइन पेमेंट लेते हैं?",
  "Which payment method?": "कौन सा पेमेंट तरीका?",

  // ── Online store (growth) ──
  "Online store": "ऑनलाइन स्टोर",
  "Want to sell your products online?": "अपने प्रोडक्ट ऑनलाइन बेचना चाहते हैं?",
  "Your Growth plan can include a simple online store. Tell us if you'd like one — leave it if you only want to showcase your work.": "आपके Growth प्लान में एक आसान ऑनलाइन स्टोर शामिल हो सकता है। बताएं कि आपको चाहिए या नहीं — अगर सिर्फ़ अपना काम दिखाना है तो छोड़ दें।",
  "Do you want to sell products online through your website?": "क्या आप अपनी वेबसाइट से प्रोडक्ट ऑनलाइन बेचना चाहते हैं?",
  "List your products": "अपने प्रोडक्ट लिखें",
  "Or upload a product list": "या प्रोडक्ट की सूची अपलोड करें",
  "Upload Excel / CSV sheet": "Excel / CSV शीट अपलोड करें",
  "Have a lot of products? Upload a sheet with names, prices and descriptions instead of typing them all out.": "बहुत सारे प्रोडक्ट हैं? सब टाइप करने के बजाय नाम, कीमत और विवरण वाली शीट अपलोड कर दें।",
  "Do you have product photos?": "क्या आपके पास प्रोडक्ट की फ़ोटो हैं?",
  "Product photo upload": "प्रोडक्ट फ़ोटो अपलोड",

  // ── Section 8b — Custom ──
  "Your custom requirements": "आपकी कस्टम ज़रूरतें",
  "Let's understand your custom build": "चलिए आपका कस्टम प्रोजेक्ट समझते हैं",
  "What do you need?": "आपको क्या चाहिए?",
  "Services that can be booked": "जो सेवाएं बुक की जा सकती हैं",
  "Your availability": "आपकी उपलब्धता",
  "Any other requirements": "कोई और ज़रूरत",
  "Anything else — custom features, integrations, special requests.": "और कुछ भी — कस्टम सुविधाएं, इंटीग्रेशन, खास अनुरोध।",

  // ── Shared product helpers ──
  "Product name — price — brief description, one per line.": "प्रोडक्ट का नाम — कीमत — छोटा विवरण, एक लाइन में एक।",
  "Service name — duration — price.": "सेवा का नाम — समय — कीमत।",

  // ── Section 9 — Scheduling ──
  "Preview call": "प्रीव्यू कॉल",
  "When would you like your preview call?": "आप अपनी प्रीव्यू कॉल कब चाहेंगे?",
  "Once you submit, we build your website within 3 days. You'll then get a Calendly link to book your 15-minute preview call. These questions just help us know roughly when you prefer.": "सबमिट करते ही हम 3 दिन में आपकी वेबसाइट बनाते हैं। फिर आपको 15-मिनट की प्रीव्यू कॉल बुक करने के लिए एक Calendly लिंक मिलेगा। ये सवाल बस यह जानने के लिए हैं कि आपको मोटे तौर पर कब सही रहेगा।",
  "Preferred days": "पसंदीदा दिन",
  "Preferred time of day": "दिन का पसंदीदा समय",
};

// Module-level current language. App syncs this every render via useLang().
let _lang = (typeof localStorage !== "undefined" && localStorage.getItem("aivo_lang")) || "en";

function setLang(l) { _lang = l; }

// translate: returns Hindi when active, English original otherwise. Safe for undefined.
function translate(s) {
  if (s == null) return s;
  if (_lang === "hi") return HI[s] || s;
  return s;
}

// React hook: language state + persistence. Keeps _lang in sync during render.
function useLang() {
  const [lang, setLangState] = React.useState(_lang);
  setLang(lang); // sync before children render
  React.useEffect(() => {
    try { localStorage.setItem("aivo_lang", lang); } catch (e) {}
    document.documentElement.lang = lang;
  }, [lang]);
  return [lang, setLangState];
}

// Segmented EN / हिंदी switcher
function LangToggle({ lang, onChange }) {
  return (
    <div className="lang-toggle" role="group" aria-label="Language / भाषा">
      <button type="button" className={"lang-opt" + (lang === "en" ? " is-on" : "")} onClick={() => onChange("en")} aria-pressed={lang === "en"}>English</button>
      <button type="button" className={"lang-opt" + (lang === "hi" ? " is-on" : "")} onClick={() => onChange("hi")} aria-pressed={lang === "hi"}>हिंदी</button>
    </div>
  );
}

Object.assign(window, { translate, setLang, useLang, LangToggle });
