import { r as reactExports, U as jsxRuntimeExports } from "./worker-entry-Xz__m-MI.js";
import { u as useSuspenseQuery } from "./useSuspenseQuery-CUxLKZvE.js";
import { i as useQueryClient, t as toast, s as supabase } from "./router-CHpUX3w1.js";
import { S as Switch, U as Upload, s as slugify, u as uploadProductImage } from "./upload-DM4WBTnj.js";
import { C as Card } from "./card-Cu-N09iC.js";
import { B as Badge } from "./badge-Q-5VUHkZ.js";
import { B as Button } from "./button-DpKP5ewx.js";
import { a as adminProductsQueryOptions, f as formatBDT } from "./format-BJ9Pc8X9.js";
import { D as Dialog, a as DialogContent, b as DialogHeader, c as DialogTitle, e as DialogFooter } from "./dialog-Cw8a5lVd.js";
import { I as Input } from "./input-79qqvIMV.js";
import { L as Label } from "./label-BQmy2bHJ.js";
import { T as Textarea } from "./textarea-CV9jx0-G.js";
import { P as Plus } from "./plus-DhfO3J3U.js";
import { L as LoaderCircle } from "./loader-circle-ON2Oh-nH.js";
import { T as Trash2 } from "./trash-2-BYAqX1Cv.js";
import { P as Pencil } from "./pencil-yYqJ3yuD.js";
import "node:events";
import "node:async_hooks";
import "node:stream/web";
import "node:stream";
import "./createLucideIcon-4cZKQB6y.js";
import "./index-P9m2NEcT.js";
import "./index-GGTY6NM3.js";
import "./utils-Bz4m9VPB.js";
import "./Combination-DLYpVfee.js";
const ALL_SIZES = ["S", "M", "L", "XL", "XXL", "Free"];
function ProductEditorDialog({ open, onOpenChange, product }) {
  const qc = useQueryClient();
  const [saving, setSaving] = reactExports.useState(false);
  const [name, setName] = reactExports.useState("");
  const [slug, setSlug] = reactExports.useState("");
  const [category, setCategory] = reactExports.useState("");
  const [fabric, setFabric] = reactExports.useState("");
  const [description, setDescription] = reactExports.useState("");
  const [price, setPrice] = reactExports.useState("");
  const [oldPrice, setOldPrice] = reactExports.useState("");
  const [sizes, setSizes] = reactExports.useState([]);
  const [isActive, setIsActive] = reactExports.useState(true);
  const [isNew, setIsNew] = reactExports.useState(false);
  const [isBestseller, setIsBestseller] = reactExports.useState(false);
  const [displayOrder, setDisplayOrder] = reactExports.useState("0");
  const [variants, setVariants] = reactExports.useState([]);
  const [autoSlug, setAutoSlug] = reactExports.useState(true);
  reactExports.useEffect(() => {
    if (!open) return;
    if (product) {
      setName(product.name);
      setSlug(product.slug);
      setAutoSlug(false);
      setCategory(product.category);
      setFabric(product.fabric);
      setDescription(product.description);
      setPrice(String(product.price));
      setOldPrice(product.old_price !== null ? String(product.old_price) : "");
      setSizes(product.sizes ?? []);
      setIsActive(product.is_active);
      setIsNew(product.is_new);
      setIsBestseller(product.is_bestseller);
      setDisplayOrder(String(product.display_order));
      setVariants(
        [...product.product_variants].sort((a, b) => a.display_order - b.display_order).map((v) => ({
          id: v.id,
          color_name: v.color_name,
          color_hex: v.color_hex,
          image_url: v.image_url,
          display_order: v.display_order
        }))
      );
    } else {
      setName("");
      setSlug("");
      setAutoSlug(true);
      setCategory("");
      setFabric("");
      setDescription("");
      setPrice("");
      setOldPrice("");
      setSizes([]);
      setIsActive(true);
      setIsNew(false);
      setIsBestseller(false);
      setDisplayOrder("0");
      setVariants([]);
    }
  }, [open, product]);
  const onNameChange = (v) => {
    setName(v);
    if (autoSlug) setSlug(slugify(v));
  };
  const toggleSize = (s) => {
    setSizes((prev) => prev.includes(s) ? prev.filter((x) => x !== s) : [...prev, s]);
  };
  const addVariant = () => {
    setVariants((v) => [
      ...v,
      { color_name: "", color_hex: "#000000", image_url: "", display_order: v.length, _new: true }
    ]);
  };
  const removeVariant = (idx) => {
    setVariants((v) => v.filter((_, i) => i !== idx));
  };
  const updateVariant = (idx, patch) => {
    setVariants((v) => v.map((x, i) => i === idx ? { ...x, ...patch } : x));
  };
  const handleVariantImage = async (idx, e) => {
    const file = e.target.files?.[0];
    if (!file) return;
    if (file.size > 5 * 1024 * 1024) {
      toast.error("ছবি ৫MB এর কম হতে হবে");
      return;
    }
    updateVariant(idx, { uploading: true });
    try {
      const url = await uploadProductImage(file);
      updateVariant(idx, { image_url: url, uploading: false });
      toast.success("ছবি আপলোড হয়েছে");
    } catch (err) {
      updateVariant(idx, { uploading: false });
      toast.error(err instanceof Error ? err.message : "আপলোড ব্যর্থ");
    }
  };
  const validate = () => {
    if (!name.trim()) return "প্রোডাক্টের নাম দিন";
    if (!slug.trim()) return "Slug দিন";
    if (!category.trim()) return "ক্যাটাগরি দিন";
    if (!fabric.trim()) return "ফেব্রিক দিন";
    if (!description.trim()) return "বিবরণ দিন";
    const p = Number(price);
    if (!p || p <= 0) return "সঠিক মূল্য দিন";
    if (oldPrice && Number(oldPrice) <= p) return "পুরাতন মূল্য নতুন মূল্যের চেয়ে বেশি হতে হবে";
    if (sizes.length === 0) return "অন্তত একটি সাইজ নির্বাচন করুন";
    if (variants.length === 0) return "অন্তত একটি কালার ভ্যারিয়েন্ট দিন";
    for (const v of variants) {
      if (!v.color_name.trim()) return "প্রতিটি ভ্যারিয়েন্টের কালার নাম দিন";
      if (!v.image_url) return `${v.color_name || "কালার"} এর ছবি আপলোড করুন`;
    }
    return null;
  };
  const handleSave = async () => {
    const err = validate();
    if (err) {
      toast.error(err);
      return;
    }
    setSaving(true);
    try {
      const payload = {
        name: name.trim(),
        slug: slug.trim(),
        category: category.trim(),
        fabric: fabric.trim(),
        description: description.trim(),
        price: Number(price),
        old_price: oldPrice ? Number(oldPrice) : null,
        sizes,
        is_active: isActive,
        is_new: isNew,
        is_bestseller: isBestseller,
        display_order: Number(displayOrder) || 0
      };
      let productId;
      if (product) {
        const { error } = await supabase.from("products").update(payload).eq("id", product.id);
        if (error) throw new Error(error.message);
        productId = product.id;
        const existingIds = product.product_variants.map((v) => v.id);
        const keptIds = variants.filter((v) => v.id).map((v) => v.id);
        const toDelete = existingIds.filter((id) => !keptIds.includes(id));
        if (toDelete.length > 0) {
          const { error: delErr } = await supabase.from("product_variants").delete().in("id", toDelete);
          if (delErr) throw new Error(delErr.message);
        }
      } else {
        const { data, error } = await supabase.from("products").insert(payload).select("id").single();
        if (error) throw new Error(error.message);
        productId = data.id;
      }
      for (let i = 0; i < variants.length; i++) {
        const v = variants[i];
        const variantPayload = {
          product_id: productId,
          color_name: v.color_name.trim(),
          color_hex: v.color_hex,
          image_url: v.image_url,
          display_order: i
        };
        if (v.id) {
          const { error: vErr } = await supabase.from("product_variants").update(variantPayload).eq("id", v.id);
          if (vErr) throw new Error(vErr.message);
        } else {
          const { error: vErr } = await supabase.from("product_variants").insert(variantPayload);
          if (vErr) throw new Error(vErr.message);
        }
      }
      toast.success(product ? "প্রোডাক্ট আপডেট হয়েছে" : "নতুন প্রোডাক্ট যোগ হয়েছে");
      qc.invalidateQueries({ queryKey: ["admin"] });
      qc.invalidateQueries({ queryKey: ["products"] });
      onOpenChange(false);
    } catch (e) {
      toast.error(e instanceof Error ? e.message : "সেভ ব্যর্থ");
    } finally {
      setSaving(false);
    }
  };
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(DialogContent, { className: "max-w-3xl max-h-[90vh] overflow-y-auto", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(DialogHeader, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(DialogTitle, { children: product ? "প্রোডাক্ট এডিট" : "নতুন প্রোডাক্ট" }) }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1.5 sm:col-span-2", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "p-name", children: "নাম *" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { id: "p-name", value: name, onChange: (e) => onNameChange(e.target.value) })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1.5", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "p-slug", children: "Slug *" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { id: "p-slug", value: slug, onChange: (e) => {
          setSlug(e.target.value);
          setAutoSlug(false);
        } })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1.5", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "p-cat", children: "ক্যাটাগরি *" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { id: "p-cat", value: category, onChange: (e) => setCategory(e.target.value), placeholder: "যেমন: শাড়ি, থ্রি-পিস" })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1.5", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "p-fab", children: "ফেব্রিক *" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { id: "p-fab", value: fabric, onChange: (e) => setFabric(e.target.value), placeholder: "যেমন: কটন, সিল্ক" })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1.5", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "p-order", children: "ডিসপ্লে অর্ডার" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { id: "p-order", type: "number", value: displayOrder, onChange: (e) => setDisplayOrder(e.target.value) })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1.5", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "p-price", children: "মূল্য (৳) *" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { id: "p-price", type: "number", value: price, onChange: (e) => setPrice(e.target.value) })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1.5", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "p-old", children: "পুরাতন মূল্য (ঐচ্ছিক)" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { id: "p-old", type: "number", value: oldPrice, onChange: (e) => setOldPrice(e.target.value) })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1.5 sm:col-span-2", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "p-desc", children: "বিবরণ *" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Textarea, { id: "p-desc", rows: 3, value: description, onChange: (e) => setDescription(e.target.value) })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2 sm:col-span-2", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { children: "সাইজ *" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-wrap gap-2", children: ALL_SIZES.map((s) => /* @__PURE__ */ jsxRuntimeExports.jsx(
          "button",
          {
            type: "button",
            onClick: () => toggleSize(s),
            className: `px-3 py-1.5 rounded-md border text-sm transition-colors ${sizes.includes(s) ? "bg-primary text-primary-foreground border-primary" : "bg-background hover:bg-accent"}`,
            children: s
          },
          s
        )) })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3 sm:col-span-2 flex-wrap", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Switch, { checked: isActive, onCheckedChange: setIsActive }),
          " সক্রিয়"
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Switch, { checked: isNew, onCheckedChange: setIsNew }),
          " নতুন"
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Switch, { checked: isBestseller, onCheckedChange: setIsBestseller }),
          " বেস্টসেলার"
        ] })
      ] })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2 pt-2 border-t", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { children: "কালার ভ্যারিয়েন্ট *" }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { type: "button", size: "sm", variant: "outline", onClick: addVariant, children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "h-4 w-4 mr-1" }),
          " কালার যোগ"
        ] })
      ] }),
      variants.length === 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground", children: "কমপক্ষে একটি কালার ভ্যারিয়েন্ট ও ছবি দিন।" }),
      /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid gap-3", children: variants.map((v, idx) => /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "p-3", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-3 items-start", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative h-20 w-20 flex-shrink-0 rounded-md border bg-muted overflow-hidden", children: [
          v.image_url ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: v.image_url, alt: v.color_name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full w-full flex items-center justify-center text-muted-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Upload, { className: "h-5 w-5" }) }),
          v.uploading && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute inset-0 bg-background/70 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(LoaderCircle, { className: "h-5 w-5 animate-spin" }) })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 grid gap-2 sm:grid-cols-2", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(
            Input,
            {
              placeholder: "কালার নাম (যেমন: লাল)",
              value: v.color_name,
              onChange: (e) => updateVariant(idx, { color_name: e.target.value })
            }
          ),
          /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
            /* @__PURE__ */ jsxRuntimeExports.jsx(
              "input",
              {
                type: "color",
                value: v.color_hex,
                onChange: (e) => updateVariant(idx, { color_hex: e.target.value }),
                className: "h-9 w-12 rounded-md border cursor-pointer"
              }
            ),
            /* @__PURE__ */ jsxRuntimeExports.jsx(
              Input,
              {
                value: v.color_hex,
                onChange: (e) => updateVariant(idx, { color_hex: e.target.value }),
                className: "flex-1 font-mono text-xs"
              }
            )
          ] }),
          /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sm:col-span-2 flex gap-2", children: [
            /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex-1", children: [
              /* @__PURE__ */ jsxRuntimeExports.jsx(
                "input",
                {
                  type: "file",
                  accept: "image/*",
                  className: "hidden",
                  onChange: (e) => handleVariantImage(idx, e)
                }
              ),
              /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "inline-flex h-9 w-full items-center justify-center rounded-md border border-input bg-background px-3 text-sm cursor-pointer hover:bg-accent", children: [
                /* @__PURE__ */ jsxRuntimeExports.jsx(Upload, { className: "h-4 w-4 mr-1" }),
                " ",
                v.image_url ? "ছবি বদলান" : "ছবি আপলোড"
              ] })
            ] }),
            /* @__PURE__ */ jsxRuntimeExports.jsx(
              Button,
              {
                type: "button",
                size: "icon",
                variant: "ghost",
                onClick: () => removeVariant(idx),
                children: /* @__PURE__ */ jsxRuntimeExports.jsx(Trash2, { className: "h-4 w-4 text-destructive" })
              }
            )
          ] })
        ] })
      ] }) }, v.id ?? `new-${idx}`)) })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs(DialogFooter, { children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), disabled: saving, children: "বাতিল" }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { onClick: handleSave, disabled: saving, children: [
        saving && /* @__PURE__ */ jsxRuntimeExports.jsx(LoaderCircle, { className: "h-4 w-4 mr-1 animate-spin" }),
        product ? "আপডেট" : "তৈরি করুন"
      ] })
    ] })
  ] }) });
}
function ProductsPage() {
  const [editorOpen, setEditorOpen] = reactExports.useState(false);
  const [editing, setEditing] = reactExports.useState(null);
  const openCreate = () => {
    setEditing(null);
    setEditorOpen(true);
  };
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between mb-4", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "text-2xl font-semibold", children: "প্রোডাক্ট ম্যানেজমেন্ট" }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { onClick: openCreate, children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "h-4 w-4 mr-1" }),
        " নতুন প্রোডাক্ট"
      ] })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-muted-foreground", children: "লোড হচ্ছে..." }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(ProductsList, { onEdit: (p) => {
      setEditing(p);
      setEditorOpen(true);
    } }) }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(ProductEditorDialog, { open: editorOpen, onOpenChange: setEditorOpen, product: editing })
  ] });
}
function ProductsList({
  onEdit
}) {
  const {
    data
  } = useSuspenseQuery(adminProductsQueryOptions());
  const qc = useQueryClient();
  const toggleActive = async (id, value) => {
    const {
      error
    } = await supabase.from("products").update({
      is_active: value
    }).eq("id", id);
    if (error) {
      toast.error(error.message);
      return;
    }
    toast.success(value ? "সক্রিয় হয়েছে" : "নিষ্ক্রিয় হয়েছে");
    qc.invalidateQueries({
      queryKey: ["admin"]
    });
    qc.invalidateQueries({
      queryKey: ["products"]
    });
  };
  const deleteProduct = async (p) => {
    if (!confirm(`"${p.name}" ডিলিট করবেন? এটি স্থায়ীভাবে মুছে যাবে।`)) return;
    const {
      error
    } = await supabase.from("products").delete().eq("id", p.id);
    if (error) {
      toast.error(error.message);
      return;
    }
    toast.success("প্রোডাক্ট ডিলিট হয়েছে");
    qc.invalidateQueries({
      queryKey: ["admin"]
    });
    qc.invalidateQueries({
      queryKey: ["products"]
    });
  };
  if (data.length === 0) {
    return /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "p-8 text-center text-muted-foreground", children: 'কোনো প্রোডাক্ট নেই। উপরে "নতুন প্রোডাক্ট" বাটনে ক্লিক করুন।' });
  }
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid gap-3", children: data.map((p) => {
    const firstImage = p.product_variants[0]?.image_url;
    return /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { className: "p-4 flex gap-3 items-center", children: [
      firstImage ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: firstImage, alt: p.name, className: "h-16 w-16 object-cover rounded-md flex-shrink-0" }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-16 w-16 rounded-md bg-muted flex-shrink-0" }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-medium truncate", children: p.name }),
          p.is_new && /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { variant: "secondary", className: "text-[10px]", children: "নতুন" }),
          p.is_bestseller && /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { className: "text-[10px]", children: "বেস্টসেলার" })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-muted-foreground", children: [
          p.category,
          " • ",
          p.fabric,
          " • ",
          p.product_variants.length,
          " কালার"
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-sm font-semibold mt-1", children: [
          formatBDT(p.price),
          p.old_price && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-muted-foreground line-through ml-1", children: formatBDT(p.old_price) })
        ] })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-end gap-2", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-muted-foreground mr-1", children: p.is_active ? "সক্রিয়" : "নিষ্ক্রিয়" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(Switch, { checked: p.is_active, onCheckedChange: (v) => toggleActive(p.id, v) })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-1", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "icon", variant: "ghost", onClick: () => onEdit(p), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Pencil, { className: "h-4 w-4" }) }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "icon", variant: "ghost", onClick: () => deleteProduct(p), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Trash2, { className: "h-4 w-4 text-destructive" }) })
        ] })
      ] })
    ] }, p.id);
  }) });
}
export {
  ProductsPage as component
};
