1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3650],{3650:(e,s,a)=>{a.r(s),a.d(s,{DashboardProductManagement:()=>ep});var t=a(7131),r=a(555),l=a(25907),i=a(50269),c=a(56771),n=a(34388),d=a(56999),o=a(6645),m=a(84160),u=a(62792),x=a(50333),h=a(83568),p=a(64408),f=a(16708),g=a(94017),v=a(24044),j=a(13009),b=a(92773),y=a(29817),N=a(44704),w=a(36900),_=a(95577),k=a(8333),S=a(59245),C=a(86972),A=a(66061),R=a(64517),z=a(63619),P=a(10220),L=a(87925),$=a(39827),q=a(38227),F=a(27753),E=a(37517),U=a(82549),M=a(29081),J=a(51942),V=a(15206),I=a(72902),D=a(9193),K=a(96590),B=a(56221),T=a(23154),O=a(49529),W=a(2781),X=a(54638),G=a(70147),H=a(3729);let Q=(0,H.createServerReference)("402e9ad41fe4f30299b084e93124db5fe74c842e1c",H.callServer,void 0,H.findSourceMapURL,"getProductsForAdminAction");var Y=a(28497),Z=a(58848),ee=a(44605),es=a(37111);let ea=(0,H.createServerReference)("706dc163b3b75c5aa20369477ce658472f09fd4e28",H.callServer,void 0,H.findSourceMapURL,"bulkUpdateProductsAction"),et=(0,H.createServerReference)("607b9ba934e2169127af5427c489d0eca090668c6b",H.callServer,void 0,H.findSourceMapURL,"bulkDeleteProductsAction");var er=a(20803),el=a(99600),ei=a(12613);let ec=(0,H.createServerReference)("601271367a4cb39c3d0893f38383b0e296eef71504",H.callServer,void 0,H.findSourceMapURL,"getProductAnalyticsAction");var en=a(75899),ed=a(50447);let eo=(0,H.createServerReference)("404a83a659b879005bd41714dcfaa2cf99f763d10d",H.callServer,void 0,H.findSourceMapURL,"updateShopEnabledAction"),em=["Books","Courses","Sermons","Merchandise","Bundles","Digital","Clothing","Other"],eu=["Book","Clothing","Digital","Physical","Bundle"],ex=["XS","S","M","L","XL","2XL","3XL"],eh=["Paperback","Hardcover","eBook","Audiobook"],ep=()=>{let e=(0,c.useRouter)(),{session:s}=(0,en.A)(),[a,H]=(0,r.useState)([]),[ep,ef]=(0,r.useState)(!0),[eg,ev]=(0,r.useState)(new Set),[ej,eb]=(0,r.useState)(!1),[ey,eN]=(0,r.useState)(null),[ew,e_]=(0,r.useState)(!0),[ek,eS]=(0,r.useState)(""),[eC,eA]=(0,r.useState)("all"),[eR,ez]=(0,r.useState)(!1),[eP,eL]=(0,r.useState)(null),[e$,eq]=(0,r.useState)([]),[eF,eE]=(0,r.useState)("table"),[eU,eM]=(0,r.useState)(!0),[eJ,e
1V]=(0,r.useState)(1),[eI,eD]=(0,r.useState)(12),[eK,eB]=(0,r.useState)(!1),[eT,eO]=(0,r.useState)(!0),[eW,eX]=(0,r.useState)(!1),[eG,eH]=(0,r.useState)({name:"",description:"",price:"",category:"Books",image_url:"",stock_quantity:"100",is_active:!0,is_free:!1,is_new_arrival:!1,is_bestseller:!1,product_type:"Physical",sizes:[],formats:[],sku:"",weight:"",compare_at_price:""});(0,r.useEffect)(()=>{eY(),eZ(),(0,ed.j)().then(e=>{e.ok&&eO(e.data.shop.enabled)}).catch(()=>{})},[]);let eQ=async e=>{eX(!0),eO(e),(await eo(e)).ok?I.oR.success(e?"Shop is now live":"Shop set to Coming Soon"):(I.oR.error("Failed to update shop status"),eO(!e)),eX(!1)},eY=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e?eB(!0):ef(!0);try{var a;let{products:t,error:r}=await Q(null!=(a=null==s?void 0:s.access_token)?a:null);r?I.oR.error("Failed to fetch products"):(H(t||[]),e||eV(1))}catch(e){I.oR.error("Failed to fetch products")}finally{ef(!1),eB(!1)}},eZ=async()=>{e_(!0);try{let{analytics:e,error:s}=await ec();s?console.error("Failed to fetch analytics:",s):eN(e)}catch(e){console.error("Error fetching analytics:",e)}finally{e_(!1)}},e0=async e=>{e.preventDefault();let s={name:eG.name,description:eG.description||null,price:parseFloat(eG.price),category:eG.category,image_url:eG.image_url||null,stock_quantity:parseInt(eG.stock_quantity)||100,is_active:eG.is_active,is_free:eG.is_free,is_new_arrival:eG.is_new_arrival,is_bestseller:eG.is_bestseller,product_type:eG.product_type,sizes:"Clothing"===eG.product_type?eG.sizes:null,formats:"Book"===eG.product_type?eG.formats:null,sku:eG.sku||null,weight:eG.weight?parseFloat(eG.weight):null,compare_at_price:eG.compare_at_price?parseFloat(eG.compare_at_price):null};if(eP){H(e=>e.map(e=>e.id===eP.id?{...e,...s}:e)),eL(null);let{product:e,error:a}=await (0,Y.n)(eP.id,s);a?(I.oR.error(a),eY(!0)):(I.oR.success("Product updated successfully"),eZ())}else{let{product:e,error:a}=await (0,Z.a)(s);a?I.oR.error(a):(I.oR.success("Product created successfully"),ez(!1),e&&H(s=>[{...e,variants:[]},...s]),eZ())}e5()},e1=async e=>{if(!confirm("Are you sure you want to delete this product?"))return;H(s=>s.filter(s=>s.id!==e));let{success:s,error:t}=await (0,ee.F)(e);t?(I.oR.error(t),H(a)):s&&(I.oR.success("Product deleted"),eZ())},e2=async e=>{let s=!e.is_active;H(a=>a.map(a=>a.id===e.id?{...a,is_active:s}:a));let{error:a}=await (0,Y.n)(e.id,{is_active:s});a?(I.oR.error(a),H(s=>s.map(s=>s.id===e.id?{...s,is_active:e.is_active}:s))):I.oR.success(s?"Product published":"Product unpublished")},e5=()=>{eH({name:"",description:"",price:"",category:"Books",image_url:"",stock_quantity:"100",is_active:!0,is_free:!1,is_new_arrival:!1,is_bestseller:!1,product_type:"Physical",sizes:[],formats:[],sku:"",weight:"",compare_at_price:""}),eq([])},e4=async e=>{var s,a,t,r,l,i,c;eH({name:e.name,description:e.description||"",price:e.price.toString(),category:e.category||"Books",image_url:e.image_url||"",stock_quantity:(null==(s=e.stock_quantity)?void 0:s.toString())||"100",is_active:null==(r=e.is_active)||r,is_free:null!=(l=e.is_free)&&l,is_new_arrival:null!=(i=e.is_new_arrival)&&i,is_bestseller:null!=(c=e.is_bestseller)&&c,product_type:e.product_type||"Physical",sizes:e.sizes||[],formats:e.formats||[],sku:e.sku||"",weight:(null==(a=e.weight)?void 0:a.toString())||"",compare_at_price:(null==(t=e.compare_at_price)?void 0:t.toString())||""}),eL(e);let{variants:n}=await (0,es.q)(e.id);eq(n||[])},e3=a.filter(e=>{var s;let a=e.name.toLowerCase().includes(ek.toLowerCase())||(null==(s=e.description)?void 0:s.toLowerCase().includes(ek.toLowerCase())),t="all"===eC||e.category===eC;return a&&t}),e6=Math.ceil(e3.length/eI),e9=(eJ-1)*eI,e7=e9+eI,e8=e3.slice(e9,e7),se=e=>{ev(s=>{let a=new Set(s);return a.has(e)?a.delete(e):a.add(e),a})},ss=async e=>{var t;if(0===eg.size)return;eb(!0);let r=Array.from(eg);H(s=>s.map(s=>r.includes(s.id)?{...s,is_active:e}:s)),ev(new Set);let{count:l,error:i}=await ea(r,{is_active:e},null!=(t=null==s?void 0:s.access_token)?t:null);i?(I.oR.error(i),H(a)):I.oR.success("".concat(l," product(s) ").concat(e?"published":"unpublished")),eb(!1)},sa=async()=>{var e;if(0===eg.size||!confirm("Delete ".concat(eg.size," product(s)? This cannot be undone.")))return;eb(!0);let t=Array.from(eg);H(e=>e.filter(e=>!t.includes(e.id))),ev(new Set);let{count:r,error:l}=await et(t,null!=(e=null==s?void 0:s.access_token)?e:null);l?(I.oR.error(l),H(a)):(I.oR.success("".concat(r," product(s) deleted")),eZ()),eb(!1)},st=async e=>{var t;if(0===eg.size)return;eb(!0);let r=Array.from(eg);H(s=>s.map(s=>
1r.includes(s.id)?{...s,category:e}:s)),ev(new Set);let{count:l,error:i}=await ea(r,{category:e},null!=(t=null==s?void 0:s.access_token)?t:null);i?(I.oR.error(i),H(a)):I.oR.success("".concat(l," product(s) moved to ").concat(e)),eb(!1)},sr=(null==ey?void 0:ey.total_revenue)||0;a.reduce((e,s)=>e+(s.view_count||0),0);let sl=(null==ey?void 0:ey.sales_by_day.map(e=>({date:new Date(e.date).toLocaleDateString("en-US",{month:"short",day:"numeric"}),revenue:e.revenue,orders:e.orders,items_sold:e.items_sold})))||[];return(0,t.jsxs)(l.P.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"space-y-6",children:[(0,t.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-5",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-2xl font-serif font-bold text-foreground",children:"Product Management"}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:[a.length," products in shop"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2.5 border border-border rounded-xl px-3.5 py-2 bg-card",children:[(0,t.jsx)(U.d,{id:"shop-toggle",checked:eT,onCheckedChange:eQ,disabled:eW}),(0,t.jsx)(M.J,{htmlFor:"shop-toggle",className:"text-sm font-medium cursor-pointer select-none whitespace-nowrap",children:eT?(0,t.jsx)("span",{className:"text-green-600 dark:text-green-400",children:"Shop Live"}):(0,t.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Coming Soon"})})]})]}),(0,t.jsxs)("div",{className:"flex gap-3",children:[(0,t.jsxs)(L.$,{variant:"outline",className:"rounded-xl gap-2",onClick:()=>eY(!0),disabled:eK,children:[(0,t.jsx)(m.A,{className:"w-4 h-4 ".concat(eK?"animate-spin":"")}),"Refresh"]}),(0,t.jsxs)("div",{className:"flex border border-border rounded-xl overflow-hidden",children:[(0,t.jsx)("button",{onClick:()=>eE("table"),className:"p-2 ".concat("table"===eF?"bg-primary text-primary-foreground":"bg-card hover:bg-muted"),title:"Table View",children:(0,t.jsx)(u.A,{className:"w-4 h-4"})}),(0,t.jsx)("button",{onClick:()=>eE("grid"),className:"p-2 ".concat("grid"===eF?"bg-primary text-primary-foreground":"bg-card hover:bg-muted"),title:"Grid View",children:(0,t.jsx)(x.A,{className:"w-4 h-4"})}),(0,t.jsx)("button",{onClick:()=>eE("list"),className:"p-2 ".concat("list"===eF?"bg-primary text-primary-foreground":"bg-card hover:bg-muted"),title:"List View",children:(0,t.jsx)(h.A,{className:"w-4 h-4"})})]}),(0,t.jsxs)(L.$,{className:"rounded-xl gap-2",onClick:()=>e.push("/dashboard/product/new"),children:[(0,t.jsx)(p.A,{className:"w-4 h-4"}),"Add Product"]})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{label:"Total Products",value:a.length,icon:f.A,color:"from-blue-500 to-cyan-500"},{label:"Active Products",value:a.filter(e=>e.is_active).length,icon:g.A,color:"from-emerald-500 to-teal-500"},{label:"Total Revenue",value:"$".concat(sr.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})),icon:v.A,color:"from-green-500 to-emerald-500"},{label:"Total Orders",value:(null==ey?void 0:ey.total_orders)||0,icon:j.A,color:"from-purple-500 to-violet-500"},{label:"Items Sold",value:(null==ey?void 0:ey.total_items_sold)||0,icon:b.A,color:"from-orange-500 to-red-500"},{label:"Low Stock (<10)",value:a.filter(e=>{let s=e.variants||[];return s.length>0?s.some(e=>10>(e.stock_quantity||0)&&e.is_active):10>(e.stock_quantity||0)}).length,icon:j.A,color:"from-red-500 to-pink-500"}].slice(0,4).map((e,s)=>(0,t.jsxs)(l.P.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1*s},className:"bg-card border border-border rounded-xl p-4 relative overflow-hidden",children:[(0,t.jsx)("div",{className:"absolute -top-6 -right-6 w-20 h-20 rounded-full bg-gradient-to-br ".concat(e.color," opacity-10 blur-xl")}),(0,t.jsxs)("div",{className:"flex items-center gap-3 relative z-10",children:[(0,t.jsx)("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br ".concat(e.color," flex items-center justify-center"),children:(0,t.jsx)(e.icon,{className:"w-5 h-5 text-white"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-2xl font-bold text-foreground",children:e.value}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.label})]})]})]},e.label))}),eU&&ey&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"bg-card border border-border rounded-xl p-5",children:[(0,t.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,t.jsxs)("h3",{className:"font-semibold text-foreground flex items-center gap-2",children:[(0,t.jsx)(y.A,{className:"w-5 h-5 text-primary"}),"Sales Analytics (Last 30 Days)"]})}),ew?(0,t.jsx)("div",{className:"h-48 flex items-center justify-center",children:(0,t.jsx)("div",{className:"animate-pulse text-muted-foreground",children:"Loading analytics..."})}):sl.length>0?(0,t.jsx)(G.at,{config:{revenue:{label:"Revenue",color:"hsl(var(--primary))"}},className:"h-64 w-full",children:(0,t.jsxs)(D.Q,{data:sl,children:[(0,t.jsx)(K.d,{strokeDasharray:"3 3",vertical:!1}
1),(0,t.jsx)(B.W,{dataKey:"date",tickLine:!1,axisLine:!1,tick:{fontSize:12}}),(0,t.jsx)(T.h,{tickLine:!1,axisLine:!1,tick:{fontSize:12},tickFormatter:e=>"$".concat(e)}),(0,t.jsx)(G.II,{content:(0,t.jsx)(G.Nt,{formatter:e=>["$".concat(Number(e).toFixed(2)),"Revenue"]})}),(0,t.jsx)(O.G,{type:"monotone",dataKey:"revenue",stroke:"var(--color-revenue)",fill:"var(--color-revenue)",fillOpacity:.2,strokeWidth:2,name:"Revenue ($)"})]})}):(0,t.jsx)("div",{className:"h-48 flex items-center justify-center text-muted-foreground",children:"No sales data available"})]}),ey.sales_by_category.length>0&&(0,t.jsxs)("div",{className:"bg-card border border-border rounded-xl p-5",children:[(0,t.jsxs)("h3",{className:"font-semibold text-foreground mb-4 flex items-center gap-2",children:[(0,t.jsx)(y.A,{className:"w-5 h-5 text-primary"}),"Sales by Category"]}),(0,t.jsx)(G.at,{config:{revenue:{label:"Revenue",color:"hsl(var(--primary))"}},className:"h-64 w-full",children:(0,t.jsxs)(W.E,{data:ey.sales_by_category,children:[(0,t.jsx)(K.d,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(B.W,{dataKey:"category",tickLine:!1,axisLine:!1,tick:{fontSize:12}}),(0,t.jsx)(T.h,{tickLine:!1,axisLine:!1,tick:{fontSize:12},tickFormatter:e=>"$".concat(e)}),(0,t.jsx)(G.II,{content:(0,t.jsx)(G.Nt,{formatter:e=>["$".concat(Number(e).toFixed(2)),"Revenue"]})}),(0,t.jsx)(X.y,{dataKey:"revenue",fill:"var(--color-revenue)",radius:[4,4,0,0],name:"Revenue ($)"})]})})]})]}),ey.top_products.length>0&&(0,t.jsxs)("div",{className:"bg-card border border-border rounded-xl p-5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("h3",{className:"font-semibold text-foreground flex items-center gap-2",children:[(0,t.jsx)(b.A,{className:"w-5 h-5 text-primary"}),"Top Selling Products"]}),(0,t.jsx)(L.$,{variant:"ghost",size:"sm",onClick:()=>eM(!1),children:(0,t.jsx)(N.A,{className:"w-4 h-4"})})]}),(0,t.jsx)("div",{className:"space-y-3",children:ey.top_products.slice(0,5).map((e,s)=>(0,t.jsxs)("div",{className:"flex items-center gap-4 p-3 bg-muted/50 rounded-lg",children:[(0,t.jsx)("div",{className:"w-12 h-12 rounded-lg overflow-hidden bg-muted flex-shrink-0",children:e.product_image_url?(0,t.jsx)("img",{src:e.product_image_url,alt:e.product_name,className:"w-full h-full object-cover"}):(0,t.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,t.jsx)(f.A,{className:"w-6 h-6 text-muted-foreground"})})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"font-medium text-foreground truncate",children:e.product_name}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[e.total_quantity_sold," sold \xb7"," ",e.order_count," orders"]})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsxs)("p",{className:"font-bold text-primary",children:["$",e.total_revenue.toFixed(2)]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Revenue"})]})]},e.product_id))})]})]}),!eU&&(0,t.jsx)(L.$,{variant:"outline",onClick:()=>eM(!0),className:"w-full",children:"Show Analytics"}),(0,t.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,t.jsxs)("div",{className:"relative flex-1",children:[(0,t.jsx)(w.A,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),(0,t.jsx)($.p,{value:ek,onChange:e=>eS(e.target.value),placeholder:"Search products...",className:"pl-10 rounded-xl"})]}),(0,t.jsxs)(F.l6,{value:eC,onValueChange:eA,children:[(0,t.jsx)(F.bq,{className:"w-full md:w-48 rounded-xl",children:(0,t.jsx)(F.yv,{placeholder:"All Categories"})}),(0,t.jsxs)(F.gC,{children:[(0,t.jsx)(F.eb,{value:"all",children:"All Categories"}),em.map(e=>(0,t.jsx)(F.eb,{value:e,children:e},e))]})]})]}),(0,t.jsx)(i.N,{children:eg.size>0&&(0,t.jsxs)(l.P.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:"sticky top-16 z-30 bg-primary/95 backdrop-blur text-primary-foreground rounded-xl p-3 flex items-center gap-3 shadow-lg",children:[(0,t.jsx)(_.A,{className:"w-4 h-4"}),(0,t.jsxs)("span",{className:"text-sm font-medium",children:[eg.size," selected"]}),(0,t.jsx)("div",{className:"flex-1"}),(0,t.jsxs)(L.$,{size:"sm",variant:"secondary",disabled:ej,onClick:()=>ss(!0),className:"gap-1",children:[(0,t.jsx)(g.A,{className:"w-3.5 h-3.5"})," Publish"]}),(0,t.jsxs)(L.$,{size:"sm",variant:"secondary",disabled:ej,onClick:()=>ss(!1),className:"gap-1",children:[(0,t.jsx)(k.A,{className:"w-3.5 h-3.5"})," Unpublish"]}),(0,t.jsxs)(F.l6,{onValueChange:st,children:[(0,t.jsx)(F.bq,{className:"w-36 h-8 text-xs bg-secondary text-secondary-foreground border-none",children:(0,t.jsx)(F.yv,{placeholder:"Move toâ¦"})}),(0,t.jsx)(F.gC,{children:em.map(e=>(0,t.jsx)(F.eb,{value:e,children:e},e))})]}),(0,t.jsxs)(L.$,{size:"sm",variant:"destructive",disabled:ej,onClick:sa,className:"gap-1",children:[(0,t.jsx)(S.A,{className:"w-3.5 h-3.5"})," Delete"]}),(0,t.jsx)(L.$,{size:"sm",variant:"ghost",className:"text-primary-foreground
1/80 hover:text-primary-foreground",onClick:()=>ev(new Set),children:(0,t.jsx)(N.A,{className:"w-3.5 h-3.5"})})]})}),ep?(0,t.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(e=>(0,t.jsx)("div",{className:"h-64 bg-muted rounded-xl animate-pulse"},e))}):0===e3.length?(0,t.jsxs)("div",{className:"text-center py-12 bg-muted/50 rounded-xl",children:[(0,t.jsx)(f.A,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"No products found"})]}):"table"===eF?(0,t.jsx)("div",{className:"bg-card border border-border rounded-xl overflow-hidden",children:(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full",children:[(0,t.jsx)("thead",{className:"bg-muted/50 border-b border-border",children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{className:"py-3 px-3 w-10",children:(0,t.jsx)(V.S,{checked:e8.length>0&&eg.size===e8.length,onCheckedChange:()=>{eg.size===e8.length?ev(new Set):ev(new Set(e8.map(e=>e.id)))}})}),(0,t.jsx)("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Product"}),(0,t.jsx)("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"SKU"}),(0,t.jsx)("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Type"}),(0,t.jsx)("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Price"}),(0,t.jsx)("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Variants"}),(0,t.jsx)("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Stock"}),(0,t.jsx)("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Status"}),(0,t.jsx)("th",{className:"text-right py-3 px-4 text-sm font-medium text-muted-foreground",children:"Actions"})]})}),(0,t.jsx)("tbody",{children:e8.map(s=>(0,t.jsxs)("tr",{className:"border-b border-border/50 hover:bg-muted/30 ".concat(eg.has(s.id)?"bg-primary/5":""),children:[(0,t.jsx)("td",{className:"py-3 px-3 w-10",children:(0,t.jsx)(V.S,{checked:eg.has(s.id),onCheckedChange:()=>se(s.id)})}),(0,t.jsx)("td",{className:"py-3 px-4",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"w-10 h-10 rounded-lg overflow-hidden bg-muted flex-shrink-0",children:s.image_url?(0,t.jsx)("img",{src:s.image_url,alt:s.name,className:"w-full h-full object-cover"}):(0,t.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,t.jsx)(f.A,{className:"w-5 h-5 text-muted-foreground"})})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:s.name}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:s.category})]})]})}),(0,t.jsx)("td",{className:"py-3 px-4 text-muted-foreground text-sm",children:s.sku||"-"}),(0,t.jsx)("td",{className:"py-3 px-4",children:(0,t.jsx)(J.E,{variant:"outline",children:s.product_type||"Physical"})}),(0,t.jsx)("td",{className:"py-3 px-4 font-medium text-foreground",children:s.is_free?(0,t.jsx)(J.E,{variant:"secondary",className:"bg-emerald-500/10 text-emerald-600 border-emerald-500/20",children:"Free"}):(()=>{let e=(s.variants||[]).filter(e=>e.is_active&&null!=e.price).map(e=>e.price);if(e.length>0){let s=Math.min(...e),a=Math.max(...e);return s===a?"$".concat(s.toFixed(2)):"$".concat(s.toFixed(2)," â $").concat(a.toFixed(2))}return"$".concat(s.price.toFixed(2))})()}),(0,t.jsx)("td",{className:"py-3 px-4",children:(s.variants||[]).length>0?(0,t.jsxs)("div",{className:"flex flex-wrap gap-1",children:[(s.variants||[]).slice(0,3).map(e=>(0,t.jsxs)(J.E,{variant:"secondary",className:"text-[10px] gap-0.5",children:[e.is_digital?(0,t.jsx)(C.A,{className:"w-2.5 h-2.5"}):(0,t.jsx)(A.A,{className:"w-2.5 h-2.5"}),e.name]},e.id)),(s.variants||[]).length>3&&(0,t.jsxs)(J.E,{variant:"outline",className:"text-[10px]",children:["+",(s.variants||[]).length-3]})]}):(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"â"})}),(0,t.jsx)("td",{className:"py-3 px-4",children:(()=>{let e=s.variants||[],a=e.length>0?e.reduce((e,s)=>e+(s.stock_quantity||0),0):s.stock_quantity||0;return(0,t.jsxs)(J.E,{variant:"outline",className:a<10?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-500",children:[a,e.length>0&&(0,t.jsxs)("span",{className:"ml-1 opacity-60",children:["(",e.length,"v)"]})]})})()}),(0,t.jsx)("td",{className:"py-3 px-4",children:(0,t.jsx)(J.E,{variant:"outline",className:s.is_active?"bg-green-500/10 text-green-500":"bg-red-500/10 text-red-500",children:s.is_active?"Active":"Inactive"})}),(0,t.jsx)("td",{className:"py-3 px-4 text-right",children:(0,t.jsxs)("div",{className:"flex gap-1 justify-end",children:[(0,t.jsx)(L.$,{variant:"ghost",size:"sm",onClick:()=>e2(s),children:s.is_active?(0,t.jsx)(k.A,{className:"w-4 h-4"}):(0,t.jsx)(g.A,{className:"w-4 h-4"})}),(0,t.jsx)(L.$,{variant:"ghost",size:"sm",onClick:()=>e.push("/dashboard/product/".concat(s.id)),children:(0,t.jsx)(R.A,{className:"w-4 h-4"})}),(0,t.jsx)(L.$,{variant:"ghost",size:"sm",className:"text-destructive",onClick:()=>e1(s.id),children:(0,t.jsx)(S.A,{className:"w-4 h-4"})})]})})]},s.id))})]})})}):"grid"===eF?(0,t.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:(0,t.jsx)(i.N,{children:e8.map((s,a)=>(0,t.jsxs)(l.P.div,{initial:{opacity:0,y:20}
1,animate:{opacity:1,y:0,transition:{delay:.05*a}},exit:{opacity:0,scale:.9},className:"bg-card border border-border rounded-xl overflow-hidden",children:[(0,t.jsxs)("div",{className:"aspect-[4/3] relative bg-muted",children:[s.image_url?(0,t.jsx)("img",{src:s.image_url,alt:s.name,className:"w-full h-full object-cover"}):(0,t.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,t.jsx)(f.A,{className:"w-12 h-12 text-muted-foreground"})}),(0,t.jsx)("div",{className:"absolute top-2 left-2",children:(0,t.jsx)(V.S,{checked:eg.has(s.id),onCheckedChange:()=>se(s.id),className:"bg-background/80 backdrop-blur"})}),(0,t.jsx)("div",{className:"absolute top-2 right-2 flex gap-2",children:(0,t.jsx)("span",{className:"px-2 py-1 rounded-full text-xs font-medium ".concat(s.is_active?"bg-green-500/20 text-green-500":"bg-red-500/20 text-red-500"),children:s.is_active?"Active":"Inactive"})})]}),(0,t.jsxs)("div",{className:"p-4 space-y-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("h3",{className:"font-semibold text-foreground truncate",children:s.name}),s.is_free?(0,t.jsx)(J.E,{variant:"secondary",className:"bg-emerald-500/10 text-emerald-600 border-emerald-500/20 text-sm",children:"Free"}):(0,t.jsxs)("span",{className:"text-lg font-bold text-primary",children:["$",s.price.toFixed(2)]})]}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[s.category," \xb7 ",s.product_type]})]}),(s.variants||[]).length>0&&(0,t.jsxs)("div",{className:"flex flex-wrap gap-1 mt-1",children:[(s.variants||[]).slice(0,2).map(e=>(0,t.jsxs)(J.E,{variant:"secondary",className:"text-[10px] gap-0.5",children:[e.is_digital?(0,t.jsx)(C.A,{className:"w-2.5 h-2.5"}):(0,t.jsx)(A.A,{className:"w-2.5 h-2.5"}),e.name]},e.id)),(s.variants||[]).length>2&&(0,t.jsxs)(J.E,{variant:"outline",className:"text-[10px]",children:["+",(s.variants||[]).length-2]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[(0,t.jsxs)("span",{children:["Stock: ",(s.variants||[]).length>0?(s.variants||[]).reduce((e,s)=>e+(s.stock_quantity||0),0):s.stock_quantity]}),(0,t.jsx)("span",{children:"\xb7"}),(0,t.jsxs)("span",{children:[(s.variants||[]).length," variant",1!==(s.variants||[]).length?"s":""]})]}),(0,t.jsxs)("div",{className:"flex gap-2 pt-2",children:[(0,t.jsxs)(L.$,{variant:"outline",size:"sm",className:"flex-1 rounded-xl",onClick:()=>e2(s),children:[s.is_active?(0,t.jsx)(k.A,{className:"w-3 h-3 mr-1"}):(0,t.jsx)(g.A,{className:"w-3 h-3 mr-1"}),s.is_active?"Hide":"Show"]}),(0,t.jsx)(L.$,{variant:"outline",size:"sm",className:"rounded-xl",onClick:()=>e.push("/dashboard/product/".concat(s.id)),children:(0,t.jsx)(R.A,{className:"w-3 h-3"})}),(0,t.jsx)(L.$,{variant:"outline",size:"sm",className:"rounded-xl text-destructive",onClick:()=>e1(s.id),children:(0,t.jsx)(S.A,{className:"w-3 h-3"})})]})]})]},s.id))})}):(0,t.jsx)("div",{className:"space-y-3",children:e8.map((e,s)=>(0,t.jsxs)(l.P.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.05*s},className:"flex items-center gap-4 p-4 bg-card border rounded-xl hover:border-primary/30 transition-colors ".concat(eg.has(e.id)?"border-primary/50 bg-primary/5":"border-border"),children:[(0,t.jsx)(V.S,{checked:eg.has(e.id),onCheckedChange:()=>se(e.id)}),(0,t.jsx)("div",{className:"w-16 h-12 rounded-lg overflow-hidden flex-shrink-0 bg-muted",children:e.image_url?(0,t.jsx)("img",{src:e.image_url,alt:e.name,className:"w-full h-full object-cover"}):(0,t.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,t.jsx)(f.A,{className:"w-6 h-6 text-muted-foreground"})})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h3",{className:"font-semibold text-foreground truncate",children:e.name}),(0,t.jsxs)("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[(0,t.jsx)("span",{children:e.category}),(0,t.jsx)("span",{children:"\xb7"}),(0,t.jsxs)("span",{children:["SKU: ",e.sku||"N/A"]}),(0,t.jsx)("span",{children:"\xb7"}),(0,t.jsxs)("span",{children:["Stock: ",e.stock_quantity]})]})]}),(0,t.jsxs)("div",{className:"text-right space-y-1",children:[e.is_free?(0,t.jsx)(J.E,{variant:"secondary",className:"bg-emerald-500/10 text-emerald-600 border-emerald-500/20",children:"Free"}):(0,t.jsxs)("p",{className:"font-bold text-foreground",children:["$",e.price.toFixed(2)]}),(0,t.jsx)(J.E,{variant:"outline",className:e.is_active?"bg-green-500/10 text-green-500":"bg-red-500/10 text-red-500",children:e.is_active?"Active":"Inactive"})]}),(0,t.jsxs)("div",{className:"flex gap-1",children:[(0,t.jsx)(L.$,{variant:"ghost",size:"sm",onClick:()=>e2(e),children:e.is_active?(0,t.jsx)(k.A,{className:"w-4 h-4"}):(0,t.jsx)(g.A,{className:"w-4 h-4"})}),(0,t.jsx)(L.$,{variant:"ghost",size:"sm",onClick:()=>window.location.href="/dashboard/product/".concat(e.id),children:(0,t.jsx)(R.A,{className:"w-4 h-4"})}),(0,t.jsx)(L.$,{variant:"ghost",size:"sm",className:"text-destructive",onClick:()=>e1(e.id),children:(0,t.jsx)(S.A,{className:"w-4 h-4"})})]})]},e.id))}),e3.length>eI&&(0,t.jsxs)("div",{className:"flex items-center justify-between border-t border-border pt-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsxs)("span",{children:["Showing ",e9+1," to"," ",Math.min(e7,e3.length)," of"," ",e3.length," products"]}),(0,t.jsxs)(F.l6,{value:eI.toString(),onValueChange:e=>{eD(Number(e)),eV(1)},children:[(0,t.jsx)(F.bq,{className:"w-20 h-8 rounded-xl",children:(0,t.jsx)(F.yv,{})}),(0,t.jsxs)(F.gC,{children:[(0,t.jsx)(F.eb,{value:"12",children:"12"}),(0,t.jsx)(F.eb,{value:"24",children:"24"}),(0,t.jsx)(F.eb,{value:"48",children:"48"}),(0,t.jsx)(F.eb,{value:"96",children:"96"})]})]}),(0,t.jsx)("span",{children:"per page"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)(L.$,{variant:"outline",size:"sm",onClick:()=>eV(e=>Math.max(1,e-1)),disabled:1===eJ,className:"rounded-xl",children:[(0,t.jsx)(z.A,{className:"w-4 h-4"}),"Previous"]}),(0,t.jsx)("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,e6)},(e,s)=>{let a;return a=e6<=5||eJ<=3?s+1:eJ>=e6-2?e6-4+s:eJ-2+s,(0,t.jsx)(L.$,{variant:eJ===a?"default":"outline",size:"sm",onClick:()=>eV(a),className:"rounded-xl w-10",children:a},a)})}),(0,t.jsxs)(L.$,{variant:"outline",size:"sm",onClick:()=>eV(e=>Math.min(e6,e+1)),disabled:eJ===e6,className:"rounded-xl",children:["Next",(0,t.jsx)(P.A,{className:"w-4 h-4"})]})]})]}),(0,t.jsx)(E.lG,{open:!!eP,onOpenChange:e=>{e||(eL(null),e5())},children:(0,t.jsxs)(E.Cf,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[(0,t.jsx)(E.c7,{children:(0,t.jsx)(E.L3,{children:"Edit Product"})}),(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsx)(()=>(0,t.jsxs)("form",{onSubmit:e0,className:"space-y-4",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"col-span-2 space-y-2",children:[(0,t.jsx)(M.J,{children:"Product Name"}),(0,t.jsx)($.p,{value:eG.name,onChange:e=>eH({...eG,name:e.target.value}),placeholder:"Enter product name",required:!0,className:"rounded-xl"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(M.J,{children:"Price ($)"}),(0,t.jsx)($.p,{type:"number",step:"0.01",value:eG.price,onChange:e=>eH({...eG,price:e.target.value}),placeholder:"29.99",required:!0,className:"rounded-xl"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(M.J,{children:"Compare at Price ($) - Optional"}),(0,t.jsx)($.p,{type:"number",step:"0.01",value:eG.compare_at_price,onChange:e=>eH({...eG,compare_at_price:e.target.value}),placeholder:"39.99",className:"rounded-xl"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(M.J,{children:"Product Type"}),(0,t.jsxs)(F.l6,{value:eG.product_type,onValueChange:e=>eH({...eG,product_type:e}),children:[(0,t.jsx)(F.bq,{className:"rounded-xl",children:(0,t.jsx)(F.yv,{})}),(0,t.jsx)(F.gC,{children:eu.map(e=>(0,t.jsx)(F.eb,{value:e,children:e},e))})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(M.J,{children:"Category"}),(0,t.jsxs)(F.l6,{value:eG.category,onValueChange:e=>eH({...eG,category:e}),children:[(0,t.jsx)(F.bq,{className:"rounded-xl",children:(0,t.jsx)(F.yv,{})}),(0,t.jsx)(F.gC,{children:em.map(e=>(0,t.jsx)(F.eb,{value:e,children:e},e))})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(M.J,{children:"SKU"}),(0,t.jsx)($.p,{value:eG.sku,onChange:e=>eH({...eG,sku:e.target.value}),placeholder:"SKU-001",className:"rounded-xl"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(M.J,{children:"Stock Quantity"}),(0,t.jsx)($.p,{type:"number",value:eG.stock_quantity,onChange:e=>eH({...eG,stock_quantity:e.target.value}),placeholder:"100",className:"rounded-xl"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(M.J,{children:"Weight (oz)"}),(0,t.jsx)($.p,{type:"number",step:"0.1",value:eG.weight,onChange:e=>eH({...eG,weight:e.target.value}),placeholder:"8.5",className:"rounded-xl"})]}),"Clothing"===eG.product_type&&(0,t.jsxs)("div",{className:"col-span-2 space-y-2",children:[(0,t.jsx)(M.J,{children:"Available Sizes"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:ex.map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>{let s=eG.sizes.includes(e)?eG.sizes.filter(s=>s!==e):[...eG.sizes,e];eH({...eG,sizes:s})},className:"px-3 py-1 rounded-lg text-sm ".concat(eG.sizes.includes(e)?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),children:e},e))})]}),"Book"===eG.product_type&&(0,t.jsxs)("div",{className:"col-span-2 space-y-2",children:[(0,t.jsx)(M.J,{children:"Available Formats"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:eh.map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>{let s=eG.formats.includes(e)?eG.formats.filter(s=>s!==e):[...eG.formats,e];eH({...eG,formats:s})},className:"px-3 py-1 rounded-lg text-sm ".concat(eG.formats.includes(e)?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),children:e},e))})]}),(0,t.jsxs)("div",{className:"col-span-2 space-y-2",children:[(0,t.jsx)(M.J,{children:"Image URL"}),(0,t.jsx)($.p,{value:eG.image_url,onChange:e=>eH({...eG,image_url:e.target.value}),placeholder:"https://example.com/image.jpg",className:"rounded-xl"})]}),(0,t.jsxs)("div",{className:"col-span-2 space-y-2",children:[(0,t.jsx)(M.J,{children:"Description"}),(0,t.jsx)(q.T,{value:eG.description,onChange:e=>eH({...eG,description:e.target.value}),placeholder:"Enter product description",rows:3,className:"rounded-xl"})]}),(0,t.jsxs)("div",{className:"col-span-2 flex items-center gap-3 p-3 bg-muted/50 rounded-xl",children:[(0,t.jsx)(U.d,{checked:eG.is_active,onCheckedChange:e=>eH({...eG,is_active:e})}),(0,t.jsx)(M.J,{children:"Active (visible in shop)"})]}),(0,t.jsxs)("div",{className:"col-span-2 flex items-center gap-3 p-3 bg-muted/50 rounded-xl",children:[(0,t.jsx)(U.d,{checked:eG.is_free,onCheckedChange:e=>eH({...eG,is_free:e})}),(0,t.jsx)(M.J,{children:"Free Product (no payment required)"})]}),(0,t.jsxs)("div",{className:"col-span-2 flex items-center gap-3 p-3 bg-emerald-500/5 border border-emerald-500/10 rounded-xl",children:[(0,t.jsx)(U.d,{checked:eG.is_new_arrival,onCheckedChange:e=>eH({...eG,is_new_arrival:e})}),(0,t.jsxs)(M.J,{className:"flex items-center gap-2",children:[(0,t.jsx)(n.A,{className:"w-4 h-4 text-emerald-500"}),'New Arrival (shown in "New Arrivals" row on shop)']})]}),(0,t.jsxs)("div",{className:"col-span-2 flex items-center gap-3 p-3 bg-orange-500/5 border border-orange-500/10 rounded-xl",children:[(0,t.jsx)(U.d,{checked:eG.is_bestseller,onCheckedChange:e=>eH({...eG,is_bestseller:e})}),(0,t.jsxs)(M.J,{className:"flex items-center gap-2",children:[(0,t.jsx)(d.A,{className:"w-4 h-4 text-orange-500"}),'Best Seller (shown in "Best Sellers" row on shop)']})]})]}),(0,t.jsxs)("div",{className:"flex gap-3 pt-2",children:[(0,t.jsx)(L.$,{type:"button",variant:"outline",className:"flex-1 rounded-xl",onClick:()=>{eL(null),ez(!1),e5()},children:"Cancel"}),(0,t.jsxs)(L.$,{type:"submit",className:"flex-1 rounded-xl gap-2",children:[(0,t.jsx)(o.A,{className:"w-4 h-4"}),eP?"Update":"Create"," Product"]})]})]}),{}),eP&&(0,t.jsxs)("div",{className:"border-t pt-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsx)("h3",{className:"font-semibold text-foreground",children:"Product Variants"}),(0,t.jsxs)(L.$,{size:"sm",variant:"outline",onClick:async()=>{let e=prompt('Enter variant name (e.g., "Small", "Red", "Paperback"):');if(!e)return;let s=prompt("Enter SKU (optional):")||null,a=parseFloat(prompt("Enter price modifier (e.g., 0 for no change, 5 for +$5):")||"0"),t=parseInt(prompt("Enter stock quantity:")||"0"),{variant:r,error:l}=await (0,er.B)(eP.id,{name:e,sku:s,price_modifier:a,stock_quantity:t});l?I.oR.error(l):(I.oR.success("Variant created"),await e4(eP))},children:[(0,t.jsx)(p.A,{className:"w-4 h-4 mr-2"}),"Add Variant"]})]}),0===e$.length?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No variants. Add variants for different sizes, colors, formats, etc."}):(0,t.jsx)("div",{className:"space-y-2",children:e$.map(e=>(0,t.jsxs)("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg",children:[(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("p",{className:"font-medium",children:e.name}),(0,t.jsxs)("div",{className:"flex gap-4 text-sm text-muted-foreground",children:[(0,t.jsxs)("span",{children:["SKU: ",e.sku||"N/A"]}
1),(0,t.jsxs)("span",{children:["Price: $",e.price_modifier>=0?"+":"",e.price_modifier.toFixed(2)]}),(0,t.jsxs)("span",{children:["Stock: ",e.stock_quantity]}),(0,t.jsx)("span",{className:e.is_active?"text-green-500":"text-red-500",children:e.is_active?"Active":"Inactive"})]})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(L.$,{variant:"ghost",size:"sm",onClick:async()=>{let{variant:s,error:a}=await (0,el.o)(e.id,{is_active:!e.is_active});a?I.oR.error(a):await e4(eP)},children:e.is_active?(0,t.jsx)(k.A,{className:"w-4 h-4"}):(0,t.jsx)(g.A,{className:"w-4 h-4"})}),(0,t.jsx)(L.$,{variant:"ghost",size:"sm",onClick:async()=>{let s=prompt("Enter variant name:",e.name);if(!s)return;let a=prompt("Enter SKU:",e.sku||"")||null,t=parseFloat(prompt("Enter price modifier:",e.price_modifier.toString())||"0"),r=parseInt(prompt("Enter stock quantity:",e.stock_quantity.toString())||"0"),{variant:l,error:i}=await (0,el.o)(e.id,{name:s,sku:a,price_modifier:t,stock_quantity:r});i?I.oR.error(i):(I.oR.success("Variant updated"),await e4(eP))},children:(0,t.jsx)(R.A,{className:"w-4 h-4"})}),(0,t.jsx)(L.$,{variant:"ghost",size:"sm",className:"text-destructive",onClick:async()=>{if(!confirm("Are you sure you want to delete this variant?"))return;let{success:s,error:a}=await (0,ei.k)(e.id);a?I.oR.error(a):s&&(I.oR.success("Variant deleted"),await e4(eP))},children:(0,t.jsx)(S.A,{className:"w-4 h-4"})})]})]},e.id))})]})]})]})})]})}},12613:(e,s,a)=>{a.d(s,{k:()=>r});var t=a(3729);let r=(0,t.createServerReference)("609f8573a4d371d2b2c21ca4ca9f6b3b6eaf53f611",t.callServer,void 0,t.findSourceMapURL,"deleteProductVariantAction")},15206:(e,s,a)=>{a.d(s,{S:()=>n});var t=a(7131),r=a(555),l=a(11066),i=a(89276),c=a(58258);let n=r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)(l.bL,{ref:s,className:(0,c.cn)("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),...r,children:(0,t.jsx)(l.C1,{className:(0,c.cn)("flex items-center justify-center text-current"),children:(0,t.jsx)(i.A,{className:"h-4 w-4"})})})});n.displayName=l.bL.displayName},20803:(e,s,a)=>{a.d(s,{B:()=>r});var t=a(3729);let r=(0,t.createServerReference)("70381013c44fceb030f9e8b7951d9bdb31fae438f4",t.callServer,void 0,t.findSourceMapURL,"createProductVariantAction")},27753:(e,s,a)=>{a.d(s,{bq:()=>u,eb:()=>f,gC:()=>p,l6:()=>o,yv:()=>m});var t=a(7131),r=a(555),l=a(11444),i=a(86106),c=a(36871),n=a(89276),d=a(58258);let o=l.bL;l.YJ;let m=l.WT,u=r.forwardRef((e,s)=>{let{className:a,children:r,...c}=e;return(0,t.jsxs)(l.l9,{ref:s,className:(0,d.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm r
1ing-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",a),...c,children:[r,(0,t.jsx)(l.In,{asChild:!0,children:(0,t.jsx)(i.A,{className:"h-4 w-4 opacity-50"})})]})});u.displayName=l.l9.displayName;let x=r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)(l.PP,{ref:s,className:(0,d.cn)("flex cursor-default items-center justify-center py-1",a),...r,children:(0,t.jsx)(c.A,{className:"h-4 w-4"})})});x.displayName=l.PP.displayName;let h=r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)(l.wn,{ref:s,className:(0,d.cn)("flex cursor-default items-center justify-center py-1",a),...r,children:(0,t.jsx)(i.A,{className:"h-4 w-4"})})});h.displayName=l.wn.displayName;let p=r.forwardRef((e,s)=>{let{className:a,children:r,position:i="popper",...c}=e;return(0,t.jsx)(l.ZL,{children:(0,t.jsxs)(l.UC,{ref:s,className:(0,d.cn)("relative z-[10001] max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===i&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",a),position:i,...c,children:[(0,t.jsx)(x,{}),(0,t.jsx)(l.LM,{className:(0,d.cn)("p-1","popper"===i&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:r}),(0,t.jsx)(h,{})]})})});p.displayName=l.UC.displayName,r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)(l.JU,{ref:s,className:(0,d.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",a),...r})}).displayName=l.JU.displayName;let f=r.forwardRef((e,s)=>{let{className:a,children:r,...i}=e;return(0,t.jsxs)(l.q7,{ref:s,className:(0,d.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",a),...i,children:[(0,t.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,t.jsx)(l.VF,{children:(0,t.jsx)(n.A,{className:"h-4 w-4"})})}),(0,t.jsx)(l.p4,{children:r})]})});f.displayName=l.q7.displayName,r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)(l.wv,{ref:s,className:(0,d.cn)("-mx-1 my-1 h-px bg-muted",a),...r})}).displayName=l.wv.displayName},28497:(e,s,a)=>{a.d(s,{n:()=>r});var t=a(3729);let r=(0,t.createServerReference)("70caba56f3cec0930c1114d03090d43e8470979fa3",t.callServer,void 0,t.findSourceMapURL,"updateProductAction")},37111:(e,s,a)=>{a.d(s,{q:()=>r});var t=a(3729);let r=(0,t.createServerReference)("406c97b7561958242805a37bf1bb68bcb36775ad49",t.callServer,void 0,t.findSourceMapURL,"getProductVariantsAction")},38227:(e,s,a)=>{a.d(s,{T:()=>i});var t=a(7131),r=a(555),l=a(58258);let i=r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)("textarea",{className:(0,l.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm r
1ing-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),ref:s,...r})});i.displayName="Textarea"},44605:(e,s,a)=>{a.d(s,{F:()=>r});var t=a(3729);let r=(0,t.createServerReference)("601da52e38a9f3f917e553e991c05cba23a3d1aaa1",t.callServer,void 0,t.findSourceMapURL,"deleteProductAction")},50447:(e,s,a)=>{a.d(s,{j:()=>r});var t=a(3729);let r=(0,t.createServerReference)("00358ad5113c8f993e1d32ecf6e8fd333e44004334",t.callServer,void 0,t.findSourceMapURL,"getAppSettingsAction")},58848:(e,s,a)=>{a.d(s,{a:()=>r});var t=a(3729);let r=(0,t.createServerReference)("604f40a2b253da7a4831add8f4ad1d74ffa2c46472",t.callServer,void 0,t.findSourceMapURL,"createProductAction")},70147:(e,s,a)=>{a.d(s,{II:()=>h,Nt:()=>p,at:()=>u});var t=a(7131),r=a(555),l=a(52952),i=a(60587),c=a(16068),n=a(58258);let d={light:"",dark:".dark"},o=r.createContext(null);function m(){let e=r.useContext(o);if(!e)throw Error("useChart must be used within a <ChartContainer />");return e}let u=r.forwardRef((e,s)=>{let{id:a,className:i,children:c,config:d,...m}=e,u=r.useId(),h="chart-".concat(a||u.replace(/:/g,""));return(0,t.jsx)(o.Provider,{value:{config:d},children:(0,t.jsxs)("div",{"data-chart":h,ref:s,className:(0,n.cn)("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",i),...m,children:[(0,t.jsx)(x,{id:h,c
1onfig:d}),(0,t.jsx)(l.u,{children:c})]})})});u.displayName="Chart";let x=e=>{let{id:s,config:a}=e,r=Object.entries(a).filter(e=>{let[s,a]=e;return a.theme||a.color});return r.length?(0,t.jsx)("style",{dangerouslySetInnerHTML:{__html:Object.entries(d).map(e=>{let[a,t]=e;return"\n".concat(t," [data-chart=").concat(s,"] {\n").concat(r.map(e=>{var s;let[t,r]=e,l=(null==(s=r.theme)?void 0:s[a])||r.color;return l?" --color-".concat(t,": ").concat(l,";"):null}).join("\n"),"\n}\n")}).join("\n")}}):null},h=i.m,p=r.forwardRef((e,s)=>{let{active:a,payload:l,className:i,indicator:c="dot",hideLabel:d=!1,hideIndicator:o=!1,label:u,labelFormatter:x,labelClassName:h,formatter:p,color:g,nameKey:v,labelKey:j}=e,{config:b}=m(),y=r.useMemo(()=>{var e;if(d||!(null==l?void 0:l.length))return null;let[s]=l,a="".concat(j||s.dataKey||s.name||"value"),r=f(b,s,a),i=j||"string"!=typeof u?null==r?void 0:r.label:(null==(e=b[u])?void 0:e.label)||u;return x?(0,t.jsx)("div",{className:(0,n.cn)("font-medium",h),children:x(i,l)}):i?(0,t.jsx)("div",{className:(0,n.cn)("font-medium",h),children:i}):null},[u,x,l,d,h,b,j]);if(!a||!(null==l?void 0:l.length))return null;let N=1===l.length&&"dot"!==c;return(0,t.jsxs)("div",{ref:s,className:(0,n.cn)("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",i),children:[N?null:y,(0,t.jsx)("div",{className:"grid gap-1.5",children:l.map((e,s)=>{let a="".concat(v||e.name||e.dataKey||"value"),r=f(b,e,a),l=g||e.payload.fill||e.color;return(0,t.jsx)("div",{className:(0,n.cn)("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===c&&"items-center"),children:p&&(null==e?void 0:e.value)!==void 0&&e.name?p(e.value,e.name,e,s,e.payload):(0,t.jsxs)(t.Fragment,{children:[(null==r?void 0:r.icon)?(0,t.jsx)(r.icon,{}):!o&&(0,t.jsx)("div",{className:(0,n.cn)("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":"dot"===c,"w-1":"line"===c,"w-0 border-[1.5px] border-dashed bg-transparent":"dashed"===c,"my-0.5":N&&"dashed"===c}),style:{"--color-bg":l,"--color-border":l}}),(0,t.jsxs)("div",{className:(0,n.cn)("flex flex-1 justify-between leading-none",N?"items-end":"items-center"),children:[(0,t.jsxs)("div",{className:"grid gap-1.5",children:[N?y:null,(0,t.jsx)("span",{className:"text-muted-foreground",children:(null==r?void 0:r.label)||e.name})]}),e.value&&(0,t.jsx)("span",{className:"font-mono font-medium tabular-nums text-foreground",children:e.value.toLocaleString()})]})]})},e.dataKey)})})]})});function f(e,s,a){if("object"!=typeof s||null===s)return;let t="payload"in s&&"object"==typeof s.payload&&null!==s.payload?s.payload:void 0,r=a;return a in s&&"string"==typeof s[a]?r=s[a]:t&&a in t&&"string"==typeof t[a]&&(r=t[a]),r in e?e[r]:e[a]}p.displayName="ChartTooltip",c.s,r.forwardRef((e,s)=>{let{className:a,hideIcon:r=!1,payload:l,verticalAlign:i="bottom",nameKey:c}=e,{config:d}=m();return(null==l?void 0:l.length)?(0,t.jsx)("div",{ref:s,className:(0,n.cn)("flex items-center justify-center gap-4","top"===i?"pb-3":"pt-3",a),children:l.map(e=>{let s="".concat(c||e.dataKey||"value"),a=f(d,e,s);return(0,t.jsxs)("div",{className:(0,n.cn)("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[(null==a?void 0:a.icon)&&!r?(0,t.jsx)(a.icon,{}):(0,t.jsx)("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:e.color}}),null==a?void 0:a.label]},e.value)})}):null}).displayName="ChartLegend"},82549:(e,s,a)=>{a.d(s,{d:()=>c});var t=a(7131),r=a(555),l=a(62051),i=a(58258);let c=r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)(l.bL,{className:(0,i.cn)("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",a),...r,ref:s,children:(0,t.jsx)(l.zi,{className:(0,i.cn)("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})})});c.displayName=l.bL.displayName},99600:(e,s,a)=>{a.d(s,{o:()=>r});var t=a(3729);let r=(0,t.createServerReference)("7041fc22403ddb5667ba79aa7443fb0be776ca65e9",t.callServer,void 0,t.findSourceMapURL,"updateProductVariantAction")}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.