var st=Object.defineProperty;var rt=(r,t,a)=>t in r?st(r,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[t]=a;var qe=(r,t,a)=>rt(r,typeof t!="symbol"?t+"":t,a);import{y as Y,bd as nt,aR as V,j as e,v as k,B as w,b6 as J,b8 as K,be as it,p as Be,g as lt,bf as ot,bg as dt,bh as ct,m as X,n as L,o as T,r as b,f as M,u as z,bi as W,I as mt,aF as Q,t as C,bj as $,az as ye,d as ut,bk as gt,bb as Ke,aS as xt,bl as ht,bm as E}from"./index-Db-xuq0b.js";import{E as Ce}from"./eye-Bhud4znU.js";import{S as Z}from"./square-pen-B91TPB19.js";import{C as ee,A as te}from"./AdvancedTable-CC9ioMU-.js";import{p as be}from"./presignedAxios-BunkFbUr.js";import{C as pt,u as F}from"./index.esm-BG4gweZJ.js";import{L as I}from"./label-CsFy6wpo.js";import{T as de}from"./textarea-BNzPMo41.js";import{S as yt,a as bt,b as ft,c as wt,d as jt}from"./select-BoQxM42A.js";import{X as He}from"./XSSUploadValidator-BMXKraj-.js";import{u as _e}from"./useSettings-BtSYqn9W.js";import{M as vt}from"./message-square-BPZTcbJs.js";import"./table-D3n3VABd.js";import"./chevron-left-DCpEaNzo.js";import"./utils-BncSPdK1.js";import"./badge-D7JvaQeJ.js";import"./command-Cr0tMDDu.js";import"./search-CM5F2ZRy.js";import"./popover-X-j_SRnG.js";import"./Popover-CzANYrEa.js";import"./use-uncontrolled-C3HRHW6t.js";import"./separator-BaOOgzZX.js";import"./refresh-cw-JB7N413f.js";import"./organizationService-DPKKJMFw.js";/**
 * @license lucide-react v0.513.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Nt=[["path",{d:"M16 2v2",key:"scm5qe"}],["path",{d:"M7 22v-2a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2",key:"1waht3"}],["path",{d:"M8 2v2",key:"pbkmx"}],["circle",{cx:"12",cy:"11",r:"3",key:"itu57m"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]],kt=Y("contact",Nt);/**
 * @license lucide-react v0.513.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const At=[["path",{d:"M12 13V2l8 4-8 4",key:"5wlwwj"}],["path",{d:"M20.561 10.222a9 9 0 1 1-12.55-5.29",key:"1c0wjv"}],["path",{d:"M8.002 9.997a5 5 0 1 0 8.9 2.02",key:"gb1g7m"}]],Ct=Y("goal",At);/**
 * @license lucide-react v0.513.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const St=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],pe=Y("image",St);/**
 * @license lucide-react v0.513.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const It=[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]],Et=Y("instagram",It);/**
 * @license lucide-react v0.513.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Tt=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],Mt=Y("link",Tt);/**
 * @license lucide-react v0.513.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const qt=[["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-4 0v-9a2 2 0 0 1 2-2h2",key:"39pd36"}],["rect",{width:"8",height:"4",x:"10",y:"6",rx:"1",key:"aywv1n"}]],ze=Y("newspaper",qt);/**
 * @license lucide-react v0.513.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Vt=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],Lt=Y("palette",Vt);/**
 * @license lucide-react v0.513.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ft=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],$e=Y("star",Ft);class Rt{static containsMaliciousScripts(t){const a=typeof t=="string"?t:t.toString("utf-8");return!!(/<script[\s>]/i.test(a)||/on\w+\s*=/i.test(a)||/javascript:/i.test(a)||/data:text\/html/i.test(a)||/vbscript:/i.test(a)||/<iframe[\s>]/i.test(a)||/<(object|embed)[\s>]/i.test(a)||/<style[\s>][\s\S]*?expression\s*\(/i.test(a))}static validateSVGContent(t,a){try{let s;return t instanceof Uint8Array?s=new TextDecoder().decode(t):s=t.toString("utf-8"),this.containsMaliciousScripts(s)?{isValid:!1,error:"SVG file contains potentially malicious scripts or event handlers"}:this.isValidXML(s)?{isValid:!0}:{isValid:!1,error:"SVG file is not valid XML"}}catch(s){return{isValid:!1,error:`Failed to validate SVG content: ${s instanceof Error?s.message:"Unknown error"}`}}}static isValidXML(t){try{const a=(t.match(/<[^/][^>]*>/g)||[]).length,s=(t.match(/<\/[^>]*>/g)||[]).length;return a>0&&s>0}catch{return!1}}static sanitizeSVG(t){let a=t.toString("utf-8");return a=a.replace(/<script[\s\S]*?<\/script>/gi,""),a=a.replace(/\s+on\w+\s*=\s*["'][^"']*["']/gi,""),a=a.replace(/\s+on\w+\s*=\s*[^\s>]*/gi,""),a=a.replace(/javascript:/gi,""),a=a.replace(/data:text\/html/gi,""),a=a.replace(/vbscript:/gi,""),a=a.replace(/<iframe[\s\S]*?<\/iframe>/gi,""),a=a.replace(/<(object|embed)[^>]*>/gi,""),Buffer.from(a,"utf-8")}}class Ge{static containsXSSPatterns(t,a){let s;typeof t=="string"?s=t:t instanceof Uint8Array?s=new TextDecoder().decode(t):s=t.toString("utf-8");const n=[/<script[\s>]/i,/on\w+\s*=\s*["'][^"']*["']/i,/on\w+\s*=\s*[^\s>]*/i,/javascript:/i,/data:text\/html/i,/vbscript:/i,/<iframe[\s>]/i,/<object[\s>]/i,/<embed[\s>]/i,/<applet[\s>]/i,/<meta[\s>]/i,/<link[\s>]/i,/<style[\s>][\s\S]*?expression\s*\(/i,/eval\s*\(/i,/expression\s*\(/i,/import\s+/i,/<!--[\s\S]*?-->/i];for(const l of n)if(l.test(s))return!0;return a.includes("html")||a.includes("xml")?this.checkHTMLXMLContent(s):a.includes("pdf")?this.checkPDFContent(s):a.includes("word")||a.includes("document")?this.checkOfficeDocumentContent(s):a.includes("sheet")||a.includes("excel")?this.checkSpreadsheetContent(s):a.includes("svg")?this.checkSVGContent(s):!1}static checkHTMLXMLContent(t){return!!(/<script[\s\S]*?<\/script>/i.test(t)||/\s+on\w+\s*=/i.test(t)||/<(iframe|object|embed|applet|meta|link|form|input|button)[\s>]/i.test(t)||/(javascript|data|vbscript):/i.test(t))}static checkPDFContent(t){return!!(/\/JavaScript|\/JS|\/OpenAction|\/AA/i.test(t)||/\/EmbeddedFile|\/ObjStm/i.test(t)||/\/Launch|\/SubmitForm|\/ImportData/i.test(t))}static checkOfficeDocumentContent(t){return!!(/vbaProject|VBA|Macro/i.test(t)||/<script[\s\S]*?<\/script>/i.test(t)||/\s+on\w+\s*=/i.test(t)||/<externalData|<connection/i.test(t))}static checkSpreadsheetContent(t){return!!(/=cmd\(|=powershell|=system|=exec/i.test(t)||/vbaProject|VBA|Macro/i.test(t)||/<script[\s\S]*?<\/script>/i.test(t))}static checkSVGContent(t){return!!(/<script[\s\S]*?<\/script>/i.test(t)||/\s+on\w+\s*=/i.test(t)||/<(iframe|object|embed|applet)[\s>]/i.test(t)||/(javascript|data|vbscript):/i.test(t))}static getThreatLevel(t,a){let s;return typeof t=="string"?s=t:t instanceof Uint8Array?s=new TextDecoder().decode(t):s=t.toString("utf-8"),/<script[\s\S]*?<\/script>/i.test(s)||/eval\s*\(/i.test(s)||/\/JavaScript|\/JS|\/OpenAction/i.test(s)?"critical":/on\w+\s*=\s*["'][^"']*["']/i.test(s)||/(javascript|vbscript):/i.test(s)||/<(iframe|object|embed|applet)[\s>]/i.test(s)?"high":/data:text\/html/i.test(s)||/vbaProject|VBA|Macro/i.test(s)?"medium":/<!--[\s\S]*?-->/i.test(s)?"low":"none"}static sanitizeContent(t,a){let s=t.toString("utf-8");return s=s.replace(/<script[\s\S]*?<\/script>/gi,""),s=s.replace(/\s+on\w+\s*=\s*["'][^"']*["']/gi,""),s=s.replace(/\s+on\w+\s*=\s*[^\s>]*/gi,""),s=s.replace(/javascript:/gi,""),s=s.replace(/vbscript:/gi,""),s=s.replace(/data:text\/html/gi,""),s=s.replace(/<(iframe|object|embed|applet)[\s\S]*?<\/\1>/gi,""),Buffer.from(s,"utf-8")}}class Pt{async detectFileType(t){try{if(!t||t.length===0)return null;const{fileTypeFromBuffer:a}=await nt(async()=>{const{fileTypeFromBuffer:l}=await import("file-type");return{fileTypeFromBuffer:l}},[]),s=await a(t);if(s)return{mime:s.mime,ext:s.ext};const n=t.toString("utf-8");return n.includes("<svg")||n.includes("<?xml")&&n.includes("<svg")?{mime:"image/svg+xml",ext:"svg"}:n.includes("<!DOCTYPE html")||n.includes("<html")?{mime:"text/html",ext:"html"}:n.includes("<?xml")?{mime:"application/xml",ext:"xml"}:null}catch{return null}}async validateMimeType(t,a){try{if(!t||t.length===0)return{isValid:!1,detectedMime:"",declaredMime:a,error:"File buffer is empty or corrupted"};const s=await this.detectFileType(t);if(!s)return{isValid:!1,detectedMime:"",declaredMime:a,error:"Unable to detect real file type from buffer"};const n=s.mime===a;return{isValid:n,detectedMime:s.mime,declaredMime:a,error:n?void 0:`MIME mismatch. Declared: ${a}, Real: ${s.mime}`}}catch(s){return{isValid:!1,detectedMime:"",declaredMime:a,error:`Validation error: ${s instanceof Error?s.message:"Unknown error"}`}}}isAllowedMimeType(t,a){return!a||a.length===0?!0:a.includes(t)}async validateUpload(t,a,s){const n=await this.validateMimeType(t,a);if(!n.isValid)return n;if(!this.isAllowedMimeType(a,s.allowedMimeTypes))return{isValid:!1,detectedMime:n.detectedMime,declaredMime:a,error:`File type ${a} is not allowed for this endpoint`};const l=this.scanContentForXSS(t,a);return l.isValid?n:l}validateSVGContent(t,a){const s=Rt.validateSVGContent(t,a);return s.isValid?{isValid:!0,detectedMime:"image/svg+xml",declaredMime:"image/svg+xml"}:{isValid:!1,detectedMime:"image/svg+xml",declaredMime:"image/svg+xml",error:s.error}}scanContentForXSS(t,a){try{if(!t||t.length===0)return{isValid:!0,detectedMime:a,declaredMime:a};if(Ge.containsXSSPatterns(t,a)){const n=Ge.getThreatLevel(t,a);return{isValid:!1,detectedMime:a,declaredMime:a,error:`File content contains potentially malicious code (threat level: ${n}). This file may contain embedded scripts or dangerous patterns.`}}return{isValid:!0,detectedMime:a,declaredMime:a}}catch(s){return{isValid:!1,detectedMime:a,declaredMime:a,error:`Error scanning file content: ${s instanceof Error?s.message:"Unknown error"}`}}}}const ke=new Pt;class Ut{constructor(){qe(this,"logs",[]);qe(this,"xssLogs",[])}async logValidationEvent(t){try{t.timestamp||(t.timestamp=new Date),this.logs.push(t)}catch{}}async logXSSValidationEvent(t){try{t.timestamp||(t.timestamp=new Date),this.xssLogs.push(t)}catch{}}async queryValidationLogs(t){return this.logs.filter(a=>!(t.module&&a.module!==t.module||t.validationResult&&a.validationResult!==t.validationResult||t.startDate&&a.timestamp<t.startDate||t.endDate&&a.timestamp>t.endDate||t.userId&&a.userId!==t.userId))}async queryXSSValidationLogs(t){return this.xssLogs.filter(a=>!(t.module&&a.module!==t.module||t.uploadContext&&a.uploadContext!==t.uploadContext||t.validationResult&&a.validationResult!==t.validationResult||t.startDate&&a.timestamp<t.startDate||t.endDate&&a.timestamp>t.endDate||t.userId&&a.userId!==t.userId))}getAllLogs(){return[...this.logs]}getAllXSSLogs(){return[...this.xssLogs]}clearLogs(){this.logs=[],this.xssLogs=[]}}const oe=new Ut,Dt=({navigate:r,onDelete:t})=>[{header:()=>k("toogle.title"),cell:({row:a})=>{const s=a.original,n=V.language;return e.jsx("span",{children:n==="en"?s.messageTitle.en:s.messageTitle.am})},enableHiding:!0,accessorKey:"title"},{accessorKey:"status",header:()=>k("toogle.status"),cell:({row:a})=>{const s=a.original;return e.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${s.isActive?"bg-primary-100 text-primary-800":"bg-red-100 text-red-800"}`,children:s.isActive?"Active":"Inactive"})},enableHiding:!0},{accessorKey:"createdAt",header:()=>k("toogle.createdAt"),cell:({row:a})=>{const s=a.original,n=V.language,l=s==null?void 0:s.amharicCreatedAt,i=new Date(s.createdAt).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}),d=n==="am"?l:i;return e.jsx("span",{className:"text-sm text-gray-500",children:d})},enableHiding:!0},{accessorKey:"Actions",header:()=>k("toogle.Actions"),cell:({row:a})=>e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>r(`/user-management/web-management/LeadershipMessage/ViewLeadershipMessage/${a.original.id}`),children:e.jsx(Ce,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>r(`/user-management/web-management/LeadershipMessage/EditLeadershipMessage/${a.original.id}`),children:e.jsx(Z,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>t(a.original.id),children:e.jsx(J,{className:"h-4 w-4 text-destructive"})})]})}],ae=({mode:r="page",label:t="Loading...",className:a,showLabel:s})=>{const n=r==="inline",l=s??!n;return e.jsxs("div",{className:K(n?"inline-flex items-center justify-center":"w-full min-h-[60vh] flex flex-col items-center justify-center gap-5 rounded-2xl border border-primary-100/80 bg-gradient-to-br from-white via-primary-50/70 to-primary-100/60 dark:border-primary-900/40 dark:from-slate-900 dark:via-slate-900 dark:to-primary-950/40 shadow-sm backdrop-blur-[1px] select-none",a),role:"status","aria-live":"polite","aria-label":t,"aria-busy":"true",children:[e.jsxs("div",{className:K("relative",n?"h-8 w-8":"h-32 w-32"),children:[e.jsx("span",{className:K("absolute inset-0 rounded-full border-primary-100/70 dark:border-primary-950/80",n?"border-2":"border-[3px]")}),e.jsx("span",{className:K("absolute inset-0 rounded-full border-transparent border-t-primary-600 border-r-primary-500 dark:border-t-primary-400 dark:border-r-primary-500 motion-safe:animate-spin motion-reduce:animate-none",n?"border-2":"border-[3px]")}),e.jsx("span",{className:K("absolute rounded-full border-transparent border-b-primary-500 border-l-primary-400 dark:border-b-primary-300 dark:border-l-primary-400 motion-safe:animate-spin motion-reduce:animate-none",n?"inset-1 border-2":"inset-2 border-[3px]"),style:{animationDirection:"reverse",animationDuration:"1.3s"}}),e.jsx("span",{className:K("absolute rounded-full bg-primary-500/80 dark:bg-primary-400/85 motion-safe:animate-pulse motion-reduce:animate-none",n?"inset-3 shadow-[0_0_10px_rgba(34,197,94,0.5)]":"inset-8 shadow-[0_0_34px_rgba(34,197,94,0.5)]")}),e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:e.jsxs("div",{className:K("relative rounded-[4px] shadow-md border border-primary-200/80 dark:border-primary-900/70 bg-gradient-to-b from-white to-primary-50 dark:from-slate-800 dark:to-slate-900",n?"w-[0.9rem] h-[1.1rem]":"w-9 h-11"),children:[e.jsx("div",{className:K("absolute top-0 right-0 border-l-transparent border-b-primary-200 dark:border-b-primary-500/90",n?"border-l-[5px] border-b-[5px]":"border-l-[8px] border-b-[8px]")}),e.jsx("div",{className:"absolute left-1 right-1 top-[24%] h-[2px] rounded bg-primary-400/70 dark:bg-primary-300/70"}),e.jsx("div",{className:"absolute left-1 right-1 top-[44%] h-[2px] rounded bg-primary-400/50 dark:bg-primary-300/50"}),e.jsx("div",{className:"absolute left-1 right-1 top-[64%] h-[2px] rounded bg-primary-400/30 dark:bg-primary-300/35"}),e.jsx("span",{className:K("absolute rounded-full border border-primary-400/70 bg-primary-100/80 dark:bg-primary-500/20 dark:border-primary-300/70",n?"h-1.5 w-1.5 right-0.5 bottom-0.5":"h-2.5 w-2.5 right-1 bottom-1")})]})})]}),l&&e.jsx("p",{className:"text-sm font-semibold tracking-wide text-primary-700 dark:text-primary-300",children:t}),!n&&e.jsxs("div",{className:"flex items-center gap-1.5","aria-hidden":"true",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary-500/70 motion-safe:animate-pulse"}),e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary-500/70 motion-safe:animate-pulse [animation-delay:180ms]"}),e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary-500/70 motion-safe:animate-pulse [animation-delay:360ms]"})]})]})},N=it.create({baseURL:"https://chronincle-dev.smartoffice.aaca.gov.et/api"});N.interceptors.request.use(r=>{const t=Be.get("auth-token");return t&&(r.headers.Authorization=`Bearer ${t}`),r.headers["X-Requested-With"]="XMLHttpRequest",r});let Ve=!1,Le=[];const Oe=(r,t=null)=>{Le.forEach(a=>{r?a.reject(r):a.resolve(t)}),Le=[]},Kt=["/auth/login","/auth/refresh","auth/me"];N.interceptors.response.use(r=>r,async r=>{var s;const t=r.config;if(Kt?.some(n=>{var l;return(l=t.url)==null?void 0:l.includes(n)}))return Promise.reject(r);if(((s=r.response)==null?void 0:s.status)===401&&!t._retry){if(Ve)return new Promise(function(n,l){Le.push({resolve:n,reject:l})}).then(n=>(t.headers.Authorization="Bearer "+n,N(t))).catch(n=>Promise.reject(n));t._retry=!0,Ve=!0;try{const n=Be.get("refresh-token");if(!n)throw new Error("missing-refresh-token");const l=lt(),i=await ot(n),d=i.data.token,x=i.data.refreshToken;return Oe(null,i.data.token),dt({token:d,refreshToken:x,rememberMe:l}),t.headers.Authorization=`Bearer ${d}`,N(t)}catch(n){return Oe(n,null),ct(),Promise.reject(n)}finally{Ve=!1}}return Promise.reject(r)});const O={async uploadImage(r,t){if(!t)throw new Error("Upload URL is undefined.");const a=await ke.validateMimeType(new Uint8Array(await r.slice(0,512).arrayBuffer()),r.type);if(!a.isValid)throw await oe.logValidationEvent({timestamp:new Date,fileSize:r.size,fileName:r.name,declaredMime:r.type,detectedMime:a.detectedMime,validationResult:"mismatch",errorDetails:a.error,module:"user-management",endpoint:"/staff/upload"}),new Error(a.error||"File validation failed");const s=["image/png","image/jpeg","image/gif","image/webp"];if(!ke.isAllowedMimeType(r.type,s))throw await oe.logValidationEvent({timestamp:new Date,fileSize:r.size,fileName:r.name,declaredMime:r.type,detectedMime:a.detectedMime,validationResult:"error",errorDetails:`File type ${r.type} is not allowed. Only images are allowed.`,module:"user-management",endpoint:"/staff/upload"}),new Error(`File type ${r.type} is not allowed. Only images are allowed.`);return await oe.logValidationEvent({timestamp:new Date,fileSize:r.size,fileName:r.name,declaredMime:r.type,detectedMime:a.detectedMime,validationResult:"success",module:"user-management",endpoint:"/staff/upload"}),be.put(t,r,{headers:{"Content-Type":r.type}})},async updateUploadStatus(r,t){await N.patch(`/staff/${r}/upload-status`,{uploadedSuccessfully:t},{headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}})},async getItem(r){throw new Error("Not implemented in this branch")},async getItems(r){throw new Error("Not implemented in this branch")},async createItem(r){throw new Error("Not implemented in this branch")},async updateItem(r,t){throw new Error("Not implemented in this branch")},async deleteItem(r){throw new Error("Not implemented in this branch")}},Se=(r,t)=>{const a=X(),{data:s}=L({queryKey:["Message",t],queryFn:async()=>await O.getItem(t||""),enabled:!!t}),{data:n,isLoading:l,error:i,refetch:d}=L({queryKey:["Message1",r],queryFn:async()=>await O.getItems(r)}),x=T({mutationFn:async m=>{const o=await O.createItem(m.data);if(!o.id)throw new Error("Failed to create Message item");try{await O.uploadImage(m.imageFile,o.presigned)}catch(g){throw await O.deleteItem(o.id),g}return await O.updateUploadStatus(o.id,!0),o},onSuccess:()=>{a.invalidateQueries({queryKey:["Message1",r]})}}),c=T({mutationFn:async({id:m,data:o,imageFile:g})=>{const p=await O.updateItem(m,o);if(g){try{const y=p;await O.uploadImage(g,y.presigned)}catch(y){throw y}await O.updateUploadStatus(m,!0)}return p},onSuccess:()=>{a.invalidateQueries({queryKey:["Message1",r]})}}),u=T({mutationFn:O.deleteItem,onSuccess:()=>{a.invalidateQueries({queryKey:["Message1",r]})}});return{items:n==null?void 0:n.items,singleItem:s,count:n==null?void 0:n.count,isLoading:l,error:i,createItem:x.mutateAsync,updateItem:c.mutateAsync,deleteItem:u.mutateAsync,isCreating:x.isPending,isUpdating:c.isPending,isDeleting:u.isPending,refetch:d}},zt=()=>{const[r,t]=b.useState(0),a=M(),s=10,{t:n}=z(),l=b.useMemo(()=>({skip:r*s,take:s,orderBy:"createdAt:DESC"}),[r]),{items:i,refetch:d,deleteItem:x,error:c,isLoading:u,count:m}=Se(l),o=g=>{t(g)};return e.jsxs("div",{className:"flex flex-col h-full w-full p-6 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-100 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 border-b pb-3 border-gray-200 dark:border-gray-700",children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-800 dark:text-gray-200",children:n("officeHead.title")}),e.jsx(W,{to:"/user-management/web-Management/LeadershipMessage/AddLeadershipMessage",children:e.jsxs(w,{variant:"addRecordBtn",className:"flex items-center gap-1 bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg transition-all",children:[e.jsx(ee,{className:"w-4 h-4"}),e.jsx("span",{children:n("officeHead.addMessage")})]})})]}),e.jsxs("div",{className:"flex-1 overflow-auto",children:[u&&e.jsx("div",{className:"flex justify-center items-center h-48",children:e.jsx(ae,{})}),c&&e.jsx("p",{className:"text-center text-red-500 text-sm mt-4",children:n("userRecord.Error loading records.")}),!u&&!c&&e.jsx("div",{className:"mt-2",children:e.jsx(te,{columns:Dt({navigate:a,onDelete:x}),data:i||[],tableName:"LeadershipMessages",toolBarPosition:"right",extraToolbar:e.jsx("div",{className:"flex gap-2"}),itemCount:m||2,pageIndex:r,onPageChange:o,nextFunction:()=>o(r+1),prevFunction:()=>o(Math.max(r-1,0)),refresh:d})})]})]})},$t=({onDelete:r,navigate:t})=>[{header:()=>k("toogle.title"),cell:({row:a})=>{var l,i;const s=a.original,n=V.language;return n==="am"?e.jsx("span",{children:((l=s.goalTitle)==null?void 0:l.am)||"-"}):n==="en"?e.jsx("span",{children:((i=s.goalTitle)==null?void 0:i.en)||"-"}):e.jsx("span",{children:"-"})},enableHiding:!0,accessorKey:"title"},{accessorKey:"status",header:()=>k("toogle.status"),cell:({row:a})=>{const s=a.original;return e.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${s.isActive?"bg-primary-100 text-primary-800":"bg-red-100 text-red-800"}`,children:s.isActive?"Active":"Inactive"})},enableHiding:!0},{accessorKey:"createdAt",header:()=>k("toogle.createdAt"),cell:({row:a})=>{const s=a.original,n=V.language,l=s==null?void 0:s.amharicCreatedAt,i=new Date(s.createdAt).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}),d=n==="am"?l:i;return e.jsx("span",{className:"text-sm text-gray-500",children:d})},enableHiding:!0},{id:"Actions",header:()=>k("toogle.Actions"),cell:({row:a})=>e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>t(`/user-management/web-management/Goals/ViewGoal/${a.original.id}`),children:e.jsx(Ce,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>t(`/user-management/web-management/Goals/EditGoal/${a.original.id}`),children:e.jsx(Z,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>r(a.original.id),children:e.jsx(J,{className:"h-4 w-4 text-destructive"})})]})}],B={async uploadImage(r,t){if(!t)throw new Error("Upload URL is undefined.");const a=await ke.validateMimeType(new Uint8Array(await r.slice(0,512).arrayBuffer()),r.type);if(!a.isValid)throw await oe.logValidationEvent({timestamp:new Date,fileSize:r.size,fileName:r.name,declaredMime:r.type,detectedMime:a.detectedMime,validationResult:"mismatch",errorDetails:a.error,module:"user-management",endpoint:"/goal/upload"}),new Error(a.error||"File validation failed");const s=["image/png","image/jpeg","image/gif","image/webp"];if(!ke.isAllowedMimeType(r.type,s))throw await oe.logValidationEvent({timestamp:new Date,fileSize:r.size,fileName:r.name,declaredMime:r.type,detectedMime:a.detectedMime,validationResult:"error",errorDetails:`File type ${r.type} is not allowed. Only images are allowed.`,module:"user-management",endpoint:"/goal/upload"}),new Error(`File type ${r.type} is not allowed. Only images are allowed.`);return await oe.logValidationEvent({timestamp:new Date,fileSize:r.size,fileName:r.name,declaredMime:r.type,detectedMime:a.detectedMime,validationResult:"success",module:"user-management",endpoint:"/goal/upload"}),be.put(t,r,{headers:{"Content-Type":r.type}})},async updateUploadStatus(r,t){await N.patch(`/goal/${r}/upload-status`,{uploadedSuccessfully:t},{headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}})},async getItem(r){throw new Error("Not implemented in this branch")},async getItems(r){throw new Error("Not implemented in this branch")},async createItem(r){throw new Error("Not implemented in this branch")},async updateItem(r,t){throw new Error("Not implemented in this branch")},async deleteItem(r){throw new Error("Not implemented in this branch")},async changeStatus(r){throw new Error("Not implemented in this branch")}},Ie=(r,t)=>{const a=X(),{data:s,isLoading:n,error:l}=L({queryKey:["Goal",t],queryFn:async()=>await B.getItem(t||""),enabled:!!t}),{data:i,refetch:d}=L({queryKey:["Goal1",r],queryFn:async()=>await B.getItems(r)}),x=T({mutationFn:async m=>{const o=await B.createItem(m.data);if(!o.id)throw new Error("Failed to create Goal item");try{await B.uploadImage(m.imageFile,o.presigned)}catch(g){throw await B.deleteItem(o.id),g}return await B.changeStatus(o==null?void 0:o.id),o},onSuccess:()=>{a.invalidateQueries({queryKey:["Goal1",r]})}}),c=T({mutationFn:async({id:m,data:o,imageFile:g})=>{const p=await B.updateItem(m,o);if(g){try{const y=p;await B.uploadImage(g,y.presigned)}catch(y){throw y}await B.changeStatus(m)}return p},onSuccess:()=>{a.invalidateQueries({queryKey:["Message1",r]})}}),u=T({mutationFn:m=>B.deleteItem(m),onSuccess:()=>{a.invalidateQueries({queryKey:["Goal1",r]})}});return{items:i==null?void 0:i.items,singleItem:s,count:i==null?void 0:i.count,isLoading:n,error:l,createItem:x.mutateAsync,updateItem:c.mutateAsync,deleteItem:u.mutateAsync,isCreating:x.isPending,isUpdating:c.isPending,isDeleting:u.isPending,refetch:d}},Gt=()=>{const[r,t]=b.useState(0),a=M(),s=10,{t:n}=z(),l=b.useMemo(()=>({skip:r*s,take:s,orderBy:"createdAt:DESC"}),[r]),{items:i,refetch:d,deleteItem:x,error:c,isLoading:u,count:m}=Ie(l),o=g=>{t(g)};return e.jsxs("div",{className:"flex flex-col h-full w-full p-6 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-100 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 border-b pb-3 border-gray-200 dark:border-gray-700",children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-800 dark:text-gray-200",children:n("Goals")}),e.jsx(W,{to:"/user-management/web-Management/Goals/AddGoal",children:e.jsxs(w,{variant:"addRecordBtn",className:"flex items-center gap-1 bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg transition-all",children:[e.jsx(ee,{className:"w-4 h-4"}),e.jsx("span",{children:n("addGoal")})]})})]}),e.jsxs("div",{className:"flex-1 overflow-auto",children:[u&&e.jsx("div",{className:"flex justify-center items-center h-48",children:e.jsx(ae,{})}),c&&e.jsx("p",{className:"text-center text-red-500 text-sm mt-4",children:n("userRecord.Error loading records.")}),!u&&!c&&e.jsx("div",{className:"mt-2",children:e.jsx(te,{columns:$t({navigate:a,onDelete:x}),data:i||[],tableName:"Goals",toolBarPosition:"right",extraToolbar:e.jsx("div",{className:"flex gap-2"}),itemCount:m||2,pageIndex:r,onPageChange:o,nextFunction:()=>o(r+1),prevFunction:()=>o(Math.max(r-1,0)),refresh:d})})]})]})},Ot=({navigate:r,onDelete:t})=>[{header:()=>k("toogle.title"),cell:({row:a})=>{var l,i;const s=a.original,n=V.language;return n==="am"?e.jsx("span",{children:((l=s.visionTitle)==null?void 0:l.am)||"-"}):n==="en"?e.jsx("span",{children:((i=s.visionTitle)==null?void 0:i.en)||"-"}):e.jsx("span",{children:"-"})},enableHiding:!0,accessorKey:"title"},{accessorKey:"status",header:()=>k("toogle.status"),cell:({row:a})=>{const s=a.original;return e.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${s.isActive?"bg-primary-100 text-primary-800":"bg-red-100 text-red-800"}`,children:s.isActive?"Active":"Inactive"})},enableHiding:!0},{accessorKey:"createdAt",header:()=>k("toogle.createdAt"),cell:({row:a})=>{const s=a.original,n=V.language,l=s==null?void 0:s.amharicCreatedAt,i=new Date(s.createdAt).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}),d=n==="am"?l:i;return e.jsx("span",{className:"text-sm text-gray-500",children:d})},enableHiding:!0},{accessorKey:"Actions",header:()=>k("toogle.Actions"),cell:({row:a})=>e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>r(`/user-management/web-management/Vision/ViewVision/${a.original.id}`),children:e.jsx(Ce,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>r(`/user-management/web-management/Vision/EditVision/${a.original.id}`),children:e.jsx(Z,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>t(a.original.id),children:e.jsx(J,{className:"h-4 w-4 text-destructive"})})]})}],ue={async createItem(r){return(await N.post("/vision",r,{headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}})).data},async getItems(r){return(await N.get("/vision/list",{params:r,headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}})).data},async getItem(r){return(await N.get(`/vision/${r}`)).data},async updateItem(r,t){const a={...t};return(await N.put(`/vision/${r}`,a)).data},async deleteItem(r){await N.delete(`/vision/${r}`)}},Ee=(r,t)=>{const a=X(),{data:s,isLoading:n,error:l}=L({queryKey:["Vision",t],queryFn:async()=>await ue.getItem(t||""),enabled:!!t}),{data:i,refetch:d}=L({queryKey:["Vision1",r],queryFn:async()=>await ue.getItems(r)}),x=T({mutationFn:async m=>{const o=await ue.createItem(m.data);if(!o.id)throw new Error("Failed to create Vision item");return o},onSuccess:()=>{a.invalidateQueries({queryKey:["Vision1",r]})}}),c=T({mutationFn:({id:m,data:o})=>ue.updateItem(m,o),onSuccess:()=>{a.invalidateQueries({queryKey:["Vision1",r]})}}),u=T({mutationFn:ue.deleteItem,onSuccess:()=>{a.invalidateQueries({queryKey:["Vision1",r]})}});return{items:i==null?void 0:i.items,singleItem:s,count:i==null?void 0:i.count,isLoading:n,error:l,createItem:x.mutateAsync,updateItem:c.mutateAsync,deleteItem:u.mutateAsync,isCreating:x.isPending,isUpdating:c.isPending,isDeleting:u.isPending,refetch:d}},Bt=()=>{const[r,t]=b.useState(0),a=M(),s=10,{t:n}=z(),l=b.useMemo(()=>({skip:r*s,take:s,orderBy:"createdAt:DESC"}),[r]),{items:i,refetch:d,deleteItem:x,error:c,isLoading:u,count:m}=Ee(l),o=g=>{t(g)};return e.jsxs("div",{className:"flex flex-col h-full w-full p-6 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-100 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 border-b pb-3 border-gray-200 dark:border-gray-700",children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-800 dark:text-gray-200",children:n("Vision")}),e.jsx(W,{to:"/user-management/web-Management/Vision/AddVision",children:e.jsxs(w,{variant:"addRecordBtn",className:"flex items-center gap-1 bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg transition-all",children:[e.jsx(ee,{className:"w-4 h-4"}),e.jsx("span",{children:n("addVision")})]})})]}),e.jsxs("div",{className:"flex-1 overflow-auto",children:[u&&e.jsx("div",{className:"flex justify-center items-center h-48",children:e.jsx(ae,{})}),c&&e.jsx("p",{className:"text-center text-red-500 text-sm mt-4",children:n("userRecord.Error loading records.")}),!u&&!c&&e.jsx("div",{className:"mt-2",children:e.jsx(te,{columns:Ot({navigate:a,onDelete:x}),data:i||[],tableName:"Visions",toolBarPosition:"right",extraToolbar:e.jsx("div",{className:"flex gap-2"}),itemCount:m||2,pageIndex:r,onPageChange:o,nextFunction:()=>o(r+1),prevFunction:()=>o(Math.max(r-1,0)),refresh:d})})]})]})},Ht=({navigate:r,onDelete:t})=>[{accessorKey:"title",header:()=>k("toogle.title"),cell:({row:a})=>{var l,i;const s=a.original,n=V.language;return n==="am"?e.jsx("span",{children:((l=s.name)==null?void 0:l.am)||"-"}):n==="en"?e.jsx("span",{children:((i=s.name)==null?void 0:i.en)||"-"}):e.jsx("span",{children:"-"})},enableHiding:!0},{accessorKey:"link",header:()=>k("toogle.link"),cell:({row:a})=>{const s=a.original;return e.jsx("span",{children:s.link||"-"})},enableHiding:!0},{accessorKey:"status",header:()=>k("toogle.status"),cell:({row:a})=>{const s=a.original;return e.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${s.isActive?"bg-primary-100 text-primary-800":"bg-red-100 text-red-800"}`,children:s.isActive?"Active":"Inactive"})},enableHiding:!0},{accessorKey:"createdAt",header:()=>k("toogle.createdAt"),cell:({row:a})=>{const s=a.original,n=V.language,l=s==null?void 0:s.amharicCreatedAt,i=new Date(s.createdAt).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}),d=n==="am"?l:i;return e.jsx("span",{className:"text-sm text-gray-500",children:d})},enableHiding:!0},{accessorKey:"Actions",header:()=>k("toogle.Actions"),cell:({row:a})=>e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>r(`/user-management/web-management/SocialMedia/EditSocialMedia/${a.original.id}`),children:e.jsx(Z,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>t(a.original.id),children:e.jsx(J,{className:"h-4 w-4 text-destructive"})})]})}],ge={async createItem(r){return(await N.post("/social-media",r,{headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}})).data},async getItems(r){return(await N.get("/social-media/list",{params:r,headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}})).data},async getItem(r){return(await N.get(`/social-media/${r}`)).data},async updateItem(r,t){const a={...t};return(await N.put(`/social-media/${r}`,a)).data},async deleteItem(r){await N.delete(`/social-media/${r}`)}},Fe=(r,t)=>{const a=X(),{data:s,isLoading:n,error:l}=L({queryKey:["SocialMedia",t],queryFn:async()=>await ge.getItem(t||""),enabled:!!t}),{data:i,refetch:d}=L({queryKey:["SocialMedia1",r],queryFn:async()=>await ge.getItems(r)}),x=T({mutationFn:async m=>{const o=await ge.createItem(m.data);if(!o.id)throw new Error("Failed to create SocialMedia item");return o},onSuccess:()=>{a.invalidateQueries({queryKey:["SocialMedia1",r]})}}),c=T({mutationFn:({id:m,data:o})=>ge.updateItem(m,o),onSuccess:()=>{a.invalidateQueries({queryKey:["SocialMedia1",r]})}}),u=T({mutationFn:ge.deleteItem,onSuccess:()=>{a.invalidateQueries({queryKey:["SocialMedia1",r]})}});return{items:i==null?void 0:i.items,singleItem:s,count:i==null?void 0:i.count,isLoading:n,error:l,createItem:x.mutateAsync,updateItem:c.mutateAsync,deleteItem:u.mutateAsync,isCreating:x.isPending,isUpdating:c.isPending,isDeleting:u.isPending,refetch:d}},_t=()=>{const[r,t]=b.useState(0),a=M(),s=10,{t:n}=z(),l=b.useMemo(()=>({skip:r*s,take:s,orderBy:"createdAt:DESC"}),[r]),{items:i,refetch:d,deleteItem:x,error:c,isLoading:u,count:m}=Fe(l),o=g=>{t(g)};return e.jsxs("div",{className:"flex flex-col h-full w-full p-6 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-100 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 border-b pb-3 border-gray-200 dark:border-gray-700",children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-800 dark:text-gray-200",children:n("socialMedia")}),e.jsx(W,{to:"/user-management/web-Management/SocialMedia/AddSocialMedia",children:e.jsxs(w,{variant:"addRecordBtn",className:"flex items-center gap-1 bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg transition-all",children:[e.jsx(ee,{className:"w-4 h-4"}),e.jsx("span",{children:n("addSocialMedia")})]})})]}),e.jsxs("div",{className:"flex-1 overflow-auto",children:[u&&e.jsx("div",{className:"flex justify-center items-center h-48",children:e.jsx(ae,{})}),c&&e.jsx("p",{className:"text-center text-red-500 text-sm mt-4",children:n("userRecord.Error loading records.")}),!u&&!c&&e.jsx("div",{className:"mt-2",children:e.jsx(te,{columns:Ht({navigate:a,onDelete:x}),data:i||[],tableName:"SocialMedias",toolBarPosition:"right",extraToolbar:e.jsx("div",{className:"flex gap-2"}),itemCount:m||2,pageIndex:r,onPageChange:o,nextFunction:()=>o(r+1),prevFunction:()=>o(Math.max(r-1,0)),refresh:d})})]})]})};function U({label:r,error:t,containerClassName:a,className:s,...n}){return e.jsxs("div",{className:K("space-y-2",a),children:[r&&e.jsx(I,{htmlFor:n.id,className:"dark:text-gray-300",children:r}),e.jsx(mt,{className:K(t&&"border-destructive",s,"dark:bg-gray-600 dark:text-gray-200 dark:border-gray-500"),...n}),t&&e.jsx("p",{className:"text-xs text-destructive mt-1",children:t})]})}function re({idAm:r,idEn:t,label:a,error:s,register:n,errors:l}){var i,d;return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-blue-500 mr-2 rounded-full"}),a]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(I,{htmlFor:"messageTitleAm",className:"text-gray-700 dark:text-gray-300",children:[a," Amharic*"]}),e.jsx(U,{id:r,...n(r,{required:s}),error:(i=l.idAm)==null?void 0:i.message,placeholder:"message title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(I,{htmlFor:t,className:"text-gray-700 dark:text-gray-300",children:[a," (English)*"]}),e.jsx(U,{id:t,...n(t,{required:s}),error:(d=l.idEn)==null?void 0:d.message,placeholder:"Message Title"})]})]})]})}function Re({id:r,type:t,label:a,error:s,register:n,errors:l}){return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-purple-500 mr-2 rounded-full"}),a]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{id:r,type:t,...n(r,{required:s}),placeholder:a}),l.link&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:l.id.message})]})]})}function fe({idAm:r,idEn:t,label:a,error:s,register:n,errors:l}){return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-purple-500 mr-2 rounded-full"}),a]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(I,{htmlFor:"messageContentAm",className:"text-gray-700 dark:text-gray-300",children:[a,"Amharic*"]}),e.jsx(de,{id:r,...n(r,{required:s}),rows:4,placeholder:"content",className:"min-h-[120px] dark:bg-gray-600 dark:text-gray-200"}),l.idAm&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:l.idAm.message})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(I,{htmlFor:"messageContentEn",className:"text-gray-700 dark:text-gray-300",children:[a,"English*"]}),e.jsx(de,{id:t,...n(t,{required:s}),rows:4,placeholder:"content",className:"min-h-[120px] dark:bg-gray-600 dark:text-gray-200"}),l.idEn&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:l.idEn.message})]})]})]})}function ne({idAm:r,label:t,watch:a,setValue:s}){const n=a(r)??!1;return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-primary-500 mr-2 rounded-full"}),t]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(I,{htmlFor:r,className:"text-gray-700 dark:text-gray-300 font-medium",children:"Is Active"}),e.jsx("button",{type:"button",onClick:()=>s(r,!a(r)),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${n?"bg-primary-500":"bg-gray-300 dark:bg-gray-500"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${n?"translate-x-6":"translate-x-1"}`})})]})]})}const Te=({title:r,children:t})=>e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-blue-500 mr-2 rounded-full"}),r]}),t]}),Qt=({children:r})=>e.jsx("div",{className:"space-y-2",children:r}),Xt=({children:r})=>e.jsx("p",{className:"text-xs text-red-500 mt-1",children:r}),Me=({label:r,preview:t,existingName:a,register:s,error:n,onView:l,id:i,isRequired:d=!1})=>e.jsxs(Qt,{children:[e.jsxs(I,{className:"text-gray-700 dark:text-gray-300 block mb-2",children:[r," ",d&&"*"]}),t&&e.jsxs("div",{className:"mb-3 flex items-center justify-between bg-blue-50 dark:bg-blue-900/30 p-3 rounded-lg",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx(pe,{className:"h-5 w-5 text-blue-500 dark:text-blue-400 mr-2"}),e.jsx("span",{className:"text-sm font-medium truncate max-w-[200px] dark:text-gray-200",children:a||"Selected Image"})]}),e.jsx(w,{type:"button",variant:"ghost",size:"sm",onClick:l,className:"text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300",children:"Preview"})]}),e.jsx("div",{children:e.jsx(U,{id:i,type:"file",accept:"image/*",...s,error:n})}),n&&e.jsx(Xt,{children:n})]});function Wt({idAm:r,label:t,error:a,register:s,errors:n,watch:l}){const i=(l==null?void 0:l(r))??"#000000";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(I,{htmlFor:"color",className:"text-gray-700 dark:text-gray-300",children:[t,"*"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{id:r,type:"color",...s(r,{required:a}),className:"h-10 w-16 cursor-pointer border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400 font-mono",children:i})]}),n.color&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:n.color.message})]})}function Ae({id:r,item:t,label:a,error:s,register:n,control:l,errors:i}){return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-primary-500 mr-2 rounded-full"}),"Select Type"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"id",className:"text-gray-700 dark:text-gray-300 font-medium",children:a}),e.jsx(pt,{name:r||"",control:l,rules:{required:"message type is required"},render:({field:d})=>e.jsxs(yt,{onValueChange:d.onChange,value:d.value,children:[e.jsx(bt,{className:"w-full dark:bg-gray-600 dark:text-gray-200 dark:border-gray-500",children:e.jsx(ft,{placeholder:"Select type"})}),e.jsx(wt,{className:"dark:bg-gray-700 dark:border-gray-600",children:t?.map(x=>e.jsx(jt,{value:x.value,className:"dark:text-gray-200 dark:hover:bg-gray-600",children:x.label},x.value))})]})}),i.type&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:i.type.message})]})]})}const Qe=({handleSubmit:r,handleCancel:t,watch:a,control:s,setValue:n,register:l,errors:i,isSubmitting:d,reset:x,item:c,label:u})=>{var p,y,h;const m=(p=a("image"))==null?void 0:p[0],[o,g]=b.useState((c==null?void 0:c.presigned)||"");return b.useEffect(()=>{c!=null&&c.presigned&&g(c.presigned)},[c]),b.useEffect(()=>{if(m){const f=URL.createObjectURL(m);return g(f),()=>URL.revokeObjectURL(f)}},[m]),e.jsx("div",{className:"max-h-[80vh] overflow-y-auto p-6 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm",children:e.jsxs("form",{onSubmit:r,className:"space-y-8",children:[e.jsx(re,{idEn:"GoalTitleEn",idAm:"GoalTitleAm",label:"Title",error:"Title is Required",errors:i,register:l}),e.jsx(fe,{idAm:"GoalDescriptionAm",idEn:"GoalDescriptionEn",label:"Description",error:"Description is Required",errors:i,register:l}),e.jsx(ne,{idAm:"isActive",label:"Status",watch:a,setValue:n}),e.jsx(Te,{title:"Image",children:e.jsx(Me,{label:"Experience Image*",preview:o,existingName:(y=c==null?void 0:c.fileInfo)==null?void 0:y.originalname,register:l("image"),error:(h=i.image)==null?void 0:h.message,onView:()=>window.open(o,"_blank"),id:"image",isRequired:!1})}),e.jsxs("div",{className:"flex justify-end gap-3 pt-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(w,{variant:"outline",onClick:t,type:"button",disabled:d,className:"px-6 py-2 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700",children:"Cancel"}),e.jsx(w,{type:"submit",disabled:d,className:"px-6 py-2 bg-purple-600 hover:bg-purple-700 text-white",children:d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4 animate-spin"}),"..."]}):u})]})]})})},Yt=()=>{const{register:r,handleSubmit:t,formState:{errors:a},watch:s,control:n,setValue:l}=F({defaultValues:{GoalTitleEn:"",GoalTitleAm:"",GoalDescriptionAm:"",GoalDescriptionEn:"",isActive:!1}}),i=M(),{createItem:d}=Ie(),[x,c]=b.useState(!1),u=async o=>{var g;c(!0);try{const p=(g=o.image)==null?void 0:g[0];if(!p)throw new Error("images are required");const y={goalTitle:{am:o.GoalTitleAm||"",en:o.GoalTitleEn||""},goalDescription:{am:o.GoalDescriptionEn||"",en:o.GoalDescriptionEn||""},fileInfo:{fileName:p.name,contentType:p.type,size:p.size,originalname:p.name},isActive:o.isActive};await d({data:y,imageFile:p}),C.success(" created successfully"),i(-1)}catch{C.error("Failed to create Goal"),c(!1)}finally{c(!1)}},m=()=>{i(-1)};return e.jsx(Qe,{handleSubmit:t(u),handleCancel:m,watch:s,setValue:l,control:n,register:r,errors:a,isSubmitting:x,label:"Add Goal"})},Xe=({handleSubmit:r,handleCancel:t,watch:a,control:s,setValue:n,register:l,errors:i,isSubmitting:d,reset:x,item:c,label:u})=>e.jsx("div",{className:"max-h-[80vh] overflow-y-auto p-6 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm",children:e.jsxs("form",{onSubmit:r,className:"space-y-8",children:[e.jsx(re,{idEn:"VisionTitleEn",idAm:"VisionTitleAm",label:"Title",error:"Title is Required",errors:i,register:l}),e.jsx(fe,{idAm:"VisionDescriptionAm",idEn:"VisionDescriptionEn",label:"Description",error:"Description is Required",errors:i,register:l}),e.jsx(ne,{idAm:"isActive",label:"Status",watch:a,setValue:n}),e.jsxs("div",{className:"flex justify-end gap-3 pt-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(w,{variant:"outline",onClick:t,type:"button",disabled:d,className:"px-6 py-2 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700",children:"Cancel"}),e.jsx(w,{type:"submit",disabled:d,className:"px-6 py-2 bg-purple-600 hover:bg-purple-700 text-white",children:d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4 animate-spin"}),"..."]}):u})]})]})}),Jt=()=>{const{register:r,handleSubmit:t,formState:{errors:a},watch:s,control:n,setValue:l}=F({defaultValues:{visionTitleEn:"",visionTitleAm:"",visionDescriptionAm:"",visionDescriptionEn:"",isActive:!1}}),i=M(),{createItem:d}=Ee(),[x,c]=b.useState(!1),u=async o=>{c(!0);try{const g={visionTitle:{am:o.visionTitleAm||"",en:o.visionTitleEn||""},visionDescription:{am:o.visionDescriptionAm||"",en:o.visionDescriptionEn||""},isActive:o.isActive};await d({data:g}),C.success(" created successfully"),i(-1)}catch{C.error("Failed to create Vision"),c(!1)}finally{c(!1)}},m=()=>{i(-1)};return e.jsx(Xe,{handleSubmit:t(u),handleCancel:m,watch:s,setValue:l,control:n,register:r,errors:a,isSubmitting:x,label:"Add Vision"})},Zt=({onDelete:r,navigate:t})=>[{accessorKey:"title",header:()=>k("toogle.title"),cell:({row:a})=>{var i,d;const s=a.original,l=V.language==="am"?(i=s.title)==null?void 0:i.am:(d=s.title)==null?void 0:d.en;return e.jsx("span",{className:"font-medium",children:l||"-"})},enableHiding:!0},{accessorKey:"category",header:()=>k("toogle.category"),cell:({row:a})=>{var i,d,x,c;const s=a.original,l=V.language==="am"?(d=(i=s.newsCategory)==null?void 0:i.newsCategoryTitle)==null?void 0:d.am:(c=(x=s.newsCategory)==null?void 0:x.newsCategoryTitle)==null?void 0:c.en;return e.jsx("span",{className:"text-sm text-blue-600 bg-blue-50 px-2 py-1 rounded-full",children:l||"No Category"})},enableHiding:!0},{accessorKey:"featured",header:()=>k("toogle.featured"),cell:({row:a})=>{const s=a.original;return e.jsx("div",{className:"flex items-center justify-center",children:s.isFeatured?e.jsx($e,{className:"h-4 w-4 text-yellow-500 fill-current"}):e.jsx($e,{className:"h-4 w-4 text-gray-300"})})},enableHiding:!0},{accessorKey:"status",header:()=>k("toogle.status"),cell:({row:a})=>{const s=a.original;return e.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${s.isActive?"bg-primary-100 text-primary-800":"bg-red-100 text-red-800"}`,children:s.isActive?"Active":"Inactive"})},enableHiding:!0},{accessorKey:"createdAt",header:()=>k("toogle.createdAt"),cell:({row:a})=>{const s=a.original,n=V.language,l=s==null?void 0:s.amharicCreatedAt,i=new Date(s.createdAt).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}),d=n==="am"?l:i;return e.jsx("span",{className:"text-sm text-gray-500",children:d})},enableHiding:!0},{accessorKey:"Actions",header:()=>k("toogle.Actions"),cell:({row:a})=>e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>t(`/user-management/web-management/News/EditNews/${a.original.id}`),title:"Edit",children:e.jsx(Z,{className:"h-4 w-4"})}),r&&e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>r(a.original.id),title:"Delete",children:e.jsx(J,{className:"h-4 w-4 text-destructive"})})]})}],ve=r=>({...r,title:r.title||{am:"",en:""},subTitle:r.subTitle||{am:"",en:""},body:r.body||{am:"",en:""}}),H={async createItem(r){const t=await N.post("/news",r,{headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}});return ve(t.data)},async getItems(r){var a;const t=await N.get("/news/list-with-presigned",{params:r,headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}});return{...t.data,items:((a=t.data.items)==null?void 0:a?.map(ve))||[]}},async getItem(r){var s;const t=await N.get("/news/list-with-presigned",{params:{id:r},headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}}),a=((s=t.data.items)==null?void 0:s[0])||t.data;return ve(a)},async updateItem(r,t){const a={...t},s=await N.put(`/news/${r}`,a,{headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}});return ve(s.data)},async deleteItem(r){await N.delete(`/news/${r}`,{headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}})},async uploadImage(r,t){var s,n,l,i;if(!t)throw new Error("Upload URL is undefined.");const a=await He.validateFileForUpload(r,{allowedMimeTypes:["image/png","image/jpeg","image/gif","image/webp"],allowedExtensions:[".png",".jpg",".jpeg",".gif",".webp"],maxSizeMB:10,uploadContext:"signature"});if(!a.isValid)throw new Error(((s=a.clientValidation.fileName)==null?void 0:s.error)||((n=a.clientValidation.extension)==null?void 0:n.error)||((l=a.clientValidation.mimeType)==null?void 0:l.error)||((i=a.clientValidation.size)==null?void 0:i.error)||"File validation failed");return be.put(t,r,{headers:{"Content-Type":r.type}})},async updateUploadStatus(r,t){await N.patch(`/news/${r}/upload-status`,{uploadedSuccessfully:t},{headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}})}},Pe=(r,t)=>{const a=X(),{data:s,isLoading:n,error:l,refetch:i}=L({queryKey:["News",t],queryFn:async()=>await H.getItem(t||""),enabled:!!t}),{data:d,refetch:x}=L({queryKey:["News1",r],queryFn:async()=>await H.getItems(r)}),c=T({mutationFn:async o=>{const g=await H.createItem(o.data);if(!g.id)throw new Error("Failed to create News item");try{await H.uploadImage(o.imageFile,g.presigned)}catch(p){throw await H.deleteItem(g.id),p}return await H.updateUploadStatus(g.id,!0),g},onSuccess:()=>{a.invalidateQueries({queryKey:["News",r]}),a.invalidateQueries({queryKey:["News1",r]})}}),u=T({mutationFn:async({id:o,data:g,imageFile:p})=>{const y=await H.updateItem(o,g);if(p&&y.presigned){try{await H.uploadImage(p,y.presigned)}catch(h){throw h}await H.updateUploadStatus(o,!0)}return y},onSuccess:()=>{a.invalidateQueries({queryKey:["News",r]}),a.invalidateQueries({queryKey:["News1",r]})}}),m=T({mutationFn:H.deleteItem,onSuccess:()=>{a.invalidateQueries({queryKey:["News",r]}),a.invalidateQueries({queryKey:["News1",r]})}});return{items:d==null?void 0:d.items,singleItem:s,count:d==null?void 0:d.count,isLoading:n,error:l,createItem:c.mutateAsync,updateItem:u.mutateAsync,deleteItem:m.mutateAsync,isCreating:c.isPending,isUpdating:u.isPending,isDeleting:m.isPending,refetch:x}},ea=()=>{const[r,t]=b.useState(0),[a,s]=b.useState(null),n=10,{t:l}=z(),i=M(),d=b.useMemo(()=>({skip:r*n,take:n,orderBy:"createdAt:DESC"}),[r]),{items:x,refetch:c,deleteItem:u,error:m,isLoading:o,count:g}=Pe(d),p=j=>{t(j)},y=async j=>{s(j)},h=async()=>{if(a)try{await u(a),C.success("News deleted successfully"),c()}catch{C.error("Failed to delete news")}finally{s(null)}},f=()=>{s(null)};return e.jsxs("div",{className:"flex flex-col h-full w-full p-6 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-100 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 border-b pb-3 border-gray-200 dark:border-gray-700",children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-800 dark:text-gray-200",children:l("nav.news")}),e.jsx(W,{to:"/user-management/web-Management/News/AddNews",children:e.jsxs(w,{variant:"addRecordBtn",className:"flex items-center gap-1 bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg transition-all",children:[e.jsx(ee,{className:"w-4 h-4"}),e.jsx("span",{children:l("addNews")})]})})]}),e.jsxs("div",{className:"flex-1 overflow-auto",children:[o&&e.jsx("div",{className:"flex justify-center items-center h-48",children:e.jsx(ae,{})}),m&&e.jsx("p",{className:"text-center text-red-500 text-sm mt-4",children:l("userRecord.Error loading records.")}),!o&&!m&&e.jsx("div",{className:"mt-2",children:e.jsx(te,{columns:Zt({navigate:i,onDelete:y}),data:x||[],tableName:"News",toolBarPosition:"right",extraToolbar:e.jsx("div",{className:"flex gap-2"}),itemCount:g||0,pageIndex:r,onPageChange:p,nextFunction:()=>p(r+1),prevFunction:()=>p(Math.max(r-1,0)),refresh:c})})]}),a&&e.jsx("div",{className:"fixed inset-0 bg-black/50 dark:bg-black/70 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"Confirm Delete"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:"Are you sure you want to delete this news? This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(w,{variant:"outline",onClick:f,className:"px-4 py-2 dark:border-gray-600 dark:text-gray-200",children:"Cancel"}),e.jsx(w,{onClick:h,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white",children:"Delete"})]})]})})]})},ta=({navigate:r,onDelete:t})=>[{accessorKey:"title",header:()=>k("toogle.title"),cell:({row:a})=>{var l,i;const s=a.original,n=V.language;return n==="am"?e.jsx("span",{children:((l=s.name)==null?void 0:l.am)||"-"}):n==="en"?e.jsx("span",{children:((i=s.name)==null?void 0:i.en)||"-"}):e.jsx("span",{children:"-"})},enableHiding:!0},{accessorKey:"link",header:()=>k("toogle.link"),cell:({row:a})=>{const s=a.original;return e.jsx("span",{children:s.value||"-"})},enableHiding:!0},{accessorKey:"status",header:()=>k("toogle.status"),cell:({row:a})=>{const s=a.original;return e.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${s.isActive?"bg-primary-100 text-primary-800":"bg-red-100 text-red-800"}`,children:s.isActive?"Active":"Inactive"})},enableHiding:!0},{accessorKey:"createdAt",header:()=>k("toogle.createdAt"),cell:({row:a})=>{const s=a.original,n=V.language,l=s==null?void 0:s.amharicCreatedAt,i=new Date(s.createdAt).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}),d=n==="am"?l:i;return e.jsx("span",{className:"text-sm text-gray-500",children:d})},enableHiding:!0},{accessorKey:"Actions",header:()=>k("toogle.Actions"),cell:({row:a})=>e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>r(`/user-management/web-management/ContactUs/EditContactUs/${a.original.id}`),children:e.jsx(Z,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>t(a.original.id),children:e.jsx(J,{className:"h-4 w-4 text-destructive"})})]})}],xe={async createItem(r){return(await N.post("/contact-us",r,{headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}})).data},async getItems(r){return(await N.get("/contact-us/list",{params:r,headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}})).data},async getItem(r){return(await N.get(`/contact-us/${r}`)).data},async updateItem(r,t){const a={...t};return(await N.put(`/contact-us/${r}`,a)).data},async deleteItem(r){await N.delete(`/contact-us/${r}`)}},Ue=(r,t)=>{const a=X(),{data:s,isLoading:n,error:l}=L({queryKey:["ContactUs",t],queryFn:async()=>await xe.getItem(t||""),enabled:!!t}),{data:i,refetch:d}=L({queryKey:["ContactUs1",r],queryFn:async()=>await xe.getItems(r)}),x=T({mutationFn:async m=>{const o=await xe.createItem(m.data);if(!o.id)throw new Error("Failed to create ContactUs item");return o},onSuccess:()=>{a.invalidateQueries({queryKey:["ContactUs1",r]})}}),c=T({mutationFn:({id:m,data:o})=>xe.updateItem(m,o),onSuccess:()=>{a.invalidateQueries({queryKey:["ContactUs1",r]})}}),u=T({mutationFn:xe.deleteItem,onSuccess:()=>{a.invalidateQueries({queryKey:["ContactUs1",r]})}});return{items:i==null?void 0:i.items,singleItem:s,count:i==null?void 0:i.count,isLoading:n,error:l,createItem:x.mutateAsync,updateItem:c.mutateAsync,deleteItem:u.mutateAsync,isCreating:x.isPending,isUpdating:c.isPending,isDeleting:u.isPending,refetch:d}},aa=()=>{const[r,t]=b.useState(0),a=M(),s=10,{t:n}=z(),i={isActive:!0,...{skip:r*s,take:s,orderBy:"createdAt:DESC"}},{items:d,refetch:x,deleteItem:c,error:u,isLoading:m,count:o}=Ue(i),g=p=>{t(p)};return e.jsxs("div",{className:"flex flex-col h-full w-full p-6 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-100 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 border-b pb-3 border-gray-200 dark:border-gray-700",children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-800 dark:text-gray-200",children:n("contactUs")}),e.jsx(W,{to:"/user-management/web-Management/ContactUs/AddContactUs",children:e.jsxs(w,{variant:"addRecordBtn",className:"flex items-center gap-1 bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg transition-all",children:[e.jsx(ee,{className:"w-4 h-4"}),e.jsx("span",{children:n("addContactUs")})]})})]}),e.jsxs("div",{className:"flex-1 overflow-auto",children:[m&&e.jsx("div",{className:"flex justify-center items-center h-48",children:e.jsx(ae,{})}),u&&e.jsx("p",{className:"text-center text-red-500 text-sm mt-4",children:n("userRecord.Error loading records.")}),!m&&!u&&e.jsx("div",{className:"mt-2",children:e.jsx(te,{columns:ta({navigate:a,onDelete:c}),data:d||[],tableName:"ContactUs",toolBarPosition:"right",extraToolbar:e.jsx("div",{className:"flex gap-2"}),itemCount:o||2,pageIndex:r,onPageChange:g,nextFunction:()=>g(r+1),prevFunction:()=>g(Math.max(r-1,0)),refresh:x})})]})]})},sa=({navigate:r,onDelete:t})=>[{accessorKey:"title",header:()=>k("toogle.title"),cell:({row:a})=>{var l,i;const s=a.original,n=V.language;return n==="am"?e.jsx("span",{children:((l=s.label)==null?void 0:l.am)||"-"}):n==="en"?e.jsx("span",{children:((i=s.label)==null?void 0:i.en)||"-"}):e.jsx("span",{children:"-"})},enableHiding:!0},{accessorKey:"description",header:()=>k("toogle.description"),cell:({row:a})=>{var i,d;const s=a.original,l=V.language==="am"?(i=s.description)==null?void 0:i.am:(d=s.description)==null?void 0:d.en;return e.jsx("span",{className:"text-sm text-gray-600 max-w-xs truncate block",children:l||"-"})},enableHiding:!0},{accessorKey:"link",header:()=>k("toogle.link"),cell:({row:a})=>{const s=a.original;return e.jsx("span",{children:s.link||"-"})},enableHiding:!0},{accessorKey:"status",header:()=>k("toogle.status"),cell:({row:a})=>{const s=a.original;return e.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${s.isActive?"bg-primary-100 text-primary-800":"bg-red-100 text-red-800"}`,children:s.isActive?"Active":"Inactive"})},enableHiding:!0},{accessorKey:"createdAt",header:()=>k("toogle.createdAt"),cell:({row:a})=>{const s=a.original,n=V.language,l=s==null?void 0:s.amharicCreatedAt,i=new Date(s.createdAt).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}),d=n==="am"?l:i;return e.jsx("span",{className:"text-sm text-gray-500",children:d})},enableHiding:!0},{accessorKey:"Actions",header:()=>k("toogle.Actions"),cell:({row:a})=>e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>r(`/user-management/web-management/Modules/EditModules/${a.original.id}`),children:e.jsx(Z,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>t(a.original.id),children:e.jsx(J,{className:"h-4 w-4 text-destructive"})})]})}],he={async createItem(r){return(await N.post("/link",r,{headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}})).data},async getItems(r){return(await N.get("/link/list",{params:r,headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}})).data},async getItem(r){return(await N.get(`/link/${r}`)).data},async updateItem(r,t){const a={...t};return(await N.put(`/link/${r}`,a)).data},async deleteItem(r){await N.delete(`/link/${r}`)}},De=(r,t)=>{const a=X(),{data:s,isLoading:n,error:l}=L({queryKey:["Modules",t],queryFn:async()=>await he.getItem(t||""),enabled:!!t}),{data:i,refetch:d}=L({queryKey:["Modules1",r],queryFn:async()=>await he.getItems(r)}),x=T({mutationFn:async m=>{const o=await he.createItem(m.data);if(!o.id)throw new Error("Failed to create Modules item");return o},onSuccess:()=>{a.invalidateQueries({queryKey:["Modules1",r]})}}),c=T({mutationFn:({id:m,data:o})=>he.updateItem(m,o),onSuccess:()=>{a.invalidateQueries({queryKey:["Modules1",r]})}}),u=T({mutationFn:he.deleteItem,onSuccess:()=>{a.invalidateQueries({queryKey:["Modules1",r]})}});return{items:i==null?void 0:i.items,singleItem:s,count:i==null?void 0:i.count,isLoading:n,error:l,createItem:x.mutateAsync,updateItem:c.mutateAsync,deleteItem:u.mutateAsync,isCreating:x.isPending,isUpdating:c.isPending,isDeleting:u.isPending,refetch:d}},ra=()=>{const[r,t]=b.useState(0),a=M(),s=10,{t:n}=z(),l=b.useMemo(()=>({skip:r*s,take:s,orderBy:"createdAt:DESC"}),[r]),{items:i,refetch:d,deleteItem:x,error:c,isLoading:u,count:m}=De(l),o=g=>{t(g)};return e.jsxs("div",{className:"flex flex-col h-full w-full p-6 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-100 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 border-b pb-3 border-gray-200 dark:border-gray-700",children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-800 dark:text-gray-200",children:n("modules")}),e.jsx(W,{to:"/user-management/web-Management/Modules/AddModules",children:e.jsxs(w,{variant:"addRecordBtn",className:"flex items-center gap-1 bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg transition-all",children:[e.jsx(ee,{className:"w-4 h-4"}),e.jsx("span",{children:n("addModules")})]})})]}),e.jsxs("div",{className:"flex-1 overflow-auto",children:[u&&e.jsx("div",{className:"flex justify-center items-center h-48",children:e.jsx(ae,{})}),c&&e.jsx("p",{className:"text-center text-red-500 text-sm mt-4",children:n("userRecord.Error loading records.")}),!u&&!c&&e.jsx("div",{className:"mt-2",children:e.jsx(te,{columns:sa({navigate:a,onDelete:x}),data:i||[],tableName:"Moduless",toolBarPosition:"right",extraToolbar:e.jsx("div",{className:"flex gap-2"}),itemCount:m||2,pageIndex:r,onPageChange:o,nextFunction:()=>o(r+1),prevFunction:()=>o(Math.max(r-1,0)),refresh:d})})]})]})},na=({onDelete:r,navigate:t})=>[{accessorKey:"image",header:()=>k("toogle.image"),cell:({row:a})=>{const s=a.original;return s.presigned?e.jsx("img",{src:s.presigned,alt:"Category",className:"w-12 h-12 object-cover rounded-md"}):e.jsx("div",{className:"w-12 h-12 bg-gray-200 rounded-md flex items-center justify-center",children:e.jsx("span",{className:"text-xs text-gray-500",children:"No Image"})})},enableHiding:!0},{accessorKey:"title",header:()=>k("toogle.title"),cell:({row:a})=>{var i,d;const s=a.original,l=V.language==="am"?(i=s.newsCategoryTitle)==null?void 0:i.am:(d=s.newsCategoryTitle)==null?void 0:d.en;return e.jsx("span",{className:"font-medium",children:l||"-"})},enableHiding:!0},{accessorKey:"description",header:()=>k("toogle.description"),cell:({row:a})=>{var i,d;const s=a.original,l=V.language==="am"?(i=s.newsCategoryDescription)==null?void 0:i.am:(d=s.newsCategoryDescription)==null?void 0:d.en;return e.jsx("span",{className:"text-sm text-gray-600 max-w-xs truncate block",children:l||"-"})},enableHiding:!0},{accessorKey:"color",header:()=>k("toogle.color"),cell:({row:a})=>{const s=a.original;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full border border-gray-300",style:{backgroundColor:s.color||"#007BFF"}}),e.jsx("span",{className:"text-xs font-mono",children:s.color||"#007BFF"})]})},enableHiding:!0},{accessorKey:"status",header:()=>k("toogle.status"),cell:({row:a})=>{const s=a.original;return e.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${s.isActive?"bg-primary-100 text-primary-800":"bg-red-100 text-red-800"}`,children:s.isActive?"Active":"Inactive"})},enableHiding:!0},{accessorKey:"createdAt",header:()=>k("toogle.createdAt"),cell:({row:a})=>{const s=a.original,n=V.language,l=s==null?void 0:s.amharicCreatedAt,i=new Date(s.createdAt).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}),d=n==="am"?l:i;return e.jsx("span",{className:"text-sm text-gray-500",children:d})},enableHiding:!0},{accessorKey:"Actions",header:()=>k("toogle.Actions"),cell:({row:a})=>e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>t(`/user-management/web-management/Category/EditCategory/${a.original.id}`),title:"Edit",children:e.jsx(Z,{className:"h-4 w-4"})}),r&&e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>r(a.original.id),title:"Delete",children:e.jsx(J,{className:"h-4 w-4 text-destructive"})})]})}],Ne=r=>({...r,NewsCategoryTitle:r.NewsCategoryTitle||r.newsCategoryTitle||{am:"",en:""},NewsCategoryDescription:r.NewsCategoryDescription||r.newsCategoryDescription||{am:"",en:""}}),_={async createItem(r){const t=await N.post("/news-category",r,{headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}});return Ne(t.data)},async getItems(r){var a;const t=await N.get("/news-category/list-with-presigned",{params:r,headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}});return{...t.data,items:((a=t.data.items)==null?void 0:a?.map(Ne))||[]}},async getItem(r){return(await N.get(`/news-category/${r}`,{headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}})).data},async updateItem(r,t){const a={...t},s=await N.put(`/news-category/${r}`,a,{headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}});return Ne(s.data)},async deleteItem(r){await N.delete(`/news-category/${r}`,{headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}})},async changeStatus(r){const t=await N.put(`/news-category/change-status/${r}`,{isCurrent:!0},{headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}});return Ne(t.data)},async uploadImage(r,t){if(!t)throw new Error("Upload URL is undefined.");return be.put(t,r,{headers:{"Content-Type":r.type}})},async updateUploadStatus(r,t){await N.patch(`/news-category/${r}/upload-status`,{uploadedSuccessfully:t},{headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}})}},we=(r,t)=>{const a=X(),{data:s,isLoading:n,error:l,refetch:i}=L({queryKey:["NewsCategory",t],queryFn:async()=>await _.getItem(t||""),enabled:!!t}),{data:d,refetch:x}=L({queryKey:["NewsCategory1",r],queryFn:async()=>await _.getItems(r)}),c=T({mutationFn:async o=>{const g=await _.createItem(o.data);if(!g.id)throw new Error("Failed to create NewsCategory item");try{await _.uploadImage(o.imageFile,g.presigned)}catch(p){throw await _.deleteItem(g.id),p}return await _.updateUploadStatus(g.id,!0),g},onSuccess:()=>{a.invalidateQueries({queryKey:["NewsCategory",r]}),a.invalidateQueries({queryKey:["NewsCategory1",r]})}}),u=T({mutationFn:async({id:o,data:g,imageFile:p})=>{const y=await _.updateItem(o,g);if(p&&y.presigned){try{await _.uploadImage(p,y.presigned)}catch(h){throw h}await _.updateUploadStatus(o,!0)}return y},onSuccess:()=>{a.invalidateQueries({queryKey:["NewsCategory",r]}),a.invalidateQueries({queryKey:["NewsCategory1",r]})}}),m=T({mutationFn:_.deleteItem,onSuccess:()=>{a.invalidateQueries({queryKey:["NewsCategory",r]}),a.invalidateQueries({queryKey:["NewsCategory1",r]})}});return{items:d==null?void 0:d.items,singleItem:s,count:d==null?void 0:d.count,isLoading:n,error:l,createItem:c.mutateAsync,updateItem:u.mutateAsync,deleteItem:m.mutateAsync,isCreating:c.isPending,isUpdating:u.isPending,isDeleting:m.isPending,refetch:x}},ia=()=>{const[r,t]=b.useState(0),[a,s]=b.useState(null),n=M(),l=10,{t:i}=z(),d=b.useMemo(()=>({skip:r*l,take:l,orderBy:"createdAt:DESC"}),[r]),{items:x,refetch:c,deleteItem:u,error:m,isLoading:o,count:g}=we(d),p=j=>{t(j)},y=async j=>{s(j)},h=async()=>{if(a)try{await u(a),C.success("News category deleted successfully"),c()}catch{C.error("Failed to delete news category")}finally{s(null)}},f=()=>{s(null)};return e.jsxs("div",{className:"flex flex-col h-full w-full p-6 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-100 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 border-b pb-3 border-gray-200 dark:border-gray-700",children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-800 dark:text-gray-200",children:i("newsCategory")}),e.jsx(W,{to:"/user-management/web-Management/Category/AddCategory",children:e.jsxs(w,{variant:"addRecordBtn",className:"flex items-center gap-1 bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg transition-all",children:[e.jsx(ee,{className:"w-4 h-4"}),e.jsx("span",{children:i("addNewsCategory")})]})})]}),e.jsxs("div",{className:"flex-1 overflow-auto",children:[o&&e.jsx("div",{className:"flex justify-center items-center h-48",children:e.jsx(ae,{})}),m&&e.jsx("p",{className:"text-center text-red-500 text-sm mt-4",children:i("userRecord.Error loading records.")}),!o&&!m&&e.jsx("div",{className:"mt-2",children:e.jsx(te,{columns:na({navigate:n,onDelete:y}),data:x||[],tableName:"NewsCategorys",toolBarPosition:"right",extraToolbar:e.jsx("div",{className:"flex gap-2"}),itemCount:g||2,pageIndex:r,onPageChange:p,nextFunction:()=>p(r+1),prevFunction:()=>p(Math.max(r-1,0)),refresh:c})})]}),a&&e.jsx("div",{className:"fixed inset-0 bg-black/50 dark:bg-black/70 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"Confirm Delete"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:"Are you sure you want to delete this news category? This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(w,{variant:"outline",onClick:f,className:"px-4 py-2 dark:border-gray-600 dark:text-gray-200",children:"Cancel"}),e.jsx(w,{onClick:h,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white",children:"Delete"})]})]})})]})},We=({handleSubmit:r,handleCancel:t,watch:a,control:s,setValue:n,register:l,errors:i,isSubmitting:d,reset:x,item:c,label:u})=>{var p,y,h;const m=(p=a("image"))==null?void 0:p[0],[o,g]=b.useState((c==null?void 0:c.presigned)||"");return b.useEffect(()=>{c!=null&&c.presigned&&g(c.presigned)},[c]),b.useEffect(()=>{if(m){const f=URL.createObjectURL(m);return g(f),()=>URL.revokeObjectURL(f)}},[m]),e.jsx("div",{className:"max-h-[80vh] overflow-y-auto p-6 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm",children:e.jsxs("form",{onSubmit:r,className:"space-y-8",children:[e.jsx(re,{idEn:"NewsCategoryTitleEn",idAm:"NewsCategoryTitleAm",label:"Title",error:"Title is Required",errors:i,register:l}),e.jsx(fe,{idAm:"NewsCategoryDescriptionAm",idEn:"NewsCategoryDescriptionEn",label:"Description",error:"Description is Required",errors:i,register:l}),e.jsx(ne,{idAm:"isActive",label:"Status",watch:a,setValue:n}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-yellow-500 mr-2 rounded-full"}),"Appearance"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 items-center",children:[e.jsx(Wt,{idAm:"color",label:"Color",error:"Color is Required",errors:i,register:l,watch:a}),e.jsx("div",{className:"space-y-2",children:e.jsx(Te,{title:"Image",children:e.jsx(Me,{label:"Category Image",preview:o,existingName:(y=c==null?void 0:c.fileInfo)==null?void 0:y.originalname,register:l("image"),error:(h=i.image)==null?void 0:h.message,onView:()=>window.open(o,"_blank"),id:"image",isRequired:!1})})})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(w,{variant:"outline",onClick:t,type:"button",disabled:d,className:"px-6 py-2 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700",children:"Cancel"}),e.jsx(w,{type:"submit",disabled:d,className:"px-6 py-2 bg-purple-600 hover:bg-purple-700 text-white",children:d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4 animate-spin"}),"..."]}):u})]})]})})},la=()=>{const{register:r,handleSubmit:t,formState:{errors:a},watch:s,control:n,setValue:l}=F({defaultValues:{NewsCategoryTitleEn:"",NewsCategoryTitleAm:"",NewsCategoryDescriptionAm:"",NewsCategoryDescriptionEn:"",color:"",isActive:!1}}),i=M(),{createItem:d}=we(),[x,c]=b.useState(!1),u=async o=>{var g;c(!0);try{const p=(g=o.image)==null?void 0:g[0];if(!p)throw new Error("images are required");const y={newsCategoryTitle:{am:o.NewsCategoryTitleAm||"",en:o.NewsCategoryTitleEn||""},newsCategoryDescription:{am:o.NewsCategoryDescriptionAm||"",en:o.NewsCategoryDescriptionEn||""},fileInfo:{fileName:p.name,contentType:p.type,size:p.size,originalname:p.name},isActive:o.isActive,color:o.color||"#007BFF"};await d({data:y,imageFile:p}),C.success("News category created successfully"),i(-1)}catch{C.error("Failed to create NewsCategory"),c(!1)}finally{c(!1)}},m=()=>{i(-1)};return e.jsx(We,{handleSubmit:t(u),handleCancel:m,watch:s,setValue:l,control:n,register:r,errors:a,isSubmitting:x,label:"Add News Category"})},oa=()=>{const{id:r}=$(),{singleItem:t,updateItem:a}=we(void 0,r),[s,n]=b.useState(!1),l=M(),i=b.useMemo(()=>{var h,f,j,v;return{NewsCategoryTitleEn:((h=t==null?void 0:t.newsCategoryTitle)==null?void 0:h.en)||"",NewsCategoryTitleAm:((f=t==null?void 0:t.newsCategoryTitle)==null?void 0:f.am)||"",NewsCategoryDescriptionAm:((j=t==null?void 0:t.newsCategoryDescription)==null?void 0:j.am)||"",NewsCategoryDescriptionEn:((v=t==null?void 0:t.newsCategoryDescription)==null?void 0:v.en)||"",color:(t==null?void 0:t.color)||"#007BFF",isActive:(t==null?void 0:t.isActive)||!1,image:void 0}},[t]),{register:d,handleSubmit:x,watch:c,control:u,reset:m,setValue:o,formState:{errors:g}}=F({defaultValues:i});b.useEffect(()=>{t&&m(i)},[t,i,m]);const p=async h=>{var f;if(t){n(!0);try{const j=(f=h.image)==null?void 0:f[0],v={newsCategoryTitle:{am:h.NewsCategoryTitleAm||"",en:h.NewsCategoryTitleEn||""},newsCategoryDescription:{am:h.NewsCategoryDescriptionAm||"",en:h.NewsCategoryDescriptionEn||""},...j&&{fileInfo:{fileName:j.name,contentType:j.type,size:j.size,originalname:j.name}},isActive:h.isActive,color:h.color};await a({id:t.id,data:v,...j&&{imageFile:j}}),C.success("News category updated successfully"),l(-1)}catch{C.error("Failed to update news category"),n(!1)}}},y=()=>{l(-1)};return e.jsx(We,{handleSubmit:x(p),handleCancel:y,watch:c,setValue:o,control:u,register:d,errors:g,isSubmitting:s,label:"Edit NewsCategory",item:t})},da=()=>{var p,y,h,f,j;const{register:r,handleSubmit:t,formState:{errors:a},watch:s,setValue:n}=F({defaultValues:{titleEn:"",titleAm:"",subTitleAm:"",subTitleEn:"",bodyAm:"",bodyEn:"",newsCategoryId:"",isActive:!1,isFeatured:!1}}),l=M(),{createItem:i}=Pe(),[d,x]=b.useState(!1),u={isActive:!0,...{skip:0,take:100,orderBy:"createdAt:DESC"}},{items:m}=we(u),o=async v=>{var A;x(!0);try{const S=(A=v.image)==null?void 0:A[0];if(!S)throw new Error("Image is required");const R={newsCategoryId:v.newsCategoryId,title:{am:v.titleAm||"",en:v.titleEn||""},subTitle:{am:v.subTitleAm||"",en:v.subTitleEn||""},body:{am:v.bodyAm||"",en:v.bodyEn||""},fileInfo:{fileName:S.name,contentType:S.type,size:S.size,originalname:S.name},isActive:v.isActive,isFeatured:v.isFeatured};await i({data:R,imageFile:S}),C.success("News created successfully"),l("/user-management/web-Management/News/news")}catch{C.error("Failed to create news"),x(!1)}finally{x(!1)}},g=()=>{l(-1)};return e.jsx("div",{className:"max-h-[80vh] overflow-y-auto p-6 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm",children:e.jsxs("form",{onSubmit:t(o),className:"space-y-8",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-blue-500 mr-2 rounded-full"}),"Category"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"newsCategoryId",className:"text-gray-700 dark:text-gray-300",children:"News Category*"}),e.jsxs("select",{id:"newsCategoryId",...r("newsCategoryId",{required:"Category is required"}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-purple-500 dark:bg-gray-600 dark:text-gray-200",children:[e.jsx("option",{value:"",children:"Select a category"}),m==null?void 0:m?.map(v=>{var A;return e.jsx("option",{value:v.id,children:((A=v.newsCategoryTitle)==null?void 0:A.en)||"Unnamed Category"},v.id)})]}),a.newsCategoryId&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:a.newsCategoryId.message})]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-blue-500 mr-2 rounded-full"}),"Title"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"titleAm",className:"text-gray-700 dark:text-gray-300",children:"Title (Amharic)*"}),e.jsx(U,{id:"titleAm",...r("titleAm",{required:"Required"}),error:(p=a.titleAm)==null?void 0:p.message,placeholder:"News title in Amharic"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"titleEn",className:"text-gray-700 dark:text-gray-300",children:"Title (English)*"}),e.jsx(U,{id:"titleEn",...r("titleEn",{required:"Required"}),error:(y=a.titleEn)==null?void 0:y.message,placeholder:"News title in English"})]})]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-primary-500 mr-2 rounded-full"}),"Subtitle"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"subTitleAm",className:"text-gray-700 dark:text-gray-300",children:"Subtitle (Amharic)*"}),e.jsx(U,{id:"subTitleAm",...r("subTitleAm",{required:"Required"}),error:(h=a.subTitleAm)==null?void 0:h.message,placeholder:"News subtitle in Amharic"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"subTitleEn",className:"text-gray-700 dark:text-gray-300",children:"Subtitle (English)*"}),e.jsx(U,{id:"subTitleEn",...r("subTitleEn",{required:"Required"}),error:(f=a.subTitleEn)==null?void 0:f.message,placeholder:"News subtitle in English"})]})]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-purple-500 mr-2 rounded-full"}),"Content"]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"bodyAm",className:"text-gray-700 dark:text-gray-300",children:"Content (Amharic)*"}),e.jsx(de,{id:"bodyAm",...r("bodyAm",{required:"Required"}),rows:6,placeholder:"News content in Amharic",className:"min-h-[150px] dark:bg-gray-600 dark:text-gray-200"}),a.bodyAm&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:a.bodyAm.message})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"bodyEn",className:"text-gray-700 dark:text-gray-300",children:"Content (English)*"}),e.jsx(de,{id:"bodyEn",...r("bodyEn",{required:"Required"}),rows:6,placeholder:"News content in English",className:"min-h-[150px] dark:bg-gray-600 dark:text-gray-200"}),a.bodyEn&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:a.bodyEn.message})]})]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-orange-500 mr-2 rounded-full"}),"Settings"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(I,{htmlFor:"isActive",className:"text-gray-700 dark:text-gray-300 font-medium",children:"Is Active"}),e.jsx("button",{type:"button",onClick:()=>n("isActive",!s("isActive")),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${s("isActive")?"bg-primary-500":"bg-gray-300 dark:bg-gray-500"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${s("isActive")?"translate-x-6":"translate-x-1"}`})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(I,{htmlFor:"isFeatured",className:"text-gray-700 dark:text-gray-300 font-medium",children:"Is Featured"}),e.jsx("button",{type:"button",onClick:()=>n("isFeatured",!s("isFeatured")),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${s("isFeatured")?"bg-yellow-500":"bg-gray-300 dark:bg-gray-500"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${s("isFeatured")?"translate-x-6":"translate-x-1"}`})})]})]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-yellow-500 mr-2 rounded-full"}),"Image"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"image",className:"text-gray-700 dark:text-gray-300",children:"News Image*"}),e.jsx(U,{id:"image",type:"file",accept:"image/*",...r("image",{required:"Image is required"}),error:(j=a.image)==null?void 0:j.message})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(w,{variant:"outline",onClick:g,type:"button",disabled:d,className:"px-6 py-2 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700",children:"Cancel"}),e.jsx(w,{type:"submit",disabled:d,className:"px-6 py-2 bg-purple-600 hover:bg-purple-700 text-white",children:d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):"Create News"})]})]})})},ca=()=>{var v,A,S,R,ce,me,G;const{id:r}=$(),{singleItem:t,updateItem:a}=Pe(void 0,r),[s,n]=b.useState(!1),l=M(),i=b.useMemo(()=>{var q,P,D,ie,le,je;return{titleEn:((q=t==null?void 0:t.title)==null?void 0:q.en)||"",titleAm:((P=t==null?void 0:t.title)==null?void 0:P.am)||"",subTitleAm:((D=t==null?void 0:t.subTitle)==null?void 0:D.am)||"",subTitleEn:((ie=t==null?void 0:t.subTitle)==null?void 0:ie.en)||"",bodyAm:((le=t==null?void 0:t.body)==null?void 0:le.am)||"",bodyEn:((je=t==null?void 0:t.body)==null?void 0:je.en)||"",newsCategoryId:(t==null?void 0:t.newsCategoryId)||"",isActive:(t==null?void 0:t.isActive)||!1,isFeatured:(t==null?void 0:t.isFeatured)||!1,image:void 0}},[t]),{register:d,handleSubmit:x,watch:c,setValue:u,reset:m,formState:{errors:o}}=F({defaultValues:i});b.useEffect(()=>{t&&m(i)},[t,i,m]);const g=(v=c("image"))==null?void 0:v[0],[p,y]=b.useState((t==null?void 0:t.presigned)||""),{items:h}=we();b.useEffect(()=>{if(g){const q=URL.createObjectURL(g);return y(q),()=>URL.revokeObjectURL(q)}},[g]);const f=({label:q,preview:P,existingName:D,register:ie,error:le,onView:je,id:tt,isRequired:at=!1})=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs(I,{className:"text-gray-700 block mb-2",children:[q," ",at&&"*"]}),P&&e.jsxs("div",{className:"mb-3 flex items-center justify-between bg-blue-50 p-3 rounded-lg",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx(pe,{className:"h-5 w-5 text-blue-500 mr-2"}),e.jsx("span",{className:"text-sm font-medium truncate max-w-[200px]",children:D||"Selected Image"})]}),e.jsx(w,{type:"button",variant:"ghost",size:"sm",onClick:je,className:"text-blue-600 hover:text-blue-800",children:"Preview"})]}),e.jsx("div",{children:e.jsx(U,{id:tt,type:"file",accept:"image/*",...ie,error:le})}),le&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:le})]}),j=async q=>{var P;if(t){n(!0);try{const D=(P=q.image)==null?void 0:P[0],ie={newsCategoryId:q.newsCategoryId,title:{am:q.titleAm||"",en:q.titleEn||""},subTitle:{am:q.subTitleAm||"",en:q.subTitleEn||""},body:{am:q.bodyAm||"",en:q.bodyEn||""},...D&&{fileInfo:{fileName:D.name,contentType:D.type,size:D.size,originalname:D.name}},isActive:q.isActive,isFeatured:q.isFeatured};await a({id:t.id,data:ie,...D&&{imageFile:D}}),C.success("News updated successfully"),l(-1)}catch{C.error("Failed to update news"),n(!1)}}};return e.jsx("div",{className:"max-h-[80vh] overflow-y-auto p-6 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm",children:e.jsxs("form",{onSubmit:x(j),className:"space-y-8",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-blue-500 mr-2 rounded-full"}),"Category"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"newsCategoryId",className:"text-gray-700 dark:text-gray-300",children:"News Category*"}),e.jsxs("select",{id:"newsCategoryId",...d("newsCategoryId",{required:"Category is required"}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-purple-500 dark:bg-gray-600 dark:text-gray-200",children:[e.jsx("option",{value:"",children:"Select a category"}),h==null?void 0:h?.map(q=>{var P;return e.jsx("option",{value:q.id,children:((P=q.newsCategoryTitle)==null?void 0:P.en)||"Unnamed Category"},q.id)})]}),o.newsCategoryId&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:o.newsCategoryId.message})]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-blue-500 mr-2 rounded-full"}),"Title"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"titleAm",className:"text-gray-700 dark:text-gray-200",children:"Title (Amharic)*"}),e.jsx(U,{id:"titleAm",...d("titleAm",{required:"Required"}),error:(A=o.titleAm)==null?void 0:A.message,placeholder:"News title in Amharic"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"titleEn",className:"text-gray-700 dark:text-gray-200",children:"Title (English)*"}),e.jsx(U,{id:"titleEn",...d("titleEn",{required:"Required"}),error:(S=o.titleEn)==null?void 0:S.message,placeholder:"News title in English"})]})]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-primary-500 mr-2 rounded-full"}),"Subtitle"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"subTitleAm",className:"text-gray-700 dark:text-gray-200",children:"Subtitle (Amharic)*"}),e.jsx(U,{id:"subTitleAm",...d("subTitleAm",{required:"Required"}),error:(R=o.subTitleAm)==null?void 0:R.message,placeholder:"News subtitle in Amharic"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"subTitleEn",className:"text-gray-700 dark:text-gray-200",children:"Subtitle (English)*"}),e.jsx(U,{id:"subTitleEn",...d("subTitleEn",{required:"Required"}),error:(ce=o.subTitleEn)==null?void 0:ce.message,placeholder:"News subtitle in English"})]})]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-purple-500 mr-2 rounded-full"}),"Content"]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"bodyAm",className:"text-gray-700 dark:text-gray-200",children:"Content (Amharic)*"}),e.jsx(de,{id:"bodyAm",...d("bodyAm",{required:"Required"}),rows:6,placeholder:"News content in Amharic",className:"min-h-[150px] dark:bg-gray-600 dark:text-gray-200"}),o.bodyAm&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:o.bodyAm.message})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"bodyEn",className:"text-gray-700 dark:text-gray-200",children:"Content (English)*"}),e.jsx(de,{id:"bodyEn",...d("bodyEn",{required:"Required"}),rows:6,placeholder:"News content in English",className:"min-h-[150px] dark:bg-gray-600 dark:text-gray-200"}),o.bodyEn&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:o.bodyEn.message})]})]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-orange-500 mr-2 rounded-full"}),"Settings"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(I,{htmlFor:"isActive",className:"text-gray-700 dark:text-gray-200 font-medium",children:"Is Active"}),e.jsx("button",{type:"button",onClick:()=>u("isActive",!c("isActive")),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${c("isActive")?"bg-primary-500":"bg-gray-300"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${c("isActive")?"translate-x-6":"translate-x-1"}`})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(I,{htmlFor:"isFeatured",className:"text-gray-700 font-medium",children:"Is Featured"}),e.jsx("button",{type:"button",onClick:()=>u("isFeatured",!c("isFeatured")),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${c("isFeatured")?"bg-yellow-500":"bg-gray-300"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${c("isFeatured")?"translate-x-6":"translate-x-1"}`})})]})]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-100 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-yellow-500 mr-2 rounded-full"}),"Image"]}),e.jsx(f,{label:"News Image",preview:p,existingName:(me=t==null?void 0:t.fileInfo)==null?void 0:me.originalname,register:d("image"),error:(G=o.image)==null?void 0:G.message,onView:()=>window.open(p,"_blank"),id:"image",isRequired:!1})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(w,{variant:"outline",onClick:()=>l(-1),type:"button",disabled:s,className:"px-6 py-2 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700",children:"Cancel"}),e.jsx(w,{type:"submit",disabled:s,className:"px-6 py-2 bg-purple-600 hover:bg-purple-700 text-white",children:s?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4 animate-spin"}),"Updating..."]}):"Update News"})]})]})})},Ye=({handleSubmit:r,handleCancel:t,watch:a,control:s,setValue:n,register:l,errors:i,isSubmitting:d,employeesList:x,reset:c,item:u,label:m})=>{var h,f,j;const o=[{label:"Office Head",value:"office_head"},{label:"Deputy",value:"deputy"}],g=(h=a("image"))==null?void 0:h[0],[p,y]=b.useState((u==null?void 0:u.presigned)||"");return b.useEffect(()=>{u!=null&&u.presigned&&y(u.presigned)},[u]),b.useEffect(()=>{if(g){const v=URL.createObjectURL(g);return y(v),()=>URL.revokeObjectURL(v)}},[g]),b.useEffect(()=>{x.length&&!a("employeeId")&&n("employeeId",x[0].value)},[x,n,a]),e.jsx("div",{className:"max-h-[80vh] overflow-y-auto p-6 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm",children:e.jsxs("form",{onSubmit:r,className:"space-y-8",children:[e.jsx(Ae,{id:"staffType",label:"Message Type",error:"Type is Required",errors:i,register:l,control:s,item:o}),e.jsx(Ae,{id:"employeeId",label:"Select Employee",error:"Employee is Required",errors:i,register:l,control:s,item:x}),e.jsx(re,{idEn:"messageTitleEn",idAm:"messageTitleAm",label:"Title",error:"Title is Required",errors:i,register:l}),e.jsx(fe,{idAm:"messageContentAm",idEn:"messageContentEn",label:"Content",error:"Content is Required",errors:i,register:l}),e.jsx(ne,{idAm:"isActive",label:"Status",watch:a,setValue:n}),e.jsx(Te,{title:"Image",children:e.jsx(Me,{label:"Experience Image*",preview:p,existingName:(f=u==null?void 0:u.fileInfo)==null?void 0:f.originalname,register:l("image"),error:(j=i.image)==null?void 0:j.message,onView:()=>window.open(p,"_blank"),id:"image",isRequired:!1})}),e.jsxs("div",{className:"flex justify-end gap-3 pt-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(w,{variant:"outline",onClick:t,type:"button",disabled:d,className:"px-6 py-2 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700",children:"Cancel"}),e.jsx(w,{type:"submit",disabled:d,className:"px-6 py-2 bg-purple-600 hover:bg-purple-700 text-white",children:d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4 animate-spin"}),"..."]}):m})]})]})})},ma=()=>{const{register:r,handleSubmit:t,formState:{errors:a},watch:s,control:n,setValue:l}=F({defaultValues:{messageTitleEn:"",messageTitleAm:"",messageContentAm:"",messageContentEn:"",employeeId:"",staffType:"",isActive:!1}}),{currentEmployeesResponse:i}=_e(),d=ye(),x=M(),{createItem:c}=Se(),[u,m]=b.useState(!1),o=(i==null?void 0:i.items?.map(y=>{var h,f;return{label:d(y.user.name),value:(y==null?void 0:y.id)??"",employeePositionId:((f=(h=y.employeePositions)==null?void 0:h[0])==null?void 0:f.id)??""}}))||[],g=async y=>{var h;m(!0);try{const f=(h=y.image)==null?void 0:h[0];if(!f)throw new Error("images are required");const j={messageTitle:{am:y.messageTitleAm||"",en:y.messageTitleEn||""},messageContent:{am:y.messageContentAm||"",en:y.messageContentEn||""},fileInfo:{fileName:f.name,contentType:f.type,size:f.size,originalname:f.name},isActive:y.isActive,staffType:y.staffType,employeeId:y.employeeId};await c({data:j,imageFile:f}),C.success(" created successfully"),x(-1)}catch{C.error("Failed to create Message"),m(!1)}},p=()=>{x(-1)};return e.jsx(Ye,{handleSubmit:t(g),handleCancel:p,watch:s,setValue:l,control:n,register:r,errors:a,isSubmitting:u,employeesList:o,label:"Add Message"})},ua=()=>{const{id:r}=$(),{singleItem:t,updateItem:a}=Se(void 0,r),[s,n]=b.useState(!1),l=M(),i=b.useMemo(()=>{var v,A,S,R;return{messageTitleEn:((v=t==null?void 0:t.messageTitle)==null?void 0:v.en)||"",messageTitleAm:((A=t==null?void 0:t.messageTitle)==null?void 0:A.am)||"",messageContentAm:((S=t==null?void 0:t.messageContent)==null?void 0:S.am)||"",messageContentEn:((R=t==null?void 0:t.messageContent)==null?void 0:R.en)||"",employeeId:(t==null?void 0:t.employeeId)||"",isActive:(t==null?void 0:t.isActive)??!0,staffType:(t==null?void 0:t.staffType)||"",image:void 0}},[t]),{register:d,handleSubmit:x,watch:c,control:u,setValue:m,reset:o,formState:{errors:g}}=F({defaultValues:i});b.useEffect(()=>{t&&o(i)},[t,i,o]);const{currentEmployeesResponse:p}=_e(),y=ye(),h=(p==null?void 0:p.items?.map(v=>{var A,S;return{label:y(v.user.name),value:v.id||"",employeePositionId:((S=(A=v.employeePositions)==null?void 0:A[0])==null?void 0:S.id)??""}}))||[],f=async v=>{var A;if(t){n(!0);try{const S=(A=v.image)==null?void 0:A[0],R={messageTitle:{am:v.messageTitleAm||"",en:v.messageTitleEn||""},messageContent:{am:v.messageContentAm||"",en:v.messageContentEn||""},fileInfo:S?{fileName:S.name,contentType:S.type,size:S.size,originalname:S.name}:void 0,isActive:v.isActive,staffType:v.staffType,employeeId:v.employeeId};await a({id:t==null?void 0:t.id,data:R,...S&&{imageFile:S}}),C.success("message updated successfully"),l(-1)}catch{C.error("Failed to update about us"),n(!1)}}},j=()=>{l(-1)};return e.jsx(Ye,{handleSubmit:x(f),handleCancel:j,watch:c,setValue:m,control:u,register:d,errors:g,isSubmitting:s,employeesList:h,reset:o,item:t,label:"Edit Message"})},ga=()=>{const{i18n:r,t}=z(),{id:a}=$(),{singleItem:s}=Se(void 0,a),n=r.language,l=ye();return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 flex items-center justify-center p-4 md:p-8",children:e.jsxs("div",{className:"max-w-6xl w-full",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("h1",{className:"text-4xl md:text-5xl font-bold text-gray-800 mb-4",children:t("Leadership Message")}),e.jsx("div",{className:"w-24 h-1 bg-indigo-600 mx-auto"})]}),e.jsx("div",{className:"bg-white rounded-2xl shadow-xl overflow-hidden transition-all duration-300 hover:shadow-2xl",children:e.jsxs("div",{className:"flex flex-col md:flex-row",children:[e.jsxs("div",{className:"md:w-2/5 relative",children:[s!=null&&s.presigned?e.jsx("img",{src:s.presigned,alt:l(s.messageTitle),className:"w-full h-64 md:h-full object-cover"}):e.jsxs("div",{className:"w-full h-64 md:h-full flex items-center justify-center bg-gray-100 text-gray-400",children:[e.jsx(pe,{className:"h-10 w-10"}),e.jsx("span",{className:"ml-2",children:t("No image available")})]}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-transparent to-transparent flex items-end p-6 md:p-8",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-white mb-2",children:l(s==null?void 0:s.messageTitle)}),e.jsx("p",{className:"text-gray-200 text-lg",children:t("Office Leadership")})]})}),e.jsx("div",{className:"absolute top-6 right-6 bg-white text-indigo-600 rounded-full p-2 shadow-lg",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})})]}),e.jsxs("div",{className:"md:w-3/5 p-6 md:p-8 flex flex-col justify-center",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center mb-6",children:[e.jsx("div",{className:"w-10 h-1 bg-indigo-600 mr-3"}),e.jsx("h3",{className:"text-lg font-semibold text-indigo-600 uppercase tracking-wide",children:t("Message Content")})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto pr-4 custom-scrollbar",children:e.jsx("p",{className:"text-gray-700 text-lg leading-relaxed whitespace-pre-line",children:l(s==null?void 0:s.messageContent)})})]}),e.jsxs("div",{className:"mt-8 pt-6 border-t border-gray-200 flex flex-col md:flex-row md:items-center md:justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700",children:t("Status")}),e.jsx("div",{className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${s!=null&&s.isActive?"bg-primary-500":"bg-gray-300"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${s!=null&&s.isActive?"translate-x-6":"translate-x-1"}`})}),e.jsx("span",{className:`text-sm font-medium ${s!=null&&s.isActive?"text-primary-600":"text-gray-500"}`,children:s!=null&&s.isActive?t("Active"):t("Inactive")})]}),(s==null?void 0:s.createdAt)&&e.jsx("span",{className:"text-sm text-gray-500",children:n==="en"?new Date(s.createdAt).toLocaleString(n,{dateStyle:"medium",timeStyle:"short"}):s.amharicCreatedAt})]})]})]})})]})})},xa=()=>{const{i18n:r,t}=z(),{id:a}=$(),{singleItem:s}=Ie(void 0,a),n=r.language,l=ye();return e.jsx("div",{className:"bg-white rounded-2xl shadow-xl overflow-hidden transition-all duration-300 hover:shadow-2xl mb-12",children:e.jsxs("div",{className:"flex flex-col md:flex-row",children:[e.jsxs("div",{className:"md:w-2/3 p-6 md:p-8 flex flex-col justify-center",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center mb-6",children:[e.jsx("div",{className:"w-12 h-12 rounded-lg bg-gradient-to-r from-indigo-500 to-blue-600 flex items-center justify-center text-white text-2xl mr-4",children:e.jsx(pe,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-600 uppercase tracking-wide",children:t("Leadership Message")}),e.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-gray-800 mt-1",children:l(s==null?void 0:s.goalTitle)})]})]}),e.jsx("div",{className:"min-h-[120px] flex items-center",children:e.jsx("p",{className:"text-gray-700 text-lg leading-relaxed whitespace-pre-line",children:l(s==null?void 0:s.goalDescription)})})]}),e.jsxs("div",{className:"mt-8 pt-6 border-t border-gray-200 flex flex-col md:flex-row md:items-center md:justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700",children:t("Status")}),e.jsx("div",{className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${s!=null&&s.isActive?"bg-primary-500":"bg-gray-300"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${s!=null&&s.isActive?"translate-x-6":"translate-x-1"}`})}),e.jsx("span",{className:`text-sm font-medium ${s!=null&&s.isActive?"text-primary-600":"text-gray-500"}`,children:s!=null&&s.isActive?t("Active"):t("Inactive")})]}),(s==null?void 0:s.createdAt)&&e.jsx("span",{className:"text-sm text-gray-500",children:new Date(s.createdAt).toLocaleString(n,{dateStyle:"medium",timeStyle:"short"})})]})]}),e.jsx("div",{className:"md:w-1/3 bg-gradient-to-br from-blue-50 to-indigo-100 p-6 md:p-8 flex flex-col justify-center items-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-32 h-32 mx-auto mb-6 bg-white rounded-2xl shadow-lg flex items-center justify-center overflow-hidden",children:s!=null&&s.presigned?e.jsx("img",{src:s.presigned,alt:l(s.goalTitle),className:"w-full h-full object-cover rounded-2xl"}):e.jsxs("div",{className:"flex flex-col items-center justify-center text-gray-400",children:[e.jsx(pe,{className:"h-10 w-10"}),e.jsx("span",{className:"text-sm mt-2",children:t("No image available")})]})}),e.jsx("h3",{className:"text-xl font-bold text-gray-800 mb-2",children:t("Office Leadership")}),e.jsx("p",{className:"text-gray-600 text-sm",children:t("Leading with vision and dedication to serve.")})]})})]})})},ha=()=>{const{id:r}=$(),{updateItem:t,singleItem:a}=Ie(void 0,r),[s,n]=b.useState(!1),l=M(),i=b.useMemo(()=>({GoalTitleEn:a==null?void 0:a.goalTitle.en,GoalTitleAm:a==null?void 0:a.goalTitle.am,GoalDescriptionAm:a==null?void 0:a.goalDescription.am,GoalDescriptionEn:a==null?void 0:a.goalDescription.en,isActive:a==null?void 0:a.isActive,image:void 0}),[a]),{register:d,handleSubmit:x,watch:c,control:u,setValue:m,reset:o,formState:{errors:g}}=F({defaultValues:i});b.useEffect(()=>{a&&o(i)},[a,i,o]);const p=async h=>{var f;if(a){n(!0);try{const j=(f=h.image)==null?void 0:f[0],v={goalTitle:{am:h.GoalTitleAm||"",en:h.GoalTitleEn||""},goalDescription:{am:h.GoalDescriptionEn||"",en:h.GoalDescriptionEn||""},fileInfo:j?{fileName:j.name,contentType:j.type,size:j.size,originalname:j.name}:void 0,isActive:h.isActive};await t({id:(a==null?void 0:a.id)||"",data:v,...j&&{imageFile:j}}),C.success("Goal updated successfully"),l(-1)}catch{C.error("Failed to update about us"),n(!1)}}},y=()=>{l(-1)};return e.jsx(Qe,{handleSubmit:x(p),handleCancel:y,watch:c,setValue:m,control:u,register:d,errors:g,isSubmitting:s,label:"Edit Goal",item:a})},pa=()=>{const{i18n:r,t}=z(),{id:a}=$(),{singleItem:s}=Ee(void 0,a),n=r.language,l=ye();return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 flex items-center justify-center p-4 md:p-8",children:e.jsxs("div",{className:"max-w-6xl w-full",children:[e.jsx("div",{className:"md:w-1/3 bg-gradient-to-br from-blue-50 to-indigo-100 p-6 md:p-8 flex flex-col justify-center items-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-32 h-32 mx-auto mb-6 bg-white rounded-2xl shadow-lg flex items-center justify-center",children:e.jsx("span",{className:"text-5xl",children:"image from goal"})}),e.jsx("h3",{className:"text-xl font-bold text-gray-800 mb-2",children:l(s==null?void 0:s.visionTitle)}),e.jsx("p",{className:"text-gray-600",children:l(s==null?void 0:s.visionDescription)})]})}),e.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-500 border-t pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-block h-3 w-3 rounded-full ${s!=null&&s.isActive?"bg-primary-500":"bg-gray-400"}`}),s!=null&&s.isActive?t("Active"):t("Inactive")]}),(s==null?void 0:s.createdAt)&&e.jsx("span",{className:"text-sm text-gray-500",children:new Date(s.createdAt).toLocaleString(n,{dateStyle:"medium",timeStyle:"short"})})]})]})})},ya=()=>{const{id:r}=$(),{singleItem:t,updateItem:a}=Ee(void 0,r),[s,n]=b.useState(!1),l=M(),i=b.useMemo(()=>{var h,f,j,v;return{visionTitleEn:(h=t==null?void 0:t.visionTitle)==null?void 0:h.en,visionTitleAm:(f=t==null?void 0:t.visionTitle)==null?void 0:f.am,visionDescriptionAm:(j=t==null?void 0:t.visionDescription)==null?void 0:j.am,visionDescriptionEn:(v=t==null?void 0:t.visionDescription)==null?void 0:v.en,isActive:t==null?void 0:t.isActive}},[t]),{register:d,handleSubmit:x,watch:c,control:u,reset:m,setValue:o,formState:{errors:g}}=F({defaultValues:i});b.useEffect(()=>{t&&m(i)},[t,i,m]);const p=async h=>{if(t){n(!0);try{const f={visionTitle:{am:h.visionTitleAm||"",en:h.visionTitleEn||""},visionDescription:{am:h.visionDescriptionEn||"",en:h.visionDescriptionEn||""},isActive:h.isActive};await a({id:t==null?void 0:t.id,data:f}),C.success("Vision updated successfully"),l(-1)}catch{C.error("Failed to update about us"),n(!1)}}},y=()=>{l(-1)};return e.jsx(Xe,{handleSubmit:x(p),handleCancel:y,watch:c,setValue:o,control:u,register:d,errors:g,isSubmitting:s,label:"Edit Vision",item:t})},Je=({handleSubmit:r,handleCancel:t,watch:a,control:s,setValue:n,register:l,errors:i,isSubmitting:d,reset:x,item:c,label:u})=>{const m=[{label:"FaceBook",value:"FACEBOOK"},{label:"Twitter",value:"TWITTER"},{label:"TikTok",value:"TIKTOK"},{label:"WebSite",value:"WEBSITE"},{label:"Linked In",value:"LINKEDIN"},{label:"Instagram",value:"INSTAGRAM"},{label:"YouTube",value:"YOUTUBE"},{label:"Telegram",value:"TELEGRAM"}];return e.jsx("div",{className:"max-h-[80vh] overflow-y-auto p-6 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm",children:e.jsxs("form",{onSubmit:r,className:"space-y-8",children:[e.jsx(Ae,{id:"type",label:"Social Media Type",error:"Type is Required",errors:i,register:l,control:s,item:m}),e.jsx(re,{idEn:"nameEn",idAm:"nameAm",label:"Name",error:"Name is Required",errors:i,register:l}),e.jsx(Re,{id:"link",label:"Link",watch:a,setValue:n,register:l,error:"Link is required",errors:i,type:"link"}),e.jsx(ne,{idAm:"isActive",label:"Status",watch:a,setValue:n}),e.jsxs("div",{className:"flex justify-end gap-3 pt-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(w,{variant:"outline",onClick:t,type:"button",disabled:d,className:"px-6 py-2 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700",children:"Cancel"}),e.jsx(w,{type:"submit",disabled:d,className:"px-6 py-2 bg-purple-600 hover:bg-purple-700 text-white",children:d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4 animate-spin"}),"..."]}):u})]})]})})},ba=()=>{const{id:r}=$(),{singleItem:t,updateItem:a}=Fe(void 0,r),[s,n]=b.useState(!1),l=M(),i=b.useMemo(()=>{var h,f;return{nameEn:(h=t==null?void 0:t.name)==null?void 0:h.en,nameAm:(f=t==null?void 0:t.name)==null?void 0:f.am,link:t==null?void 0:t.link,type:t==null?void 0:t.type,isActive:t==null?void 0:t.isActive}},[t]),{register:d,handleSubmit:x,watch:c,control:u,setValue:m,reset:o,formState:{errors:g}}=F({defaultValues:i});b.useEffect(()=>{t&&o(i)},[t,i,o]);const p=async h=>{if(t){n(!0);try{const f={name:{am:h.nameAm||"",en:h.nameEn||""},type:h.type,link:h.link,isActive:h.isActive};await a({id:t==null?void 0:t.id,data:f}),C.success("SocialMedia updated successfully"),l(-1)}catch{C.error("Failed to update about us"),n(!1)}}},y=()=>{l(-1)};return e.jsx(Je,{handleSubmit:x(p),handleCancel:y,watch:c,setValue:m,control:u,register:d,errors:g,isSubmitting:s,label:"Edit Social Media Information"})},fa=()=>{const{register:r,handleSubmit:t,formState:{errors:a},watch:s,control:n,setValue:l}=F({defaultValues:{nameAm:"",nameEn:"",link:"",type:"",isActive:!1}}),i=M(),{createItem:d}=Fe(),[x,c]=b.useState(!1),u=async o=>{c(!0);try{const g={name:{am:o.nameAm||"",en:o.nameEn||""},type:o.type,link:o.link,isActive:o.isActive};await d({data:g}),C.success(" created successfully"),i(-1)}catch{C.error("Failed to create SocialMedia"),c(!1)}finally{c(!1)}},m=()=>{i(-1)};return e.jsx(Je,{handleSubmit:t(u),handleCancel:m,watch:s,setValue:l,control:n,register:r,errors:a,isSubmitting:x,label:"Add Social Media Information"})},se={async createItem(r){return(await N.post("/theme/bulk",r,{headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}})).data},async getItems(r){return(await N.get("/theme/list-with-presigned",{params:r,headers:{"x-tenant-id":"adf98293-41ba-4bda-bdb4-70e30a70c1b7"}})).data},async getItem(r){return(await N.get(`/theme/list-with-presigned/${r}`)).data},async deleteItem(r){await N.delete(`/theme/${r}`)},async updateUploadStatus(r,t){return(await N.patch(`/theme/${t}/upload-status`,{id:t,parentId:r,uploadedSuccessfully:!0})).data},async changeStatus(r){return(await N.put(`/theme/change-status/${r}`,{isCurrent:!0})).data},async uploadImage(r,t){var s,n,l,i;if(!t)throw new Error("Upload URL is undefined.");const a=await He.validateFileForUpload(r,{allowedMimeTypes:["image/png","image/jpeg","image/gif","image/webp"],allowedExtensions:[".png",".jpg",".jpeg",".gif",".webp"],maxSizeMB:10,uploadContext:"signature"});if(!a.isValid)throw new Error(((s=a.clientValidation.fileName)==null?void 0:s.error)||((n=a.clientValidation.extension)==null?void 0:n.error)||((l=a.clientValidation.mimeType)==null?void 0:l.error)||((i=a.clientValidation.size)==null?void 0:i.error)||"File validation failed");return be.put(t,r,{headers:{"Content-Type":r.type}})}},wa=(r,t)=>{const a=X(),{data:s}=L({queryKey:["Theme1"],queryFn:async()=>await se.getItem(""),enabled:!1}),{data:n,isLoading:l,error:i,refetch:d}=L({queryKey:["Theme",r],queryFn:async()=>await se.getItems(r)}),x=T({mutationFn:async u=>{const m=await se.createItem(u.data);if(!m)throw new Error("Failed to create Theme item(s)");try{await Promise.all(m.filter(o=>o.presigned)?.map(async(o,g)=>{try{return await se.uploadImage(u.imageFile,o.presigned),await se.updateUploadStatus(o.id,o.id),o}catch(p){throw await se.deleteItem(o.id),p}}))}catch(o){throw o}return m},onSuccess:()=>{a.invalidateQueries({queryKey:["Theme1",r]})}}),c=T({mutationFn:se.deleteItem,onSuccess:()=>{a.invalidateQueries({queryKey:["Theme1",r]})}});return{items:n==null?void 0:n.items,unit:n==null?void 0:n.unit,singleItem:s,count:n==null?void 0:n.count,isLoading:l,error:i,createItem:x.mutateAsync,deleteItem:c.mutateAsync,isCreating:x.isPending,isDeleting:c.isPending,refetch:d}},ja=()=>{var y,h,f,j,v;const{id:r}=$(),{items:t,createItem:a}=wa(),[s,n]=b.useState(!1);M();const l=b.useMemo(()=>{var A,S;return{primaryColor:{type:"PRIMARY_COLOR",value:(A=t==null?void 0:t.find(R=>R.type==="PRIMARY_COLOR"))==null?void 0:A.value},SecondaryColor:{type:"SECONDARY_COLOR",value:(S=t==null?void 0:t.find(R=>R.type==="SECONDARY_COLOR"))==null?void 0:S.value},isActive:!0,image:void 0}},[t]),{register:i,handleSubmit:d,watch:x,reset:c,formState:{errors:u}}=F({defaultValues:l});b.useEffect(()=>{t&&c(l)},[t,l,c]);const m=(y=x("image"))==null?void 0:y[0],[o,g]=b.useState(((h=t==null?void 0:t.find(A=>A.type==="LOGO"))==null?void 0:h.presigned)||"");b.useEffect(()=>{const A=t==null?void 0:t.find(S=>S.type==="LOGO");A!=null&&A.presigned&&g(A.presigned)},[t]),b.useEffect(()=>{if(m){const A=URL.createObjectURL(m);return g(A),()=>URL.revokeObjectURL(A)}},[m]);const p=async A=>{var S,R,ce,me;if(t){n(!0);try{const G=(S=A.image)==null?void 0:S[0],q=[{type:A.primaryColor.type,value:A.primaryColor.value,fileInfo:void 0,isActive:!0,id:((R=t.find(P=>P.type==="PRIMARY_COLOR"))==null?void 0:R.id)||void 0},{type:A.SecondaryColor.type,value:A.SecondaryColor.value,fileInfo:void 0,isActive:!0,id:((ce=t.find(P=>P.type==="SECONDARY_COLOR"))==null?void 0:ce.id)||void 0},{type:"LOGO",value:"",fileInfo:G?{fileName:G.name,contentType:G.type,size:G.size,originalname:G.name}:void 0,isActive:!0,id:((me=t.find(P=>P.type==="LOGO"))==null?void 0:me.id)||void 0}];await a({data:q,...G&&{imageFile:G}}),C.success("Theme saved successfully"),n(!1)}catch{C.error("Failed to update about us"),n(!1)}}};return e.jsx("div",{className:"max-h-[80vh] overflow-y-auto p-6 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm",children:e.jsxs("form",{onSubmit:d(p),className:"space-y-8",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-5 rounded-lg border border-gray-100 dark:border-gray-600",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200 mb-4 flex items-center",children:[e.jsx("div",{className:"h-1 w-4 bg-blue-500 mr-2 rounded-full"}),"Color"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"ThemeTitleAm",className:"text-gray-700 dark:text-gray-300",children:"Primary color"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{id:"color",type:"color",...i("primaryColor.value",{required:"Color is required"}),className:"h-10 w-16 cursor-pointer border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-600"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400 font-mono",children:x("primaryColor.value")||"#000000"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"ThemeTitleEn",className:"text-gray-700 dark:text-gray-300",children:"secondary color"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{id:"color",type:"color",...i("SecondaryColor.value",{required:"Color is required"}),className:"h-10 w-16 cursor-pointer border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-600"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400 font-mono",children:x("SecondaryColor.value")||"#000000"})]})]})]})]}),e.jsx(Te,{title:"Image",children:e.jsx(Me,{label:"Experience Image*",preview:o,existingName:(j=(f=t==null?void 0:t.find(A=>A.type==="LOGO"))==null?void 0:f.fileInfo)==null?void 0:j.originalname,register:i("image"),error:(v=u.image)==null?void 0:v.message,onView:()=>window.open(o,"_blank"),id:"image",isRequired:!1})}),e.jsx("div",{className:"flex justify-end gap-3 pt-6 border-t border-gray-200 dark:border-gray-700",children:e.jsx(w,{type:"submit",disabled:s,className:"px-6 py-2 bg-purple-600 hover:bg-purple-700 text-white",children:s?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4 animate-spin"}),"saving..."]}):"save"})})]})})},Ze=({handleSubmit:r,handleCancel:t,watch:a,control:s,setValue:n,register:l,errors:i,isSubmitting:d,reset:x,item:c,label:u})=>{const m=[{label:"Location",value:"LOCATION"},{label:"Phone Number",value:"PHONE_NUMBER"},{label:"Email",value:"EMAIL"}];return e.jsx("div",{className:"max-h-[80vh] overflow-y-auto p-6 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm",children:e.jsxs("form",{onSubmit:r,className:"space-y-8",children:[e.jsx(Ae,{id:"type",label:"Contact Information Type",error:"Type is Required",errors:i,register:l,control:s,item:m}),e.jsx(re,{idEn:"nameEn",idAm:"nameAm",label:"Name",error:"Name is Required",errors:i,register:l}),e.jsx(Re,{id:"value",label:"Value",watch:a,setValue:n,register:l,error:"Value is required",errors:i,type:"link"}),e.jsx(ne,{idAm:"isActive",label:"Status",watch:a,setValue:n}),e.jsxs("div",{className:"flex justify-end gap-3 pt-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(w,{variant:"outline",onClick:t,type:"button",disabled:d,className:"px-6 py-2 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700",children:"Cancel"}),e.jsx(w,{type:"submit",disabled:d,className:"px-6 py-2 bg-purple-600 hover:bg-purple-700 text-white",children:d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4 animate-spin"}),"..."]}):u})]})]})})},va=()=>{const{register:r,handleSubmit:t,formState:{errors:a},watch:s,control:n,setValue:l}=F({defaultValues:{nameAm:"",nameEn:"",value:"",type:"",isActive:!1}}),i=M(),{createItem:d}=Ue(),[x,c]=b.useState(!1),u=async o=>{c(!0);try{const g={name:{am:o.nameAm||"",en:o.nameEn||""},type:o.type,value:o.value,isActive:o.isActive};await d({data:g}),C.success(" created successfully"),i(-1)}catch{C.error("Failed to create ContactUs")}finally{c(!1)}},m=()=>{i(-1)};return e.jsx(Ze,{handleSubmit:t(u),handleCancel:m,watch:s,setValue:l,control:n,register:r,errors:a,isSubmitting:x,label:"Add Contact Information"})},Na=()=>{const{id:r}=$(),{singleItem:t,updateItem:a}=Ue(void 0,r),[s,n]=b.useState(!1),l=M(),i=b.useMemo(()=>{var h,f;return{nameEn:(h=t==null?void 0:t.name)==null?void 0:h.en,nameAm:(f=t==null?void 0:t.name)==null?void 0:f.am,value:t==null?void 0:t.value,type:t==null?void 0:t.type,isActive:t==null?void 0:t.isActive}},[t]),{register:d,handleSubmit:x,watch:c,reset:u,control:m,setValue:o,formState:{errors:g}}=F({defaultValues:i});b.useEffect(()=>{t&&u(i)},[t,i,u]);const p=async h=>{if(t){n(!0);try{const f={name:{am:h.nameAm||"",en:h.nameEn||""},type:h.type,value:h.value,isActive:h.isActive};await a({id:t==null?void 0:t.id,data:f}),C.success("ContactUs updated successfully"),l(-1)}catch{C.error("Failed to update about us"),n(!1)}}},y=()=>{l(-1)};return e.jsx(Ze,{handleSubmit:x(p),handleCancel:y,watch:c,setValue:o,control:m,register:d,errors:g,isSubmitting:s,label:"Edit Contact Information"})},et=({handleSubmit:r,handleCancel:t,watch:a,control:s,setValue:n,register:l,errors:i,isSubmitting:d,reset:x,item:c,label:u})=>e.jsx("div",{className:"max-h-[80vh] overflow-y-auto p-6 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm",children:e.jsxs("form",{onSubmit:r,className:"space-y-8",children:[e.jsx(re,{idEn:"labelEn",idAm:"labelAm",label:"Label",error:"Label is Required",errors:i,register:l}),e.jsx(fe,{idAm:"descriptionAm",idEn:"descriptionEn",label:"Description",error:"Description is Required",errors:i,register:l}),e.jsx(Re,{id:"link",label:"Value",watch:a,setValue:n,register:l,error:"Value is required",errors:i,type:"link"}),e.jsx(ne,{idAm:"isActive",label:"Status",watch:a,setValue:n}),e.jsxs("div",{className:"flex justify-end gap-3 pt-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(w,{variant:"outline",onClick:t,type:"button",disabled:d,className:"px-6 py-2 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700",children:"Cancel"}),e.jsx(w,{type:"submit",disabled:d,className:"px-6 py-2 bg-purple-600 hover:bg-purple-700 text-white",children:d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4 animate-spin"}),"..."]}):u})]})]})}),ka=()=>{const{register:r,handleSubmit:t,formState:{errors:a},watch:s,control:n,setValue:l}=F({defaultValues:{labelAm:"",labelEn:"",descriptionEn:"",descriptionAm:"",link:"",isActive:!1}}),i=M(),{createItem:d}=De(),[x,c]=b.useState(!1),u=async o=>{c(!0);try{const g={label:{am:o.labelAm||"",en:o.labelEn||""},description:{am:o.descriptionAm||"",en:o.descriptionEn||""},link:o.link,isActive:o.isActive};await d({data:g}),C.success(" created successfully"),i(-1)}catch{C.error("Failed to create Modules"),c(!1)}finally{c(!1)}},m=()=>{i(-1)};return e.jsx(et,{handleSubmit:t(u),handleCancel:m,watch:s,setValue:l,control:n,register:r,errors:a,isSubmitting:x,label:"Add Module"})},Aa=()=>{const{id:r}=$(),{singleItem:t,updateItem:a}=De(void 0,r),[s,n]=b.useState(!1),l=M(),i=b.useMemo(()=>({labelAm:t==null?void 0:t.label.am,labelEn:t==null?void 0:t.label.en,descriptionEn:t==null?void 0:t.description.en,descriptionAm:t==null?void 0:t.description.am,link:t==null?void 0:t.link,isActive:t==null?void 0:t.isActive}),[t]),{register:d,handleSubmit:x,watch:c,control:u,reset:m,setValue:o,formState:{errors:g}}=F({defaultValues:i});b.useEffect(()=>{t&&m(i)},[t,i,m]);const p=async h=>{if(t){n(!0);try{const f={label:{am:h.labelAm||"",en:h.labelEn||""},description:{am:h.descriptionAm||"",en:h.descriptionEn||""},link:h.link,isActive:h.isActive};await a({id:t==null?void 0:t.id,data:f}),C.success("Modules updated successfully"),l(-1)}catch{C.error("Failed to update about us"),n(!1)}}},y=()=>{l(-1)};return e.jsx(et,{handleSubmit:x(p),handleCancel:y,watch:c,setValue:o,control:u,register:d,errors:g,isSubmitting:s,label:"Edit Module"})},Ca=()=>{const{user:r}=ut(),{t}=z(),a=gt(),[s,n]=b.useState(!1),[l,i]=b.useState(!1),d=[{label:"officeHead.title",href:"/user-management/web-management/LeadershipMessage/LeadershipMessage",icon:e.jsx(vt,{className:"h-5 w-5"})},{label:"Goals",href:"/user-management/web-management/Goals/goals",icon:e.jsx(Ct,{className:"h-5 w-5"})},{label:"Vision",href:"/user-management/web-management/Vision/vision",icon:e.jsx(Ce,{className:"h-5 w-5"})},{label:"newsCategory",href:"/user-management/web-management/Category/Category",icon:e.jsx(ze,{className:"h-5 w-5"})},{label:"nav.news",href:"/user-management/web-management/News/news",icon:e.jsx(ze,{className:"h-5 w-5"})},{label:"modules",href:"/user-management/web-management/Modules/Modules",icon:e.jsx(Mt,{className:"h-5 w-5"})},{label:"socialMedia",href:"/user-management/web-management/SocialMedia/SocialMedia",icon:e.jsx(Et,{className:"h-5 w-5"})},{label:"contactUs",href:"/user-management/web-management/ContactUs/ContactUs",icon:e.jsx(kt,{className:"h-5 w-5"})},{label:"theme",href:"/user-management/web-management/Theme/Theme",icon:e.jsx(Lt,{className:"h-5 w-5"})}];b.useEffect(()=>{n(!1)},[a.pathname]),b.useEffect(()=>{const u=()=>{window.innerWidth>=768&&n(!1)};return window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)},[]);const x=(u,m)=>{if(!u||!m)return!1;const o=u.toLowerCase(),g=m.toLowerCase();if(g===o)return!0;const p=o.split("/").slice(0,-1).join("/");if(g.startsWith(p)){const y=o.split("/").pop();if(y&&g.includes(y))return!0}return!1},c=d.filter(u=>x(u.href,a.pathname)).sort((u,m)=>{var o,g;return(((o=m.href)==null?void 0:o.length)||0)-(((g=u.href)==null?void 0:g.length)||0)})[0]||null;return e.jsxs("div",{className:"flex w-full min-h-[calc(100vh-4rem)] bg-gray-50 dark:bg-gray-900",children:[s&&e.jsx("div",{className:"fixed inset-0 bg-black/50 dark:bg-black/70 z-40 md:hidden",onClick:()=>n(!1)}),e.jsxs("div",{className:K("md:sticky top-0 flex flex-col bg-white dark:bg-gray-800 border-r border-gray-200/60 dark:border-gray-700 transition-all duration-300 ease-in-out","backdrop-blur-sm bg-white/95 md:bg-white dark:bg-gray-800/95",s?"absolute left-0 top-0 z-40 w-72 lg:w-80":"hidden md:flex",l?"md:w-16 lg:w-20":"md:w-72 lg:w-80","h-[calc(100vh-2rem)] md:h-screen rounded-2xl md:rounded-none shadow-xl md:shadow-none"),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[!l&&e.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200",children:t("organization.webManagement")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>i(!l),className:"hidden md:flex p-2 rounded-lg hover:bg-purple-200 dark:hover:bg-gray-700 transition-colors",title:t(l?"expandSidebar":"collapseSidebar"),children:e.jsx(Ke,{className:"h-4 w-4 text-gray-700 dark:text-gray-300"})}),e.jsx("button",{onClick:()=>n(!1),className:"md:hidden p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:e.jsx(xt,{className:"h-4 w-4 text-gray-700 dark:text-gray-300"})})]})]}),e.jsx("nav",{className:"flex-1 p-4 space-y-2 overflow-y-auto",children:d?.map(u=>{const m=x(u.href,a.pathname);return e.jsxs(W,{to:u.href||"#",className:`flex items-center gap-3 p-3 rounded-xl text-sm font-medium transition-all duration-200 group relative
                  ${m?"bg-gradient-to-r from-purple-50 to-purple-50 dark:from-purple-900/30 dark:to-purple-900/20 text-purple-700 dark:text-purple-300 border-purple-200 dark:border-purple-700 shadow-sm":"text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 hover:text-gray-900 dark:hover:text-gray-100"}
                  ${l?"justify-center":""}`,children:[u.icon,!l&&e.jsx("span",{className:"flex-1",children:t(u.label)})]},u.label)})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsxs("div",{className:"md:hidden flex items-center justify-between p-4 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("button",{onClick:()=>n(!0),className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:e.jsx(Ke,{className:"h-5 w-5 text-gray-700 dark:text-gray-300"})}),e.jsx("h1",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200",children:t("webManagement")}),e.jsx("div",{className:"w-9"})]}),e.jsxs("div",{className:"flex-1 p-4 md:p-6 overflow-auto",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400 mb-6",children:[e.jsx("span",{children:t("webManagement")}),c&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"/"}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100 font-medium",children:t(c.label)})]})]}),e.jsxs(ht,{children:[e.jsx(E,{path:"/LeadershipMessage/LeadershipMessage",element:e.jsx(zt,{})}),e.jsx(E,{path:"/LeadershipMessage/AddLeadershipMessage",element:e.jsx(ma,{})}),e.jsx(E,{path:"/LeadershipMessage/EditLeadershipMessage/:id",element:e.jsx(ua,{})}),e.jsx(E,{path:"/LeadershipMessage/ViewLeadershipMessage/:id",element:e.jsx(ga,{})}),e.jsx(E,{path:"/Goals/goals",element:e.jsx(Gt,{})}),e.jsx(E,{path:"/Goals/AddGoal",element:e.jsx(Yt,{})}),e.jsx(E,{path:"/Goals/EditGoal/:id",element:e.jsx(ha,{})}),e.jsx(E,{path:"/Goals/ViewGoal/:id",element:e.jsx(xa,{})}),e.jsx(E,{path:"/Vision/vision",element:e.jsx(Bt,{})}),e.jsx(E,{path:"/Vision/AddVision",element:e.jsx(Jt,{})}),e.jsx(E,{path:"/Vision/ViewVision/:id",element:e.jsx(pa,{})}),e.jsx(E,{path:"/Vision/EditVision/:id",element:e.jsx(ya,{})}),e.jsx(E,{path:"/News/news",element:e.jsx(ea,{})}),e.jsx(E,{path:"/News/AddNews",element:e.jsx(da,{})}),e.jsx(E,{path:"/News/EditNews/:id",element:e.jsx(ca,{})}),e.jsx(E,{path:"/Category/Category",element:e.jsx(ia,{})}),e.jsx(E,{path:"/Category/AddCategory",element:e.jsx(la,{})}),e.jsx(E,{path:"/Category/EditCategory/:id",element:e.jsx(oa,{})}),e.jsx(E,{path:"/SocialMedia/SocialMedia",element:e.jsx(_t,{})}),e.jsx(E,{path:"/SocialMedia/AddSocialMedia",element:e.jsx(fa,{})}),e.jsx(E,{path:"/SocialMedia/EditSocialMedia/:id",element:e.jsx(ba,{})}),e.jsx(E,{path:"/Theme/Theme",element:e.jsx(ja,{})}),e.jsx(E,{path:"/ContactUs/ContactUs",element:e.jsx(aa,{})}),e.jsx(E,{path:"/ContactUs/AddContactUs",element:e.jsx(va,{})}),e.jsx(E,{path:"/ContactUs/EditContactUs/:id",element:e.jsx(Na,{})}),e.jsx(E,{path:"/Modules/Modules",element:e.jsx(ra,{})}),e.jsx(E,{path:"/Modules/AddModules",element:e.jsx(ka,{})}),e.jsx(E,{path:"/Modules/EditModules/:id",element:e.jsx(Aa,{})})]})]})]})]})},Ja=()=>e.jsx(Ca,{});export{Ja as default};
