"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[723],{53879:function(e,t,a){a.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,a(87461).Z)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]])},37451:function(e,t,a){a.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,a(87461).Z)("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]])},18994:function(e,t,a){a.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,a(87461).Z)("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},70699:function(e,t,a){a.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,a(87461).Z)("Save",[["path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z",key:"1owoqh"}],["polyline",{points:"17 21 17 13 7 13 7 21",key:"1md35c"}],["polyline",{points:"7 3 7 8 15 8",key:"8nz8an"}]])},24232:function(e,t,a){a.d(t,{default:function(){return s.a}});var r=a(24930),s=a.n(r)},47907:function(e,t,a){var r=a(15313);a.o(r,"useParams")&&a.d(t,{useParams:function(){return r.useParams}}),a.o(r,"usePathname")&&a.d(t,{usePathname:function(){return r.usePathname}}),a.o(r,"useRouter")&&a.d(t,{useRouter:function(){return r.useRouter}}),a.o(r,"useSearchParams")&&a.d(t,{useSearchParams:function(){return r.useSearchParams}})},24930:function(e,t,a){Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n}});let r=a(86921);a(3827),a(64090);let s=r._(a(84795));function n(e,t){let a={loading:e=>{let{error:t,isLoading:a,pastDelay:r}=e;return null}};return"function"==typeof e&&(a.loader=e),(0,s.default)({...a,...t})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},19721:function(e,t,a){function r(e){let{reason:t,children:a}=e;return a}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"BailoutToCSR",{enumerable:!0,get:function(){return r}}),a(99775)},84795:function(e,t,a){Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return o}});let r=a(3827),s=a(64090),n=a(19721);function l(e){var t;return{default:null!=(t=null==e?void 0:e.default)?t:e}}let i={loader:()=>Promise.resolve(l(()=>null)),loading:null,ssr:!0},o=function(e){let t={...i,...e},a=(0,s.lazy)(()=>t.loader().then(l)),o=t.loading;function d(e){let l=o?(0,r.jsx)(o,{isLoading:!0,pastDelay:!0,error:null}):null,i=t.ssr?(0,r.jsx)(a,{...e}):(0,r.jsx)(n.BailoutToCSR,{reason:"next/dynamic",children:(0,r.jsx)(a,{...e})});return(0,r.jsx)(s.Suspense,{fallback:l,children:i})}return d.displayName="LoadableComponent",d}},60723:function(e,t,a){a.d(t,{Z:function(){return b}});var r=a(3827),s=a(64090),n=a(47907),l=a(24232),i=a(18994),o=a(53879),d=a(70699),c=a(37451),u=a(71774),x=a(8792);let h=(0,l.default)(()=>Promise.all([a.e(7902),a.e(3572),a.e(1965),a.e(6271),a.e(9305)]).then(a.bind(a,29305)),{loadableGenerated:{webpack:()=>[29305]},ssr:!1}),m=["admin","dashboard","api","blog","pricing","contact","login","register","p","create"];function b(e){let{pageId:t}=e,a=(0,n.useRouter)(),{lang:l,isRTL:b}=(0,u.Z)(),g="ar"===l,f=!!t,[p,j]=(0,s.useState)("ar"),[w,y]=(0,s.useState)(!1),[v,N]=(0,s.useState)(f),[S,P]=(0,s.useState)(null),[D,k]=(0,s.useState)(""),[E,C]=(0,s.useState)(""),[A,T]=(0,s.useState)(""),[Z,O]=(0,s.useState)(""),[_,M]=(0,s.useState)(""),[R,z]=(0,s.useState)("DRAFT"),[L,B]=(0,s.useState)(!1),[F,H]=(0,s.useState)(!1),[I,U]=(0,s.useState)(""),[q,G]=(0,s.useState)(""),[V,W]=(0,s.useState)(""),[J,$]=(0,s.useState)(""),[K,Q]=(0,s.useState)("");function X(e,t){P({msg:e,type:t}),setTimeout(()=>P(null),3e3)}function Y(e){return e?/^[a-z0-9-]+$/.test(e)?m.includes(e)?g?'"'.concat(e,'" محجوز'):'"'.concat(e,'" is reserved'):"":g?"أحرف صغيرة وأرقام وشرطات فقط":"Lowercase letters, numbers, hyphens only":g?"الرابط مطلوب":"Slug is required"}async function ee(e){let r=Y(D);if(r){Q(r);return}if(!E||!A){X(g?"العنوانان مطلوبان":"Both titles are required","error");return}y(!0);let s=await fetch(f?"/api/admin/cms-pages/".concat(t):"/api/admin/cms-pages",{method:f?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:D,titleAr:E,titleEn:A,contentAr:Z,contentEn:_,status:e,showInFooter:L,showInNavbar:F,metaTitleAr:I||null,metaTitleEn:q||null,metaDescAr:V||null,metaDescEn:J||null})});if(y(!1),!s.ok){var n;X(null!==(n=(await s.json()).error)&&void 0!==n?n:g?"حدث خطأ":"An error occurred","error");return}if(X(g?"تم الحفظ":"Saved successfully","success"),f)z(e);else{let e=await s.json();a.push("/admin/cms-pages/".concat(e.id,"/edit"))}}return(0,s.useEffect)(()=>{f&&fetch("/api/admin/cms-pages/".concat(t)).then(e=>e.json()).then(e=>{var t,a,r,s,n,l;k(e.slug),C(e.titleAr),T(e.titleEn),O(null!==(t=e.contentAr)&&void 0!==t?t:""),M(null!==(a=e.contentEn)&&void 0!==a?a:""),z(e.status),B(e.showInFooter),H(e.showInNavbar),U(null!==(r=e.metaTitleAr)&&void 0!==r?r:""),G(null!==(s=e.metaTitleEn)&&void 0!==s?s:""),W(null!==(n=e.metaDescAr)&&void 0!==n?n:""),$(null!==(l=e.metaDescEn)&&void 0!==l?l:"")}).catch(()=>{X(g?"فشل تحميل البيانات":"Failed to load page data","error")}).finally(()=>{N(!1)})},[t,f]),v?(0,r.jsx)("div",{className:"flex items-center justify-center min-h-[400px]",children:(0,r.jsx)(i.Z,{className:"h-6 w-6 animate-spin text-gray-500"})}):(0,r.jsxs)("div",{dir:b?"rtl":"ltr",className:"max-w-5xl mx-auto",children:[S&&(0,r.jsx)("div",{className:"fixed top-4 ".concat(b?"left-4":"right-4"," z-50 px-4 py-3 rounded-xl text-sm font-medium shadow-lg ").concat("success"===S.type?"bg-green-500/10 border border-green-500/20 text-green-400":"bg-red-500/10 border border-red-500/20 text-red-400"),children:S.msg}),(0,r.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(x.default,{href:"/admin/cms-pages",className:"p-2 text-gray-400 hover:text-white hover:bg-white/[0.06] rounded-lg transition-colors",children:(0,r.jsx)(o.Z,{className:"h-4 w-4 ".concat(b?"rotate-180":"")})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-xl font-bold text-white",children:f?g?"تعديل الصفحة":"Edit Page":g?"صفحة جديدة":"New Page"}),D&&(0,r.jsxs)("p",{className:"text-indigo-400 text-xs mt-0.5 font-mono",children:["/",D]})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("button",{onClick:()=>ee("DRAFT"),disabled:w,className:"flex items-center gap-2 px-3 py-2 rounded-lg text-sm text-gray-400 hover:text-white hover:bg-white/[0.06] border border-white/[0.06] transition-colors disabled:opacity-50",children:[w&&"DRAFT"===R?(0,r.jsx)(i.Z,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(d.Z,{className:"h-3.5 w-3.5"}),g?"حفظ مسودة":"Save Draft"]}),(0,r.jsxs)("button",{onClick:()=>ee("PUBLISHED"),disabled:w,className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-500 transition-colors disabled:opacity-50",children:[w&&"PUBLISHED"===R?(0,r.jsx)(i.Z,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(c.Z,{className:"h-3.5 w-3.5"}),g?"نشر":"Publish"]})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[(0,r.jsxs)("div",{className:"lg:col-span-2 space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:g?"الرابط (Slug)":"Slug"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-gray-500 text-sm",children:"/"}),(0,r.jsx)("input",{value:D,onChange:e=>(function(e){let t=e.toLowerCase().replace(/[^a-z0-9-]/g,"");k(t),Q(Y(t))})(e.target.value),placeholder:"about",className:"flex-1 bg-white/[0.04] border border-white/[0.08] rounded-lg px-3 py-2 text-sm text-white placeholder:text-gray-600 focus:outline-none focus:border-indigo-500/50 font-mono",dir:"ltr"})]}),K&&(0,r.jsx)("p",{className:"text-red-400 text-xs mt-1",children:K})]}),(0,r.jsx)("div",{className:"flex gap-1 p-1 bg-white/[0.03] rounded-xl border border-white/[0.06]",children:["ar","en"].map(e=>(0,r.jsx)("button",{onClick:()=>j(e),className:"flex-1 py-2 rounded-lg text-sm font-medium transition-colors ".concat(p===e?"bg-white/[0.08] text-white":"text-gray-500 hover:text-gray-300"),children:"ar"===e?"\uD83C\uDDF8\uD83C\uDDE6 العربية":"\uD83C\uDDEC\uD83C\uDDE7 English"},e))}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:g?"العنوان":"Title"}),(0,r.jsx)("input",{value:"ar"===p?E:A,onChange:e=>"ar"===p?C(e.target.value):T(e.target.value),placeholder:"ar"===p?"سياسة الخصوصية":"Privacy Policy",dir:"ar"===p?"rtl":"ltr",className:"w-full bg-white/[0.04] border border-white/[0.08] rounded-lg px-3 py-2 text-sm text-white placeholder:text-gray-600 focus:outline-none focus:border-indigo-500/50"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:g?"المحتوى":"Content"}),(0,r.jsx)("div",{className:"border border-white/[0.08] rounded-xl overflow-hidden",children:"ar"===p?(0,r.jsx)(h,{content:Z,onChange:O,dir:"rtl",placeholder:g?"اكتب محتوى الصفحة هنا...":"Write Arabic content here..."},"ar"):(0,r.jsx)(h,{content:_,onChange:M,dir:"ltr",placeholder:"Write English content here..."},"en")})]})]}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"bg-white/[0.03] border border-white/[0.06] rounded-xl p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-white mb-3",children:g?"الحالة":"Status"}),(0,r.jsx)("div",{className:"flex gap-2",children:["DRAFT","PUBLISHED"].map(e=>(0,r.jsx)("button",{onClick:()=>z(e),className:"flex-1 py-1.5 rounded-lg text-xs font-medium transition-colors ".concat(R===e?"PUBLISHED"===e?"bg-green-500/10 text-green-400 border border-green-500/20":"bg-yellow-500/10 text-yellow-400 border border-yellow-500/20":"bg-white/[0.04] text-gray-500 border border-white/[0.06] hover:text-gray-300"),children:"PUBLISHED"===e?g?"منشور":"Published":g?"مسودة":"Draft"},e))})]}),(0,r.jsxs)("div",{className:"bg-white/[0.03] border border-white/[0.06] rounded-xl p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-white mb-3",children:g?"ظهور في القوائم":"Navigation Visibility"}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("label",{className:"flex items-center justify-between cursor-pointer",children:[(0,r.jsx)("span",{className:"text-sm text-gray-400",children:g?"ظهور في الفوتر":"Show in Footer"}),(0,r.jsx)("button",{onClick:()=>B(!L),className:"relative w-10 h-5 rounded-full transition-colors ".concat(L?"bg-indigo-600":"bg-white/[0.1]"),children:(0,r.jsx)("span",{className:"absolute top-0.5 h-4 w-4 rounded-full bg-white transition-transform ".concat(L?b?"-translate-x-5":"translate-x-5":"translate-x-0.5")})})]}),(0,r.jsxs)("label",{className:"flex items-center justify-between cursor-pointer",children:[(0,r.jsx)("span",{className:"text-sm text-gray-400",children:g?"ظهور في النافبار":"Show in Navbar"}),(0,r.jsx)("button",{onClick:()=>H(!F),className:"relative w-10 h-5 rounded-full transition-colors ".concat(F?"bg-indigo-600":"bg-white/[0.1]"),children:(0,r.jsx)("span",{className:"absolute top-0.5 h-4 w-4 rounded-full bg-white transition-transform ".concat(F?b?"-translate-x-5":"translate-x-5":"translate-x-0.5")})})]})]})]}),(0,r.jsxs)("div",{className:"bg-white/[0.03] border border-white/[0.06] rounded-xl p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-white mb-3",children:"SEO"}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-gray-500 block mb-1",children:g?"عنوان SEO (AR)":"Meta Title (AR)"}),(0,r.jsx)("input",{value:I,onChange:e=>U(e.target.value),dir:"rtl",className:"w-full bg-white/[0.04] border border-white/[0.08] rounded-lg px-3 py-1.5 text-xs text-white placeholder:text-gray-600 focus:outline-none focus:border-indigo-500/50"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-gray-500 block mb-1",children:g?"عنوان SEO (EN)":"Meta Title (EN)"}),(0,r.jsx)("input",{value:q,onChange:e=>G(e.target.value),dir:"ltr",className:"w-full bg-white/[0.04] border border-white/[0.08] rounded-lg px-3 py-1.5 text-xs text-white placeholder:text-gray-600 focus:outline-none focus:border-indigo-500/50"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-gray-500 block mb-1",children:g?"وصف SEO (AR)":"Meta Desc (AR)"}),(0,r.jsx)("textarea",{value:V,onChange:e=>W(e.target.value),dir:"rtl",rows:2,className:"w-full bg-white/[0.04] border border-white/[0.08] rounded-lg px-3 py-1.5 text-xs text-white placeholder:text-gray-600 focus:outline-none focus:border-indigo-500/50 resize-none"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-gray-500 block mb-1",children:g?"وصف SEO (EN)":"Meta Desc (EN)"}),(0,r.jsx)("textarea",{value:J,onChange:e=>$(e.target.value),dir:"ltr",rows:2,className:"w-full bg-white/[0.04] border border-white/[0.08] rounded-lg px-3 py-1.5 text-xs text-white placeholder:text-gray-600 focus:outline-none focus:border-indigo-500/50 resize-none"})]})]})]})]})]})]})}}}]);