/**
 * «سياسة الخصوصية» and «شروط الاستخدام», 13 October 2026 — the first text of the two legal pages, in both
 * languages, plus their two links in the footer.
 *
 * Everything written here is a statement about what the academy actually does today, checked against the running
 * system rather than copied from a template:
 *   - the fields really collected (name, email, mobile, the guardian's mobile, account type) are the platform's
 *     own sign-up fields; the guardian's mobile is the `parentmobile` profile field.
 *   - «ما بتروحش لأي شركة ذكاء اصطناعي برّه» is true as of this date: the only enabled AI connection on the
 *     platform is the academy's own gateway (local_tkai_conn id 4, an internal host). The OpenAI and Gemini
 *     connections exist in the admin but are switched off. If one is ever switched on, this page has to change
 *     the same day.
 *   - live support is the academy's own Chatwoot at chat.thinkera.academy, not a third-party widget.
 *   - Google Analytics is on (GANALYTICSCODE), YouTube serves the lesson videos, Google sign-in is offered.
 *   - no card details are stored: payment is an InstaPay transfer and a receipt image.
 *
 * Two things the owner decided (13 October 2026) rather than this script:
 *   - the data controller is named «أكاديمية Thinkera», with no company registration or address, until there is
 *     a registered entity to name.
 *   - a refund is a full refund within 7 days of payment, as long as the paid units' lessons were not opened.
 *
 * The Arabic is the site's one voice — clear Egyptian, no formal-Arabic sentences mixed in (the decision of
 * 20 September 2026) — with the legal terms themselves kept exact: «البيانات الشخصية», «الموافقة»,
 * «معالجة البيانات». The English is written for an English reader, not translated sentence by sentence.
 *
 *   ./tk cms-tools npx tsx src/scripts/2026-10-13-legal.ts
 *
 * Safe to re-run: it writes the same text again. Backs the two pages and the footer up first.
 */
import fs from 'node:fs'
import path from 'node:path'
import { getPayload } from 'payload'
import config from '@payload-config'

type L = 'ar' | 'en'
const payload = await getPayload({ config })
const get = (slug: string, locale: L) => payload.findGlobal({ slug: slug as never, locale, depth: 0 }) as Promise<any>
const set = (slug: string, locale: L, data: any) =>
  payload.updateGlobal({ slug: slug as never, locale, data, depth: 0 }) as Promise<any>

const S = (title: string, text: string) => ({ title, text })

// ------------------------------------------------------------------ سياسة الخصوصية
const privacyAr = {
  seo: {
    title: 'سياسة الخصوصية | أكاديمية Thinkera',
    description: 'إيه البيانات اللي بنجمعها عنك، وليه، ومين بيشوفها، وإزاي تطلب نسخة منها أو تمسحها.',
  },
  h1: 'سياسة الخصوصية',
  updated: 'آخر تحديث: 13 أكتوبر 2026',
  lead: 'الصفحة دي بتقول بالظبط إيه البيانات اللي بنجمعها عنك، وليه، ومين بيشوفها، وإيه حقوقك عليها. مكتوبة بلغة واضحة من غير لف، وأي تعديل فيها بيظهر في تاريخ آخر تحديث فوق.',
  sections: [
    S(
      'إحنا مين، والصفحة دي بتغطي إيه',
      'أكاديمية Thinkera منصة تعليمية مصرية بتشرح مناهج الثانوي أونلاين. الأكاديمية هي المسؤولة عن البيانات الشخصية اللي بتتجمع من الموقع ومن منصة التعلّم.\n\nالسياسة دي بتغطي موقع الأكاديمية، ومنصة التعلّم، والرسايل اللي بنبعتهالك. ما بتغطيش المواقع التانية اللي ممكن توصلها من عندنا — زي يوتيوب — دي ليها سياساتها هي.',
    ),
    S(
      'البيانات اللي بنجمعها',
      '- بيانات حسابك: الاسم، البريد الإلكتروني، رقم موبايلك، رقم موبايل وليّ الأمر، ونوع الحساب (طالب أو مدرب).\n- بيانات دراستك: الدروس اللي فتحتها، الفيديوهات اللي اتفرجت عليها، إجاباتك في التدريبات والامتحانات ودرجاتك، حضورك الجلسات المباشرة، والأسئلة اللي بتبعتها للمدرب أو للمساعد الذكي.\n- بيانات اشتراكك: قيمة الاشتراك وتاريخه وطريقة الدفع وإيصال التحويل. إحنا ما بنشوفش ولا بنخزّن أي بيانات كارت بنكي.\n- مراسلاتك معانا: رسايل البريد اللي بنبعتهالك — وهل اتفتحت وهل ضغطت على الزر اللي فيها — ورسايل الواتساب، ومحادثات الدعم المباشر.\n- لو سجّلت اهتمامك على الموقع: الاسم والبريد والموبايل وصفتك والمنهج اللي سألت عنه.\n- بيانات تقنية: عنوان الـ IP، نوع المتصفح والجهاز، والصفحات اللي فتحتها وإمتى.',
    ),
    S(
      'ليه بنجمعها',
      'بنستخدم البيانات دي في الأغراض دي بس:\n\n- نفتحلك المنهج، ونصحّح إجاباتك، ونسجّل تقدّمك — وده تنفيذ للاتفاق اللي بينّا.\n- المدرب يتابع مستواك ويعرف مين محتاج مساعدة.\n- نرد على أسئلتك ونبعتلك اللي يخص دروسك واشتراكك.\n- نحسّن الشرح والتدريبات، ونعرف أنهي صفحات بتفيد الناس فعلاً.\n- نلتزم بالقانون وبالمستندات المحاسبية.\n\nأي استخدام تاني غير ده بنرجعلك فيه الأول.',
    ),
    S(
      'ملفات تعريف الارتباط (Cookies) وقياس الزيارات',
      '- ملفات ضرورية: بتخلّي تسجيل دخولك شغّال، وبتفتكر لغتك والوضع الفاتح أو الداكن. من غيرها المنصة ما تشتغلش.\n- قياس الزيارات: بنستخدم Google Analytics عشان نعرف عدد الزوار وأنهي صفحات بيقروها. الأرقام دي إجمالية، ومش بنستخدمها نعرف بيها شخص بعينه.\n\nتقدر تقفل ملفات تعريف الارتباط من إعدادات متصفحك، بس ساعتها الدخول للمنصة غالباً مش هيشتغل.',
    ),
    S(
      'مين بيشوف بياناتك',
      '- مدرب المنهج اللي إنت مشترك فيه: بيشوف تقدّمك ودرجاتك وبيانات تواصلك عشان يتابعك.\n- وليّ أمرك: بنتواصل معاه في اللي يخص مستوى الطالب واشتراكه.\n- مزوّدي خدمات بنشتغل بيهم: استضافة الخوادم، وخدمة البريد اللي بتوصّل رسايلنا، وGoogle Analytics، ويوتيوب لما تشغّل فيديو درس، وتسجيل الدخول بحساب Google لو اخترته، وواتساب لما تراسلنا عليه، وخدمة الدفع.\n- الجهات الرسمية، لو القانون طلب كده.\n\nما بنبيعش بياناتك ولا بنأجّرها ولا بنبعتها لأي جهة إعلانية.\n\nحاجتين بالذات ناس بتسأل عليهم: تصحيح الإجابات والمساعد الذكي بيشتغلوا على نماذج مستضافة على خوادم الأكاديمية نفسها، يعني إجاباتك ما بتروحش لأي شركة ذكاء اصطناعي برّه — ولو ده اتغيّر هنكتبه هنا قبل ما يحصل. والدعم المباشر كمان على خادم تبع الأكاديمية، مش خدمة محادثة من شركة تانية.',
    ),
    S(
      'الطلبة تحت 18 سنة ووليّ الأمر',
      'أغلب طلبتنا في سن المدرسة. فتح الحساب والاشتراك بيكونوا بموافقة وليّ الأمر ومسؤوليته، وعشان كده بنطلب رقم موبايله.\n\nلو إنت وليّ أمر وعايز تعرف إيه المسجّل عن ابنك أو بنتك، أو عايز تطلب تصحيحه أو حذفه، ابعتلنا على البريد المكتوب تحت.',
    ),
    S(
      'بنحتفظ بالبيانات لحد إمتى',
      '- بيانات حسابك ودراستك بتفضل طول ما حسابك شغّال.\n- لو طلبت حذف حسابك، بنمسح بياناتك خلال 30 يوم من الطلب.\n- المستندات المالية (الفواتير وإيصالات الدفع) بنحتفظ بيها للمدة اللي القانون المصري بيلزمنا بيها، حتى بعد حذف الحساب.',
    ),
    S(
      'حقوقك على بياناتك',
      'قانون حماية البيانات الشخصية المصري (رقم 151 لسنة 2018) بيديك حقوق على بياناتك، وإحنا ملتزمين بيها:\n\n- تعرف إيه المسجّل عنك وتاخد نسخة منه.\n- تصحّح أي بيان غلط أو ناقص.\n- تطلب حذف بياناتك.\n- تسحب موافقتك في أي وقت، من غير ما ده يلغي اللي اتعمل قبل السحب.\n- تعترض على استخدام معيّن لبياناتك.\n- تشتكي للجهة المختصة بحماية البيانات الشخصية في مصر.\n\nعشان تستخدم أي حق من دول، ابعتلنا على البريد المكتوب تحت. بنرد في وقت معقول، وممكن نتأكد من شخصيتك الأول عشان ما نسلّمش بيانات حد لحد تاني.',
    ),
    S(
      'إزاي بنحمي بياناتك',
      'الموقع والمنصة شغالين على اتصال مشفّر (HTTPS). كلمات السر متخزّنة مشفّرة، ومحدش في الأكاديمية بيقدر يشوفها. الوصول للبيانات محصور في اللي شغله يحتاجها فعلاً.\n\nلو حصل تسريب يمسّ بياناتك الشخصية، هنبلّغك وهنبلّغ الجهة المختصة.',
    ),
    S(
      'تعديل السياسة',
      'ممكن نعدّل الصفحة دي لما الخدمة تتغيّر أو القانون يتغيّر. تاريخ آخر تحديث فوق هو اللي بيقولك إمتى اتغيرت آخر مرة، ولو التغيير مؤثر هنبعتلك عليه رسالة على بريدك.',
    ),
  ],
  closing:
    'عندك سؤال عن بياناتك، أو عايز تستخدم حق من حقوقك؟ ابعتلنا على البريد أو الواتساب المكتوبين في آخر الصفحة، واكتب كلمة «خصوصية» في العنوان عشان يوصل للشخص الصح بسرعة.',
}

const privacyEn = {
  seo: {
    title: 'Privacy policy | Thinkera Academy',
    description: 'What we collect about you, why, who sees it, and how to ask for a copy or have it deleted.',
  },
  h1: 'Privacy policy',
  updated: 'Last updated: 13 October 2026',
  lead: 'This page says exactly what we collect about you, why, who sees it, and what you can ask us to do with it. It is written plainly, and the date above changes whenever the text does.',
  sections: [
    S(
      'Who we are, and what this page covers',
      'Thinkera Academy is an Egyptian online academy that teaches the secondary-school syllabus. The academy is responsible for the personal data collected through its website and its learning platform.\n\nThis page covers the website, the learning platform and the emails we send you. It does not cover other sites you may reach from ours, such as YouTube, which have policies of their own.',
    ),
    S(
      'What we collect',
      '- Your account: name, email address, mobile number, your guardian’s mobile number, and whether the account is a student’s or an instructor’s.\n- Your study: the lessons you open, the videos you watch, your answers in practice sets and exams and the marks they earn, your attendance at live sessions, and the questions you send to an instructor or to the AI assistant.\n- Your subscription: the amount, the date, the payment method and the transfer receipt. We never see or store card details.\n- Your correspondence with us: the emails we send you — including whether they were opened and whether their button was pressed — WhatsApp messages, and live-support conversations.\n- If you register interest on the website: your name, email, mobile, who you are, and the course you asked about.\n- Technical data: your IP address, your browser and device, and which pages you opened and when.',
    ),
    S(
      'Why we collect it',
      'We use it for these purposes and no others:\n\n- To open the syllabus for you, mark your answers and record your progress — this is us doing what we agreed to do.\n- So your instructor can follow your level and see who needs help.\n- To answer your questions and write to you about your lessons and your subscription.\n- To improve the teaching and the practice, and to learn which pages actually help.\n- To meet our legal and accounting obligations.\n\nAnything beyond that, we come back and ask you first.',
    ),
    S(
      'Cookies and measurement',
      '- Necessary cookies: they keep you signed in and remember your language and whether you chose the light or dark theme. Without them the platform does not work.\n- Measurement: we use Google Analytics to see how many people visit and which pages they read. Those figures are totals; we do not use them to identify anybody.\n\nYou can block cookies in your browser, but signing in to the platform will most likely stop working.',
    ),
    S(
      'Who sees your data',
      '- The instructor of the course you are enrolled in: your progress, your marks and your contact details, so they can follow you up.\n- Your guardian: we talk to them about the student’s level and subscription.\n- The service providers we work with: server hosting, the mail service that delivers our emails, Google Analytics, YouTube when you play a lesson video, Google sign-in if you chose it, WhatsApp when you message us, and the payment service.\n- The authorities, where the law requires it.\n\nWe do not sell your data, rent it, or pass it to any advertiser.\n\nTwo things people ask about in particular. Marking and the AI assistant run on models hosted on the academy’s own servers, so your answers do not go to any outside AI company — and if that ever changes, this page will say so before it does. Live support likewise runs on the academy’s own server, not on a third party’s chat service.',
    ),
    S(
      'Students under 18, and their guardian',
      'Most of our students are of school age. Opening an account and paying for it are done with a guardian’s consent and are their responsibility, which is why we ask for their mobile number.\n\nIf you are a guardian and want to know what is held about your child, or to have it corrected or deleted, write to the address below.',
    ),
    S(
      'How long we keep it',
      '- Your account and study data stay for as long as your account is open.\n- If you ask us to delete your account, we erase your data within 30 days of the request.\n- Financial records (invoices and payment receipts) are kept for as long as Egyptian law requires, even after an account is deleted.',
    ),
    S(
      'Your rights over your data',
      'Egypt’s Personal Data Protection Law (no. 151 of 2018) gives you rights over your data, and we honour them:\n\n- To know what is held about you and receive a copy of it.\n- To have anything wrong or missing corrected.\n- To ask for your data to be deleted.\n- To withdraw your consent at any time, without that undoing what was done before you withdrew it.\n- To object to a particular use of your data.\n- To complain to the authority responsible for personal data protection in Egypt.\n\nTo use any of these, write to the address below. We answer within a reasonable time, and we may check who you are first so that nobody is handed somebody else’s data.',
    ),
    S(
      'How we protect it',
      'The website and the platform run over an encrypted connection (HTTPS). Passwords are stored hashed, and nobody at the academy can read them. Access to data is limited to the people whose work needs it.\n\nIf a breach affects your personal data, we will tell you and tell the authority.',
    ),
    S(
      'Changes to this policy',
      'We may change this page when the service changes or the law does. The date above tells you when it last changed, and if a change matters we will email you about it.',
    ),
  ],
  closing:
    'A question about your data, or want to use one of your rights? Write to the email or WhatsApp number at the bottom of this page, and put “privacy” in the subject so it reaches the right person quickly.',
}

// ------------------------------------------------------------------ شروط الاستخدام
const termsAr = {
  seo: {
    title: 'شروط الاستخدام | أكاديمية Thinkera',
    description: 'الاتفاق بينك وبين الأكاديمية: الحساب، الاشتراك والاسترداد، المحتوى، والاستخدام المقبول.',
  },
  h1: 'شروط الاستخدام',
  updated: 'آخر تحديث: 13 أكتوبر 2026',
  lead: 'الصفحة دي هي الاتفاق اللي بينك وبين أكاديمية Thinkera: إيه اللي بنقدّمه، وإيه المتوقع منك، وإيه اللي بيحصل لو حاجة مامشتش صح. استخدامك للموقع أو المنصة معناه إنك موافق على اللي مكتوب هنا.',
  sections: [
    S(
      'القبول بالشروط',
      'لما تفتح حساب على منصة Thinkera أو تستخدم الموقع، إنت موافق على الشروط دي وعلى سياسة الخصوصية. لو مش موافق على حاجة فيها، ما تستخدمش الخدمة.\n\nلو سنّك تحت 18 سنة، لازم يكون وليّ أمرك موافق، وهو المسؤول عن الاشتراك.',
    ),
    S(
      'حسابك',
      '- الحساب شخصي لشخص واحد. ممنوع تشارك اسم الدخول وكلمة السر مع أي حد.\n- اكتب بيانات صحيحة. البيانات الغلط ممكن تضيّع عليك اشتراكك أو شهادتك.\n- إنت مسؤول عن أي استخدام بيحصل من حسابك. لو حسّيت إن حد تاني دخل عليه، بلّغنا على طول.',
    ),
    S(
      'الاشتراك والدفع',
      '- الوحدة الأولى من كل منهج مفتوحة مجاناً عشان تجرّب قبل ما تدفع.\n- باقي المنهج بيتفتح بالاشتراك. السعر مكتوب على صفحة المنهج، وهو للسنة الدراسية.\n- الدفع بيتم على المنصة بالطرق المعلنة فيها.\n- الاشتراك شخصي ومش قابل للتحويل لحد تاني.\n- السعر ممكن يتغيّر للمشتركين الجداد، لكن اشتراك دفعته بالفعل سعره ثابت طول مدته.',
    ),
    S(
      'الاسترداد',
      'تقدر تطلب استرداد كامل خلال 7 أيام من تاريخ الدفع، بشرط إنك ما تكونش فتحت دروس الوحدات المدفوعة.\n\nبعد الـ 7 أيام، أو لو بدأت تفتح الوحدات المدفوعة، الاشتراك بيبقى غير قابل للاسترداد — المحتوى رقمي وبيتفتحلك كامل من أول لحظة، وعشان كده الوحدة الأولى مجانية تجرّب بيها الأول.\n\nلو حصل خطأ في الدفع أو اتخصم منك مرتين، بلّغنا وهنرجّعلك الفرق.',
    ),
    S(
      'محتوى الأكاديمية وحقوق الملكية',
      'كل اللي على المنصة — الفيديوهات والملازم وبنوك الأسئلة والتصميمات — ملك أكاديمية Thinkera. اشتراكك بيديك حق تستخدمه لمذاكرتك إنت شخصياً، وبس.\n\nممنوع تسجيل الفيديوهات أو تصويرها، أو إعادة نشر أي جزء من المحتوى، أو بيعه أو توزيعه، أو رفعه في أي مكان تاني.\n\nالمناهج الدراسية الرسمية ملك أصحابها؛ إحنا بنشرحها، والكتاب المدرسي هو المرجع.',
    ),
    S(
      'الاستخدام المقبول',
      '- ما تحاولش تدخل على حاجة مش من حقك، أو تعطّل المنصة، أو تستخدم برامج تنزّل المحتوى تلقائياً.\n- في الجلسات المباشرة وفي الأسئلة، اتكلم باحترام. مافيش إساءة ولا محتوى مخالف.\n- ما تدّيش حسابك لحد تاني وما تبيعش وصول لمحتوانا.\n\nمخالفة البنود دي ممكن توقف حسابك فوراً من غير استرداد.',
    ),
    S(
      'الجلسات المباشرة والأسئلة',
      'مواعيد الجلسات معلنة، وممكن تتأجّل لظروف طارئة — وساعتها بنبلّغك.\n\nأسئلتك للمدرب بيتم الرد عليها في وقت معقول. ده جزء من المتابعة، مش بديل عن المذاكرة ولا وعد برد فوري.',
    ),
    S(
      'اللي ما بنوعدش بيه',
      'بنوعدك بشرح أمين، ومحتوى مراجَع، وتدريب كتير. ما بنضمنش درجة معيّنة ولا نتيجة امتحان: النتيجة بتعتمد على مذاكرتك إنت وعلى عوامل برّه إيدينا.\n\nوبنعمل اللي علينا عشان المنصة تفضل شغّالة، لكن ممكن يحصل انقطاع لصيانة أو لعطل خارج عننا.',
    ),
    S(
      'إيقاف الحساب',
      '- تقدر تبطّل استخدام الخدمة وتطلب حذف حسابك في أي وقت.\n- ممكن نوقف حساب خالف الشروط دي، وبنوضّحلك السبب.\n- لو أوقفنا حسابك من غير مخالفة منك، بنرجّعلك باقي قيمة اشتراكك.',
    ),
    S(
      'خدمات من غيرنا',
      'المنصة بتستخدم خدمات خارجية: يوتيوب لتشغيل الفيديوهات، وتسجيل الدخول بحساب Google لو اخترته، وواتساب للتواصل، وخدمة الدفع. استخدامك ليهم بيخضع لشروطهم هم كمان، وإحنا مش مسؤولين عن أعطالهم.',
    ),
    S(
      'تعديل الشروط والقانون الواجب التطبيق',
      '- ممكن نعدّل الشروط دي. تاريخ آخر تحديث فوق، ولو التغيير مؤثر هنبلّغك على بريدك قبل ما يسري.\n- الشروط دي بتخضع للقانون المصري، وأي نزاع بيكون من اختصاص المحاكم المصرية.',
    ),
  ],
  closing: 'محتاج توضيح لأي بند؟ كلّمنا على البريد أو الواتساب المكتوبين في آخر الصفحة.',
}

const termsEn = {
  seo: {
    title: 'Terms of service | Thinkera Academy',
    description: 'The agreement between you and the academy: your account, payment and refunds, the content, and fair use.',
  },
  h1: 'Terms of service',
  updated: 'Last updated: 13 October 2026',
  lead: 'This page is the agreement between you and Thinkera Academy: what we provide, what we expect of you, and what happens when something goes wrong. Using the website or the platform means you accept it.',
  sections: [
    S(
      'Accepting these terms',
      'When you open an account on the Thinkera platform or use the website, you accept these terms and the privacy policy. If there is something here you do not accept, please do not use the service.\n\nIf you are under 18, your guardian must agree, and the subscription is their responsibility.',
    ),
    S(
      'Your account',
      '- An account belongs to one person. Do not share your username and password with anybody.\n- Give correct details. Wrong details can cost you your subscription or your certificate.\n- You are responsible for whatever is done from your account. If you think somebody else has got into it, tell us at once.',
    ),
    S(
      'Subscription and payment',
      '- The first unit of every course is open free, so you can try before you pay.\n- The rest of the syllabus opens with a subscription. The price is on the course page, and it covers the school year.\n- Payment is made on the platform, by the methods shown there.\n- A subscription is personal and cannot be transferred to anybody else.\n- The price may change for new subscribers, but a subscription you have already paid for keeps its price for its term.',
    ),
    S(
      'Refunds',
      'You can ask for a full refund within 7 days of paying, as long as you have not opened the lessons of the paid units.\n\nAfter those 7 days, or once you have started opening the paid units, the subscription is not refundable — the content is digital and all of it opens for you from the first moment, which is exactly why the first unit is free to try.\n\nIf a payment went wrong or you were charged twice, tell us and we will return the difference.',
    ),
    S(
      'Our content, and who owns it',
      'Everything on the platform — the videos, the booklets, the question banks and the artwork — belongs to Thinkera Academy. Your subscription gives you the right to use it for your own study, and nothing more.\n\nDo not record or film the videos, republish any part of the content, sell or distribute it, or upload it anywhere else.\n\nThe official syllabus belongs to its owners; we teach it, and the school textbook remains the reference.',
    ),
    S(
      'Fair use',
      '- Do not try to reach anything that is not yours, disrupt the platform, or use software that downloads the content automatically.\n- In live sessions and in questions, be respectful. No abuse, and nothing unlawful.\n- Do not give your account to anybody else or sell access to our content.\n\nBreaking these can close your account at once, without a refund.',
    ),
    S(
      'Live sessions and questions',
      'Session times are announced, and a session may be moved in an emergency — we tell you when that happens.\n\nQuestions to an instructor are answered within a reasonable time. That is part of following you up; it is not a substitute for studying, nor a promise of an immediate reply.',
    ),
    S(
      'What we do not promise',
      'We promise honest teaching, reviewed content and plenty of practice. We do not promise a particular mark or exam result: that depends on your own work and on things outside our hands.\n\nWe also do our part to keep the platform running, but it may be interrupted for maintenance or by a fault that is not ours.',
    ),
    S(
      'Closing an account',
      '- You can stop using the service and ask for your account to be deleted at any time.\n- We may close an account that breaks these terms, and we will tell you why.\n- If we close your account when you have broken nothing, we return the remainder of your subscription.',
    ),
    S(
      'Services that are not ours',
      'The platform uses outside services: YouTube to play the videos, Google sign-in if you choose it, WhatsApp for messages, and the payment service. Using them is also subject to their own terms, and we are not responsible for their outages.',
    ),
    S(
      'Changes, and the law that applies',
      '- We may change these terms. The date above says when they last changed, and if a change matters we will email you before it takes effect.\n- These terms are governed by Egyptian law, and any dispute belongs to the Egyptian courts.',
    ),
  ],
  closing: 'Need any clause explained? Write to the email or WhatsApp number at the bottom of this page.',
}

// ------------------------------------------------------------------ the two footer links
const FOOTER: Record<L, { label: string; href: string }[]> = {
  ar: [
    { label: 'سياسة الخصوصية', href: '/privacy' },
    { label: 'شروط الاستخدام', href: '/terms' },
  ],
  en: [
    { label: 'Privacy policy', href: '/privacy' },
    { label: 'Terms of service', href: '/terms' },
  ],
}

// ------------------------------------------------------------------ write it
const backup: Record<string, unknown> = {}
for (const locale of ['ar', 'en'] as L[]) {
  backup[`privacy.${locale}`] = await get('privacy', locale)
  backup[`terms.${locale}`] = await get('terms', locale)
  backup[`settings.${locale}`] = await get('settings', locale)
}
const file = path.join(process.cwd(), 'src/scripts/backup-2026-10-13-legal.json')
fs.writeFileSync(file, JSON.stringify(backup, null, 2))
console.log(`backup written to ${file}`)

await set('privacy', 'ar', privacyAr)
await set('privacy', 'en', privacyEn)
await set('terms', 'ar', termsAr)
await set('terms', 'en', termsEn)
console.log('privacy and terms written in both languages')

for (const locale of ['ar', 'en'] as L[]) {
  const s = await get('settings', locale)
  const links = [...((s.footer?.links || []) as { label?: string; href?: string }[])]
  for (const want of FOOTER[locale]) {
    if (!links.some((l) => (l.href || '') === want.href)) links.push(want)
  }
  await set('settings', locale, { footer: { ...(s.footer || {}), links } })
  console.log(`${locale}: footer now has ${links.length} academy links`)
}

console.log('done')
process.exit(0)
