File manager - Edit - /home/webapp69.cm.in.th/u69319090023/Shop23/_next/static/chunks/3wjbiy88meqna.js
Back
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,56430,e=>{"use strict";var t=e.i(43476),s=e.i(71645),r=e.i(22016),a=e.i(57688),l=e.i(18566),n=e.i(94105),o=e.i(63448),i=e.i(79258),d=e.i(66794),c=e.i(67784),x=e.i(26909),p=e.i(93583),m=e.i(70812),h=e.i(16327),u=e.i(53138),b=e.i(66595),g=e.i(77071),f=e.i(56420);let y=(0,f.default)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);var j=e.i(89664),N=e.i(63676),v=e.i(75183),w=e.i(82954),k=e.i(67927);let S=(0,f.default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),C=(0,f.default)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]);var A=e.i(70387),L=e.i(10818),P=e.i(49882),F=e.i(2773),$=e.i(67363),_=e.i(57657);let D=(0,f.default)("percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]]);var E=e.i(8734),T=e.i(28623),M=e.i(70904),B=e.i(29210),I=e.i(26091),O=e.i(44779),z=e.i(23067),R=e.i(94164),W=e.i(35034),q=e.i(30801);let U=class{static getWalletSummary(e){let t=e.toLowerCase(),s=localStorage.getItem("ctc_orders"),r=s?JSON.parse(s):[],a=localStorage.getItem("ctc_products"),l=a?JSON.parse(a):[],n=r.filter(e=>e.items.some(e=>{let s=l.find(t=>t.id===e.product?.id),r=s?s.merchantEmail:e.product?.merchantEmail;return r&&r.toLowerCase()===t})),o=W.default.getCommissionSettings(),i=0,d=0;n.forEach(e=>{let s=e.items.reduce((e,s)=>{let r=l.find(e=>e.id===s.product?.id),a=r?r.merchantEmail:s.product?.merchantEmail;return a&&a.toLowerCase()===t?e+s.product.price*s.quantity:e},0),r=o.enabled?Math.round(s*o.baseRatePercent/100):0,a=Math.max(0,s-r);"delivered"===e.status||"completed"===e.status?d+=a:i+=a});let c=q.default.getMerchantPayoutRequests(t),x=c.filter(e=>"approved"===e.status).reduce((e,t)=>e+t.amount,0),p=c.filter(e=>"pending"===e.status).reduce((e,t)=>e+t.amount,0),m=c.filter(e=>"pending"===e.status).length,h=Math.max(0,d-(x+p)),u=d+i;return{pendingBalance:i,availableBalance:h,totalWithdrawn:x,lifetimeEarnings:u,activePayoutsCount:m}}};e.s(["default",0,function(){let e,f,K,J,X,G,H,V,Z,Y,Q,ee,et,es,er,ea=(0,l.useRouter)(),[el,en]=(0,s.useState)(null),[eo,ei]=(0,s.useState)(!1),[ed,ec]=(0,s.useState)("overview"),[ex,ep]=(0,s.useState)(!1),[em,eh]=(0,s.useState)(!1),[eu,eb]=(0,s.useState)(!1),[eg,ef]=(0,s.useState)(null),[ey,ej]=(0,s.useState)("th"),[eN,ev]=(0,s.useState)([]);(0,s.useEffect)(()=>{ej(localStorage.getItem("preferred_language")||"th");let e=()=>{ej(localStorage.getItem("preferred_language")||"th")};return window.addEventListener("languageChange",e),window.addEventListener("storage",e),()=>{window.removeEventListener("languageChange",e),window.removeEventListener("storage",e)}},[]);let ew="en"===ey,[ek,eS]=(0,s.useState)([]),[eC,eA]=(0,s.useState)([]),[eL,eP]=(0,s.useState)(W.default.getDefaultSettings());(0,s.useEffect)(()=>{eP(W.default.getCommissionSettings());let e=()=>{eP(W.default.getCommissionSettings())};return window.addEventListener("commissionChange",e),window.addEventListener("storage",e),()=>{window.removeEventListener("commissionChange",e),window.removeEventListener("storage",e)}},[]);let[eF,e$]=(0,s.useState)(""),[e_,eD]=(0,s.useState)(""),[eE,eT]=(0,s.useState)("ศูนย์บริหารจัดการเสื้อช็อปและอุปกรณ์เพื่อการศึกษา แผนกวิชาเทคนิควิทยาลัย"),[eM,eB]=(0,s.useState)(!1),[eI,eO]=(0,s.useState)([]),[ez,eR]=(0,s.useState)(""),[eW,eq]=(0,s.useState)(0),[eU,eK]=(0,s.useState)(0),[eJ,eX]=(0,s.useState)("free_shipping"),[eG,eH]=(0,s.useState)("percent"),[eV,eZ]=(0,s.useState)(""),[eY,eQ]=(0,s.useState)(""),[e0,e1]=(0,s.useState)(10),[e5,e2]=(0,s.useState)(0),[e4,e3]=(0,s.useState)(0),[e8,e6]=(0,s.useState)(100),[e9,e7]=(0,s.useState)(""),[te,tt]=(0,s.useState)(!1),[ts,tr]=(0,s.useState)("all"),[ta,tl]=(0,s.useState)(!1),[tn,to]=(0,s.useState)("all"),[ti,td]=(0,s.useState)(""),[tc,tx]=(0,s.useState)("none"),[tp,tm]=(0,s.useState)(!1),[th,tu]=(0,s.useState)(()=>{let e=new Date;return new Date(e.getFullYear(),e.getMonth(),1)}),[tb,tg]=(0,s.useState)(()=>{let e=new Date;return new Date(e.getFullYear(),e.getMonth()+1,0)}),[tf,ty]=(0,s.useState)(!1),[tj,tN]=(0,s.useState)(()=>new Date().getMonth()),[tv,tw]=(0,s.useState)(()=>new Date().getFullYear()),[tk,tS]=(0,s.useState)("start"),[tC,tA]=(0,s.useState)(""),[tL,tP]=(0,s.useState)(null),[tF,t$]=(0,s.useState)(""),[t_,tD]=(0,s.useState)(!1),[tE,tT]=(0,s.useState)(0),[tM,tB]=(0,s.useState)(!0),[tI,tO]=(0,s.useState)(50),[tz,tR]=(0,s.useState)(""),[tW,tq]=(0,s.useState)(""),[tU,tK]=(0,s.useState)([]),[tJ,tX]=(0,s.useState)(0),[tG,tH]=(0,s.useState)(""),[tV,tZ]=(0,s.useState)(!0),[tY,tQ]=(0,s.useState)(["S","M","L","XL"]),[t0,t1]=(0,s.useState)(""),[t5,t2]=(0,s.useState)([]),[t4,t3]=(0,s.useState)("cat_tshirt"),[t8,t6]=(0,s.useState)("เสื้อยืดคอกลม"),[t9,t7]=(0,s.useState)("CMTC OFFICIAL"),[se,st]=(0,s.useState)(0),[ss,sr]=(0,s.useState)(!1),[sa,sl]=(0,s.useState)(!1),[sn,so]=(0,s.useState)(""),[si,sd]=(0,s.useState)(!1),[sc,sx]=(0,s.useState)(!1),[sp,sm]=(0,s.useState)(null),[sh,su]=(0,s.useState)(!1),[sb,sg]=(0,s.useState)(null),[sf,sy]=(0,s.useState)("Flash Express"),[sj,sN]=(0,s.useState)(""),[sv,sw]=(0,s.useState)(""),[sk,sS]=(0,s.useState)({}),[sC,sA]=(0,s.useState)(!1),[sL,sP]=(0,s.useState)("week"),[sF,s$]=(0,s.useState)(!1),[s_,sD]=(0,s.useState)(!0),[sE,sT]=(0,s.useState)({pendingBalance:0,availableBalance:0,totalWithdrawn:0,lifetimeEarnings:0,activePayoutsCount:0}),[sM,sB]=(0,s.useState)([]),[sI,sO]=(0,s.useState)([]),[sz,sR]=(0,s.useState)(!1),[sW,sq]=(0,s.useState)(!1),[sU,sK]=(0,s.useState)(null),[sJ,sX]=(0,s.useState)(0),[sG,sH]=(0,s.useState)(""),[sV,sZ]=(0,s.useState)("ธนาคารกสิกรไทย (KBANK)"),[sY,sQ]=(0,s.useState)(""),[s0,s1]=(0,s.useState)(""),[s5,s2]=(0,s.useState)(""),s4=e=>{if(!e)return;sT(U.getWalletSummary(e));let t=q.default.getBankAccounts(e);sB(t),t.length>0&&sH(e=>e||t[0].id),sO(q.default.getMerchantPayoutRequests(e))},s3=async e=>{let t=e.target.files?.[0];if(t){if(!t.type.startsWith("image/"))return void s6("กรุณาเลือกไฟล์รูปภาพเท่านั้น","error");sd(!0);try{let e=await new Promise((e,s)=>{let r=new FileReader;r.readAsDataURL(t),r.onload=t=>{let r=new window.Image;r.src=t.target?.result,r.onload=()=>{let t=document.createElement("canvas"),s=r.width,a=r.height;s>a?s>200&&(a*=200/s,s=200):a>200&&(s*=200/a,a=200),t.width=s,t.height=a;let l=t.getContext("2d");l?.drawImage(r,0,0,s,a);let n=t.toDataURL("image/jpeg",.6);e(n)},r.onerror=e=>s(e)},r.onerror=e=>s(e)});so(e),s6("อัปโหลดโลโก้ร้านค้าและบีบอัดสำเร็จ (ไม่มีแลค)","success")}catch(e){console.error(e),s6("เกิดข้อผิดพลาดในการประมวลผลรูปภาพโลโก้","error")}finally{sd(!1)}}},s8=async e=>{let t=e.target.files?.[0];if(t){if(!t.type.startsWith("image/"))return void s6("กรุณาเลือกไฟล์รูปภาพเท่านั้น","error");sl(!0);try{let e=await new Promise((e,s)=>{let r=new FileReader;r.readAsDataURL(t),r.onload=t=>{let r=new window.Image;r.src=t.target?.result,r.onload=()=>{let t=document.createElement("canvas"),s=r.width,a=r.height;s>a?s>1e3&&(a*=1e3/s,s=1e3):a>1e3&&(s*=1e3/a,a=1e3),t.width=s,t.height=a;let l=t.getContext("2d");l?.drawImage(r,0,0,s,a);let n=t.toDataURL("image/jpeg",.85);e(n)},r.onerror=e=>s(e)},r.onerror=e=>s(e)});tK(t=>{let s=[...t,e];return tX(s.length-1),s}),tq(e),s6("อัปโหลดและบีบอัดรูปภาพสำเร็จ (ไม่มีแลค)","success")}catch(e){console.error(e),s6("เกิดข้อผิดพลาดในการประมวลผลรูปภาพ","error")}finally{sl(!1)}}},s6=(e,t="success")=>{ef({text:e,type:t}),setTimeout(()=>ef(null),3e3)};if((0,s.useEffect)(()=>{let e=O.default.getCurrentUser();if(e&&("merchant"===e.role||"admin"===e.role)){en(e),eD(e.email),ei(!0),z.default.getProducts().then(t=>{ev([]),eS(t.filter(t=>t.merchantEmail&&t.merchantEmail.toLowerCase()===e.email.toLowerCase()));let s=localStorage.getItem("ctc_orders");eA((s?JSON.parse(s):[]).filter(s=>s.items&&s.items.some(s=>{let r=t.find(e=>e.id===(s.product?.id||s.product_id)),a=r?r.merchantEmail:s.product?.merchantEmail;return a&&a.toLowerCase()===e.email.toLowerCase()})))});let t=localStorage.getItem("store_settings_"+e.email);if(t){let s=JSON.parse(t);eB(!0===s.disallowSystemCoupons),eO(s.coupons||[]),e$(s.storeName||e.fullName),eT(s.storeDescription||"ยินดีต้อนรับสู่ร้านค้าทางการ"),so(s.storeLogo||"")}else e$(e.fullName),eT("ยินดีต้อนรับสู่ร้านค้าทางการ"),so("");s4(e.email);let s=()=>{s4(e.email);let t=localStorage.getItem("ctc_categories");if(t)try{let e=JSON.parse(t);t2(e.filter(e=>!1!==e.active));return}catch(e){console.error(e)}t2([{id:"cat_tshirt",name:"เสื้อยืดเครื่องแบบ"},{id:"cat_polo",name:"เสื้อโปโลเครื่องแบบ"},{id:"cat_hoodie",name:"เสื้อฮู้ดดี้เครื่องแบบ"},{id:"cat_jacket",name:"เสื้อช็อป/แจ็คเก็ต"},{id:"cat_accessories",name:"อุปกรณ์เสริม"}])};return s(),window.addEventListener("storage",s),()=>{window.removeEventListener("storage",s)}}ea.push("/login?redirect=/merchant")},[ea]),!eo||!el)return(0,t.jsx)("div",{className:"min-h-screen bg-[#FAF8F5] flex items-center justify-center",children:(0,t.jsxs)("div",{className:"flex flex-col items-center space-y-4",children:[(0,t.jsx)("div",{className:"w-12 h-12 rounded-full border-4 border-[#800A0A] border-t-transparent animate-spin"}),(0,t.jsx)("span",{className:"text-sm text-gray-500 font-medium",children:"กำลังตรวจสอบสิทธิ์ร้านค้า..."})]})});let s9=eC.filter(e=>"delivered"===e.status).reduce((e,t)=>e+t.totalAmount,0),s7=eC.reduce((e,t)=>e+t.totalAmount,0),re=s9>0?Math.round(.94*s9):0,rt=eC.filter(e=>"pending"===e.status).length,rs=eC.filter(e=>"processing"===e.status).length;ek.filter(e=>!e.inStock).length;let rr=(e,t,s)=>{if(!s.trim())return void s6("กรุณากรอกหมายเลขพัสดุ","error");let r=localStorage.getItem("ctc_orders"),a=(r?JSON.parse(r):[]).map(r=>r.id===e?{...r,status:"shipped",trackingCode:s,shippingCarrier:t}:r);localStorage.setItem("ctc_orders",JSON.stringify(a));let l=localStorage.getItem("ctc_products"),n=l?JSON.parse(l):[];eA(a.filter(e=>e.items&&e.items.some(e=>{let t=n.find(t=>t.id===e.product?.id),s=t?t.merchantEmail:e.product?.merchantEmail;return s&&s.toLowerCase()===el?.email.toLowerCase()}))),window.dispatchEvent(new Event("storage")),s6(`ยืนยันการจัดส่งออเดอร์ #${e} แล้ว`,"success")},ra=e=>{e&&e.preventDefault();let t=t0.trim().toUpperCase();if(t){if(tY.includes(t))return void s6(ew?"This size already exists":"มีขนาดไซส์นี้อยู่ในรายการแล้ว","error");tQ(e=>[...e,t]),t1(""),s6(ew?`Added size ${t}`:`เพิ่มขนาด ${t} เรียบร้อย`,"success")}},rl=e=>{tQ(e),s6(ew?"Applied size preset":"เลือกชุดไซส์สำเร็จรูปแล้ว","info")},rn=(e,t)=>{el&&localStorage.setItem("store_settings_"+el.email,JSON.stringify({disallowSystemCoupons:e,coupons:t,storeName:eF,storeDescription:eE,storeLogo:sn}))},ro=e=>{"u">typeof navigator&&navigator.clipboard&&(navigator.clipboard.writeText(e),s6(`คัดลอกรหัส "${e}" ไปยังคลิปบอร์ดแล้ว`,"success"))},ri=[{id:"overview",label:ew?"Overview":"ภาพรวม",icon:(0,t.jsx)(n.LayoutDashboard,{className:"w-4 h-4"})},{id:"products",label:ew?"Products":"จัดการสินค้า",icon:(0,t.jsx)(i.Package,{className:"w-4 h-4"})},{id:"coupons",label:ew?"Coupons & Deals":"คูปอง & โปรโมชัน",icon:(0,t.jsx)(_.Ticket,{className:"w-4 h-4"}),badge:eI.length>0?eI.length.toString():null},{id:"orders",label:ew?"Orders":"คำสั่งซื้อ",icon:(0,t.jsx)(o.ShoppingBag,{className:"w-4 h-4"}),badge:rt>0?rt.toString():null},{id:"shipping",label:ew?"Shipping":"การจัดส่ง",icon:(0,t.jsx)($.Truck,{className:"w-4 h-4"}),badge:rs>0?rs.toString():null},{id:"finance",label:ew?"Finance & Commission":"การเงิน & ค่าคอมมิชชั่น",icon:(0,t.jsx)(A.CreditCard,{className:"w-4 h-4"})},{id:"settings",label:ew?"Settings":"ตั้งค่าร้านค้า",icon:(0,t.jsx)(d.Settings,{className:"w-4 h-4"})}],rd=[{id:"messages",label:ew?"Message Center":"ศูนย์ข้อความ",icon:(0,t.jsx)(L.Info,{className:"w-4 h-4"})},{id:"profile",label:ew?"Company Profile":"ข้อมูลร้านค้า",icon:(0,t.jsx)(v.Store,{className:"w-4 h-4"})},{id:"faq",label:ew?"FAQ":"คำถามที่พบบ่อย",icon:(0,t.jsx)(u.AlertTriangle,{className:"w-4 h-4"})}],rc=(e=!1)=>{let s=sF&&!e;return(0,t.jsxs)("div",{className:"flex flex-col min-h-full justify-between gap-6 pb-4 w-full",children:[(0,t.jsxs)("div",{className:"space-y-6 w-full",children:[!e&&(0,t.jsxs)("div",{className:`flex items-center pb-4 border-b border-gray-100 sticky top-0 bg-white z-10 w-full ${s?"justify-center":"justify-between"}`,children:[(0,t.jsxs)("div",{className:`flex items-center ${s?"justify-center":"space-x-2.5"}`,children:[(0,t.jsx)("button",{type:"button",onClick:()=>s$(!sF),className:"w-9 h-9 bg-[#800A0A] hover:bg-[#991B1B] rounded-xl flex items-center justify-center text-white font-black shadow-sm flex-shrink-0 cursor-pointer border-none transition-all",title:s?"คลิกเพื่อขยายแถบเมนู (Expand)":"CMTC SHOP",children:(0,t.jsx)(v.Store,{className:"w-5 h-5"})}),!s&&(0,t.jsxs)("div",{className:"flex flex-col text-left",children:[(0,t.jsx)("span",{className:"text-sm font-black text-gray-900 leading-tight",children:"CMTC SHOP"}),(0,t.jsx)("span",{className:"text-[9px] text-[#800A0A] font-bold uppercase tracking-widest leading-none mt-0.5",children:"SELLER CENTRE"})]})]}),!s&&(0,t.jsx)("button",{type:"button",onClick:()=>s$(!0),className:"p-1.5 text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded-lg transition-all cursor-pointer border-none bg-transparent",title:"พับปิดแถบเมนู (Collapse)",children:(0,t.jsx)(k.ChevronRight,{className:"w-4 h-4 rotate-180"})})]}),(0,t.jsxs)("div",{className:"space-y-1.5 font-prompt w-full",children:[ri.map(r=>{let a=ed===r.id,l="products"===r.id;return(0,t.jsxs)("div",{className:"space-y-1 w-full",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{l?"products"===ed?sD(!s_):(ec("products"),sD(!0),tl(!1)):ec(r.id),e&&!l&&ep(!1)},title:r.label,className:`w-full flex items-center ${s?"justify-center p-2.5":"justify-between px-3.5 py-2.5"} rounded-xl text-[12px] font-bold transition-all cursor-pointer relative group ${a?"bg-gray-900 text-white shadow-xs":"text-gray-500 hover:text-gray-800 hover:bg-gray-50"}`,children:[(0,t.jsxs)("div",{className:`flex items-center ${s?"justify-center":"space-x-3"}`,children:[r.icon,!s&&(0,t.jsx)("span",{children:r.label})]}),!s&&(0,t.jsxs)("div",{className:"flex items-center space-x-1",children:[r.badge&&(0,t.jsx)("span",{className:`text-[9px] font-black px-2 py-0.5 rounded-full ${a?"bg-white/20 text-white":"bg-red-100 text-red-750"}`,children:r.badge}),l&&(0,t.jsx)(h.ChevronDown,{className:`w-3.5 h-3.5 text-gray-400 transition-transform duration-200 ${a&&s_?"rotate-180 text-white":"rotate-0"}`})]}),s&&r.badge&&(0,t.jsx)("span",{className:"absolute top-1.5 right-1.5 w-2 h-2 rounded-full bg-red-500"})]}),l&&a&&s_&&!s&&(0,t.jsxs)("div",{className:"pl-9 space-y-1.5 animate-in slide-in-from-top-1 duration-150 py-1",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{tl(!1),e&&ep(!1)},className:`w-full flex items-center space-x-2 py-1 text-[11px] font-medium text-left transition-colors cursor-pointer border-none bg-transparent ${!ta?"text-[#800A0A] font-bold":"text-gray-400 hover:text-gray-600"}`,children:[(0,t.jsx)("span",{className:"w-1 h-1 rounded-full bg-current"}),(0,t.jsx)("span",{children:"สินค้าทั้งหมด (All Products)"})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>{tP(null),tA(""),tT(0),tO(50),tR(""),tq("/u69319090023/Shop23/images/products/tshirt_black_1.svg"),tK([]),tX(0),tH(""),t3("cat_tshirt"),t6("เสื้อยืดคอกลม"),t7("CMTC OFFICIAL"),st(0),tZ(!0),tQ(["S","M","L","XL"]),t1(""),ev([]),tl(!0),e&&ep(!1)},className:`w-full flex items-center space-x-2 py-1 text-[11px] font-medium text-left transition-colors cursor-pointer border-none bg-transparent ${ta?"text-[#800A0A] font-bold":"text-gray-400 hover:text-gray-600"}`,children:[(0,t.jsx)("span",{className:"w-1 h-1 rounded-full bg-current"}),(0,t.jsx)("span",{children:"เพิ่มสินค้าใหม่ (Add New Product)"})]})]})]},r.id)}),(0,t.jsx)("div",{className:"h-[1px] bg-gray-100 my-4"}),rd.map(r=>{let a=ed===r.id;return(0,t.jsxs)("button",{type:"button",onClick:()=>{"bargains"===r.id?(ec("bargains"),tl(!1),e&&ep(!1)):s6("ฟังก์ชันนี้จะพร้อมใช้งานในรุ่นถัดไป (Coming Soon)","info")},title:r.label,className:`w-full flex items-center ${s?"justify-center p-2.5":"space-x-3 px-3.5 py-2.5"} rounded-xl text-[12px] font-bold transition-all cursor-pointer ${a?"border-2 border-gray-900 bg-white text-gray-900 shadow-xs":"text-gray-400 hover:text-gray-600 hover:bg-gray-50"}`,children:[r.icon,!s&&(0,t.jsx)("span",{children:r.label})]},r.id)})]})]}),(0,t.jsxs)("div",{className:"space-y-1.5 border-t border-gray-100 pt-4 mt-auto w-full",children:[el?.role==="admin"&&(0,t.jsxs)(r.default,{href:"/admin",onClick:()=>e&&ep(!1),title:"กลับสู่แผงควบคุมผู้ดูแลระบบ (Admin Panel)",className:`w-full flex items-center ${s?"justify-center p-2.5":"space-x-3 px-3.5 py-2.5"} text-amber-800 bg-amber-50 hover:bg-amber-100 rounded-xl text-xs font-bold transition-all text-left block font-prompt border border-amber-200 shadow-2xs`,children:[(0,t.jsx)(w.Shield,{className:"w-4 h-4 flex-shrink-0 text-amber-700"}),!s&&(0,t.jsx)("span",{children:ew?"Return to Admin Panel":"กลับสู่หน้าแอดมิน (Admin)"})]}),(0,t.jsxs)(r.default,{href:"/",onClick:()=>e&&ep(!1),title:ew?"Switch to Buyer Mode":"สลับไปยังโหมดผู้ซื้อ",className:`w-full flex items-center ${s?"justify-center p-2.5":"space-x-3 px-3.5 py-2.5"} text-[#800A0A] hover:bg-red-50/50 rounded-xl text-xs font-bold transition-all text-left block font-prompt`,children:[(0,t.jsx)(x.ArrowLeftRight,{className:"w-4 h-4 flex-shrink-0"}),!s&&(0,t.jsx)("span",{children:ew?"Switch to Buyer Mode":"สลับไปยังโหมดผู้ซื้อ"})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>{O.default.logout(),ea.push("/login")},title:"ออกจากระบบ",className:`w-full flex items-center ${s?"justify-center p-2.5":"space-x-3 px-3.5 py-2.5"} text-red-650 hover:text-red-700 hover:bg-red-50/50 rounded-xl text-xs font-bold transition-all text-left bg-transparent border-none cursor-pointer font-prompt`,children:[(0,t.jsx)(c.LogOut,{className:"w-4 h-4 flex-shrink-0"}),!s&&(0,t.jsx)("span",{children:"ออกจากระบบ"})]}),!s&&(0,t.jsx)("div",{className:"px-1 py-1.5 mt-4 select-none font-prompt",children:(0,t.jsxs)("div",{className:"bg-gray-100 p-1 rounded-xl flex items-center space-x-1 text-[11px]",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>s6("สลับไปยังโหมดสว่าง (กำลังเปิดใช้งาน)","info"),className:"flex-1 py-1.5 rounded-lg flex items-center justify-center space-x-1.5 bg-white text-gray-800 shadow-sm font-bold border-none cursor-pointer",children:[(0,t.jsx)(S,{className:"w-3.5 h-3.5 text-amber-500"}),(0,t.jsx)("span",{children:"Light"})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>s6("สลับไปยังโหมดมืด (อยู่ระหว่างพัฒนา)","info"),className:"flex-1 py-1.5 rounded-lg flex items-center justify-center space-x-1.5 text-gray-400 hover:text-gray-600 font-medium border-none bg-transparent cursor-pointer",children:[(0,t.jsx)(C,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{children:"Dark"})]})]})})]})]})};return(0,t.jsxs)("div",{className:"h-screen w-screen bg-[#F8F9FA] flex overflow-hidden font-sans relative",children:[eg&&(0,t.jsx)("div",{className:"fixed top-6 right-6 z-50 animate-in fade-in slide-in-from-top-4 duration-300",children:(0,t.jsxs)("div",{className:`px-5 py-3.5 rounded-2xl shadow-luxury border flex items-center space-x-3 text-xs font-bold ${"success"===eg.type?"bg-emerald-50 text-emerald-700 border-emerald-100":"error"===eg.type?"bg-red-50 text-red-700 border-red-100":"bg-amber-50 text-amber-700 border-amber-100"}`,children:[(0,t.jsx)("span",{className:"w-2 h-2 rounded-full bg-current animate-pulse"}),(0,t.jsx)("span",{children:eg.text})]})}),(0,t.jsx)("aside",{className:`hidden md:flex ${sF?"w-20 p-3 items-center":"w-64 p-5"} bg-white border-r border-gray-150 flex-col justify-between flex-shrink-0 z-30 h-full overflow-y-auto transition-all duration-300`,children:rc(!1)}),(0,t.jsx)(R.default,{isOpen:ex,onClose:()=>ep(!1),children:rc(!0)}),(0,t.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,t.jsxs)("header",{className:"h-16 bg-white border-b border-gray-150 flex items-center px-8 justify-between flex-shrink-0 z-40",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3 flex-1 max-w-md",children:[(0,t.jsx)("button",{type:"button",onClick:()=>ep(!0),className:"md:hidden p-1.5 text-gray-500 hover:text-gray-805 hover:bg-gray-50 rounded-xl transition-all cursor-pointer border-none bg-transparent","aria-label":"เปิดเมนูนำทาง",children:(0,t.jsx)(p.Menu,{className:"w-5.5 h-5.5"})}),(0,t.jsx)("button",{type:"button",onClick:()=>s$(!sF),className:"hidden md:flex p-2 text-gray-500 hover:text-gray-805 hover:bg-gray-50 rounded-xl transition-all cursor-pointer border-none bg-transparent",title:sF?"ขยายเมนูด้านซ้าย":"พับปิดเมนูด้านซ้าย",children:(0,t.jsx)(p.Menu,{className:"w-5 h-5"})}),(0,t.jsxs)("div",{className:"relative w-full",children:[(0,t.jsx)("span",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none",children:(0,t.jsx)(b.Search,{className:"h-4 w-4 text-gray-400"})}),(0,t.jsx)("input",{type:"text",placeholder:"I'm Looking for ...",className:"w-full pl-10 pr-4 py-1.5 bg-[#FAF9F6]/60 hover:bg-gray-100/50 focus:bg-white border border-gray-200 focus:border-gray-300 rounded-xl text-xs focus:outline-none transition-all placeholder:text-gray-400 font-medium font-prompt",onChange:e=>{}})]})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-5",children:[(0,t.jsxs)("div",{className:"hidden sm:flex items-center space-x-2 bg-emerald-50 border border-emerald-100 px-3 py-1.5 rounded-full text-[10px] font-bold text-emerald-700 font-prompt",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),(0,t.jsx)("span",{children:eF})]}),(0,t.jsx)("div",{className:"relative",children:(e=eC.filter(e=>"pending"===e.status),f=ek.filter(e=>!e.inStock||0===e.stockCount),K=e.length+f.length,(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{onClick:()=>{eb(!eu),eh(!1)},className:"p-2 hover:bg-gray-100/80 text-gray-500 hover:text-gray-800 rounded-full transition-all focus:outline-none relative cursor-pointer flex items-center justify-center border-none bg-transparent",children:[(0,t.jsx)(m.Bell,{className:"w-[19px] h-[19px]"}),K>0&&(0,t.jsx)("span",{className:"absolute top-1 right-1 w-4 h-4 bg-[#800A0A] text-white text-[8px] font-bold rounded-full flex items-center justify-center border-2 border-white",children:K})]}),eu&&(0,t.jsxs)("div",{className:"absolute right-0 mt-2.5 w-72 bg-white border border-gray-150 rounded-2xl shadow-luxury p-3 text-left space-y-2.5 z-50 font-prompt",children:[(0,t.jsx)("h5",{className:"font-extrabold text-gray-800 text-xs px-1 border-b border-gray-100 pb-2",children:"แจ้งเตือนร้านค้า"}),(0,t.jsx)("div",{className:"space-y-2 text-[11px] text-gray-600",children:K>0?(0,t.jsxs)(t.Fragment,{children:[e.length>0&&(0,t.jsxs)("button",{type:"button",onClick:()=>{ec("orders"),eb(!1)},className:"w-full text-left p-2 hover:bg-gray-50 rounded-lg border-l-2 border-[#800A0A] bg-red-50/10 cursor-pointer block transition-colors",children:[(0,t.jsx)("span",{className:"font-bold text-gray-800 block",children:"มีคำสั่งซื้อใหม่"}),(0,t.jsxs)("span",{className:"font-light text-gray-500 block mt-0.5",children:["มี ",e.length," ออเดอร์ที่รอจัดส่ง"]})]}),f.length>0&&(0,t.jsxs)("button",{type:"button",onClick:()=>{ec("products"),eb(!1)},className:"w-full text-left p-2 hover:bg-gray-50 rounded-lg border-l-2 border-amber-500 bg-amber-50/20 cursor-pointer block transition-colors",children:[(0,t.jsx)("span",{className:"font-bold text-gray-800 block",children:"แจ้งเตือนสินค้าหมดสต็อก"}),(0,t.jsxs)("span",{className:"font-light text-gray-500 block mt-0.5",children:["มี ",f.length," รายการสินค้าที่สต็อกหมด"]})]})]}):(0,t.jsxs)("div",{className:"py-6 text-center space-y-1.5 bg-gray-50/50 rounded-xl border border-gray-100",children:[(0,t.jsx)("span",{className:"text-xl block",children:"🔔"}),(0,t.jsx)("span",{className:"font-bold text-gray-700 text-xs block",children:"ไม่มีการแจ้งเตือนใหม่"}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 block px-2",children:"เมื่อมีคำสั่งซื้อใหม่หรือสินค้าหมดจะแจ้งเตือนที่นี่"})]})})]})]}))}),(0,t.jsxs)("div",{className:"relative font-prompt",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{eh(!em),eb(!1)},className:"flex items-center space-x-2.5 py-1 focus:outline-none transition-all text-left cursor-pointer border-none bg-transparent",children:[(0,t.jsx)("div",{className:"relative w-8 h-8 rounded-full overflow-hidden border border-gray-100 bg-[#800A0A] flex items-center justify-center text-white text-xs font-bold uppercase shadow-sm",children:eF.slice(0,2)}),(0,t.jsxs)("div",{className:"hidden sm:flex flex-col justify-center",children:[(0,t.jsx)("span",{className:"text-[11px] font-bold text-gray-850 leading-tight truncate max-w-[130px]",children:eF||(el?.role==="admin"?"ผู้ดูแลระบบ":"ร้านค้าแผนก")}),(0,t.jsx)("span",{className:"text-[9px] text-gray-450 font-medium leading-none mt-0.5 truncate max-w-[130px]",children:e_})]}),(0,t.jsx)(h.ChevronDown,{className:"w-3.5 h-3.5 text-gray-400"})]}),em&&(0,t.jsxs)("div",{className:"absolute right-0 mt-2 w-48 bg-white border border-gray-150 rounded-2xl shadow-luxury overflow-hidden z-50",children:[(0,t.jsxs)("div",{className:"px-4 py-3 border-b border-gray-100 text-xs",children:[(0,t.jsx)("span",{className:"font-bold text-gray-850 block",children:eF}),(0,t.jsx)("span",{className:"text-gray-450 text-[10px] block mt-0.5",children:e_})]}),el?.role==="admin"&&(0,t.jsxs)(r.default,{href:"/admin",className:"w-full flex items-center space-x-2.5 px-4 py-3 hover:bg-amber-50 text-amber-800 text-xs font-bold text-left transition-colors block border-b border-gray-100",children:[(0,t.jsx)(w.Shield,{className:"w-4 h-4 text-amber-600"}),(0,t.jsx)("span",{children:ew?"Return to Admin Panel":"กลับสู่หน้าแอดมิน (Admin)"})]}),(0,t.jsxs)(r.default,{href:"/",className:"w-full flex items-center space-x-2.5 px-4 py-3 hover:bg-gray-50 text-gray-700 text-xs font-bold text-left transition-colors block",children:[(0,t.jsx)(x.ArrowLeftRight,{className:"w-4 h-4 text-gray-400"}),(0,t.jsx)("span",{children:ew?"Switch to Buyer Mode":"สลับไปยังโหมดผู้ซื้อ"})]}),(0,t.jsxs)("button",{onClick:()=>{O.default.logout(),ea.push("/login")},className:"w-full flex items-center space-x-2.5 px-4 py-3 hover:bg-red-50 text-red-650 hover:text-red-700 text-xs font-bold text-left transition-colors border-none bg-transparent cursor-pointer",children:[(0,t.jsx)(c.LogOut,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"ออกจากระบบ"})]})]})]})]})]}),(0,t.jsxs)("main",{className:"flex-1 bg-[#F8F9FA] overflow-y-auto p-6 md:p-8 text-left",children:["overview"===ed&&(0,t.jsxs)("div",{className:"space-y-6 animate-in fade-in duration-200",children:[(0,t.jsx)("div",{className:"flex justify-between items-center",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-xl font-extrabold text-gray-900 leading-none font-prompt",children:ew?"Sales Success Overview":"ภาพรวมความสำเร็จ"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 font-semibold mt-1.5 font-prompt",children:ew?`Sales performance report for ${eF}`:`รายงานสถิติกิจกรรมการขายสาขา ${eF}`})]})}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-6",children:[(0,t.jsxs)("div",{className:"col-span-1 md:col-span-2 lg:col-span-2 bg-white rounded-3xl border border-gray-150 p-6 shadow-sm flex items-center justify-between font-prompt relative overflow-visible group hover:shadow-md transition-shadow",children:[(0,t.jsxs)("div",{className:"space-y-3.5 z-10",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-extrabold uppercase tracking-wider block",children:"TOTAL SALES"}),(0,t.jsxs)("div",{className:"flex items-center gap-2 relative",children:[(0,t.jsxs)("span",{className:"text-3xl font-black text-gray-900 block leading-tight",children:["฿",s7.toLocaleString()]}),(0,t.jsxs)("div",{className:"relative inline-block",children:[(0,t.jsx)("button",{type:"button",onClick:()=>sA(!sC),onMouseEnter:()=>sA(!0),onMouseLeave:()=>sA(!1),className:"w-4 h-4 rounded-full border border-emerald-500 flex items-center justify-center text-[10px] text-emerald-600 bg-emerald-50 hover:bg-emerald-100 transition-colors cursor-pointer",title:"ดูสูตรคำนวณยอดขายรวม",children:"·"}),sC&&(0,t.jsxs)("div",{className:"absolute left-1/2 -translate-x-1/2 bottom-full mb-2 w-64 bg-[#111827] text-white p-3 rounded-2xl shadow-2xl text-left z-50 animate-in fade-in zoom-in duration-150 border border-gray-700",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-emerald-400 text-xs font-bold mb-1.5",children:[(0,t.jsx)(j.Check,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{children:"สูตรคำนวณยอดขายรวม"})]}),(0,t.jsxs)("div",{className:"text-[11px] space-y-1 text-gray-300 font-mono",children:[(0,t.jsxs)("div",{className:"font-bold text-white",children:["Total (฿",s7.toLocaleString(),")"]}),(0,t.jsxs)("div",{children:["= Direct Sales (฿",(s7-(eI.length>0?Math.round(.25*s7):0)).toLocaleString(),")"]}),(0,t.jsxs)("div",{className:"text-amber-400",children:["+ Promo Sales (฿",(eI.length>0?Math.round(.25*s7):0).toLocaleString(),")"]})]})]})]}),(0,t.jsx)("span",{className:"text-sm font-extrabold text-gray-900 ml-auto",children:s7>0?"100%":"0%"})]}),(0,t.jsxs)("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-emerald-50 text-emerald-700 text-[10px] font-bold mt-1",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500"}),(0,t.jsxs)("span",{children:[ek.length," สินค้าในร้าน · ",eC.length," คำสั่งซื้อทั้งหมด"]})]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>ec("orders"),className:"bg-[#E96E25] hover:bg-[#d65f1c] text-white text-[10px] font-black uppercase tracking-wider px-4 py-2 rounded-xl transition-all shadow-sm active:scale-[0.97] cursor-pointer border-none",children:"ดูคำสั่งซื้อทั้งหมด"})]}),(0,t.jsx)("div",{className:"flex-shrink-0 relative",children:(0,t.jsxs)("svg",{className:"w-24 h-24 sm:w-28 sm:h-28 object-contain opacity-95 group-hover:scale-105 transition-transform duration-300",viewBox:"0 0 120 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,t.jsx)("ellipse",{cx:"60",cy:"98",rx:"42",ry:"12",fill:"rgba(0,0,0,0.06)"}),(0,t.jsx)("ellipse",{cx:"38",cy:"90",rx:"22",ry:"6",fill:"rgba(0,0,0,0.08)"}),(0,t.jsx)("path",{d:"M40 70 L65 57 L65 80 L40 93 Z",fill:"#D97706"}),(0,t.jsx)("path",{d:"M40 70 L15 57 L15 80 L40 93 Z",fill:"#B45309"}),(0,t.jsx)("path",{d:"M40 70 L65 57 L40 45 L15 57 Z",fill:"#FBBF24"}),(0,t.jsx)("path",{d:"M25 62 L32 58",stroke:"#B45309",strokeWidth:"1"}),(0,t.jsx)("path",{d:"M22 69 L32 64",stroke:"#B45309",strokeWidth:"1"}),(0,t.jsx)("path",{d:"M75 50 L95 40 L95 60 L75 70 Z",fill:"#E28743"}),(0,t.jsx)("path",{d:"M75 50 L55 40 L55 60 L75 70 Z",fill:"#C56A28"}),(0,t.jsx)("path",{d:"M75 50 L95 40 L75 30 L55 40 Z",fill:"#F4A261"}),(0,t.jsx)("path",{d:"M85 82 L105 72 L105 92 L85 102 Z",fill:"#D97706"}),(0,t.jsx)("path",{d:"M85 82 L65 72 L65 92 L85 102 Z",fill:"#B45309"}),(0,t.jsx)("path",{d:"M85 82 L105 72 L85 62 L65 72 Z",fill:"#FBBF24"}),(0,t.jsx)("path",{d:"M72 78 L82 73",stroke:"#B45309",strokeWidth:"1"})]})})]}),(0,t.jsxs)("div",{className:"col-span-1 bg-white rounded-3xl border border-gray-150 p-5 shadow-sm flex flex-col justify-between font-prompt hover:shadow-md transition-shadow",children:[(0,t.jsxs)("div",{className:"flex justify-between items-start",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl bg-purple-50 text-[#8B5CF6] flex items-center justify-center",children:(0,t.jsx)(A.CreditCard,{className:"w-5 h-5"})}),(0,t.jsx)("span",{className:"text-[9px] text-gray-400 bg-gray-100 px-1.5 py-0.5 rounded font-bold",children:s9>0?"+100%":"0%"})]}),(0,t.jsxs)("div",{className:"space-y-1 mt-4",children:[(0,t.jsxs)("span",{className:"text-xl font-black text-gray-900 block leading-tight",children:["฿",s9.toLocaleString()]}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-extrabold uppercase tracking-wider block",children:"ยอดขายวันนี้"})]}),(0,t.jsxs)("div",{className:"pt-2.5 border-t border-gray-100 flex items-center justify-between text-[10px] text-gray-400 font-bold mt-4 select-none",children:[(0,t.jsx)("span",{children:"เมื่อวานนี้"}),(0,t.jsxs)("span",{className:"text-gray-500",children:["฿",re.toLocaleString()]})]})]}),(0,t.jsxs)("div",{className:"col-span-1 bg-white rounded-3xl border border-gray-150 p-5 shadow-sm flex flex-col justify-between font-prompt hover:shadow-md transition-shadow",children:[(0,t.jsxs)("div",{className:"flex justify-between items-start",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl bg-emerald-50 text-emerald-600 flex items-center justify-center",children:(0,t.jsx)(i.Package,{className:"w-5 h-5"})}),(0,t.jsx)("span",{className:"text-[9px] text-gray-400 bg-gray-100 px-1.5 py-0.5 rounded font-bold",children:rt+rs>0?`${rt+rs}`:"0"})]}),(0,t.jsxs)("div",{className:"space-y-1 mt-4",children:[(0,t.jsxs)("span",{className:"text-xl font-black text-gray-900 block leading-tight",children:[rt+rs," ออเดอร์"]}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-extrabold uppercase tracking-wider block",children:"รายการรอจัดส่ง"})]}),(0,t.jsxs)("div",{className:"pt-2.5 border-t border-gray-100 flex items-center justify-between text-[10px] mt-4 select-none",children:[(0,t.jsx)("span",{className:"font-bold text-emerald-600",children:"จัดการจัดส่ง"}),(0,t.jsx)("span",{className:"text-xs font-bold text-emerald-600",children:rt+rs})]})]}),(0,t.jsxs)("div",{className:"col-span-1 bg-white rounded-3xl border border-gray-150 p-5 shadow-sm flex flex-col justify-between font-prompt hover:shadow-md transition-shadow",children:[(0,t.jsxs)("div",{className:"flex justify-between items-start",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl bg-orange-50 text-[#D97706] flex items-center justify-center",children:(0,t.jsx)(u.AlertTriangle,{className:"w-5 h-5"})}),(0,t.jsx)("span",{className:"text-[9px] text-gray-400 bg-gray-100 px-1.5 py-0.5 rounded font-bold",children:ek.filter(e=>!e.inStock||void 0!==e.stockCount&&0===e.stockCount).length})]}),(0,t.jsxs)("div",{className:"space-y-1 mt-4",children:[(0,t.jsxs)("span",{className:"text-xl font-black text-gray-900 block leading-tight",children:[ek.filter(e=>!e.inStock||void 0!==e.stockCount&&0===e.stockCount).length," รายการ"]}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-extrabold uppercase tracking-wider block",children:"สินค้าหมดเกลี้ยง"})]}),(0,t.jsxs)("div",{className:"pt-2.5 border-t border-gray-100 flex items-center justify-between text-[10px] mt-4 select-none",children:[(0,t.jsx)("span",{className:"font-bold text-gray-700",children:"เช็คคลังสินค้า"}),(0,t.jsx)("span",{className:"text-xs font-bold text-orange-600",children:ek.filter(e=>!e.inStock||void 0!==e.stockCount&&0===e.stockCount).length})]})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[(0,t.jsxs)("div",{className:"lg:col-span-2 bg-white rounded-3xl border border-gray-150 p-6 shadow-sm font-prompt",children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center pb-4 border-b border-gray-100 gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-extrabold uppercase tracking-wider block",children:"ภาพรวมยอดขาย"}),(0,t.jsxs)("span",{className:"text-2xl font-black text-gray-900",children:["฿",s7.toLocaleString()]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 bg-gray-100 p-1 rounded-xl text-xs font-bold",children:[(0,t.jsx)("button",{type:"button",onClick:()=>sP("week"),className:`px-3 py-1 rounded-lg transition-all cursor-pointer ${"week"===sL?"bg-white shadow-xs text-gray-900":"text-gray-500"}`,children:"สัปดาห์"}),(0,t.jsx)("button",{type:"button",onClick:()=>sP("month"),className:`px-3 py-1 rounded-lg transition-all cursor-pointer ${"month"===sL?"bg-white shadow-xs text-gray-900":"text-gray-500"}`,children:"เดือน"}),(0,t.jsx)("button",{type:"button",onClick:()=>sP("year"),className:`px-3 py-1 rounded-lg transition-all cursor-pointer ${"year"===sL?"bg-white shadow-xs text-gray-900":"text-gray-500"}`,children:"ปี"})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-4 text-xs font-bold text-gray-600 mt-4 mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500"}),(0,t.jsxs)("span",{children:["รายได้ (฿",s7.toLocaleString(),")"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"w-2.5 h-2.5 rounded-full bg-purple-500"}),(0,t.jsxs)("span",{children:["คำสั่งซื้อ (",eC.length,")"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"w-2.5 h-2.5 rounded-full bg-amber-500"}),(0,t.jsxs)("span",{children:["สินค้าในร้าน (",ek.length,")"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"w-2.5 h-2.5 rounded-full bg-yellow-400"}),(0,t.jsx)("span",{children:"การคืนเงิน (฿0)"})]})]}),(0,t.jsxs)("div",{className:"relative h-60 w-full pt-4",children:[(0,t.jsxs)("svg",{className:"w-full h-full overflow-visible",viewBox:"0 0 500 180",preserveAspectRatio:"none",children:[(0,t.jsxs)("defs",{children:[(0,t.jsxs)("linearGradient",{id:"dealGreenArea",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,t.jsx)("stop",{offset:"0%",stopColor:"#10B981",stopOpacity:"0.3"}),(0,t.jsx)("stop",{offset:"100%",stopColor:"#10B981",stopOpacity:"0.0"})]}),(0,t.jsxs)("linearGradient",{id:"dealOrangeArea",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,t.jsx)("stop",{offset:"0%",stopColor:"#F59E0B",stopOpacity:"0.3"}),(0,t.jsx)("stop",{offset:"100%",stopColor:"#F59E0B",stopOpacity:"0.0"})]})]}),(0,t.jsx)("line",{x1:"0",y1:"30",x2:"500",y2:"30",stroke:"#F3F4F6",strokeWidth:"1",strokeDasharray:"3 3"}),(0,t.jsx)("line",{x1:"0",y1:"80",x2:"500",y2:"80",stroke:"#F3F4F6",strokeWidth:"1",strokeDasharray:"3 3"}),(0,t.jsx)("line",{x1:"0",y1:"130",x2:"500",y2:"130",stroke:"#F3F4F6",strokeWidth:"1",strokeDasharray:"3 3"}),(0,t.jsx)("path",{d:s7>0?"M 0 140 Q 80 120, 160 85 T 320 60 T 500 40 L 500 160 L 0 160 Z":"M 0 150 L 500 150 L 500 160 L 0 160 Z",fill:"url(#dealGreenArea)"}),(0,t.jsx)("path",{d:s7>0?"M 0 140 Q 80 120, 160 85 T 320 60 T 500 40":"M 0 150 L 500 150",fill:"none",stroke:"#10B981",strokeWidth:"3"}),(0,t.jsx)("path",{d:s7>0?"M 0 150 Q 80 140, 160 110 T 320 95 T 500 70 L 500 160 L 0 160 Z":"M 0 155 L 500 155 L 500 160 L 0 160 Z",fill:"url(#dealOrangeArea)"}),(0,t.jsx)("path",{d:s7>0?"M 0 150 Q 80 140, 160 110 T 320 95 T 500 70":"M 0 155 L 500 155",fill:"none",stroke:"#F59E0B",strokeWidth:"2.5",strokeDasharray:"4 2"}),s7>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("circle",{cx:"160",cy:"85",r:"4",fill:"#10B981"}),(0,t.jsx)("circle",{cx:"320",cy:"60",r:"4",fill:"#10B981"}),(0,t.jsx)("circle",{cx:"500",cy:"40",r:"5",fill:"#10B981",stroke:"#fff",strokeWidth:"2"}),(0,t.jsx)("circle",{cx:"160",cy:"110",r:"4",fill:"#F59E0B"}),(0,t.jsx)("circle",{cx:"320",cy:"95",r:"4",fill:"#F59E0B"}),(0,t.jsx)("circle",{cx:"500",cy:"70",r:"5",fill:"#F59E0B",stroke:"#fff",strokeWidth:"2"})]})]}),(0,t.jsxs)("div",{className:"flex justify-between text-[10px] text-gray-400 font-bold mt-2",children:[(0,t.jsx)("span",{children:"จันทร์"}),(0,t.jsx)("span",{children:"อังคาร"}),(0,t.jsx)("span",{children:"พุธ"}),(0,t.jsx)("span",{children:"พฤหัสบดี"}),(0,t.jsx)("span",{children:"ศุกร์"}),(0,t.jsx)("span",{children:"เสาร์"}),(0,t.jsx)("span",{children:"อาทิตย์"})]})]})]}),(0,t.jsxs)("div",{className:"bg-white rounded-3xl border border-gray-150 p-6 shadow-sm font-prompt flex flex-col justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex justify-between items-center pb-3 border-b border-gray-100",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(_.Ticket,{className:"w-4 h-4 text-[#800A0A]"}),(0,t.jsxs)("h3",{className:"font-extrabold text-gray-900 text-xs uppercase tracking-wider",children:["ดีลโปรโมชันร้านค้า (",eI.length," ดีล)"]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>{ec("coupons"),tt(!0)},className:"text-[10px] font-bold text-[#800A0A] bg-red-50 hover:bg-red-100 px-2.5 py-1 rounded-lg transition-colors border-none cursor-pointer",children:"+ สร้างคูปอง"})]}),(0,t.jsx)("div",{className:"space-y-3 mt-4",children:eI.length>0?eI.slice(0,3).map((e,s)=>{let r="free_shipping"===e.type||"free_shipping"===e.discountType,a="percent"===e.discountType,l=e.minSpend??e.minPurchase??0;return(0,t.jsxs)("div",{className:"p-3 rounded-2xl bg-[#FAF8F5] border border-gray-200/70 flex items-center justify-between hover:border-gray-300 transition-colors",children:[(0,t.jsxs)("div",{className:"space-y-1 text-left",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"font-mono font-black text-xs text-[#800A0A] bg-white px-2 py-0.5 rounded-md border border-gray-200 shadow-2xs",children:e.code}),(0,t.jsx)("span",{className:`text-[9px] font-bold px-2 py-0.5 rounded-md ${r?"bg-emerald-50 text-emerald-700 border border-emerald-200":a?"bg-amber-50 text-amber-700 border border-amber-200":"bg-blue-50 text-blue-700 border border-blue-200"}`,children:r?"🚚 ส่งฟรี":a?`ลด ${e.discountValue||e.discount}%`:`ลด ฿${(e.discountValue||e.discount).toLocaleString()}`})]}),(0,t.jsxs)("div",{className:"text-[10.5px] text-gray-500 font-medium",children:[l>0?`ซื้อขั้นต่ำ ฿${l.toLocaleString()}`:"ไม่มีขั้นต่ำ",e.maxDiscount>0?` \xb7 ลดสูงสุด ฿${e.maxDiscount.toLocaleString()}`:""]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>ro(e.code),title:"คัดลอกรหัส",className:"p-1.5 text-gray-400 hover:text-gray-700 hover:bg-white rounded-lg border-none bg-transparent cursor-pointer transition-colors",children:(0,t.jsx)(E.Copy,{className:"w-3.5 h-3.5"})})]},e.id||e.code||s)}):(0,t.jsxs)("div",{className:"p-5 text-center bg-gray-50/70 border border-dashed border-gray-200 rounded-2xl space-y-2",children:[(0,t.jsx)("span",{className:"text-2xl",children:"🏷️"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 font-medium",children:ew?"No active promotions created yet":"ยังไม่มีโปรโมชันคูปองที่สร้างไว้"}),(0,t.jsxs)("button",{type:"button",onClick:()=>{ec("coupons"),tt(!0)},className:"text-[10.5px] font-bold text-[#800A0A] hover:underline bg-transparent border-none cursor-pointer",children:["+ ",ew?"Create Store Coupon":"สร้างคูปองส่วนลดของร้าน"]})]})})]}),(0,t.jsxs)("div",{className:"pt-3.5 border-t border-gray-100 mt-4 flex items-center justify-between text-xs",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>ec("coupons"),className:"text-[#800A0A] hover:underline font-bold text-[11px] bg-transparent border-none cursor-pointer",children:["ดูคูปองทั้งหมด (",eI.length,") →"]}),(0,t.jsxs)("span",{className:"font-bold text-gray-500 text-[11px]",children:[eI.filter(e=>!1!==e.isActive).length," กำลังทำงาน"]})]})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,t.jsxs)("div",{className:"bg-white rounded-3xl border border-gray-150 p-6 shadow-sm font-prompt",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center pb-3 border-b border-gray-100 mb-4",children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-xs uppercase tracking-wider",children:"คำสั่งซื้อล่าสุด (Latest Orders)"}),(0,t.jsxs)("span",{className:"text-[10px] font-bold text-gray-400",children:[eC.length," ออเดอร์"]})]}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-left text-xs",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"border-b border-gray-100 text-[10px] text-gray-400 uppercase",children:[(0,t.jsx)("th",{className:"pb-2",children:"ลูกค้า"}),(0,t.jsx)("th",{className:"pb-2",children:"การชำระเงิน / ช่องทาง"}),(0,t.jsx)("th",{className:"pb-2 text-right",children:"ยอดรวม"}),(0,t.jsx)("th",{className:"pb-2 text-right",children:"สถานะ"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-gray-50",children:eC.length>0?eC.slice(0,10).map(e=>(0,t.jsxs)("tr",{className:"hover:bg-gray-50/50",children:[(0,t.jsx)("td",{className:"py-3 font-bold text-gray-800",children:e.shippingAddress?.fullName||"ลูกค้าทั่วไป"}),(0,t.jsx)("td",{className:"py-3",children:(0,t.jsx)("span",{className:"px-2 py-0.5 rounded-md bg-gray-100 text-gray-600 text-[10px] font-bold",children:"qr_code"===e.paymentMethod?"พร้อมเพย์ QR":"bank_transfer"===e.paymentMethod?"โอนเงินธนาคาร":"ปกติ (General)"})}),(0,t.jsxs)("td",{className:"py-3 text-right font-black",children:["฿",e.totalAmount.toLocaleString()]}),(0,t.jsx)("td",{className:"py-3 text-right",children:(0,t.jsx)("span",{className:`font-bold ${"delivered"===e.status?"text-emerald-600":"shipped"===e.status?"text-amber-600":"processing"===e.status?"text-blue-600":"text-gray-500"}`,children:"delivered"===e.status?"จัดส่งแล้ว":"shipped"===e.status?"กำลังจัดส่ง":"processing"===e.status?"กำลังเตรียมพัสดุ":"รอดำเนินการ"})})]},e.id)):(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:4,className:"py-8 text-center text-gray-400 font-medium",children:ew?"No orders for your store yet":"ยังไม่มีประวัติคำสั่งซื้อในร้านค้าของคุณ"})})}),(0,t.jsx)("tfoot",{children:(0,t.jsxs)("tr",{className:"border-t-2 border-gray-100 font-black text-gray-900",children:[(0,t.jsx)("td",{colSpan:2,className:"pt-3",children:ew?"Total Order Sales:":"รวมยอดคำสั่งซื้อทั้งหมด:"}),(0,t.jsxs)("td",{className:"pt-3 text-right text-emerald-600 text-sm",children:["฿",s7.toLocaleString()]}),(0,t.jsx)("td",{className:"pt-3"})]})})]})})]}),(0,t.jsxs)("div",{className:"bg-white rounded-3xl border border-gray-150 p-6 shadow-sm font-prompt",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center pb-3 border-b border-gray-100 mb-4",children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-xs uppercase tracking-wider",children:"สินค้าและสถานะสต็อก (Product Activity)"}),(0,t.jsxs)("span",{className:"text-[10px] font-bold text-rose-600 bg-rose-50 px-2 py-0.5 rounded-full",children:[ek.filter(e=>!e.inStock||void 0!==e.stockCount&&0===e.stockCount).length," สินค้าหมด"]})]}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-left text-xs",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"border-b border-gray-100 text-[10px] text-gray-400 uppercase",children:[(0,t.jsx)("th",{className:"pb-2",children:"ชื่อสินค้า"}),(0,t.jsx)("th",{className:"pb-2",children:"ราคา"}),(0,t.jsx)("th",{className:"pb-2 text-right",children:"ขายแล้ว"}),(0,t.jsx)("th",{className:"pb-2 text-right",children:"สถานะคลัง"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-gray-50",children:ek.length>0?ek.map(e=>{let s=!e.inStock||void 0!==e.stockCount&&0===e.stockCount,r=void 0!==e.stockCount?e.stockCount:50*!!e.inStock,a=eC.reduce((t,s)=>{let r=s.items?.find(t=>t.product?.id===e.id);return t+(r?r.quantity||1:0)},0);return(0,t.jsxs)("tr",{className:"hover:bg-gray-50/50",children:[(0,t.jsxs)("td",{className:"py-3 font-bold text-gray-800 flex items-center gap-2",children:[e.images&&e.images.length>0&&(0,t.jsx)("img",{src:e.images[0],alt:e.name,className:"w-7 h-7 object-cover rounded-lg border border-gray-100 flex-shrink-0"}),(0,t.jsx)("span",{className:"truncate max-w-[140px] sm:max-w-[200px]",title:e.name,children:e.name})]}),(0,t.jsxs)("td",{className:"py-3",children:[e.originalPrice&&e.originalPrice>e.price&&(0,t.jsxs)("span",{className:"text-gray-400 line-through mr-1 text-[10px]",children:["฿",e.originalPrice.toLocaleString()]}),(0,t.jsxs)("span",{className:"font-bold text-amber-600",children:["฿",e.price.toLocaleString()]})]}),(0,t.jsxs)("td",{className:"py-3 text-right font-black",children:[a," ชิ้น"]}),(0,t.jsx)("td",{className:"py-3 text-right",children:s?(0,t.jsx)("span",{className:"text-rose-600 font-bold bg-rose-50 px-1.5 py-0.5 rounded text-[10px]",children:"หมดเกลี้ยง (0)"}):(0,t.jsxs)("span",{className:"text-emerald-600 font-bold text-[10px]",children:["มีสินค้า (",r,")"]})})]},e.id)}):(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:4,className:"py-8 text-center text-gray-400 font-medium",children:ew?"No products found in your store":"ยังไม่มีรายการสินค้าในร้านค้าของคุณ"})})})]})})]})]})]}),"products"===ed&&(0,t.jsx)("div",{className:"space-y-6",children:ta?(0,t.jsxs)("div",{className:"space-y-6 animate-in fade-in duration-200 font-prompt",children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center bg-white border border-gray-200/85 p-4.5 rounded-2xl shadow-xs gap-4 text-left",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3.5",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{tl(!1),tA(""),tT(0),tR(""),tq(""),tK([]),tX(0),tH(""),tB(!0)},className:"w-9 h-9 border border-gray-200 hover:bg-gray-50 text-gray-500 rounded-xl flex items-center justify-center transition-all cursor-pointer bg-white",children:(0,t.jsx)("span",{className:"text-sm",children:"←"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-base font-black text-gray-800 leading-none",children:tL?ew?"Edit Product":"แก้ไขข้อมูลสินค้า":ew?"Add New Product":"เพิ่มสินค้าใหม่"}),(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 font-bold block mt-1",children:[ew?"Last Update":"อัปเดตล่าสุด"," ",new Date().toLocaleDateString(ew?"en-US":"th-TH",{day:"numeric",month:"long",year:"numeric"})]})]})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-2 w-full sm:w-auto justify-end",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{tl(!1),tA(""),tT(0),tR(""),tq(""),tH(""),tB(!0),s6(ew?"Draft cleared and operation cancelled":"ล้างข้อมูลและยกเลิกรายการแล้ว","info")},className:"w-9 h-9 border border-rose-100 hover:bg-rose-50 text-rose-500 rounded-xl flex items-center justify-center transition-all cursor-pointer bg-white",title:ew?"Delete draft":"ลบแบบร่าง",children:(0,t.jsx)("span",{className:"text-sm",children:"🗑️"})}),(0,t.jsx)("button",{type:"button",onClick:()=>{tl(!1),s6(ew?"Product draft saved successfully":"บันทึกแบบร่างสินค้าแล้ว","success")},className:"bg-white hover:bg-gray-50 text-gray-700 font-bold border border-gray-200 text-xs px-4 py-2 h-9 rounded-xl transition-all cursor-pointer",children:ew?"Save Draft":"บันทึกแบบร่าง"}),(0,t.jsx)("button",{type:"submit",form:"add-product-form",className:"bg-[#800A0A] hover:bg-[#991B1B] text-white font-bold text-xs px-5 py-2 h-9 rounded-xl transition-all shadow-xs cursor-pointer",children:tL?ew?"Save Changes":"บันทึกการแก้ไข":ew?"Publish":"เผยแพร่"})]})]}),(0,t.jsxs)("form",{id:"add-product-form",onSubmit:e=>{if(e.preventDefault(),!tC.trim()||tE<=0)return void s6(ew?"Please fill in product name and price correctly":"กรุณากรอกข้อมูลสินค้าให้ถูกต้อง","error");if(tI<0)return void s6(ew?"Please enter a valid stock quantity":"กรุณาระบุจำนวนสินค้าในสต็อกให้ถูกต้อง","error");if(0===tU.length&&!tW)return void s6(ew?"Please upload at least one product image":"กรุณาอัปโหลดรูปภาพสินค้าอย่างน้อยหนึ่งรูป","error");let t=localStorage.getItem("ctc_products");t&&JSON.parse(t);let s=tV?tY.length>0?tY:["Free Size"]:[];if(tL){let e=ek.find(e=>e.id===tL),t={...e||{},id:tL,name:tC,slug:tC.toLowerCase().replace(/ /g,"-").replace(/[^\w-]/g,""),description:tz||"รายละเอียดสินค้าวิชาการเฉพาะสาขาช็อปแผนก",price:tE,compareAtPrice:se>0?Math.round(tE*(1+se/100)):void 0,images:tU.length>0?tU:[tW||"/u69319090023/Shop23/images/products/tshirt_black_1.svg"],categoryId:t4,sizes:s,stockCount:Number(tI),inStock:Number(tI)>0&&tM,videoUrl:tG||void 0,relatedProductIds:eN.map(e=>e.id),merchantEmail:el.email,rating:e?.rating??5,reviewsCount:e?.reviewsCount??0};z.default.saveProduct(t).then(()=>{z.default.getProducts().then(e=>{eS(e.filter(e=>e.merchantEmail&&e.merchantEmail.toLowerCase()===el.email.toLowerCase()))})}),tP(null),s6(ew?"Product updated successfully":"แก้ไขข้อมูลสินค้าเสร็จสิ้น","success")}else{let e={id:`prod_${Date.now()}`,name:tC,slug:tC.toLowerCase().replace(/ /g,"-").replace(/[^\w-]/g,""),description:tz||"รายละเอียดสินค้าวิชาการเฉพาะสาขาช็อปแผนก",price:tE,compareAtPrice:se>0?Math.round(tE*(1+se/100)):void 0,images:tU.length>0?tU:[tW||"/u69319090023/Shop23/images/products/tshirt_black_1.svg"],categoryId:t4,rating:5,reviewsCount:0,sizes:s,stockCount:Number(tI),inStock:Number(tI)>0&&tM,departmentSlugs:el.fullName.includes("คอมพิวเตอร์")?["computer-technology"]:[],merchantEmail:el.email,videoUrl:tG||void 0,relatedProductIds:eN.map(e=>e.id)};z.default.saveProduct(e).then(()=>{z.default.getProducts().then(e=>{eS(e.filter(e=>e.merchantEmail&&e.merchantEmail.toLowerCase()===el.email.toLowerCase()))})}),s6(ew?"New product published successfully":"เพิ่มสินค้าใหม่ลงในระบบสำเร็จแล้ว","success")}tl(!1),tA(""),tT(0),tO(50),tR(""),tq("/u69319090023/Shop23/images/products/tshirt_black_1.svg"),tK([]),tX(0),tH(""),t3("cat_tshirt"),t6("เสื้อยืดคอกลม"),t7("CMTC OFFICIAL"),st(0),tZ(!0),tQ(["S","M","L","XL"]),t1(""),tP(null),ev([])},className:"grid grid-cols-1 lg:grid-cols-3 gap-6 text-left",children:[(0,t.jsxs)("div",{className:"lg:col-span-1 flex flex-col space-y-6",children:[(0,t.jsxs)("div",{className:"bg-white border border-gray-200 p-5 rounded-2xl shadow-sm space-y-4",children:[(0,t.jsxs)("div",{className:"relative aspect-square w-full rounded-xl overflow-hidden bg-gray-50 border border-gray-150 flex items-center justify-center text-xs group cursor-pointer",children:[(0,t.jsx)("input",{type:"file",accept:"image/*",onChange:s8,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer z-10"}),tU[tJ]?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(a.default,{src:tU[tJ],alt:"Cover image",fill:!0,className:"object-contain p-1.5"}),(0,t.jsx)("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation();let t=tU.filter((e,t)=>t!==tJ);tK(t),tq(t[0]||""),tX(Math.max(0,t.length-1)),s6(ew?"Image removed":"ลบรูปภาพแล้ว","info")},className:"absolute top-2.5 right-2.5 w-7 h-7 bg-white/90 hover:bg-red-50 text-red-500 rounded-lg border border-gray-200 flex items-center justify-center text-xs cursor-pointer z-20 transition-all shadow-sm hover:scale-105",title:ew?"Remove image":"ลบรูปภาพ",children:"🗑️"})]}):(0,t.jsx)("div",{className:"text-center space-y-2 p-4 text-gray-400",children:sa?(0,t.jsx)("div",{className:"w-6 h-6 border-2 border-[#800A0A] border-t-transparent animate-spin rounded-full mx-auto"}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"text-2xl",children:"🖼️"}),(0,t.jsx)("p",{className:"font-bold text-[10px]",children:ew?"Click to upload image":"คลิกเพื่ออัปโหลดรูปภาพ"}),(0,t.jsxs)("p",{className:"text-[8px] text-gray-400",children:["(",ew?"Supports JPG, PNG, WEBP":"รองรับ JPG, PNG, WEBP",")"]})]})}),(0,t.jsx)("div",{className:"absolute bottom-2.5 left-2.5 bg-white/95 border border-gray-150 rounded-lg px-2 py-0.5 text-[9px] font-bold text-gray-700 select-none z-10 pointer-events-none",children:0===tJ?ew?"Cover":"ภาพหน้าปก":ew?`Image ${tJ+1}`:`รูปภาพที่ ${tJ+1}`})]}),(0,t.jsxs)("div",{className:"grid grid-cols-4 gap-2",children:[[0,1,2].map(e=>{let s=tU[e],r=tJ===e&&s;return(0,t.jsx)("div",{onClick:()=>{s&&tX(e)},className:`relative aspect-square rounded-xl overflow-hidden border bg-gray-50 flex items-center justify-center cursor-pointer transition-all ${r?"border-[#800A0A] ring-1 ring-[#800A0A]":"border-gray-200 hover:border-gray-300"}`,children:s?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(a.default,{src:s,alt:`Thumb ${e+1}`,fill:!0,className:"object-contain p-0.5"}),(0,t.jsx)("button",{type:"button",onClick:t=>{t.preventDefault(),t.stopPropagation();let s=tU.filter((t,s)=>s!==e);tK(s),tq(s[0]||""),tX(Math.max(0,s.length-1))},className:"absolute -top-1.5 -right-1.5 w-4.5 h-4.5 bg-red-500 hover:bg-red-600 text-white rounded-full flex items-center justify-center text-[8px] border border-white cursor-pointer hover:scale-110 transition-transform z-20",title:ew?"Remove":"ลบออก",children:"✕"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{type:"file",accept:"image/*",onChange:s8,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer z-10"}),(0,t.jsx)("span",{className:"text-[9px] text-gray-300 select-none",children:ew?"Empty":"ว่าง"})]})},e)}),(0,t.jsxs)("div",{className:"relative aspect-square rounded-xl border-2 border-dashed border-gray-200 hover:border-[#800A0A]/50 bg-gray-50 flex items-center justify-center transition-colors cursor-pointer group",children:[(0,t.jsx)("input",{type:"file",accept:"image/*",onChange:s8,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer z-10"}),sa?(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-[#800A0A] border-t-transparent animate-spin rounded-full mx-auto"}):(0,t.jsx)("span",{className:"text-gray-400 group-hover:text-[#800A0A] font-bold text-base pointer-events-none",children:"+"})]})]}),(0,t.jsxs)("div",{className:"pt-3 border-t border-gray-100 space-y-1.5",children:[(0,t.jsx)("label",{className:"text-[10px] font-bold text-gray-400 block",children:"ระบุ URL รูปภาพสินค้า (URL):"}),(0,t.jsx)("input",{type:"text",value:tW.startsWith("data:image")?"อัปโหลดรูปภาพสำเร็จ":tW,readOnly:tU.length>0,onChange:e=>{let t=e.target.value;t&&(tK([t]),tX(0),tq(t))},placeholder:"https://example.com/image.jpg",className:"w-full bg-gray-50 border border-gray-250 rounded-xl px-3 py-2 text-[10px] focus:outline-none focus:ring-1 focus:ring-[#800A0A]"})]})]}),(0,t.jsx)("div",{className:"bg-white border border-gray-200 p-5 rounded-2xl shadow-sm text-left flex-grow flex flex-col justify-between",children:(0,t.jsx)("div",{className:"flex-1 flex flex-col justify-between",children:(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex justify-between items-center pb-2 relative",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-xs",children:ew?"Free Gifts":"ของแถมสินค้า"}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 font-semibold mt-1",children:ew?"Select free gifts for this product from your store items":"เลือกของแถมสำหรับสินค้าชิ้นนี้จากสินค้าในร้านของคุณ"})]}),(0,t.jsx)("button",{type:"button",onClick:()=>{tD(!t_)},className:"w-7 h-7 border border-gray-250 text-gray-600 rounded-lg flex items-center justify-center text-xs hover:bg-gray-50 transition-all font-bold cursor-pointer bg-white",title:ew?"Add Related Item":"เพิ่มสินค้าเกี่ยวข้อง",children:t_?"✕":"+"}),t_&&(0,t.jsxs)("div",{className:"absolute right-0 top-9 w-64 bg-white border border-gray-200 rounded-xl shadow-lg p-2.5 z-30 space-y-1.5 max-h-48 overflow-y-auto",children:[(0,t.jsx)("span",{className:"text-[9px] font-bold text-gray-400 block px-1.5 uppercase",children:ew?"Select Free Gift from Store":"เลือกของแถมจากสินค้าในร้าน"}),0===(J=ek.filter(e=>e.id!==tL&&!eN.some(t=>t.id===e.id))).length?(0,t.jsx)("p",{className:"text-[10px] text-gray-400 italic text-center py-2",children:ew?"No other products available for gift":"ไม่มีสินค้าอื่นให้เลือกทำของแถมแล้ว"}):J.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>{ev(t=>[...t,e]),tD(!1),s6(ew?"Free gift added":"เพิ่มสินค้าของแถมสำเร็จ","success")},className:"w-full text-left flex items-center space-x-2 p-1.5 hover:bg-gray-50 rounded-lg border-none bg-transparent cursor-pointer transition-colors",children:[(0,t.jsx)("div",{className:"relative w-6 h-6 rounded border border-gray-200 overflow-hidden bg-white flex-shrink-0",children:(0,t.jsx)(a.default,{src:e.images?.[0]||"/u69319090023/Shop23/images/products/placeholder.jpg",alt:e.name,fill:!0,className:"object-contain p-0.5"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-gray-700 block truncate",children:e.name}),(0,t.jsxs)("span",{className:"text-[9px] text-emerald-600 font-extrabold block",children:["฿0 (",ew?"Free Gift":"ของแถมฟรี",")"]}),(0,t.jsxs)("span",{className:"text-[8px] text-gray-400 line-through block",children:["฿",e.price," (",e.inStock?ew?"Published":"เผยแพร่":ew?"Draft":"แบบร่าง",")"]})]})]},e.id))]})]}),(0,t.jsx)("div",{className:"mt-3.5 space-y-2.5",children:eN.length>0?eN.map(e=>(0,t.jsxs)("div",{className:"flex items-center justify-between bg-gray-50/50 p-2 border border-gray-150 rounded-xl",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2.5",children:[(0,t.jsx)("div",{className:"relative w-8 h-8 rounded-lg border border-gray-200 overflow-hidden bg-white flex-shrink-0",children:(0,t.jsx)(a.default,{src:e.images?.[0]||"/u69319090023/Shop23/images/products/placeholder.jpg",alt:e.name,fill:!0,className:"object-contain p-0.5"})}),(0,t.jsxs)("div",{className:"text-left",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-gray-800 block truncate max-w-[110px]",children:ew?"prod_tshirt_classic"===e.id?"CTC Classic T-Shirt":"prod_polo_official"===e.id?"CMTC Official Polo":e.name:e.name}),(0,t.jsxs)("span",{className:"text-[9px] text-emerald-600 font-extrabold block",children:["฿0 (",ew?"Free Gift":"ของแถมฟรี",")"]}),(0,t.jsxs)("span",{className:"text-[8px] text-gray-400 line-through block",children:["฿",e.price]})]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>{ev(t=>t.filter(t=>t.id!==e.id)),s6(ew?"Free gift removed":"ถอดสินค้าของแถมออกแล้ว","info")},className:"text-gray-400 hover:text-red-500 p-1 border-none bg-transparent cursor-pointer transition-colors",title:ew?"Remove":"ลบออก",children:"🗑️"})]},e.id)):(0,t.jsx)("p",{className:"text-[10px] text-gray-400 italic text-center py-2",children:ew?"No free gifts selected":"ยังไม่มีของแถมที่เลือก"})})]})})})]}),(0,t.jsxs)("div",{className:"lg:col-span-2 space-y-6",children:[(0,t.jsxs)("div",{className:"bg-white border border-gray-200 p-6 rounded-2xl shadow-sm space-y-5",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center border-b border-gray-100 pb-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-sm",children:ew?"Product Details":"รายละเอียดสินค้า"}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 font-semibold mt-0.5",children:ew?"Key info to describe and display your product.":"ข้อมูลสำคัญในการอธิบายและแสดงสินค้าของคุณ"})]}),(0,t.jsx)("span",{className:`px-2.5 py-0.8 rounded-full text-[9px] font-bold border leading-none ${tM?"bg-emerald-50 border-emerald-100 text-emerald-700":"bg-gray-50 border-gray-150 text-gray-500"}`,children:ew?`Status: ${tM?"Published":"Draft"}`:`สถานะ: ${tM?"เผยแพร่แล้ว":"แบบร่าง"}`})]}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("label",{className:"text-[11px] font-bold text-gray-600 block",children:[ew?"Product Name":"ชื่อสินค้า"," ",(0,t.jsx)("span",{className:"text-[#800A0A]",children:"*"})]}),(0,t.jsx)("input",{type:"text",required:!0,value:tC,onChange:e=>tA(e.target.value),placeholder:ew?"e.g. Natural Glow Face Moisturizer":"เช่น เสื้อช็อปแผนกช่างอิเล็กทรอนิกส์",className:"w-full bg-white border border-gray-200 rounded-xl px-3.5 py-2.5 text-xs focus:outline-none focus:ring-1 focus:ring-[#800A0A] focus:border-[#800A0A] transition-all font-medium h-10"})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("label",{className:"text-[11px] font-bold text-gray-600 block",children:[ew?"Status":"สถานะ"," ",(0,t.jsx)("span",{className:"text-[#800A0A]",children:"*"})]}),(0,t.jsxs)("select",{value:tM?"published":"draft",onChange:e=>tB("published"===e.target.value),className:"w-full bg-white border border-gray-200 rounded-xl px-3.5 py-2.5 text-xs focus:outline-none focus:ring-1 focus:ring-[#800A0A] font-medium h-10 cursor-pointer",children:[(0,t.jsx)("option",{value:"choose",disabled:!0,children:ew?"Choose product status":"เลือกสถานะสินค้า"}),(0,t.jsx)("option",{value:"published",children:ew?"Published":"เผยแพร่แล้ว"}),(0,t.jsx)("option",{value:"draft",children:ew?"Draft":"แบบร่าง"})]})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("label",{className:"text-[11px] font-bold text-gray-600 block",children:[ew?"Category":"หมวดหมู่สินค้า"," ",(0,t.jsx)("span",{className:"text-[#800A0A]",children:"*"})]}),(0,t.jsxs)("select",{value:t4,onChange:e=>t3(e.target.value),className:"w-full bg-white border border-gray-200 rounded-xl px-3.5 py-2.5 text-xs focus:outline-none focus:ring-1 focus:ring-[#800A0A] font-medium h-10 cursor-pointer",children:[t5.map(e=>(0,t.jsx)("option",{value:e.id,children:e.name},e.id)),(0,t.jsx)("option",{value:"cat_other",children:ew?"Others (Suggest New Category)":"อื่นๆ (เสนอแนะหมวดหมู่ใหม่)"})]})]}),"cat_other"===t4&&(0,t.jsxs)("div",{className:"bg-amber-50/60 border border-amber-200/80 rounded-xl p-4 space-y-3 animate-in fade-in slide-in-from-top-1 duration-200 text-left",children:[(0,t.jsxs)("span",{className:"text-[10px] text-amber-800 font-extrabold uppercase tracking-wide block",children:["💡 ",ew?"Suggest New Category to Admin":"เสนอแนะหมวดหมู่ใหม่แก่แอดมิน"]}),(0,t.jsx)("p",{className:"text-[10.5px] text-amber-700 font-medium leading-relaxed",children:ew?"Don't see your category? You can write it below to submit a request to the system administrator to review and add this category.":"หากไม่พบหมวดหมู่ที่ต้องการ คุณสามารถกรอกชื่อหมวดหมู่ที่ต้องการด้านล่างเพื่อเสนอแนะให้แอดมินพิจารณาอนุมัติเปิดหมวดหมู่ใหม่เข้าระบบได้ครับ"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("input",{type:"text",value:tF,onChange:e=>t$(e.target.value),placeholder:ew?"e.g. Uniform Shoes":"เช่น รองเท้าเครื่องแบบ",className:"flex-1 bg-white border border-amber-250 rounded-xl px-3 py-2 text-xs focus:outline-none focus:ring-1 focus:ring-amber-500 h-9 font-medium"}),(0,t.jsx)("button",{type:"button",onClick:()=>{if(!tF.trim())return void s6(ew?"Please enter a category name":"กรุณากรอกชื่อหมวดหมู่ที่ต้องการเสนอแนะ","error");let e=localStorage.getItem("ctc_category_suggestions"),t=e?JSON.parse(e):[],s={id:`sug_${Date.now()}`,name:tF.trim(),merchantEmail:el.email,status:"pending",createdAt:new Date().toISOString()};localStorage.setItem("ctc_category_suggestions",JSON.stringify([s,...t])),window.dispatchEvent(new Event("storage")),t$(""),s6(ew?"Category suggestion submitted to Admin!":"ส่งคำข้อแนะนำเพิ่มหมวดหมู่ให้แอดมินพิจารณาสำเร็จ!","success")},className:"bg-amber-600 hover:bg-amber-700 text-white font-bold text-[10.5px] px-3.5 h-9 rounded-xl border-none cursor-pointer transition-all shadow-xs",children:ew?"Submit Request":"ส่งคำเสนอ"})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("label",{className:"text-[11px] font-bold text-gray-600 block",children:[ew?"Price (THB)":"ราคา (บาท)"," ",(0,t.jsx)("span",{className:"text-[#800A0A]",children:"*"})]}),(0,t.jsx)("input",{type:"number",required:!0,min:"1",value:tE||"",onChange:e=>tT(Number(e.target.value)),placeholder:ew?"e.g. 350":"เช่น 350",className:"w-full bg-white border border-gray-200 rounded-xl px-3.5 py-2.5 text-xs focus:outline-none focus:ring-1 focus:ring-[#800A0A] focus:border-[#800A0A] transition-all font-medium h-10"})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-[11px] font-bold text-gray-600 block",children:ew?"Discount":"ส่วนลด"}),(0,t.jsxs)("div",{className:"flex rounded-xl border border-gray-200 overflow-hidden bg-white focus-within:ring-1 focus-within:ring-[#800A0A] focus-within:border-[#800A0A] transition-all h-10",children:[(0,t.jsx)("input",{type:"number",min:"0",max:"100",value:se||"",onChange:e=>st(Math.max(0,Math.min(100,Number(e.target.value)))),placeholder:ew?"e.g. 15":"เช่น 15",className:"w-full bg-transparent px-3.5 py-2 text-xs focus:outline-none border-none font-medium h-full"}),(0,t.jsx)("span",{className:"bg-gray-50 border-l border-gray-200 px-3 flex items-center text-xs text-gray-500 font-bold select-none h-full",children:"%"})]})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("label",{className:"text-[11px] font-bold text-gray-600 block",children:[ew?"Stock Quantity":"จำนวนสินค้า (สต็อก)"," ",(0,t.jsx)("span",{className:"text-[#800A0A]",children:"*"})]}),(0,t.jsxs)("div",{className:"flex rounded-xl border border-gray-200 overflow-hidden bg-white focus-within:ring-1 focus-within:ring-[#800A0A] focus-within:border-[#800A0A] transition-all h-10",children:[(0,t.jsx)("input",{type:"number",required:!0,min:"0",value:void 0!==tI?tI:"",onChange:e=>{let t=Math.max(0,parseInt(e.target.value,10)||0);tO(t),0===t?tB(!1):!tM&&t>0&&tB(!0)},placeholder:ew?"e.g. 50":"เช่น 50",className:"w-full bg-transparent px-3.5 py-2 text-xs focus:outline-none border-none font-medium h-full"}),(0,t.jsx)("span",{className:"bg-gray-50 border-l border-gray-200 px-3 flex items-center text-xs text-gray-500 font-bold select-none h-full",children:ew?"Items":"ชิ้น"})]})]})]}),(0,t.jsxs)("div",{className:"bg-gray-50/70 border border-gray-200 rounded-2xl p-4.5 space-y-3.5 transition-all text-left",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)("span",{className:"text-sm",children:"📏"}),(0,t.jsx)("label",{className:"text-xs font-bold text-gray-850",children:ew?"Product Size Options":"ตัวเลือกขนาดไซส์สินค้า"}),(0,t.jsx)("span",{className:`px-2 py-0.5 rounded-full text-[9px] font-bold border ${tV?"bg-emerald-50 text-emerald-700 border-emerald-200":"bg-gray-100 text-gray-500 border-gray-200"}`,children:tV?ew?"Sizes Enabled":"เปิดใช้งาน":ew?"Disabled":"ปิดใช้งาน"})]}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 font-medium",children:ew?"Enable size selection for apparel, or turn off for one-size/accessories.":"เปิดสำหรับสินค้าที่มีหลายขนาด (เช่น เสื้อผ้า รองเท้า) หรือปิดสำหรับสินค้าชิ้นเดียว/อุปกรณ์"})]}),(0,t.jsx)("button",{type:"button",onClick:()=>tZ(!tV),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors duration-200 focus:outline-none cursor-pointer border-none flex-shrink-0 ${tV?"bg-[#800A0A]":"bg-gray-300"}`,title:tV?ew?"Disable sizes":"ปิดระบบไซส์":ew?"Enable sizes":"เปิดระบบไซส์",children:(0,t.jsx)("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform duration-200 ${tV?"translate-x-4.5":"translate-x-0.8"}`})})]}),tV?(0,t.jsxs)("div",{className:"space-y-3 pt-2 border-t border-gray-200/80 animate-in fade-in duration-200",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-gray-500 uppercase tracking-wide block mb-1.5",children:ew?"Quick Presets:":"ชุดขนาดสำเร็จรูป:"}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,t.jsx)("button",{type:"button",onClick:()=>rl(["S","M","L","XL"]),className:"px-2.5 py-1 bg-white hover:bg-gray-100 border border-gray-250 text-gray-700 text-[10.5px] font-bold rounded-lg cursor-pointer transition-all shadow-2xs",children:"S - XL"}),(0,t.jsx)("button",{type:"button",onClick:()=>rl(["XS","S","M","L","XL","2XL","3XL"]),className:"px-2.5 py-1 bg-white hover:bg-gray-100 border border-gray-250 text-gray-700 text-[10.5px] font-bold rounded-lg cursor-pointer transition-all shadow-2xs",children:"XS - 3XL"}),(0,t.jsx)("button",{type:"button",onClick:()=>rl(['รอบอก 36"','รอบอก 38"','รอบอก 40"','รอบอก 42"','รอบอก 44"']),className:"px-2.5 py-1 bg-white hover:bg-gray-100 border border-gray-250 text-gray-700 text-[10.5px] font-bold rounded-lg cursor-pointer transition-all shadow-2xs",children:ew?'Chest 36"-44"':'รอบอก 36"-44"'}),(0,t.jsx)("button",{type:"button",onClick:()=>rl(["38","39","40","41","42","43","44"]),className:"px-2.5 py-1 bg-white hover:bg-gray-100 border border-gray-250 text-gray-700 text-[10.5px] font-bold rounded-lg cursor-pointer transition-all shadow-2xs",children:ew?"Shoes (38-44)":"รองเท้า (38-44)"}),(0,t.jsx)("button",{type:"button",onClick:()=>rl(["Free Size"]),className:"px-2.5 py-1 bg-white hover:bg-gray-100 border border-gray-250 text-gray-700 text-[10.5px] font-bold rounded-lg cursor-pointer transition-all shadow-2xs",children:"Free Size"})]})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("input",{type:"text",value:t0,onChange:e=>t1(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),ra())},placeholder:ew?"e.g. 4XL, Size 42, 100cm...":"พิมพ์ขนาดที่ต้องการ เช่น 4XL, รอบอก 46, เบอร์ 45...",className:"flex-1 bg-white border border-gray-300 rounded-xl px-3 py-2 text-xs focus:outline-none focus:ring-1 focus:ring-[#800A0A] focus:border-[#800A0A] font-medium h-9.5"}),(0,t.jsxs)("button",{type:"button",onClick:()=>ra(),className:"bg-[#800A0A] hover:bg-[#991B1B] text-white font-bold text-xs px-4 h-9.5 rounded-xl border-none cursor-pointer transition-all flex items-center gap-1 shadow-2xs",children:[(0,t.jsx)("span",{children:"+"}),(0,t.jsx)("span",{children:ew?"Add Size":"เพิ่มไซส์"})]})]}),(0,t.jsxs)("div",{className:"pt-1",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-gray-500 uppercase tracking-wide block mb-1.5",children:ew?`Active Sizes (${tY.length}):`:`ขนาดไซส์ที่พร้อมจำหน่าย (${tY.length}):`}),tY.length>0?(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:tY.map(e=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 bg-white border border-gray-250 text-gray-850 rounded-xl text-xs font-bold shadow-2xs hover:border-gray-400 transition-colors",children:[(0,t.jsx)("span",{children:e}),(0,t.jsx)("button",{type:"button",onClick:()=>{tQ(t=>t.filter(t=>t!==e))},className:"text-gray-400 hover:text-red-500 font-extrabold text-[11px] p-0.5 border-none bg-transparent cursor-pointer transition-colors",title:ew?"Remove size":"ลบไซส์นี้",children:"✕"})]},e))}):(0,t.jsxs)("p",{className:"text-[10.5px] text-amber-600 font-medium italic bg-amber-50/70 border border-amber-200 rounded-lg p-2",children:["⚠️ ",ew?"No sizes defined. Product will default to Free Size.":"ยังไม่มีขนาดไซส์ในรายการ (ระบบจะบันทึกเป็น Free Size อัตโนมัติ)"]})]})]}):(0,t.jsxs)("div",{className:"bg-white/80 border border-gray-200/80 rounded-xl p-3 text-[11px] text-gray-500 leading-relaxed font-medium flex items-center gap-2 animate-in fade-in duration-200",children:[(0,t.jsx)("span",{className:"text-base",children:"📦"}),(0,t.jsx)("span",{children:ew?"This product has no size options. Customers can choose quantity and buy directly without picking a size.":"สินค้านี้ไม่มีตัวเลือกขนาดไซส์ ลูกค้าสามารถระบุจำนวนและสั่งซื้อได้ทันทีโดยไม่ต้องเลือกขนาด"})]})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-[11px] font-bold text-gray-600 block",children:ew?"Description":"รายละเอียดคำอธิบาย"}),(0,t.jsx)("textarea",{value:tz,onChange:e=>tR(e.target.value),placeholder:ew?"Write a short description highlighting key benefits and features":"เขียนคำอธิบายสั้นๆ เพื่อเน้นจุดเด่นและลักษณะสำคัญของสินค้า",className:"w-full bg-white border border-gray-200 rounded-xl px-3.5 py-2.5 text-xs min-h-[120px] focus:outline-none focus:ring-1 focus:ring-[#800A0A] focus:border-[#800A0A] transition-all resize-none font-medium leading-relaxed"})]})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,t.jsxs)("div",{className:"bg-white border border-gray-200 p-5 rounded-2xl shadow-sm text-left flex flex-col justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-xs",children:"Visibility"}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 font-semibold mt-1",children:"You can change the visibility of this product for customers"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between mt-4 pt-4 border-t border-gray-100",children:[(0,t.jsx)("span",{className:"text-xs font-bold text-gray-700",children:ew?"Visible":"แสดงผลต่อลูกค้า"}),(0,t.jsx)("button",{type:"button",onClick:()=>tB(!tM),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors duration-200 focus:outline-none cursor-pointer border-none ${tM?"bg-emerald-500":"bg-gray-300"}`,children:(0,t.jsx)("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform duration-200 ${tM?"translate-x-4.5":"translate-x-0.8"}`})})]})]}),(0,t.jsxs)("div",{className:"bg-white border border-gray-200 p-5 rounded-2xl shadow-sm text-left flex flex-col justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-xs",children:"Preview"}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 font-semibold mt-1",children:"Want to see how your product will look like?"})]}),(0,t.jsx)("button",{type:"button",onClick:()=>s6("ตัวอย่างสินค้าจะถูกแสดงจำลองขึ้นมาบนหน้าร้านหลังจัดเก็บเสร็จสิ้น","info"),className:"w-full bg-white hover:bg-gray-50 text-gray-700 font-bold border border-gray-200 text-xs py-2 rounded-xl transition-all cursor-pointer mt-4 h-9 flex items-center justify-center animate-pulse",children:ew?"Preview":"ดูตัวอย่าง"})]})]})]})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-2xl font-black text-gray-900 leading-none font-prompt",children:ew?"All Products":"สินค้าทั้งหมด"}),(0,t.jsxs)("div",{className:"flex items-center space-x-1 text-[10px] sm:text-[11px] text-gray-400 font-bold uppercase tracking-wider font-prompt mt-2",children:[(0,t.jsx)("span",{children:"Products"}),(0,t.jsx)(k.ChevronRight,{className:"w-3 h-3 text-gray-300"}),(0,t.jsx)("span",{className:"text-gray-600",children:"All Products"})]})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-3 w-full md:w-auto",children:[(0,t.jsxs)("button",{onClick:()=>s6("การอัปโหลดไฟล์ชุดใหญ่ยังไม่เปิดใช้งานในเวอร์ชันนี้","info"),className:"flex-1 md:flex-initial flex items-center justify-center space-x-2 bg-white hover:bg-gray-50 text-gray-700 font-bold text-xs px-4 py-2.5 rounded-xl border border-gray-200 transition-all cursor-pointer font-prompt shadow-2xs h-9",children:[(0,t.jsx)(g.Plus,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{children:ew?"Upload Bulk Products":"อัปโหลดสินค้าหลายรายการ"})]}),(0,t.jsxs)("button",{onClick:()=>{tP(null),tA(""),tT(0),tO(50),tR(""),tq("/u69319090023/Shop23/images/products/tshirt_black_1.svg"),tK([]),tX(0),tH(""),t3("cat_tshirt"),t6("เสื้อยืดคอกลม"),t7("CMTC OFFICIAL"),st(0),tZ(!0),tQ(["S","M","L","XL"]),t1(""),ev([]),tl(!0)},className:"flex-1 md:flex-initial flex items-center justify-center space-x-2 bg-[#800A0A] hover:bg-[#991B1B] text-white font-bold text-xs px-4 py-2.5 rounded-xl transition-all cursor-pointer font-prompt shadow-sm h-9",children:[(0,t.jsx)(g.Plus,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{children:ew?"Add Product":"เพิ่มสินค้าใหม่"})]})]})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-4 shadow-sm font-prompt space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-col md:flex-row justify-between items-stretch md:items-center gap-4",children:[(0,t.jsxs)("div",{className:"relative flex-1 max-w-md",children:[(0,t.jsx)("span",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none",children:(0,t.jsx)(b.Search,{className:"h-4 w-4 text-gray-400"})}),(0,t.jsx)("input",{type:"text",value:ti,onChange:e=>td(e.target.value),placeholder:ew?"Search for product...":"ค้นหาข้อมูลสินค้า...",className:"w-full pl-10 pr-4 py-2 bg-white hover:bg-gray-50 focus:bg-white border border-gray-200 focus:border-gray-300 focus:ring-1 focus:ring-[#800A0A] rounded-xl text-xs focus:outline-none transition-all placeholder:text-gray-400 font-medium"})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-3 justify-end",children:[(0,t.jsxs)("div",{className:"relative font-prompt",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>ty(!tf),className:`flex items-center space-x-2 border px-4 py-2 rounded-xl text-xs font-bold transition-all cursor-pointer h-9 shadow-2xs ${tf?"bg-[#800A0A] border-[#800A0A] text-white":"bg-white hover:bg-gray-50 border-gray-200 text-gray-500"}`,children:[(0,t.jsx)(P.Calendar,{className:`w-4 h-4 ${tf?"text-white":"text-gray-400 animate-pulse"}`}),(0,t.jsx)("span",{children:(X=["ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค."],G=th.getDate().toString().padStart(2,"0"),H=X[th.getMonth()],V=th.getFullYear(),Z=tb.getDate().toString().padStart(2,"0"),Y=X[tb.getMonth()],Q=tb.getFullYear(),`${G} ${H} ${V} - ${Z} ${Y} ${Q}`)}),(0,t.jsx)(h.ChevronDown,{className:`w-3.5 h-3.5 transition-transform duration-200 ${tf?"rotate-180":""}`})]}),tf&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"fixed inset-0 z-30",onClick:()=>ty(!1)}),(0,t.jsxs)("div",{className:"absolute right-0 mt-2 w-72 rounded-2xl bg-white border border-gray-150 shadow-lg p-4 z-40 animate-in fade-in slide-in-from-top-2 duration-150 text-left font-prompt",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-1.5 mb-3.5",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{let e=new Date;tu(e),tg(e),ty(!1)},className:"px-2 py-1.5 text-[10px] font-bold text-gray-505 hover:text-gray-900 bg-gray-50 hover:bg-gray-100 rounded-lg transition-colors border-none cursor-pointer",children:"วันนี้ (Today)"}),(0,t.jsx)("button",{type:"button",onClick:()=>{let e=new Date,t=new Date;t.setDate(e.getDate()-7),tu(t),tg(e),ty(!1)},className:"px-2 py-1.5 text-[10px] font-bold text-gray-505 hover:text-gray-900 bg-gray-50 hover:bg-gray-100 rounded-lg transition-colors border-none cursor-pointer",children:"7 วันล่าสุด"}),(0,t.jsx)("button",{type:"button",onClick:()=>{let e=new Date;tu(new Date(e.getFullYear(),e.getMonth(),1)),tg(new Date(e.getFullYear(),e.getMonth()+1,0)),ty(!1)},className:"px-2 py-1.5 text-[10px] font-bold text-gray-505 hover:text-gray-900 bg-gray-50 hover:bg-gray-100 rounded-lg transition-colors border-none cursor-pointer",children:"เดือนนี้ (This Month)"}),(0,t.jsx)("button",{type:"button",onClick:()=>{let e=new Date,t=new Date;if(t.setDate(t.getDate()-7),el)try{let e=localStorage.getItem("ctc_accounts"),s=(e?JSON.parse(e):[]).find(e=>e.email.toLowerCase()===el.email.toLowerCase());if(s&&s.date){let e=s.date.includes("/")?"/":"-",r=s.date.split(e);if(3===r.length){let e=parseInt(r[0],10),s=parseInt(r[1],10)-1,a=parseInt(r[2],10);a>2400&&(a-=543),t=new Date(a,s,e)}}}catch(e){console.error("Error finding registration date:",e)}eC&&eC.length>0?t=new Date(Math.min(...eC.map(e=>new Date(e.createdAt||e.date||Date.now())).map(e=>e.getTime()))):ek&&ek.length>0&&(t=new Date(Math.min(...ek.map(e=>new Date(e.createdAt||Date.now())).map(e=>e.getTime())))),tu(t),tg(e),ty(!1)},className:"px-2 py-1.5 text-[9px] font-bold text-gray-550 hover:text-gray-900 bg-gray-50 hover:bg-gray-100 rounded-lg transition-colors border-none cursor-pointer leading-tight",children:"ตั้งแต่วันที่เริ่มขายจนถึงปัจจุบัน"})]}),(0,t.jsxs)("div",{className:"border-t border-gray-100 pt-3 mb-3.5",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center mb-3",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{0===tj?(tN(11),tw(tv-1)):tN(tj-1)},className:"p-1 hover:bg-gray-50 rounded-lg border-none bg-transparent cursor-pointer text-gray-500 hover:text-gray-900 text-xs font-bold",children:"<"}),(0,t.jsx)("span",{className:"text-xs font-black text-gray-800",children:`${["มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม"][tj]} ${tv}`}),(0,t.jsx)("button",{type:"button",onClick:()=>{11===tj?(tN(0),tw(tv+1)):tN(tj+1)},className:"p-1 hover:bg-gray-50 rounded-lg border-none bg-transparent cursor-pointer text-gray-500 hover:text-gray-900 text-xs font-bold",children:">"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-7 gap-1 text-center text-[10px] text-gray-400 font-extrabold uppercase mb-1.5",children:[(0,t.jsx)("span",{children:"อา"}),(0,t.jsx)("span",{children:"จ"}),(0,t.jsx)("span",{children:"อ"}),(0,t.jsx)("span",{children:"พ"}),(0,t.jsx)("span",{children:"พฤ"}),(0,t.jsx)("span",{children:"ศ"}),(0,t.jsx)("span",{children:"ส"})]}),(0,t.jsx)("div",{className:"grid grid-cols-7 gap-1 text-center",children:(()=>{let e=new Date(tv,tj+1,0).getDate(),s=new Date(tv,tj,1).getDay(),r=[];for(let e=0;e<s;e++)r.push((0,t.jsx)("div",{},`empty-${e}`));for(let s=1;s<=e;s++){let e=new Date(tv,tj,s),a=th&&e.toDateString()===th.toDateString(),l=tb&&e.toDateString()===tb.toDateString(),n=th&&tb&&e>th&&e<tb;r.push((0,t.jsx)("button",{type:"button",onClick:()=>{"start"===tk||e<th?(tu(e),tg(e),tS("end")):(tg(e),tS("start"),ty(!1))},className:`h-6 w-6 rounded-lg text-[10px] font-bold transition-all border-none cursor-pointer flex items-center justify-center mx-auto ${a||l?"bg-[#800A0A] text-white shadow-xs":n?"bg-red-50 text-[#800A0A] font-extrabold rounded-none":"text-gray-700 hover:bg-gray-100"}`,children:s},`day-${s}`))}return r})()})]}),(0,t.jsxs)("div",{className:"border-t border-gray-100 pt-3 flex flex-col space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between text-[10px] font-bold text-gray-400",children:[(0,t.jsx)("span",{children:"เลือกช่วงวันแมนนวล:"}),"end"===tk&&(0,t.jsx)("span",{className:"text-[#800A0A] animate-pulse",children:"← โปรดเลือกวันสิ้นสุด"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{className:"text-[9px] text-gray-400 font-extrabold uppercase",children:"วันที่เริ่มต้น"}),(0,t.jsx)("input",{type:"date",value:th.toISOString().split("T")[0],onChange:e=>{e.target.value&&tu(new Date(e.target.value))},className:"w-full bg-gray-50 border border-gray-200 rounded-lg px-2 py-1 text-[10px] focus:outline-none focus:ring-1 focus:ring-[#800A0A] font-medium"})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{className:"text-[9px] text-gray-400 font-extrabold uppercase",children:"วันที่สิ้นสุด"}),(0,t.jsx)("input",{type:"date",value:tb.toISOString().split("T")[0],onChange:e=>{e.target.value&&tg(new Date(e.target.value))},className:"w-full bg-gray-50 border border-gray-200 rounded-lg px-2 py-1 text-[10px] focus:outline-none focus:ring-1 focus:ring-[#800A0A] font-medium"})]})]})]})]})]})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>tm(!tp),className:`flex items-center space-x-2 border px-4 py-2 rounded-xl text-xs font-bold transition-all cursor-pointer h-9 shadow-2xs ${tp||"none"!==tc?"bg-[#800A0A] border-[#800A0A] text-white hover:bg-[#991B1B] hover:border-[#991B1B]":"bg-white hover:bg-gray-50 border-gray-200 text-gray-500"}`,children:[(0,t.jsx)(F.Filter,{className:`w-4 h-4 ${tp||"none"!==tc?"text-white":"text-gray-400"}`}),(0,t.jsxs)("span",{children:["best_seller"===tc&&"Filters: ขายดีสุด","least_seller"===tc&&"Filters: ขายน้อยสุด","price_desc"===tc&&"Filters: ราคาสูงสุด","price_asc"===tc&&"Filters: ราคาน้อยสุด","none"===tc&&"Filters"]}),(0,t.jsx)(h.ChevronDown,{className:`w-3.5 h-3.5 transition-transform duration-200 ${tp?"rotate-180":""}`})]}),tp&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"fixed inset-0 z-30",onClick:()=>tm(!1)}),(0,t.jsxs)("div",{className:"absolute right-0 mt-2 w-52 rounded-2xl bg-white border border-gray-150 shadow-lg py-2.5 z-40 animate-in fade-in slide-in-from-top-2 duration-150 text-left font-prompt",children:[(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-extrabold uppercase tracking-wider px-4 py-1.5 block",children:"เรียงตามยอดขาย"}),(0,t.jsxs)("button",{type:"button",onClick:()=>{tx("best_seller"),tm(!1)},className:`w-full px-4 py-2 text-xs font-bold hover:bg-gray-50 flex items-center justify-between border-none bg-transparent cursor-pointer ${"best_seller"===tc?"text-[#800A0A]":"text-gray-700"}`,children:[(0,t.jsx)("span",{children:"1. ขายดีสุด"}),"best_seller"===tc&&(0,t.jsx)("span",{children:"✓"})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>{tx("least_seller"),tm(!1)},className:`w-full px-4 py-2 text-xs font-bold hover:bg-gray-50 flex items-center justify-between border-none bg-transparent cursor-pointer ${"least_seller"===tc?"text-[#800A0A]":"text-gray-700"}`,children:[(0,t.jsx)("span",{children:"2. ขายน้อยสุด"}),"least_seller"===tc&&(0,t.jsx)("span",{children:"✓"})]}),(0,t.jsx)("div",{className:"border-t border-gray-100 my-1.5"}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-extrabold uppercase tracking-wider px-4 py-1.5 block",children:"เรียงตามราคาขาย"}),(0,t.jsxs)("button",{type:"button",onClick:()=>{tx("price_desc"),tm(!1)},className:`w-full px-4 py-2 text-xs font-bold hover:bg-gray-50 flex items-center justify-between border-none bg-transparent cursor-pointer ${"price_desc"===tc?"text-[#800A0A]":"text-gray-700"}`,children:[(0,t.jsx)("span",{children:"3. ราคาสินค้าสูงสุด"}),"price_desc"===tc&&(0,t.jsx)("span",{children:"✓"})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>{tx("price_asc"),tm(!1)},className:`w-full px-4 py-2 text-xs font-bold hover:bg-gray-50 flex items-center justify-between border-none bg-transparent cursor-pointer ${"price_asc"===tc?"text-[#800A0A]":"text-gray-700"}`,children:[(0,t.jsx)("span",{children:"4. ราคาสินค้าน้อยสุด"}),"price_asc"===tc&&(0,t.jsx)("span",{children:"✓"})]}),"none"!==tc&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"border-t border-gray-100 my-1.5"}),(0,t.jsx)("button",{type:"button",onClick:()=>{tx("none"),tm(!1)},className:"w-full px-4 py-1.5 text-xs font-bold text-gray-400 hover:text-gray-650 border-none bg-transparent cursor-pointer text-center",children:"ล้างการเรียงลำดับ"})]})]})]})]})]})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-1.5 border-b border-gray-100 pb-1 overflow-x-auto whitespace-nowrap scrollbar-none select-none",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>to("all"),className:`flex items-center space-x-2 px-4 py-2 text-xs font-bold transition-all border-none bg-transparent cursor-pointer relative ${"all"===tn?"text-gray-900 border-b-2 border-gray-900 font-black":"text-gray-400 hover:text-gray-600"}`,children:[(0,t.jsx)("span",{children:ew?"All":"ทั้งหมด"}),(0,t.jsx)("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full font-extrabold ${"all"===tn?"bg-gray-900 text-white":"bg-gray-100 text-gray-450"}`,children:ek.length})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>to("published"),className:`flex items-center space-x-2 px-4 py-2 text-xs font-bold transition-all border-none bg-transparent cursor-pointer relative ${"published"===tn?"text-gray-900 border-b-2 border-gray-900 font-black":"text-gray-400 hover:text-gray-600"}`,children:[(0,t.jsx)("span",{children:ew?"Published":"เผยแพร่แล้ว"}),(0,t.jsx)("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full font-extrabold ${"published"===tn?"bg-[#E96E25] text-white":"bg-gray-100 text-gray-450"}`,children:ek.filter(e=>e.inStock).length})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>to("out_of_stock"),className:`flex items-center space-x-2 px-4 py-2 text-xs font-bold transition-all border-none bg-transparent cursor-pointer relative ${"out_of_stock"===tn?"text-gray-900 border-b-2 border-gray-900 font-black":"text-gray-400 hover:text-gray-600"}`,children:[(0,t.jsx)("span",{children:ew?"Out of Stock":"สินค้าหมด"}),(0,t.jsx)("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full font-extrabold ${"out_of_stock"===tn?"bg-[#E96E25] text-white":"bg-gray-100 text-gray-450"}`,children:ek.filter(e=>!e.inStock).length})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>s6(ew?"No blocked items in this store":"ยังไม่มีรายการที่ถูกบล็อกในสาขานี้","info"),className:"flex items-center space-x-2 px-4 py-2 text-xs font-bold text-gray-400 hover:text-gray-605 transition-all border-none bg-transparent cursor-pointer",children:[(0,t.jsx)("span",{children:ew?"Block":"ถูกระงับ"}),(0,t.jsx)("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-gray-100 text-gray-400 font-extrabold",children:"0"})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>s6(ew?"No pending items in this store":"ยังไม่มีรายการรออนุมัติจัดส่งในสาขานี้","info"),className:"flex items-center space-x-2 px-4 py-2 text-xs font-bold text-gray-400 hover:text-gray-605 transition-all border-none bg-transparent cursor-pointer",children:[(0,t.jsx)("span",{children:ew?"Pending":"รอตรวจสอบ"}),(0,t.jsx)("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-gray-100 text-gray-400 font-extrabold",children:"0"})]})]}),(0,t.jsx)("div",{className:"overflow-x-auto w-full pt-2",children:(0,t.jsxs)("table",{className:"w-full text-left text-xs border-collapse min-w-[900px] whitespace-nowrap",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"border-b border-gray-100 text-gray-400 font-bold uppercase tracking-wider text-[10px]",children:[(0,t.jsx)("th",{className:"p-3.5 w-10 text-center",children:(0,t.jsx)("input",{type:"checkbox",className:"rounded border-gray-305 text-[#800A0A] focus:ring-[#800A0A] w-3.5 h-3.5 cursor-pointer"})}),(0,t.jsx)("th",{className:"p-3.5 w-12 text-center",children:"#"}),(0,t.jsx)("th",{className:"p-3.5",children:ew?"Product":"สินค้า"}),(0,t.jsx)("th",{className:"p-3.5",children:ew?"Stock":"คลังสินค้า"}),(0,t.jsx)("th",{className:"p-3.5",children:ew?"Price":"ราคา"}),(0,t.jsx)("th",{className:"p-3.5",children:ew?"Orders":"คำสั่งซื้อ"}),(0,t.jsx)("th",{className:"p-3.5",children:ew?"Rating":"คะแนน"}),(0,t.jsx)("th",{className:"p-3.5 text-center",children:ew?"Published":"เผยแพร่"}),(0,t.jsx)("th",{className:"p-3.5",children:ew?"Status":"สถานะ"}),(0,t.jsx)("th",{className:"p-3.5 text-center w-20",children:ew?"Action":"การจัดการ"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-gray-50 font-medium",children:(()=>{let e=ek.filter(e=>{if(ti){let t=ti.toLowerCase(),s=e.name.toLowerCase().includes(t),r=("cat_jacket"===e.categoryId?"เสื้อช็อป/แจ็คเก็ต":"เสื้อยืดเครื่องแบบ").toLowerCase().includes(t);if(!s&&!r)return!1}return"published"===tn?!0===e.inStock:"out_of_stock"!==tn||!1===e.inStock});if("best_seller"===tc){let t=e=>eC.filter(t=>t.items&&t.items.some(t=>t.product?.id===e.id)).length;e.sort((e,s)=>t(s)-t(e))}else if("least_seller"===tc){let t=e=>eC.filter(t=>t.items&&t.items.some(t=>t.product?.id===e.id)).length;e.sort((e,s)=>t(e)-t(s))}else"price_desc"===tc?e.sort((e,t)=>t.price-e.price):"price_asc"===tc&&e.sort((e,t)=>e.price-t.price);return e.length>0?e.map((e,s)=>{let l=eC.filter(t=>t.items&&t.items.some(t=>t.product?.id===e.id)).length,n=(s+1).toString().padStart(2,"0");return(0,t.jsxs)("tr",{className:"hover:bg-gray-50/40 transition-colors",children:[(0,t.jsx)("td",{className:"p-3.5 text-center",children:(0,t.jsx)("input",{type:"checkbox",className:"rounded border-gray-305 text-[#800A0A] focus:ring-[#800A0A] w-3.5 h-3.5 cursor-pointer"})}),(0,t.jsx)("td",{className:"p-3.5 text-center text-gray-400 font-semibold",children:n}),(0,t.jsx)("td",{className:"p-3.5",children:(0,t.jsxs)("div",{className:"flex items-center space-x-3.5",children:[(0,t.jsx)("div",{className:"relative w-10 h-10 bg-gray-50 rounded-xl overflow-hidden border border-gray-150 flex items-center justify-center flex-shrink-0",children:(0,t.jsx)(a.default,{src:e.images[0]||"/u69319090023/Shop23/images/placeholder.png",alt:e.name,fill:!0,className:"object-contain p-1"})}),(0,t.jsxs)("div",{className:"flex flex-col text-left min-w-0",children:[(0,t.jsx)("span",{className:"font-extrabold text-gray-850 hover:text-[#800A0A] transition-colors truncate max-w-[220px]",children:(0,t.jsx)(r.default,{href:`/products/${e.id}`,children:e.name})}),(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 font-semibold mt-0.5 uppercase tracking-wide",children:[ew?"Category:":"หมวดหมู่:"," ",t5.find(t=>t.id===e.categoryId)?.name||(ew?({cat_tshirt:"T-Shirt",cat_polo:"Polo Shirt",cat_hoodie:"Hoodie",cat_jacket:"Jacket",cat_accessory:"Accessory"})[e.categoryId]||"Specialty":"cat_tshirt"===e.categoryId?"เสื้อยืด":"cat_polo"===e.categoryId?"เสื้อโปโล":"cat_hoodie"===e.categoryId?"เสื้อฮู้ดดี้":"cat_jacket"===e.categoryId?"เสื้อช็อป/แจ็คเก็ต":"สินค้าทั่วไป")]})]})]})}),(0,t.jsx)("td",{className:"p-3.5 text-gray-700 font-bold",children:void 0!==e.stockCount?e.stockCount:80*!!e.inStock}),(0,t.jsxs)("td",{className:"p-3.5 font-bold text-gray-800",children:["฿",e.price.toLocaleString()]}),(0,t.jsx)("td",{className:"p-3.5 text-gray-500 font-bold",children:l}),(0,t.jsxs)("td",{className:"p-3.5 text-amber-500 font-black flex items-center gap-1 select-none",children:[(0,t.jsx)("span",{className:"text-xs",children:"★"})," ",(0,t.jsx)("span",{children:"4.5"})]}),(0,t.jsx)("td",{className:"p-3.5 text-center",children:(0,t.jsx)("button",{type:"button",onClick:()=>{let t=!e.inStock;eS(ek.map(s=>s.id===e.id?{...s,inStock:t}:s)),z.default.updateProductStock(e.id,t),s6(`อัปเดตสถานะคลังสินค้าสำหรับ "${e.name}" เรียบร้อยแล้ว`,"info")},className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors duration-200 focus:outline-none cursor-pointer border-none ${e.inStock?"bg-emerald-500":"bg-gray-300"}`,children:(0,t.jsx)("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform duration-200 ${e.inStock?"translate-x-4.5":"translate-x-0.8"}`})})}),(0,t.jsx)("td",{className:"p-3.5",children:(0,t.jsx)("span",{className:`inline-flex px-2.5 py-0.5 rounded-full text-[9px] font-bold border select-none ${e.inStock?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-gray-50 text-gray-500 border-gray-150"}`,children:e.inStock?ew?"Published":"เผยแพร่แล้ว":ew?"Draft":"แบบร่าง"})}),(0,t.jsx)("td",{className:"p-3.5 text-center",children:(0,t.jsxs)("div",{className:"flex items-center justify-center space-x-1.5",children:[(0,t.jsx)("button",{onClick:()=>{tP(e.id),tA(e.name),tT(e.price),st(e.discount||0),tO(void 0!==e.stockCount?e.stockCount:50*!!e.inStock),tR(e.description||""),tK(e.images||[]),tX(0),tq(e.images?.[0]||"/u69319090023/Shop23/images/products/tshirt_black_1.svg"),tH(e.videoUrl||""),t3(e.categoryId),tB(e.inStock);let t=e.sizes||[];t.length>0&&(1!==t.length||"Free Size"!==t[0])?(tZ(!0),tQ(t)):1===t.length&&"Free Size"===t[0]?(tZ(!0),tQ(["Free Size"])):(tZ(!1),tQ([])),t1("");let s=localStorage.getItem("ctc_products"),r=s?JSON.parse(s):[],a=e.relatedProductIds||[];ev(r.filter(e=>a.includes(e.id))),tl(!0)},className:"text-gray-400 hover:text-gray-700 p-1.5 transition-colors cursor-pointer border-none bg-transparent",title:ew?"Edit item":"แก้ไขรายการ",children:(0,t.jsx)(y,{className:"w-4 h-4"})}),(0,t.jsx)("button",{onClick:()=>{var t;return t=e.id,void(z.default.deleteProduct(t).then(()=>{z.default.getProducts().then(e=>{eS(e.filter(e=>e.merchantEmail&&e.merchantEmail.toLowerCase()===el.email.toLowerCase()))})}),s6("ลบสินค้าออกจากระบบสำเร็จแล้ว","info"))},className:"text-red-500 hover:text-red-700 p-1.5 transition-colors hover:scale-105 active:scale-95 cursor-pointer border-none bg-transparent",title:"ลบสินค้าออกจากระบบ",children:(0,t.jsx)(N.X,{className:"w-4.5 h-4.5"})})]})})]},e.id)}):(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:10,className:"p-10 text-center text-gray-400 text-xs font-semibold select-none",children:"ไม่มีข้อมูลสินค้าที่ตรงกับการค้นหาของคุณ"})})})()})]})}),(0,t.jsxs)("div",{className:"flex items-center justify-between border-t border-gray-100 pt-4 text-xs font-bold text-gray-400 select-none",children:[(0,t.jsx)("div",{children:(ee=ek.filter(e=>{if(ti){let t=ti.toLowerCase(),s=e.name.toLowerCase().includes(t),r=("cat_jacket"===e.categoryId?"เสื้อช็อป/แจ็คเก็ต":"เสื้อยืดเครื่องแบบ").toLowerCase().includes(t);if(!s&&!r)return!1}return"published"===tn?!0===e.inStock:"out_of_stock"!==tn||!1===e.inStock}).length,(0,t.jsxs)("span",{children:["1-",ee," of ",ee," items"]}))}),(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("button",{disabled:!0,className:"p-1 hover:bg-gray-50 rounded-lg text-gray-300 disabled:opacity-40 border-none bg-transparent cursor-pointer",children:"<"}),(0,t.jsx)("span",{className:"text-gray-800",children:"1"}),(0,t.jsx)("button",{disabled:!0,className:"p-1 hover:bg-gray-50 rounded-lg text-gray-300 disabled:opacity-40 border-none bg-transparent cursor-pointer",children:">"})]})]})]})]})}),"coupons"===ed&&(0,t.jsxs)("div",{className:"space-y-6 animate-in fade-in duration-200 font-prompt",children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center bg-white border border-gray-150 p-6 rounded-3xl shadow-sm gap-4",children:[(0,t.jsx)("div",{children:(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-2xl bg-red-50 text-[#800A0A] flex items-center justify-center flex-shrink-0",children:(0,t.jsx)(_.Ticket,{className:"w-5 h-5"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-xl font-extrabold text-gray-900 leading-none",children:ew?"Store Coupons & Promotions":"คูปอง & โปรโมชันร้านค้า"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 font-semibold mt-1",children:ew?"Create and manage Free Shipping or Discount coupons with minimum purchase conditions":"สร้างคูปองส่งฟรี หรือคูปองส่วนลด (% หรือ ฿) พร้อมกำหนดเงื่อนไขยอดซื้อขั้นต่ำ"})]})]})}),(0,t.jsxs)("button",{type:"button",onClick:()=>tt(!0),className:"bg-[#800A0A] hover:bg-[#991B1B] text-white text-xs font-bold px-5 py-2.5 rounded-2xl transition-all shadow-sm hover:shadow active:scale-98 flex items-center space-x-2 border-none cursor-pointer",children:[(0,t.jsx)(g.Plus,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:ew?"Create New Coupon":"สร้างคูปองใหม่"})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[(0,t.jsxs)("div",{className:"bg-white border border-gray-150 p-5 rounded-3xl shadow-sm space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between text-gray-400 text-xs font-bold",children:[(0,t.jsx)("span",{children:ew?"Total Coupons":"คูปองทั้งหมด"}),(0,t.jsx)(_.Ticket,{className:"w-4 h-4 text-gray-400"})]}),(0,t.jsx)("div",{className:"text-2xl font-black text-gray-900",children:eI.length}),(0,t.jsx)("div",{className:"text-[10px] text-gray-400 font-medium",children:ew?"Active in this store":"ในร้านค้านี้"})]}),(0,t.jsxs)("div",{className:"bg-white border border-gray-150 p-5 rounded-3xl shadow-sm space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between text-emerald-600 text-xs font-bold",children:[(0,t.jsx)("span",{children:ew?"Free Shipping":"คูปองส่งฟรี"}),(0,t.jsx)($.Truck,{className:"w-4 h-4"})]}),(0,t.jsx)("div",{className:"text-2xl font-black text-emerald-600",children:eI.filter(e=>"free_shipping"===e.type||"free_shipping"===e.discountType).length}),(0,t.jsx)("div",{className:"text-[10px] text-gray-400 font-medium",children:ew?"Free delivery deals":"ส่งฟรีเมื่อถึงยอดขั้นต่ำ"})]}),(0,t.jsxs)("div",{className:"bg-white border border-gray-150 p-5 rounded-3xl shadow-sm space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between text-amber-600 text-xs font-bold",children:[(0,t.jsx)("span",{children:ew?"Discounts":"คูปองส่วนลด"}),(0,t.jsx)(D,{className:"w-4 h-4"})]}),(0,t.jsx)("div",{className:"text-2xl font-black text-amber-600",children:eI.filter(e=>"discount"===e.type||"percent"===e.discountType||"amount"===e.discountType).length}),(0,t.jsx)("div",{className:"text-[10px] text-gray-400 font-medium",children:ew?"% and ฿ discount vouchers":"ลด % และเงินสด ฿"})]}),(0,t.jsxs)("div",{className:"bg-white border border-gray-150 p-5 rounded-3xl shadow-sm space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between text-blue-600 text-xs font-bold",children:[(0,t.jsx)("span",{children:ew?"Active Now":"เปิดใช้งานอยู่"}),(0,t.jsx)(j.Check,{className:"w-4 h-4"})]}),(0,t.jsx)("div",{className:"text-2xl font-black text-blue-600",children:eI.filter(e=>!1!==e.isActive).length}),(0,t.jsx)("div",{className:"text-[10px] text-gray-400 font-medium",children:ew?"Available for checkout":"ลูกค้าใช้สิทธิ์ได้ทันที"})]})]}),(0,t.jsxs)("div",{className:"bg-white border border-gray-150 p-6 rounded-3xl shadow-sm space-y-6",children:[(0,t.jsx)("div",{className:"flex flex-wrap items-center justify-between gap-4 border-b border-gray-100 pb-4",children:(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>tr("all"),className:`px-4 py-2 rounded-xl text-xs font-bold transition-all border-none cursor-pointer ${"all"===ts?"bg-gray-900 text-white shadow-xs":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:[ew?"All":"ทั้งหมด"," (",eI.length,")"]}),(0,t.jsxs)("button",{type:"button",onClick:()=>tr("free_shipping"),className:`px-4 py-2 rounded-xl text-xs font-bold transition-all border-none cursor-pointer ${"free_shipping"===ts?"bg-emerald-600 text-white shadow-xs":"bg-emerald-50 text-emerald-700 hover:bg-emerald-100"}`,children:["🚚 ",ew?"Free Shipping":"ส่งฟรี"," (",eI.filter(e=>"free_shipping"===e.type||"free_shipping"===e.discountType).length,")"]}),(0,t.jsxs)("button",{type:"button",onClick:()=>tr("discount"),className:`px-4 py-2 rounded-xl text-xs font-bold transition-all border-none cursor-pointer ${"discount"===ts?"bg-amber-600 text-white shadow-xs":"bg-amber-50 text-amber-700 hover:bg-amber-100"}`,children:["🏷️ ",ew?"Discounts":"ส่วนลด"," (",eI.filter(e=>"discount"===e.type||"percent"===e.discountType||"amount"===e.discountType).length,")"]}),(0,t.jsxs)("button",{type:"button",onClick:()=>tr("active"),className:`px-4 py-2 rounded-xl text-xs font-bold transition-all border-none cursor-pointer ${"active"===ts?"bg-blue-600 text-white shadow-xs":"bg-blue-50 text-blue-700 hover:bg-blue-100"}`,children:["🟢 ",ew?"Active":"เปิดใช้งาน"," (",eI.filter(e=>!1!==e.isActive).length,")"]})]})}),0===(et=eI.filter(e=>"free_shipping"===ts?"free_shipping"===e.type||"free_shipping"===e.discountType:"discount"===ts?"discount"===e.type||"percent"===e.discountType||"amount"===e.discountType:"active"!==ts||!1!==e.isActive)).length?(0,t.jsxs)("div",{className:"py-14 text-center space-y-4",children:[(0,t.jsx)("div",{className:"w-16 h-16 bg-gray-50 border border-gray-150 rounded-full flex items-center justify-center mx-auto text-3xl",children:"🎟️"}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("h3",{className:"text-sm font-extrabold text-gray-800",children:ew?"No coupons found in this category":"ยังไม่มีคูปองในหมวดหมู่นี้"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 font-medium",children:ew?"Click the button below to create your first promotion coupon":"กดปุ่มด้านล่างเพื่อเริ่มสร้างคูปองส่งฟรี หรือคูปองส่วนลดสำหรับร้านค้าของคุณ"})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>tt(!0),className:"bg-[#800A0A] hover:bg-[#991B1B] text-white text-xs font-bold px-5 py-2.5 rounded-xl transition-all shadow-sm border-none cursor-pointer",children:["+ ",ew?"Create Store Coupon":"สร้างคูปองใหม่"]})]}):(0,t.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:et.map((e,s)=>{let r="free_shipping"===e.type||"free_shipping"===e.discountType,a="percent"===e.discountType,l=e.minSpend??e.minPurchase??0,n=!1!==e.isActive;return(0,t.jsxs)("div",{className:`rounded-2xl border transition-all relative overflow-hidden flex flex-col justify-between ${n?"bg-white border-gray-200 hover:border-gray-300 shadow-sm hover:shadow":"bg-gray-50/80 border-gray-200 opacity-60"}`,children:[(0,t.jsxs)("div",{className:"p-5 space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:`px-2.5 py-0.5 rounded-md text-[10px] font-black uppercase tracking-wider ${r?"bg-emerald-100 text-emerald-800":a?"bg-amber-100 text-amber-800":"bg-blue-100 text-blue-800"}`,children:r?"🚚 ส่งฟรี (Free Shipping)":a?`🏷️ ส่วนลด ${e.discountValue||e.discount}%`:`💵 ส่วนลด ฿${(e.discountValue||e.discount).toLocaleString()}`}),(0,t.jsx)("span",{className:`text-[9px] font-bold px-2 py-0.5 rounded-full ${n?"bg-emerald-50 text-emerald-700":"bg-gray-200 text-gray-600"}`,children:n?"Active":"Disabled"})]}),(0,t.jsx)("h3",{className:"font-extrabold text-sm text-gray-900 pt-1",children:e.title||e.code})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>ro(e.code),className:"flex items-center space-x-1.5 bg-gray-100 hover:bg-gray-200 text-gray-800 px-3 py-1.5 rounded-xl text-xs font-mono font-black transition-colors cursor-pointer border border-gray-200",title:"คลิกเพื่อคัดลอกรหัส",children:[(0,t.jsx)("span",{children:e.code}),(0,t.jsx)(E.Copy,{className:"w-3 h-3 text-gray-500"})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 pt-2 text-[11px] font-medium text-gray-600",children:[(0,t.jsxs)("div",{className:"bg-gray-100 px-2.5 py-1 rounded-lg flex items-center space-x-1 font-bold text-gray-700",children:[(0,t.jsx)("span",{children:"🛒"}),(0,t.jsx)("span",{children:l>0?`ซื้อขั้นต่ำ ฿${l.toLocaleString()}`:"ไม่มีขั้นต่ำ"})]}),a&&e.maxDiscount>0&&(0,t.jsxs)("div",{className:"bg-amber-50 text-amber-800 px-2.5 py-1 rounded-lg font-bold",children:["🎯 ลดสูงสุด ฿",e.maxDiscount.toLocaleString()]})]})]}),(0,t.jsxs)("div",{className:"px-5 py-3 bg-gray-50 border-t border-gray-100 flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-[11px] text-gray-400 font-medium",children:e.usageCount?`ใช้ไปแล้ว ${e.usageCount} ครั้ง`:"ยังไม่มีการใช้งาน"}),(0,t.jsx)("div",{className:"flex items-center space-x-2",children:(0,t.jsx)("button",{type:"button",onClick:()=>{var t;let s;return t=e.code,void(eO(s=eI.map(e=>{if(e.code===t){let s=!1===e.isActive;return s6(s?`เปิดใช้งานคูปอง ${t} แล้ว`:`ปิดใช้งานคูปอง ${t} ชั่วคราว`,"info"),{...e,isActive:s}}return e})),rn(eM,s))},className:`text-[11px] font-bold px-2.5 py-1 rounded-lg border transition-colors ${n?"text-red-600 border-red-200 hover:bg-red-50":"text-emerald-600 border-emerald-200 hover:bg-emerald-50"}`,children:n?"ปิดใช้งาน":"เปิดใช้งาน"})})]})]},e.id||e.code||s)})})]})]}),"settings"===ed&&(0,t.jsxs)("div",{className:"space-y-6 text-left font-prompt",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-2xl font-black text-gray-900 leading-none",children:ew?"Store Settings":"ตั้งค่าร้านค้า"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 font-bold mt-1.5",children:ew?"Edit contact details and store information":"แก้ไขรายละเอียดการติดต่อและข้อมูลร้านค้าเพื่อสร้างความน่าเชื่อถือ"})]}),(0,t.jsxs)("div",{className:"w-full bg-white rounded-2xl border border-gray-150 p-6 sm:p-8 shadow-xs text-left space-y-6 font-prompt",children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-base",children:ew?"General Store Information":"ข้อมูลทั่วไปของร้านค้า"}),(0,t.jsxs)("div",{className:"flex items-center space-x-4 bg-gray-50 p-4 sm:p-5 rounded-2xl border border-gray-150",children:[(0,t.jsx)("div",{className:"relative w-16 h-16 sm:w-20 sm:h-20 rounded-2xl bg-[#800A0A]/5 border border-[#800A0A]/10 overflow-hidden flex items-center justify-center flex-shrink-0 text-3xl shadow-inner",children:sn?(0,t.jsx)(a.default,{src:sn,alt:"Store Logo",fill:!0,className:"object-cover"}):(0,t.jsx)("span",{children:"🏬"})}),(0,t.jsxs)("div",{className:"space-y-2 text-left flex-1",children:[(0,t.jsx)("span",{className:"text-xs font-bold text-gray-700 block",children:ew?"Store Logo / Profile Picture":"โลโก้ / รูปโปรไฟล์ร้านค้า"}),(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("input",{type:"file",accept:"image/*",onChange:s3,className:"text-xs text-gray-500 file:mr-3 file:py-1.5 file:px-3 file:rounded-xl file:border-0 file:text-xs file:font-bold file:bg-[#800A0A]/10 file:text-[#800A0A] hover:file:bg-[#800A0A]/20 cursor-pointer"}),si&&(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-[#800A0A] border-t-transparent animate-spin rounded-full flex-shrink-0"}),sn&&(0,t.jsx)("button",{type:"button",onClick:()=>{so(""),s6("ล้างรูปภาพโลโก้แล้ว","info")},className:"text-xs text-red-500 hover:underline font-bold cursor-pointer",children:ew?"Delete":"ลบรูป"})]})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-xs font-bold text-gray-700 block",children:ew?"Store Name":"ชื่อร้านค้า"}),(0,t.jsx)("input",{type:"text",value:eF,onChange:e=>e$(e.target.value),className:"w-full bg-gray-50 border border-gray-200 rounded-xl px-3.5 py-2.5 text-xs focus:outline-none focus:bg-white focus:border-[#800A0A] transition-all"})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-xs font-bold text-gray-700 block",children:ew?"Store Account Email":"อีเมลบัญชีร้านค้า"}),(0,t.jsx)("input",{type:"email",disabled:!0,value:e_,className:"w-full bg-gray-100 border border-gray-200 text-gray-500 rounded-xl px-3.5 py-2.5 text-xs cursor-not-allowed"})]})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-xs font-bold text-gray-700 block",children:ew?"Store Description / Policy":"รายละเอียดร้านค้า / นโยบายร้านค้า"}),(0,t.jsx)("textarea",{value:eE,onChange:e=>eT(e.target.value),className:"w-full bg-gray-50 border border-gray-200 rounded-xl p-3 text-xs h-28 focus:outline-none focus:bg-white focus:border-[#800A0A] transition-all font-prompt resize-none"})]}),(0,t.jsx)("div",{className:"flex justify-end pt-4 border-t border-gray-150",children:(0,t.jsx)("button",{onClick:()=>{el&&(localStorage.setItem("store_settings_"+el.email,JSON.stringify({disallowSystemCoupons:eM,coupons:eI,storeName:eF,storeDescription:eE,storeLogo:sn})),s6("บันทึกการตั้งค่าโปรไฟล์ร้านค้าสำเร็จ","success"))},className:"bg-[#800A0A] hover:bg-[#991B1B] text-white font-bold text-xs px-6 py-2.5 rounded-xl transition-all cursor-pointer shadow-sm active:scale-98",children:"บันทึกข้อมูลตั้งค่า"})})]})]}),"shipping"===ed&&(0,t.jsxs)("div",{className:"space-y-6 text-left",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-2xl font-black text-gray-900 leading-none",children:ew?"Fulfillment & Shipping Hub":"ศูนย์บริหารงานการจัดส่งและพัสดุ"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 font-bold mt-1.5",children:ew?"Manage store shipments, print shipping labels, and input tracking numbers.":"จัดการรายการจัดส่งสินค้า พิมพ์ใบปะหน้าพัสดุ และบันทึกหมายเลขการจัดส่งของร้านค้าของคุณ"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 font-prompt",children:[(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-gray-450 uppercase tracking-wider block",children:ew?"Pending Shipment":"รอการจัดส่ง"}),(0,t.jsx)("span",{className:"text-2xl font-black text-amber-600 block",children:eC.filter(e=>"processing"===e.status).length})]}),(0,t.jsx)("div",{className:"w-10 h-10 rounded-xl bg-amber-50 text-amber-500 border border-amber-100 flex items-center justify-center font-bold text-lg",children:"📦"})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-gray-455 uppercase tracking-wider block",children:ew?"Shipped / Dispatched":"จัดส่งแล้ว"}),(0,t.jsx)("span",{className:"text-2xl font-black text-emerald-600 block",children:eC.filter(e=>"shipped"===e.status||"delivered"===e.status).length})]}),(0,t.jsx)("div",{className:"w-10 h-10 rounded-xl bg-emerald-50 text-emerald-500 border border-emerald-100 flex items-center justify-center font-bold text-lg",children:"🚚"})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-gray-455 uppercase tracking-wider block",children:ew?"Returned / Problems":"ตีกลับ / มีปัญหา"}),(0,t.jsx)("span",{className:"text-2xl font-black text-red-600 block",children:eC.filter(e=>"cancelled"===e.status).length})]}),(0,t.jsx)("div",{className:"w-10 h-10 rounded-xl bg-red-50 text-red-500 border border-red-100 flex items-center justify-center font-bold text-lg",children:"⚠️"})]})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs space-y-4",children:[(0,t.jsx)("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center space-y-3 sm:space-y-0",children:(0,t.jsx)("h2",{className:"text-sm font-black text-gray-950",children:ew?"Orders Awaiting Fulfillment":"คำสั่งซื้อที่พร้อมจัดส่ง"})}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-left text-xs border-collapse min-w-[850px] whitespace-nowrap",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"border-b border-gray-150 text-gray-450 font-bold",children:[(0,t.jsx)("th",{className:"pb-3 pr-4 font-bold",children:ew?"Order ID":"เลขคำสั่งซื้อ"}),(0,t.jsx)("th",{className:"pb-3 px-4 font-bold",children:ew?"Recipient":"ผู้รับปลายทาง"}),(0,t.jsx)("th",{className:"pb-3 px-4 font-bold",children:ew?"Items Ordered":"รายการสินค้า"}),(0,t.jsx)("th",{className:"pb-3 px-4 font-bold",children:ew?"Method":"วิธีจัดส่ง"}),(0,t.jsx)("th",{className:"pb-3 px-4 font-bold",children:ew?"Fulfillment Status":"สถานะขั้นตอน"}),(0,t.jsx)("th",{className:"pb-3 pl-4 font-bold text-right",children:ew?"Actions":"การจัดการ"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-gray-100 font-medium text-gray-700",children:eC.filter(e=>"processing"===e.status||"pending"===e.status||"shipped"===e.status).length>0?eC.filter(e=>"processing"===e.status||"pending"===e.status||"shipped"===e.status).map(e=>{let s=e.shippingAddress?.addressLine1?.toLowerCase().includes("รับเอง")||e.shippingAddress?.city?.toLowerCase().includes("รับเอง")||e.shippingAddress?.postalCode==="50000_pickup",r=e.shippingCarrier||(s?"รับเองที่วิทยาลัย":"Flash Express");return(0,t.jsxs)("tr",{className:"hover:bg-gray-50/40 transition-colors",children:[(0,t.jsxs)("td",{className:"py-3.5 pr-4 font-bold text-gray-950",children:["#",e.id,(0,t.jsx)("span",{className:"block text-[9px] text-gray-450 font-normal mt-0.5",children:new Date(e.date).toLocaleDateString("th-TH")})]}),(0,t.jsxs)("td",{className:"py-3.5 px-4",children:[(0,t.jsx)("span",{className:"font-bold text-gray-900 block leading-none",children:e.shippingAddress?.fullName}),(0,t.jsxs)("span",{className:"text-[10px] text-gray-455 font-normal block mt-1",children:["โทร: ",e.shippingAddress?.phone||"ไม่มีเบอร์โทร"]})]}),(0,t.jsx)("td",{className:"py-3.5 px-4 max-w-[240px] truncate",children:e.items?.map((e,s)=>(0,t.jsxs)("div",{className:"text-[11px] leading-tight truncate",children:["• ",e.product?.name," (x",e.quantity,")"]},s))}),(0,t.jsx)("td",{className:"py-3.5 px-4",children:(0,t.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold ${s?"bg-amber-50 text-amber-600 border border-amber-100":"bg-blue-50 text-blue-600 border border-blue-100"}`,children:s?"🏢 รับที่วิทยาลัย":`🚚 ${r}`})}),(0,t.jsx)("td",{className:"py-3.5 px-4",children:"shipped"===e.status?(0,t.jsxs)("span",{className:"text-[11px] text-emerald-600 font-extrabold flex items-center space-x-1",children:[(0,t.jsx)("span",{children:"✓"}),(0,t.jsx)("span",{children:ew?`Shipped (${e.trackingCode})`:`จัดส่งแล้ว (${e.trackingCode})`})]}):(0,t.jsxs)("span",{className:"text-[11px] text-amber-500 font-bold flex items-center space-x-1",children:[(0,t.jsx)("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-amber-500 animate-ping"}),(0,t.jsx)("span",{children:ew?"Awaiting Shipment":"รอผู้ขายจัดส่ง"})]})}),(0,t.jsx)("td",{className:"py-3.5 pl-4 text-right",children:(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{sm(e),sx(!0)},className:"border border-gray-250 hover:bg-gray-50 text-gray-700 text-[10px] font-bold px-2.5 py-1.5 rounded-lg cursor-pointer transition-colors shadow-2xs",children:["🎫 ",ew?"Label":"ใบปะหน้า"]}),"shipped"!==e.status&&(0,t.jsxs)("button",{type:"button",onClick:()=>{sg(e),sN(""),sy(s?"รับเองที่วิทยาลัย":"Flash Express"),su(!0)},className:"bg-[#800A0A] hover:bg-[#991B1B] text-white text-[10px] font-bold px-2.5 py-1.5 rounded-lg cursor-pointer transition-colors shadow-sm",children:["✍ ",ew?"Enter Tracking":"ใส่เลขพัสดุ"]})]})})]},e.id)}):(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:6,className:"py-8 text-center text-gray-400 italic",children:ew?"No shipments found for your products":"ไม่พบรายการส่งมอบสำหรับผลิตภัณฑ์ของคุณ"})})})]})})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs space-y-4",children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-sm",children:ew?"Quick Fulfillment Form":"กรอกเลขพัสดุรวดเร็ว (หลายออเดอร์)"}),(0,t.jsx)("p",{className:"text-[11px] text-gray-450",children:ew?"Enter tracking codes inline below and save them one-by-one.":"พิมพ์หมายเลขการจัดส่งและคลิกเพื่อบันทึกและเปลี่ยนสถานะรวดเร็วแยกตามออเดอร์"}),(0,t.jsx)("div",{className:"space-y-2.5 max-h-[300px] overflow-y-auto pr-1",children:eC.filter(e=>"processing"===e.status).length>0?eC.filter(e=>"processing"===e.status).map(e=>{let s=e.shippingAddress?.addressLine1?.toLowerCase().includes("รับเอง")||e.shippingAddress?.city?.toLowerCase().includes("รับเอง")||e.shippingAddress?.postalCode==="50000_pickup";return(0,t.jsxs)("div",{className:"flex items-center justify-between border border-gray-150 p-3 rounded-xl bg-gray-50/50",children:[(0,t.jsxs)("div",{className:"text-xs",children:[(0,t.jsxs)("span",{className:"font-bold text-gray-950 block",children:["#",e.id]}),(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 font-medium",children:[e.shippingAddress?.fullName," (",s?"รับเองที่วิทยาลัย":"จัดส่งพัสดุ",")"]})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)("input",{type:"text",placeholder:s?"รหัสรับสินค้า":"เลขพัสดุ Tracking",value:sk[e.id]?.code||"",onChange:t=>{sS({...sk,[e.id]:{code:t.target.value,carrier:s?"รับเองที่วิทยาลัย":sk[e.id]?.carrier||"Flash Express"}})},className:"bg-white border border-gray-250 rounded-lg px-2 py-1 text-[11px] w-[140px] focus:outline-none"}),(0,t.jsx)("button",{type:"button",onClick:()=>{let t=sk[e.id]?.code||(s?`PICKUP-${Math.random().toString(36).substr(2,6).toUpperCase()}`:""),r=s?"รับเองที่วิทยาลัย":sk[e.id]?.carrier||"Flash Express";rr(e.id,r,t)},className:"bg-emerald-600 hover:bg-emerald-700 text-white font-bold text-[10px] px-3 py-1.5 rounded-lg shadow-sm cursor-pointer",children:ew?"Save":"บันทึก"})]})]},e.id)}):(0,t.jsx)("p",{className:"text-xs text-gray-400 italic py-4 text-center",children:ew?"No pending shipments to fulfill":"ไม่มีคำสั่งซื้อที่รอการจัดส่งในขณะนี้"})})]}),(0,t.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),!sv.trim())return void s6("กรุณากรอกข้อมูลเลขพัสดุแบบกลุ่ม","error");let t=sv.split("\n"),s=0,r=localStorage.getItem("ctc_orders"),a=(r?JSON.parse(r):[]).map(e=>{let r=t.find(t=>{let s=t.split(",");return s[0]&&s[0].trim()===e.id});if(r){let t=r.split(","),a=t[1]?t[1].trim():"",l=t[2]?t[2].trim():"Flash Express";if(a)return s++,{...e,status:"shipped",trackingCode:a,shippingCarrier:l}}return e});if(0===s)return void s6("ไม่พบรหัสออเดอร์ที่ตรงกันหรือข้อมูลไม่ถูกต้อง","error");localStorage.setItem("ctc_orders",JSON.stringify(a));let l=localStorage.getItem("ctc_products"),n=l?JSON.parse(l):[];eA(a.filter(e=>e.items&&e.items.some(e=>{let t=n.find(t=>t.id===e.product?.id),s=t?t.merchantEmail:e.product?.merchantEmail;return s&&s.toLowerCase()===el?.email.toLowerCase()}))),sw(""),window.dispatchEvent(new Event("storage")),s6(`อัปเดตเลขพัสดุแบบกลุ่มสำเร็จ ${s} รายการ`,"success")},className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs space-y-4",children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-sm",children:ew?"Batch Upload Tracking (CSV Format)":"อัปโหลดเลขพัสดุแบบกลุ่ม (Batch CSV)"}),(0,t.jsx)("p",{className:"text-[11px] text-gray-450",children:ew?"Paste tracking data. Format: OrderID,TrackingCode,CarrierName (one order per line).":"วางข้อมูลหมายเลขพัสดุในรูปแบบ: รหัสสั่งซื้อ,เลขพัสดุ,บริษัทขนส่ง (1 รายการต่อบรรทัด)"}),(0,t.jsx)("textarea",{rows:4,value:sv,onChange:e=>sw(e.target.value),placeholder:"CMTC-2024,TH0123456789FL,Flash Express CMTC-2025,KER123456789,Kerry Express",className:"w-full bg-gray-50 border border-gray-255 rounded-xl p-3 text-xs font-mono focus:outline-none focus:ring-1 focus:ring-[#800A0A] resize-none"}),(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("span",{className:"text-[10px] text-gray-450 italic",children:ew?"Supports Kerry, Flash, EMS, Pickup":"รองรับ Flash, Kerry, EMS และ รับเองที่วิทยาลัย"}),(0,t.jsx)("button",{type:"submit",className:"bg-[#800A0A] hover:bg-[#991B1B] text-white font-bold text-xs px-4 py-2 rounded-xl transition-all cursor-pointer shadow-sm",children:ew?"Process Batch":"ประมวลผลกลุ่ม"})]})]})]})]}),sc&&sp&&(0,t.jsx)("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-xs flex items-center justify-center z-50 p-4 font-prompt",children:(0,t.jsxs)("div",{className:"bg-white rounded-2xl max-w-lg w-full overflow-hidden shadow-2xl border border-gray-150 flex flex-col text-left",children:[(0,t.jsxs)("div",{className:"p-4 border-b border-gray-150 bg-gray-50 flex justify-between items-center",children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-sm",children:ew?"Print Shipping Label (Mockup)":"ใบปะหน้าพัสดุสำหรับพิมพ์ (จำลอง)"}),(0,t.jsx)("button",{type:"button",onClick:()=>{sx(!1),sm(null)},className:"text-gray-400 hover:text-gray-600 p-1 text-sm font-bold cursor-pointer",children:"✕"})]}),(0,t.jsx)("div",{id:"shipping-label-printable",className:"p-6 space-y-5 bg-white overflow-y-auto max-h-[480px]",children:(0,t.jsxs)("div",{className:"border-2 border-black p-4 font-sans space-y-4 text-xs",children:[(0,t.jsxs)("div",{className:"flex justify-between items-start border-b-2 border-black pb-2",children:[(0,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsx)("span",{className:"font-extrabold text-sm block",children:"CMTC SHOP"}),(0,t.jsx)("span",{className:"text-[10px] text-gray-500 font-bold tracking-widest block uppercase",children:"Chiangmai Technical College"})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("span",{className:"text-[10px] bg-black text-white px-2 py-0.5 font-bold uppercase tracking-wider",children:sp.shippingAddress?.addressLine1?.toLowerCase().includes("รับเอง")||sp.shippingAddress?.city?.toLowerCase().includes("รับเอง")||sp.shippingAddress?.postalCode==="50000_pickup"?"PICKUP":"DOMESTIC"}),(0,t.jsxs)("span",{className:"block font-bold text-[10px] mt-1 text-gray-900",children:["ออเดอร์ #",sp.id]})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-[11px] leading-relaxed",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"font-black text-gray-900 block text-[10px] uppercase",children:"ผู้ส่ง (FROM)"}),(0,t.jsx)("p",{className:"font-bold text-gray-800",children:eF||"ร้านค้าแผนก CMTC"}),(0,t.jsx)("p",{className:"text-gray-500 font-medium",children:"วิทยาลัยเทคนิคเชียงใหม่ 9 ถ.เวียงแก้ว ต.ศรีภูมิ อ.เมือง จ.เชียงใหม่ 50200"}),(0,t.jsx)("p",{className:"text-gray-550 font-medium",children:"โทร: 053-217-123"})]}),(0,t.jsxs)("div",{className:"space-y-1 border-l border-gray-300 pl-4",children:[(0,t.jsx)("span",{className:"font-black text-gray-900 block text-[10px] uppercase",children:"ผู้รับ (TO)"}),(0,t.jsx)("p",{className:"font-bold text-gray-800",children:sp.shippingAddress?.fullName}),(0,t.jsxs)("p",{className:"text-gray-550 font-medium",children:[sp.shippingAddress?.addressLine1," ",sp.shippingAddress?.addressLine2||""," ",sp.shippingAddress?.city," ",sp.shippingAddress?.postalCode]}),(0,t.jsxs)("p",{className:"text-gray-550 font-medium",children:["โทร: ",sp.shippingAddress?.phone]}),(0,t.jsxs)("p",{className:"text-[9px] text-[#800A0A] font-bold",children:["รหัสนักศึกษา: ",sp.shippingAddress?.studentId||"65301040088"]})]})]}),(0,t.jsxs)("div",{className:"border-t-2 border-black pt-4 flex flex-col items-center justify-center space-y-1 select-none py-2 bg-gray-50 border border-dashed border-gray-300 rounded-lg",children:[(0,t.jsx)("div",{className:"flex space-x-[1px] h-8 items-end",children:[1,3,1,1,2,1,4,1,2,3,1,2,1,4,2,1,3,1,1,2,1,3,1,4,1,2,1,1,3,2,1,2,4,1,2,1,3].map((e,s)=>(0,t.jsx)("div",{className:"bg-black",style:{width:`${e}px`,height:"100%"}},s))}),(0,t.jsx)("span",{className:"font-mono text-[10px] font-black tracking-widest text-gray-800",children:sp.trackingCode||`CMTC-${sp.id}-TEMP`})]}),(0,t.jsx)("div",{className:"border-t border-gray-200 pt-2 text-[9px] text-gray-400 text-center font-medium italic",children:"พัสดุอุปกรณ์เพื่อการศึกษาผ่านระบบ CMTC SHOP วิทยาลัยเทคนิคเชียงใหม่"})]})}),(0,t.jsxs)("div",{className:"p-4 border-t border-gray-150 bg-gray-50 flex justify-end gap-2 text-xs",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{window.print(),s6("ส่งคำสั่งพิมพ์ใบปะหน้าสำเร็จ","success")},className:"bg-[#800A0A] hover:bg-[#991B1B] text-white font-bold px-4 py-2 rounded-xl transition-all cursor-pointer shadow-sm",children:["🖨️ ",ew?"Print Label":"พิมพ์ใบปะหน้า"]}),(0,t.jsx)("button",{type:"button",onClick:()=>{sx(!1),sm(null)},className:"border border-gray-250 hover:bg-gray-55 text-gray-755 font-bold px-4 py-2 rounded-xl cursor-pointer transition-colors",children:ew?"Close":"ปิด"})]})]})}),sh&&sb&&(0,t.jsx)("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-xs flex items-center justify-center z-50 p-4 font-prompt",children:(0,t.jsxs)("form",{onSubmit:e=>{e.preventDefault(),rr(sb.id,sf,sj),su(!1),sg(null)},className:"bg-white rounded-2xl max-w-sm w-full overflow-hidden shadow-2xl border border-gray-150 flex flex-col text-left",children:[(0,t.jsxs)("div",{className:"p-4 border-b border-gray-150 bg-gray-50 flex justify-between items-center",children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-sm",children:ew?"Update Tracking & Carrier":"บันทึกข้อมูลและหมายเลขพัสดุ"}),(0,t.jsx)("button",{type:"button",onClick:()=>{su(!1),sg(null)},className:"text-gray-400 hover:text-gray-600 p-1 text-sm font-bold cursor-pointer",children:"✕"})]}),(0,t.jsxs)("div",{className:"p-5 space-y-4 text-xs font-prompt",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"font-bold text-gray-450 block uppercase",children:"ออเดอร์ที่ดำเนินการ (Order)"}),(0,t.jsxs)("span",{className:"font-extrabold text-gray-950 text-sm",children:["#",sb.id]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{className:"font-bold text-gray-600 block",children:ew?"Shipping Carrier":"บริษัทขนส่ง"}),(0,t.jsxs)("select",{value:sf,onChange:e=>{let t=e.target.value;sy(t),"รับเองที่วิทยาลัย"===t?sN(`PICKUP-${Math.random().toString(36).substr(2,6).toUpperCase()}`):sN("")},className:"w-full bg-gray-55 border border-gray-250 rounded-xl px-3 py-2 text-xs focus:outline-none",children:[(0,t.jsx)("option",{value:"Flash Express",children:"Flash Express"}),(0,t.jsx)("option",{value:"Kerry Express",children:"Kerry Express"}),(0,t.jsx)("option",{value:"EMS (Thailand Post)",children:"EMS (Thailand Post)"}),(0,t.jsx)("option",{value:"รับเองที่วิทยาลัย",children:"รับเองที่วิทยาลัย (CMTC Coop/Dept Pickup)"})]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{className:"font-bold text-gray-600 block",children:"รับเองที่วิทยาลัย"===sf?ew?"Pickup Code":"รหัสรับสินค้า":ew?"Tracking Code":"หมายเลขพัสดุ Tracking"}),(0,t.jsx)("input",{type:"text",required:!0,placeholder:"รับเองที่วิทยาลัย"===sf?"เช่น PICKUP-A7B8":"เช่น TH0123456789FL",value:sj,onChange:e=>sN(e.target.value),className:"w-full bg-gray-55 border border-gray-250 rounded-xl px-3 py-2 text-xs focus:outline-none"})]})]}),(0,t.jsxs)("div",{className:"p-4 border-t border-gray-150 bg-gray-50 flex justify-end gap-2 text-xs",children:[(0,t.jsx)("button",{type:"submit",className:"bg-emerald-600 hover:bg-emerald-700 text-white font-bold px-4 py-2 rounded-xl shadow-sm cursor-pointer",children:ew?"Confirm Dispatch":"ยืนยันจัดส่ง"}),(0,t.jsx)("button",{type:"button",onClick:()=>{su(!1),sg(null)},className:"border border-gray-250 hover:bg-gray-55 text-gray-755 font-bold px-4 py-2 rounded-xl cursor-pointer transition-colors",children:ew?"Cancel":"ยกเลิก"})]})]})}),"finance"===ed&&(0,t.jsx)("div",{className:"space-y-6 text-left font-prompt",children:(es=eC.filter(e=>"cancelled"!==e.status).reduce((e,t)=>e+(t.totalAmount||0),0),er=W.default.calculateStoreCommission(es,eL),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("h1",{className:"text-2xl font-black text-gray-900 leading-none flex items-center gap-2.5",children:[(0,t.jsx)("span",{children:"💰"}),(0,t.jsx)("span",{children:ew?"Seller Wallet & Financial Overview":"กระเป๋าเงินผู้ขาย & รายงานการเงิน"})]}),(0,t.jsx)("p",{className:"text-xs text-gray-450 font-bold mt-1.5",children:ew?"Manage your earnings, withdraw funds to bank account, and track platform commissions":"จัดการรายรับร้านค้า ขอถอนเงินเข้าบัญชีธนาคาร และติดตามการหักค่าคอมมิชชั่น"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 bg-[#FAF8F5] border border-[#ECE7DF] px-3.5 py-1.5 rounded-xl self-start sm:self-auto",children:[(0,t.jsx)("span",{className:"text-xs font-bold text-gray-700",children:ew?"Platform Commission Rate:":"อัตราค่าคอมมิชชั่นแพลตฟอร์ม:"}),(0,t.jsxs)("span",{className:"bg-[#800A0A] text-white text-xs font-black px-2.5 py-0.5 rounded-lg shadow-xs",children:[er.effectiveRate,"%"]})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-amber-200/80 p-5 shadow-xs flex flex-col justify-between space-y-3 relative overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)("span",{className:"w-2.5 h-2.5 rounded-full bg-amber-400 animate-pulse"}),(0,t.jsx)("span",{className:"text-[11px] font-bold text-amber-800 uppercase tracking-wider",children:ew?"Pending Balance":"ยอดเงินรอตรวจสอบ / รอจัดส่ง"})]}),(0,t.jsx)("div",{className:"w-8 h-8 rounded-xl bg-amber-50 text-amber-600 flex items-center justify-center font-bold text-sm",children:"⏳"})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("span",{className:"text-3xl font-black text-gray-900 block",children:["฿",sE.pendingBalance.toLocaleString()]}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 block font-medium mt-1",children:ew?"Earnings from orders being processed or delivered":"รายรับจากออเดอร์ที่กำลังจัดส่ง (จะปลดล็อคเมื่อสินค้าส่งถึงลูกค้า)"})]})]}),(0,t.jsxs)("div",{className:"bg-gradient-to-br from-emerald-600 via-emerald-700 to-teal-800 text-white rounded-2xl p-5 shadow-md flex flex-col justify-between space-y-3 relative overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)("span",{className:"w-2.5 h-2.5 rounded-full bg-emerald-300"}),(0,t.jsx)("span",{className:"text-[11px] font-bold text-emerald-100 uppercase tracking-wider",children:ew?"Available for Withdrawal":"ยอดเงินที่ถอนได้ทันที"})]}),(0,t.jsx)("div",{className:"w-8 h-8 rounded-xl bg-white/15 text-white flex items-center justify-center font-bold text-sm",children:"💵"})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("span",{className:"text-3xl font-black text-white block",children:["฿",sE.availableBalance.toLocaleString()]}),(0,t.jsx)("span",{className:"text-[10px] text-emerald-100 block font-medium mt-1",children:ew?"Ready to be transferred to your bank account":"พร้อมโอนเข้าบัญชีธนาคารของคุณได้ทันที"})]}),(0,t.jsx)("div",{className:"pt-1",children:(0,t.jsxs)("button",{type:"button",onClick:()=>{sE.availableBalance<=0?s6(ew?"No available balance to withdraw":"ยังไม่มียอดเงินที่สามารถถอนได้ในขณะนี้","info"):(sX(sE.availableBalance),sR(!0))},className:"w-full bg-white hover:bg-emerald-50 text-emerald-850 font-black text-xs py-2.5 px-4 rounded-xl border-none cursor-pointer transition-all shadow-sm flex items-center justify-center space-x-2 active:scale-98",children:[(0,t.jsx)(M.Wallet,{className:"w-4 h-4 text-emerald-700"}),(0,t.jsx)("span",{children:ew?"Request Payout (Withdraw)":"ขอถอนเงิน (Withdraw Funds)"})]})})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-blue-200/80 p-5 shadow-xs flex flex-col justify-between space-y-3 relative overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)("span",{className:"w-2.5 h-2.5 rounded-full bg-blue-500"}),(0,t.jsx)("span",{className:"text-[11px] font-bold text-blue-800 uppercase tracking-wider",children:ew?"Total Paid / Withdrawn":"ยอดเงินที่ถอนสำเร็จแล้ว"})]}),(0,t.jsx)("div",{className:"w-8 h-8 rounded-xl bg-blue-50 text-blue-600 flex items-center justify-center font-bold text-sm",children:"🏦"})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("span",{className:"text-3xl font-black text-gray-900 block",children:["฿",sE.totalWithdrawn.toLocaleString()]}),(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 block font-medium mt-1",children:[ew?"Lifetime Net Revenue:":"รายรับสะสมทั้งหมด:"," ฿",sE.lifetimeEarnings.toLocaleString()]})]})]})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-6 shadow-xs space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"font-extrabold text-gray-900 text-sm sm:text-base flex items-center gap-2",children:[(0,t.jsx)(B.Landmark,{className:"w-4.5 h-4.5 text-[#800A0A]"}),(0,t.jsx)("span",{children:ew?"Payout Bank Account & PromptPay":"ข้อมูลบัญชีธนาคารและพร้อมเพย์สำหรับรับเงิน"})]}),(0,t.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:ew?"Admin will transfer payout funds to this bank account upon approval":"แอดมินจะโอนเงินจากการถอนเข้าสู่บัญชีธนาคารนี้หลังได้รับการอนุมัติ"})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>sq(!0),className:"bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold text-xs px-4 py-2 rounded-xl transition-all border-none cursor-pointer flex items-center gap-1.5 self-start sm:self-auto shadow-2xs",children:[(0,t.jsx)(g.Plus,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{children:ew?"Add / Edit Bank Account":"เพิ่ม / แก้ไขบัญชีธนาคาร"})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 pt-1",children:sM.length>0?sM.map(e=>(0,t.jsxs)("div",{className:"border border-gray-200 bg-gray-50/50 hover:bg-white rounded-2xl p-4 transition-all relative space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("span",{className:"font-extrabold text-xs text-gray-900 flex items-center gap-1.5",children:[(0,t.jsx)("span",{children:"🏦"}),(0,t.jsx)("span",{children:e.bankName})]}),e.isDefault&&(0,t.jsx)("span",{className:"text-[9px] font-black bg-emerald-100 text-emerald-800 px-2 py-0.5 rounded-full",children:"บัญชีหลัก"})]}),(0,t.jsxs)("div",{className:"text-xs text-gray-700 font-medium space-y-0.5",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-gray-400",children:"เลขที่บัญชี:"})," ",(0,t.jsx)("strong",{className:"text-gray-900 tracking-wide",children:e.accountNumber})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-gray-400",children:"ชื่อบัญชี:"})," ",e.accountName]}),e.promptPayNumber&&(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-gray-400",children:"พร้อมเพย์:"})," ",e.promptPayNumber]})]})]},e.id)):(0,t.jsx)("div",{className:"col-span-3 text-center py-6 text-xs text-gray-400 border border-dashed border-gray-200 rounded-2xl",children:'ยังไม่มีการผูกบัญชีธนาคาร กรุณากดปุ่ม "+ เพิ่ม / แก้ไขบัญชีธนาคาร" เพื่อระบุบัญชีรับเงิน'})})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-6 shadow-xs space-y-4",children:[(0,t.jsx)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2",children:(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"font-extrabold text-gray-900 text-sm sm:text-base flex items-center gap-2",children:[(0,t.jsx)("span",{children:"📋"}),(0,t.jsx)("span",{children:ew?"Payout Request History":"ประวัติการขอถอนเงินและสถานะการโอน"})]}),(0,t.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:ew?"Track your withdrawal status and view transfer slips":"ตรวจสอบสถานะคำขอถอนเงินและเปิดดูสลิปหลักฐานการโอนเงินจากแอดมิน"})]})}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-left text-xs border-collapse min-w-[700px]",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"bg-[#FAF8F5] text-gray-600 font-bold uppercase border-b border-gray-150",children:[(0,t.jsx)("th",{className:"py-3 px-4",children:"รหัสคำขอ"}),(0,t.jsx)("th",{className:"py-3 px-4",children:"วันที่ทำรายการ"}),(0,t.jsx)("th",{className:"py-3 px-4",children:"บัญชีปลายทาง"}),(0,t.jsx)("th",{className:"py-3 px-4 text-right",children:"ยอดที่ขอถอน"}),(0,t.jsx)("th",{className:"py-3 px-4 text-center",children:"ค่าธรรมเนียม"}),(0,t.jsx)("th",{className:"py-3 px-4 text-center",children:"สถานะ"}),(0,t.jsx)("th",{className:"py-3 px-4 text-center",children:"หลักฐาน / การดำเนินการ"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-gray-100 font-medium text-gray-800",children:sI.length>0?sI.map(e=>(0,t.jsxs)("tr",{className:"hover:bg-gray-50/50 transition-colors",children:[(0,t.jsxs)("td",{className:"py-3 px-4 font-black text-gray-900",children:["#",e.id]}),(0,t.jsx)("td",{className:"py-3 px-4 text-gray-500",children:new Date(e.requestedAt).toLocaleDateString("th-TH",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}),(0,t.jsxs)("td",{className:"py-3 px-4",children:[(0,t.jsx)("div",{className:"font-bold text-gray-900",children:e.bankAccount.bankName}),(0,t.jsxs)("div",{className:"text-[11px] text-gray-400",children:[e.bankAccount.accountNumber," (",e.bankAccount.accountName,")"]})]}),(0,t.jsxs)("td",{className:"py-3 px-4 text-right font-black text-emerald-600 text-sm",children:["฿",e.amount.toLocaleString()]}),(0,t.jsx)("td",{className:"py-3 px-4 text-center text-gray-400 font-bold",children:"ฟรี"}),(0,t.jsx)("td",{className:"py-3 px-4 text-center",children:"approved"===e.status?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[10px] font-black bg-emerald-50 text-emerald-700 border border-emerald-200",children:[(0,t.jsx)("span",{children:"✓"}),(0,t.jsx)("span",{children:"โอนเงินสำเร็จ"})]}):"rejected"===e.status?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[10px] font-black bg-red-50 text-red-700 border border-red-200",children:[(0,t.jsx)("span",{children:"✕"}),(0,t.jsx)("span",{children:"ถูกปฏิเสธ"})]}):(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[10px] font-black bg-amber-50 text-amber-700 border border-amber-200",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"}),(0,t.jsx)("span",{children:"รอตรวจสอบ"})]})}),(0,t.jsx)("td",{className:"py-3 px-4 text-center",children:"approved"===e.status&&e.slipUrl?(0,t.jsxs)("button",{type:"button",onClick:()=>sK(e.slipUrl||null),className:"inline-flex items-center gap-1 px-3 py-1 bg-white hover:bg-emerald-50 border border-emerald-300 text-emerald-700 font-bold rounded-lg text-[11px] cursor-pointer transition-all shadow-2xs",children:[(0,t.jsx)(I.FileText,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{children:"ดูสลิปโอนเงิน"})]}):"rejected"===e.status&&e.adminNote?(0,t.jsx)("button",{type:"button",onClick:()=>s6(`เหตุผลที่ปฏิเสธ: ${e.adminNote}`,"error"),className:"inline-flex items-center gap-1 px-2.5 py-1 bg-red-50 hover:bg-red-100 text-red-700 font-bold rounded-lg text-[11px] border border-red-200 cursor-pointer transition-all",children:(0,t.jsx)("span",{children:"เหตุผล"})}):(0,t.jsx)("span",{className:"text-gray-400 text-[11px]",children:"-"})})]},e.id)):(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:7,className:"py-8 text-center text-gray-400 bg-gray-50/40 rounded-b-xl",children:"ยังไม่มีประวัติการขอถอนเงิน เมื่อคุณส่งคำขอถอนเงิน รายการจะแสดงที่นี่"})})})]})})]}),eL.isTieredEnabled&&(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-6 shadow-xs space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-sm sm:text-base flex items-center gap-2",children:(0,t.jsx)("span",{children:"🎯 เกณฑ์ยอดขายขั้นบันไดสำหรับอัตราคอมมิชชั่น"})}),(0,t.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:er.isTier2?`ยอดขายสะสมของร้านค้าคุณเกินเกณฑ์ ฿${eL.tierThresholdAmount.toLocaleString()} แล้ว ระบบคิดค่าคอมมิชชั่นในอัตราขั้นที่สอง (${eL.tierRatePercent}%)`:`เมื่อมียอดขายสะสมเกิน ฿${eL.tierThresholdAmount.toLocaleString()} อัตราคอมมิชชั่นจะปรับเป็น ${eL.tierRatePercent}% ตามนโยบายส่วนกลาง`})]}),(0,t.jsxs)("span",{className:"text-xs font-black text-gray-900 self-start sm:self-auto",children:[er.progressPercent,"% สู่เกณฑ์ขั้นบันได"]})]}),(0,t.jsx)("div",{className:"w-full bg-gray-100 rounded-full h-3.5 overflow-hidden p-0.5 border border-gray-200",children:(0,t.jsx)("div",{className:`h-full rounded-full transition-all duration-500 ${er.isTier2?"bg-gradient-to-r from-amber-500 to-orange-500":"bg-gradient-to-r from-[#800A0A] to-[#B91C1C]"}`,style:{width:`${Math.min(100,Math.max(5,er.progressPercent))}%`}})}),(0,t.jsxs)("div",{className:"flex justify-between text-[11px] font-bold text-gray-500 pt-1",children:[(0,t.jsxs)("span",{children:["ยอดขายปัจจุบัน: ฿",es.toLocaleString()]}),er.isTier2?(0,t.jsxs)("span",{className:"text-amber-700 font-extrabold",children:["ทะลุเกณฑ์เป้าหมายแล้ว (+฿",(es-eL.tierThresholdAmount).toLocaleString(),")"]}):(0,t.jsxs)("span",{className:"text-gray-600",children:["ขาดอีก ฿",er.amountToThreshold.toLocaleString()," จะถึงเกณฑ์ ฿",eL.tierThresholdAmount.toLocaleString()]})]})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-6 shadow-xs space-y-4",children:[(0,t.jsx)("div",{className:"flex justify-between items-center pb-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-sm sm:text-base",children:ew?"Order Commission Itemized Breakdown":"รายละเอียดการหักค่าคอมมิชชั่นแยกรายคำสั่งซื้อ"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:ew?"View fee calculations and payout for each customer order":"ตรวจสอบยอดหักค่าคอมมิชชั่นและรายรับสุทธิที่ได้รับในแต่ละคำสั่งซื้อ"})]})}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-left text-xs border-collapse min-w-[750px]",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"bg-[#FAF8F5] text-gray-600 font-bold uppercase border-b border-gray-150",children:[(0,t.jsx)("th",{className:"py-3 px-4",children:"เลขคำสั่งซื้อ"}),(0,t.jsx)("th",{className:"py-3 px-4",children:"ลูกค้า"}),(0,t.jsx)("th",{className:"py-3 px-4 text-right",children:"ยอดรวมคำสั่งซื้อ"}),(0,t.jsx)("th",{className:"py-3 px-4 text-center",children:"อัตราหัก (%)"}),(0,t.jsx)("th",{className:"py-3 px-4 text-right",children:"หักค่าคอมมิชชั่น"}),(0,t.jsx)("th",{className:"py-3 px-4 text-right",children:"รายรับสุทธิร้านค้า"}),(0,t.jsx)("th",{className:"py-3 px-4 text-center",children:"สถานะ"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-gray-100 font-medium text-gray-800",children:eC.length>0?eC.map(e=>{let s=Math.round(e.totalAmount*er.effectiveRate/100),r=e.totalAmount-s;return(0,t.jsxs)("tr",{className:"hover:bg-gray-50/50 transition-colors",children:[(0,t.jsxs)("td",{className:"py-3 px-4 font-bold text-gray-950",children:["#",e.id]}),(0,t.jsx)("td",{className:"py-3 px-4",children:e.shippingAddress?.fullName||"ลูกค้าทั่วไป"}),(0,t.jsxs)("td",{className:"py-3 px-4 text-right font-black text-gray-900",children:["฿",e.totalAmount.toLocaleString()]}),(0,t.jsxs)("td",{className:"py-3 px-4 text-center font-bold text-gray-600",children:[er.effectiveRate,"%"]}),(0,t.jsxs)("td",{className:"py-3 px-4 text-right font-bold text-red-650",children:["-฿",s.toLocaleString()]}),(0,t.jsxs)("td",{className:"py-3 px-4 text-right font-black text-emerald-600",children:["฿",r.toLocaleString()]}),(0,t.jsx)("td",{className:"py-3 px-4 text-center",children:(0,t.jsx)("span",{className:`inline-block px-2.5 py-0.5 rounded-full text-[10px] font-bold border ${"delivered"===e.status?"bg-emerald-50 text-emerald-700 border-emerald-200":"bg-amber-50 text-amber-700 border-amber-200"}`,children:"delivered"===e.status?"ส่งมอบแล้ว (พร้อมถอน)":"รอดำเนินการ (Pending)"})})]},e.id)}):(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:7,className:"py-12 text-center text-gray-400 font-light bg-gray-50/30 rounded-b-xl",children:(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center space-y-1.5",children:[(0,t.jsx)("span",{className:"text-2xl",children:"📦"}),(0,t.jsx)("span",{className:"font-bold text-gray-700 text-xs",children:"ยังไม่มีคำสั่งซื้อสำหรับร้านค้านี้"}),(0,t.jsx)("span",{className:"text-[11px] text-gray-400",children:"เมื่อมีลูกค้าสั่งซื้อสินค้าของร้าน รายการและยอดหักค่าคอมมิชชั่นจะแสดงที่นี่"})]})})})})]})})]})]}))}),sz&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs font-prompt animate-in fade-in duration-200",children:(0,t.jsxs)("div",{className:"bg-white rounded-3xl border border-gray-150 shadow-2xl max-w-lg w-full overflow-hidden flex flex-col",children:[(0,t.jsxs)("div",{className:"px-6 py-4.5 border-b border-gray-150 flex items-center justify-between bg-white",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2.5",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-xl bg-emerald-50 text-emerald-700 flex items-center justify-center",children:(0,t.jsx)(M.Wallet,{className:"w-4 h-4"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"font-extrabold text-base text-gray-900",children:ew?"Request Funds Withdrawal":"ขอถอนเงินเข้าบัญชีธนาคาร"}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 font-semibold leading-none mt-0.5",children:ew?"Withdraw your available balance to registered bank account":"ถอนยอดเงินพร้อมถอนเข้าสู่บัญชีธนาคารที่คุณลงทะเบียนไว้"})]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>sR(!1),className:"p-1.5 text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded-xl transition-colors border-none bg-transparent cursor-pointer",children:(0,t.jsx)(N.X,{className:"w-4 h-4"})})]}),(0,t.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),!el)return;if(sJ<=0)return void s6(ew?"Please enter a valid amount":"กรุณาระบุจำนวนเงินที่ต้องการถอนให้ถูกต้อง","error");if(sJ>sE.availableBalance)return void s6(ew?"Withdrawal amount exceeds available balance":"ยอดเงินที่ขอถอนเกินยอดเงินที่ถอนได้ในกระเป๋า","error");let t=sM.find(e=>e.id===sG)||sM[0];t?(q.default.createPayoutRequest(el.email,eF||el.fullName,sJ,t),s4(el.email),sR(!1),sX(0),s6(ew?"Payout request submitted successfully":"ส่งคำขอถอนเงินไปยังแอดมินเรียบร้อยแล้ว","success")):s6(ew?"Please add a bank account first":"กรุณาเพิ่มข้อมูลบัญชีธนาคารสำหรับรับเงินก่อน","error")},className:"p-6 space-y-4 text-left",children:[(0,t.jsxs)("div",{className:"bg-emerald-50/70 border border-emerald-200 rounded-2xl p-4 flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-emerald-800 uppercase tracking-wider block",children:"ยอดเงินที่ถอนได้ในปัจจุบัน"}),(0,t.jsxs)("span",{className:"text-2xl font-black text-emerald-700 block mt-0.5",children:["฿",sE.availableBalance.toLocaleString()]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>sX(sE.availableBalance),className:"px-3 py-1.5 bg-emerald-600 hover:bg-emerald-700 text-white font-bold text-xs rounded-xl border-none cursor-pointer shadow-2xs transition-all",children:"ถอนทั้งหมด"})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("label",{className:"text-xs font-bold text-gray-700 block",children:["จำนวนเงินที่ต้องการถอน (บาท) ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("span",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-gray-400 font-bold text-sm",children:"฿"}),(0,t.jsx)("input",{type:"number",required:!0,min:"1",max:sE.availableBalance,value:sJ||"",onChange:e=>sX(Number(e.target.value)),placeholder:"ระบุจำนวนเงิน เช่น 1000",className:"w-full pl-9 pr-4 py-2.5 bg-white border border-gray-300 focus:border-emerald-600 focus:ring-1 focus:ring-emerald-600 rounded-xl text-sm font-bold text-gray-900 focus:outline-none transition-all"})]})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("label",{className:"text-xs font-bold text-gray-700 block",children:["เลือกบัญชีธนาคารปลายทาง ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),sM.length>0?(0,t.jsx)("select",{value:sG,onChange:e=>sH(e.target.value),className:"w-full px-3.5 py-2.5 bg-white border border-gray-300 rounded-xl text-xs font-bold text-gray-800 focus:outline-none focus:border-emerald-600",children:sM.map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.bankName," - ",e.accountNumber," (",e.accountName,")"]},e.id))}):(0,t.jsx)("div",{className:"text-xs text-amber-700 bg-amber-50 p-3 rounded-xl border border-amber-200",children:"ยังไม่มีบัญชีธนาคาร กรุณากดเพิ่มบัญชีธนาคารก่อนทำรายการ"})]}),(0,t.jsxs)("div",{className:"bg-gray-50 border border-gray-200 rounded-xl p-3 text-xs space-y-1 text-gray-600",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{children:"ยอดถอน:"}),(0,t.jsxs)("strong",{children:["฿",sJ.toLocaleString()]})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{children:"ค่าธรรมเนียมการถอน:"}),(0,t.jsx)("strong",{className:"text-emerald-600",children:"ฟรี (฿0)"})]}),(0,t.jsxs)("div",{className:"flex justify-between border-t border-gray-200 pt-1 text-gray-900 font-black",children:[(0,t.jsx)("span",{children:"ยอดเงินที่ได้รับเข้าบัญชี:"}),(0,t.jsxs)("strong",{className:"text-emerald-700",children:["฿",sJ.toLocaleString()]})]})]}),(0,t.jsxs)("div",{className:"pt-3 border-t border-gray-150 flex items-center justify-end space-x-3",children:[(0,t.jsx)("button",{type:"button",onClick:()=>sR(!1),className:"px-5 py-2.5 rounded-xl border border-gray-250 text-xs font-bold text-gray-600 hover:bg-gray-50 transition-colors cursor-pointer bg-white",children:ew?"Cancel":"ยกเลิก"}),(0,t.jsxs)("button",{type:"submit",disabled:0===sM.length||sJ<=0,className:"px-6 py-2.5 rounded-xl bg-emerald-600 hover:bg-emerald-700 disabled:opacity-50 text-white text-xs font-bold transition-all shadow-sm active:scale-98 cursor-pointer border-none flex items-center space-x-2",children:[(0,t.jsx)(j.Check,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:ew?"Confirm Withdrawal":"ยืนยันส่งคำขอถอนเงิน"})]})]})]})]})}),sW&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs font-prompt animate-in fade-in duration-200",children:(0,t.jsxs)("div",{className:"bg-white rounded-3xl border border-gray-150 shadow-2xl max-w-lg w-full overflow-hidden flex flex-col",children:[(0,t.jsxs)("div",{className:"px-6 py-4.5 border-b border-gray-150 flex items-center justify-between bg-white",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2.5",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-xl bg-red-50 text-[#800A0A] flex items-center justify-center",children:(0,t.jsx)(B.Landmark,{className:"w-4 h-4"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"font-extrabold text-base text-gray-900",children:ew?"Add Bank Account / PromptPay":"เพิ่ม / แก้ไขบัญชีธนาคารรับเงิน"}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 font-semibold leading-none mt-0.5",children:ew?"Set up receiving bank account for store payout settlements":"ระบุข้อมูลธนาคารเพื่อรับเงินจากการขายสินค้า"})]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>sq(!1),className:"p-1.5 text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded-xl transition-colors border-none bg-transparent cursor-pointer",children:(0,t.jsx)(N.X,{className:"w-4 h-4"})})]}),(0,t.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),el){if(!sY.trim()||!s0.trim())return void s6(ew?"Please fill in bank account number and name":"กรุณากรอกเลขที่บัญชีและชื่อบัญชีให้ครบถ้วน","error");q.default.saveBankAccount(el.email,{bankName:sV,bankCode:sV.includes("KBANK")?"kbank":sV.includes("SCB")?"scb":sV.includes("KTB")?"ktb":"bbl",accountNumber:sY.trim(),accountName:s0.trim(),promptPayNumber:s5.trim()||void 0,isDefault:0===sM.length}),s4(el.email),sq(!1),sQ(""),s1(""),s2(""),s6(ew?"Bank account saved successfully":"บันทึกข้อมูลบัญชีธนาคารสำเร็จ","success")}},className:"p-6 space-y-4 text-left",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("label",{className:"text-xs font-bold text-gray-700 block",children:["ธนาคารผู้ให้บริการ ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsxs)("select",{value:sV,onChange:e=>sZ(e.target.value),className:"w-full px-3.5 py-2.5 bg-white border border-gray-300 rounded-xl text-xs font-bold text-gray-800 focus:outline-none focus:border-[#800A0A]",children:[(0,t.jsx)("option",{value:"ธนาคารกสิกรไทย (KBANK)",children:"ธนาคารกสิกรไทย (KBANK)"}),(0,t.jsx)("option",{value:"ธนาคารไทยพาณิชย์ (SCB)",children:"ธนาคารไทยพาณิชย์ (SCB)"}),(0,t.jsx)("option",{value:"ธนาคารกรุงไทย (KTB)",children:"ธนาคารกรุงไทย (KTB)"}),(0,t.jsx)("option",{value:"ธนาคารกรุงเทพ (BBL)",children:"ธนาคารกรุงเทพ (BBL)"}),(0,t.jsx)("option",{value:"ธนาคารทหารไทยธนชาต (TTB)",children:"ธนาคารทหารไทยธนชาต (TTB)"}),(0,t.jsx)("option",{value:"ธนาคารออมสิน (GSB)",children:"ธนาคารออมสิน (GSB)"}),(0,t.jsx)("option",{value:"ธนาคารกรุงศรีอยุธยา (BAY)",children:"ธนาคารกรุงศรีอยุธยา (BAY)"}),(0,t.jsx)("option",{value:"พร้อมเพย์ (PromptPay)",children:"พร้อมเพย์ (PromptPay)"})]})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("label",{className:"text-xs font-bold text-gray-700 block",children:["เลขที่บัญชีธนาคาร ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsx)("input",{type:"text",required:!0,value:sY,onChange:e=>sQ(e.target.value),placeholder:"เช่น 123-4-56789-0",className:"w-full px-3.5 py-2.5 bg-white border border-gray-300 focus:border-[#800A0A] focus:ring-1 focus:ring-[#800A0A] rounded-xl text-xs font-medium text-gray-900 focus:outline-none"})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("label",{className:"text-xs font-bold text-gray-700 block",children:["ชื่อบัญชี (ตรงกับสมุดบัญชี) ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsx)("input",{type:"text",required:!0,value:s0,onChange:e=>s1(e.target.value),placeholder:"เช่น นายอาทิตย์ ลุงกอ หรือ ร้านค้า CMTC",className:"w-full px-3.5 py-2.5 bg-white border border-gray-300 focus:border-[#800A0A] focus:ring-1 focus:ring-[#800A0A] rounded-xl text-xs font-medium text-gray-900 focus:outline-none"})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-xs font-bold text-gray-700 block",children:"เบอร์พร้อมเพย์ / เลขบัตรประชาชน (ไม่บังคับ)"}),(0,t.jsx)("input",{type:"text",value:s5,onChange:e=>s2(e.target.value),placeholder:"เช่น 0812345678",className:"w-full px-3.5 py-2.5 bg-white border border-gray-300 focus:border-[#800A0A] focus:ring-1 focus:ring-[#800A0A] rounded-xl text-xs font-medium text-gray-900 focus:outline-none"})]}),(0,t.jsxs)("div",{className:"pt-3 border-t border-gray-150 flex items-center justify-end space-x-3",children:[(0,t.jsx)("button",{type:"button",onClick:()=>sq(!1),className:"px-5 py-2.5 rounded-xl border border-gray-250 text-xs font-bold text-gray-600 hover:bg-gray-50 transition-colors cursor-pointer bg-white",children:ew?"Cancel":"ยกเลิก"}),(0,t.jsxs)("button",{type:"submit",className:"px-6 py-2.5 rounded-xl bg-[#800A0A] hover:bg-[#991B1B] text-white text-xs font-bold transition-all shadow-sm active:scale-98 cursor-pointer border-none flex items-center space-x-2",children:[(0,t.jsx)(j.Check,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:ew?"Save Bank Account":"บันทึกข้อมูลบัญชี"})]})]})]})]})}),sU&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/70 backdrop-blur-xs font-prompt animate-in fade-in duration-200",children:(0,t.jsxs)("div",{className:"bg-white rounded-3xl border border-gray-150 shadow-2xl max-w-md w-full overflow-hidden flex flex-col",children:[(0,t.jsxs)("div",{className:"px-6 py-4 border-b border-gray-150 flex items-center justify-between bg-white",children:[(0,t.jsxs)("h3",{className:"font-extrabold text-base text-gray-900 flex items-center gap-2",children:[(0,t.jsx)(I.FileText,{className:"w-4 h-4 text-emerald-600"}),(0,t.jsx)("span",{children:"หลักฐานการโอนเงิน (Transfer Slip)"})]}),(0,t.jsx)("button",{type:"button",onClick:()=>sK(null),className:"p-1.5 text-gray-400 hover:text-gray-700 rounded-xl border-none bg-transparent cursor-pointer",children:(0,t.jsx)(N.X,{className:"w-4 h-4"})})]}),(0,t.jsxs)("div",{className:"p-6 flex flex-col items-center justify-center bg-gray-50/50 space-y-3",children:[(0,t.jsx)("div",{className:"max-h-[60vh] overflow-auto rounded-2xl border border-gray-200 bg-white p-2 shadow-xs",children:(0,t.jsx)("img",{src:sU,alt:"Transfer Slip",className:"w-full h-auto object-contain rounded-xl"})}),(0,t.jsx)("button",{type:"button",onClick:()=>sK(null),className:"w-full py-2.5 bg-gray-900 text-white font-bold text-xs rounded-xl border-none cursor-pointer hover:bg-black transition-colors",children:"ปิดหน้าต่าง"})]})]})}),te&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs font-prompt animate-in fade-in duration-200",children:(0,t.jsxs)("div",{className:"bg-white rounded-3xl border border-gray-150 shadow-2xl max-w-2xl w-full overflow-hidden flex flex-col max-h-[92vh]",children:[(0,t.jsxs)("div",{className:"px-6 py-4.5 border-b border-gray-150 flex items-center justify-between bg-white sticky top-0 z-10",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2.5",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-xl bg-red-50 text-[#800A0A] flex items-center justify-center",children:(0,t.jsx)(_.Ticket,{className:"w-4 h-4"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"font-extrabold text-base text-gray-900",children:ew?"Create Store Promotion Coupon":"สร้างคูปองโปรโมชันร้านค้า"}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 font-semibold leading-none mt-0.5",children:ew?"Choose coupon type, discount rate and minimum spend condition":"เลือกประเภทคูปอง มูลค่า และเงื่อนไขยอดซื้อขั้นต่ำ"})]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>tt(!1),className:"p-1.5 text-gray-400 hover:text-gray-700 hover:bg-gray-100 rounded-xl transition-colors border-none bg-transparent cursor-pointer",children:(0,t.jsx)(N.X,{className:"w-4 h-4"})})]}),(0,t.jsxs)("form",{onSubmit:e=>{e.preventDefault();let t=eV.toUpperCase().trim();if(!t)return void s6("กรุณากรอกรหัสคูปอง","error");if("discount"===eJ&&(!e0||e0<=0))return void s6("กรุณาระบุมูลค่าส่วนลดที่มากกว่า 0","error");if(eI.some(e=>e.code.toUpperCase()===t))return void s6("รหัสคูปองนี้มีอยู่ในร้านค้าแล้ว โปรดใช้รหัสอื่น","error");let s=[{id:`coupon_${Date.now()}`,code:t,title:eY.trim()||("free_shipping"===eJ?e5>0?`คูปองส่งฟรีเมื่อช้อปครบ ฿${e5.toLocaleString()}`:"คูปองส่งฟรีไม่มีขั้นต่ำ":"percent"===eG?`ส่วนลด ${e0}% ${e5>0?`(ขั้นต่ำ ฿${e5.toLocaleString()})`:""}`:`ส่วนลด ฿${e0.toLocaleString()} ${e5>0?`(ขั้นต่ำ ฿${e5.toLocaleString()})`:""}`),description:eY.trim(),type:eJ,discountType:"free_shipping"===eJ?"free_shipping":eG,discountValue:"free_shipping"===eJ?0:Number(e0),discount:"free_shipping"===eJ?0:Number(e0),minSpend:Number(e5)||0,minPurchase:Number(e5)||0,maxDiscount:"percent"===eG&&Number(e4)||0,usageLimit:Number(e8)||0,usedCount:0,isActive:!0,expiryDate:e9||"",merchantEmail:el?.email,storeName:eF,createdAt:new Date().toISOString()},...eI];eO(s),rn(eM,s),eZ(""),eQ(""),e1(10),e2(0),e3(0),e6(100),e7(""),tt(!1),s6(`สร้างคูปอง "${t}" สำเร็จแล้ว!`,"success")},className:"p-6 overflow-y-auto space-y-5 text-left",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("label",{className:"text-[11px] font-extrabold text-gray-700 uppercase tracking-wide block",children:["1. ",ew?"Select Coupon Type":"เลือกประเภทคูปอง"," ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{eX("free_shipping"),(!eV||eV.startsWith("DISC")||eV.startsWith("SAVE"))&&eZ(`FREE${Math.floor(100+900*Math.random())}`)},className:`p-4 rounded-2xl border text-left transition-all cursor-pointer space-y-1.5 flex flex-col justify-between ${"free_shipping"===eJ?"bg-emerald-50/50 border-emerald-500 ring-2 ring-emerald-500/20 shadow-xs":"bg-white border-gray-200 hover:border-gray-300"}`,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between w-full",children:[(0,t.jsx)("span",{className:"text-xl",children:"🚚"}),(0,t.jsx)("span",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${"free_shipping"===eJ?"border-emerald-600 bg-emerald-600 text-white":"border-gray-300"}`,children:"free_shipping"===eJ&&(0,t.jsx)(j.Check,{className:"w-2.5 h-2.5 text-white"})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-extrabold text-xs text-gray-900 block",children:ew?"Free Shipping Coupon":"คูปองส่งฟรี (Free Shipping)"}),(0,t.jsx)("p",{className:"text-[10px] text-gray-500 leading-relaxed mt-0.5",children:ew?"Free delivery when minimum spend requirement is met":"ยกเว้นค่าจัดส่งเมื่อยอดซื้อสินค้าในร้านถึงเกณฑ์ที่กำหนด"})]})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>{eX("discount"),(!eV||eV.startsWith("FREE"))&&eZ(`DISC${e0||10}-${Math.floor(100+900*Math.random())}`)},className:`p-4 rounded-2xl border text-left transition-all cursor-pointer space-y-1.5 flex flex-col justify-between ${"discount"===eJ?"bg-amber-50/50 border-amber-500 ring-2 ring-amber-500/20 shadow-xs":"bg-white border-gray-200 hover:border-gray-300"}`,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between w-full",children:[(0,t.jsx)("span",{className:"text-xl",children:"🏷️"}),(0,t.jsx)("span",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${"discount"===eJ?"border-amber-600 bg-amber-600 text-white":"border-gray-300"}`,children:"discount"===eJ&&(0,t.jsx)(j.Check,{className:"w-2.5 h-2.5 text-white"})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-extrabold text-xs text-gray-900 block",children:ew?"Product Discount":"คูปองส่วนลดสินค้า (Discount)"}),(0,t.jsx)("p",{className:"text-[10px] text-gray-500 leading-relaxed mt-0.5",children:ew?"Choose percentage (%) or fixed amount (฿) discount":"ลดเป็นเปอร์เซ็นต์ (%) หรือเป็นจำนวนเงินบาท (฿)"})]})]})]})]}),"discount"===eJ&&(0,t.jsxs)("div",{className:"bg-gray-50 p-4 rounded-2xl border border-gray-200/80 space-y-3 animate-in fade-in duration-150",children:[(0,t.jsx)("label",{className:"text-[11px] font-extrabold text-gray-700 block",children:ew?"Choose Discount Format:":"เลือกรูปแบบส่วนลด:"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>eH("percent"),className:`py-2 px-3 rounded-xl text-xs font-bold transition-all border cursor-pointer flex items-center justify-center space-x-2 ${"percent"===eG?"bg-amber-600 text-white border-amber-600 shadow-xs":"bg-white text-gray-700 border-gray-200 hover:bg-gray-100"}`,children:[(0,t.jsx)(D,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{children:ew?"Percentage (%)":"ส่วนลดเปอร์เซ็นต์ (%)"})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>eH("amount"),className:`py-2 px-3 rounded-xl text-xs font-bold transition-all border cursor-pointer flex items-center justify-center space-x-2 ${"amount"===eG?"bg-amber-600 text-white border-amber-600 shadow-xs":"bg-white text-gray-700 border-gray-200 hover:bg-gray-100"}`,children:[(0,t.jsx)("span",{className:"font-mono font-black",children:"฿"}),(0,t.jsx)("span",{children:ew?"Fixed Amount (฿)":"ส่วนลดจำนวนเงิน (บาท ฿)"})]})]})]}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("label",{className:"text-[11px] font-extrabold text-gray-700 uppercase tracking-wide block",children:["2. ",ew?"Coupon Code & Conditions":"กำหนดรหัสและเงื่อนไข"," ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsxs)("label",{className:"text-xs font-bold text-gray-700",children:[ew?"Coupon Code":"รหัสคูปอง (ตัวพิมพ์ใหญ่และตัวเลข)"," ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>{let e="free_shipping"===eJ?"FREE":"percent"===eG?`DISC${e0||10}`:`SAVE${e0||50}`,t=Math.floor(100+900*Math.random());eZ(`${e}${t}`)},className:"text-[10.5px] font-bold text-[#800A0A] hover:underline flex items-center space-x-1 bg-transparent border-none cursor-pointer",children:[(0,t.jsx)(T.Sparkles,{className:"w-3 h-3 text-amber-500"}),(0,t.jsx)("span",{children:ew?"Auto Generate":"สุ่มรหัสอัตโนมัติ"})]})]}),(0,t.jsx)("input",{type:"text",required:!0,value:eV,onChange:e=>eZ(e.target.value.toUpperCase()),placeholder:"free_shipping"===eJ?"เช่น FREESHIP300":"percent"===eG?"เช่น CMTC15":"เช่น SAVE50",className:"w-full bg-white border border-gray-200 rounded-xl px-3.5 py-2.5 text-xs font-mono font-bold focus:outline-none focus:ring-1 focus:ring-[#800A0A] h-10 tracking-wider uppercase"})]}),"discount"===eJ&&(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("label",{className:"text-xs font-bold text-gray-700",children:["percent"===eG?ew?"Discount Rate (%)":"ส่วนลด (%)":ew?"Discount Amount (฿)":"มูลค่าส่วนลด (บาท ฿)"," ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"number",required:!0,min:"1",max:"percent"===eG?"100":"100000",value:e0||"",onChange:e=>e1(Number(e.target.value)),placeholder:"percent"===eG?"เช่น 10 (สำหรับลด 10%)":"เช่น 50 (สำหรับลด 50 บาท)",className:"w-full bg-white border border-gray-200 rounded-xl px-3.5 py-2.5 text-xs font-bold focus:outline-none focus:ring-1 focus:ring-[#800A0A] h-10"}),(0,t.jsx)("span",{className:"absolute right-3.5 top-2.5 text-xs font-bold text-gray-400",children:"percent"===eG?"%":"บาท"})]})]}),"percent"===eG&&(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-xs font-bold text-gray-700",children:ew?"Max Discount Limit (฿)":"จำกัดส่วนลดสูงสุด (บาท ฿)"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"number",min:"0",value:e4||"",onChange:e=>e3(Number(e.target.value)),placeholder:"เช่น 200 (เว้นว่างหากไม่จำกัด)",className:"w-full bg-white border border-gray-200 rounded-xl px-3.5 py-2.5 text-xs font-bold focus:outline-none focus:ring-1 focus:ring-[#800A0A] h-10"}),(0,t.jsx)("span",{className:"absolute right-3.5 top-2.5 text-xs font-bold text-gray-400",children:"บาท"})]})]})]}),(0,t.jsxs)("div",{className:"space-y-1.5 bg-red-50/30 p-3.5 rounded-2xl border border-red-100",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsxs)("label",{className:"text-xs font-extrabold text-gray-900",children:[ew?"Minimum Purchase Requirement (฿)":"เงื่อนไขยอดสั่งซื้อขั้นต่ำ (ต้องซื้อเท่านี้จึงจะใช้ได้)"," ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsx)("span",{className:"text-[10px] text-gray-500 font-medium",children:"ใส่ 0 หากไม่มีขั้นต่ำ"})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"number",min:"0",value:e5,onChange:e=>e2(Number(e.target.value)),placeholder:"เช่น 300 (ต้องซื้อครบ 300 บาทขึ้นไป)",className:"w-full bg-white border border-gray-200 rounded-xl px-3.5 py-2.5 text-xs font-bold focus:outline-none focus:ring-1 focus:ring-[#800A0A] h-10"}),(0,t.jsx)("span",{className:"absolute right-3.5 top-2.5 text-xs font-bold text-gray-400",children:"บาท"})]}),(0,t.jsxs)("p",{className:"text-[10.5px] text-gray-500 font-medium leading-relaxed",children:["💡 ",e5>0?`ลูกค้าต้องมียอดซื้อสินค้าจากร้านของคุณอย่างน้อย ฿${e5.toLocaleString()} จึงจะสามารถนำคูปองนี้ไปใช้สิทธิ์ได้`:"ลูกค้าสามารถใช้คูปองนี้ได้ทันทีโดยไม่มียอดสั่งซื้อขั้นต่ำ"]})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-xs font-bold text-gray-700",children:ew?"Coupon Title / Description":"ชื่อหรือคำอธิบายคูปอง (ตัวเลือก)"}),(0,t.jsx)("input",{type:"text",value:eY,onChange:e=>eQ(e.target.value),placeholder:"free_shipping"===eJ?"เช่น คูปองส่งฟรี ต้อนรับนักศึกษาใหม่":"เช่น ส่วนลดพิเศษ 10% สำหรับทุกสินค้า",className:"w-full bg-white border border-gray-200 rounded-xl px-3.5 py-2.5 text-xs font-medium focus:outline-none focus:ring-1 focus:ring-[#800A0A] h-10"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-xs font-bold text-gray-700",children:ew?"Usage Quota (Number of times)":"จำนวนสิทธิ์การใช้งาน"}),(0,t.jsx)("input",{type:"number",min:"0",value:e8||"",onChange:e=>e6(Number(e.target.value)),placeholder:"เช่น 100 (ใส่ 0 หากไม่จำกัด)",className:"w-full bg-white border border-gray-200 rounded-xl px-3.5 py-2.5 text-xs font-bold focus:outline-none focus:ring-1 focus:ring-[#800A0A] h-10"})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-xs font-bold text-gray-700",children:ew?"Expiration Date":"วันหมดอายุคูปอง"}),(0,t.jsx)("input",{type:"date",value:e9,onChange:e=>e7(e.target.value),className:"w-full bg-white border border-gray-200 rounded-xl px-3.5 py-2.5 text-xs font-medium focus:outline-none focus:ring-1 focus:ring-[#800A0A] h-10"})]})]})]}),(0,t.jsxs)("div",{className:"space-y-2 pt-2 border-t border-gray-100",children:[(0,t.jsx)("span",{className:"text-[10px] font-extrabold text-gray-400 uppercase tracking-wider block",children:ew?"Live Customer Ticket Preview":"พรีวิวบัตรคูปองที่ลูกค้าจะเห็น (Live Preview)"}),(0,t.jsxs)("div",{className:"p-4 rounded-2xl bg-gradient-to-r from-gray-900 to-gray-800 text-white shadow-md relative overflow-hidden flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1 z-10 text-left",children:[(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsx)("span",{className:"text-sm font-black text-amber-400",children:"free_shipping"===eJ?"🚚 ส่งฟรี (Free Shipping)":"percent"===eG?`🏷️ ลด ${e0||10}%`:`💵 ลด ฿${(e0||50).toLocaleString()}`})}),(0,t.jsx)("div",{className:"text-xs font-bold text-white",children:eY||("free_shipping"===eJ?"คูปองส่งฟรีพิเศษเฉพาะร้าน":"คูปองส่วนลดพิเศษเฉพาะร้าน")}),(0,t.jsxs)("div",{className:"text-[10.5px] text-gray-300 font-mono",children:[e5>0?`🛒 ช้อปขั้นต่ำ ฿${e5.toLocaleString()}`:"🛒 ไม่มีขั้นต่ำ","discount"===eJ&&"percent"===eG&&e4>0?` \xb7 ลดสูงสุด ฿${e4.toLocaleString()}`:""]})]}),(0,t.jsxs)("div",{className:"border-l border-dashed border-gray-600 pl-4 text-center z-10 flex flex-col items-center",children:[(0,t.jsx)("span",{className:"text-[9px] text-gray-400 font-bold uppercase",children:"CODE"}),(0,t.jsx)("span",{className:"text-xs font-mono font-black text-amber-300 bg-white/10 px-2 py-1 rounded-md border border-white/20 mt-0.5",children:eV||"PROMO123"})]})]})]}),(0,t.jsxs)("div",{className:"pt-4 border-t border-gray-150 flex items-center justify-end space-x-3",children:[(0,t.jsx)("button",{type:"button",onClick:()=>tt(!1),className:"px-5 py-2.5 rounded-xl border border-gray-250 text-xs font-bold text-gray-600 hover:bg-gray-50 transition-colors cursor-pointer bg-white",children:ew?"Cancel":"ยกเลิก"}),(0,t.jsxs)("button",{type:"submit",className:"px-6 py-2.5 rounded-xl bg-[#800A0A] hover:bg-[#991B1B] text-white text-xs font-bold transition-all shadow-sm active:scale-98 cursor-pointer border-none flex items-center space-x-2",children:[(0,t.jsx)(j.Check,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:ew?"Create & Activate Coupon":"ยืนยันการสร้างคูปอง"})]})]})]})]})})]})]})]})}],56430)}]);
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.25 |
proxy
|
phpinfo
|
Settings