(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9674],{15429:function(e,t,s){Promise.resolve().then(s.bind(s,24540))},87461:function(e,t,s){"use strict";s.d(t,{Z:function(){return i}});var r=s(64090),n={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
 * @license lucide-react v0.344.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),i=(e,t)=>{let s=(0,r.forwardRef)((s,i)=>{let{color:l="currentColor",size:d=24,strokeWidth:c=2,absoluteStrokeWidth:o,className:x="",children:m,...h}=s;return(0,r.createElement)("svg",{ref:i,...n,width:d,height:d,stroke:l,strokeWidth:o?24*Number(c)/Number(d):c,className:["lucide","lucide-".concat(a(e)),x].join(" "),...h},[...t.map(e=>{let[t,s]=e;return(0,r.createElement)(t,s)}),...Array.isArray(m)?m:[m]])});return s.displayName="".concat(e),s}},99325:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});/**
 * @license lucide-react v0.344.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let r=(0,s(87461).Z)("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]])},46578:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});/**
 * @license lucide-react v0.344.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let r=(0,s(87461).Z)("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},44715:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});/**
 * @license lucide-react v0.344.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let r=(0,s(87461).Z)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]])},18994:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});/**
 * @license lucide-react v0.344.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let r=(0,s(87461).Z)("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},28670:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});/**
 * @license lucide-react v0.344.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let r=(0,s(87461).Z)("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]])},77326:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});/**
 * @license lucide-react v0.344.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let r=(0,s(87461).Z)("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]])},50489:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});/**
 * @license lucide-react v0.344.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let r=(0,s(87461).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},24540:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return g}});var r=s(3827),n=s(64090),a=s(89966),i=s(71774),l=s(44715),d=s(28670),c=s(18994),o=s(77326);/**
 * @license lucide-react v0.344.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let x=(0,s(87461).Z)("ShieldOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);var m=s(99325),h=s(46578),u=s(50489),p=s(22169);function g(){let{lang:e}=(0,i.Z)(),t="ar"===e,[s,g]=(0,n.useState)(""),[y,j]=(0,n.useState)(""),[f,N]=(0,n.useState)(null),[b,v]=(0,n.useState)(""),[w,k]=(0,n.useState)(null),[C,Z]=(0,n.useState)(""),S=y?"/api/admin/users?search=".concat(encodeURIComponent(y)):"/api/admin/users",{data:E=[],isLoading:A,mutate:M}=(0,a.ZP)(S),D=()=>j(s),F=async(e,t)=>{let s=await fetch("/api/admin/users",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,...t})});if(s.ok)await M(void 0,{revalidate:!0});else{let e=await s.json();alert(e.error||"Failed")}},I=e=>{e.suspended?F(e.id,{suspended:!1}):(k(e),Z(""))},L=async()=>{w&&(await F(w.id,{suspended:!0,reason:C||void 0}),k(null),Z(""))},P=async e=>{if(!confirm(t?"هل أنت متأكد من حذف هذا المستخدم نهائياً؟":"Permanently delete this user?"))return;let s=await fetch("/api/admin/users?userId=".concat(e),{method:"DELETE"});if(s.ok)M();else{let e=await s.json();alert(e.error||"Failed")}},R=async e=>{let t=parseInt(b);isNaN(t)||t<0||(await F(e,{pagesLimit:t}),N(null))};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-2xl font-bold text-white",children:t?"إدارة المستخدمين":"Users Management"}),(0,r.jsx)("p",{className:"text-sm text-gray-400",children:t?"".concat(E.length," مستخدم"):"".concat(E.length," users")})]}),(0,r.jsxs)("a",{href:"/api/admin/export?type=users",className:"flex items-center gap-2 px-4 py-2 text-sm border rounded-lg border-white/[0.1] text-gray-400 hover:text-white hover:bg-white/[0.06] transition-colors",children:[(0,r.jsx)(l.Z,{className:"h-4 w-4"}),t?"تصدير CSV":"Export CSV"]})]}),(0,r.jsxs)("div",{className:"flex gap-2 mb-6",children:[(0,r.jsxs)("div",{className:"relative flex-1 max-w-md",children:[(0,r.jsx)(d.Z,{className:"absolute ".concat(t?"right-3":"left-3"," top-1/2 -translate-y-1/2 h-4 w-4 text-gray-500")}),(0,r.jsx)("input",{type:"text",value:s,onChange:e=>g(e.target.value),onKeyDown:e=>"Enter"===e.key&&D(),placeholder:t?"بحث بالاسم أو الإيميل...":"Search by name or email...",className:"w-full ".concat(t?"pr-10 pl-4":"pl-10 pr-4"," py-2 border rounded-lg text-sm bg-white/[0.03] border-white/[0.08] text-white placeholder:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/30 focus:border-indigo-500/30")})]}),(0,r.jsx)("button",{onClick:D,className:"px-4 py-2 bg-indigo-500 text-white rounded-lg text-sm font-medium hover:bg-indigo-400 transition-colors",children:t?"بحث":"Search"})]}),A?(0,r.jsx)("div",{className:"flex justify-center py-12",children:(0,r.jsx)(c.Z,{className:"h-8 w-8 animate-spin text-gray-500"})}):0===E.length?(0,r.jsx)("div",{className:"rounded-2xl border border-white/[0.06] bg-white/[0.03] overflow-hidden",children:(0,r.jsx)("div",{className:"text-center py-12 text-gray-500",children:t?"لا يوجد مستخدمون":"No users found"})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"hidden md:block rounded-2xl border border-white/[0.06] bg-white/[0.03] overflow-hidden",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"bg-white/[0.03] ".concat(t?"text-right":"text-left"),children:[(0,r.jsx)("th",{className:"py-3 px-4 font-medium text-gray-400",children:t?"المستخدم":"User"}),(0,r.jsx)("th",{className:"py-3 px-4 font-medium text-gray-400",children:t?"الخطة":"Plan"}),(0,r.jsx)("th",{className:"py-3 px-4 font-medium text-gray-400",children:t?"الصلاحية":"Role"}),(0,r.jsx)("th",{className:"py-3 px-4 font-medium text-gray-400",children:t?"حد الصفحات":"Pages Limit"}),(0,r.jsx)("th",{className:"py-3 px-4 font-medium text-gray-400",children:t?"الصفحات":"Pages"}),(0,r.jsx)("th",{className:"py-3 px-4 font-medium text-gray-400",children:t?"الحالة":"Status"}),(0,r.jsx)("th",{className:"py-3 px-4 font-medium text-gray-400",children:t?"انضم":"Joined"}),(0,r.jsx)("th",{className:"py-3 px-4 font-medium text-gray-400",children:t?"إجراءات":"Actions"})]})}),(0,r.jsx)("tbody",{children:E.map(e=>(0,r.jsxs)("tr",{className:"border-t border-white/[0.04] hover:bg-white/[0.02] transition-colors",children:[(0,r.jsxs)("td",{className:"py-3 px-4",children:[(0,r.jsx)("div",{className:"font-medium text-white",children:e.name||"—"}),(0,r.jsx)("div",{className:"text-xs text-gray-500",children:e.email})]}),(0,r.jsx)("td",{className:"py-3 px-4",children:(0,r.jsxs)("select",{value:e.plan,onChange:t=>F(e.id,{plan:t.target.value}),className:"text-xs border rounded px-2 py-1 bg-[#12121f] border-white/[0.1] text-gray-300 cursor-pointer",children:[(0,r.jsx)("option",{value:"FREE",children:"Free"}),(0,r.jsx)("option",{value:"PRO",children:"Pro"}),(0,r.jsx)("option",{value:"BUSINESS",children:"Business"})]})}),(0,r.jsx)("td",{className:"py-3 px-4",children:(0,r.jsxs)("button",{onClick:()=>F(e.id,{role:"ADMIN"===e.role?"USER":"ADMIN"}),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium transition-colors ".concat("ADMIN"===e.role?"bg-purple-500/10 text-purple-400 hover:bg-purple-500/20":"bg-white/[0.05] text-gray-400 hover:bg-white/[0.08]"),children:["ADMIN"===e.role?(0,r.jsx)(o.Z,{className:"h-3 w-3"}):(0,r.jsx)(x,{className:"h-3 w-3"}),e.role]})}),(0,r.jsx)("td",{className:"py-3 px-4",children:f===e.id?(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("input",{type:"number",value:b,onChange:e=>v(e.target.value),onKeyDown:t=>"Enter"===t.key&&R(e.id),className:"w-16 border rounded px-1 py-0.5 text-xs bg-[#12121f] border-white/[0.1] text-white",autoFocus:!0}),(0,r.jsx)("button",{onClick:()=>R(e.id),className:"text-xs text-green-400 font-medium",children:"✓"}),(0,r.jsx)("button",{onClick:()=>N(null),className:"text-xs text-gray-500",children:"✕"})]}):(0,r.jsx)("button",{onClick:()=>{N(e.id),v(String(e.pagesLimit))},className:"text-sm text-cyan-400 hover:underline cursor-pointer font-medium",children:e.pagesLimit})}),(0,r.jsx)("td",{className:"py-3 px-4 text-gray-400",children:e._count.pages}),(0,r.jsx)("td",{className:"py-3 px-4",children:(0,r.jsx)("button",{onClick:()=>I(e),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium transition-colors ".concat(e.suspended?"bg-red-500/10 text-red-400 hover:bg-red-500/20":"bg-green-500/10 text-green-400 hover:bg-green-500/20"),children:e.suspended?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(m.Z,{className:"h-3 w-3"}),t?"محظور":"Suspended"]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(h.Z,{className:"h-3 w-3"}),t?"نشط":"Active"]})})}),(0,r.jsx)("td",{className:"py-3 px-4 text-xs text-gray-500",children:(0,p.p)(e.createdAt)}),(0,r.jsx)("td",{className:"py-3 px-4",children:(0,r.jsx)("button",{onClick:()=>P(e.id),className:"p-1.5 rounded-md text-red-400 hover:bg-red-500/[0.08] hover:text-red-300 transition-colors",title:t?"حذف":"Delete",children:(0,r.jsx)(u.Z,{className:"h-4 w-4"})})})]},e.id))})]})})}),(0,r.jsx)("div",{className:"md:hidden space-y-3",children:E.map(e=>(0,r.jsxs)("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.03] p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:"font-medium text-white truncate",children:e.name||"—"}),(0,r.jsx)("div",{className:"text-xs text-gray-500 truncate",children:e.email})]}),(0,r.jsx)("button",{onClick:()=>P(e.id),className:"p-1.5 rounded-md text-red-400 hover:bg-red-500/[0.08] shrink-0",children:(0,r.jsx)(u.Z,{className:"h-4 w-4"})})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-gray-500 text-xs",children:t?"الخطة":"Plan"}),(0,r.jsx)("div",{children:(0,r.jsxs)("select",{value:e.plan,onChange:t=>F(e.id,{plan:t.target.value}),className:"text-xs border rounded px-2 py-1 bg-[#12121f] border-white/[0.1] text-gray-300 cursor-pointer mt-0.5",children:[(0,r.jsx)("option",{value:"FREE",children:"Free"}),(0,r.jsx)("option",{value:"PRO",children:"Pro"}),(0,r.jsx)("option",{value:"BUSINESS",children:"Business"})]})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-gray-500 text-xs",children:t?"الصلاحية":"Role"}),(0,r.jsx)("div",{className:"mt-0.5",children:(0,r.jsxs)("button",{onClick:()=>F(e.id,{role:"ADMIN"===e.role?"USER":"ADMIN"}),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium ".concat("ADMIN"===e.role?"bg-purple-500/10 text-purple-400":"bg-white/[0.05] text-gray-400"),children:["ADMIN"===e.role?(0,r.jsx)(o.Z,{className:"h-3 w-3"}):(0,r.jsx)(x,{className:"h-3 w-3"}),e.role]})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-gray-500 text-xs",children:t?"حد الصفحات":"Limit"}),(0,r.jsx)("div",{className:"mt-0.5",children:f===e.id?(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("input",{type:"number",value:b,onChange:e=>v(e.target.value),onKeyDown:t=>"Enter"===t.key&&R(e.id),className:"w-14 border rounded px-1 py-0.5 text-xs bg-[#12121f] border-white/[0.1] text-white",autoFocus:!0}),(0,r.jsx)("button",{onClick:()=>R(e.id),className:"text-xs text-green-400",children:"✓"}),(0,r.jsx)("button",{onClick:()=>N(null),className:"text-xs text-gray-500",children:"✕"})]}):(0,r.jsx)("button",{onClick:()=>{N(e.id),v(String(e.pagesLimit))},className:"text-sm text-cyan-400 hover:underline font-medium",children:e.pagesLimit})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-gray-500 text-xs",children:t?"الصفحات":"Pages"}),(0,r.jsx)("div",{className:"text-gray-300 mt-0.5",children:e._count.pages})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between pt-2 border-t border-white/[0.04]",children:[(0,r.jsx)("button",{onClick:()=>I(e),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium ".concat(e.suspended?"bg-red-500/10 text-red-400":"bg-green-500/10 text-green-400"),children:e.suspended?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(m.Z,{className:"h-3 w-3"}),t?"محظور":"Suspended"]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(h.Z,{className:"h-3 w-3"}),t?"نشط":"Active"]})}),(0,r.jsx)("span",{className:"text-xs text-gray-500",children:(0,p.p)(e.createdAt)})]})]},e.id))})]}),w&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:(0,r.jsxs)("div",{className:"bg-[#1a1a2e] border border-white/[0.1] rounded-2xl p-6 w-full max-w-md mx-4 shadow-2xl",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,r.jsx)("div",{className:"p-2 rounded-lg bg-orange-500/10",children:(0,r.jsx)(m.Z,{className:"h-5 w-5 text-orange-400"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-white",children:t?"تعليق المستخدم":"Suspend User"}),(0,r.jsx)("p",{className:"text-sm text-gray-400",children:w.name||w.email})]})]}),(0,r.jsx)("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:t?"سبب التعليق (اختياري)":"Reason for suspension (optional)"}),(0,r.jsx)("textarea",{value:C,onChange:e=>Z(e.target.value),placeholder:t?"مثال: مخالفة شروط الاستخدام...":"e.g. Terms of service violation...",className:"w-full px-3 py-2 border rounded-lg text-sm bg-white/[0.03] border-white/[0.08] text-white placeholder:text-gray-500 focus:outline-none focus:ring-2 focus:ring-orange-500/30 focus:border-orange-500/30 resize-none",rows:3,dir:t?"rtl":"ltr",autoFocus:!0}),(0,r.jsxs)("div",{className:"flex gap-3 mt-4",children:[(0,r.jsx)("button",{onClick:L,className:"flex-1 px-4 py-2 text-sm font-medium text-white bg-orange-500 hover:bg-orange-400 rounded-lg transition-colors",children:t?"تأكيد التعليق":"Confirm Suspend"}),(0,r.jsx)("button",{onClick:()=>{k(null),Z("")},className:"flex-1 px-4 py-2 text-sm font-medium text-gray-400 bg-white/[0.05] hover:bg-white/[0.08] rounded-lg transition-colors",children:t?"إلغاء":"Cancel"})]})]})})]})}},22169:function(e,t,s){"use strict";s.d(t,{cn:function(){return a},p:function(){return i}});var r=s(75504),n=s(51367);function a(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,n.m6)((0,r.W)(t))}function i(e){return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(new Date(e))}}},function(e){e.O(0,[9966,2150,1774,2971,8069,1744],function(){return e(e.s=15429)}),_N_E=e.O()}]);