import Translation from "@/models/Translation";

export const DEFAULT_STOREFRONT_TRANSLATION_KEYS = [
  "Home",
  "Shop",
  "Categories",
  "Brands",
  "About",
  "Contact",
  "Search",
  "User Profile",
  "Admin Panel",
  "Logout",
  "Limited Time Offer",
  "Discover Your Style",
  "Explore our latest collection of premium fashion designed for the modern woman.",
  "SHOP COLLECTION",
  "SHOP FLASH SALE",
  "Featured Collection",
  "View All Products",
  "Free Shipping",
  "On all orders above",
  "Delivery within 2-3 business days.",
  "Secure Checkout",
  "All transactions are encrypted and processed through trusted gateways.",
  "Premium Quality",
  "Handcrafted, luxury fabrics designed with precision for premium comfort.",
  "Shop Collection",
  "Showing",
  "products",
  "Newest Arrivals",
  "Price: Low to High",
  "Price: High to Low",
  "Filters",
  "Clear All",
  "Price Range",
  "Availability",
  "In Stock Only",
  "On Sale",
  "Featured Only",
  "Sizes",
  "Colors",
  "Best Seller",
  "Sale",
  "View Details",
  "Add to Cart",
  "Qty",
  "Total",
  "Subtotal",
  "Reviews",
  "Your Cart",
  "Proceed to Checkout",
  "Shipping Cost",
  "Calculated at next step",
  "No products match your selected filters.",
  "Reset Filters",
  "Checkout",
  "Contact Information",
  "Payment Methods",
  "Fulfillment Status",
  "Order Details",
  "Order ID",
  "Date",
  "Total Amount",
  "Fulfillable",
  "Refunded",
  "Returned",
  "Restocked",
  "Cancelled",
  "Paid",
  "Unpaid",
  "Contact Us",
  "About Us",
  "Limited Time Flash Sale",
  "Shopping Cart",
  "Order History",
  "Manage the languages available on your storefront. Set a default language or add new ones.",
  "Languages Management",
  "back_to_shop",
  "added_to_cart_success",
  "view_cart",
  "buy_now",
  "secure_payment",
  "free_returns",
  "verified_reviews",
  "shipping_information",
  "estimated_delivery",
  "free_shipping_min",
  "product_details",
  "available_variants",
  "selected_variant",
  "stock_available",
  "items_available",
  "out_of_stock",
  "shipping_and_returns",
  "size_guide",
  "write_a_review",
  "review_submitted_success",
  "your_rating",
  "your_name",
  "enter_your_name",
  "your_review",
  "share_experience",
  "submit_review",
  "no_reviews_yet",
  "shipping_policy",
  "returns_policy",
  "size_chart",
  "bust_inches",
  "waist_inches",
  "hips_inches",
  "color",
  "size",
  "quantity",
  "category",
  "brand",
  "description",
  "your_cart_is_empty",
  "add_items_before_checkout",
  "go_to_shop",
  "back_to_cart",
  "shipping_details",
  "full_name",
  "email_address",
  "phone_number",
  "street_address",
  "city",
  "postal_code",
  "payment_method",
  "cash_on_delivery",
  "cod_description",
  "stripe_payment_title",
  "stripe_payment_desc",
  "paypal_payment_title",
  "paypal_payment_desc",
  "razorpay_payment_title",
  "razorpay_payment_desc",
  "secure_stripe_checkout",
  "stripe_redirect_notice",
  "secure_paypal_checkout",
  "paypal_redirect_notice",
  "razorpay_redirect_notice",
  "cards",
  "upi",
  "order_review",
  "processing",
  "place_order",
  "pay_with",
  "free",
  "payment_cancelled_message",
  "order_confirmed",
  "thank_you_purchase",
  "payment_successful",
  "payment_verified_message",
  "shipping_address",
  "payment_and_shipping",
  "payment_method_label",
  "payment_status_label",
  "carrier",
  "items_ordered",
  "continue_shopping",
  "cash_on_delivery_display",
  "stripe_secure_checkout_display",
  "snapshop_standard_delivery",
];

const DEFAULT_TRANSLATION_VALUES: Record<string, string> = {
  back_to_shop: "Back to Shop",
  added_to_cart_success: "Added to cart successfully!",
  view_cart: "View Cart",
  buy_now: "Buy Now",
  secure_payment: "Secure Payment",
  free_returns: "Free Returns",
  verified_reviews: "Verified Reviews",
  shipping_information: "Shipping Information",
  estimated_delivery: "Estimated delivery: 3-5 business days",
  free_shipping_min: "Free shipping on orders over",
  product_details: "Product Details",
  available_variants: "Available Variants",
  selected_variant: "Selected Variant",
  stock_available: "Stock Available",
  items_available: "items available",
  out_of_stock: "Out of Stock",
  shipping_and_returns: "Shipping & Returns",
  size_guide: "Size Guide",
  write_a_review: "Write a Review",
  review_submitted_success: "Review submitted successfully!",
  your_rating: "Your Rating",
  your_name: "Your Name",
  enter_your_name: "Enter your name",
  your_review: "Your Review",
  share_experience: "Share your experience with this product...",
  submit_review: "Submit Review",
  no_reviews_yet: "No reviews yet. Be the first to review this product!",
  shipping_policy: "Shipping Policy",
  returns_policy: "Returns Policy",
  size_chart: "Size Chart",
  bust_inches: "Bust (inches)",
  waist_inches: "Waist (inches)",
  hips_inches: "Hips (inches)",
  color: "Color",
  size: "Size",
  quantity: "Quantity",
  category: "Category",
  brand: "Brand",
  description: "Description",
  your_cart_is_empty: "Your Cart is Empty",
  add_items_before_checkout: "Add some items to your shopping cart before proceeding to checkout.",
  go_to_shop: "Go to Shop",
  back_to_cart: "Back to Cart",
  shipping_details: "Shipping Details",
  full_name: "Full Name",
  email_address: "Email Address",
  phone_number: "Phone Number",
  street_address: "Street Address",
  city: "City",
  postal_code: "Postal Code",
  payment_method: "Payment Method",
  cash_on_delivery: "Cash on Delivery (COD)",
  cod_description: "Pay cash when order is delivered to your doorstep.",
  stripe_payment_title: "Credit Card / Debit Card (Stripe)",
  stripe_payment_desc: "Pay securely with Visa, MasterCard, Amex, or Apple Pay.",
  paypal_payment_title: "PayPal Secure Checkout",
  paypal_payment_desc: "Pay using your PayPal wallet balance or linked bank accounts.",
  razorpay_payment_title: "UPI / Netbanking (Razorpay)",
  razorpay_payment_desc: "Support instant UPI payments and cards.",
  secure_stripe_checkout: "Secure Stripe Checkout",
  stripe_redirect_notice: "You will be redirected to the secure Stripe payment gateway to complete your transaction. All payments are fully encrypted and secure.",
  secure_paypal_checkout: "Secure PayPal Checkout",
  paypal_redirect_notice: "You will be redirected to the secure PayPal payment gateway to complete your transaction. All payments are fully encrypted and secure.",
  razorpay_redirect_notice: "Razorpay secure payment is active. You will choose UPI or card details in the official Razorpay checkout after clicking Place Order.",
  cards: "Cards",
  upi: "UPI",
  order_review: "Order Review",
  processing: "Processing...",
  place_order: "Place Order",
  pay_with: "Pay with",
  free: "Free",
  payment_cancelled_message: "Payment was cancelled. Please try again.",
  order_confirmed: "Order Confirmed!",
  thank_you_purchase: "Thank you for your purchase at SnapShop.",
  payment_successful: "Payment Successful!",
  payment_verified_message: "Thank you for your trust. Payment has been successfully verified for your order.",
  shipping_address: "Shipping Address",
  payment_and_shipping: "Payment & Shipping",
  payment_method_label: "Payment Method:",
  payment_status_label: "Payment Status:",
  carrier: "Carrier:",
  items_ordered: "Items Ordered",
  continue_shopping: "Continue Shopping",
  cash_on_delivery_display: "Cash on Delivery",
  stripe_secure_checkout_display: "Stripe Secure Checkout",
  snapshop_standard_delivery: "SnapShop Standard Delivery",
};

export async function ensureDefaultStorefrontTranslations() {
  const result = await Translation.bulkWrite(
    DEFAULT_STOREFRONT_TRANSLATION_KEYS.map((key) => ({
      updateOne: {
        filter: { key },
        update: { $setOnInsert: { key, translations: { en: DEFAULT_TRANSLATION_VALUES[key] || key } } },
        upsert: true,
      },
    })),
    { ordered: false }
  );

  return {
    insertedCount: result.upsertedCount || 0,
    totalDefaultKeys: DEFAULT_STOREFRONT_TRANSLATION_KEYS.length,
  };
}
