import { n as __toESM } from "../_runtime.mjs";
import { u as require_react } from "../_libs/@floating-ui/react-dom+[...].mjs";
import { n as CheckboxIndicator, p as require_jsx_runtime, t as Checkbox$1 } from "../_libs/@radix-ui/react-checkbox+[...].mjs";
import { a as cn, d as statusLabel, f as useStore, r as Input, s as fmt, t as Button } from "./categories-MJJjwt1u.mjs";
import { h as Link } from "../_libs/@tanstack/react-router+[...].mjs";
import { n as toast } from "../_libs/sonner.mjs";
import { E as Package, K as CircleX, N as LayoutDashboard, Q as Check, R as Eye, S as RotateCcw, Y as ChevronRight, d as Store, f as Star, i as Video, m as SquarePen, q as CircleCheck, u as Trash2, w as Plus, y as Settings, z as ExternalLink } from "../_libs/lucide-react.mjs";
import { c as DialogTitle, i as DialogContent, l as Header, n as CheckoutFlow, o as DialogFooter, r as Dialog, s as DialogHeader, t as CartDrawer, u as SignInModal } from "./Modals-PUPoXlMv.mjs";
import { n as Textarea, t as ImageUpload } from "./image-upload-BsyTIobY.mjs";
//#region node_modules/.nitro/vite/services/ssr/assets/admin-u9VsuHe2.js
var import_react = /* @__PURE__ */ __toESM(require_react());
var import_jsx_runtime = require_jsx_runtime();
var Checkbox = import_react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checkbox$1, {
	ref,
	className: cn("grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground", className),
	...props,
	children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckboxIndicator, {
		className: cn("grid place-content-center text-current"),
		children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Check, { className: "h-4 w-4" })
	})
}));
Checkbox.displayName = Checkbox$1.displayName;
var steps = [
	"placed",
	"processing",
	"shipped",
	"out_for_delivery",
	"delivered"
];
function EditVendorForm({ vendor, onClose, onSave }) {
	const [form, setForm] = (0, import_react.useState)(vendor);
	const submit = (e) => {
		e.preventDefault();
		onSave(vendor.id, form);
		onClose();
	};
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
		onSubmit: submit,
		className: "space-y-4 pt-2",
		children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
				className: "grid grid-cols-2 gap-3",
				children: [
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
						className: "text-xs font-medium",
						children: "Business Name"
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
						value: form.businessName,
						onChange: (e) => setForm({
							...form,
							businessName: e.target.value
						})
					})] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
						className: "text-xs font-medium",
						children: "Contact Name"
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
						value: form.contactName,
						onChange: (e) => setForm({
							...form,
							contactName: e.target.value
						})
					})] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
						className: "text-xs font-medium",
						children: "Email"
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
						value: form.contactEmail,
						onChange: (e) => setForm({
							...form,
							contactEmail: e.target.value
						})
					})] }),
					/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
						className: "text-xs font-medium",
						children: "Phone"
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
						value: form.contactPhone,
						onChange: (e) => setForm({
							...form,
							contactPhone: e.target.value
						})
					})] })
				]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
				className: "text-xs font-medium",
				children: "Address"
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
				value: form.address,
				onChange: (e) => setForm({
					...form,
					address: e.target.value
				})
			})] }),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogFooter, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
				variant: "outline",
				type: "button",
				onClick: onClose,
				children: "Cancel"
			}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
				type: "submit",
				className: "bg-orange-500 hover:bg-orange-600",
				children: "Save Changes"
			})] })
		]
	});
}
function EditProductForm({ product, onClose, onSave }) {
	const [form, setForm] = (0, import_react.useState)({
		...product,
		img: product.images?.[0] || "",
		is_flash: !!product.is_flash,
		is_top: !!product.is_top,
		description: product.description || ""
	});
	const submit = (e) => {
		e.preventDefault();
		const { img, ...rest } = form;
		const images = img ? [img] : void 0;
		onSave(product.id, {
			...rest,
			price: Number(form.price),
			old: form.old ? Number(form.old) : void 0,
			images: images || product.images
		});
		onClose();
	};
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
		onSubmit: submit,
		className: "space-y-4 pt-2",
		children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
			className: "grid grid-cols-2 gap-3",
			children: [
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "col-span-2",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
						className: "text-xs font-medium",
						children: "Primary Image"
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ImageUpload, {
						value: form.img,
						onChange: (url) => setForm({
							...form,
							img: url
						})
					})]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
					className: "text-xs font-medium",
					children: "Name"
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
					value: form.name,
					onChange: (e) => setForm({
						...form,
						name: e.target.value
					})
				})] }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
					className: "text-xs font-medium",
					children: "Category"
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
					value: form.category,
					onChange: (e) => setForm({
						...form,
						category: e.target.value
					})
				})] }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
					className: "text-xs font-medium",
					children: "Price ₦"
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
					type: "number",
					value: form.price,
					onChange: (e) => setForm({
						...form,
						price: Number(e.target.value)
					})
				})] }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
					className: "text-xs font-medium",
					children: "Old Price"
				}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
					type: "number",
					value: form.old || "",
					onChange: (e) => setForm({
						...form,
						old: Number(e.target.value)
					})
				})] }),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "col-span-2",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
						className: "text-xs font-medium",
						children: "Description"
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Textarea, {
						className: "h-20",
						value: form.description,
						onChange: (e) => setForm({
							...form,
							description: e.target.value
						})
					})]
				}),
				/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "col-span-2 flex gap-6 mt-2",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "flex items-center space-x-2",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checkbox, {
							id: "is_flash",
							checked: form.is_flash,
							onCheckedChange: (c) => setForm({
								...form,
								is_flash: !!c
							})
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
							htmlFor: "is_flash",
							className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
							children: "Flash Sale"
						})]
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "flex items-center space-x-2",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checkbox, {
							id: "is_top",
							checked: form.is_top,
							onCheckedChange: (c) => setForm({
								...form,
								is_top: !!c
							})
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
							htmlFor: "is_top",
							className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
							children: "Top Seller"
						})]
					})]
				})
			]
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogFooter, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			variant: "outline",
			type: "button",
			onClick: onClose,
			children: "Cancel"
		}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
			type: "submit",
			className: "bg-orange-500 hover:bg-orange-600",
			children: "Save Changes"
		})] })]
	});
}
function AdminPage() {
	const [signInOpen, setSignInOpen] = (0, import_react.useState)(false);
	const [cartOpen, setCartOpen] = (0, import_react.useState)(false);
	const [checkoutOpen, setCheckoutOpen] = (0, import_react.useState)(false);
	const [tab, setTab] = (0, import_react.useState)("orders");
	const [viewVendor, setViewVendor] = (0, import_react.useState)(null);
	const [editVendor, setEditVendor] = (0, import_react.useState)(null);
	const [editProduct, setEditProduct] = (0, import_react.useState)(null);
	const [adminReviews, setAdminReviews] = (0, import_react.useState)([]);
	const { orders, setOrderStatus, updateOrderDriverPhone, advanceOrder, hydrated, vendors, adminApproveVendor, adminEditVendor, adminDeleteVendor, paystackKey, setPaystackKey, topBanners, setTopBanners, heroBanners, setHeroBanners, getAllProducts, editProduct: storeEditProduct, removeProduct, withdrawals, fetchWithdrawals, adminUpdateWithdrawal } = useStore();
	const fetchAdminReviews = () => {
		fetch("/api/reviews.php?action=admin_list").then((r) => r.json()).then((data) => {
			if (Array.isArray(data)) setAdminReviews(data);
		}).catch(() => {});
	};
	(0, import_react.useEffect)(() => {
		if (tab === "withdrawals") fetchWithdrawals();
		if (tab === "reviews") fetchAdminReviews();
	}, [tab, fetchWithdrawals]);
	const handleApproveReview = async (id) => {
		try {
			if ((await (await fetch("/api/reviews.php?action=approve", {
				method: "POST",
				headers: { "Content-Type": "application/json" },
				body: JSON.stringify({ id })
			})).json()).success) {
				setAdminReviews((prev) => prev.map((r) => r.id === id ? {
					...r,
					status: "approved"
				} : r));
				toast.success("Video review approved! It is now visible on the product page.");
			}
		} catch {
			toast.error("Failed to approve review.");
		}
	};
	const handleRejectReview = async (id) => {
		try {
			if ((await (await fetch("/api/reviews.php?action=reject", {
				method: "POST",
				headers: { "Content-Type": "application/json" },
				body: JSON.stringify({ id })
			})).json()).success) {
				setAdminReviews((prev) => prev.map((r) => r.id === id ? {
					...r,
					status: "rejected"
				} : r));
				toast.info("Video review rejected.");
			}
		} catch {
			toast.error("Failed to reject review.");
		}
	};
	const handleDeleteReview = async (id) => {
		if (!confirm("Are you sure you want to permanently delete this video review?")) return;
		try {
			if ((await (await fetch("/api/reviews.php?action=delete", {
				method: "POST",
				headers: { "Content-Type": "application/json" },
				body: JSON.stringify({ id })
			})).json()).success) {
				setAdminReviews((prev) => prev.filter((r) => r.id !== id));
				toast.success("Video review deleted permanently.");
			}
		} catch {
			toast.error("Failed to delete review.");
		}
	};
	const setStatus = (id, target) => {
		const order = orders.find((o) => o.id === id);
		if (!order) return;
		const from = steps.indexOf(order.status);
		if (steps.indexOf(target) <= from) return;
		setOrderStatus(id, target);
	};
	const pendingReviewsCount = adminReviews.filter((r) => (r.status || "pending") === "pending").length;
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
		className: "min-h-screen bg-neutral-50",
		children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SignInModal, {
				open: signInOpen,
				onOpenChange: setSignInOpen
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CartDrawer, {
				open: cartOpen,
				onOpenChange: setCartOpen,
				onCheckout: () => {
					setCartOpen(false);
					setCheckoutOpen(true);
				}
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckoutFlow, {
				open: checkoutOpen,
				onOpenChange: setCheckoutOpen
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Header, {
				onOpenCart: () => setCartOpen(true),
				onOpenSignIn: () => setSignInOpen(true)
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Dialog, {
				open: !!editProduct,
				onOpenChange: (o) => !o && setEditProduct(null),
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogContent, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogTitle, { children: "Edit Product" }) }), editProduct && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditProductForm, {
					product: editProduct,
					onClose: () => setEditProduct(null),
					onSave: storeEditProduct
				})] })
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("main", {
				className: "max-w-[1100px] mx-auto px-4 py-8",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "mb-6 flex flex-col sm:flex-row sm:items-end justify-between gap-4",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
						className: "text-xs text-neutral-500",
						children: "Admin"
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
						className: "text-2xl font-bold",
						children: "Dashboard"
					})] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "flex bg-white rounded-lg border p-1 self-start sm:self-auto flex-wrap gap-1",
						children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								onClick: () => setTab("orders"),
								className: `px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition ${tab === "orders" ? "bg-orange-50 text-orange-600" : "text-neutral-600 hover:bg-neutral-100"}`,
								children: "Orders"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								onClick: () => setTab("vendors"),
								className: `px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition ${tab === "vendors" ? "bg-orange-50 text-orange-600" : "text-neutral-600 hover:bg-neutral-100"}`,
								children: "Vendors"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								onClick: () => setTab("products"),
								className: `px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition ${tab === "products" ? "bg-orange-50 text-orange-600" : "text-neutral-600 hover:bg-neutral-100"}`,
								children: "Products"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
								onClick: () => setTab("reviews"),
								className: `px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition relative ${tab === "reviews" ? "bg-orange-50 text-orange-600" : "text-neutral-600 hover:bg-neutral-100"}`,
								children: ["Reviews", pendingReviewsCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
									className: "ml-1 px-1.5 py-0.2 bg-amber-500 text-white text-[10px] font-bold rounded-full",
									children: pendingReviewsCount
								})]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								onClick: () => setTab("withdrawals"),
								className: `px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition ${tab === "withdrawals" ? "bg-orange-50 text-orange-600" : "text-neutral-600 hover:bg-neutral-100"}`,
								children: "Withdrawals"
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
								onClick: () => setTab("settings"),
								className: `px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition ${tab === "settings" ? "bg-orange-50 text-orange-600" : "text-neutral-600 hover:bg-neutral-100"}`,
								children: "Settings"
							})
						]
					})]
				}), !hydrated ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
					className: "text-center py-16 text-sm text-neutral-500",
					children: "Loading…"
				}) : tab === "orders" ? orders.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "bg-white rounded-lg border p-10 text-center",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Package, { className: "w-12 h-12 text-neutral-300 mx-auto mb-3" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
						className: "text-lg font-bold",
						children: "No orders yet"
					})]
				}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
					className: "space-y-4",
					children: orders.map((o) => {
						const idx = steps.indexOf(o.status);
						const next = steps[idx + 1];
						return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "bg-white rounded-lg border p-5",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
								className: "flex flex-wrap items-start justify-between gap-4 mb-4",
								children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
									/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
										className: "flex items-center gap-2",
										children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
											className: "font-bold",
											children: o.id
										}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
											className: "text-xs px-2 py-0.5 rounded-full bg-orange-100 text-orange-700 font-medium",
											children: statusLabel[o.status]
										})]
									}),
									/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
										className: "text-xs text-neutral-500 mt-1",
										children: [
											new Date(o.createdAt).toLocaleString(),
											" · ",
											o.items.length,
											" item",
											o.items.length !== 1 ? "s" : "",
											" · ₦ ",
											fmt(o.total)
										]
									}),
									/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
										className: "text-xs text-neutral-500 flex flex-wrap items-center gap-2 mt-1",
										children: [
											/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
												o.address.name,
												" — ",
												o.address.city,
												", ",
												o.address.state
											] }),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
												className: "text-neutral-300",
												children: "•"
											}),
											o.driverPhone ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
												className: "text-emerald-700 font-mono font-bold bg-emerald-50 px-2 py-0.5 rounded border border-emerald-200",
												children: ["Driver: ", o.driverPhone]
											}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
												className: "text-amber-700 bg-amber-50 px-2 py-0.5 rounded border border-amber-200 text-[11px]",
												children: "Driver: Not assigned"
											}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
												onSubmit: (e) => {
													e.preventDefault();
													const input = e.currentTarget.elements.namedItem("phone").value.trim();
													if (!/^\d{11}$/.test(input)) {
														toast.error("Driver phone number must be an 11-digit number (e.g. 08031234567)");
														return;
													}
													updateOrderDriverPhone(o.id, input);
													toast.success(`Driver phone number (${input}) updated for Order ${o.id}!`);
												},
												className: "inline-flex items-center gap-1 ml-1",
												children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
													name: "phone",
													defaultValue: o.driverPhone || "",
													placeholder: "Update 11 digits",
													maxLength: 11,
													className: "h-6 text-[11px] w-32 font-mono bg-neutral-50 px-1.5"
												}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
													type: "submit",
													size: "sm",
													variant: "outline",
													className: "h-6 text-[10px] px-2",
													children: "Save"
												})]
											})
										]
									})
								] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "flex gap-2",
									children: [
										/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
											to: "/admin/$id",
											params: { id: o.id },
											children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
												variant: "outline",
												size: "sm",
												children: "View details"
											})
										}),
										/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
											to: "/orders/$id",
											params: { id: o.id },
											children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
												variant: "outline",
												size: "sm",
												children: "Tracking"
											})
										}),
										next ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
											size: "sm",
											className: next === "delivered" ? "bg-emerald-600 hover:bg-emerald-700 text-white font-bold" : "bg-orange-500 hover:bg-orange-600",
											onClick: () => {
												setOrderStatus(o.id, next);
												if (next === "delivered") toast.success(`Order ${o.id} marked as DELIVERED! Payment released to vendor wallet.`);
											},
											children: [
												next === "delivered" ? "Confirm Delivery & Release Payout" : `Advance to ${statusLabel[next]}`,
												" ",
												/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChevronRight, { className: "w-4 h-4 ml-1" })
											]
										}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
											size: "sm",
											variant: "outline",
											disabled: true,
											children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RotateCcw, { className: "w-3 h-3 mr-1" }), " Delivered & Paid"]
										})
									]
								})]
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
								className: "flex flex-wrap gap-2 items-center",
								children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
									className: "text-xs font-semibold text-neutral-500 mr-1",
									children: "Admin Controls:"
								}), steps.map((s, i) => {
									const done = i <= idx;
									const isCurrent = i === idx;
									const isFuture = i > idx;
									const isDeliveredStep = s === "delivered";
									return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
										disabled: !isFuture,
										onClick: () => {
											setStatus(o.id, s);
											if (s === "delivered") toast.success(`Order ${o.id} marked as DELIVERED! Payment released to vendor wallet.`);
										},
										className: [
											"text-xs px-3 py-1.5 rounded-full border transition font-medium",
											isCurrent && "bg-orange-500 text-white border-orange-500 font-bold",
											done && !isCurrent && "bg-emerald-50 text-emerald-700 border-emerald-200",
											isFuture && isDeliveredStep && "bg-emerald-600 text-white border-emerald-600 font-bold hover:bg-emerald-700 shadow-sm cursor-pointer",
											isFuture && !isDeliveredStep && "bg-white text-neutral-700 border-neutral-300 hover:border-orange-400 hover:text-orange-600 cursor-pointer"
										].filter(Boolean).join(" "),
										children: [
											i + 1,
											". ",
											statusLabel[s],
											" ",
											isDeliveredStep ? "⚡ (Confirm Payout)" : ""
										]
									}, s);
								})]
							})]
						}, o.id);
					})
				}) : tab === "vendors" ? vendors.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "bg-white rounded-lg border p-10 text-center",
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Store, { className: "w-12 h-12 text-neutral-300 mx-auto mb-3" }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
							className: "text-lg font-bold",
							children: "No vendors yet"
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
							className: "text-sm text-neutral-500 mt-1",
							children: "Vendor applications will appear here."
						})
					]
				}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
					className: "space-y-4",
					children: vendors.map((v) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "bg-white rounded-lg border p-5 flex flex-wrap items-center justify-between gap-4",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
								className: "flex items-center gap-2",
								children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
									className: "font-bold text-lg",
									children: v.businessName
								}), v.status === "approved" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
									className: "text-xs px-2 py-0.5 rounded-full bg-emerald-100 text-emerald-700 font-medium",
									children: "Approved"
								}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
									className: "text-xs px-2 py-0.5 rounded-full bg-amber-100 text-amber-700 font-medium",
									children: "Pending"
								})]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
								className: "text-sm text-neutral-500 mt-1",
								children: [
									v.contactName,
									" · ",
									v.contactEmail
								]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
								className: "text-xs text-neutral-400 mt-0.5",
								children: ["Applied ", new Date(v.appliedAt).toLocaleDateString()]
							})
						] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "flex gap-2 items-center flex-wrap mt-2 sm:mt-0",
							children: [
								v.status === "pending" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
									size: "sm",
									onClick: () => adminApproveVendor(v.id),
									className: "bg-emerald-500 hover:bg-emerald-600",
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CircleCheck, { className: "w-4 h-4 mr-1.5" }), " Approve"]
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
									size: "sm",
									variant: "outline",
									onClick: () => setViewVendor(v),
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Eye, { className: "w-4 h-4 mr-1" }), " View Details"]
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
									size: "sm",
									variant: "outline",
									onClick: () => setEditVendor(v),
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SquarePen, { className: "w-4 h-4 mr-1" }), " Edit"]
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
									size: "sm",
									variant: "outline",
									className: "text-red-500 hover:text-red-600 hover:bg-red-50",
									onClick: () => {
										if (confirm("Are you sure you want to delete this vendor?")) adminDeleteVendor(v.id);
									},
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trash2, { className: "w-4 h-4 mr-1" }), " Delete"]
								}),
								v.status === "approved" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
									to: "/admin/vendors/$id",
									params: { id: v.id },
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
										size: "sm",
										variant: "outline",
										children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(LayoutDashboard, { className: "w-4 h-4 mr-1" }), " Dashboard"]
									})
								}), v.storeSlug && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
									to: "/$storeSlug",
									params: { storeSlug: v.storeSlug },
									target: "_blank",
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
										size: "sm",
										variant: "outline",
										className: "text-orange-600 hover:text-orange-700 hover:bg-orange-50",
										children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExternalLink, { className: "w-4 h-4 mr-1" }), " Storefront"]
									})
								})] })
							]
						})]
					}, v.id))
				}) : tab === "products" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
					className: "space-y-4",
					children: getAllProducts().map((p) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "bg-white rounded-lg border p-4 flex flex-wrap items-center justify-between gap-4",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "flex items-center gap-3",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
								src: p.images?.[0] || `https://picsum.photos/seed/${p.seed}/60/60`,
								className: "w-12 h-12 rounded object-cover border"
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
								className: "font-medium text-sm",
								children: p.name
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
								className: "text-xs text-neutral-500",
								children: [
									p.category,
									" ",
									p.vendorEmail ? `· By Vendor` : `· Official`
								]
							})] })]
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "flex items-center gap-4",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
								className: "font-bold text-sm",
								children: ["₦ ", fmt(p.price)]
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
								className: "flex gap-2",
								children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
									size: "sm",
									variant: "outline",
									onClick: () => setEditProduct(p),
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SquarePen, { className: "w-4 h-4 mr-1" }), " Edit"]
								}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
									size: "sm",
									variant: "outline",
									className: "text-red-500 hover:text-red-600 hover:bg-red-50",
									onClick: () => {
										if (confirm("Are you sure?")) removeProduct(p.id);
									},
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trash2, { className: "w-4 h-4 mr-1" }), " Delete"]
								})]
							})]
						})]
					}, p.id))
				}) : tab === "withdrawals" ? withdrawals.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "bg-white rounded-lg border p-10 text-center",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
						className: "text-lg font-bold",
						children: "No withdrawals"
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
						className: "text-sm text-neutral-500 mt-1",
						children: "There are no withdrawal requests."
					})]
				}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
					className: "space-y-4",
					children: withdrawals.map((w) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "bg-white rounded-lg border p-5 flex flex-wrap items-center justify-between gap-4",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
								className: "font-bold text-lg",
								children: [
									"Payable: ₦ ",
									fmt(w.amount * .99),
									" ",
									/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
										className: "text-xs font-normal text-neutral-400",
										children: [
											"(1% VAT deducted from ₦ ",
											fmt(w.amount),
											")"
										]
									})
								]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
								className: "text-sm text-neutral-500 mt-1",
								children: ["Vendor: ", w.vendorEmail]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
								className: "text-xs text-neutral-400 mt-0.5",
								children: ["Requested: ", (/* @__PURE__ */ new Date(w.requestedAt * 1e3)).toLocaleString()]
							})
						] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							className: "flex items-center gap-2",
							children: w.status === "pending" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
								size: "sm",
								onClick: () => adminUpdateWithdrawal(w.id, "approve"),
								className: "bg-emerald-500 hover:bg-emerald-600",
								children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CircleCheck, { className: "w-4 h-4 mr-1.5" }), " Approve"]
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
								size: "sm",
								variant: "outline",
								onClick: () => adminUpdateWithdrawal(w.id, "reject"),
								className: "text-red-500 hover:bg-red-50 hover:text-red-600",
								children: "Reject"
							})] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
								className: `text-xs px-2 py-1 rounded-full ${w.status === "approved" ? "bg-emerald-100 text-emerald-800" : "bg-red-100 text-red-800"}`,
								children: w.status.charAt(0).toUpperCase() + w.status.slice(1)
							})
						})]
					}, w.id))
				}) : tab === "reviews" ? adminReviews.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "bg-white rounded-lg border p-10 text-center",
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Video, { className: "w-12 h-12 text-neutral-300 mx-auto mb-3" }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
							className: "text-lg font-bold",
							children: "No customer video reviews"
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
							className: "text-sm text-neutral-500 mt-1",
							children: "Submitted video reviews requiring admin approval will appear here."
						})
					]
				}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
					className: "space-y-4",
					children: adminReviews.map((r) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "bg-white rounded-lg border p-5 flex flex-col md:flex-row gap-5",
						children: [r.video_url && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							className: "w-full md:w-56 h-40 bg-black rounded-lg overflow-hidden shrink-0 border relative",
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("video", {
								src: r.video_url,
								controls: true,
								className: "w-full h-full object-cover"
							})
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "flex-1 flex flex-col justify-between",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "flex flex-wrap items-center justify-between gap-2 mb-2",
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
										className: "flex items-center gap-2",
										children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
											className: "font-bold text-base",
											children: r.title || "Customer Review"
										}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
											className: `text-xs px-2.5 py-0.5 rounded-full font-bold uppercase ${r.status === "approved" ? "bg-emerald-100 text-emerald-800 border border-emerald-300" : r.status === "rejected" ? "bg-red-100 text-red-800 border border-red-300" : "bg-amber-100 text-amber-800 border border-amber-300"}`,
											children: r.status || "pending"
										})]
									}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
										className: "flex items-center text-amber-500 font-bold text-sm",
										children: [Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Star, { className: `w-4 h-4 ${i < (r.rating || 5) ? "fill-amber-400 text-amber-400" : "text-neutral-300"}` }, i)), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
											className: "ml-1 text-neutral-700",
											children: [
												"(",
												r.rating || 5,
												"/5)"
											]
										})]
									})]
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
									className: "text-sm text-neutral-700 bg-neutral-50 p-3 rounded border mb-3 font-normal",
									children: [
										"\"",
										r.comment,
										"\""
									]
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "text-xs text-neutral-500 space-y-0.5",
									children: [
										/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Customer:" }),
											" ",
											r.user_name,
											" (",
											r.user_email,
											")"
										] }),
										/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Product:" }),
											" ",
											r.product_name || r.product_id
										] }),
										/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Submitted:" }),
											" ",
											new Date(r.created_at || Date.now()).toLocaleString()
										] })
									]
								})
							] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
								className: "flex items-center gap-2 pt-4 border-t mt-4",
								children: [
									r.status !== "approved" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
										size: "sm",
										onClick: () => handleApproveReview(r.id),
										className: "bg-emerald-600 hover:bg-emerald-700 text-white font-bold",
										children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CircleCheck, { className: "w-4 h-4 mr-1.5" }), " Approve & Publish Review"]
									}),
									r.status !== "rejected" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
										size: "sm",
										variant: "outline",
										onClick: () => handleRejectReview(r.id),
										className: "text-amber-700 border-amber-300 hover:bg-amber-50",
										children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CircleX, { className: "w-4 h-4 mr-1.5" }), " Reject Review"]
									}),
									/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
										size: "sm",
										variant: "outline",
										onClick: () => handleDeleteReview(r.id),
										className: "text-red-600 border-red-200 hover:bg-red-50 hover:border-red-300 ml-auto",
										children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trash2, { className: "w-4 h-4 mr-1" }), " Delete Review"]
									})
								]
							})]
						})]
					}, r.id))
				}) : tab === "settings" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "bg-white rounded-lg border p-6 max-w-3xl",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "flex items-center gap-3 mb-6",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Settings, { className: "w-6 h-6 text-neutral-400" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
							className: "text-xl font-bold",
							children: "Settings"
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
							className: "text-sm text-neutral-500 mt-0.5",
							children: "Configure store preferences and API keys."
						})] })]
					}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "space-y-6",
						children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
									className: "block text-sm font-medium text-neutral-700 mb-1",
									children: "Paystack Public Key"
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
									value: paystackKey,
									onChange: (e) => setPaystackKey(e.target.value),
									placeholder: "pk_test_...",
									className: "font-mono text-sm max-w-sm"
								}),
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
									className: "text-xs text-neutral-500 mt-1",
									children: "Required to process real payments via Paystack."
								})
							] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
								className: "pt-6 border-t",
								children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "flex items-center justify-between mb-4",
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
										className: "text-sm font-bold text-neutral-800",
										children: "Homepage Top Banners"
									}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
										className: "text-xs text-neutral-500",
										children: "Edit the circular category items on the homepage carousel."
									})] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
										size: "sm",
										variant: "outline",
										onClick: () => setTopBanners([...topBanners, {
											id: Math.random().toString(),
											title: "New Item",
											image: "https://picsum.photos/seed/new/120/120"
										}]),
										children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Plus, { className: "w-4 h-4 mr-1.5" }), " Add Banner"]
									})]
								}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "space-y-3",
									children: [topBanners.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
										className: "flex gap-3 items-center bg-neutral-50 p-2 rounded border",
										children: [
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
												src: b.image,
												alt: b.title,
												className: "w-10 h-10 rounded-full bg-white object-cover shadow-sm border"
											}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
												className: "flex-1 space-y-1",
												children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
													value: b.title,
													onChange: (e) => {
														const nb = [...topBanners];
														nb[i].title = e.target.value;
														setTopBanners(nb);
													},
													placeholder: "Banner Title",
													className: "h-8 text-sm bg-white"
												}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ImageUpload, {
													value: b.image,
													onChange: (url) => {
														const nb = [...topBanners];
														nb[i].image = url;
														setTopBanners(nb);
													}
												})]
											}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
												size: "icon",
												variant: "ghost",
												className: "text-red-500 hover:text-red-600 hover:bg-red-50 shrink-0",
												onClick: () => {
													setTopBanners(topBanners.filter((_, idx) => idx !== i));
												},
												children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trash2, { className: "w-4 h-4" })
											})
										]
									}, b.id)), topBanners.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
										className: "text-center p-4 text-sm text-neutral-500 bg-neutral-50 rounded border border-dashed",
										children: "No banners configured. Add one above."
									})]
								})]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
								className: "pt-6 border-t",
								children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "flex items-center justify-between mb-4",
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
										className: "text-sm font-bold text-neutral-800",
										children: "Hero Banners"
									}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
										className: "text-xs text-neutral-500",
										children: "Edit the sliding banners on the homepage."
									})] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
										size: "sm",
										variant: "outline",
										onClick: () => setHeroBanners([...heroBanners, {
											id: Math.random().toString(),
											image: "https://images.unsplash.com/photo-1607082348824-0a96f2a4b9da?w=1200&h=500&fit=crop",
											link: ""
										}]),
										children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Plus, { className: "w-4 h-4 mr-1.5" }), " Add Hero Banner"]
									})]
								}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "space-y-3",
									children: [heroBanners.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
										className: "flex gap-3 items-center bg-neutral-50 p-2 rounded border",
										children: [
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
												src: b.image,
												alt: "Hero banner preview",
												className: "w-20 h-10 rounded bg-white object-cover shadow-sm border"
											}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
												className: "flex-1 space-y-1",
												children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ImageUpload, {
													value: b.image,
													onChange: (url) => {
														const nb = [...heroBanners];
														nb[i].image = url;
														setHeroBanners(nb);
													}
												}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
													value: b.link || "",
													onChange: (e) => {
														const nb = [...heroBanners];
														nb[i].link = e.target.value;
														setHeroBanners(nb);
													},
													placeholder: "Banner Link URL (Optional)",
													className: "h-8 text-sm bg-white"
												})]
											}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
												size: "icon",
												variant: "ghost",
												className: "text-red-500 hover:text-red-600 hover:bg-red-50 shrink-0",
												onClick: () => {
													setHeroBanners(heroBanners.filter((_, idx) => idx !== i));
												},
												children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trash2, { className: "w-4 h-4" })
											})
										]
									}, b.id)), heroBanners.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
										className: "text-center p-4 text-sm text-neutral-500 bg-neutral-50 rounded border border-dashed",
										children: "No hero banners configured. Add one above."
									})]
								})]
							}),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
								className: "pt-6 border-t",
								children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
									className: "flex items-center justify-between mb-4",
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
										className: "text-sm font-bold text-neutral-800",
										children: "Tawk.to AI Live Chat Channels"
									}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
										className: "text-xs text-neutral-500",
										children: "Configure Property IDs for Admin-Buyer and Vendor-Admin chats."
									})] })
								}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "grid md:grid-cols-2 gap-4 bg-neutral-50 p-4 rounded-xl border",
									children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
										className: "space-y-2",
										children: [
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
												className: "text-xs font-semibold text-neutral-700 block",
												children: "Channel 1: Admin & Buyer Tawk Property"
											}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
												placeholder: "e.g. 600000000000000000000000",
												defaultValue: localStorage.getItem("tawk_property_admin-buyer") || "",
												onChange: (e) => localStorage.setItem("tawk_property_admin-buyer", e.target.value),
												className: "text-xs bg-white"
											}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
												placeholder: "Widget ID e.g. 1f0000000",
												defaultValue: localStorage.getItem("tawk_widget_admin-buyer") || "",
												onChange: (e) => localStorage.setItem("tawk_widget_admin-buyer", e.target.value),
												className: "text-xs bg-white"
											})
										]
									}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
										className: "space-y-2",
										children: [
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
												className: "text-xs font-semibold text-neutral-700 block",
												children: "Channel 2: Vendor & Admin Tawk Property"
											}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
												placeholder: "e.g. 600000000000000000000001",
												defaultValue: localStorage.getItem("tawk_property_vendor-admin") || "",
												onChange: (e) => localStorage.setItem("tawk_property_vendor-admin", e.target.value),
												className: "text-xs bg-white"
											}),
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
												placeholder: "Widget ID e.g. 1f0000001",
												defaultValue: localStorage.getItem("tawk_widget_vendor-admin") || "",
												onChange: (e) => localStorage.setItem("tawk_widget_vendor-admin", e.target.value),
												className: "text-xs bg-white"
											})
										]
									})]
								})]
							})
						]
					})]
				}) : tab === "reviews" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "bg-white rounded-xl border p-6 space-y-6",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "flex flex-col sm:flex-row sm:items-center justify-between gap-4 border-b pb-4",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h2", {
							className: "text-xl font-bold flex items-center gap-2",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Video, { className: "w-5 h-5 text-orange-500" }), " Customer Video Reviews Moderation"]
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
							className: "text-xs text-neutral-500 mt-1",
							children: "Reviews must be confirmed by Admin before they appear on vendor storefronts and product pages."
						})] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
							size: "sm",
							variant: "outline",
							onClick: fetchAdminReviews,
							className: "text-xs shrink-0",
							children: "Refresh Reviews"
						})]
					}), adminReviews.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "text-center py-12 text-neutral-500 text-sm",
						children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Video, { className: "w-12 h-12 text-neutral-300 mx-auto mb-3" }), "No customer video reviews submitted yet."]
					}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
						className: "space-y-4",
						children: adminReviews.map((rev) => {
							const revStatus = rev.status || "pending";
							const isApproved = revStatus === "approved";
							const isRejected = revStatus === "rejected";
							return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
								className: "border rounded-xl p-4 bg-neutral-50/50 flex flex-col sm:flex-row gap-4 items-start hover:border-neutral-300 transition",
								children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
									className: "w-full sm:w-56 shrink-0",
									children: rev.video_url ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("video", {
										src: rev.video_url,
										controls: true,
										className: "w-full h-36 object-cover rounded-lg bg-black shadow-sm border"
									}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
										className: "w-full h-36 bg-neutral-200 rounded-lg flex items-center justify-center text-xs text-neutral-500",
										children: "No Video File"
									})
								}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
									className: "flex-1 space-y-2 text-xs",
									children: [
										/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
											className: "flex flex-wrap items-start justify-between gap-2",
											children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
												className: "font-bold text-sm text-neutral-900",
												children: rev.product_name || `Product: ${rev.product_id}`
											}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
												className: "text-neutral-500 mt-0.5",
												children: [
													"Submitted by ",
													/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", {
														className: "text-neutral-800",
														children: rev.user_name
													}),
													" (",
													rev.user_email,
													") · Order ",
													rev.order_id
												]
											})] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
												className: `text-[11px] px-2.5 py-0.5 rounded-full font-bold uppercase border ${isApproved ? "bg-emerald-50 text-emerald-700 border-emerald-200" : isRejected ? "bg-red-50 text-red-700 border-red-200" : "bg-amber-50 text-amber-700 border-amber-200"}`,
												children: isApproved ? "Approved & Public" : isRejected ? "Rejected" : "Pending Confirmation"
											})]
										}),
										/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
											className: "flex items-center gap-1",
											children: [[
												1,
												2,
												3,
												4,
												5
											].map((s) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Star, { className: `w-3.5 h-3.5 ${s <= (rev.rating || 5) ? "text-amber-400 fill-amber-400" : "text-neutral-300"}` }, s)), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
												className: "ml-1 text-[11px] font-bold text-neutral-600",
												children: [rev.rating || 5, "/5 Stars"]
											})]
										}),
										/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
											className: "bg-white p-3 rounded-lg border text-xs space-y-1",
											children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
												className: "font-bold text-neutral-900",
												children: rev.title
											}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
												className: "text-neutral-600 leading-relaxed",
												children: rev.comment
											})]
										}),
										/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
											className: "pt-2 flex flex-wrap gap-2 items-center",
											children: [!isApproved && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
												size: "sm",
												onClick: () => handleApproveReview(rev.id),
												className: "bg-emerald-600 hover:bg-emerald-700 text-white font-semibold text-xs gap-1.5 h-8",
												children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CircleCheck, { className: "w-3.5 h-3.5" }), " Approve & Publish Review"]
											}), !isRejected && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
												size: "sm",
												variant: "outline",
												onClick: () => handleRejectReview(rev.id),
												className: "border-red-300 text-red-600 hover:bg-red-50 text-xs gap-1.5 h-8",
												children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CircleX, { className: "w-3.5 h-3.5" }), " Reject Review"]
											})]
										})
									]
								})]
							}, rev.id);
						})
					})]
				}) : null]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Dialog, {
				open: !!viewVendor,
				onOpenChange: (o) => !o && setViewVendor(null),
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogContent, {
					className: "sm:max-w-[600px] max-h-[80vh] overflow-y-auto",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogTitle, { children: ["Vendor Details: ", viewVendor?.businessName] }) }), viewVendor && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
						className: "grid grid-cols-2 gap-4 text-sm mt-4",
						children: [
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
								className: "text-neutral-500 block text-xs",
								children: "Business Type"
							}), viewVendor.businessType] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
								className: "text-neutral-500 block text-xs",
								children: "Category"
							}), viewVendor.category] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
								className: "text-neutral-500 block text-xs",
								children: "RC Number"
							}), viewVendor.rcNumber || "-"] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
								className: "text-neutral-500 block text-xs",
								children: "Tax ID"
							}), viewVendor.taxId || "-"] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
								className: "text-neutral-500 block text-xs",
								children: "Contact Name"
							}), viewVendor.contactName] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
								className: "text-neutral-500 block text-xs",
								children: "Contact Email"
							}), viewVendor.contactEmail] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
								className: "text-neutral-500 block text-xs",
								children: "Contact Phone"
							}), viewVendor.contactPhone] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
								/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
									className: "text-neutral-500 block text-xs",
									children: "Address"
								}),
								viewVendor.address,
								", ",
								viewVendor.city,
								", ",
								viewVendor.state
							] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
								className: "text-neutral-500 block text-xs",
								children: "GPS Location"
							}), viewVendor.lat && viewVendor.lng ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("a", {
								href: `https://www.google.com/maps/search/?api=1&query=${viewVendor.lat},${viewVendor.lng}`,
								target: "_blank",
								rel: "noreferrer",
								className: "text-orange-500 hover:underline",
								children: [
									"View on Map (",
									viewVendor.lat.toFixed(4),
									", ",
									viewVendor.lng.toFixed(4),
									")"
								]
							}) : "-"] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
								className: "text-neutral-500 block text-xs",
								children: "Bank Name"
							}), viewVendor.bankName] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
								className: "text-neutral-500 block text-xs",
								children: "Account Name"
							}), viewVendor.accountName] }),
							/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
								className: "text-neutral-500 block text-xs",
								children: "Account Number"
							}), viewVendor.accountNumber] })
						]
					})]
				})
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Dialog, {
				open: !!editVendor,
				onOpenChange: (o) => !o && setEditVendor(null),
				children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogContent, {
					className: "sm:max-w-[500px]",
					children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogTitle, { children: "Edit Vendor" }) }), editVendor && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditVendorForm, {
						vendor: editVendor,
						onClose: () => setEditVendor(null),
						onSave: adminEditVendor
					})]
				})
			})
		]
	});
}
//#endregion
export { AdminPage as component };
