PageSourceSearch

https://thietbibangviet.com/assets/TenantModule-DhBQI7EP.js

js thietbibangviet.com collected 2026-10-09 01:11:41 UTC 77,238 bytes, 3 lines download raw bytes

1var je=Object.defineProperty,_e=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var ge=Object.getOwnPropertySymbols;var ke=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable;var fe=(n,g,l)=>g in n?je(n,g,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[g]=l,r=(n,g)=>{for(var l in g||(g={}))ke.call(g,l)&&fe(n,l,g[l]);if(ge)for(var l of ge(g))Se.call(g,l)&&fe(n,l,g[l]);return n},h=(n,g)=>_e(n,ve(g));import{r as m,j as e}from"./react-vendor-BfWn7mO-.js";import{N as we}from"./NumberInput-Dpx7XXYg.js";import{g as Z,a as R,P as me}from"./index-CuUAF55y.js";import"./i18n-vi-C8tq8Mhp.js";import"./vendor-B_rZVQz_.js";const E="",Y=[{value:"free",label:"Miễn phí",color:"#64748b",bg:"#f1f5f9"},{value:"pro",label:"Pro",color:"#1B3A57",bg:"#D6E0EA"},{value:"enterprise",label:"Enterprise",color:"#ea580c",bg:"#ffedd5"},{value:"trial",label:"Trial",color:"#94a3b8",bg:"#f1f5f9",legacy:!0},{value:"basic",label:"Basic",color:"#1B3A57",bg:"#D6E0EA",legacy:!0},{value:"starter",label:"Starter",color:"#0891b2",bg:"#cffafe",legacy:!0},{value:"business",label:"Business",color:"#1B3A57",bg:"#D6E0EA",legacy:!0},{value:"professional",label:"Professional",color:"#1B3A57",bg:"#F0F4F8",legacy:!0},{value:"custom",label:"Custom",color:"#16a34a",bg:"#dcfce7",legacy:!0}],te=Y.filter(n=>!n.legacy),xe=[{value:"active",labelKey:"tnt_status_active",color:"#16a34a",bg:"#dcfce7"},{value:"inactive",labelKey:"tnt_status_inactive",color:"#ef4444",bg:"#fee2e2"}],he=[{value:"retail",label:"🛒 Bán lẻ & TMĐT"},{value:"fnb",label:"🍜 F&B"},{value:"services",label:"💼 Dịch vụ B2B"},{value:"manufacturing",label:"🏭 Sản xuất"},{value:"education",label:"🎓 Giáo dục & Đào tạo"},{value:"realestate",label:"🏢 Bất động sản"},{value:"spa",label:"💆 Spa & Làm đẹp"},{value:"travel",label:"✈️ Du lịch"},{value:"trading",label:"🏪 Thương mại tổng hợp"},{value:"other",label:"⚙️ Khác"}],be=[{key:"dashboard",name:"Dashboard",icon:"📊",premium:!1},{key:"dailyactivity",name:"Hoạt động hằng ngày",icon:"📈",premium:!0},{key:"workreport",name:"Báo cáo hàng ngày",icon:"📋",premium:!0},{key:"approvals",name:"Phê duyệt",icon:"✅",premium:!0},{key:"calendar",name:"Lịch",icon:"📅",premium:!0},{key:"tasks",name:"Nhiệm vụ",icon:"✅",premium:!0},{key:"crm",name:"CRM",icon:"🤝",premium:!1},{key:"orders",name:"Đơn hàng",icon:"📦",premium:!0},{key:"pos",name:"POS - Bán tại quầy",icon:"💳",premium:!0},{key:"fnb",name:"F&B - Bàn & Bếp",icon:"🍽️",premium:!0},{key:"bookings",name:"Lịch hẹn (Spa/Dịch vụ)",icon:"📅",premium:!0},{key:"paymentreceipt",name:"Nhận tiền",icon:"🧾",premium:!1},{key:"products",name:"Trung tâm sản phẩm",icon:"🛍️",premium:!0},{key:"aistudio",name:"AI Studio sản phẩm",icon:"✨",premium:!0},{key:"warehouse",name:"Kho vận",icon:"📦",premium:!1},{key:"purchasing",name:"Mua hàng",icon:"🛒",premium:!0},{key:"warranty",name:"Bảo hành",icon:"🔧",premium:!1},{key:"mrp",name:"MRP - Lập kế hoạch SX",icon:"🏭",premium:!0},{key:"qc",name:"QC - Kiểm chất lượng",icon:"✅",premium:!0},{key:"dealership",name:"Đại lý ô tô (PDV)",icon:"🚗",premium:!0},{key:"marketing",name:"AI Marketing",icon:"📢",premium:!0},{key:"ads",name:"Quảng cáo số",icon:"📣",premium:!0},{key:"contentintel",name:"Phân tích nội dung",icon:"📊",premium:!0},{key:"seo",name:"SEO Website",icon:"🔍",premium:!0},{key:"catalogue",name:"Auto Catalogue",icon:"📚",premium:!1},{key:"videoservice",name:"Dịch vụ Video AI",icon:"🎬",premium:!0},{key:"accounting",name:"Kế toán",icon:"📒",premium:!0},{key:"finance",name:"Tài chính cá nhân",icon:"💰",premium:!1},{key:"bi",name:"Phân tích kinh doanh",icon:"📊",premium:!0},{key:"strategy",name:"Chiến lược kinh doanh",icon:"📈",premium:!0},{key:"hr",name:"HR & Chấm công",icon:"👥",premium:!1},{key:"assets",name:"Tài sản & bàn giao",icon:"🧰",premium:!0},{key:"field_workforce",name:"Chấm công & Điều động hiện trường",icon:"🏗️",premium:!0},{key:"shift",name:"Quản lý ca",icon:"🕐",premium:!0},{key:"training",name:"Đào tạo",icon:"🎓",premium:!0},{key:"playbook",name:"Sổ tay & Cẩm nang",icon:"📘",premium:!0},{key:"academy",name:"Opsone Academy",icon:"🏛️",premium:!0},{key:"calls",name:"Cuộc gọi",icon:"📞",premium:!0},{key:"chatbotbuilder",name:"Chatbot Builder",icon:"🔧",premium:!0},{key:"projects",name:"Quản lý Project",icon:"🏢",premium:!0},{key:"users",name:"Quản lý User",icon:"🔐",premium:!1},{key:"settings",name:"Cài đặt",icon:"⚙️",premium:!1},{key:"integrations",name:"Tích hợp",icon:"🔌",premium:!0},{key:"tenants",name:"Quản lý Tenants",icon:"🏢",premium:!0,superAdminOnly:!0},{key:"aiagent",name:"AI Agent",icon:"🤖",premium:!0}
1,{key:"knowledgebase",name:"Kiến thức",icon:"📚",premium:!0},{key:"workflows",name:"Tự động hoá",icon:"⚡",premium:!0},{key:"qa",name:"QA Testing",icon:"🧪",premium:!0},{key:"simulator",name:"Mô phỏng KD",icon:"📊",premium:!0,superAdminOnly:!0},{key:"governance",name:"Sức khoẻ quản trị",icon:"⚖️",premium:!0},{key:"company",name:"Doanh nghiệp",icon:"🏢",premium:!1},{key:"techdoc",name:"Tài liệu KT",icon:"📐",premium:!1},{key:"chat",name:"AI Trợ lý",icon:"🤖",premium:!1},{key:"messaging",name:"Nhắn tin nội bộ",icon:"💬",premium:!1},{key:"roadmap",name:"Lộ trình số hóa",icon:"🗺️",premium:!1},{key:"affiliate",name:"CTV & Affiliate",icon:"🤝",premium:!0},{key:"services",name:"Dịch vụ doanh nghiệp",icon:"⚖️",premium:!0}],oe=["dashboard","crm","chat","warehouse","catalogue","paymentreceipt","settings"],ie=[...oe,"hr","warranty","techdoc","roadmap","finance","users","purchasing","marketing","seo","contentintel","chatbotbuilder","knowledgebase","training","calls","affiliate","invoicecontrol","services"],le=be.map(n=>n.key),de={free:oe,pro:ie,enterprise:le,trial:oe,basic:ie,starter:ie,business:ie,professional:le,custom:le},Ce=[{value:"banmai",labelKey:"tnt_voice_banmai"},{value:"leminh",labelKey:"tnt_voice_leminh"},{value:"thuminh",labelKey:"tnt_voice_thuminh"},{value:"giahuy",labelKey:"tnt_voice_giahuy"},{value:"myan",labelKey:"tnt_voice_myan"}],Be=[{key:"searchProducts",labelKey:"tnt_tool_search",descKey:"tnt_tool_search_desc"},{key:"createQuotation",labelKey:"tnt_tool_quote",descKey:"tnt_tool_quote_desc"},{key:"createOrder",labelKey:"tnt_tool_order",descKey:"tnt_tool_order_desc"},{key:"createCatalog",labelKey:"tnt_tool_catalog",descKey:"tnt_tool_catalog_desc"}],ae=[{key:"sapo",name:"Sapo",icon:"🛍️",fields:["store","api_key","access_token"]},{key:"haravan",name:"Haravan",icon:"🏪",fields:["store","api_key","access_token"]},{key:"facebook",name:"Facebook",icon:"📘",fields:["page_id","access_token"]},{key:"zalo",name:"Zalo OA",icon:"💬",fields:["oa_id","access_token","refresh_token"]}];function ne({value:n,items:g,t:l}){const s=g.find(y=>y.value===n);if(!s)return e.jsx("span",{children:n});const d=s.labelKey&&l?l(s.labelKey):s.label;return e.jsx("span",{style:h(r({},t.badge),{background:s.bg,color:s.color}),children:d})}function ze({msg:n}){return n?e.jsx("div",{style:{padding:"8px 14px",borderRadius:6,marginBottom:12,fontSize:13,fontWeight:500,background:n.type==="success"?"#dcfce7":"#fee2e2",color:n.type==="success"?"#16a34a":"#ef4444",border:`1px solid ${n.type==="success"?"#bbf7d0":"#fecaca"}`},children:n.text}):null}function re({label:n,value:g,color:l,icon:s}){return e.jsx("div",{style:h(r({},t.card),{padding:16,flex:1,minWidth:160}),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,color:"#64748b",fontWeight:600,marginBottom:4},children:n}),e.jsx("div",{style:{fontSize:24,fontWeight:700,color:l||"#1e293b"},children:g})]}),e.jsx("div",{style:{fontSize:28,opacity:.6},children:s})]})})}function ce(n){if(!n)return"";const g=String(n).trim();return(!g.endsWith("Z")&&!g.includes("+")&&!g.includes("T")?new Date(g.replace(" ","T")+"Z"):new Date(g)).toLocaleDateString("vi-VN",{day:"2-digit",month:"2-digit",year:"numeric"})}function Te(n){if(!n)return"";const g=String(n).trim();return(!g.endsWith("Z")&&!g.includes("+")&&!g.includes("T")?new Date(g.replace(" ","T")+"Z"):new Date(g)).toLocaleString("vi-VN")}function Ve({navigateTo:n,onNavigated:g}){var se,ue,pe,ye;const{t:l}=Z(),[s,d]=m.useState([]),[y,k]=m.useState({total:0,active:0,trial:0,revenue:0}),[b,a]=m.useState(!0),[o,C]=m.useState(null),[u,_]=m.useState("info"),[j,S]=m.useState(""),[p,z]=m.useState(""),[W,q]=m.useState(""),[D,J]=m.useState(""),[U,H]=m.useState("created_at"),[G,N]=m.useState("desc"),[ee,Q]=m.useState(!1),[c,T]=m.useState(null),[M,B]=m.useState(!1),[$,V]=m.useState("tenants"),f=m.useCallback(async()=>{try{const i=await R(`${E}/api/tenants?limit=200`);if(i.ok){const x=await i.json();d(x.tenants||x||[]),x.stats&&k(x.stats)}}catch(i){console.error("Failed to fetch tenants:",i)}finally{a(!1)}},[]),L=m.useCallback(async()=>{try{const i=await R(`${E}
1/api/tenants/stats/overview`);if(i.ok){const x=await i.json();k(x)}}catch(i){console.error("Failed to fetch tenant stats:",i)}},[]);m.useEffect(()=>{f(),L()},[f,L]);const A=s.filter(i=>{if(j){const x=j.toLowerCase();if(!((i.name||"").toLowerCase().includes(x)||(i.code||"").toLowerCase().includes(x)||(i.domain||"").toLowerCase().includes(x)||(i.owner_email||"").toLowerCase().includes(x)||(i.login_email||"").toLowerCase().includes(x)))return!1}return!(p&&i.plan!==p||W&&i.status!==W||D&&i.industry!==D)}).sort((i,x)=>{const v=i[U]||"",F=x[U]||"",I=String(v).localeCompare(String(F),"vi");return G==="asc"?I:-I});function O(i){U===i?N(x=>x==="asc"?"desc":"asc"):(H(i),N("asc"))}function w(i,x){T({type:i,text:x}),setTimeout(()=>T(null),4e3)}return b?e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:300},children:e.jsx("div",{style:{color:"#64748b",fontSize:14},children:l("tnt_loading")})}):e.jsxs("div",{style:{maxWidth:1400,margin:"0 auto"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{marginBottom:4,color:"#1e293b"},children:l("tnt_page_title")}),e.jsx("p",{style:{color:"#64748b",fontSize:13,margin:0},children:l("tnt_page_subtitle")})]}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",background:"#f1f5f9",borderRadius:10,padding:4},children:[e.jsx("button",{onClick:()=>V("tenants"),style:{padding:"8px 14px",fontSize:13,fontWeight:600,borderRadius:8,border:"none",cursor:"pointer",background:$==="tenants"?"#fff":"transparent",color:$==="tenants"?"#1e293b":"#64748b",boxShadow:$==="tenants"?"0 1px 2px rgba(0,0,0,0.06)":"none"},children:"🏢 Tenants"}),e.jsx("button",{onClick:()=>V("billing"),style:{padding:"8px 14px",fontSize:13,fontWeight:600,borderRadius:8,border:"none",cursor:"pointer",background:$==="billing"?"#fff":"transparent",color:$==="billing"?"#1e293b":"#64748b",boxShadow:$==="billing"?"0 1px 2px rgba(0,0,0,0.06)":"none"},children:"💳 Hóa đơn & Giao dịch"})]}),$==="tenants"&&e.jsx("button",{style:t.btnPrimary,onClick:()=>Q(!0),children:l("tnt_create_new")})]})]}),$==="billing"?e.jsx(Ae,{showMessage:w}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:12,marginBottom:20,flexWrap:"wrap"},children:[e.jsx(re,{label:l("tnt_stat_total"),value:(se=y.total_tenants)!=null?se:s.length,color:"#1e293b",icon:"🏢"}),e.jsx(re,{label:l("tnt_stat_active"),value:(ue=y.active_tenants)!=null?ue:s.filter(i=>i.is_active===1).length,color:"#16a34a",icon:"✅"}),e.jsx(re,{label:l("tnt_stat_trial"),value:(ye=(pe=y.by_plan)==null?void 0:pe.trial)!=null?ye:s.filter(i=>i.plan==="trial").length,color:"#f59e0b",icon:"⏳"}),e.jsx(re,{label:l("tnt_stat_revenue"),value:(y.revenue_monthly||0).toLocaleString("vi-VN")+" ₫",color:"#1B3A57",icon:"💰"})]}),c&&e.jsx(ze,{msg:c}),e.jsxs("div",{style:{display:"flex",gap:16,alignItems:"flex-start"},children:[e.jsxs("div",{style:h(r({},t.card),{flex:o?"0 0 420px":1,minWidth:0,overflow:"hidden"}),children:[e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("input",{style:h(r({},t.input),{marginBottom:8}),placeholder:l("tnt_search_placeholder"),value:j,onChange:i=>S(i.target.value)}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("select",{style:h(r({},t.input),{width:"auto",flex:1}),value:p,onChange:i=>z(i.target.value),children:[e.jsx("option",{value:"",children:l("tnt_all_plans")}),Y.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))]}),e.jsxs("select",{style:h(r({},t.input),{width:"auto",flex:1}),value:W,onChange:i=>q(i.target.value),children:[e.jsx("option",{value:"",children:l("tnt_all_statuses")}),xe.map(i=>e.jsx("option",{value:i.value,children:i.labelKey?l(i.labelKey):i.label},i.value))]}),e.jsxs("select",{style:h(r({},t.input),{width:"auto",flex:1}),value:D,onChange:i=>J(i.target.value),children:[e.jsx("option",{value:"",children:l("tnt_all_industries")}),he.map(i=>e.jsx("option",{value:i.value,children:i.labelKey?l(i.labelKey):i.label},i.value))]})]})]}),e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:t.table,children:[e.jsx("thead",{children:e.jsx("tr",{children:[{key:"name",labelKey:"tnt_col_name"},{key:"plan",label:"Plan"},{key:"industry",labelKey:"tnt_col_industry"},{key:"owner_email",labelKey:"tnt_col_owner_email"},{key:"modules_count",label:"Modules"},{key:"status",label:"Status"},{key:"created_at",label:"Created"}].map(i=>e.jsxs("th",{style:h(r({},t.th),{cursor:"pointer",userSelect:"none"}),onClick:()=>O(i.key),children:[i.labelKey?l(i.labelKey):i.label," ",U===i.key?G==="asc"?"â
1†‘":"↓":""]},i.key))})}),e.jsx("tbody",{children:A.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,style:h(r({},t.td),{textAlign:"center",color:"#94a3b8"}),children:l("tnt_no_tenants")})}):A.map(i=>e.jsxs("tr",{onClick:async()=>{C(i),_("info");try{const x=await R(`${E}/api/tenants/${i.id}`);if(x.ok){const v=await x.json(),F=(v.modules||[]).filter(K=>K.is_enabled===1||K.is_enabled===!0).map(K=>K.code),I=h(r(r({},i),v.tenant),{modules:v.modules,enabled_modules:F,integrations_list:v.integrations,detail_stats:v.stats});if(v.integrations){const K={};v.integrations.forEach(P=>{K[P.platform]=r(r({},P),P.sync_config?typeof P.sync_config=="string"?JSON.parse(P.sync_config):P.sync_config:{})}),I.integrations=K}C(I),d(K=>K.map(P=>P.id===I.id?I:P))}}catch(x){console.error("Fetch tenant detail:",x)}},style:{cursor:"pointer",background:(o==null?void 0:o.id)===i.id?"#F0F4F8":"transparent",transition:"background 0.1s"},onMouseEnter:x=>{(o==null?void 0:o.id)!==i.id&&(x.currentTarget.style.background="#f8fafc")},onMouseLeave:x=>{(o==null?void 0:o.id)!==i.id&&(x.currentTarget.style.background="transparent")},children:[e.jsxs("td",{style:t.td,children:[e.jsx("div",{style:{fontWeight:600,color:"#1e293b"},children:i.name}),e.jsxs("div",{style:{fontSize:11,color:"#94a3b8"},children:[i.code," | ",i.domain||"—"]})]}),e.jsx("td",{style:t.td,children:e.jsx(ne,{value:i.plan,items:Y})}),e.jsx("td",{style:t.td,children:e.jsx("span",{style:{fontSize:12,color:"#64748b"},children:i.industry||"—"})}),e.jsx("td",{style:t.td,children:e.jsx("span",{style:{fontSize:12,color:"#64748b",wordBreak:"break-all"},children:i.owner_email||i.login_email||"—"})}),e.jsx("td",{style:t.td,children:e.jsx("span",{style:h(r({},t.badge),{background:"#F0F4F8",color:"#1B3A57"}),children:Array.isArray(i.enabled_modules)?i.enabled_modules.length:i.modules_count||0})}),e.jsx("td",{style:t.td,children:e.jsx(ne,{value:i.status,items:xe,t:l})}),e.jsx("td",{style:t.td,children:e.jsx("span",{style:{fontSize:12,color:"#64748b"},children:ce(i.created_at)})})]},i.id))})]})}),e.jsx("div",{style:{marginTop:8,fontSize:12,color:"#94a3b8"},children:l("tnt_showing").replace("{filtered}",A.length).replace("{total}",s.length)})]}),o&&e.jsxs("div",{style:h(r({},t.card),{flex:1,minWidth:0}),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[e.jsxs("div",{children:[e.jsx("h3",{style:{margin:0,fontSize:16,color:"#1e293b"},children:o.name}),e.jsxs("span",{style:{fontSize:12,color:"#94a3b8"},children:[o.code," | ",o.domain||"—"]})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{style:h(r({},t.btnSmall),{background:"#fef3c7",color:"#b45309",border:"1px solid #fcd34d",fontWeight:600}),onClick:async()=>{if(confirm(`Đăng nhập hộ KH "${o.name}"?
2
3Bạn sẽ truy cập với tư cách admin của họ. Mọi hành động đều được ghi log.`))try{const i=await R(`${E}/api/tenants/${o.id}/impersonate`,{method:"POST"}),x=await i.json();if(!i.ok){alert("Lỗi đăng nhập hộ: "+(x.error||"không rõ"));return}const v=localStorage.getItem("tbbv_token");v&&localStorage.setItem("tbbv_impersonator_token",v),localStorage.setItem("tbbv_token",x.token),localStorage.removeItem("tbbv_user_cache"),localStorage.setItem("tbbv_impersonate_info",JSON.stringify({tenant_name:x.user.tenant_name,target_username:x.user.username,target_display_name:x.user.display_name,started_at:Date.now()})),window.location.href="/dashboard"}catch(i){alert("Lỗi mạng: "+i.message)}},title:"Đăng nhập với tư cách admin của KH để hỗ trợ",children:"🎭 Đăng nhập hộ"}),e.jsx("button",{style:t.btnSmall,onClick:()=>C(null),children:l("tnt_close")})]})]}),e.jsx("div",{style:{display:"flex",gap:4,marginBottom:16,borderBottom:"2px solid #e2e8f0",paddingBottom:0},children:[{key:"info",labelKey:"tnt_tab_info",icon:"📋"},{key:"modules",label:"Modules",icon:"🧩"},{key:"chatbot",label:"AI Chatbot",icon:"🤖"},{key:"integrations",labelKey:"tnt_tab_integrations",icon:"🔗"},{key:"billing",label:"Billing",icon:"💳"},{key:"analytics",label:"Analytics",icon:"📈"}].map(i=>e.jsxs("button",{onClick:()=>_(i.key),style:{padding:"10px 14px",border:"none",background:"none",fontSize:13,fontWeight:600,cursor:"pointer",color:u===i.key?"#1B3A57":"#64748b",borderBottom:u===i.key?"2px solid #1B3A57":"2px solid transparent",marginBottom:-2,fontFamily:"inherit",transition:"all 0.15s",whiteSpace:"nowrap"},children:[i.icon," ",i.labelKey?l(i.labelKey):i.label]},i.key))}),u==="info"&&e.jsx(Ie,{tenant:o,onSave:async i=>{try{B(!0);const x=await R(`${E}
3/api/tenants/${o.id}`,{method:"PUT",body:JSON.stringify(i)});if(x.ok){const F=(await x.json()).tenant||r(r({},o),i);C(F),d(I=>I.map(K=>K.id===F.id?F:K)),w("success",l("tnt_updated_info"))}else{const v=await x.json();w("error",v.error||l("tnt_error_update"))}}catch(x){w("error",l("tnt_error_connection"))}finally{B(!1)}},submitting:M}),u==="modules"&&e.jsx(Ke,{tenant:o,onSave:async i=>{try{B(!0);const x=await R(`${E}/api/tenants/${o.id}/modules`,{method:"PUT",body:JSON.stringify({modules:i.map(v=>({code:v,is_enabled:!0}))})});if(x.ok){const v=await x.json().catch(()=>({})),F=Array.isArray(v.refused)?v.refused:[],I=F.length?i.filter(P=>!F.some(X=>X.code===P)):i,K=h(r({},o),{enabled_modules:I});C(K),d(P=>P.map(X=>X.id===K.id?K:X)),F.length?w("error",`Chưa bật được ${F.length} module trả phí (${F.map(P=>P.code).join(", ")}) — cần mua hoặc dùng thử ở Chợ ứng dụng.`):w("success",l("tnt_updated_modules"))}else{const v=await x.json();w("error",v.error||l("tnt_error_modules"))}}catch(x){w("error",l("tnt_error_connection"))}finally{B(!1)}},submitting:M}),u==="chatbot"&&e.jsx(Le,{tenant:o,onSave:async i=>{try{B(!0);const x=await R(`${E}/api/tenants/${o.id}/chatbot`,{method:"PUT",body:JSON.stringify(i)});if(x.ok){const v=h(r({},o),{chatbot_config:i});C(v),d(F=>F.map(I=>I.id===v.id?v:I)),w("success",l("tnt_updated_chatbot"))}else{const v=await x.json();w("error",v.error||l("tnt_error_chatbot"))}}catch(x){w("error",l("tnt_error_connection"))}finally{B(!1)}},submitting:M}),u==="integrations"&&e.jsx(Fe,{tenant:o,onSave:async i=>{try{B(!0);const x=await R(`${E}/api/tenants/${o.id}/integrations`,{method:"PUT",body:JSON.stringify({integrations:i})});if(x.ok){const v=h(r({},o),{integrations:i});C(v),d(F=>F.map(I=>I.id===v.id?v:I)),w("success",l("tnt_updated_integrations"))}else{const v=await x.json();w("error",v.error||l("tnt_error_update"))}}catch(x){w("error",l("tnt_error_connection"))}finally{B(!1)}},showMessage:w}),u==="billing"&&e.jsx(Pe,{tenant:o,onChangePlan:async i=>{try{B(!0);const x=await R(`${E}/api/tenants/${o.id}/subscription`,{method:"POST",body:JSON.stringify({plan_code:i,billing_cycle:"monthly"})});if(x.ok){const v=await R(`${E}/api/tenants/${o.id}`);if(v.ok){const I=(await v.json()).tenant||h(r({},o),{plan:i});C(I),d(K=>K.map(P=>P.id===I.id?r(r({},P),I):P))}w("success",l("tnt_plan_changed").replace("{plan}",i)),L()}else{const v=await x.json();w("error",v.error||l("tnt_error_plan"))}}catch(x){w("error",l("tnt_error_connection"))}finally{B(!1)}},onExtend:async i=>{try{B(!0);const x=await R(`${E}/api/tenants/${o.id}/subscription/extend`,{method:"POST",body:JSON.stringify(i)}),v=await x.json();if(x.ok){const F=await R(`${E}/api/tenants/${o.id}`);if(F.ok){const K=(await F.json()).tenant||r({},o);C(K),d(P=>P.map(X=>X.id===K.id?r(r({},X),K):X))}w("success",v.message||"Đã gia hạn subscription"),L()}else w("error",v.error||"Lỗi gia hạn subscription")}catch(x){w("error",l("tnt_error_connection"))}finally{B(!1)}},submitting:M}),u==="analytics"&&e.jsx($e,{tenant:o})]})]}),ee&&e.jsx(Ne,{onClose:()=>Q(!1),onCreated:i=>{d(x=>[i,...x]),Q(!1),L(),w("success",l("tnt_tenant_created"))},showMessage:w})]})]})}function Ae({showMessage:n}){const[g,l]=m.useState("invoices"),[s,d]=m.useState([]),[y,k]=m.useState([]),[b,a]=m.useState([]),[o,C]=m.useState(!0),[u,_]=m.useState(""),[j,S]=m.useState(null),[p,z]=m.useState(null),[W,q]=m.useState(null),D=m.useCallback(async()=>{try{const c=u?`?status=${u}&limit=100`:"?limit=100",T=await R(`/api/payment/admin/invoices${c}`);if(T.ok){const M=await T.json();d(M.invoices||[])}}catch(c){console.error(c)}},[u]),J=m.useCallback(async()=>{try{const c=await R("/api/payment/admin/transactions?limit=100");if(c.ok){const T=await c.json();k(T.transactions||[])}}catch(c){console.error(c)}},[]),U=m.useCallback(async()=>{try{const c=await R("/api/payment/admin/pending-invoices");if(c.ok){const T=await c.json();a(T.invoices||[])}}catch(c){console.error(c)}},[]);m.useEffect(()=>{C(!0),Promise.all([D(),J(),U()]).finally(()=>C(!1))},[D,J,U]);const H=async(c,T,M)=>{S(c);try{const B=T==="mark-paid"?`/api/payment/admin/invoices/${c}/mark-paid`:T==="revert"?`/api/payment/admin/invoices/${c}/revert`:T==="refund"?`/api/payment/admin/invoices/${c}/refund`:T==="cancel"?`/api/payment/admin/invoices/${c}/cancel`:null;if(!B)throw new Error("Hành động không hợp lệ");const $=await R(B,{method:"PUT",body:JSON.stringify({reason:M})}),V=await $.json();$.ok&&(V.success||V.matched)?(n("success",V.message||"Thành công"),D(),J(),U(),z(null)):n("error",V.error||V.message||"Lỗi xử lý")}catch(B){n("error",B.message)}finally{S(null)}},G=async(c,T,M)=>{S("tx-"+c);try{const B=await R(`/api/payment/admin/transactions/${c}/assign`,{method:"PUT",body:JSON.stringify({invoice_id:T,reason:M})}),$=await B.json();B.ok&&$.success?(n("success",$.message),D(),J(),U(),q(null)):n("error",$.error||"Lỗi gán")}catch(B){n("error",B.message)}finally{S(null)}},N=c=>
3Number(c||0).toLocaleString("vi-VN")+"₫",ee=c=>c?new Date(c).toLocaleString("vi-VN"):"—",Q=c=>({padding:"10px 16px",fontSize:14,fontWeight:600,border:"none",background:"transparent",borderBottom:c?"2px solid #1B3A57":"2px solid transparent",color:c?"#1B3A57":"#64748b",cursor:"pointer"});return o?e.jsx("div",{style:{padding:40,textAlign:"center",color:"#94a3b8"},children:"Đang tải..."}):e.jsxs("div",{style:{background:"#fff",borderRadius:12,padding:"var(--card-pad, 20px)",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[e.jsxs("div",{style:{display:"flex",gap:4,borderBottom:"1px solid #e2e8f0",marginBottom:16},children:[e.jsxs("button",{onClick:()=>l("invoices"),style:Q(g==="invoices"),children:["📄 Hoá đơn (",s.length,")"]}),e.jsxs("button",{onClick:()=>l("transactions"),style:Q(g==="transactions"),children:["💸 Giao dịch ngân hàng (",y.length,")"]})]}),g==="invoices"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:10,marginBottom:12,alignItems:"center"},children:[e.jsx("span",{style:{fontSize:13,color:"#64748b"},children:"Lọc trạng thái:"}),e.jsxs("select",{value:u,onChange:c=>_(c.target.value),style:{padding:"6px 10px",borderRadius:6,border:"1px solid #cbd5e1",fontSize:13},children:[e.jsx("option",{value:"",children:"Tất cả"}),e.jsx("option",{value:"pending",children:"Chờ thanh toán"}),e.jsx("option",{value:"paid",children:"Đã thanh toán"}),e.jsx("option",{value:"refunded",children:"Đã hoàn tiền"}),e.jsx("option",{value:"cancelled",children:"Đã hủy"})]})]}),e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13,tableLayout:"fixed",minWidth:1060},children:[e.jsx("colgroup",{children:[140,180,120,170,130,120,200].map((c,T)=>e.jsx("col",{style:{width:c}},T))}),e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f8fafc",textAlign:"left"},children:[e.jsx("th",{style:{padding:"10px 12px",borderBottom:"1px solid #e2e8f0"},children:"Mã HĐ"}),e.jsx("th",{style:{padding:"10px 12px",borderBottom:"1px solid #e2e8f0"},children:"Tenant"}),e.jsx("th",{style:{padding:"10px 12px",borderBottom:"1px solid #e2e8f0",textAlign:"right"},children:"Số tiền"}),e.jsx("th",{style:{padding:"10px 12px",borderBottom:"1px solid #e2e8f0"},children:"Trạng thái"}),e.jsx("th",{style:{padding:"10px 12px",borderBottom:"1px solid #e2e8f0"},children:"Người xử lý"}),e.jsx("th",{style:{padding:"10px 12px",borderBottom:"1px solid #e2e8f0"},children:"Tạo lúc"}),e.jsx("th",{style:{padding:"10px 12px",borderBottom:"1px solid #e2e8f0"},children:"Hành động"})]})}),e.jsx("tbody",{children:s.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,style:{padding:30,textAlign:"center",color:"#94a3b8"},children:"Chưa có hoá đơn"})}):s.map(c=>{const T={paid:"✓ Đã thanh toán",pending:"⏳ Chờ thanh toán",cancelled:"✗ Đã hủy",refunded:"↩ Hoàn tiền"},B={paid:{bg:"#dcfce7",fg:"#166534"},pending:{bg:"#fef3c7",fg:"#92400e"},cancelled:{bg:"#e2e8f0",fg:"#475569"},refunded:{bg:"#fee2e2",fg:"#991b1b"}}[c.status]||{bg:"#f1f5f9",fg:"#64748b"};return e.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[e.jsx("td",{style:{padding:"10px 12px",fontFamily:"monospace",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:c.invoice_code||"",children:c.invoice_code}),e.jsx("td",{style:{padding:"10px 12px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:c.tenant_name||"",children:c.tenant_name||`#${c.tenant_id}`}),e.jsx("td",{style:{padding:"10px 12px",textAlign:"right",fontWeight:600,whiteSpace:"nowrap"},children:N(c.total)}),e.jsxs("td",{style:{padding:"10px 12px"},children:[e.jsx("span",{style:{padding:"2px 8px",borderRadius:6,fontSize:11,fontWeight:600,background:B.bg,color:B.fg},children:T[c.status]||c.status}),c.processed_reason&&e.jsxs("div",{style:{fontSize:11,color:"#64748b",marginTop:2,fontStyle:"italic"},title:c.processed_reason,children:['"',c.processed_reason.slice(0,40),c.processed_reason.length>40?"...":"",'"']})]}),e.jsxs("td",{style:{padding:"10px 12px",fontSize:12,color:"#64748b"},children:[c.processed_by_username||"—",c.last_action&&e.jsx("div",{style:{fontSize:10,
3color:"#94a3b8"},children:c.last_action})]}),e.jsx("td",{style:{padding:"10px 12px",color:"#64748b",fontSize:12,whiteSpace:"nowrap"},children:ee(c.created_at)}),e.jsx("td",{style:{padding:"10px 12px"},children:e.jsxs("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:[c.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>z({invoice:c,action:"mark-paid"}),disabled:j===c.id,style:{padding:"5px 10px",background:"#16a34a",color:"#fff",border:"none",borderRadius:5,fontSize:11,fontWeight:600,cursor:"pointer"},children:"✓ Xác nhận TT"}),e.jsx("button",{onClick:()=>z({invoice:c,action:"cancel"}),disabled:j===c.id,style:{padding:"5px 10px",background:"#64748b",color:"#fff",border:"none",borderRadius:5,fontSize:11,fontWeight:600,cursor:"pointer"},children:"✗ Hủy HĐ"})]}),c.status==="paid"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>z({invoice:c,action:"revert"}),disabled:j===c.id,style:{padding:"5px 10px",background:"#f59e0b",color:"#fff",border:"none",borderRadius:5,fontSize:11,fontWeight:600,cursor:"pointer"},children:"↶ Hủy xác nhận"}),e.jsx("button",{onClick:()=>z({invoice:c,action:"refund"}),disabled:j===c.id,style:{padding:"5px 10px",background:"#dc2626",color:"#fff",border:"none",borderRadius:5,fontSize:11,fontWeight:600,cursor:"pointer"},children:"↩ Hoàn tiền"})]}),(c.status==="cancelled"||c.status==="refunded")&&e.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:"—"})]})})]},c.id)})})]})})]}),g==="transactions"&&e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f8fafc",textAlign:"left"},children:[e.jsx("th",{style:{padding:"10px 12px",borderBottom:"1px solid #e2e8f0"},children:"Thời gian"}),e.jsx("th",{style:{padding:"10px 12px",borderBottom:"1px solid #e2e8f0"},children:"Ngân hàng"}),e.jsx("th",{style:{padding:"10px 12px",borderBottom:"1px solid #e2e8f0",textAlign:"right"},children:"Số tiền"}),e.jsx("th",{style:{padding:"10px 12px",borderBottom:"1px solid #e2e8f0"},children:"Nội dung"}),e.jsx("th",{style:{padding:"10px 12px",borderBottom:"1px solid #e2e8f0"},children:"Khớp HĐ"}),e.jsx("th",{style:{padding:"10px 12px",borderBottom:"1px solid #e2e8f0"},children:"Hành động"})]})}),e.jsx("tbody",{children:y.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,style:{padding:30,textAlign:"center",color:"#94a3b8"},children:"Chưa có giao dịch nào (cần cấu hình SePay webhook)"})}):y.map(c=>{var T;return e.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[e.jsx("td",{style:{padding:"10px 12px",color:"#64748b",fontSize:12},children:ee(c.created_at)}),e.jsx("td",{style:{padding:"10px 12px"},children:c.bank_name||"—"}),e.jsxs("td",{style:{padding:"10px 12px",textAlign:"right",fontWeight:600,color:"#16a34a"},children:["+",N(c.amount)]}),e.jsx("td",{style:{padding:"10px 12px",fontFamily:"monospace",fontSize:12,maxWidth:300,overflow:"hidden",textOverflow:"ellipsis"},title:c.description,children:c.description||"—"}),e.jsx("td",{style:{padding:"10px 12px"},children:c.matched?e.jsx("span",{style:{padding:"2px 8px",borderRadius:6,fontSize:11,fontWeight:600,background:"#dcfce7",color:"#166534"},title:c.match_result,children:"✓ Đã khớp"}):e.jsxs("span",{style:{padding:"2px 8px",borderRadius:6,fontSize:11,background:"#fee2e2",color:"#991b1b"},title:c.match_result,children:["✗ ",((T=c.match_result)==null?void 0:T.slice(0,30))||"Chưa khớp"]})}),e.jsx("td",{style:{padding:"10px 12px"},children:!c.matched&&e.jsx("button",{onClick:()=>q({tx:c}),disabled:j==="tx-"+c.id,style:{padding:"5px 10px",background:"#1B3A57",color:"#fff",border:"none",borderRadius:5,fontSize:11,fontWeight:600,cursor:"pointer"},children:"Gán hóa đơn"})})]},c.id)})})]})}),p&&e.jsx(We,{modal:p,onClose:()=>z(null),onConfirm:H,inProgress:j===p.invoice.id,fmtVND:N}),W&&e.jsx(Re,{tx:W.tx,pendingInvoices:b,onClose:()=>q(null),onConfirm:G,inProgress:j==="tx-"+W.tx.id,fmtVND:N})]})}function We({modal:n,onClose:g,onConfirm:l,inProgress:s,fmtVND:d}){const[y,k]=m.useState(""),{invoice:b,action:a}=n,o={"mark-paid":{title:"Xác nhận thanh toán",color:"#16a34a",label:"Lý do/ghi chú (tuỳ chọn)",required:!1,btn:"✓ Xác nhận"},cancel:{title:"Hủy hóa đơn",color:"#64748b",label:"Lý do hủy *",required:!0,btn:"✗ Hủy hóa đơn"},revert:{title:"Hủy xác nhận thanh toán",color:"#f59e0b",label:"Lý do hủy xác nhận *",required:!0,btn:"↶ Hủy xác nhận"},refund:{title:"Hoàn tiền",color:"#dc2626",label:"Lý do hoàn tiền *",required:!0,btn:"↩ Hoàn tiền"}}[a],C=()=>
3{if(o.required&&!y.trim())return alert("Vui lòng nhập lý do");l(b.id,a,y.trim())};return e.jsx("div",{style:h(r({},me),{background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3}),onClick:g,children:e.jsxs("div",{onClick:u=>u.stopPropagation(),style:{background:"#fff",borderRadius:12,padding:24,maxWidth:480,width:"90%"},children:[e.jsx("h3",{style:{margin:0,marginBottom:6,color:o.color,fontSize:18},children:o.title}),e.jsxs("div",{style:{fontSize:13,color:"#64748b",marginBottom:16},children:[e.jsxs("div",{children:["Hóa đơn: ",e.jsx("strong",{style:{fontFamily:"monospace"},children:b.invoice_code})]}),e.jsxs("div",{children:["Tenant: ",e.jsx("strong",{children:b.tenant_name||`#${b.tenant_id}`})]}),e.jsxs("div",{children:["Số tiền: ",e.jsx("strong",{children:d(b.total)})]})]}),(a==="revert"||a==="refund")&&e.jsxs("div",{style:{background:"#fef3c7",border:"1px solid #fde68a",borderRadius:8,padding:10,marginBottom:12,fontSize:12,color:"#92400e"},children:["⚠️ Tenant sẽ bị ",e.jsx("strong",{children:"hết hạn ngay lập tức"})," sau khi xá»­ lý. Hệ thống sẽ gá»­i notification cho tenant."]}),e.jsx("label",{style:{fontSize:13,fontWeight:600,color:"#334155",display:"block",marginBottom:6},children:o.label}),e.jsx("textarea",{value:y,onChange:u=>k(u.target.value),rows:3,placeholder:"VD: Khách yêu cầu hoàn tiền do đổi ý...",style:{width:"100%",padding:10,borderRadius:8,border:"1px solid #cbd5e1",fontSize:13,resize:"vertical",boxSizing:"border-box"}}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:16},children:[e.jsx("button",{onClick:g,disabled:s,style:{padding:"8px 16px",background:"#f1f5f9",color:"#475569",border:"none",borderRadius:8,fontSize:13,fontWeight:600,cursor:"pointer"},children:"Há»§y"}),e.jsx("button",{onClick:C,disabled:s,style:{padding:"8px 16px",background:o.color,color:"#fff",border:"none",borderRadius:8,fontSize:13,fontWeight:600,cursor:"pointer",opacity:s?.5:1},children:s?"Đang xá»­ lý...":o.btn})]})]})})}function Re({tx:n,pendingInvoices:g,onClose:l,onConfirm:s,inProgress:d,fmtVND:y}){const[k,b]=m.useState(""),[a,o]=m.useState(""),C=()=>{if(!k)return alert("Vui lòng chọn hóa đơn");s(n.id,parseInt(k),a.trim())};return e.jsx("div",{style:h(r({},me),{background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3}),onClick:l,children:e.jsxs("div",{onClick:u=>u.stopPropagation(),style:{background:"#fff",borderRadius:12,padding:24,maxWidth:540,width:"90%"},children:[e.jsx("h3",{style:{margin:0,marginBottom:12,color:"#1B3A57",fontSize:18},children:"Gán giao dịch → hóa đơn"}),e.jsxs("div",{style:{background:"#f8fafc",borderRadius:8,padding:12,marginBottom:14,fontSize:13},children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Số tiền:"})," ",y(n.amount)]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Ngân hàng:"})," ",n.bank_name||"—"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Nội dung:"})," ",e.jsx("span",{style:{fontFamily:"monospace"},children:n.description||"—"})]})]}),e.jsx("label",{style:{fontSize:13,fontWeight:600,color:"#334155",display:"block",marginBottom:6},children:"Chọn hóa đơn pending *"}),e.jsxs("select",{value:k,onChange:u=>b(u.target.value),style:{width:"100%",padding:10,borderRadius:8,border:"1px solid #cbd5e1",fontSize:13,marginBottom:12,boxSizing:"border-box"},children:[e.jsx("option",{value:"",children:"-- Chọn hóa đơn --"}),g.map(u=>e.jsxs("option",{value:u.id,children:[u.invoice_code," — ",u.tenant_name||`#${u.id}`," — ",y(u.total)]},u.id))]}),e.jsx("label",{style:{fontSize:13,fontWeight:600,color:"#334155",display:"block",marginBottom:6},children:"Ghi chú (tuỳ chọn)"}),e.jsx("textarea",{value:a,onChange:u=>o(u.target.value),rows:2,placeholder:"VD: Khách chuyển nội dung sai, đã liên hệ xác nhận...",style:{width:"100%",padding:10,borderRadius:8,border:"1px solid #cbd5e1",fontSize:13,resize:"vertical",boxSizing:"border-box"}}),e.jsx("div",{style:{background:"#fef3c7",border:"1px solid #fde68a",borderRadius:8,padding:10,marginTop:12,fontSize:12,color:"#92400e"},children:"⚠️ Hành động này sẽ kích hoạt subscription cá»
3§a tenant. Đảm bảo số tiền giao dịch khớp với số tiền hóa đơn (lệch <= 1.000đ)."}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:16},children:[e.jsx("button",{onClick:l,disabled:d,style:{padding:"8px 16px",background:"#f1f5f9",color:"#475569",border:"none",borderRadius:8,fontSize:13,fontWeight:600,cursor:"pointer"},children:"Há»§y"}),e.jsx("button",{onClick:C,disabled:d,style:{padding:"8px 16px",background:"#1B3A57",color:"#fff",border:"none",borderRadius:8,fontSize:13,fontWeight:600,cursor:"pointer",opacity:d?.5:1},children:d?"Đang xá»­ lý...":"Gán + Kích hoạt"})]})]})})}function Ie({tenant:n,onSave:g,submitting:l}){const{t:s}=Z(),[d,y]=m.useState({code:n.code||"",name:n.name||"",domain:n.domain||"",industry:n.industry||"",plan:n.plan||"trial",status:n.status||"active",owner_name:n.owner_name||"",owner_email:n.owner_email||"",owner_phone:n.owner_phone||"",settings:typeof n.settings=="string"?n.settings:JSON.stringify(n.settings||{},null,2)});m.useEffect(()=>{y({code:n.code||"",name:n.name||"",domain:n.domain||"",industry:n.industry||"",plan:n.plan||"trial",status:n.status||"active",owner_name:n.owner_name||"",owner_email:n.owner_email||"",owner_phone:n.owner_phone||"",settings:typeof n.settings=="string"?n.settings:JSON.stringify(n.settings||{},null,2)})},[n.id]);function k(){let b;try{b=JSON.parse(d.settings)}catch(a){b={}}g(h(r({},d),{settings:b}))}return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:12,marginBottom:16},children:[e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:s("tnt_label_code")}),e.jsx("input",{style:t.input,value:d.code,onChange:b=>y(a=>h(r({},a),{code:b.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:s("tnt_label_name")}
3),e.jsx("input",{style:t.input,value:d.name,onChange:b=>y(a=>h(r({},a),{name:b.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:"Domain"}),e.jsx("input",{style:t.input,value:d.domain,onChange:b=>y(a=>h(r({},a),{domain:b.target.value})),placeholder:"vd: tenant1.tbbv.vn"})]}),e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:s("tnt_label_industry")}),e.jsxs("select",{style:t.input,value:d.industry,onChange:b=>y(a=>h(r({},a),{industry:b.target.value})),children:[e.jsx("option",{value:"",children:s("tnt_select_industry")}),he.map(b=>e.jsx("option",{value:b.value,children:b.labelKey?s(b.labelKey):b.label},b.value))]})]}),e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:s("tnt_label_plan")}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:4},children:[e.jsx(ne,{value:n.plan,items:Y}),e.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:"Đổi gói ở tab Billing"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:s("tnt_label_status")}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:4},children:e.jsx("button",{style:h(r({},t.btnSmall),{background:d.status==="active"?"#dcfce7":"#fee2e2",color:d.status==="active"?"#16a34a":"#ef4444",border:`1px solid ${d.status==="active"?"#bbf7d0":"#fecaca"}`,fontWeight:600}),onClick:()=>y(b=>h(r({},b),{status:b.status==="active"?"inactive":"active"})),children:d.status==="active"?s("tnt_status_active_text"):s("tnt_status_inactive_text")})})]})]}),e.jsxs("div",{style:h(r({},t.formBox),{marginBottom:16}),children:[e.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#374151"},children:s("tnt_owner_title")}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:s("tnt_label_fullname")}),e.jsx("input",{style:t.input,value:d.owner_name,onChange:b=>y(a=>h(r({},a),{owner_name:b.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:"Email"}),e.jsx("input",{style:t.input,type:"email",value:d.owner_email,onChange:b=>y(a=>h(r({},a),{owner_email:b.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:s("tnt_label_phone")}),e.jsx("input",{style:t.input,value:d.owner_phone,onChange:b=>y(a=>h(r({},a),{owner_phone:b.target.value}))})]})]})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:t.label,children:s("tnt_label_settings")}),e.jsx("textarea",{style:h(r({},t.input),{height:120,fontFamily:"monospace",fontSize:12,resize:"vertical"}),value:d.settings,onChange:b=>y(a=>h(r({},a),{settings:b.target.value}))})]}),e.jsx("button",{style:t.btnPrimary,onClick:k,disabled:l,children:s(l?"tnt_saving":"tnt_save_changes")})]})}function Ke({tenant:n,onSave:g,submitting:l}){const{t:s}=Z(),[d,y]=m.useState(Array.isArray(n.enabled_modules)?[...n.enabled_modules]:[]);m.useEffect(()=>{y(Array.isArray(n.enabled_modules)?[...n.enabled_modules]:[])},[n.id,n.enabled_modules]);const k=de[n.plan]||de.trial;function b(a){y(o=>o.includes(a)?o.filter(C=>C!==a):[...o,a])}return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[e.jsxs("div",{style:{fontSize:13,color:"#64748b"},children:[s("tnt_current_plan")," ",e.jsx(ne,{value:n.plan,items:Y})," — ",s("tnt_modules_available").replace("{count}",k.length)]}),e.jsx("button",{style:t.btnPrimary,onClick:()=>g(d),disabled:l,children:s(l?"tnt_saving":"tnt_save_changes")})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))",gap:12},children:be.map(a=>{const o=d.includes(a.key),C=k.includes(a.key),u=a.premium;return e.jsxs("div",{style:h(r({},t.card),{padding:14,marginBottom:0,opacity:C?1:.5,border:o?"2px solid #1B3A57":"1px solid #e2e8f0",position:"relative",cursor:C?"pointer":"default",transition:"all 0.15s"}),onClick:()=>C&&b(a.key),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:6},children:[e.jsx("span",{style:{fontSize:22},children:a.icon}),e.jsx("div",{style:{flex:1},children:e.jsx("div",{style:{fontWeight:600,fontSize:13,color:"#1e293b"},children:a.nameKey?s(a.nameKey):a.name})}),u&&e.jsx("span",{style:h(r({},t.badge),{background:"#fef3c7",color:"#d97706",fontSize:10}),children:"Premium"}),e.jsx("div",{style:{width:40,height:22,borderRadius:11,background:o?"#1B3A57":"#d1d5db",position:"relative",transition:"background 0.2s",flexShrink:0,opacity:C?1:.4},children:e.jsx("div",{style:{width:18,height:18,borderRadius:"50%",background:"#fff",position:"absolute",top:2,left:o?20:2,transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})})]}),e.jsx("div",{style:{fontSize:12,color:"#64748b",lineHeight:1.4},children:a.descKey?s(a.descKey):a.desc}),!C&&e.jsx("div",{style:{fontSize:11,color:"#ef4444",marginTop:4},children:s("tnt_upgrade_required")})]},a.key)})})]})}function Le({tenant:n,onSave:g,submitting:l}){const{t:s}=Z(),d=n.chatbot_config||{},[y,k]=m.useState({persona_name:d.persona_name||s("tnt_default_persona"),greeting:d.greeting||s("tnt_default_greeting"),system_prompt:d.system_prompt||"",voice:d.voice||"banmai",tools:d.tools||{searchProducts:!0,createQuotation:!1,createOrder:!1,createCatalog:!1},widget_color:d.widget_color||"#1B3A57",avatar_url:d.avatar_url||""});m.useEffect(()=>{const a=n.chatbot_config||{};k({persona_name:a.persona_name||s("tnt_default_persona"),greeting:a.greeting||s("tnt_default_greeting"),system_prompt:a.system_prompt||"",voice:a.voice||"banmai",tools:a.tools||{searchProducts:!0,createQuotation:!1,createOrder:!1,createCatalog:!1},widget_color:a.widget_color||"#1B3A57",avatar_url:a.avatar_url||""})},[n.id]);function b(a){k(o=>h(r({},o),{tools:h(r({},o.tools),{[a]:!o.tools[a]})}))}return e.jsxs("div",{children:[e.jsxs("div",{style:h(r({},t.formBox),{marginBottom:16}),children:[e.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#374151"},children:s("tnt_persona_title")}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,marginBottom:12},children:[e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:s("tnt_chatbot_name")}
3),e.jsx("input",{style:t.input,value:y.persona_name,onChange:a=>k(o=>h(r({},o),{persona_name:a.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:s("tnt_voice_label")}),e.jsx("select",{style:t.input,value:y.voice,onChange:a=>k(o=>h(r({},o),{voice:a.target.value})),children:Ce.map(a=>e.jsx("option",{value:a.value,children:a.labelKey?s(a.labelKey):a.label},a.value))})]})]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:t.label,children:s("tnt_greeting")}),e.jsx("input",{style:t.input,value:y.greeting,onChange:a=>k(o=>h(r({},o),{greeting:a.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:"System Prompt"}),e.jsx("textarea",{style:h(r({},t.input),{height:120,resize:"vertical",fontFamily:"monospace",fontSize:12}),value:y.system_prompt,onChange:a=>k(o=>h(r({},o),{system_prompt:a.target.value})),placeholder:s("tnt_system_prompt_ph")})]})]}),e.jsxs("div",{style:h(r({},t.formBox),{marginBottom:16}),children:[e.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#374151"},children:s("tnt_ai_tools_title")}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:Be.map(a=>{const o=y.tools[a.key];return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:8,border:`1px solid ${o?"#D6E0EA":"#e2e8f0"}`,background:o?"#F0F4F8":"#fff",cursor:"pointer",transition:"all 0.15s"},onClick:()=>b(a.key),children:[e.jsx("div",{style:{width:36,height:20,borderRadius:10,background:o?"#1B3A57":"#d1d5db",position:"relative",flexShrink:0,transition:"background 0.2s"},children:e.jsx("div",{style:{width:16,height:16,borderRadius:"50%",background:"#fff",position:"absolute",top:2,left:o?18:2,transition:"left 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#1e293b"},children:a.labelKey?s(a.labelKey):a.label}),e.jsx("div",{style:{fontSize:11,color:"#94a3b8"},children:a.descKey?s(a.descKey):a.desc})]})]},a.key)})})]}),e.jsxs("div",{style:h(r({},t.formBox),{marginBottom:16}),children:[e.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#374151"},children:s("tnt_widget_title")}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:s("tnt_primary_color")}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("input",{type:"color",value:y.widget_color,onChange:a=>k(o=>h(r({},o),{widget_color:a.target.value})),style:{width:40,height:32,border:"1px solid #d1d5db",borderRadius:6,cursor:"pointer",padding:2}}),e.jsx("input",{style:h(r({},t.input),{flex:1}),value:y.widget_color,onChange:a=>k(o=>h(r({},o),{widget_color:a.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:"Avatar URL"}),e.jsx("input",{style:t.input,value:y.avatar_url,onChange:a=>k(o=>h(r({},o),{avatar_url:a.target.value})),placeholder:"https://..."})]})]})]}),e.jsxs("div",{style:h(r({},t.formBox),{marginBottom:16}),children:[e.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#374151"},children:s("tnt_widget_preview")}),e.jsxs("div",{style:{maxWidth:320,background:"#f8fafc",borderRadius:16,border:"1px solid #e2e8f0",overflow:"hidden"},children:[e.jsxs("div",{style:{background:y.widget_color,padding:"14px 16px",display:"flex",alignItems:"center",gap:10},children:[y.avatar_url?e.jsx("img",{src:y.avatar_url,alt:"",style:{width:32,height:32,borderRadius:"50%",objectFit:"cover"}}):e.jsx("div",{style:{width:32,height:32,borderRadius:"50%",background:"rgba(255,255,255,0.3)",display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontWeight:700,fontSize:14},children:"AI"}),e.jsxs("div",{children:[e.jsx("div",{style:{color:"#fff",fontWeight:600,fontSize:14},children:y.persona_name}),e.jsx("div",{style:{color:"rgba(255,255,255,0.7)",fontSize:11},children:"Online"})]})]}),e.jsx("div",{style:{padding:16},children:e.jsx("div",{style:{background:"#fff",padding:"10px 14px",borderRadius:"4px 12px 12px 12px",fontSize:13,color:"#374151",maxWidth:"85%",border:"1px solid #e2e8f0"},children:y.greeting})}),e.jsxs("div",{style:{padding:"10px 16px",borderTop:"1px solid #e2e8f0",display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{style:{flex:1,padding:"8px 12px",borderRadius:20,background:"#fff",border:"1px solid #e2e8f0",fontSize:12,color:"#94a3b8"},children:s("tnt_type_message")}),e.jsx("div",{style:{width:32,height:32,borderRadius:"50%",background:y.widget_color,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:14},children:"➤"})]})]})]}),e.jsx("button",{style:t.btnPrimary,onClick:()=>g(y),disabled:l,children:s(l?"tnt_saving":"tnt_save_chatbot")})]})}function Fe({tenant:n,onSave:g,showMessage:l}){const{t:s}=Z(),d=n.integrations||{},[y,k]=m.useState(()=>{const j={};return ae.forEach(S=>{j[S.key]={},S.fields.forEach(p=>{j[S.key][p]=(d[S.key]||{})[p]||""}),j[S.key].status=(d[S.key]||{}).status||"disconnected",j[S.key].last_sync=(d[S.key]||{}).last_sync||null}),j}),[b,a]=m.useState("");m.useEffect(()=>{const j=n.integrations||{},S={};ae.forEach(p=>{S[p.key]={},p.fields.forEach(z=>{S[p.key][z]=(j[p.key]||{})[z]||""}),S[p.key].status=(j[p.key]||{}).status||"disconnected",S[p.key].last_sync=(j[p.key]||{}).last_sync||null}),k(S)},[n.id]);function o(j,S,p){k(z=>h(r({},z),{[j]:h(r({},z[j]),{[S]:p})}))}async function C(j){a(j);try{const S=await R(`${E}
3/api/tenants/${n.id}/integrations/${j}/sync`,{method:"POST"});if(S.ok){const p=await S.json();k(z=>h(r({},z),{[j]:h(r({},z[j]),{last_sync:p.synced_at||new Date().toISOString(),status:"connected"})})),l("success",s("tnt_sync_success").replace("{platform}",j))}else{const p=await S.json();l("error",p.error||s("tnt_error_sync"))}}catch(S){l("error",s("tnt_error_connection"))}finally{a("")}}function u(){const j={};ae.forEach(S=>{j[S.key]=r({},y[S.key])}),g(j)}const _={store:s("tnt_store_name"),api_key:"API Key",access_token:"Access Token",page_id:"Page ID",oa_id:"OA ID",refresh_token:"Refresh Token"};return e.jsxs("div",{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:16},children:ae.map(j=>{var p,z;const S=((p=y[j.key])==null?void 0:p.status)==="connected";return e.jsxs("div",{style:h(r({},t.card),{padding:16,marginBottom:0}),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:22},children:j.icon}),e.jsx("span",{style:{fontWeight:600,fontSize:14,color:"#1e293b"},children:j.name})]}),e.jsx("span",{style:h(r({},t.badge),{background:S?"#dcfce7":"#fee2e2",color:S?"#16a34a":"#ef4444"}),children:s(S?"tnt_connected":"tnt_not_connected")})]}),j.fields.map(W=>{var q;return e.jsxs("div",{style:{marginBottom:8},children:[e.jsx("label",{style:t.label,children:_[W]||W}),e.jsx("input",{style:t.input,value:((q=y[j.key])==null?void 0:q[W])||"",onChange:D=>o(j.key,W,D.target.value),type:W.includes("token")||W.includes("key")?"password":"text",placeholder:`${_[W]||W}...`})]},W)}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:12},children:[e.jsx("button",{style:h(r({},t.btnSmall),{background:"#F0F4F8",color:"#1B3A57",border:"1px solid #D6E0EA"}),onClick:()=>C(j.key),disabled:b===j.key,children:b===j.key?s("tnt_syncing"):s("tnt_sync_now")}),((z=y[j.key])==null?void 0:z.last_sync)&&e.jsxs("span",{style:{fontSize:11,color:"#94a3b8"},children:[s("tnt_last_sync")," ",Te(y[j.key].last_sync)]})]})]},j.key)})}),e.jsx("button",{style:t.btnPrimary,onClick:u,children:s("tnt_save_integrations")})]})}function Pe({tenant:n,onChangePlan:g,onExtend:l,submitting:s}){var T,M,B,$,V;const{t:d}=Z(),[y,k]=m.useState([]),[b,a]=m.useState([]),[o,C]=m.useState({total_paid:0,total_refunded:0}),[u,_]=m.useState({users:0,max_users:0,products:0,max_products:0,orders:0,max_orders:0,chatbot_messages:0,max_chatbot_messages:0}),[j,S]=m.useState(""),[p,z]=m.useState(1),[W,q]=m.useState(""),[D,J]=m.useState(n.subscription_seats==null||n.subscription_seats<0?"":String(n.subscription_seats));m.useEffect(()=>{U()},[n.id]),m.useEffect(()=>{J(n.subscription_seats==null||n.subscription_seats<0?"":String(n.subscription_seats))},[n.subscription_seats]);async function U(){try{const[f,L]=await Promise.all([R(`${E}/api/tenants/${n.id}/usage`),R(`${E}/api/payment/admin/tenants/${n.id}/history`)]);if(f.ok){const A=await f.json();_(A)}if(L.ok){const A=await L.json();k(A.invoices||[]),a(A.transactions||[]),C({total_paid:A.total_paid||0,total_refunded:A.total_refunded||0})}else{const A=await R(`${E}/api/tenants/${n.id}/invoices`);if(A.ok){const O=await A.json();k(Array.isArray(O)?O:O.invoices||[])}}}catch(f){console.error("Failed to load billing:",f)}}const H={free:{price:0,label:"Miễn phí",users:5,products:200,orders:50,messages:100,perUser:!1},pro:{price:199e3,label:"Pro",users:-1,products:-1,orders:-1,messages:5e3,perUser:!0},enterprise:{price:299e3,label:"Enterprise",users:-1,products:-1,orders:-1,messages:2e4,perUser:!0},trial:{price:0,label:"Trial (cũ)",users:2,products:200,orders:50,messages:100,perUser:!1},basic:{price:199e3,label:"Basic (cũ)",users:-1,products:-1,orders:-1,messages:5e3,perUser:!0},starter:{price:199e3,label:"Starter (cũ)",users:-1,products:-1,orders:-1,messages:5e3,perUser:!0},business:{price:199e3,label:"Business (cũ)",users:-1,products:-1,orders:-1,messages:5e3,perUser:!0},professional:{price:299e3,label:"Professional (cũ)",users:-1,products:-1,orders:-1,messages:2e4,perUser:!0},custom:{price:299e3,label:"Custom (cũ)",users:-1,products:-1,orders:-1,messages:-1,perUser:!0}},G=n.subscription_expires_at||n.plan_expires_at,N=G?Math.ceil((new Date(G)-new Date)/864e5):null,ee=N==null?"#94a3b8":N<=7?"#dc2626":N<=30?"#d97706":"#16a34a",Q=N==null?"#f1f5f9":N<=7?"#fee2e2":N<=30?"#fef3c7":"#dcfce7";function c({label:f,current:L,max:A}){const O=A<=0?0:Math.min(L/A*100,100),w=A===-1,se=!w&&O>80;return e.jsxs("div",{style:{marginBottom:12},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:4},children:[e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:f}),e.jsxs("span",{style:{fontSize:12,color:se?"#ef4444":"#64748b"}
3,children:[L.toLocaleString("vi-VN")," / ",w?d("tnt_unlimited"):A.toLocaleString("vi-VN")]})]}),e.jsx("div",{style:{height:6,background:"#e2e8f0",borderRadius:3,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:3,width:w?"10%":`${O}%`,background:se?"#ef4444":w?"#22c55e":"#1B3A57",transition:"width 0.3s"}})})]})}return e.jsxs("div",{children:[e.jsxs("div",{style:h(r({},t.formBox),{marginBottom:16}),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12,flexWrap:"wrap",gap:8},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{margin:"0 0 4px",fontSize:14,fontWeight:600,color:"#374151"},children:d("tnt_current_plan_title")}),e.jsx(ne,{value:n.plan,items:Y}),e.jsx("span",{style:{fontSize:13,color:"#64748b",marginLeft:8},children:((T=H[n.plan])==null?void 0:T.label)||""})]}),e.jsx("div",{style:{padding:"6px 12px",borderRadius:8,background:Q,color:ee,fontSize:13,fontWeight:600,display:"flex",alignItems:"center",gap:6},children:G?e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"📅"}),e.jsxs("span",{children:["Hạn: ",new Date(G).toLocaleDateString("vi-VN",{day:"2-digit",month:"2-digit",year:"numeric"}),N!=null&&e.jsxs("span",{style:{marginLeft:6,opacity:.85},children:["(",N>0?`còn ${N} ngày`:N===0?"hết hạn hôm nay":`quá hạn ${-N} ngày`,")"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"⚠️"}),e.jsx("span",{children:'Chưa có thời hạn — cần đổi gói qua nút "Chọn gói" để tạo subscription'})]})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsxs("select",{value:p,onChange:f=>z(Number(f.currentTarget.value)),style:h(r({},t.input),{width:"auto",padding:"6px 8px",fontSize:13}),disabled:s,children:[e.jsx("option",{value:1,children:"1 tháng"}),e.jsx("option",{value:3,children:"3 tháng"}),e.jsx("option",{value:6,children:"6 tháng"}),e.jsx("option",{value:12,children:"12 tháng"})]}),e.jsx("button",{onClick:()=>l&&l({months:p}),disabled:s,style:{padding:"7px 14px",borderRadius:8,border:"none",background:s?"#86efac":"#16a34a",color:"#fff",fontSize:13,fontWeight:600,cursor:s?"default":"pointer",whiteSpace:"nowrap"},children:s?"Đang gia hạn…":"+ Gia hạn"}),e.jsx("span",{style:{fontSize:12,color:"#94a3b8"},children:"hoặc"}),e.jsx("input",{type:"date",value:W,onChange:f=>q(f.currentTarget.value),style:h(r({},t.input),{width:"auto",padding:"6px 8px",fontSize:13}),disabled:s}),e.jsx("button",{onClick:()=>W&&l&&l({expiresAt:W}),disabled:s||!W,style:{padding:"7px 14px",borderRadius:8,border:"1px solid #cbd5e1",background:"#fff",color:"#334155",fontSize:13,fontWeight:600,cursor:s||!W?"default":"pointer",opacity:s||!W?.5:1,whiteSpace:"nowrap"},children:"Đặt hạn"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap",marginTop:10},children:[e.jsx("span",{style:{fontSize:13,fontWeight:600,color:"#334155"},children:"👤 Số người dùng:"}),e.jsx(we,{min:1,value:D,onChange:f=>J(f.currentTarget.value),placeholder:"theo gói",style:h(r({},t.input),{width:90,padding:"6px 8px",fontSize:13}),disabled:s}),e.jsx("button",{onClick:()=>{const f=parseInt(D,10);isNaN(f)||f<1||l&&l({seats:f})},disabled:s||!D,style:{padding:"7px 14px",borderRadius:8,border:"none",background:s||!D?"#93c5fd":"#2563eb",color:"#fff",fontSize:13,fontWeight:600,cursor:s||!D?"default":"pointer",opacity:s||!D?.6:1,whiteSpace:"nowrap"},children:"Lưu số người dùng"}),e.jsx("button",{onClick:()=>l&&l({seats:-1}),disabled:s,style:{padding:"7px 12px",borderRadius:8,border:"1px solid #cbd5e1",background:"#fff",color:"#334155",fontSize:13,fontWeight:600,cursor:s?"default":"pointer",whiteSpace:"nowrap"},children:"∞ Không giới hạn"}),e.jsx("span",{style:{fontSize:12,color:"#94a3b8"},children:n.subscription_seats==null?"Hiện: theo giới hạn gói":n.subscription_seats===-1?"Hiện: không giới hạn":`Hiện: ${n.subscription_seats} người`})]})]}),e.jsx(c,{label:d("tnt_usage_users"),current:u.users,max:u.max_users||((M=H[n.plan])==null?void 0:M.users)||0}),e.jsx(c,{label:d("tnt_usage_products"),current:u.products,max:u.max_products||((B=H[n.plan])==null?void 0:B.products)||0}),e.jsx(c,{label:d("tnt_usage_orders"),current:u.orders,max:u.max_orders||(($=H[n.plan])==null?void 0:$.orders)||0}),e.jsx(c,{label:d("tnt_usage_messages"),current:u.chatbot_messages,max:u.max_chatbot_messages||((V=H[n.plan])==null?void 0:V.messages)||0})]}),e.jsx("div",{style:h(r({},t.card),{marginBottom:16,padding:0,overflow:"hidden"}),children:e.jsxs("table",{style:t.table,children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f8fafc"},children:[e.jsx("th",{style:t.th,children:d("tnt_feature")}),te.map(f=>e.jsx("th",{style:h(r({},t.th),{textAlign:"center"}),children:e.jsx(ne,{value:f.value,items:Y})},f.value))]})}),e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("td",{style:t.td,children:d("tnt_price_monthly")}),te.map(f=>{var L,A,O;return e.jsx("td",{style:h(r({},t.td),{textAlign:"center",fontWeight:600}),children:((L=H[f.value])==null?void 0:L.price)===0?d("tnt_free"):((A=H[f.value])==null?void 0:A.price.toLocaleStr
3ing("vi-VN"))+((O=H[f.value])!=null&&O.perUser?" ₫/user":" ₫")},f.value)})]}),[{labelKey:"tnt_usage_users",key:"users"},{labelKey:"tnt_usage_products",key:"products"},{labelKey:"tnt_orders_monthly",key:"orders"},{labelKey:"tnt_usage_messages",key:"messages"}].map(f=>e.jsxs("tr",{children:[e.jsx("td",{style:t.td,children:f.labelKey?d(f.labelKey):f.label}),te.map(L=>{var A,O,w;return e.jsx("td",{style:h(r({},t.td),{textAlign:"center"}),children:((A=H[L.value])==null?void 0:A[f.key])===-1?"∞":(w=(O=H[L.value])==null?void 0:O[f.key])==null?void 0:w.toLocaleString("vi-VN")},L.value)})]},f.key)),e.jsxs("tr",{children:[e.jsx("td",{style:t.td,children:"Modules"}),te.map(f=>e.jsx("td",{style:h(r({},t.td),{textAlign:"center"}),children:(de[f.value]||[]).length},f.value))]}),e.jsxs("tr",{children:[e.jsx("td",{style:t.td}),te.map(f=>e.jsx("td",{style:h(r({},t.td),{textAlign:"center"}),children:n.plan===f.value?e.jsx("span",{style:h(r({},t.badge),{background:"#dcfce7",color:"#16a34a"}),children:d("tnt_current")}):e.jsx("button",{style:h(r({},t.btnSmall),{background:"#F0F4F8",color:"#1B3A57",border:"1px solid #D6E0EA",fontWeight:600}),onClick:()=>{S(f.value),g(f.value)},disabled:s,children:s&&j===f.value?d("tnt_changing_plan"):d("tnt_select_plan")})},f.value))]})]})]})}),e.jsxs("div",{style:{display:"flex",gap:12,marginBottom:12,flexWrap:"wrap"},children:[e.jsxs("div",{style:{flex:1,minWidth:180,background:"#dcfce7",border:"1px solid #86efac",borderRadius:10,padding:14},children:[e.jsx("div",{style:{fontSize:12,color:"#166534",fontWeight:600},children:"💰 Tổng đã thanh toán"}),e.jsxs("div",{style:{fontSize:22,fontWeight:800,color:"#15803d",marginTop:4},children:[(o.total_paid||0).toLocaleString("vi-VN")," ₫"]})]}),e.jsxs("div",{style:{flex:1,minWidth:180,background:"#fee2e2",border:"1px solid #fca5a5",borderRadius:10,padding:14},children:[e.jsx("div",{style:{fontSize:12,color:"#991b1b",fontWeight:600},children:"↩ Tổng đã hoàn tiền"}),e.jsxs("div",{style:{fontSize:22,fontWeight:800,color:"#dc2626",marginTop:4},children:[(o.total_refunded||0).toLocaleString("vi-VN")," ₫"]})]}),e.jsxs("div",{style:{flex:1,minWidth:180,background:"#D6E0EA",border:"1px solid #D6E0EA",borderRadius:10,padding:14},children:[e.jsx("div",{style:{fontSize:12,color:"#163049",fontWeight:600},children:"📊 Doanh thu thực"}),e.jsxs("div",{style:{fontSize:22,fontWeight:800,color:"#1B3A57",marginTop:4},children:[((o.total_paid||0)-(o.total_refunded||0)).toLocaleString("vi-VN")," ₫"]})]})]}),e.jsxs("div",{style:t.card,children:[e.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#374151"},children:d("tnt_invoice_history")}),y.length===0?e.jsx("div",{style:{textAlign:"center",color:"#94a3b8",padding:"var(--card-pad, 20px)",fontSize:13},children:d("tnt_no_invoices")}):e.jsxs("table",{style:t.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.th,children:d("tnt_invoice_code")}),e.jsx("th",{style:t.th,children:d("tnt_invoice_date")}),e.jsx("th",{style:t.th,children:d("tnt_invoice_amount")}),e.jsx("th",{style:t.th,children:d("tnt_invoice_status")}),e.jsx("th",{style:t.th,children:"Người xử lý"}),e.jsx("th",{style:t.th,children:"Ghi chú"})]})}),e.jsx("tbody",{children:y.map((f,L)=>{const A={paid:"✓ Đã thanh toán",pending:"⏳ Chờ thanh toán",cancelled:"✗ Đã hủy",refunded:"↩ Hoàn tiền"},w={paid:{bg:"#dcfce7",fg:"#16a34a"},pending:{bg:"#fef3c7",fg:"#d97706"},cancelled:{bg:"#e2e8f0",fg:"#475569"},refunded:{bg:"#fee2e2",fg:"#dc2626"}}[f.status]||{bg:"#f1f5f9",fg:"#64748b"};return e.jsxs("tr",{children:[e.jsx("td",{style:t.td,children:e.jsx("span",{style:{fontWeight:600,fontFamily:"monospace"},children:f.invoice_code||`INV-${L+1}`})}),e.jsx("td",{style:t.td,children:ce(f.created_at)}),e.jsxs("td",{style:t.td,children:[(f.total||f.amount||0).toLocaleString("vi-VN")," ₫"]}),e.jsx("td",{style:t.td,children:e.jsx("span",{style:h(r({},t.badge),{background:w.bg,color:w.fg}),children:A[f.status]||f.status})}),e.jsxs("td",{style:t.td,children:[e.jsx("span",{style:{fontSize:12,color:"#64748b"},children:f.processed_by_username||"—"}
3),f.last_action&&e.jsx("div",{style:{fontSize:10,color:"#94a3b8"},children:f.last_action})]}),e.jsx("td",{style:t.td,title:f.processed_reason||"",children:e.jsx("span",{style:{fontSize:12,color:"#64748b",fontStyle:"italic"},children:f.processed_reason?f.processed_reason.slice(0,50)+(f.processed_reason.length>50?"...":""):"—"})})]},f.id||L)})})]})]}),b.length>0&&e.jsxs("div",{style:h(r({},t.card),{marginTop:12}),children:[e.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#374151"},children:"💸 Giao dịch ngân hàng đã khớp"}),e.jsxs("table",{style:t.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.th,children:"Thời gian"}),e.jsx("th",{style:t.th,children:"Ngân hàng"}),e.jsx("th",{style:t.th,children:"Số tiền"}),e.jsx("th",{style:t.th,children:"Nội dung"})]})}),e.jsx("tbody",{children:b.map(f=>e.jsxs("tr",{children:[e.jsx("td",{style:t.td,children:ce(f.created_at)}),e.jsx("td",{style:t.td,children:f.bank_name||"—"}),e.jsx("td",{style:t.td,children:e.jsxs("span",{style:{color:"#16a34a",fontWeight:600},children:["+",Number(f.amount||0).toLocaleString("vi-VN")," ₫"]})}),e.jsx("td",{style:t.td,children:e.jsx("span",{style:{fontFamily:"monospace",fontSize:12},children:f.description||"—"})})]},f.id))})]})]})]})}function Ne({onClose:n,onCreated:g,showMessage:l}){const{t:s}=Z(),[d,y]=m.useState({code:"",name:"",domain:"",industry:"",plan:"trial",owner_name:"",owner_email:"",owner_phone:""}),[k,b]=m.useState(!1),[a,o]=m.useState(null);async function C(){if(!d.code||!d.name){l("error",s("tnt_required_code_name"));return}if(!d.owner_name||!d.owner_email){l("error",s("tnt_required_owner"));return}b(!0);try{const u=await R(`${E}/api/tenants`,{method:"POST",body:JSON.stringify(d)}),_=await u.json();if(u.ok){const j=_.admin_credentials||_.credentials;j?o(h(r({},j),{tenant:_.tenant})):g(_.tenant||_)}else l("error",_.error||s("tnt_error_create"))}catch(u){l("error",s("tnt_error_connection"))}finally{b(!1)}}return e.jsx("div",{style:t.overlay,onClick:n,children:e.jsxs("div",{style:t.modal,onClick:u=>u.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[e.jsx("h3",{style:{margin:0,fontSize:16,color:"#1e293b"},children:s("tnt_create_title")}),e.jsx("button",{style:h(r({},t.btnSmall),{fontSize:16,padding:"4px 8px"}),onClick:n,children:"✕"})]}),a?e.jsxs("div",{children:[e.jsxs("div",{style:{background:"#dcfce7",padding:16,borderRadius:8,marginBottom:16,border:"1px solid #bbf7d0"},children:[e.jsx("div",{style:{fontWeight:700,color:"#16a34a",marginBottom:8,fontSize:14},children:s("tnt_created_success")}),e.jsx("div",{style:{fontSize:13,color:"#374151",marginBottom:4},children:s("tnt_login_info")})]}),e.jsxs("div",{style:h(r({},t.formBox),{marginBottom:16}),children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:"Username"}),e.jsx("div",{style:h(r({},t.input),{background:"#f8fafc",fontWeight:600,fontFamily:"monospace",display:"flex",alignItems:"center"}),children:a.username})]}),e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:"Password"}),e.jsx("div",{style:h(r({},t.input),{background:"#f8fafc",fontWeight:600,fontFamily:"monospace",display:"flex",alignItems:"center"}),children:a.password})]})]}),e.jsx("div",{style:{marginTop:8,fontSize:12,color:"#ef4444",fontWeight:500},children:s("tnt_save_warning")})]}),e.jsx("button",{style:t.btnPrimary,onClick:()=>{g(a.tenant||h(r({},d),{id:a.tenant_id}))},children:s("tnt_saved_close")})]}):e.jsxs("div",{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,marginBottom:16},children:[e.jsxs("div",{children:[e.jsxs("label",{style:t.label,children:[s("tnt_label_code")," *"]}),e.jsx("input",{style:t.input,value:d.code,onChange:u=>y(_=>h(r({},_),{code:u.target.value})),placeholder:"vd: acme-corp"})]}),e.jsxs("div",{children:[e.jsxs("label",{style:t.label,children:[s("tnt_label_name")," *"]}),e.jsx("input",{style:t.input,value:d.name,onChange:u=>y(_=>h(r({},_),{name:u.target.value})),placeholder:"vd: ACME Corporation"})]}),e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:"Domain"}),e.jsx("input",{style:t.input,value:d.domain,onChange:u=>y(_=>h(r({},_),{domain:u.target.value})),placeholder:"vd: acme.tbbv.vn"})]}),e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:s("tnt_label_industry")}),e.jsxs("select",{style:t.input,value:d.industry,onChange:u=>y(_=>h(r({},_),{industry:u.target.value})),children:[e.jsx("option",{value:"",children:s("tnt_select_industry")}),he.map(u=>e.jsx("option",{value:u.value,children:u.labelKey?s(u.labelKey):u.label},u.value))]})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("label",{style:t.label,children:s("tnt_label_plan")}),e.jsx("div",{style:{display:"flex",gap:8},children:te.map(u=>e.jsx("button",{onClick:()=>y(_=>h(r({},_),{plan:u.value})),style:{flex:1,padding:"10px 8px",borderRadius:8,border:`2px solid ${d.plan===u.value?u.color:"#e2e8f0"}`,background:d.plan===u.value?u.bg:"#fff",color:d.plan===u.value?u.color:"#64748b",fontWeight:600,fontSize:13,cursor:"pointer",fontFamily:"inherit",transition:"all 0.15s"},children:u.label},u.value))})]})]}),e.jsxs("div",{style:h(r({},t.formBox),{marginBottom:16}),children:[e.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#374151"},children:s("tnt_owner_title")}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsxs("label",{style:t.label,children:[s("tnt_label_fullname")," *"]}),e.jsx("input",{style:t.input,value:d.owner_name,onChange:u=>y(_=>h(r({},_),{owner_name:u.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:"Email *"}),e.jsx("input",{style:t.input,type:"email",value:d.owner_email,onChange:u=>y(_=>h(r({},_),{owner_email:u.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{style:t.label,children:s("tnt_label_phone")}),e.jsx("input",{style:t.input,value:d.owner_phone,onChange:u=>y(_=>h(r({},_),{owner_phone:u.target.value}))})]})]})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{style:t.btnPrimary,onClick:C,disabled:k,children:s(k?"tnt_creating":"tnt_create_btn")}),e.jsx("button",{style:t.btnSecondary,onClick:n,children:s("cancel")})]})]})]})})}const t={card:{background:"#fff",borderRadius:12,padding:"var(--card-pad, 20px)",marginBottom:20,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},formBox:{background:"#f8fafc",borderRadius:8,padding:16,border:"1px solid #e2e8f0"},label:{display:"block",fontSize:12,fontWeight:600,color:"#64748b",marginBottom:4},input:{width:"100%",padding:"8px 12px",borderRadius:6,border:"1px solid #d1d5db",fontSize:13,outline:"none",fontFamily:"inherit",boxSizing:"border-box"},btnPrimary:{padding:"8px 18px",borderRadius:6,border:"none",background:"#1B3A57",color:"#fff",fontSize:13,fontWeight:600,cursor:"pointer",fontFamily:"inherit"},btnSecondary:{padding:"8px 18px",borderRadius:6,border:"1px solid #d1d5db",background:"#fff",color:"#374151",fontSize:13,cursor:"pointer",fontFamily:"inherit"},btnSmall:{padding:"4px 10px",borderRadius:4,border:"1px solid #d1d5db",background:"#fff",fontSize:12,cursor:"pointer",fontFamily:"inherit"},badge:{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,whiteSpace:"nowrap",display:"inline-block"},table:{width:"100%",borderCollapse:"collapse"},th:{textAlign:"left",padding:"10px 12px",fontSize:11,fontWeight:600,color:"#64748b",borderBottom:"1px solid #e2e8f0",textTransform:"uppercase"},td:{padding:"10px 12px",fontSize:13,borderBottom:"1px solid #f1f5f9"},overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},modal:{background:"#fff",borderRadius:16,padding:24,width:"90%",maxWidth:640,maxHeight:"calc(var(--app-vh) * 0.90)",overflowY:"auto",boxShadow:"0 20px 60px rgba(0,0,0,0.15)"}};function $e({tenant:n}){var S;const{t:g}=Z(),[l,s]=m.useState(null),[d,y]=m.useState(!0),[k,b]=m.useState(30);if(m.useEffect(()=>{n!=null&&n.id&&(y(!0),R(`${E}
3/api/tenants/${n.id}/analytics?days=${k}`).then(p=>p.json()).then(p=>{s(p),y(!1)}).catch(()=>y(!1)))},[n==null?void 0:n.id,k]),d)return e.jsx("div",{style:{padding:"var(--card-pad, 20px)",color:"#64748b"},children:g("tnt_analytics_loading")});if(!l)return e.jsx("div",{style:{padding:"var(--card-pad, 20px)",color:"#ef4444"},children:g("tnt_analytics_error")});const{live:a,modules:o,history:C}=l,u=[{key:"users",labelKey:"tnt_analytics_users",icon:"👥",color:"#1B3A57"},{key:"active_users",labelKey:"tnt_analytics_active",icon:"🟢",color:"#16a34a"},{key:"customers",labelKey:"tnt_analytics_customers",icon:"🤝",color:"#1B3A57"},{key:"orders",labelKey:"tnt_analytics_orders",icon:"🛒",color:"#ea580c"},{key:"revenue",labelKey:"tnt_analytics_revenue",icon:"💰",color:"#d97706",format:p=>p.toLocaleString("vi-VN")+"đ"},{key:"products",labelKey:"tnt_analytics_products",icon:"📦",color:"#0d9488"},{key:"videos",label:"Video",icon:"🎬",color:"#e11d48"},{key:"modules_enabled",labelKey:"tnt_analytics_modules",icon:"🧩",color:"#1B3A57"}],_={};for(const p of C){const z=((S=p.recorded_at)==null?void 0:S.split("T")[0])||p.recorded_at;_[z]||(_[z]={}),_[z][p.metric_key]=p.metric_value}const j=Object.keys(_).sort();return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[e.jsxs("h4",{style:{margin:0,fontSize:15,fontWeight:700,color:"#1e293b"},children:[g("tnt_analytics_title")," — ",l.tenant_name]}),e.jsx("div",{style:{display:"flex",gap:4},children:[7,30,90].map(p=>e.jsx("button",{onClick:()=>b(p),style:{padding:"4px 12px",borderRadius:6,border:"none",fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:"inherit",background:k===p?"#1B3A57":"#f1f5f9",color:k===p?"#fff":"#64748b"},children:g("tnt_analytics_days").replace("{d}",p)},p))})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:10,marginBottom:20},children:u.map(p=>e.jsx("div",{style:{padding:14,background:"#fff",border:"1px solid #e2e8f0",borderRadius:10,borderLeft:`3px solid ${p.color}`},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,color:"#64748b",fontWeight:600,marginBottom:4},children:p.labelKey?g(p.labelKey):p.label}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:p.color},children:p.format?p.format(a[p.key]||0):a[p.key]||0})]}),e.jsx("div",{style:{fontSize:24,opacity:.6},children:p.icon})]})},p.key))}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("h4",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:8},children:g("tnt_modules_enabled")}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:[o.filter(p=>p.is_enabled).map(p=>e.jsx("span",{style:{padding:"4px 10px",background:"#D6E0EA",color:"#1B3A57",borderRadius:6,fontSize:12,fontWeight:600},children:p.module_code},p.module_code)),o.filter(p=>p.is_enabled).length===0&&e.jsx("span",{style:{color:"#94a3b8",fontSize:13},children:g("tnt_no_modules")})]})]}),j.length>0&&e.jsxs("div",{children:[e.jsx("h4",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:8},children:g("tnt_usage_history")}),e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f8fafc"},children:[e.jsx("th",{style:t.th,children:g("tnt_invoice_date")}),e.jsx("th",{style:t.th,children:"Users"}),e.jsx("th",{style:t.th,children:g("tnt_analytics_customers")}),e.jsx("th",{style:t.th,children:g("tnt_analytics_orders")}),e.jsx("th",{style:t.th,children:g("tnt_analytics_revenue")}),e.jsx("th",{style:t.th,children:g("tnt_analytics_products")}),e.jsx("th",{style:t.th,children:"Video"})]})}),e.jsx("tbody",{children:j.slice(-15).reverse().map(p=>e.jsxs("tr",{children:[e.jsx("td",{style:t.td,children:p}),e.jsx("td",{style:t.td,children:_[p].users||0}),e.jsx("td",{style:t.td,children:_[p].customers||0}),e.jsx("td",{style:t.td,children:_[p].orders||0}),e.jsxs("td",{style:t.td,children:[(_[p].revenue||0).toLocaleStr
3ing("vi-VN"),"đ"]}),e.jsx("td",{style:t.td,children:_[p].products||0}),e.jsx("td",{style:t.td,children:_[p].videos||0})]},p))})]})})]}),j.length===0&&e.jsx("div",{style:{padding:24,textAlign:"center",color:"#94a3b8",background:"#f8fafc",borderRadius:10},children:g("tnt_no_history")})]})}export{Ve as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.