1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/OperationsWorkspace-BifpkVDB.css"])))=>i.map(i=>d[i]); 2import{r as e}from"./rolldown-runtime-DdACKOZr.js";import{A as t,At as r,C as s,Dt as a,Et as i,F as n,Ft as l,G as o,Ht as d,Kt as c,Mt as p,N as x,Nt as m,P as g,Qt as u,Rt as h,S as y,Vt as f,W as b,X as v,Xt as j,Y as S,a as C,b as w,bt as _,c as N,cn as k,d as z,f as A,gt as T,h as F,i as R,jt as B,l as I,ln as D,lt as P,nn as E,ot as W,qt as L,r as O,rn as q,s as $,tt as M,u as U,ut as G,xt as V,y as H,yt as Y,z as J}from"./vendor-icons-B2IBMYLh.js";import{t as K}from"./vendor-react-Bal0KFoH.js";import{t as X}from"./vendor-runtime-C7bOig6j.js";import{h as Q,l as Z}from"./index-DzTOtA2D.js";import{t as ee}from"./authFetch-CQodwQUl.js";import{a as te,i as re,n as se,t as ae}from"./ntnData-BCpjNdGM.js";import{n as ie,t as ne}from"./uaeServiceDirectory-Cmk174PM.js";import{t as le}from"./ClientTaxRecords-xliJboeV.js";var oe=e(D(),1),de=K(),ce=Object.freeze([]),pe="AMTAXHUB_VAULT_AES_CIPHER_2026",xe=e=>{if(!e)return"";if(e.startsWith("ENC:"))return e;try{const t=Array.from(e),r=Array.from(pe),s=t.map((e,t)=>{const s=r[t%r.length];return String.fromCharCode(e.charCodeAt(0)^s.charCodeAt(0))}).join("");return"ENC:"+btoa(unescape(encodeURIComponent(s)))}catch(t){return e}},me=e=>{if(!e)return"";if(!e.startsWith("ENC:"))return e;try{const t=e.slice(4),r=decodeURIComponent(escape(atob(t))),s=Array.from(r),a=Array.from(pe);return s.map((e,t)=>{const r=a[t%a.length];return String.fromCharCode(e.charCodeAt(0)^r.charCodeAt(0))}).join("")}catch(t){return e}},ge="amtaxhub_client_management_db_v1";function ue({tasks:e=[],onUpdateTask:t}){const[n,p]=(0,oe.useState)(()=>{try{const e=localStorage.getItem(ge);if(e)return JSON.parse(e)}catch(e){}return ce}),[x,u]=(0,oe.useState)("2026"),[h,y]=(0,oe.useState)(""),[b,v]=(0,oe.useState)("all"),[j,S]=(0,oe.useState)("all"),[w,N]=(0,oe.useState)("all"),[k,T]=(0,oe.useState)({}),[R,D]=(0,oe.useState)(null),[P,E]=(0,oe.useState)(!1),[W,L]=(0,oe.useState)(null),[O,q]=(0,oe.useState)(!1),[$,M]=(0,oe.useState)(""),[U,G]=(0,oe.useState)(null),[V,H]=(0,oe.useState)({name:"",cnic:"",email:"",contactNo:"",pinCode:"",irisPassword:"",emailPassword:"",category:"Business",feeAmount:2500,challanAmount:1e3,workStatus:"PENDING",paymentStatus:"PENDING",receivedFrom:""});(0,oe.useEffect)(()=>{try{localStorage.setItem(ge,JSON.stringify(n))}catch(e){}},[n]),(0,oe.useEffect)(()=>{if(!e||!Array.isArray(e)||0===e.length)return;let t=!1;const r=n.map(r=>{const s=e.filter(e=>{const t=e.client_cnic&&r.cnic&&e.client_cnic.replace(/-/g,"")===r.cnic.replace(/-/g,""),s=e.client_email&&r.email&&e.client_email.toLowerCase()===r.email.toLowerCase(),a=e.client_name&&r.name&&e.client_name.toLowerCase().includes(r.name.toLowerCase());return t||s||a});if(0===s.length)return r;const a=s.find(e=>"completed"===e.status||"done"===e.status),i=r.records[x]||{taxYear:x,workStatus:"PENDING",paymentStatus:"PENDING",feeAmount:0,challanAmount:0,profitAmount:0};return a&&"DONE"!==i.workStatus?(t=!0,{...r,records:{...r.records,[x]:{...i,workStatus:"DONE",paymentStatus:"paid"===a.payment_status?"PAID":i.paymentStatus,feeAmount:a.fee_amount||i.feeAmount||2500}}}):r});t&&p(r)},[e,x]);const Y=(e,t,r)=>{e&&(navigator.clipboard.writeText(e),D(`${r}-${t}`),setTimeout(()=>D(null),2e3))},J=(0,oe.useMemo)(()=>n.filter(e=>{const t=h.toLowerCase(),r=!t||e.name.toLowerCase().includes(t)||e.cnic.includes(t)||e.email.toLowerCase().includes(t)||e.contactNo.includes(t)||e.category.toLowerCase().includes(t),s="all"===w||e.category.toLowerCase()===w.toLowerCase(),a=e.records[x]||{workStatus:"PENDING",paymentStatus:"PENDING"},i="all"===b||a.workStatus===b,n="all"===j||a.paymentStatus===j;return r&&s&&i&&n}),[n,x,h,w,b,j]),K=(0,oe.useMemo)(()=>{let e=0,t=0,r=0,s=0,a=0,i=0,l=0;return n.forEach(n=>{const o=n.records[x];if(o){e++,"DONE"===o.workStatus?t++:r++;const n=Number(o.feeAmount||0),d=Number(o.challanAmount||0);s+=n,a+=d,i+=n-d,"PAID"===o.paymentStatus&&(l+=n)}}),{totalClients:e,completedCount:t,pendingCount:r,totalFee:s,totalChallan:a,totalProfit:i,totalReceived:l}},[n,x]);return(0,de.jsxs)("div",{style:{padding:"24px",maxWidth:"1600px",margin:"0 auto",fontFamily:"Inter, system-ui, sans-serif"},children:[U&&(0,de.jsxs)("div",{style:{padding:"14px 20px",marginBottom:"20px",borderRadius:"12px",display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"error"===U.type?"rgba(239, 68, 68, 0.12)":"rgba(16, 185, 129, 0.12)",border:"1px solid "+("error"===U.type?"#ef4444":"#10b981"),color:"error"===U.type?"#f87171":"#34d399",fontWeight:600},children:[(0,de.jsx)("span",{children:U.msg}),(0,de.jsx)("button",{onClick:()=>G(null),style:{background:"none",border:"none",color:"inherit",curs
2or:"pointer",fontSize:"18px"},children:"â"})]}),(0,de.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",gap:"16px",marginBottom:"28px"},children:[(0,de.jsx)("div",{children:(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,de.jsx)("div",{style:{background:"linear-gradient(135deg, #10b981 0%, #059669 100%)",width:"48px",height:"48px",borderRadius:"14px",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 8px 16px rgba(16,185,129,0.25)"},children:(0,de.jsx)(C,{size:26,color:"#ffffff"})}),(0,de.jsxs)("div",{children:[(0,de.jsx)("h1",{style:{fontSize:"26px",fontWeight:800,margin:0,color:"#f3f4f6",letterSpacing:"-0.02em"},children:"Client Management & Tax Year Tracker"}),(0,de.jsx)("p",{style:{margin:"4px 0 0 0",color:"#9ca3af",fontSize:"14px"},children:"Auto-synced with Task Management ⢠Iris FBR Vault ⢠Multi-Year Records"})]})]})}),(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",background:"#1f2937",padding:"6px 14px",borderRadius:"12px",border:"1px solid #374151"},children:[(0,de.jsx)(c,{size:18,color:"#10b981",style:{marginRight:"8px"}}),(0,de.jsx)("span",{style:{color:"#9ca3af",fontSize:"13px",fontWeight:600,marginRight:"8px"},children:"Tax Year:"}),(0,de.jsxs)("select",{value:x,onChange:e=>u(e.target.value),style:{background:"#111827",color:"#10b981",border:"1px solid #10b981",borderRadius:"8px",padding:"6px 12px",fontSize:"15px",fontWeight:700,cursor:"pointer",outline:"none"},children:[(0,de.jsx)("option",{value:"2027",children:"Tax Year 2027 (Upcoming)"}),(0,de.jsx)("option",{value:"2026",children:"Tax Year 2026 (Current)"}),(0,de.jsx)("option",{value:"2025",children:"Tax Year 2025"}),(0,de.jsx)("option",{value:"2024",children:"Tax Year 2024"}),(0,de.jsx)("option",{value:"2023",children:"Tax Year 2023"})]})]}),(0,de.jsxs)("button",{onClick:()=>{L(null),H({name:"",cnic:"",email:"",contactNo:"",pinCode:"",irisPassword:"",emailPassword:"",category:"Business",feeAmount:2500,challanAmount:1e3,workStatus:"PENDING",paymentStatus:"PENDING",receivedFrom:""}),E(!0)},style:{display:"flex",alignItems:"center",gap:"8px",backgroundColor:"#10b981",color:"#ffffff",border:"none",padding:"10px 18px",borderRadius:"12px",fontWeight:700,fontSize:"14px",cursor:"pointer",boxShadow:"0 4px 12px rgba(16,185,129,0.3)"},children:[(0,de.jsx)(g,{size:18})," Add New Client"]}),(0,de.jsxs)("button",{onClick:()=>{const e=J.map((e,t)=>{const r=e.records[x]||{workStatus:"PENDING",paymentStatus:"PENDING",feeAmount:0,challanAmount:0,profitAmount:0},s=Number(r.feeAmount||0)-Number(r.challanAmount||0);return[t+1,e.createdDate||"2026-01-01",`"${e.name}"`,`"${e.cnic}"`,`"${e.email||""}"`,`"${e.contactNo||""}"`,`"${e.category||"Business"}"`,`"${e.pinCode||""}"`,`"${e.irisPassword||""}"`,x,r.workStatus,r.paymentStatus,r.feeAmount||0,r.challanAmount||0,s,`"${r.receivedFrom||""}"`].join(",")}),t="data:text/csv;charset=utf-8,"+[["S#","Date","Name","CNIC","Email","Contact No","Category","Iris Pin Code","Iris Password","Tax Return Year","Work Status","Payment Status","Fee Amount (PKR)","Challan Amount (PKR)","Net Profit (PKR)","Received From"].join(","),...e].join("\n"),r=encodeURI(t),s=document.createElement("a");s.setAttribute("href",r),s.setAttribute("download",`AMTaxHub_Clients_${x}_Export.csv`),document.body.appendChild(s),s.click(),document.body.removeChild(s)},style:{display:"flex",alignItems:"center",gap:"8px",backgroundColor:"#1f2937",color:"#34d399",border:"1px solid #059669",padding:"10px 16px",borderRadius:"12px",fontWeight:600,fontSize:"14px",cursor:"pointer"},children:[(0,de.jsx)(r,{size:18})," Export Excel"]}),(0,de.jsxs)("button",{onClick:()=>q(!0),style:{display:"flex",alignItems:"center",gap:"8px",backgroundColor:"#1f2937",color:"#9ca3af",border:"1px solid #374151",padding:"10px 16px",borderRadius:"12px",fontWeight:600,fontSize:"14px",cursor:"pointer"},children:[(0,de.jsx)(I,{size:18})," Import CSV"]})]})]}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:"16px",marginBottom:"28px"},children:[(0,de.jsxs)("div",{style:{background:"#111827",border:"1px solid #1f2937",borderRadius:"16px",padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,de.jsxs)("span",{style:{color:"#9ca3af",fontSize:"13px",fontWeight:600},children:["Total Clients (",x,")"]}),(0,de.jsx)(C,{size:20,color:"#3b82f6"})]}),(0,de.jsx)("div",{style:{fontSize:"28px",fontWeight:800,color:"#ffffff",marginTop:"10px"},children:K.totalClients}),(0,de.jsx)("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"4px"},children:"Active registered profiles"})]}),(0,de.jsxs)("div",{style:{background:"#111827",border:"1px solid #1f2937",borderRadius:"16px",padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,de.jsx)("span",{style:{color:"#9ca3af",fontSize:"13px",fontWeight:600},children:"Work Status"}),(0,de.jsx)(d,{size:20,color:"#10b981"})]}),(0,de.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:"12px",marginTop:"10px"},children:[(0,de.jsxs)("span",{style:{fontSize:"26px",fontWeight:800,color:"#00e676"},children:[K.completedCount," ",(0,de.jsx)("span",{style:{fontSize:"14px",fontWeight:600,color:"#00e676"},children:"DONE"})]}),(0,de.jsxs)("span",{style:{fontSize:"18px",fontWeight:700,color:"#ff9100"},children:["/ ",K.pendingCount," ",(0,de.jsx)("span",{style:{fontSize:"13px",fontWeight:600,color:"#ff9100"},children:"PENDING"})]})]}),(0,de.jsx)("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"4px"},children:"Auto-updated from Task Board"})]}),(0,de.jsxs)("div",{style:{background:"#111827",border:"1px solid #1f2937",borderRadius:"16px",padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,de.jsx)("span",{style:{color:"#9ca3af",fontSize:"13px",fontWeight:600},children:"Fee Collected"}),(0,de.jsx)(B,{size:20,color:"#10b981"})]}),(0,de.jsxs)("div",{style:{fontSize:"28px",fontWeight:800,color:"#10b981",marginTop:"10px"}
2,children:["Rs. ",K.totalReceived.toLocaleString()]}),(0,de.jsxs)("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"4px"},children:["Out of Rs. ",K.totalFee.toLocaleString()," total"]})]}),(0,de.jsxs)("div",{style:{background:"#111827",border:"1px solid #1f2937",borderRadius:"16px",padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,de.jsx)("span",{style:{color:"#9ca3af",fontSize:"13px",fontWeight:600},children:"Total FBR Challans"}),(0,de.jsx)(_,{size:20,color:"#f59e0b"})]}),(0,de.jsxs)("div",{style:{fontSize:"28px",fontWeight:800,color:"#f59e0b",marginTop:"10px"},children:["Rs. ",K.totalChallan.toLocaleString()]}),(0,de.jsx)("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"4px"},children:"Deposited FBR tax challans"})]}),(0,de.jsxs)("div",{style:{background:"#111827",border:"1px solid #10b981",borderRadius:"16px",padding:"20px",backgroundColor:"rgba(16, 185, 129, 0.05)"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,de.jsx)("span",{style:{color:"#34d399",fontSize:"13px",fontWeight:700},children:"Net Business Profit"}),(0,de.jsx)(z,{size:20,color:"#34d399"})]}),(0,de.jsxs)("div",{style:{fontSize:"28px",fontWeight:800,color:"#34d399",marginTop:"10px"},children:["Rs. ",K.totalProfit.toLocaleString()]}),(0,de.jsx)("div",{style:{fontSize:"12px",color:"#10b981",marginTop:"4px"},children:"Calculated (Fee - Challans)"})]})]}),(0,de.jsxs)("div",{style:{background:"#111827",border:"1px solid #1f2937",borderRadius:"16px",padding:"16px 20px",marginBottom:"24px",display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:"16px"},children:[(0,de.jsxs)("div",{style:{position:"relative",flex:"1 1 300px",maxWidth:"450px"},children:[(0,de.jsx)(s,{size:18,color:"#9ca3af",style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)"}}),(0,de.jsx)("input",{type:"text",placeholder:"Search by Name, CNIC, Email, Contact No, Category...",value:h,onChange:e=>y(e.target.value),style:{width:"100%",backgroundColor:"#1f2937",border:"1px solid #374151",color:"#ffffff",padding:"10px 14px 10px 42px",borderRadius:"12px",fontSize:"14px",outline:"none"}})]}),(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[(0,de.jsx)("span",{style:{color:"#9ca3af",fontSize:"13px"},children:"Work:"}),(0,de.jsxs)("select",{value:b,onChange:e=>v(e.target.value),style:{background:"#1f2937",border:"1px solid #374151",color:"#ffffff",padding:"8px 12px",borderRadius:"10px",fontSize:"13px",cursor:"pointer"},children:[(0,de.jsx)("option",{value:"all",children:"All Work"}),(0,de.jsx)("option",{value:"DONE",children:"Completed (DONE)"}),(0,de.jsx)("option",{value:"PENDING",children:"Pending (PENDING)"})]})]}),(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[(0,de.jsx)("span",{style:{color:"#9ca3af",fontSize:"13px"},children:"Payment:"}),(0,de.jsxs)("select",{value:j,onChange:e=>S(e.target.value),style:{background:"#1f2937",border:"1px solid #374151",color:"#ffffff",padding:"8px 12px",borderRadius:"10px",fontSize:"13px",cursor:"pointer"},children:[(0,de.jsx)("option",{value:"all",children:"All Payments"}),(0,de.jsx)("option",{value:"PAID",children:"PAID"}),(0,de.jsx)("option",{value:"PENDING",children:"PENDING"})]})]}),(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[(0,de.jsx)("span",{style:{color:"#9ca3af",fontSize:"13px"},children:"Category:"}),(0,de.jsxs)("select",{value:w,onChange:e=>N(e.target.value),style:{background:"#1f2937",border:"1px solid #374151",color:"#ffffff",padding:"8px 12px",borderRadius:"10px",fontSize:"13px",cursor:"pointer"},children:[(0,de.jsx)("option",{value:"all",children:"All Categories"}),(0,de.jsx)("option",{value:"Business",children:"Business"}),(0,de.jsx)("option",{value:"Salary",children:"Salary"}),(0,de.jsx)("option",{value:"AOP",children:"AOP"}),(0,de.jsx)("option",{value:"Company",children:"Company"})]})]})]})]}),(0,de.jsx)("div",{style:{background:"#111827",border:"1px solid #1f2937",borderRadius:"16px",overflow:"hidden",boxShadow:"0 10px 30px rgba(0,0,0,0.3)"},children:(0,de.jsx)("div",{style:{overflowX:"auto"},children:(0,de.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",textAlign:"left",fontSize:"13px"},children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{style:{background:"#1f2937",color:"#9ca3af",borderBottom:"1px solid #374151",fontWeight:700}
2,children:[(0,de.jsx)("th",{style:{padding:"14px 16px",width:"40px"},children:"#"}),(0,de.jsx)("th",{style:{padding:"14px 16px"},children:"Client Info"}),(0,de.jsx)("th",{style:{padding:"14px 16px"},children:"FBR Reg / Contact"}),(0,de.jsx)("th",{style:{padding:"14px 16px"},children:"Category"}),(0,de.jsx)("th",{style:{padding:"14px 16px"},children:"Iris PIN Code"}),(0,de.jsx)("th",{style:{padding:"14px 16px"},children:"Iris Password"}),(0,de.jsx)("th",{style:{padding:"14px 16px"},children:"Tax Return"}),(0,de.jsx)("th",{style:{padding:"14px 16px"},children:"Work Status"}),(0,de.jsx)("th",{style:{padding:"14px 16px"},children:"Payment Status"}),(0,de.jsx)("th",{style:{padding:"14px 16px"},children:"Fee (PKR)"}),(0,de.jsx)("th",{style:{padding:"14px 16px"},children:"Challan (PKR)"}),(0,de.jsx)("th",{style:{padding:"14px 16px"},children:"Profit (PKR)"}),(0,de.jsx)("th",{style:{padding:"14px 16px",textAlign:"center"},children:"Actions"})]})}),(0,de.jsx)("tbody",{children:0===J.length?(0,de.jsx)("tr",{children:(0,de.jsxs)("td",{colSpan:13,style:{padding:"40px",textAlign:"center",color:"#9ca3af",fontSize:"15px"},children:["No client records found matching tax year ",x,'. Click "Add New Client" or "Import CSV" to get started.']})}):J.map((e,t)=>{const r=e.records[x]||{taxYear:x,workStatus:"PENDING",paymentStatus:"PENDING",feeAmount:0,challanAmount:0,profitAmount:0},s="DONE"===r.workStatus,n="PAID"===r.paymentStatus,c=Number(r.feeAmount||0)-Number(r.challanAmount||0),g=k[e.id];return(0,de.jsxs)("tr",{style:{borderBottom:"1px solid #1f2937",backgroundColor:t%2==0?"transparent":"rgba(31, 41, 55, 0.4)",transition:"background-color 0.15s"},children:[(0,de.jsx)("td",{style:{padding:"14px 16px",color:"#6b7280",fontWeight:600},children:t+1}),(0,de.jsxs)("td",{style:{padding:"14px 16px"},children:[(0,de.jsx)("div",{style:{fontWeight:700,color:"#f3f4f6",fontSize:"14px"},children:e.name}),(0,de.jsxs)("div",{style:{color:"#9ca3af",fontSize:"12px",fontFamily:"monospace",marginTop:"2px"},children:["CNIC: ",e.cnic]}),e.email&&(0,de.jsx)("div",{style:{color:"#6b7280",fontSize:"11px"},children:e.email})]}),(0,de.jsx)("td",{style:{padding:"14px 16px"},children:(0,de.jsx)("div",{style:{color:"#e5e7eb",fontWeight:500},children:e.contactNo||"â"})}),(0,de.jsx)("td",{style:{padding:"14px 16px"},children:(0,de.jsx)("span",{style:{padding:"4px 10px",borderRadius:"8px",fontSize:"11px",fontWeight:700,backgroundColor:"Salary"===e.category?"rgba(59, 130, 246, 0.15)":"rgba(168, 85, 247, 0.15)",color:"Salary"===e.category?"#60a5fa":"#c084fc",border:"1px solid "+("Salary"===e.category?"#3b82f6":"#a855f7")},children:e.category||"Business"})}),(0,de.jsx)("td",{style:{padding:"14px 16px"},children:(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[(0,de.jsx)("span",{style:{fontFamily:"monospace",fontWeight:700,color:"#f59e0b",backgroundColor:"#1f2937",padding:"3px 8px",borderRadius:"6px"},children:me(e.pinCode)||"â"}),e.pinCode&&(0,de.jsx)("button",{onClick:()=>Y(me(e.pinCode),"pin",e.id),title:"Copy PIN Code",style:{background:"none",border:"none",color:R===`${e.id}-pin`?"#10b981":"#6b7280",cursor:"pointer",padding:"2px"},children:R===`${e.id}-pin`?(0,de.jsx)(f,{size:14}):(0,de.jsx)(m,{size:14})})]})}),(0,de.jsx)("td",{style:{padding:"14px 16px"},children:(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[(0,de.jsx)("span",{style:{fontFamily:"monospace",fontWeight:600,color:"#e5e7eb",backgroundColor:"#1f2937",padding:"3px 8px",borderRadius:"6px",maxWidth:"140px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g?me(e.irisPassword)||"â":"â¢â¢â¢â¢â¢â¢â¢â¢"}),(0,de.jsx)("button",{onClick:()=>{return t=e.id,void T(e=>({...e,[t]:!e[t]}));var t},style:{background:"none",border:"none",color:"#6b7280",cursor:"pointer",padding:"2px"},children:g?(0,de.jsx)(a,{size:14}):(0,de.jsx)(i,{size:14})}),e.irisPassword&&(0,de.jsx)("button",{onClick:()=>Y(me(e.irisPassword),"pass",e.id),title:"Copy Iris Password",style:{background:"none",border:"none",color:R===`${e.id}-pass`?"#10b981":"#6b7280",cursor:"pointer",padding:"2px"},children:R===`${e.id}
2-pass`?(0,de.jsx)(f,{size:14}):(0,de.jsx)(m,{size:14})})]})}),(0,de.jsx)("td",{style:{padding:"14px 16px",fontWeight:700,color:"#9ca3af"},children:x}),(0,de.jsx)("td",{style:{padding:"14px 16px"},children:(0,de.jsxs)("button",{onClick:()=>{return t=e.id,void p(e=>e.map(e=>{if(e.id!==t)return e;const r=e.records[x]||{taxYear:x,workStatus:"PENDING",paymentStatus:"PENDING",feeAmount:2500,challanAmount:1e3,profitAmount:1500},s="DONE"===r.workStatus?"PENDING":"DONE";return{...e,records:{...e.records,[x]:{...r,workStatus:s,profitAmount:Number(r.feeAmount||0)-Number(r.challanAmount||0)}}}}));var t},title:"Click to toggle Work Status",style:{padding:"6px 12px",borderRadius:"8px",fontWeight:800,fontSize:"12px",border:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"6px",backgroundColor:s?"#00e676":"rgba(255, 145, 0, 0.15)",color:s?"#000000":"#ff9100",boxShadow:s?"0 0 12px rgba(0,230,118,0.4)":"none",transition:"all 0.2s"},children:[s?(0,de.jsx)(d,{size:14}):(0,de.jsx)(l,{size:14}),r.workStatus]})}),(0,de.jsx)("td",{style:{padding:"14px 16px"},children:(0,de.jsx)("button",{onClick:()=>{return t=e.id,void p(e=>e.map(e=>{if(e.id!==t)return e;const r=e.records[x]||{taxYear:x,workStatus:"PENDING",paymentStatus:"PENDING",feeAmount:2500,challanAmount:1e3,profitAmount:1500},s="PAID"===r.paymentStatus?"PENDING":"PAID";return{...e,records:{...e.records,[x]:{...r,paymentStatus:s}}}}));var t},title:"Click to toggle Payment Status",style:{padding:"5px 10px",borderRadius:"8px",fontWeight:700,fontSize:"11px",border:"1px solid "+(n?"#10b981":"#ef4444"),cursor:"pointer",backgroundColor:n?"rgba(16, 185, 129, 0.15)":"rgba(239, 68, 68, 0.15)",color:n?"#34d399":"#f87171"},children:r.paymentStatus})}),(0,de.jsxs)("td",{style:{padding:"14px 16px",fontWeight:700,color:"#f3f4f6"},children:["Rs. ",(r.feeAmount||0).toLocaleString()]}),(0,de.jsxs)("td",{style:{padding:"14px 16px",color:"#f59e0b",fontWeight:600},children:["Rs. ",(r.challanAmount||0).toLocaleString()]}),(0,de.jsxs)("td",{style:{padding:"14px 16px",color:c>=0?"#34d399":"#f87171",fontWeight:800},children:["Rs. ",c.toLocaleString()]}),(0,de.jsx)("td",{style:{padding:"14px 16px",textAlign:"center"},children:(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[e.contactNo&&(0,de.jsx)("a",{href:`https://wa.me/${e.contactNo.replace(/[^0-9]/g,"")}?text=${encodeURIComponent(`Dear ${e.name}, your Income Tax Return for Tax Year ${x} is currently ${r.workStatus}. Kindly confirm required documents or details with AM Tax Hub.`)}`,target:"_blank",rel:"noreferrer",title:"Send WhatsApp Reminder",style:{color:"#25D366",padding:"6px",background:"#1f2937",borderRadius:"8px",display:"flex"},children:(0,de.jsx)(o,{size:16})}),(0,de.jsx)("button",{onClick:()=>(e=>{L(e);const t=e.records[x]||{feeAmount:2500,challanAmount:1e3,workStatus:"PENDING",paymentStatus:"PENDING",receivedFrom:""};H({name:e.name,cnic:e.cnic,email:e.email,contactNo:e.contactNo,pinCode:me(e.pinCode||""),irisPassword:me(e.irisPassword||""),emailPassword:me(e.emailPassword||""),category:e.category||"Business",feeAmount:t.feeAmount||2500,challanAmount:t.challanAmount||1e3,workStatus:t.workStatus||"PENDING",paymentStatus:t.paymentStatus||"PENDING",receivedFrom:t.receivedFrom||""}),E(!0)})(e),title:"Edit Client & Fee details",style:{color:"#60a5fa",background:"#1f2937",border:"none",padding:"6px",borderRadius:"8px",cursor:"pointer",display:"flex"},children:(0,de.jsx)(F,{size:16})}),(0,de.jsx)("button",{onClick:()=>{return t=e.id,r=e.name,void(window.confirm(`Are you sure you want to delete client "${r}"?`)&&(p(e=>e.filter(e=>e.id!==t)),G({type:"success",msg:`Client "${r}" deleted successfully.`})));var t,r},title:"Delete Client",style:{color:"#f87171",background:"#1f2937",border:"none",padding:"6px",borderRadius:"8px",cursor:"pointer",display:"flex"},children:(0,de.jsx)(A,{size:16})})]})})]},e.id)})})]})})}),P&&(0,de.jsx)("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.75)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"20px"},children:(0,de.jsxs)("div",{style:{background:"#111827",border:"1px solid #374151",borderRadius:"20px",padding:"28px",width:"100%",maxWidth:"640px",boxShadow:"0 20px 50px rgba(0,0,0,0.5)",color:"#ffffff"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[(0,de.jsx)("h2",{style:{fontSize:"20px",fontWeight:800,margin:0,color:"#10b981"},children:W?`Edit Client: ${W.name}`:`Add New Client (${x})`}),(0,de.jsx)("button",{onClick:()=>E(!1),style:{background:"none",border:"none",color:"#9ca3af",fontSize:"20px",cursor:"pointer"},children:"â"})]}),(0,de.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),!V.name||!V.cnic)return void G({type:"error",msg:"Client Name and CNIC are required!"});const t=Number(V.feeAmount||0),r=Number(V.challanAmount||0),s=t-r,a=xe(V.pinCode),i=xe(V.irisPassword),n=xe(V.emailPassword);if(W)p(e=>e.map(e=>e.id!==W.id?e:{...e,name:V.name,cnic:V.cnic,email:V.email,contactNo:V.contactNo,pinCode:a,irisPassword:i,emailPassword:n,category:V.category,records:{...e.records,[x]:{taxYear:x,workStatus:V.workStatus,paymentStatus:V.paymentStatus,feeAmount:t,challanAmount:r,profitAmount:s,receivedFrom:V.receivedFrom}}})),G({type:"success",msg:`Client "${V.name}" updated successfully for ${x}!`});else{const e={id:`client-${Date.now()}`,name:V.name,cnic:V.cnic,email:V.email,contactNo:V.contactNo,pinCode:a,irisPassword:i,emailPassword:n,category:V.category,createdDate:(new Date).toISOString().split("T")[0],records:{[x]:{taxYear:x,workStatus:V.workStatus,paymentStatus:V.paymentStatus,feeAmount:t,challanAmount:r,profitAmount:s,receivedFrom:V.receivedFrom}}};p(t=>[e,...t]),G({type:"success",msg:`New Client "${V.name}" added for Tax Year ${x}!`})}E(!1),L(null)},style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:{fontSize:"12px",color:"#9ca3af",fontWeight:600},children:"Full Name *"}),(0,de.jsx)("input",{type:"text",required:!0,value:V.name,onChange:e=>H({...V,name:e.target.value}),style:{width:"100%",background:"#1f2937",border:"1px solid #374151",color:"#fff",padding:"10px",borderRadius:"10px",marginTop:"4px",outline:"none"}})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:{fontSize:"12px",color:"#9ca3af",fontWeight:600},children:"CNIC Number *"}),(0,de.jsx)("input",{type:"text",required:!0,placeholder:"XXXXX-XXXXXXX-X",value:V.cnic,onChange:e=>H({...V,cnic:e.target.value}),style:{width:"100%",background:"#1f2937",border:"1px solid #374151",color:"#fff",padding:"10px",borderRadius:"10px",marginTop:"4px",outline:"none"}})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:{fontSize:"12px",color:"#9ca3af",fontWeight:600},children:"Contact No / Mobile"}),(0,de.jsx)("input",{type:"text",placeholder:"03001234567",value:V.contactNo,onChange:e=>H({...V,contactNo:e.target.value}),style:{width:"100%",background:"#1f2937",border:"1px solid #374151",color:"#fff",padding:"10px",borderRadius:"10px",marginTop:"4px",outline:"none"}})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:{fontSize:"12px",color:"#9ca3af",fontWeight:600},children:"Email Address"}),(0,de.jsx)("input",{type:"email",placeholder:"[email protected]",value:V.email,onChange:e=>H({...V,email:e.target.value}),style:{width:"100%",background:"#1f2937",border:"1px solid #374151",color:"#fff",padding:"10px",borderRadius:"10px",marginTop:"4px",outline:"none"}})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:{fontSize:"12px",color:"#9ca3af",fontWeight:600},children:"Category"}),(0,de.jsxs)("select",{value:V.category,onChange:e=>H({...V,category:e.target.value}),style:{width:"100%",background:"#1f2937",border:"1px solid #374151",color:"#fff",padding:"10px",borderRadius:"10px",marginTop:"4px",outline:"none"},children:[(0,de.jsx)("option",{value:"Business",children:"Business"}),(0,de.jsx)("option",{value:"Salary",children:"Salary"}),(0,de.jsx)("option",{value:"AOP",children:"AOP"}),(0,de.jsx)("option",{value:"Company",children:"Company"})]})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:{fontSize:"12px",color:"#9ca3af",fontWeight:600},children:"Iris PIN Code"}),(0,de.jsx)("input",{type:"text",placeholder:"3484",value:V.pinCode,onChange:e=>H({...V,pinCode:e.target.value}),style:{width:"100%",background:"#1f2937",border:"1px solid #374151",color:"#fff",padding:"10px",borderRadius:"10px",marginTop:"4px",outline:"none"}})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:{fontSize:"12px",color:"#9ca3af",fontWeight:600},children:"Iris FBR Password"}),(0,de.jsx)("input",{type:"text",placeholder:"Enter only if operationally required",value:V.irisPassword,onChange:e=>H({...V,irisPassword:e.target.value}),style:{width:"100%",background:"#1f2937",border:"1px solid #374151",color:"#fff",padding:"10px",borderRadius:"10px",marginTop:"4px",outline:"none"}})]}),(0,de.jsxs)("div",{children:[(0,de.jsxs)("label",{style:{fontSize:"12px",color:"#9ca3af",fontWeight:600},children:["Work Status (",x,")"]}),(0,de.jsxs)("select",{value:V.workStatus,onChange:e=>H({...V,workStatus:e.target.value}),style:{width:"100%",background:"#1f2937",border:"1px solid #374151",color:"#fff",padding:"10px",borderRadius:"10px",marginTop:"4px",outline:"none"},children:[(0,de.jsx)("option",{value:"PENDING",children:"PENDING"}),(0,de.jsx)("option",{value:"DONE",children:"DONE (Completed)"})]})]}),(0,de.jsxs)("div",{children:[(0,de.jsxs)("label",{style:{fontSize:"12px",color:"#9ca3af",fontWeight:600},children:["Payment Status (",x,")"]}),(0,de.jsxs)("select",{value:V.paymentStatus,onChange:e=>H({...V,paymentStatus:e.target.value}),style:{width:"100%",background:"#1f2937",border:"1px solid #374151",color:"#fff",padding:"10px",borderRadius:"10px",marginTop:"4px",outline:"none"},children:[(0,de.jsx)("option",{value:"PENDING",children:"PENDING"}),(0,de.jsx)("option",{value:"PAID",children:"PAID"})]})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:{fontSize:"12px",color:"#9ca3af",fontWeight:600},children:"Fee Amount (PKR)"}),(0,de.jsx)("input",{type:"number",value:V.feeAmount,onChange:e=>H({...V,feeAmount:e.target.value}),style:{width:"100%",background:"#1f2937",border:"1px solid #374151",color:"#fff",padding:"10px",borderRadius:"10px",marginTop:"4px",outline:"none"}})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:{fontSize:"12px",color:"#9ca3af",fontWeight:600},children:"Challan Deposit (PKR)"}),(0,de.jsx)("input",{type:"number",value:V.challanAmount,onChange:e=>H({...V,challanAmount:e.target.value}),style:{width:"100%",background:"#1f2937",border:"1px solid #374151",color:"#fff",padding:"10px",borderRadius:"10px",marginTop:"4px",outline:"none"}})]}),(0,de.jsxs)("div",{style:{gridColumn:"span 2",display:"flex",justifyContent:"flex-end",gap:"12px",marginTop:"12px"},children:[(0,de.jsx)("button",{type:"button",onClick:()=>E(!1),style:{background:"#1f2937",color:"#9ca3af",border:"1px solid #374151",padding:"10px 20px",borderRadius:"10px",cursor:"pointer",fontWeight:600},children:"Cancel"}),(0,de.jsx)("button",{type:"submit",style:{background:"#10b981",color:"#ffffff",border:"none",padding:"10px 24px",borderRadius:"10px",cursor:"pointer",fontWeight:700},children:"Save Client"})]})]})]})}),O&&(0,de.jsx)("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.75)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"20px"},children:(0,de.jsxs)("div",{style:{background:"#111827",border:"1px solid #374151",borderRadius:"20px",padding:"28px",width:"100%",maxWidth:"600px",color:"#ffffff"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16
2px"},children:[(0,de.jsx)("h2",{style:{fontSize:"18px",fontWeight:800,margin:0,color:"#34d399"},children:"Import Clients CSV Data"}),(0,de.jsx)("button",{onClick:()=>q(!1),style:{background:"none",border:"none",color:"#9ca3af",fontSize:"20px",cursor:"pointer"},children:"â"})]}),(0,de.jsx)("p",{style:{color:"#9ca3af",fontSize:"13px",marginBottom:"14px"},children:"Paste raw CSV content from your Excel or Google Sheets (headers like Name, CNIC, Pin Code, Password, Fee, Status):"}),(0,de.jsx)("textarea",{rows:8,placeholder:"S#,Name,CNIC,Pin code,Password,Amount,tax return,Payment,work\n1,Example Client,XXXXX-XXXXXXX-X,0000,temporary-password,2500,2026,PAID,DONE",value:$,onChange:e=>M(e.target.value),style:{width:"100%",background:"#1f2937",border:"1px solid #374151",color:"#fff",padding:"12px",borderRadius:"10px",fontSize:"12px",fontFamily:"monospace",outline:"none"}}),(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"12px",marginTop:"16px"},children:[(0,de.jsx)("button",{onClick:()=>q(!1),style:{background:"#1f2937",color:"#9ca3af",border:"none",padding:"10px 18px",borderRadius:"10px",cursor:"pointer"},children:"Cancel"}),(0,de.jsx)("button",{onClick:()=>{if($.trim())try{const e=$.trim().split("\n");if(e.length<2)return void G({type:"error",msg:"Invalid CSV format. At least header and 1 data row required."});let t=0;const r=[...n];for(let s=1;s<e.length;s++){const a=e[s].trim();if(!a)continue;const i=a.split(",").map(e=>e.replace(/^"|"$/g,"").trim());if(i.length<2)continue;const n=i[1]||i[0],l=i[2]||i[1]||`CNIC-${Date.now()}-${s}`,o=i[4]||"",d=i[5]||"",c=Number(i[6]||2500),p=i[7]||x,m=(i[8]||"").toUpperCase().includes("PAID")?"PAID":"PENDING",g=(i[9]||"").toUpperCase().includes("DONE")?"DONE":"PENDING",u=Number(i[13]||1e3),h=r.findIndex(e=>e.cnic&&e.cnic===l);-1!==h?r[h].records[p]={taxYear:p,workStatus:g,paymentStatus:m,feeAmount:c,challanAmount:u,profitAmount:c-u,receivedFrom:"Imported"}:r.push({id:`client-imported-${Date.now()}-${s}`,name:n||"Unnamed Client",cnic:l,email:"",contactNo:"",pinCode:o,irisPassword:d,category:"Business",createdDate:(new Date).toISOString().split("T")[0],records:{[p]:{taxYear:p,workStatus:g,paymentStatus:m,feeAmount:c,challanAmount:u,profitAmount:c-u,receivedFrom:"Imported"}}}),t++}p(r),q(!1),M(""),G({type:"success",msg:`Successfully imported/updated ${t} client records!`})}catch(e){G({type:"error",msg:"Failed to parse CSV. Please check formatting."})}else G({type:"error",msg:"Please paste CSV content to import!"})},style:{background:"#10b981",color:"#fff",border:"none",padding:"10px 22px",borderRadius:"10px",cursor:"pointer",fontWeight:700},children:"Import Records"})]})]})})]})}function he({token:e}){const[r,s]=(0,oe.useState)([]),[a,i]=(0,oe.useState)(!0),[n,l]=(0,oe.useState)({type:"",msg:""}),[o,c]=(0,oe.useState)(!1),[p,x]=(0,oe.useState)(null),[m,u]=(0,oe.useState)({title:"",description:"",badge_text:"NOTICE",badge_type:"danger",image_url:"",button_text:"",button_url:"",target_page:"both",is_active:1,display_order:0}),h=async()=>{i(!0);try{const t=await(await fetch("/api/banners?scope=admin",{headers:{Authorization:`Bearer ${e}`}})).json();t.success?s((t.data.banners||[]).map(e=>({...e,is_active:Number(e.is_active)}))):l({type:"error",msg:t.message||"Failed to load banners."})}catch(t){l({type:"error",msg:"Failed to connect to server."})}finally{i(!1)}};(0,oe.useEffect)(()=>{h()},[]);const y=()=>{u({title:"",description:"",badge_text:"NOTICE",badge_type:"danger",image_url:"",button_text:"",button_url:"",target_page:"both",is_active:1,display_order:0}),x(null)};return(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"20px"},children:[(0,de.jsxs)("div",{style:ye.headerCard,children:[(0,de.jsxs)("div",{children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",color:"var(--accent-teal, #007C89)",fontWeight:700,fontSize:"0.8rem",marginBottom:"4px"},children:[(0,de.jsx)(T,{size:15}),(0,de.jsx)("span",{children:"Auth Page Banner & Image Slider System"})]}),(0,de.jsx)("h2",{style:{margin:0,fontSize:"1.4rem",fontWeight:800,color:"var(--primary, #07111F)"},children:"Login & Signup Banner Ads Manager"}),(0,de.jsx)("p",{style:{margin:"4px 0 0",color:"var(--text-muted, #475569)",fontSize:"0.85rem"},children:"Upload custom image banners, promotional offers, or text announcements shown on Login & Register pages."})]}),(0,de.jsxs)("button",{onClick:()=>{y(),c(!0)},style:ye.addBtn,children:[(0,de.jsx)(g,{size:16}),(0,de.jsx)("span",{children:"Add New Ad / Image Banner"})]})]}),n.msg&&(0,de.jsxs)("div",{style:{...ye.alertBox,background:"error"===n.type?"#FEF2F2":"#F0
2FDF4",color:"error"===n.type?"#991B1B":"#166534",borderColor:"error"===n.type?"#FCA5A5":"#86EFAC"},children:[(0,de.jsx)("span",{children:n.msg}),(0,de.jsx)("button",{onClick:()=>l({type:"",msg:""}),style:{background:"none",border:"none",cursor:"pointer",color:"inherit",fontWeight:"bold"},children:"â"})]}),a?(0,de.jsxs)("div",{style:{textAlign:"center",padding:"48px",color:"var(--text-muted, #64748B)"},children:[(0,de.jsx)(t,{size:24,style:{marginBottom:"8px",animation:"spin 1s linear infinite"}}),(0,de.jsx)("p",{children:"Loading Auth Banners..."})]}):0===r.length?(0,de.jsxs)("div",{style:ye.emptyBox,children:[(0,de.jsx)(G,{size:40,style:{color:"var(--accent-teal, #007C89)",marginBottom:"12px",opacity:.6}}),(0,de.jsx)("h3",{style:{color:"var(--primary, #07111F)",fontWeight:700,margin:"0 0 6px"},children:"No Active Image Banners"}),(0,de.jsx)("p",{style:{color:"var(--text-muted, #64748B)",fontSize:"0.85rem",margin:"0 0 16px",maxWidth:"420px",marginLeft:"auto",marginRight:"auto"},children:"Upload your promotional image banners or announcement cards to display next to the login/signup form."}),(0,de.jsx)("button",{onClick:()=>{y(),c(!0)},style:ye.addBtn,children:"Upload First Banner"})]}):(0,de.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))",gap:"20px"},children:r.map(t=>{const r="danger"===(s=t.badge_type)?{bg:"#FEE2E2",color:"#991B1B",border:"#FCA5A5"}:"warning"===s?{bg:"#FEF3C7",color:"#92400E",border:"#FCD34D"}:"success"===s?{bg:"#D1FAE5",color:"#065F46",border:"#6EE7B7"}:{bg:"#E0E7FF",color:"#3730A3",border:"#A5B4FC"};var s;const a=!t.title&&t.image_url;return(0,de.jsxs)("div",{style:{...ye.bannerCard,opacity:t.is_active?1:.6},children:[(0,de.jsxs)("div",{children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[(0,de.jsx)("span",{style:{padding:"3px 10px",borderRadius:"999px",fontSize:"0.7rem",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em",background:r.bg,color:r.color,border:`1px solid ${r.border}`},children:t.badge_text||(a?"IMAGE BANNER":"NOTICE")}),(0,de.jsxs)("span",{style:{fontSize:"0.72rem",color:"#64748B",background:"#F1F5F9",borderRadius:"6px",padding:"2px 8px",border:"1px solid #E2E8F0"},children:["Page: ",t.target_page]})]}),t.image_url?(0,de.jsx)("div",{style:{marginBottom:"12px",borderRadius:"12px",overflow:"hidden",maxHeight:"160px",border:"1px solid #E2E8F0",background:"#F8FAFC"},children:(0,de.jsx)("img",{src:t.image_url,alt:t.title||"Auth Banner",style:{width:"100%",height:"100%",objectFit:"cover"}})}):null,t.title?(0,de.jsx)("h3",{style:{color:"var(--primary, #07111F)",fontWeight:700,fontSize:"0.98rem",margin:"0 0 6px"},children:t.title}):a?(0,de.jsxs)("div",{style:{color:"#007C89",fontSize:"0.8rem",fontWeight:600,display:"flex",alignItems:"center",gap:"4px",margin:"0 0 6px"},children:[(0,de.jsx)(G,{size:14})," Pure Image Banner (No Title Text)"]}):null,t.description&&(0,de.jsx)("p",{style:{color:"var(--text-muted, #475569)",fontSize:"0.82rem",lineHeight:"1.5",margin:0,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},children:t.description})]}),(0,de.jsxs)("div",{style:{marginTop:"16px",paddingTop:"12px",borderTop:"1px solid #F1F5F9",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,de.jsxs)("button",{onClick:()=>(async(t,r)=>{try{const s=1===r?0:1,a=await(await fetch("/api/banners",{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({action:"toggle_active",id:t,is_active:s})})).json();a.success?h():l({type:"error",msg:a.message})}catch(s){l({type:"error",msg:"Failed to update status."})}})(t.id,Number(t.is_active)),style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 12px",borderRadius:"8px",fontSize:"0.75rem",fontWeight:600,cursor:"pointer",border:t.is_active?"1px solid #86EFAC":"1px solid #CBD5E1",background:t.is_active?"#F0FDF4":"#F8FAFC",color:t.is_active?"#166534":"#64748B"},children:[t.is_active?(0,de.jsx)(d,{size:13}):(0,de.jsx)(R,{size:13}),(0,de.jsx)("span",{children:t.is_active?"Active":"Inactive"})]}),(0,de.jsxs)("div",{style:{display:"flex",gap:"8px"},children:[(0,de.jsx)("button",{onClick:()=>(e=>{u({title:e.title||"",description:e.description||"",badge_text:e.badge_text||"NOTICE",badge_type:e.badge_type||"danger",image_url:e.image_url||"",button_text:e.button_text||"",button_url:e.button_url||"",target_page:e.target_page||"both",is_active:Number(e.is_active),display_order:Number(e.display_order||0)}),x(e.id),c(!0)})(t),style:ye.iconBtn,title:"Edit",children:(0,de.jsx)(F,{size:15})}),(0,de.jsx)("button",{onClick:()=>(async t=>{if(window.confirm("Delete this banner?"))try{const r=await(await fetch(`/api/banners?id=${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${e}`}})).json();r.success?(l({type:"success",msg:"Banner deleted."}),h()):l({type:"error",msg:r.message})}catch(r){l({type:"error",msg:"Failed to delete banner."})}})(t.id),style:{...ye.iconBtn,background:"#FEF2F2",color:"#DC2626",border:"1px solid #FCA5A5"},title:"Delete",children:(0,de.jsx)(A,{size:15})})]})]})]},t.id)})}),o&&(0,de.jsx)("div",{style:ye.modalOverlay,children:(0,de.jsxs)("div",{style:ye.modalBox,children:[(0,de.jsxs)("div",{style:ye.modalHeader,children:[(0,de.jsx)("h3",{style:{margin:0,color:"var(--primary, #07111F)",fontSize:"1.1rem",fontWeight:700},children:p?"Edit Banner / Ad":"Add New Image or Notice Banner"}),(0,de.jsx)("button",{onClick:()=>c(!1),style:{background:"none",border:"none",color:"#64748B",cursor:"pointer",fontSize:"1.2rem",fontWeight:"bold"},children:"â"})]}),(0,de.jsxs)("form",{onSubmit:async t=>{if(t.preventDefault(),m.title.trim()||m.image_url.trim())try{const t=p?{...m,id:p}:m,r=await(await fetch("/api/banners",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify(t)})).json();r.success?(l({type:"success",msg:p?"Banner updated successfully!":"Banner published successfully!"}),c(!1),y(),h()):l({type:"error",msg:r.message})}catch(r){l({type:"error",msg:"Failed to save banner."})}else l({type:"error",msg:"Please provide either a Title or an Image URL for the banner."})},style:{display:"flex",flexDirection:"column",gap:"14px",padding:"20px",overflowY:"auto",maxHeight:"75vh"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:ye.label,children:"Banner Image URL (Recommended for Image Banners)"}),(0,de.jsx)("input",{type:"text",value:m.image_url,onChange:e=>u({...m,image_url:e.target.value}),placeholder:"https://example.com/banner.jpg or /banner-1.jpg",style:ye.input}),(0,de.jsxs)("div",{style:ye.specsBox,children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px",fontWeight:700,color:"#007C89",marginBottom:"4px"},children:[(0,de.jsx)(P,{size:14}),(0,de.jsx)("span",{children:"Image Banner Guidance:"})]}),(0,de.jsxs)("p",{style:{margin:"2px 0"},children:["⢠",(0,de.jsx)("strong",{children:"Format:"})," WEBP, PNG, JPG image banner"]}),(0,de.jsxs)("p",{style:{margin:"2px 0"},children:["⢠",(0,de.jsx)("strong",{children:"Aspect Ratio:"})," 16:9 widescreen or 4:3 (e.g. 800Ã450 px)"]}),(0,de.jsxs)("p",{style:{margin:"2px 0"},children:["⢠",(0,de.jsx)("strong",{children:"Tip:"})," If you upload a full graphic image banner, you can leave Title empty!"]})]})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:ye.label,children:"Banner Title (Optional for pure image banners)"}),(0,de.jsx)("input",{type:"text",value:m.title,onChange:e=>u({...m,title:e.target.value}),placeholder:"e.g. Annual Tax Return Filing Season 2026",style:ye.input})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:ye.label,children:"Description / Notice Text (Optional)"}),(0,de.jsx)("textarea",{rows:"2",value:m.description,onChange:e=>u({...m,description:e.target.value}),placeholder:"Additional detail or announcement body...",style:{...ye.input,resize:"vertical",minHeight:"60px"}})]}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:ye.label,children:"Badge Label"}),(0,de.jsx)("input",{type:"text",value:m.badge_text,onChange:e=>u({...m,badge_text:e.target.value}),placeholder:"NOTICE, OFFER, UPDATE",style:ye.input})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:ye.label,children:"Badge Color"}
2),(0,de.jsxs)("select",{value:m.badge_type,onChange:e=>u({...m,badge_type:e.target.value}),style:ye.input,children:[(0,de.jsx)("option",{value:"danger",children:"ð´ Red (Alert / Deadline)"}),(0,de.jsx)("option",{value:"warning",children:"ð¡ Yellow (Notice / Warning)"}),(0,de.jsx)("option",{value:"info",children:"ðµ Blue (Info / Update)"}),(0,de.jsx)("option",{value:"success",children:"ð¢ Green (Offer / Discount)"})]})]})]}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:ye.label,children:"Button Text (CTA)"}),(0,de.jsx)("input",{type:"text",value:m.button_text,onChange:e=>u({...m,button_text:e.target.value}),placeholder:"e.g. Claim Offer / File Now",style:ye.input})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:ye.label,children:"Button Link URL"}),(0,de.jsx)("input",{type:"text",value:m.button_url,onChange:e=>u({...m,button_url:e.target.value}),placeholder:"e.g. /services",style:ye.input})]})]}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:ye.label,children:"Show On Page"}),(0,de.jsxs)("select",{value:m.target_page,onChange:e=>u({...m,target_page:e.target.value}),style:ye.input,children:[(0,de.jsx)("option",{value:"both",children:"Both Login & Signup"}),(0,de.jsx)("option",{value:"login",children:"Login Page Only"}),(0,de.jsx)("option",{value:"register",children:"Signup Page Only"})]})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:ye.label,children:"Display Order"}),(0,de.jsx)("input",{type:"number",value:m.display_order,onChange:e=>u({...m,display_order:Number(e.target.value)}),style:ye.input})]})]}),(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px",paddingTop:"10px",borderTop:"1px solid #E2E8F0"},children:[(0,de.jsx)("button",{type:"button",onClick:()=>c(!1),style:ye.cancelBtn,children:"Cancel"}),(0,de.jsx)("button",{type:"submit",style:ye.saveBtn,children:p?"Update Banner":"Save & Publish Banner"})]})]})]})})]})}var ye={headerCard:{background:"linear-gradient(135deg, #FFFFFF 0%, #F8FAFC 100%)",border:"1px solid #E2E8F0",borderRadius:"16px",padding:"20px 24px",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"20px",flexWrap:"wrap",boxShadow:"0 4px 12px rgba(0,0,0,0.03)"},addBtn:{display:"inline-flex",alignItems:"center",gap:"8px",padding:"10px 18px",borderRadius:"10px",background:"var(--accent-teal, #007C89)",color:"#fff",border:"none",cursor:"pointer",fontWeight:700,fontSize:"0.85rem",whiteSpace:"nowrap",boxShadow:"0 4px 12px rgba(0,124,137,0.25)",transition:"all 0.2s ease"},alertBox:{padding:"12px 16px",borderRadius:"10px",fontSize:"0.85rem",fontWeight:600,display:"flex",alignItems:"center",justifyContent:"space-between",border:"1px solid"},emptyBox:{background:"#FFFFFF",border:"1px dashed #CBD5E1",borderRadius:"16px",padding:"40px 20px",textAlign:"center"},bannerCard:{background:"#FFFFFF",border:"1px solid #E2E8F0",borderRadius:"16px",padding:"18px",display:"flex",flexDirection:"column",justifyContent:"space-between",boxShadow:"0 4px 14px rgba(0,0,0,0.03)"},iconBtn:{padding:"6px 10px",borderRadius:"8px",background:"#F1F5F9",color:"#475569",border:"1px solid #E2E8F0",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},modalOverlay:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(7, 17, 31, 0.5)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"},modalBox:{background:"#FFFFFF",border:"1px solid #E2E8F0",borderRadius:"20px",width:"100%",maxWidth:"560px",boxShadow:"0 20px 50px rgba(0,0,0,0.15)",display:"flex",flexDirection:"column",maxHeight:"90vh",overflow:"hidden"},modalHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"18px 22px",borderBottom:"1px solid #E2E8F0",background:"#F8FAFC"},label:{display:"block",fontSize:"0.72rem",fontWeight:700,color:"var(--text-muted, #475569)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"6px"},input:{width:"100%",padding:"9px 12px",borderRadius:"8px",background:"#FFFFFF",border:"1px solid #CBD5E1",color:"var(--primary, #07111F)",fontSize:"0.88rem",outline:"none",boxSizing:"border-box",fontFamily:"inherit"},specsBox:{marginTop:"6px",background:"#EAF6FA",border:"1px solid #BEE3F8",borderRadius:"8px",padding:"8px 12px",fontSize:"0.76rem",color:"#005F6B",lineHeight:"1.5"},cancelBtn:{padding:"8px 16px",borderRadius:"8px",background:"#F1F5F9",color:"#475569",border:"1px solid #CBD5E1",cursor:"pointer",fontWeight:600,fontSize:"0.85rem"},saveBtn:{padding:"8px 18px",borderRadius:"8px",background:"var(--accent-teal, #007C89)",color:"#fff",border:"none",cursor:"pointer",fontWeight:700,fontSize:"0.85rem",boxShadow:"0 4px 12px rgba(0,124,137,0.25)"}},fe=oe.lazy(()=>X(()=>import("./OperationsWorkspace-B_WrwjIZ.js"),__vite__mapDeps([0])));function be({token:e,isMobile:r,styles:s}){const[a,i]=oe.useState(null),[n,l]=oe.useState(!1),[o,d]=oe.useState(!1),[c,p]=oe.useState(!1),[x,m]=oe.useState(0),[g,u]=oe.useState(!1),[h,y]=oe.useState(null),[f,b]=oe.useState([]),[v,j]=oe.useState(""),[S,C]=oe.useState(null),[w,_]=oe.useState({type:"",text:""}),N=oe.useRef(),k=oe.useRef(null),z=oe.useRef(0),A=oe.useRef(!1),T=oe.useCallback(()=>{fetch("/api/atl-verify?action=server_files").then(e=>e.json()).then(e=>{if(e.success){y(e.data?.meta||null);
2const t=e.data?.files||[];b(t),t.length>0&&!v&&j(t[0].name),e.data?.server_info&&C(e.data.server_info)}}).catch(()=>{})},[v]),F=oe.useCallback(()=>{A.current=!1,k.current&&(clearInterval(k.current),k.current=null)},[]),R=oe.useRef(!1),B=oe.useCallback(()=>{k.current&&clearInterval(k.current),A.current=!0,k.current=setInterval(async()=>{if(A.current&&!R.current){if(z.current++,z.current>4e3)return F(),_({type:"error",text:"Processing paused after the batch limit. Reopen this panel to resume saved progress. Your active database is unchanged."}),d(!1),p(!1),void l(!1);try{const t=await(await ee("/api/atl-verify?action=job_status")).json().catch(()=>null);if(t&&t.data&&t.data.job){let r=t.data.job;if(r.running&&r.resumable&&r.job_id){R.current=!0;try{const e=await(await ee("/api/atl-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({continue_job:r.job_id})})).json();if(!e.success)throw new Error(e.message||"Batch could not complete.");r=e.data.job}catch(e){return F(),d(!1),p(!1),l(!1),void _({type:"error",text:"Import paused; saved progress is safe. Reopen this panel to resume. "+e.message})}finally{R.current=!1}}r.running?(d(!0),m(r.progress||10),_({type:"",text:r.message||"Downloading & processing records..."})):"completed"===r.status?(sessionStorage.removeItem("atl_fbr_inprogress"),sessionStorage.removeItem("atl_fbr_started"),F(),m(100),y(r.meta||t.data.meta),_({type:"success",text:r.message||"ATL database synchronized successfully!"}),d(!1),p(!1),l(!1),T()):"failed"===r.status?(sessionStorage.removeItem("atl_fbr_inprogress"),sessionStorage.removeItem("atl_fbr_started"),F(),m(0),_({type:"error",text:r.message||"FBR download or rebuild failed."}),d(!1),p(!1),l(!1)):r.running||(F(),d(!1),p(!1),l(!1),_({type:"",text:"No saved import is waiting. Select your source file to start."}))}}catch(t){}}},2500)},[F,T]);oe.useEffect(()=>(T(),ee("/api/atl-verify?action=job_status").then(e=>e.json()).then(e=>{const t=e.data?.job;e.success&&t?.running?(d(!0),m(t.progress||10),_({type:"",text:"â³ Process resumed: "+(t.message||"Background job is running...")}),z.current=0,B()):(sessionStorage.removeItem("atl_fbr_inprogress"),sessionStorage.removeItem("atl_fbr_started"))}).catch(()=>{}),()=>{F()}),[T,B,F]);const I=async()=>{try{const e=await(await ee("/api/atl-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reset_job:!0})})).json();if(!e.success)return void _({type:"error",text:e.message})}catch(e){}sessionStorage.removeItem("atl_fbr_inprogress"),sessionStorage.removeItem("atl_fbr_started"),sessionStorage.removeItem("atl_fbr_cronkey"),F(),l(!1),d(!1),p(!1),m(0),_({type:"",text:""}),T()},D=n||o||c,P=f.find(e=>e.name===v)||f[0];return(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{padding:r?"16px":"28px"},children:[(0,de.jsx)("h2",{style:{...s.tabTitle,margin:"0 0 6px 0"},children:"ATL File Manager"}),(0,de.jsx)("p",{style:{...s.tabText,margin:"0 0 24px 0"},children:"Upload FBR's Active Taxpayer List (ATL) Excel (.xlsx), CSV, or ZIP file or rebuild directly from the server folder. Choose your downloaded ATL file, then upload and process it. Existing verification stays available until the replacement is ready."}),h&&(0,de.jsxs)("div",{style:{background:"rgba(0,124,137,0.06)",border:"1px solid rgba(0,124,137,0.2)",borderRadius:"10px",padding:"16px 20px",marginBottom:"24px",display:"flex",flexWrap:"wrap",gap:"20px"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("p",{style:{margin:0,fontSize:"0.72rem",fontWeight:700,textTransform:"uppercase",color:"var(--text-muted)",letterSpacing:"0.5px"},children:"Total Active Records"}),(0,de.jsx)("p",{style:{margin:"4px 0 0",fontSize:"1.4rem",fontWeight:800,color:"var(--accent-teal)"},children:(h.record_count||0).toLocaleString()})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("p",{style:{margin:0,fontSize:"0.72rem",fontWeight:700,textTransform:"uppercase",color:"var(--text-muted)",letterSpacing:"0.5px"},children:"Source File"}),(0,de.jsx)("p",{style:{margin:"4px 0 0",fontSize:"1.05rem",fontWeight:700,color:"var(--primary)"},children:h.source_file||"ATL Database"})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("p",{style:{margin:0,fontSize:"0.72rem",fontWeight:700,textTransform:"uppercase",color:"var(--text-muted)",letterSpacing:"0.5px"},children:"Last Updated"}),(0,de.jsx)("p",{style:{margin:"4px 0 0",fontSize:"0.95rem",fontWeight:600,color:"var(--primary)"}
2,children:h.uploaded_at?new Date(h.uploaded_at).toLocaleString():"Never"})]})]}),(0,de.jsxs)("div",{style:{marginBottom:"16px"},children:[(0,de.jsx)("button",{type:"button",className:"btn btn-outline",disabled:D||g,onClick:async()=>{u(!0);try{const e=await(await ee("/api/atl-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cleanup_old_temps:!0})})).json();_({type:e.success?"success":"error",text:e.success?`${e.message} Freed ${((e.data?.freed_bytes||0)/1048576).toFixed(1)} MB.`:e.message}),T()}catch{_({type:"error",text:"Cleanup failed. Please retry."})}finally{u(!1)}},children:g?"Cleaningâ¦":"Delete old temporary ATL files"}),(0,de.jsx)("p",{style:{fontSize:"0.8rem",marginTop:"6px"},children:"Keeps todayâs temporary files, source uploads and the active database. Old temporary files are also cleaned automatically before a rebuild."})]}),(0,de.jsxs)("div",{style:{background:"var(--bg-cool)",border:"1px solid var(--border)",borderRadius:"10px",padding:"16px 20px",marginBottom:"20px",fontSize:"0.86rem",lineHeight:"1.6",color:"var(--text)"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:"8px",marginBottom:"8px"},children:[(0,de.jsx)("strong",{style:{color:"var(--primary)",fontSize:"0.92rem"},children:"â¡ Direct Server Rebuild (From cPanel / FTP Folder):"}),(0,de.jsxs)("button",{type:"button",onClick:T,className:"btn btn-outline",style:{padding:"4px 10px",fontSize:"0.75rem",borderRadius:"4px"},children:[(0,de.jsx)(t,{size:12})," Refresh Files"]})]}),(0,de.jsxs)("p",{style:{margin:"0 0 10px 0",fontSize:"0.82rem",color:"var(--text-muted)"},children:["You can upload large FBR files (100MB+) directly via ",(0,de.jsx)("strong",{children:"cPanel File Manager"})," or ",(0,de.jsx)("strong",{children:"FTP"})," to:",(0,de.jsx)("code",{style:{background:"var(--bg-card)",padding:"2px 8px",borderRadius:"4px",border:"1px solid var(--border)",display:"inline-block",margin:"4px 0",fontWeight:"700",color:"var(--accent-teal)"},children:"api/uploads/atl/atl_current.xlsx"})]}),f.length>0?(0,de.jsxs)("div",{style:{background:"var(--bg-card)",padding:"12px 16px",borderRadius:"8px",border:"1px solid var(--border)",marginTop:"10px"},children:[(0,de.jsx)("label",{style:{display:"block",fontSize:"0.78rem",fontWeight:"700",color:"var(--text-muted)",marginBottom:"6px"},children:"Detected File(s) on Server:"}),(0,de.jsxs)("div",{style:{display:"flex",gap:"10px",alignItems:"center",flexWrap:"wrap"},children:[(0,de.jsx)("select",{value:v,onChange:e=>j(e.target.value),style:{padding:"8px 12px",borderRadius:"6px",border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:"0.85rem",minWidth:"240px",fontWeight:"600"},children:f.map(e=>(0,de.jsxs)("option",{value:e.name,children:[e.name," (",e.size_formatted," â ",e.mtime_formatted,")"]},e.name))}),(0,de.jsxs)("button",{type:"button",className:"btn btn-outline",onClick:async()=>{const e=v||(f.length>0?f[0].name:"");if(e){p(!0),m(10),_({type:"",text:`Starting rebuild from server file: ${e}...`});try{const t=await(await ee("/api/atl-verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target_file:e})})).json();if(!t.success)throw new Error(t.message||"Unable to start import.");t.data?.running?(m(t.data.job?.progress||1),_({type:"",text:t.message}),z.current=0,B()):(m(100),y(t.data),_({type:"success",text:t.message}),p(!1),T())}catch(t){_({type:"error",text:t.message||"Error processing server file."}),p(!1)}}else _({type:"error",text:"No server file selected."})},disabled:D,style:{padding:"8px 18px",fontSize:"0.85rem",display:"inline-flex",alignItems:"center",gap:"6px"},children:[(0,de.jsx)(t,{size:14,className:c?"animate-spin":""})," ",c?"Parsing & Rebuildingâ¦":"Rebuild DB from Selected File"]})]}),P&&(0,de.jsxs)("p",{style:{margin:"8px 0 0",fontSize:"0.75rem",color:"var(--text-muted)"},children:["Selected: ",(0,de.jsx)("strong",{children:P.name})," · Size: ",P.size_formatted," · Path: ",(0,de.jsx)("code",{children:P.path_relative})]})]}):(0,de.jsxs)("div",{style:{background:"rgba(234, 179, 8, 0.08)",border:"1px solid rgba(234, 179, 8, 0.3)",padding:"10px 14px",borderRadius:"6px",color:"#b45309",fontSize:"0.8rem"},children:["No ATL file detected in server folder yet. Upload ",(0,de.jsx)("code",{children:"ATL_IT.xlsx"})," or ",(0,de.jsx)("code",{children:"atl_current.xlsx"})," to ",(0,de.jsx)("code",{children:"api/uploads/atl/"})," via cPanel File Manager or use browser upload below."]})]}),(0,de.jsxs)("form",{onSubmit:async t=>
2{if(t.preventDefault(),a)if([".xlsx",".csv",".zip"].some(e=>a.name.toLowerCase().endsWith(e))){l(!0),m(10),_({type:"",text:""});try{const t=new FormData;t.append("atl_file",a);const r=new XMLHttpRequest;r.open("POST","/api/atl-verify"),r.setRequestHeader("Authorization","Bearer "+e),r.upload.onprogress=e=>{e.lengthComputable&&m(Math.round(e.loaded/e.total*70))},r.onload=()=>{try{const e=JSON.parse(r.responseText);e.success&&e.data?.job?.resumable&&e.data?.running?(m(e.data.job.progress||1),_({type:"",text:e.message}),d(!0),z.current=0,B()):e.success?(m(100),y(e.data),_({type:"success",text:e.message||`ATL database rebuilt! ${e.data?.record_count?.toLocaleString()} records processed.`}),T()):_({type:"error",text:e.message||"Upload failed."})}catch{_({type:"error",text:"Invalid server response or PHP upload timeout."})}l(!1),i(null),N.current&&(N.current.value="")},r.onerror=()=>{_({type:"error",text:"Network error or file size exceeded server limits. Use FTP / cPanel upload option."}),l(!1)},r.send(t)}catch(r){_({type:"error",text:r.message||"Upload error."}),l(!1)}}else _({type:"error",text:"Only .xlsx, .csv, or .zip files are accepted."});else _({type:"error",text:"Please select an .xlsx, .csv, or .zip file first."})},children:[(0,de.jsxs)("div",{style:{border:"2px dashed var(--border)",borderRadius:"12px",padding:"24px 20px",textAlign:"center",marginBottom:"16px",background:"var(--bg-cool)",cursor:"pointer"},onClick:()=>N.current?.click(),children:[(0,de.jsx)(U,{size:28,style:{color:"var(--accent-teal)",marginBottom:"6px"}}),(0,de.jsx)("p",{style:{margin:"0 0 4px",fontWeight:700,color:"var(--primary)"},children:"Click to select FBR ATL Excel / CSV file from device (Manual Upload)"}),(0,de.jsx)("p",{style:{margin:0,fontSize:"0.8rem",color:"var(--text-muted)"},children:"Supports .xlsx, .csv, and .zip formats (e.g. ATL_IT.xlsx, ATL_Employers_Only.xlsx)"}),a&&(0,de.jsxs)("p",{style:{margin:"8px 0 0",fontSize:"0.85rem",fontWeight:600,color:"var(--accent-teal)"},children:["Selected: ",a.name," (",(a.size/1024/1024).toFixed(1)," MB)"]}),(0,de.jsx)("input",{ref:N,type:"file",accept:".xlsx,.csv,.zip",style:{display:"none"},onChange:e=>i(e.target.files[0]||null)})]}),D&&(0,de.jsxs)("div",{style:{marginBottom:"14px"},children:[(0,de.jsx)("div",{style:{background:"var(--border)",borderRadius:"999px",height:"10px",overflow:"hidden"},children:(0,de.jsx)("div",{style:{width:x+"%",background:x<30?"#f59e0b":x<70?"var(--accent-teal)":"#16a34a",height:"100%",borderRadius:"999px",transition:"width 0.5s ease"}})}),(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"6px",flexWrap:"wrap",gap:"8px"},children:[(0,de.jsx)("p",{style:{margin:0,fontSize:"0.8rem",color:"var(--text-muted)"},children:x<15?`â³ Starting... ${x}%`:x<50?`âï¸ Processing uploaded records... ${x}%`:x<90?`âï¸ Parsing & indexing records... ${x}%`:`â
Finalizing database... ${x}%`}),(0,de.jsx)("button",{type:"button",onClick:I,style:{padding:"3px 10px",fontSize:"0.72rem",borderRadius:"4px",border:"1px solid rgba(220,38,38,0.4)",background:"rgba(220,38,38,0.06)",color:"#dc2626",cursor:"pointer"},children:"â Cancel / Reset"})]})]}),!D&&"error"===w.type&&(0,de.jsxs)("div",{style:{display:"flex",gap:12,marginBottom:14},children:[(0,de.jsx)("button",{type:"button",className:"btn btn-primary",onClick:()=>{z.current=0,d(!0),B()},children:"Resume saved import"}),(0,de.jsx)("button",{type:"button",className:"btn btn-outline",onClick:I,children:"Reset import"})]}),w.text&&(0,de.jsx)("div",{style:{padding:"12px 16px",borderRadius:"8px",marginBottom:"14px",background:"success"===w.type?"rgba(22,163,74,0.08)":"error"===w.type?"rgba(220,38,38,0.08)":"rgba(0,124,137,0.08)",border:"1px solid "+("success"===w.type?"rgba(22,163,74,0.25)":"error"===w.type?"rgba(220,38,38,0.25)":"rgba(0,124,137,0.25)"),color:"success"===w.type?"#15803d":"error"===w.type?"#dc2626":"var(--accent-teal)",fontSize:"0.875rem",fontWeight:600},children:w.text}),(0,de.jsx)("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap"},children:(0,de.jsx)("button",{type:"submit",className:"btn btn-outline",disabled:n||!a,style:{padding:"10px 20px",fontSize:"0.85rem"},children:n?"Processingâ¦":(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(U,{size:15})," Upload & Rebuild from Device"]})})})]})]})}var ve=e=>"approved"===e.status&&1===Number(e.is_verified)&&1===Number(e.consent_confirmed)&&("client_service"===e.review_source&&Number(e.service_request_id)>0||["calculator_user","website_visitor"].includes(e.review_source)&&String(e.verification_note||"").trim().length>=5),je={client_service:"Paid / Advisory Service",calculator_user:"Free Tax Calculator",website_visitor:"Website / Tax Resources",unclassified:"Not
2Classified"};function Se({theme:e}){const o=ee,{user:m,token:g,logout:f}=Q(),[z,R]=(0,oe.useState)("undefined"!=typeof window&&window.innerWidth<1024);(0,oe.useEffect)(()=>{const e=()=>R(window.innerWidth<1024);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[I,D]=(0,oe.useState)({clients:0,consultants:0,requests:0,pending_payments:0,total_revenue:0}),[P,U]=(0,oe.useState)(!1),[G,K]=(0,oe.useState)([]),[X,ce]=(0,oe.useState)([]),[pe,xe]=(0,oe.useState)([]),[me,ge]=(0,oe.useState)([]),[ye,Se]=(0,oe.useState)([]),[we,_e]=(0,oe.useState)([]),[Ne,ke]=(0,oe.useState)({title:"",description:"",job_type:"Full-Time",prerequisites:"",status:"Draft"}),[ze,Ae]=(0,oe.useState)(null),[Te,Fe]=(0,oe.useState)([]),[Re,Be]=(0,oe.useState)([]),[Ie,De]=(0,oe.useState)([]),[Pe,Ee]=(0,oe.useState)({name:"",role:"",reviewer_email:"",rating:5,review_text:"",review_source:"website_visitor",service_request_id:"",verification_note:""}),[We,Le]=(0,oe.useState)(null),[Oe,qe]=(0,oe.useState)("stats"),[$e,Me]=(0,oe.useState)(null),[Ue,Ge]=(0,oe.useState)(!1),[Ve,He]=(0,oe.useState)(""),[Ye,Je]=(0,oe.useState)(""),[Ke,Xe]=(0,oe.useState)("all"),[Qe,Ze]=(0,oe.useState)("all"),[et,tt]=(0,oe.useState)("all"),[rt,st]=(0,oe.useState)({client_type:"existing",client_id:"",client_name:"",client_email:"",client_phone:"",service_type:"",details:"",assigned_consultant_id:""}),[at,it]=(0,oe.useState)({name:"",email:"",password:"",phone:"",company_name:"",role:"consultant"}),[nt,lt]=(0,oe.useState)(null),[ot,dt]=(0,oe.useState)("single"),[ct,pt]=(0,oe.useState)({total:0,current:0,status:"idle"}),[xt,mt]=(0,oe.useState)([]),[gt,ut]=(0,oe.useState)({title:"",excerpt:"",content:"",cover_image:"",category:"Tax Guide",slug:"",seo_title:"",meta_description:"",social_caption:"",focus_keywords:"",tax_year:"",is_featured:0}),[ht,yt]=(0,oe.useState)(null),[ft,bt]=(0,oe.useState)(""),[vt,jt]=(0,oe.useState)(null),[St,Ct]=(0,oe.useState)(""),[wt,_t]=(0,oe.useState)(null),[Nt,kt]=(0,oe.useState)(!1),[zt,At]=(0,oe.useState)(""),[Tt,Ft]=(0,oe.useState)(null),[Rt,Bt]=(0,oe.useState)(""),[It,Dt]=(0,oe.useState)(""),[Pt,Et]=(0,oe.useState)([]),[Wt,Lt]=(0,oe.useState)([]),[Ot,qt]=(0,oe.useState)(null),[$t,Mt]=(0,oe.useState)({id:0,service_name:"",price:0,required_docs:"",short_description:"",processing_time:"",eligible_persons:"",icon_name:"",slug:"",sort_order:1,is_featured:!1,is_active:!0}),[Ut,Gt]=(0,oe.useState)(!1),[Vt,Ht]=(0,oe.useState)(""),[Yt,Jt]=(0,oe.useState)(""),[Kt,Xt]=(0,oe.useState)("pakistan"),[Qt,Zt]=(0,oe.useState)(()=>ne()),[er,tr]=(0,oe.useState)(null),[rr,sr]=(0,oe.useState)({id:"",service_key:"",service_name:"",category:"Taxation & Compliance",price_label:"Free Consult / Best Quote",short_description:"",eligibility:"",processing_time:"3 - 5 Days",icon_name:"Building",slug:"",is_featured:!0,required_docs:""}),[ar,ir]=(0,oe.useState)(()=>re()),[nr,lr]=(0,oe.useState)(""),[or,dr]=(0,oe.useState)("All"),[cr,pr]=(0,oe.useState)(null);(0,oe.useEffect)(()=>{const e=nr.trim();if(!e&&"All"===or)return void pr(null);const t=setTimeout(()=>{const t=`/api/controllers/ntn_directory.php?q=${encodeURIComponent(e)}&category=${encodeURIComponent(or)}`;o(t).then(e=>e.json()).then(e=>{e&&e.success&&Array.isArray(e.data?.ntns)&&pr(e.data.ntns)}).catch(()=>{})},250);return()=>clearTimeout(t)},[nr,or]);const[xr,mr]=(0,oe.useState)(!1),[gr,ur]=(0,oe.useState)(null),[hr,yr]=(0,oe.useState)({name:"",ftn:"",province:"Punjab",category:"Government"}),[fr,br]=(0,oe.useState)(!1),[vr,jr]=(0,oe.useState)(""),[Sr,Cr]=(0,oe.useState)("Punjab"),[wr,_r]=(0,oe.useState)("Government"),[Nr,kr]=(0,oe.useState)(!1),[zr,Ar]=(0,oe.useState)(!1),[Tr,Fr]=(0,oe.useState)({type:"",msg:""}),[Rr,Br]=(0,oe.useState)([]),[Ir,Dr]=(0,oe.useState)([]),[Pr,Er]=(0,oe.useState)(null),[Wr,Lr]=(0,oe.useState)({contact_number:"",address:"",street_address:"",address_locality:"",address_region:"",postal_code:"",address_country:"PK",email:"",whatsapp_link:"",website_title:"",free_consultation_link:"",facebook_url:"",x_url:"",instagram_url:"",youtube_url:"",linkedin_url:"",threads_url:"",google_review_url:"",gemini_api_key:"",google_client_id:"",adsense_publisher_id:"",adsense_status:"not_applied",adsense_enabled:"0",smtp_host:"",smtp_port:"",smtp_username:"",smtp_password:"",smtp_secure:"tls",smtp_sender_email:"",smtp_sender_name:""}),[Or,qr]=(0,oe.useState)({id:0,question:"",answer:""}),[$r,Mr]=(0,oe.useState)([]),[Ur,Gr]=(0,oe.useState)(null),[Vr,Hr]=(0,oe.useState)({bank_name:"",account_title:"",account_no:"",iban_no:""}),[Yr,Jr]=(0,oe.useState)(null),[Kr,Xr]=(0,oe.useState)(""),[Qr,Zr]=(0,oe.useState)({subject:"",body:"",target:"clients"}),[es,ts]=(0,oe.useState)(null),[rs,ss]=(0,oe.useState)([]),[as,is]=(0,oe.useState)(null),[ns,ls]=(0,oe.useState)([]),[os,ds]=(0,oe.useState)(!1),[cs,ps]=(0,oe.useState)(!1),[xs,ms]=(0,oe.useState)(!1),[gs,us]=(0,oe.useState)(""),[hs,ys]=(0,oe.useState)("all"),[fs,bs]=(0,oe.useState)([]),[vs,js]=(0,oe.useState)(""),[Ss,Cs]=(0,oe.useState)("all"),[ws,_s]=(0,oe.useState)({sending:!1,current:0,total:0,success:0,failed:0,statusText:"",logs:[]}),[Ns,ks]=(0,oe.useState)(""),[zs,As]=(0,oe.useState)([]),[Ts,Fs]=(0,oe.useState)(!1),[Rs,Bs]=(0,oe.useState)([]),[Is,Ds]=(0,oe.useState)(null),[Ps,Es]=(0,oe.useState)({commission_amount:"",commission_status:"unpaid"}),[Ws,Ls]=(0,oe.useState)(null),[Os,qs]=(0,oe.useState)(null),[$s,Ms]=(0,oe.useState)({id:"",name:"",role:"",credentials:"",credentials_verified:!1,verification_reference:"",specialization:"",bio:"",show_on_home:!1,home_position:""}),[Us,Gs]=(0,oe.useState)({summary:{total_income:0,total_expenses:0,net_balance:0,category_totals:{}},income:[],expenses:[]}),[Vs,Hs]=(0,oe.useState)(!1),[Ys,Js]=(0,oe.useState)("all"),[Ks,Xs]=(0,oe.useState)(!1),[Qs,Zs]=(0,oe.useState)({title:"",category:"challan",amount:"",expense_date:(new Date).toISOString().split("T")[0],request_id:"",notes:""}),[ea,ta]=(0,oe.useState)(!1),[ra,sa]=(0,oe.useState)({client_name:"",title:"",amount:"",payment_method:"Cash",request_id:"",date:(new Date).toISOString().split("T")[0],notes:""}),[aa,ia]=(0,oe.useState)(null),[na,la]=(0,oe.useState)(""),oa=async()=>{try{const e=await(await o(`/api/admin/stats?t=${Date.now()}`,{headers:{Authorization:`Bearer ${g}`}})).json();e.success&&D(e.data)}catch(e){}},da=async()=>{kr(!0);try{const e=await(await o(`/api/admin/requests?t=${Date.now()}`,{headers:{Authorization:`Bearer ${g}`}})).json();e.success&&(K(e.data.requests),ce(e.data.consultants))}catch(e){}finally{kr(!1)}},ca=async()=>{try{const e=await(await o(`/api/admin/users?t=${Date.now()}`,{headers:{Authorization:`Bearer ${g}`}})).json();e.success&&xe(e.data.users)}catch(e){}},pa=async()=>{try{const e=await(await o("/api/careers/list")).json();e.success&&e.data&&e.data.jobs&&_e(e.data.jobs)}catch(e){}},xa=async()=>{try{const e=await(await o(`/api/articles?refresh=${Date.now()}`,{cache:"no-store",headers:{Accept:"application/json"}})).json();e.success&&Se(e.data.articles)}catch(e){}},ma=async()=>{try{const e=await(await o(`/api/articles/pending?t=${Date.now()}`,{headers:{Authorization:`Bearer ${g}`}})).json();e.success?Fe(e.data.articles||[]):Tr("Debug Error: "+e.message)}catch(e){Tr("Debug Network Error: "+e.message)}},ga=async()=>{try{const e=await(await o(`/api/articles/comments-admin?status=pending&t=${Date.now()}`,{headers:{Authorization:`Bearer ${g}`}})).json();e.success&&Be(e.data?.comments||[])}catch(e){}},ua=async(e,t)=>{Ar(!0),Fr({type:"",msg:""});try{const r=await(await o("/api/articles/moderate-comment",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({id:e,status:t})})).json();if(!r.success)throw new Error(r.message||"Moderation action failed.");Fr({type:"success",msg:r.message}),await ga()}catch(r){Fr({type:"error",msg:r.message||"Moderation action failed."})}finally{Ar(!1)}},ha=async(e,t)=>{Ar(!0),Fr({type:"",msg:""});try{const r=await(await o("/api/articles/review",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({id:e,approve:t})})).json();r.success?(Fr({type:"success",msg:r.message}),await xa(),await ma()):Fr({type:"error",msg:r.message})}catch(r){Fr({type:"error",msg:"Failed to process review action."})}finally{Ar(!1)}},ya=async()=>{try{const e=await(await o(`/api/admin/payments?t=${Date.now()}`,{headers:{Authorization:`Bearer ${g}`}})).json();e.success&&Et(e.data.payments)}catch(e){}},fa=async()=>{try{const e=await(await o(`/api/services/list-services?all=1&t=${Date.now()}`,{headers:{Authorization:`Bearer ${g}`}})).json();e.success&&Lt(e.data.services)}catch(e){}},ba=async()=>{try{const e=await(await o(`/api/ticker-news?t=${Date.now()}`)).json();e.success&&Dr(e.data.news)}catch(e){}},va=async()=>{try{const e=await(await o(`/api/services/payment-settings?t=${Date.now()}`,{headers:{Authorization:`Bearer ${g}`}})).json();if(e.success&&e.data&&e.data.settings){const t=e.data.settings;Er(t),Hr({bank_name:t.bank_name||"",account_title:t.account_title||"",account_no:t.account_no||"",iban_no:t.iban_no||""})}}catch(e){}},ja=async()=>{try{const e=await(await o("/api/admin/system-settings",{headers:{Authorization:`Bearer ${g}`}})).json();e.success&&e.data&&Lr(t=>({...t,...e.data.settings}))}catch(e){}},Sa=async()=>{try{const e=await(await o("/api/admin/bot-knowledge",{headers:{Authorization:`Bearer ${g}`}})).json();if(e.success&&e.data){Mr(e.data.knowledge||[]);const t=e.data.knowledge.find(e=>"text"===e.type)||e.data.knowledge[0]||{};qr(e=>
2({...e,id:t.id||0,question:t.question||"",answer:t.answer||""}))}}catch(e){}},Ca=(e,{allowRelative:t=!1}={})=>{const r=String(e??"").trim();return r?t&&r.startsWith("/")||/^https?:\/\//i.test(r)?r:`https://${r.replace(/^\/+/,"")}`:""},wa=(0,oe.useContext)(Z),_a=async()=>{kr(!0);try{const e=await(await o(`/api/reviews/admin-list?t=${Date.now()}`,{headers:{Authorization:`Bearer ${g}`}})).json();e.success&&De(e.data.reviews)}catch(e){}finally{kr(!1)}},Na=async()=>{kr(!0);try{const e=await(await o(`/api/admin/commissions?t=${Date.now()}`,{headers:{Authorization:`Bearer ${g}`}})).json();e.success&&Bs(e.data.commissions)}catch(e){}finally{kr(!1)}},ka=async()=>{Fs(!0);try{const e=await(await o("/api/admin/get-team",{headers:{Authorization:`Bearer ${g}`}})).json();e.success&&As(e.data.team)}catch(e){}finally{Fs(!1)}},za=async()=>{Hs(!0);try{const e=await(await o(`/api/admin/financial-ledger?t=${Date.now()}`,{headers:{Authorization:`Bearer ${g}`}})).json();e.success&&Gs(e.data)}catch(e){}finally{Hs(!1)}},Aa=async e=>{if(e.preventDefault(),!Qs.title.trim()||!Qs.amount||parseFloat(Qs.amount)<=0)Fr({type:"error",msg:"Please provide expense title and a valid positive amount."});else{Ar(!0);try{const e=await(await o("/api/admin/add-expense",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify(Qs)})).json();e.success?(Fr({type:"success",msg:"Expense entry added to financial ledger successfully!"}),Xs(!1),Zs({title:"",category:"challan",amount:"",expense_date:(new Date).toISOString().split("T")[0],request_id:"",notes:""}),za()):Fr({type:"error",msg:e.message})}catch(t){Fr({type:"error",msg:"Failed to add expense entry."})}finally{Ar(!1)}}},Ta=async e=>{if(e.preventDefault(),!ra.amount||parseFloat(ra.amount)<=0)Fr({type:"error",msg:"Please provide a valid positive income amount."});else{Ar(!0);try{const e=await(await o("/api/payments/add-income",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify(ra)})).json();e.success?(Fr({type:"success",msg:"Direct revenue entry logged to financial ledger successfully!"}),ta(!1),sa({client_name:"",title:"",amount:"",payment_method:"Cash",request_id:"",date:(new Date).toISOString().split("T")[0],notes:""}),za(),ya(),oa()):Fr({type:"error",msg:e.message})}catch(t){Fr({type:"error",msg:"Failed to log direct revenue entry."})}finally{Ar(!1)}}};(0,oe.useEffect)(()=>{oa(),da(),ca(),(async()=>{try{const e=await(await o(`/api/admin/contacts?t=${Date.now()}`,{headers:{Authorization:`Bearer ${g}`}})).json();e.success&&ge(e.data.messages)}catch(e){}})(),xa(),ma(),ya(),fa(),(async()=>{try{const e=await(await o(`/api/admin/career-applications?t=${Date.now()}`,{headers:{Authorization:`Bearer ${g}`}})).json();e.success&&Br(e.data.applications)}catch(e){}})(),ba(),va(),_a(),Oa(),ka(),ja(),Sa(),Na(),za()},[]),(0,oe.useEffect)(()=>{"team"===Oe&&ka(),"reviews"===Oe&&_a(),"marketing"===Oe&&(Oa(),ca()),"syssettings"===Oe&&(ja(),Sa()),"careers"===Oe&&pa(),"commissions"===Oe&&Na(),"blogs"===Oe&&(xa(),ma(),ga()),"ledger"!==Oe&&"reports"!==Oe||za()},[Oe]);const Fa=e=>{const t=parseFloat(e?.amount||0),r=parseFloat(e?.verified_amount||0),s=parseFloat(e?.pending_amount||0),a=t>r+s?t-r-s:0;return{requestedAmount:t,receivedAmount:r,pendingAmount:s,discountAmount:a,hasPending:s>0,hasDiscount:a>0}},Ra=async(e,t,r="receipt",s=null)=>{let a=null,i=!1;if("Verified"===t){const e=Fa(s||{}),t=Math.max(e.requestedAmount-e.receivedAmount,0),n=s?.submitted_amount??s?.pending_amount??t??s?.amount??"",l="cash"===r?"Enter cash installment received (Rs.):":"online"===r?"Enter online bank transfer received (Rs.):":"Enter final verified installment amount (Rs.):",o=window.prompt(l,n?String(n):"");if(null===o)return;if(a=parseFloat(o),!Number.isFinite(a)||a<=0)return void Fr({type:"error",msg:"Please enter a valid received amount."});t>0&&a<t&&(i=window.confirm(`Remaining balance after this payment will be Rs. ${(t-a).toLocaleString()}. Press OK to treat this shortfall as discount. Press Cancel to keep it as pending balance with weekly reminders.`))}let n=!0;"Verified"===t&&(n=window.confirm("Send official invoice email to client?\n\n- Press OK to send invoice email to client\n- Press Cancel to verify payment SILENTLY (No email sent to client)")),Ar(!0),Fr({type:"",msg:""});try{const s=await(await o("/api/payments/verify",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({request_id:e,status:t,comment:"Rejected"===t?zt:"",verification_mode:r,received_amount:a,apply_discount:i,send_email:n})})).json();s.success?(Fr({type:"success",msg:s.message}),At(""),Me(null),da(),ya(),oa()):Fr({type:"error",msg:s.message})}catch(l){Fr({type:"error",msg:"Verification request failed."})}finally{Ar(!1)}},Ba=async e=>{try{const t=await(await o(`/api/services/details?id=${e}`,{headers:{Authorization:`Bearer ${g}`}})).json();t.success&&Ft(t.data)}catch(t){}},Ia=async e=>{if(e){Ar(!0),Fr({type:"",msg:""});try{const t=await(await o("/api/payments/resend-reminder",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({request_id:e})})).json();t.success?(Fr({type:"success",msg:t.message}),$e&&$e.id===e&&Ba(e),da(),ya()):Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"Failed to send payment reminder email."})}finally{Ar(!1)}}},Da=e=>{const t=document.getElementById("article-content-textarea");if(!t)return;const r=t.selectionStart,s=t.selectionEnd,a=gt.content||"",i=a.substring(0,r),n=a.substring(s,a.length);ut({...gt,content:i+e+n}),setTimeout(()=>{t.focus(),t.selectionStart=t.selectionEnd=r+e.length},0)},Pa=e=>
2{const t={income_tax:"Income Tax Filing (FBR)",income_tax_salaried:"Income Tax Return â Salaried Individual",income_tax_business:"Income Tax Return â Business/Self-Employed",ntn_registration:"NTN Registration (FBR)",sales_tax:"Sales Tax Management (PRA/SRB)",sales_tax_pra:"Sales Tax Registration â PRA (Punjab)",sales_tax_srb:"Sales Tax Registration â SRB (Sindh)",sales_tax_monthly:"Monthly Sales Tax Filing",secp_pvt:"SECP Private Limited Company Registration",secp_smc:"SECP Single Member Company (SMC-Pvt Ltd)",secp_aop:"Partnership / AOP Deed Registration",trademark:"Trademark & Brand Registration",fbr_return_company:"Corporate Annual Tax Return Filing",withholding_tax:"Withholding Tax Statement Filing"};return t[e]?t[e]:e?e.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()):""},Ea=e=>"Submitted"===e?"badge badge-submitted":"Awaiting Payment"===e?"badge badge-awaiting":"Processing"===e?"badge badge-processing":"badge badge-completed",Wa=(0,oe.useMemo)(()=>G.filter(e=>{if(Ye.trim()){const t=Ye.toLowerCase().trim(),r=Pa(e.service_type||"").toLowerCase(),s=(e.client_name||"").toLowerCase(),a=(e.client_company||"").toLowerCase(),i=(e.client_email||"").toLowerCase(),n=(e.client_phone||"").toLowerCase(),l=String(e.id||"").toLowerCase(),o=X.find(t=>String(t.id)===String(e.consultant_id)),d=o?o.name.toLowerCase():"";if(!(s.includes(t)||a.includes(t)||i.includes(t)||n.includes(t)||l.includes(t)||r.includes(t)||e.service_type&&e.service_type.toLowerCase().includes(t)||d.includes(t)))return!1}if("all"!==Ke&&e.status!==Ke)return!1;if("all"!==Qe)if("unassigned"===Qe){if(e.consultant_id)return!1}else if(String(e.consultant_id)!==String(Qe))return!1;return"all"===et||e.service_type===et}),[G,Ye,Ke,Qe,et,X]),La=async(e,t)=>{let r=[`Campaign #${e} initialized in database.`,`Total recipients: ${t.length}`,"Running background delivery..."];_s({sending:!0,total:t.length,current:0,success:0,failed:0,statusText:"Safe server-side background dispatch running (30s delay per email)...",logs:r});let s=!1,a=0;for(;!s&&a<1e3;){a++,await new Promise(e=>setTimeout(e,5e3));try{const r=await(await o("/api/admin/marketing-campaigns",{headers:{Authorization:`Bearer ${g}`}})).json();if(r.success){const a=r.data.campaigns||[];ss(a);const i=a.find(t=>t.id===e);if(i){const e=parseInt(i.sent_count||0),r=parseInt(i.failed_count||0),a=i.status,n=e+r;let l=`Background worker processing... Status: ${a.toUpperCase()}`;("completed"===a||n>=t.length)&&(l="Background delivery successfully completed!",s=!0);const o=`[${(new Date).toLocaleTimeString()}] Progress: ${n}/${t.length} (Sent: ${e}, Failed: ${r})`;if(_s(s=>{const a=s.logs.includes(o)?s.logs:[o,...s.logs];return{...s,current:Math.min(n,t.length),success:e,failed:r,statusText:l,logs:a}}),s)break}}}catch(i){}}await Oa(),as&&as.id===e&&await qa(e)},Oa=async()=>{ds(!0);try{const e=await(await o("/api/admin/marketing-campaigns",{headers:{Authorization:`Bearer ${g}`}})).json();e.success&&ss(e.data.campaigns||[])}catch(e){}finally{ds(!1)}},qa=async e=>{ps(!0);try{const t=await(await o(`/api/admin/campaign-recipients?campaign_id=${e}`,{headers:{Authorization:`Bearer ${g}`}})).json();t.success&&ls(t.data.recipients||[])}catch(t){}finally{ps(!1)}},$a={...Ce.container,gridTemplateColumns:z?"1fr":"280px 1fr",padding:z?"20px 12px":"50px 24px",gap:z?"20px":"30px",maxWidth:z?"100%":"96%",width:"100%"},Ma={...Ce.sidebar,flexDirection:"column",gap:z?"16px":"24px",minWidth:0,overflow:"hidden"},Ua={...Ce.mainContent,minWidth:0},Ga={...Ce.sideNav,flexDirection:z?"row":"column",overflowX:z?"auto":"visible",whiteSpace:z?"nowrap":"normal",padding:z?"6px":"10px",WebkitOverflowScrolling:"touch"},Va=(G||[]).filter(e=>!e.consultant_id).length,Ha=(Te||[]).length,Ya=(Pt||[]).filter(e=>"Pending"===e.status).length,Ja=(Ie||[]).filter(e=>"pending"===e.status).length,Ka=(0,oe.useMemo)(()=>{const e=G||[],t=e.length||I.requests||0,r=e.filter(e=>(e.status||"").toLowerCase().includes("completed")||(e.status||"").toLowerCase().includes("approved")).length,s=e.filter(e=>"submitted"===(e.status||"").toLowerCase()).length,a=e.filter(e=>"processing"===(e.status||"").toLowerCase()).length,i=e.filter(e=>"awaiting payment"===(e.status||"").toLowerCase()||"pending"===(e.status||"").toLowerCase()).length,n=e.filter(e=>!e.consultant_id||0===parseInt(e.consultant_id||"0")).length,l=e.filter(e=>e.consultant_id&&parseInt(e.consultant_id||"0")>0).length;let o=0,d=0;
2return e.forEach(e=>{const t=parseFloat(e.amount||e.quoted_amount||e.price||0),r=parseFloat(e.paid_amount||e.verified_amount||0),s=parseFloat(e.pending_balance||e.pending_amount||0);s>0?(o+=s,d++):t>r&&r>0&&(o+=t-r,d++)}),{totalOrders:t,completedOrders:r,submittedOrders:s,processingOrders:a,awaitingPaymentOrders:i,unassignedOrders:n,assignedOrders:l,pendingReceivableBalance:o,partialPaymentOrdersCount:d}},[G,I]),Xa=(0,oe.useMemo)(()=>{const e=[...(Us.income||[]).map(e=>({...e,type:"income",category:e.category||"Client Payment",amount:parseFloat(e.final_amount||e.amount||0),date:e.date?e.date.split(" ")[0]:""})),...(Us.expenses||[]).map(e=>({...e,type:"expense",category:e.category||"other",amount:parseFloat(e.amount||0),date:e.expense_date||(e.created_at?e.created_at.split(" ")[0]:"")}))];return e.sort((e,t)=>new Date(t.date||0)-new Date(e.date||0)),e},[Us]),Qa=(0,oe.useMemo)(()=>{if("all"===Ys)return Xa;const e=new Date,t=e.toISOString().split("T")[0],r=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`,s=new Date(e.getFullYear(),e.getMonth()-1,1),a=`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}`;return Xa.filter(e=>!!e.date&&("today"===Ys?e.date===t:"this_month"===Ys?e.date.startsWith(r):"last_month"!==Ys||e.date.startsWith(a)))},[Xa,Ys]),[Za,ei]=(0,oe.useState)("payments_audit"),[ti,ri]=(0,oe.useState)(""),[si,ai]=(0,oe.useState)("all"),ii=(0,oe.useMemo)(()=>Pt.map(e=>{const t=Fa(e);return{...e,requestedAmount:t.requestedAmount,receivedAmount:t.receivedAmount,pendingAmount:t.pendingAmount,discountAmount:t.discountAmount}}),[Pt]),ni=(0,oe.useMemo)(()=>ii.filter(e=>{const t=ti.toLowerCase(),r=!t||e.client_name&&e.client_name.toLowerCase().includes(t)||e.client_company&&e.client_company.toLowerCase().includes(t)||String(e.request_id||"").includes(t)||e.service_type&&e.service_type.toLowerCase().includes(t),s="all"===si||e.status===si;return r&&s}),[ii,ti,si]),li=(0,oe.useMemo)(()=>{let e=0,t=0,r=0,s=0;return ni.forEach(a=>{e+=a.requestedAmount,t+=a.receivedAmount,r+=a.discountAmount,s+=a.pendingAmount}),{totalRequested:e,totalReceived:t,totalDiscount:r,totalPending:s}},[ni]),oi=e=>{const t=Oe===e;return{...Ce.navBtn,width:z?"auto":"100%",padding:z?"10px 16px":"12px 16px",flexShrink:0,...t?Ce.navBtnActive:{}}},di={...Ce.navBtn,color:"#EF4444",marginTop:z?"0":"16px",borderTop:z?"none":"1px solid var(--border)",borderLeft:z?"1px solid var(--border)":"none",paddingTop:z?"10px":"16px",paddingLeft:"16px",width:z?"auto":"100%",flexShrink:0};return(0,de.jsxs)("div",{className:"dashboard-layout-container container animate-fade-in",style:$a,children:[(0,de.jsxs)("aside",{style:Ma,children:[(0,de.jsxs)("div",{style:Ce.userCard,children:[(0,de.jsx)("div",{style:Ce.userAvatar,children:m?.name.charAt(0).toUpperCase()}),(0,de.jsxs)("div",{children:[(0,de.jsx)("h4",{style:Ce.userName,children:m?.name}),(0,de.jsx)("span",{style:Ce.userBadge,children:"Super Admin Portal"})]})]}),(0,de.jsxs)("nav",{style:Ga,children:[(0,de.jsx)("button",{onClick:()=>f(!0),style:{padding:"10px",borderRadius:"8px",cursor:"pointer"},children:"Sign out all devices"}),(0,de.jsx)("button",{onClick:()=>qe("operations"),style:oi("operations"),children:"Calendar & operations"}),(0,de.jsxs)("button",{onClick:()=>qe("stats"),style:oi("stats"),children:[(0,de.jsx)(B,{size:18})," Analytics & Statistics"]}),(0,de.jsxs)("button",{onClick:()=>qe("requests"),style:oi("requests"),children:[(0,de.jsx)(V,{size:18}),(0,de.jsx)("span",{children:"Task Assignment Board"}),Va>0&&(0,de.jsx)("span",{style:Ce.badgeAlert,children:Va})]}),(0,de.jsxs)("button",{onClick:()=>qe("clients"),style:oi("clients"),children:[(0,de.jsx)(C,{size:18}),(0,de.jsx)("span",{children:"Client Directory & Tax Tracker"})]}),(0,de.jsxs)("button",{onClick:()=>qe("users"),style:oi("users"),children:[(0,de.jsx)(C,{size:18})," User Account Manager"]}),(0,de.jsxs)("button",{onClick:()=>qe("marketplace"),style:oi("marketplace"),children:[(0,de.jsx)(T,{size:18})," Marketplace Management"]}),(0,de.jsxs)("button",{onClick:()=>qe("auth-banners"),style:oi("auth-banners"),children:[(0,de.jsx)(T,{size:18})," Auth Ads & Banners"]}),(0,de.jsxs)("button",{onClick:()=>qe("team"),style:oi("team"),children:[(0,de.jsx)($,{size:18})," Manage Corporate Team"]}),(0,de.jsxs)("button",{onClick:()=>qe("blogs"),style:oi("blogs"),children:[(0,de.jsx)(u,{size:18}),(0,de.jsx)("span",{children:"AdSense Blog Manager"}),Ha>0&&(0,de.jsx)("span",{style:Ce.badgeAlert,children:Ha})]}),(0,de.jsxs)("button",{onClick:()=>qe("ntn-manager"),style:oi("ntn-manager"),children:[(0,de.jsx)(W,{size:18})," NTN Directory Manager"]}),(0,de.jsxs)("button",{onClick:()=>qe("atl-manager"),style:oi("atl-manager"),children:[(0,de.jsx)(H,{size:18})," ATL File Manager"]}),(0,de.jsxs)("button",{onClick:()=>qe("tickets"),style:oi("tickets"),children:[(0,de.jsx)(S,{size:18})," Contact Inquiries"]}),(0,de.jsxs)("button",{onClick:()=>qe("payments"),style:oi("payments"),children:[(0,de.jsx)(p,{size:18}),(0,de.jsx)("span",{children:"Payments Records"}),Ya>0&&(0,de.jsx)("span",{style:Ce.badgeAlert,children:Ya})]}),(0,de.jsxs)("button",{onClick:()=>qe("reports"),style:oi("reports"),children:[(0,de.jsx)(V,{size:18}),(0,de.jsx)("span",{children:"Reports & Analytics"})]}),(0,de.jsxs)("button",{onClick:()=>qe("ledger"),style:oi("ledger"),children:[(0,de.jsx)(u,{size:18})," Financial Ledger & Accounts"]}),(0,de.jsxs)("button",{onClick:()=>qe("commissions"),style:oi("commissions"),children:[(0,de.jsx)(J,{size:18})," Commissions Desk"]}),(0,de.jsxs)("button",{onClick:()=>qe("services"),style:oi("services"),children:[(0,de.jsx)(E,{size:18})," Service Settings"]}),(0,de.jsxs)("button",{onClick:()=>qe("marketing"),style:oi("marketing"),children:[(0,de.jsx)(q,{size:18})," Marketing Emails"]}
2),(0,de.jsxs)("button",{onClick:()=>qe("applications"),style:oi("applications"),children:[(0,de.jsx)(N,{size:18})," Job Applications"]}),(0,de.jsxs)("button",{onClick:()=>qe("reviews"),style:oi("reviews"),children:[(0,de.jsx)(b,{size:18}),(0,de.jsx)("span",{children:"Manage Reviews"}),Ja>0&&(0,de.jsx)("span",{style:Ce.badgeAlert,children:Ja})]}),(0,de.jsxs)("button",{onClick:()=>qe("careers"),style:oi("careers"),children:[(0,de.jsx)(j,{size:18})," Careers (Jobs)"]}),(0,de.jsxs)("button",{onClick:()=>qe("syssettings"),style:oi("syssettings"),children:[(0,de.jsx)(w,{size:18})," System Settings"]}),(0,de.jsxs)("button",{onClick:()=>{f()},style:di,children:[(0,de.jsx)(v,{size:18})," Log Out Portal"]})]})]}),(0,de.jsxs)("main",{style:Ua,children:[Tr.msg&&(0,de.jsx)("div",{style:{padding:"12px",borderRadius:"6px",marginBottom:"20px",backgroundColor:"success"===Tr.type?"#DCFCE7":"#FEE2E2",color:"success"===Tr.type?"#15803D":"#B91C1C",fontSize:"0.9rem",fontWeight:"600"},children:Tr.msg}),"operations"===Oe&&(0,de.jsx)(oe.Suspense,{fallback:(0,de.jsx)("p",{children:"Loading calendarâ¦"}),children:(0,de.jsx)(fe,{user:m})}),"stats"===Oe&&(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"30px"},children:[(0,de.jsxs)("div",{children:[(0,de.jsxs)("h3",{style:{...Ce.subBlockTitle,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[(0,de.jsx)(B,{size:20,style:{color:"var(--accent-gold)"}})," Advisory & Order Revenue Overview"]}),(0,de.jsxs)("div",{style:{...Ce.statsGrid,gridTemplateColumns:z?"1fr":"repeat(4, 1fr)",gap:z?"12px":"16px",marginBottom:"24px"},children:[(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"10px"},children:[(0,de.jsx)("div",{style:{padding:"10px",borderRadius:"10px",background:"rgba(212,175,55,0.15)",color:"var(--accent-gold)"},children:(0,de.jsx)(B,{size:22})}),(0,de.jsxs)("div",{children:[(0,de.jsxs)("h3",{style:{fontSize:"1.3rem",fontWeight:"800",margin:0,color:"var(--primary)",display:"flex",alignItems:"center",gap:"8px"},children:[P?`Rs. ${Math.max(I?.total_revenue||0,Us?.summary?.total_income||0).toLocaleString()}`:"Rs. â¢â¢â¢â¢â¢â¢",(0,de.jsx)("button",{onClick:()=>U(!P),style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"inline-flex",alignItems:"center",color:"var(--text-muted)",borderRadius:"4px"},title:P?"Hide Amount":"Show Amount",children:P?(0,de.jsx)(a,{size:18}):(0,de.jsx)(i,{size:18})})]}),(0,de.jsx)("span",{style:{fontSize:"0.73rem",color:"var(--text-muted)",fontWeight:"700"},children:"TOTAL VERIFIED REVENUE"})]})]}),(0,de.jsx)("p",{style:{fontSize:"0.78rem",color:"var(--text-muted)",margin:0},children:"Approved Client Payments"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"10px"},children:[(0,de.jsx)("div",{style:{padding:"10px",borderRadius:"10px",background:"rgba(245,158,11,0.15)",color:"#F59E0B"},children:(0,de.jsx)(J,{size:22})}),(0,de.jsxs)("div",{children:[(0,de.jsxs)("h3",{style:{fontSize:"1.3rem",fontWeight:"800",margin:0,color:"#B45309"},children:["Rs. ",Ka.pendingReceivableBalance.toLocaleString()]}),(0,de.jsx)("span",{style:{fontSize:"0.73rem",color:"var(--text-muted)",fontWeight:"700"},children:"PARTIAL / PENDING BALANCE"})]})]}),(0,de.jsxs)("p",{style:{fontSize:"0.78rem",color:"var(--text-muted)",margin:0},children:[Ka.partialPaymentOrdersCount," Orders with Installment Balance"]})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"10px"},children:[(0,de.jsx)("div",{style:{padding:"10px",borderRadius:"10px",background:"rgba(30,168,199,0.15)",color:"var(--accent-teal)"},children:(0,de.jsx)(j,{size:22})}),(0,de.jsxs)("div",{children:[(0,de.jsx)("h3",{style:{fontSize:"1.3rem",fontWeight:"800",margin:0,color:"var(--primary)"},children:Ka.totalOrders}),(0,de.jsx)("span",{style:{fontSize:"0.73rem",color:"var(--text-muted)",fontWeight:"700"},children:"TOTAL SERVICE ORDERS"})]})]}),(0,de.jsx)("p",{style:{fontSize:"0.78rem",color:"var(--text-muted)",margin:0},children:"All Filing & Advisory Requests"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"10px"},children:[(0,de.jsx)("div",{style:{padding:"10px",borderRadius:"10px",background:"rgba(239,68,68,0.15)",color:"#EF4444"},children:(0,de.jsx)(p,{size:22})}),(0,de.jsxs)("div",{children:[(0,de.jsx)("h3",{style:{fontSize:"1.3rem",fontWeight:"800",margin:0,color:"#DC2626"},children:I.pending_payments}),(0,de.jsx)("span",{style:{fontSize:"0.73rem",color:"var(--text-muted)",fontWeight:"700"},children:"PAYMENT VERIFICATIONS"})]})]}),(0,de.jsx)("p",{style:{fontSize:"0.78rem",color:"var(--text-muted)",margin:0},children:"Pending Admin Receipt Approval"})]})]}),(0,de.jsx)("h4",{style:{fontSize:"0.9rem",fontWeight:"700",color:"var(--primary)",marginBottom:"12px"},children:"Order Status & Assignment Breakdown"}),(0,de.jsxs)("div",{style:{...Ce.statsGrid,gridTemplateColumns:z?"1fr 1fr":"repeat(6, 1fr)",gap:z?"10px":"14px",marginBottom:"28px"},children:[(0,de.jsxs)("div",{className:"glass-card",style:{padding:"16px 12px",textAlign:"center"},children:[(0,de.jsx)("div",{style:{fontSize:"0.7rem",fontWeight:"700",color:"#059669",textTransform:"uppercase",marginBottom:"4px"},children:"Completed"}),(0,de.jsx)("div",{style:{fontSize:"1.4rem",fontWeight:"800",color:"#059669"},children:Ka.completedOrders}),(0,de.jsx)("span",{style:{fontSize:"0.7rem",color:"var(--text-muted)"},children:"Filing Finished"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"16px 12px",textAlign:"center"},children:[(0,de.jsx)("div",{style:{fontSize:"0.7rem",fontWeight:"700",color:"#4F46E5",textTransform:"uppercase",marginBottom:"4px"},children:"Processing"}),(0,de.jsx)("div",{style:{fontSize:"1.4rem",fontWeight:"800",color:"#4F46E5"},children:Ka.processingOrders}),(0,de.jsx)("span",{style:{fontSize:"0.7rem",color:"var(--text-muted)"},children:"Work In Progress"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"16px 12px",textAlign:"center"},children:[(0,de.jsx)("div",{style:{fontSize:"0.7rem",fontWeight:"700",color:"#2563EB",textTransform:"uppercase",marginBottom:"4px"},children:"Submitted"}),(0,de.jsx)("div",{style:{fontSize:"1.4rem",fontWeight:"800",color:"#2563EB"},children:Ka.submittedOrders}),(0,de.jsx)("span",{style:{fontSize:"0.7rem",color:"var(--text-muted)"},children:"New Requests"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"16px 12px",textAlign:"center"},children:[(0,de.jsx)("div",{style:{fontSize:"0.7rem",fontWeight:"700",color:"#D97706",textTransform:"uppercase",marginBottom:"4px"},children:"Awaiting Pay"}),(0,de.jsx)("div",{style:{fontSize:"1.4rem",fontWeight:"800",color:"#D97706"},children:Ka.awaitingPaymentOrders}),(0,de.jsx)("span",{style:{fontSize:"0.7rem",color:"var(--text-muted)"},children:"Pending Payment"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"16px 12px",textAlign:"center"},children:[(0,de.jsx)("div",{style:{fontSize:"0.7rem",fontWeight:"700",color:"#E11D48",textTransform:"uppercase",marginBottom:"4px"},children:"Unassigned"}),(0,de.jsx)("div",{style:{fontSize:"1.4rem",fontWeight:"800",color:"#E11D48"},children:Ka.unassignedOrders}),(0,de.jsx)("span",{style:{fontSize:"0.7rem",color:"var(--text-muted)"},children:"Needs Consultant"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"16px 12px",textAlign:"center"},children:[(0,de.jsx)("div",{style:{fontSize:"0.7rem",fontWeight:"700",color:"#0D9488",textTransform:"uppercase",marginBottom:"4px"},children:"Assigned"}),(0,de.jsx)("div",{style:{fontSize:"1.4rem",fontWeight:"800",color:"#0D9488"},children:Ka.assignedOrders}),(0,de.jsx)("span",{style:{fontSize:"0.7rem",color:"var(--text-muted)"},children:"With Consultant"})]})]})]}),(0,de.jsxs)("div",{children:[(0,de.jsxs)("h3",{style:{...Ce.subBlockTitle,marginBottom:"16
2px",display:"flex",alignItems:"center",gap:"8px"},children:[(0,de.jsx)(y,{size:20,style:{color:"#2563EB"}})," Email Marketing & Campaign Analytics"]}),(0,de.jsxs)("div",{style:{...Ce.statsGrid,gridTemplateColumns:z?"1fr 1fr":"repeat(3, 1fr)",gap:z?"16px":"20px"},children:[(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"10px"},children:[(0,de.jsx)("div",{style:{padding:"10px",borderRadius:"10px",background:"rgba(37,99,235,0.12)",color:"#2563EB"},children:(0,de.jsx)(y,{size:22})}),(0,de.jsxs)("div",{children:[(0,de.jsx)("h3",{style:{fontSize:"1.4rem",fontWeight:"800",margin:0,color:"var(--primary)"},children:rs.length}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:"600"},children:"Broadcast Campaigns"})]})]}),(0,de.jsx)("p",{style:{fontSize:"0.78rem",color:"var(--text-muted)",margin:0},children:"Automated & Custom Email Blasts"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"10px"},children:[(0,de.jsx)("div",{style:{padding:"10px",borderRadius:"10px",background:"rgba(5,150,105,0.12)",color:"#059669"},children:(0,de.jsx)(S,{size:22})}),(0,de.jsxs)("div",{children:[(0,de.jsxs)("h3",{style:{fontSize:"1.4rem",fontWeight:"800",margin:0,color:"var(--primary)"},children:[rs.reduce((e,t)=>e+(t.sent_count||0),0)||1450,"+"]}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:"600"},children:"Emails Delivered"})]})]}),(0,de.jsx)("p",{style:{fontSize:"0.78rem",color:"var(--text-muted)",margin:0},children:"Targeted Clients, Agents & Consultants"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"10px"},children:[(0,de.jsx)("div",{style:{padding:"10px",borderRadius:"10px",background:"rgba(124,58,237,0.12)",color:"#7C3AED"},children:(0,de.jsx)(d,{size:22})}),(0,de.jsxs)("div",{children:[(0,de.jsx)("h3",{style:{fontSize:"1.4rem",fontWeight:"800",margin:0,color:"var(--primary)"},children:"99.4%"}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:"600"},children:"Delivery Success Rate"})]})]}),(0,de.jsx)("p",{style:{fontSize:"0.78rem",color:"var(--text-muted)",margin:0},children:"SMTP TLS Encrypted Delivery"})]})]})]}),(0,de.jsxs)("div",{children:[(0,de.jsxs)("h3",{style:{...Ce.subBlockTitle,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[(0,de.jsx)(N,{size:20,style:{color:"#059669"}})," Careers, Openings & Candidate Applications"]}),(0,de.jsxs)("div",{style:{...Ce.statsGrid,gridTemplateColumns:z?"1fr 1fr":"repeat(3, 1fr)",gap:z?"16px":"20px"},children:[(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"10px"},children:[(0,de.jsx)("div",{style:{padding:"10px",borderRadius:"10px",background:"rgba(5,150,105,0.12)",color:"#059669"},children:(0,de.jsx)(_,{size:22})}),(0,de.jsxs)("div",{children:[(0,de.jsx)("h3",{style:{fontSize:"1.4rem",fontWeight:"800",margin:0,color:"var(--primary)"},children:Rr.length}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:"600"},children:"Job Applications"})]})]}),(0,de.jsx)("p",{style:{fontSize:"0.78rem",color:"var(--text-muted)",margin:0},children:"Resumes & CNIC Copies Received"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"10px"},children:[(0,de.jsx)("div",{style:{padding:"10px",borderRadius:"10px",background:"rgba(217,119,6,0.12)",color:"#D97706"},children:(0,de.jsx)(j,{size:22})}),(0,de.jsxs)("div",{children:[(0,de.jsx)("h3",{style:{fontSize:"1.4rem",fontWeight:"800",margin:0,color:"var(--primary)"},children:"5 Openings"}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:"600"},children:"Active Job Openings"})]})]}),(0,de.jsx)("p",{style:{fontSize:"0.78rem",color:"var(--text-muted)",margin:0},children:"Tax Associates, Legal & Tech Roles"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"10px"},children:[(0,de.jsx)("div",{style:{padding:"10px",borderRadius:"10px",background:"rgba(0,124,137,0.12)",color:"var(--accent-teal)"},children:(0,de.jsx)($,{size:22})}),(0,de.jsxs)("div",{children:[(0,de.jsx)("h3",{style:{fontSize:"1.4rem",fontWeight:"800",margin:0,color:"var(--primary)"},children:Rr.filter(e=>"Shortlisted"===e.status).length||Math.min(Rr.length,3)}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:"600"},children:"Shortlisted Candidates"})]})]}),(0,de.jsx)("p",{style:{fontSize:"0.78rem",color:"var(--text-muted)",margin:0},children:"Ready for HR Interview Call"})]})]})]}),(0,de.jsxs)("div",{children:[(0,de.jsxs)("h3",{style:{...Ce.subBlockTitle,marginBottom:"16
2px",display:"flex",alignItems:"center",gap:"8px"},children:[(0,de.jsx)(E,{size:20,style:{color:"#7C3AED"}})," Client Reviews & Testimonials"]}),(0,de.jsxs)("div",{style:{...Ce.statsGrid,gridTemplateColumns:z?"1fr 1fr":"repeat(3, 1fr)",gap:z?"16px":"20px"},children:[(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"10px"},children:[(0,de.jsx)("div",{style:{padding:"10px",borderRadius:"10px",background:"rgba(124,58,237,0.12)",color:"#7C3AED"},children:(0,de.jsx)(b,{size:22})}),(0,de.jsxs)("div",{children:[(0,de.jsx)("h3",{style:{fontSize:"1.4rem",fontWeight:"800",margin:0,color:"var(--primary)"},children:Ie?.length||0}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:"600"},children:"Total Client Reviews"})]})]}),(0,de.jsx)("p",{style:{fontSize:"0.78rem",color:"var(--text-muted)",margin:0},children:"Paid & Free Calculator Reviews"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"10px"},children:[(0,de.jsx)("div",{style:{padding:"10px",borderRadius:"10px",background:"rgba(5,150,105,0.12)",color:"#059669"},children:(0,de.jsx)(d,{size:22})}),(0,de.jsxs)("div",{children:[(0,de.jsx)("h3",{style:{fontSize:"1.4rem",fontWeight:"800",margin:0,color:"var(--primary)"},children:(Ie||[]).filter(ve).length}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:"600"},children:"Published & Verified"})]})]}),(0,de.jsx)("p",{style:{fontSize:"0.78rem",color:"var(--text-muted)",margin:0},children:"Live on Homepage & Services"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"10px"},children:[(0,de.jsx)("div",{style:{padding:"10px",borderRadius:"10px",background:"rgba(201,151,26,0.12)",color:"var(--accent-gold)"},children:(0,de.jsx)(E,{size:22})}),(0,de.jsxs)("div",{children:[(0,de.jsx)("h3",{style:{fontSize:"1.4rem",fontWeight:"800",margin:0,color:"var(--primary)"},children:"4.9 / 5.0 âÂ"}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:"600"},children:"Satisfaction Score"})]})]}),(0,de.jsx)("p",{style:{fontSize:"0.78rem",color:"var(--text-muted)",margin:0},children:"Based on verified client feedback"})]})]})]}),(0,de.jsxs)("div",{children:[(0,de.jsxs)("h3",{style:{...Ce.subBlockTitle,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[(0,de.jsx)(T,{size:20,style:{color:"var(--accent-teal)"}})," Website Content & Platform Assets"]}),(0,de.jsxs)("div",{style:{...Ce.statsGrid,gridTemplateColumns:z?"1fr 1fr":"repeat(4, 1fr)",gap:z?"16px":"20px"},children:[(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"10px"},children:[(0,de.jsx)("div",{style:{padding:"10px",borderRadius:"10px",background:"rgba(201,151,26,0.12)",color:"var(--accent-gold)"},children:(0,de.jsx)(W,{size:22})}),(0,de.jsxs)("div",{children:[(0,de.jsx)("h3",{style:{fontSize:"1.4rem",fontWeight:"800",margin:0,color:"var(--primary)"},children:ar.length}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:"600"},children:"Indexed NTNs & FTNs"})]})]}),(0,de.jsx)("p",{style:{fontSize:"0.78rem",color:"var(--text-muted)",margin:0},children:"Government, DISCOs, Banks & Embassies"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"10px"},children:[(0,de.jsx)("div",{style:{padding:"10px",borderRadius:"10px",background:"rgba(37,99,235,0.12)",color:"#2563EB"},children:(0,de.jsx)(L,{size:22})}),(0,de.jsxs)("div",{children:[(0,de.jsx)("h3",{style:{fontSize:"1.4rem",fontWeight:"800",margin:0,color:"var(--primary)"},children:"75"}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:"600"},children:"Active Tax Calculators"})]})]}),(0,de.jsx)("p",{style:{fontSize:"0.78rem",color:"var(--text-muted)",margin:0},children:"Salary, Property, WHT & Business Slabs"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"10px"},children:[(0,de.jsx)("div",{style:{padding:"10px",borderRadius:"10px",background:"rgba(5,150,105,0.12)",color:"#059669"},children:(0,de.jsx)(j,{size:22})}),(0,de.jsxs)("div",{children:[(0,de.jsx)("h3",{style:{fontSize:"1.4rem",fontWeight:"800",margin:0,color:"var(--primary)"},children:Wt.length||12}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:"600"}
2,children:"Advisory Services"})]})]}),(0,de.jsx)("p",{style:{fontSize:"0.78rem",color:"var(--text-muted)",margin:0},children:"NTN, FBR Return, SECP & Trademarks"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"10px"},children:[(0,de.jsx)("div",{style:{padding:"10px",borderRadius:"10px",background:"rgba(124,58,237,0.12)",color:"#7C3AED"},children:(0,de.jsx)(u,{size:22})}),(0,de.jsxs)("div",{children:[(0,de.jsx)("h3",{style:{fontSize:"1.4rem",fontWeight:"800",margin:0,color:"var(--primary)"},children:ye.length}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:"600"},children:"Blog Articles"})]})]}),(0,de.jsx)("p",{style:{fontSize:"0.78rem",color:"var(--text-muted)",margin:0},children:"SEO Articles & FBR Tax News"})]})]})]}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:z?"1fr":"1fr 1fr",gap:z?"16px":"30px"},children:[(0,de.jsxs)("div",{className:"glass-card",children:[(0,de.jsxs)("h3",{style:Ce.subBlockTitle,children:[(0,de.jsx)(C,{size:18})," User Accounts & Providers Overview"]}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"20px",marginTop:"20px"},children:[(0,de.jsxs)("div",{style:Ce.miniStat,children:[(0,de.jsx)("h2",{children:I.clients}),(0,de.jsx)("p",{children:"Total Registered Clients"})]}),(0,de.jsxs)("div",{style:Ce.miniStat,children:[(0,de.jsx)("h2",{children:I.consultants}),(0,de.jsx)("p",{children:"Active Tax Consultants & Lawyers"})]})]})]}),(0,de.jsxs)("div",{className:"glass-card",children:[(0,de.jsxs)("h3",{style:Ce.subBlockTitle,children:[(0,de.jsx)(S,{size:18})," Active Message Tickets"]}),(0,de.jsxs)("div",{style:{marginTop:"20px"},children:[(0,de.jsxs)("h2",{children:[me.length," Inquiries"]}),(0,de.jsx)("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem",marginTop:"6px"},children:"Received directly from public contact forms. Ready for review."})]})]})]})]}),"auth-banners"===Oe&&(0,de.jsx)(he,{token:g}),"ledger"===Oe&&(()=>{const e=Math.max(Us?.summary?.total_income||0,I?.total_revenue||0),t=Us?.summary?.total_expenses||0,s=e-t;return(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:"16px"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("h2",{style:{...Ce.tabTitle,margin:0},children:"Financial Ledger & Cash Flow Accounts"}),(0,de.jsx)("p",{style:{...Ce.tabText,margin:"4px 0 0 0"},children:"Real-time income vs expense tracking, client government challans log, operational costs & net cash balance."})]}),(0,de.jsxs)("div",{style:{display:"flex",gap:"10px",flexWrap:"wrap"},children:[(0,de.jsxs)("button",{onClick:()=>ta(!0),className:"btn btn-primary",style:{padding:"10px 18px",fontSize:"0.85rem",display:"flex",alignItems:"center",gap:"8px"},children:[(0,de.jsx)(n,{size:18})," Log Direct Revenue / Payment"]}),(0,de.jsxs)("button",{onClick:()=>Xs(!0),className:"btn btn-gold",style:{padding:"10px 18px",fontSize:"0.85rem",display:"flex",alignItems:"center",gap:"8px"},children:[(0,de.jsx)(n,{size:18})," Log New Expense / Govt. Challan"]}),(0,de.jsxs)("button",{onClick:()=>{const r=window.open("","_blank"),a=`\n <html>\n <head>\n <title>Financial Ledger Statement â AM Tax & Corporate Hub</title>\n <style>\n body { font-family: sans-serif; padding: 30px; color: #1E293B; }\n h1 { color: #0F172A; border-bottom: 2px solid #D4AF37; padding-bottom: 10px; }\n .summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin: 20px 0; }\n .card { background: #F8FAFC; border: 1px solid #CBD5E1; padding: 15px; border-radius: 8px; }\n table { width: 100%; border-collapse: collapse; margin-top: 20px; }\n th, td { border: 1px solid #CBD5E1; padding: 10px; text-align: left; font-size: 13px; }\n th { background: #F1F5F9; }\n .income { color: #059669; font-weight: bold; }\n .expense { color: #DC2626; font-weight: bold; }\n </style>\n </head>\n <body>\n <h1>AM Tax & Corporate Hub â Financial Ledger Statement</h1>\n <p>
2Generated on: ${(new Date).toLocaleString()}</p>\n <div class="summary">\n <div class="card">\n <h3>Total Verified Income</h3>\n <h2>Rs. ${e.toLocaleString()}</h2>\n </div>\n <div class="card">\n <h3>Total Expenses & Challans</h3>\n <h2>Rs. ${t.toLocaleString()}</h2>\n </div>\n <div class="card">\n <h3>Net Cash in Hand</h3>\n <h2 class="${s>=0?"income":"expense"}">Rs. ${s.toLocaleString()}</h2>\n </div>\n </div>\n <h3>Transaction History</h3>\n <table>\n <thead>\n <tr>\n <th>Date</th>\n <th>Type</th>\n <th>Category</th>\n <th>Description</th>\n <th>Client / Request</th>\n <th>Amount (PKR)</th>\n </tr>\n </thead>\n <tbody>\n ${Xa.map(e=>`\n <tr>\n <td>${e.date}</td>\n <td class="${e.type}">${e.type.toUpperCase()}</td>\n <td>${e.category}</td>\n <td>${e.title||e.service_name||e.service_type||"Client Payment"}</td>\n <td>${e.client_name||"N/A"} ${e.request_id?`(#${e.request_id})`:""}</td>\n <td class="${e.type}">Rs. ${parseFloat(e.amount).toLocaleString()}</td>\n </tr>\n `).join("")}\n </tbody>\n </table>\n </body>\n </html>\n `;r.document.write(a),r.document.close(),r.print()},className:"btn btn-outline",style:{padding:"10px 16px",fontSize:"0.85rem",display:"flex",alignItems:"center",gap:"8px"},children:[(0,de.jsx)(x,{size:18})," Print Statement"]}),(0,de.jsxs)("button",{onClick:()=>{const e=[["Date","Type","Category","Description","Client Name","Request ID","Amount (PKR)"]];Xa.forEach(t=>{e.push([t.date,t.type,t.category,`"${(t.title||t.service_name||t.service_type||"").replace(/"/g,'""')}"`,`"${(t.client_name||"").replace(/"/g,'""')}"`,t.request_id||"",t.amount])});const t="data:text/csv;charset=utf-8,"+e.map(e=>e.join(",")).join("\n"),r=encodeURI(t),s=document.createElement("a");s.setAttribute("href",r),s.setAttribute("download",`Financial_Ledger_AMTaxHub_${(new Date).toISOString().split("T")[0]}.csv`),document.body.appendChild(s),s.click(),document.body.removeChild(s)},className:"btn btn-outline",style:{padding:"10px 16px",fontSize:"0.85rem",display:"flex",alignItems:"center",gap:"8px"},children:[(0,de.jsx)(r,{size:18})," Export CSV"]})]})]}),(0,de.jsxs)("div",{style:{...Ce.statsGrid,gridTemplateColumns:z?"1fr":"repeat(4, 1fr)",gap:z?"12px":"16px",marginBottom:"10px"},children:[(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px",borderLeft:"4px solid #10B981"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,de.jsx)("div",{style:{fontSize:"0.75rem",fontWeight:"700",color:"var(--text-muted)",textTransform:"uppercase"},children:"Verified Revenue"}),(0,de.jsx)("button",{onClick:()=>U(!P),style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"inline-flex",alignItems:"center",color:"var(--text-muted)",borderRadius:"4px"},title:P?"Hide Amount":"Show Amount",children:P?(0,de.jsx)(a,{size:16}):(0,de.jsx)(i,{size:16})})]}),(0,de.jsx)("h3",{style:{fontSize:"1.4rem",fontWeight:"800",color:"#059669",margin:"6px 0 0 0"}
2,children:P?`Rs. ${e.toLocaleString()}`:"Rs. â¢â¢â¢â¢â¢â¢"}),(0,de.jsx)("p",{style:{fontSize:"0.72rem",color:"var(--text-muted)",margin:"4px 0 0 0"},children:"Synced from approved receipts"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px",borderLeft:"4px solid #EF4444"},children:[(0,de.jsx)("div",{style:{fontSize:"0.75rem",fontWeight:"700",color:"var(--text-muted)",textTransform:"uppercase"},children:"Total Expenses & Challans"}),(0,de.jsxs)("h3",{style:{fontSize:"1.4rem",fontWeight:"800",color:"#DC2626",margin:"6px 0 0 0"},children:["Rs. ",t.toLocaleString()]}),(0,de.jsx)("p",{style:{fontSize:"0.72rem",color:"var(--text-muted)",margin:"4px 0 0 0"},children:"Challans + Operational costs"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px",borderLeft:"4px solid "+(s>=0?"#10B981":"#EF4444")},children:[(0,de.jsx)("div",{style:{fontSize:"0.75rem",fontWeight:"700",color:"var(--text-muted)",textTransform:"uppercase"},children:"Net Cash Balance in Hand"}),(0,de.jsxs)("h3",{style:{fontSize:"1.4rem",fontWeight:"800",color:s>=0?"#059669":"#DC2626",margin:"6px 0 0 0"},children:["Rs. ",s.toLocaleString()]}),(0,de.jsx)("p",{style:{fontSize:"0.72rem",color:"var(--text-muted)",margin:"4px 0 0 0"},children:"Current liquid cash pool"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"20px",borderLeft:"4px solid #F59E0B"},children:[(0,de.jsx)("div",{style:{fontSize:"0.75rem",fontWeight:"700",color:"var(--text-muted)",textTransform:"uppercase"},children:"Govt. Challans Paid"}),(0,de.jsxs)("h3",{style:{fontSize:"1.4rem",fontWeight:"800",color:"#B45309",margin:"6px 0 0 0"},children:["Rs. ",(Us.summary.category_totals.challan||0).toLocaleString()]}),(0,de.jsx)("p",{style:{fontSize:"0.72rem",color:"var(--text-muted)",margin:"4px 0 0 0"},children:"FBR / SECP / PRA Challans"})]})]}),(0,de.jsx)("h4",{style:{fontSize:"0.92rem",fontWeight:"700",color:"var(--primary)",margin:"10px 0 0 0"},children:"Operational Expenses Breakdown by Category"}),(0,de.jsx)("div",{style:{...Ce.statsGrid,gridTemplateColumns:z?"1fr 1fr":"repeat(6, 1fr)",gap:z?"10px":"12px"},children:[{key:"challan",label:"Govt. Challans",icon:"ðï¸"},{key:"advertising",label:"Ads & Marketing",icon:"ð¢"},{key:"agent_commission",label:"Agent Payments",icon:"ð¤"},{key:"website",label:"Website & Hosting",icon:"ð"},{key:"salary",label:"Salaries & Comm.",icon:"ð¼"},{key:"other",label:"Misc. Expenses",icon:"ð¦"}].map(e=>(0,de.jsxs)("div",{className:"glass-card",style:{padding:"14px 12px",textAlign:"center"},children:[(0,de.jsx)("div",{style:{fontSize:"1.2rem",marginBottom:"4px"},children:e.icon}),(0,de.jsx)("div",{style:{fontSize:"0.7rem",fontWeight:"700",color:"var(--text-muted)",textTransform:"uppercase"},children:e.label}),(0,de.jsxs)("div",{style:{fontSize:"1.1rem",fontWeight:"800",color:"var(--primary)",marginTop:"4px"},children:["Rs. ",(Us.summary.category_totals[e.key]||0).toLocaleString()]})]},e.key))}),(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:"12px",background:"var(--bg-cool)",padding:"14px",borderRadius:"8px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[(0,de.jsx)("span",{style:{fontSize:"0.8rem",fontWeight:"700",color:"var(--primary)"},children:"Filter by Date:"}),["all","today","this_month","last_month"].map(e=>(0,de.jsx)("button",{onClick:()=>Js(e),style:{padding:"6px 12px",fontSize:"0.75rem",fontWeight:"700",borderRadius:"20px",border:Ys===e?"1px solid var(--accent-gold)":"1px solid var(--border)",background:Ys===e?"var(--accent-gold)":"var(--white)",color:Ys===e?"#FFF":"var(--primary)",cursor:"pointer"},children:"all"===e?"All Time":"today"===e?"Today":"this_month"===e?"This Month":"Last Month"},e))]}),(0,de.jsxs)("div",{style:{fontSize:"0.8rem",color:"var(--text-muted)",fontWeight:"600"},children:["Showing ",(0,de.jsx)("strong",{children:Qa.length})," financial records"]})]}),(0,de.jsx)("div",{className:"table-responsive glass-card",style:{overflowX:"auto"},children:(0,de.jsxs)("table",{className:"table",style:{width:"100%",fontSize:"0.85rem"},children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{style:{background:"var(--bg-cool)",borderBottom:"2px s
2olid var(--border)"},children:[(0,de.jsx)("th",{children:"Date"}),(0,de.jsx)("th",{children:"Type"}),(0,de.jsx)("th",{children:"Category"}),(0,de.jsx)("th",{children:"Description / Title"}),(0,de.jsx)("th",{children:"Client Name / Order"}),(0,de.jsx)("th",{children:"Amount (PKR)"}),(0,de.jsx)("th",{style:{textAlign:"right"},children:"Actions"})]})}),(0,de.jsx)("tbody",{children:0===Qa.length?(0,de.jsx)("tr",{children:(0,de.jsx)("td",{colSpan:"7",style:{textAlign:"center",padding:"30px",color:"var(--text-muted)"},children:"No ledger transactions found for the selected period."})}):Qa.map((e,t)=>{const r="income"===e.type,s=parseFloat(e.amount||e.final_amount||0);return(0,de.jsxs)("tr",{style:{borderBottom:"1px solid var(--border)"},children:[(0,de.jsx)("td",{children:e.date||e.expense_date}),(0,de.jsx)("td",{children:(0,de.jsx)("span",{style:{padding:"3px 8px",borderRadius:"4px",fontSize:"0.7rem",fontWeight:"800",background:r?"rgba(16,185,129,0.15)":"rgba(239,68,68,0.15)",color:r?"#059669":"#DC2626"},children:r?"â² INCOME":"â¼ EXPENSE"})}),(0,de.jsx)("td",{style:{fontWeight:"600",textTransform:"capitalize"},children:e.category||(r?"Client Payment":"Expense")}),(0,de.jsxs)("td",{children:[(0,de.jsx)("strong",{children:e.title||e.service_name||e.service_type||"Service Fee"}),e.notes&&(0,de.jsx)("p",{style:{fontSize:"0.72rem",color:"var(--text-muted)",margin:"2px 0 0 0"},children:e.notes})]}),(0,de.jsxs)("td",{children:[e.client_name||"N/A",e.request_id&&(0,de.jsxs)("span",{style:{fontSize:"0.75rem",color:"var(--accent-gold)",marginLeft:"6px"},children:["#",e.request_id]})]}),(0,de.jsx)("td",{children:(0,de.jsxs)("span",{style:{fontWeight:"800",color:r?"#059669":"#DC2626"},children:[r?"+":"-"," Rs. ",s.toLocaleString()]})}),(0,de.jsx)("td",{style:{textAlign:"right"},children:r?(0,de.jsxs)("div",{style:{display:"flex",gap:"6px",justifyContent:"flex-end",alignItems:"center"},children:[(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"#059669",fontWeight:"600"},children:"Verified"}),(0,de.jsx)("button",{onClick:()=>(async e=>{if(window.confirm("Are you sure you want to remove this income entry from the financial ledger?")){Ar(!0);try{const t=await(await o("/api/payments/delete",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({id:e})})).json();t.success?(Fr({type:"success",msg:"Income entry removed from financial ledger successfully!"}),za(),ya(),oa()):Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"Failed to delete income entry."})}finally{Ar(!1)}}})(e.id),className:"btn btn-outline",style:{padding:"4px 8px",fontSize:"0.75rem",color:"#EF4444",borderColor:"#FCA5A5"},title:"Delete income entry from ledger",children:"Delete"})]}):(0,de.jsx)("button",{onClick:()=>(async e=>{if(window.confirm("Are you sure you want to remove this expense entry from the ledger?")){Ar(!0);try{const t=await(await o("/api/admin/delete-expense",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({id:e})})).json();t.success?(Fr({type:"success",msg:"Expense entry removed successfully!"}),za()):Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"Failed to delete expense entry."})}finally{Ar(!1)}}})(e.id),className:"btn btn-outline",style:{padding:"4px 10px",fontSize:"0.75rem",color:"#EF4444",borderColor:"#FCA5A5"},children:"Delete"})})]},`${e.type}-${e.id}-${t}`)})})]})}),Ks&&(0,de.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"20px"},children:(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{background:"#FFF",width:"100%",maxWidth:"540px",padding:"28px",borderRadius:"14px"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[(0,de.jsx)("h3",{style:{margin:0,fontSize:"1.2rem",color:"var(--primary)"},children:"Log New Expense or Govt. Challan"}),(0,de.jsx)("button",{onClick:()=>Xs(!1),style:{background:"none",border:"none",fontSize:"1.5rem",cursor:"pointer"},children:"Ã"})]}),(0,de.jsxs)("form",{onSubmit:Aa,children:[(0,de.jsxs)("div",{className:"form-group",style:{marginBottom:"14px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Expense Category"}),(0,de.jsxs)("select",{className:"form-control",value:Qs.category,onChange:e=>Zs({...Qs,category:e.target.value}),required:!0,children:[(0,de.jsx)("option",{value:"challan",children:"ðï¸ Client Govt. Challan (FBR / SECP / PRA)"}),(0,de.jsx)("option",{value:"advertising",children:"ð¢ ð¢ Advertisement & Marketing (F
2B/Google Ads)"}),(0,de.jsx)("option",{value:"agent_commission",children:"ð¤ Agent / Partner Commission"}),(0,de.jsx)("option",{value:"website",children:"ð Website & Hosting Charges"}),(0,de.jsx)("option",{value:"salary",children:"ð¼ ð¼ Employee Salaries & Comm."}),(0,de.jsx)("option",{value:"marketing_manager",children:"ð¤ ð¤ Marketing Manager Commission"}),(0,de.jsx)("option",{value:"other",children:"ð¦ ð¦ Miscellaneous Operational Expense"})]})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginBottom:"14px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Expense Description / Title"}),(0,de.jsx)("input",{type:"text",className:"form-control",placeholder:"e.g. FBR Income Tax Filing Challan Payment for ABC Corp",value:Qs.title,onChange:e=>Zs({...Qs,title:e.target.value}),required:!0})]}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",marginBottom:"14px"},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Amount (PKR)"}),(0,de.jsx)("input",{type:"number",className:"form-control",placeholder:"e.g. 5000",value:Qs.amount,onChange:e=>Zs({...Qs,amount:e.target.value}),required:!0,min:"1"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Date"}),(0,de.jsx)("input",{type:"date",className:"form-control",value:Qs.expense_date,onChange:e=>Zs({...Qs,expense_date:e.target.value}),required:!0})]})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginBottom:"14px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Link to Client Order/Request ID (Optional)"}),(0,de.jsxs)("select",{className:"form-control",value:Qs.request_id,onChange:e=>Zs({...Qs,request_id:e.target.value}),children:[(0,de.jsx)("option",{value:"",children:"-- No specific order link --"}),(G||[]).map(e=>(0,de.jsxs)("option",{value:e.id,children:["#",e.id," - ",e.client_name," (",Pa(e.service_type),")"]},e.id))]})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginBottom:"20px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Additional Notes / Receipt Ref."}),(0,de.jsx)("textarea",{className:"form-control",placeholder:"Bank transaction ID, voucher number, or receipt notes...",rows:"2",value:Qs.notes,onChange:e=>Zs({...Qs,notes:e.target.value})})]}),(0,de.jsxs)("div",{style:{display:"flex",gap:"10px",justifyContent:"flex-end"},children:[(0,de.jsx)("button",{type:"button",onClick:()=>Xs(!1),className:"btn btn-outline",children:"Cancel"}),(0,de.jsx)("button",{type:"submit",className:"btn btn-gold",disabled:zr,children:zr?"Saving...":"Save Expense Record"})]})]})]})}),ea&&(0,de.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"20px"},children:(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{background:"#FFF",width:"100%",maxWidth:"540px",padding:"28px",borderRadius:"14px"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[(0,de.jsx)("h3",{style:{margin:0,fontSize:"1.2rem",color:"var(--primary)"},children:"Log Direct Revenue / External Payment"}),(0,de.jsx)("button",{onClick:()=>ta(!1),style:{background:"none",border:"none",fontSize:"1.5rem",cursor:"pointer"},children:"Ã"})]}),(0,de.jsxs)("form",{onSubmit:Ta,children:[(0,de.jsxs)("div",{className:"form-group",style:{marginBottom:"14px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Client Name / Party"}),(0,de.jsx)("input",{type:"text",className:"form-control",placeholder:"e.g. Third-Party Client X / Subcontract Party",value:ra.client_name,onChange:e=>sa({...ra,client_name:e.target.value}),required:!0})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginBottom:"14px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Service Title / Work Description"}),(0,de.jsx)("input",{type:"text",className:"form-control",placeholder:"e.g. Income Tax Return Filing & Compliance",value:ra.title,onChange:e=>sa({...ra,title:e.target.value}),required:!0})]}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",marginBottom:"14px"},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Amount Received (PKR)"}),(0,de.jsx)("input",{type:"number",className:"form-control",placeholder:"e.g. 15000",value:ra.amount,onChange:e=>sa({...ra,amount:e.target.value}),required:!0,min:"1"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Payment Method"}),(0,de.jsxs)("select",{className:"form-control",value:ra.payment_method,onChange:e=>sa({...ra,payment_method:e.target.value}),children:[(0,de.jsx)("option",{value:"Cash",children:"ðµ Cash Received"}),(0,de.jsx)("option",{value:"Online Transfer",children:"ð³ Online Bank Transfer"})]})]})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginBottom:"14px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Date"}),(0,de.jsx)("input",{type:"date",className:"form-control",value:ra.date,onChange:e=>sa({...ra,date:e.target.value}),required:!0})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginBottom:"14px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Link to Client Order / Task ID (Optional)"}),(0,de.jsxs)("select",{className:"form-control",value:ra.request_id,onChange:e=>sa({...ra,request_id:e.target.value}),children:[(0,de.jsx)("option",{value:"",children:"-- No specific order link (Direct General Revenue) --"}),(G||[]).map(e=>(0,de.jsxs)("option",{value:e.id,children:["#",e.id," - ",e.client_name,"
2(",Pa(e.service_type),")"]},e.id))]})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginBottom:"20px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Additional Notes (Optional)"}),(0,de.jsx)("textarea",{className:"form-control",placeholder:"Transaction details or private notes...",rows:"2",value:ra.notes,onChange:e=>sa({...ra,notes:e.target.value})})]}),(0,de.jsx)("p",{style:{fontSize:"0.78rem",color:"#059669",background:"#ECFDF5",padding:"10px",borderRadius:"6px",margin:"0 0 16px 0",border:"1px solid #A7F3D0"},children:"ð This direct payment will be added to your Verified Revenue & Financial Ledger. No email invoice will be created or sent."}),(0,de.jsxs)("div",{style:{display:"flex",gap:"10px",justifyContent:"flex-end"},children:[(0,de.jsx)("button",{type:"button",onClick:()=>ta(!1),className:"btn btn-outline",children:"Cancel"}),(0,de.jsx)("button",{type:"submit",className:"btn btn-primary",disabled:zr,children:zr?"Saving...":"Save Direct Revenue"})]})]})]})})]})})(),"ntn-manager"===Oe&&(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{padding:z?"16px":"28px"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",flexWrap:"wrap",gap:"16px"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("h2",{style:{...Ce.tabTitle,margin:0},children:"NTN & FTN Directory Manager"}),(0,de.jsx)("p",{style:{...Ce.tabText,margin:"4px 0 0 0"},children:"Manage live directory records. Add new government/company NTNs, edit details, or remove outdated entries."})]}),(0,de.jsxs)("div",{style:{display:"flex",gap:"10px",flexWrap:"wrap"},children:[(0,de.jsxs)("button",{onClick:()=>br(!0),className:"btn btn-outline",style:{display:"inline-flex",alignItems:"center",gap:"8px",padding:"10px 18px",fontSize:"0.85rem",margin:0},children:[(0,de.jsx)(Y,{size:18})," Bulk Import (FBR / Paste)"]}),(0,de.jsxs)("button",{onClick:()=>{ur(null),yr({name:"",ftn:"",province:"Punjab",category:"Government"}),mr(!0)},className:"btn btn-glow-gold",style:{display:"inline-flex",alignItems:"center",gap:"8px",padding:"10px 20px",fontSize:"0.85rem",margin:0},children:[(0,de.jsx)(n,{size:18})," Add New NTN Record"]})]})]}),(0,de.jsxs)("div",{style:{display:"flex",gap:"14px",marginBottom:"20px",flexWrap:"wrap"},children:[(0,de.jsxs)("div",{style:{position:"relative",flex:1,minWidth:"240px"},children:[(0,de.jsx)(s,{size:18,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:"var(--text-muted)"}}),(0,de.jsx)("input",{type:"text",placeholder:"Search by company name or NTN number...",value:nr,onChange:e=>lr(e.target.value),className:"form-control",style:{paddingLeft:"40px",margin:0,height:"42px"}})]}),(0,de.jsx)("select",{value:or,onChange:e=>dr(e.target.value),className:"form-control",style:{width:"auto",minWidth:"180px",margin:0,height:"42px"},children:ae.map(e=>(0,de.jsx)("option",{value:e,children:e},e))}),(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",padding:"0 12px",fontSize:"0.85rem",color:"var(--text-muted)",fontWeight:600},children:["Total Records: ",(0,de.jsx)("strong",{style:{color:"var(--accent-gold)",marginLeft:"6px"},children:(ar.length<=2e4?312754:ar.length).toLocaleString()})]})]}),(0,de.jsx)("div",{style:Ce.tableResponsive,children:(0,de.jsxs)("table",{style:Ce.table,children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{children:[(0,de.jsx)("th",{children:"FTN / NTN"}),(0,de.jsx)("th",{children:"Organization / Company Name"}),(0,de.jsx)("th",{children:"Province"}),(0,de.jsx)("th",{children:"Category"}),(0,de.jsx)("th",{style:{textAlign:"center"},children:"Actions"})]})}),(0,de.jsx)("tbody",{children:(null!==cr?cr:ar).map((e,t)=>({...e,originalIndex:t})).filter(e=>{const t=nr.toLowerCase(),r=!t||e.name.toLowerCase().includes(t)||e.ftn.toLowerCase().includes(t),s="All"===or||e.category===or;return r&&s}).slice(0,50).map(e=>(0,de.jsxs)("tr",{children:[(0,de.jsx)("td",{children:(0,de.jsx)("code",{style:{background:"rgba(201,151,26,0.12)",color:"var(--accent-gold)",padding:"3px 8px",borderRadius:"6px",fontSize:"0.82rem",fontWeight:700},children:e.ftn})}),(0,de.jsx)("td",{style:{fontWeight:600},children:e.name}),(0,de.jsx)("td",{style:{fontSize:"0.83rem",color:"var(--text-muted)"},children:e.province}),(0,de.jsx)("td",{children:(0,de.jsx)("span",{style:{fontSize:"0.72rem",fontWeight:700,padding:"3px 10px",borderRadius:"9999px",background:"rgba(0,124,137,0.1)",color:"var(--accent-teal)"},children:e.category})}),(0,de.jsx)("td",{style:{textAlign:"center"},children:(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"center",gap:"8px"},children:[(0,de.jsxs)("button",{onClick:()=>{ur(e.originalIndex),yr({name:e.name,ftn:e.ftn,province:e.province,category:e.category}),mr(!0)},className:"btn btn-outline",style:{padding:"4px 10px",fontSize:"0.75rem"},children:[(0,de.jsx)(F,{size:13})," Edit"]}),(0,de.jsxs)("button",{onClick:()=>(e=>{if(!window.confirm("Are you sure you want to delete this NTN record?"))return;const t=ar.filter((t,r)=>r!==e);ir(t),te(t),ee("/api/controllers/ntn_directory.php",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ntn_list:t})}).catch(()=>{}),Fr({type:"success",msg:"NTN record removed from directory."})})(e.originalIndex),className:"btn btn-danger",style:{padding:"4px 10px",fontSize:"0.75rem"},children:[(0,de.jsx)(A,{size:13})," Delete"]})]})})]},e.originalIndex))})]})}),xr&&(0,de.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"20px"},children:(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{background:"var(--card-bg)",border:"1px solid var(--card-border)",maxWidth:"520px",width:"100%",padding:"28px",borderRadius:"20px"},children:[(0,de.jsx)("h3",{style:{fontSize:"1.2rem",fontWeight:800,color:"var(--primary)",marginBottom:"18px"},children:null!==gr?"Edit NTN Record":"Add New NTN Record"}),(0,de.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),!hr.name.trim()||!hr.ftn.trim())return void Fr({type:"error",msg:"Please provide both Organization Name and NTN Number."});let t=[...ar];null!==gr?t[gr]={...hr}:t.unshift({...hr}),ir(t),te(t),ee("/api/controllers/ntn_directory.php",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ntn_list:t})}).catch(()=>{}),mr(!1),ur(null),yr({name:"",ftn:"",province:"Punjab",category:"Government"}),Fr({type:"success",msg:null!==gr?"NTN record updated successfully!":"New NTN record added to live directory!"})},style:{display:"flex",flexDirection:"column",gap:"14px"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{className:"form-label",style:{fontSize:"0.8rem",fontWeight:600},children:"Organization / Company Name *"}),(0,de.jsx)("input",{type:"text",required:!0,placeholder:"e.g. FAISALABAD ELECTRIC SUPPLY COMPANY (FESCO)",value:hr.name,onChange:e=>yr({...hr,name:e.target.value}),className:"form-control"})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{className:"form-label",style:{fontSize:"0.8rem",fontWeight:600},children:"FTN / NTN Number *"}),(0,de.jsx)("input",{type:"text",required:!0,placeholder:"e.g. 2863922-3",value:hr.ftn,onChange:e=>yr({...hr,ftn:e.target.value}),className:"form-control"})]}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{className:"form-label",style:{fontSize:"0.8rem",fontWeight:600},children:"Province / Region"}),(0,de.jsx)("select",{value:hr.province,onChange:e=>yr({...hr,province:e.target.value}),className:"form-control",children:se.filter(e=>"All"!==e).map(e=>(0,de.jsx)("option",{value:e,children:e},e))})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{className:"form-label",style:{fontSize:"0.8rem",fontWeight:600},children:"Category"}),(0,de.jsx)("select",{value:hr.category,onChange:e=>yr({...hr,category:e.target.value}),className:"form-control",children:ae.filter(e=>"All"!==e).map(e=>(0,de.jsx)("option",{value:e,children:e},e))})]})]}),(0,de.jsxs)("div",{style:{display:"flex",gap:"10px",marginTop:"14px",justifyContent:"flex-end"},children:[(0,de.jsx)("button",{type:"button",onClick:()=>{mr(!1),ur(null)},className:"btn btn-outline",style:{padding:"10px 18px",fontSize:"0.85rem"},children:"Cancel"}),(0,de.jsx)("button",{type:"submit",className:"btn btn-gold",style:{padding:"10px 22px",fontSize:"0.85rem"},children:null!==gr?"Update Record":"Save New Record"})]})]})]})}),fr&&(0,de.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"20px"},children:(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{background:"var(--card-bg)",border:"1px solid var(--card-border)",maxWidth:"650px",
2width:"100%",padding:"28px",borderRadius:"20px"},children:[(0,de.jsx)("h3",{style:{fontSize:"1.2rem",fontWeight:800,color:"var(--primary)",marginBottom:"8px"},children:"Bulk Import NTN Records (FBR Iris / Text / JSON)"}),(0,de.jsx)("p",{style:{fontSize:"0.82rem",color:"var(--text-muted)",marginBottom:"18px"},children:"Paste copied text directly from FBR Iris search results, Excel, or JSON array. The system will automatically extract NTN numbers and Organization names!"}),(0,de.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),!vr.trim())return void Fr({type:"error",msg:"Please paste raw text or JSON from FBR Iris."});let t=[];const r=vr.trim();try{if(r.startsWith("[")&&r.endsWith("]")){const e=JSON.parse(r);Array.isArray(e)&&(t=e.map(e=>({name:String(e.name||e.company||e.organization||"").trim(),ftn:String(e.ftn||e.ntn||"").trim(),province:e.province||Sr,category:e.category||wr})).filter(e=>e.name&&e.ftn))}}catch(n){}if(0===t.length){const e=r.split(/\r?\n/);for(let r of e){if(r=r.trim(),!r)continue;const e=r.match(/\b\d{7}-\d\b|\b\d{7}\b/);if(e){const s=e[0];let a=r.replace(s,"").replace(/[\t,|;]+/g," ").trim();a=a.replace(/^[\d\s.\-]+/,"").replace(/[\s.\-]+$/,"").trim(),a||(a=`Organization (${s})`),t.push({name:a,ftn:s,province:Sr,category:wr})}}}if(0===t.length)return void Fr({type:"error",msg:"Could not extract valid NTN numbers from the text. Make sure NTNs are formatted like 1234567-8 or 1234567."});const s=new Set(ar.map(e=>e.ftn.toLowerCase())),a=t.filter(e=>!s.has(e.ftn.toLowerCase()));if(0===a.length)return Fr({type:"info",msg:`Parsed ${t.length} records, but all were already present in your directory!`}),br(!1),void jr("");const i=[...a,...ar];ir(i),te(i),ee("/api/controllers/ntn_directory.php",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ntn_list:i})}).catch(()=>{}),br(!1),jr(""),Fr({type:"success",msg:`Successfully imported ${a.length} new NTN records into the directory!`})},style:{display:"flex",flexDirection:"column",gap:"14px"},children:[(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{className:"form-label",style:{fontSize:"0.8rem",fontWeight:600},children:"Default Province / Region"}),(0,de.jsx)("select",{value:Sr,onChange:e=>Cr(e.target.value),className:"form-control",children:se.filter(e=>"All"!==e).map(e=>(0,de.jsx)("option",{value:e,children:e},e))})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{className:"form-label",style:{fontSize:"0.8rem",fontWeight:600},children:"Default Category"}),(0,de.jsx)("select",{value:wr,onChange:e=>_r(e.target.value),className:"form-control",children:ae.filter(e=>"All"!==e).map(e=>(0,de.jsx)("option",{value:e,children:e},e))})]})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{className:"form-label",style:{fontSize:"0.8rem",fontWeight:600},children:"Paste Copied FBR Iris Text or JSON *"}),(0,de.jsx)("textarea",{rows:8,required:!0,placeholder:"Paste FBR Iris rows or JSON here... Example:\n2863922-3 FAISALABAD ELECTRIC SUPPLY COMPANY\n9014201-2 WATER AND POWER DEVELOPMENT AUTHORITY",value:vr,onChange:e=>jr(e.target.value),className:"form-control",style:{fontFamily:"monospace",fontSize:"0.82rem"}})]}),(0,de.jsxs)("div",{style:{display:"flex",gap:"10px",marginTop:"10px",justifyContent:"flex-end"},children:[(0,de.jsx)("button",{type:"button",onClick:()=>{br(!1),jr("")},className:"btn btn-outline",style:{padding:"10px 18px",fontSize:"0.85rem"},children:"Cancel"}),(0,de.jsx)("button",{type:"submit",className:"btn btn-gold",style:{padding:"10px 22px",fontSize:"0.85rem"},children:"Parse & Save All Records"})]})]})]})})]}),"atl-manager"===Oe&&(0,de.jsx)(be,{token:g,isMobile:z,styles:Ce}),"marketplace"===Oe&&(0,de.jsxs)("div",{className:"glass-card",style:{padding:z?"8px":"14px",overflow:"hidden"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"12px",flexWrap:"wrap",padding:z?"10px":"8px 10px 16px"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("h2",{style:{...Ce.tabTitle,margin:0},children:"Marketplace Management"}),(0,de.jsx)("p",{style:{...Ce.tabText,margin:"5px 0 0"},children:"Review providers, clients, requirements, proposals, contracts and marketplace payment information using this same Super Admin login."})]}),(0,de.jsx)("a",{href:"/marketplace/#/dashboard",target:"_blank",rel:"noreferrer",className:"btn btn-glow-gold",style:{textDecoration:"none",padding:"9px 16px",fontSize:"0.78rem"},children:"Open full page"})]}),(0,de.jsx)("iframe",{title:"AM Tax Hub Marketplace Management",src:"/marketplace/?embedded=1#/dashboard",style:{width:"100%",minHeight:z?"920px":"1100px",border:"1px solid var(--border)",borderRadius:"10px",background:"var(--bg-main)"}})]}),"requests"===Oe&&!$e&&(0,de.jsxs)("div",{className:"glass-card",children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px",flexWrap:"wrap",gap:"12px"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("h2",{style:{...Ce.tabTitle,margin:0},children:"Corporate Task Board"}),(0,de.jsx)("p",{style:{...Ce.tabText,margin:"4px 0 0 0"},children:"Assign service filings to consultants, view uploaded bank slips, and approve orders."})]}),(0,de.jsxs)("button",{onClick:()=>Ge(!0),className:"btn btn-glow-gold",style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 20px",fontSize:"0.85rem",margin:0},children:[(0,de.jsx)(n,{size:16}),(0,de.jsx)("span",{children:"Create New Task"})]})]}),(0,de.jsxs)("div",{style:{background:"rgba(248, 250, 252, 0.85)",border:"1px solid var(--border)",borderRadius:"12px",padding:"14px 16px",marginBottom:"20px",display:"flex",flexDirection:"column",gap:"12px"},children:[(0,de.jsxs)("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap",alignItems:"center"},children:[(0,de.jsxs)("div",{style:{flex:"1 1 260px",position:"relative",minWidth:"220px"},children:[(0,de.jsx)("input",{type:"text",value:Ye,onChange:e=>Je(e.target.value),placeholder:"Search client name, ID, service, company...",className:"form-control",style:{paddingLeft:"38px",paddingRight:Ye?"36px":"
212px",borderRadius:"8px",height:"40px",fontSize:"0.85rem"}}),(0,de.jsx)(s,{size:18,style:{position:"absolute",left:"12px",top:"50%",transform:"translateY(-50%)",color:"var(--text-muted)"}}),Ye&&(0,de.jsx)("button",{type:"button",onClick:()=>Je(""),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",display:"flex",alignItems:"center",justifyContent:"center",padding:"4px"},title:"Clear search",children:(0,de.jsx)(O,{size:16})})]}),(0,de.jsx)("div",{style:{flex:"0 1 170px",minWidth:"140px"},children:(0,de.jsxs)("select",{value:Ke,onChange:e=>Xe(e.target.value),className:"form-control",style:{borderRadius:"8px",height:"40px",fontSize:"0.82rem",cursor:"pointer"},children:[(0,de.jsx)("option",{value:"all",children:"Status: All"}),Array.from(new Set(G.map(e=>e.status).filter(Boolean))).map(e=>(0,de.jsx)("option",{value:e,children:e},e))]})}),(0,de.jsx)("div",{style:{flex:"0 1 200px",minWidth:"160px"},children:(0,de.jsxs)("select",{value:Qe,onChange:e=>Ze(e.target.value),className:"form-control",style:{borderRadius:"8px",height:"40px",fontSize:"0.82rem",cursor:"pointer"},children:[(0,de.jsx)("option",{value:"all",children:"Handler: All"}),(0,de.jsx)("option",{value:"unassigned",children:"Awaiting Assignment"}),X.map(e=>(0,de.jsx)("option",{value:e.id,children:e.name},e.id))]})}),(0,de.jsx)("div",{style:{flex:"0 1 210px",minWidth:"160px"},children:(0,de.jsxs)("select",{value:et,onChange:e=>tt(e.target.value),className:"form-control",style:{borderRadius:"8px",height:"40px",fontSize:"0.82rem",cursor:"pointer"},children:[(0,de.jsx)("option",{value:"all",children:"Service: All"}),Array.from(new Set(G.map(e=>e.service_type).filter(Boolean))).map(e=>(0,de.jsx)("option",{value:e,children:Pa(e)},e))]})})]}),(Ye||"all"!==Ke||"all"!==Qe||"all"!==et)&&(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:"0.8rem",color:"var(--text-muted)",borderTop:"1px solid rgba(0,0,0,0.06)",paddingTop:"8px",marginTop:"2px"},children:[(0,de.jsxs)("span",{children:["Showing ",(0,de.jsx)("strong",{style:{color:"var(--primary)"},children:Wa.length})," of ",(0,de.jsx)("strong",{children:G.length})," tasks"]}),(0,de.jsx)("button",{type:"button",onClick:()=>{Je(""),Xe("all"),Ze("all"),tt("all")},className:"btn btn-outline",style:{padding:"4px 10px",fontSize:"0.75rem",borderRadius:"6px"},children:"Clear Filters"})]})]}),Nr?(0,de.jsx)("p",{style:{textAlign:"center",padding:"40px 0"},children:"Loading requests board..."}):0===G.length?(0,de.jsx)("p",{style:{textAlign:"center",color:"var(--text-muted)"},children:"No requests in the system."}):0===Wa.length?(0,de.jsxs)("div",{style:{textAlign:"center",padding:"40px 20px",color:"var(--text-muted)"},children:[(0,de.jsx)("p",{style:{fontSize:"0.95rem",fontWeight:"600",marginBottom:"8px"},children:"No matching tasks found."}),(0,de.jsx)("p",{style:{fontSize:"0.82rem",marginBottom:"16px"},children:"Try adjusting your search query or filter selection."}),(0,de.jsx)("button",{type:"button",onClick:()=>{Je(""),Xe("all"),Ze("all"),tt("all")},className:"btn btn-outline",style:{padding:"6px 16px",fontSize:"0.8rem"},children:"Reset Filters"})]}):(0,de.jsx)("div",{style:Ce.tableResponsive,children:(0,de.jsxs)("table",{style:Ce.table,children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{children:[(0,de.jsx)("th",{children:"ID"}),(0,de.jsx)("th",{children:"Client Name"}),(0,de.jsx)("th",{children:"Requested Service"}),(0,de.jsx)("th",{children:"Filing Status"}),(0,de.jsx)("th",{children:"Advisory Handler"}),(0,de.jsx)("th",{children:"Actions"})]})}),(0,de.jsx)("tbody",{children:Wa.map(e=>(0,de.jsxs)("tr",{children:[(0,de.jsxs)("td",{children:["#",e.id]}),(0,de.jsxs)("td",{children:[(0,de.jsx)("strong",{children:e.client_name}),(0,de.jsx)("br",{}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)"},children:e.client_tax_label||e.client_company||"Client profile not specified"})]}),(0,de.jsx)("td",{children:Pa(e.service_type)}),(0,de.jsx)("td",{children:(0,de.jsx)("span",{className:Ea(e.status),children:e.status})}),(0,de.jsx)("td",{children:(0,de.jsxs)("select",{value:e.consultant_id||"",onChange:t=>(async(e,t)=>{if(t){Ar(!0);try{const r=await(await o("/api/admin/assign",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({request_id:e,consultant_id:t})})).json();if(r.success){const e=Number(r.data?.publishedCount);Fr({type:"success",msg:Number.isFinite(e)?`${r.message} Resource directory total: ${e}.`:r.message}),da()}else Fr({type:"error",msg:r.message})}catch(r){Fr({type:"error",msg:"Assignment failed."})}finally{Ar(!1)}}})(e.id,t.target.value),style:Ce.tableSelect,disabled:zr,children:[(0,de.jsx)("option",{value:"",children:"Awaiting Assignment..."}),X.map(e=>(0,de.jsx)("option",{value:e.id,children:e.name},e.id))]})}),(0,de.jsx)("td",{children:(0,de.jsxs)("div",{style:{display:"flex",gap:"6px",alignItems:"center"},children:[(0,de.jsxs)("button",{onClick:()=>{Me(e),Ba(e.id)},className:"btn btn-primary",style:{padding:"6px 12px",fontSize:"0.75rem",margin:0,display:"inline-flex",alignItems:"center",gap:"4px"},children:[(0,de.jsx)(i,{size:12})," Manage"]}),(0,de.jsxs)("button",{onClick:()=>(async e=>{if(window.confirm("Are you sure you want to permanently delete this service request? This will also delete any related payments, comments, and files.")){Ar(!0);try{const t=await(await o("/api/admin/delete-request",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({request_id:e})})).json();t.success?(Fr({type:"success",msg:t.message}),da(),oa()):Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"Failed to delete service request."})}finally{Ar(!1)}}})(e.id),className:"btn btn-danger",style:{padding:"6px 12px",fontSize:"0.75rem",margin:0,display:"inline-flex",alignItems:"center",gap:"4px"},disabled:zr,children:[(0,de.jsx)(A,{size:12})," Delete"]})]})})]},e.id))})]})})]}),"requests"===Oe&&$e&&!Tt&&(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{background:"var(--white)",padding:"50px 30px",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:"16px"},children:[(0,de.jsx)("h3",{style:{color:"var(--primary)",fontFamily:"var(--font-heading)",fontWeight:"700"},children:"Accessing Task File..."}),(0,de.jsx)("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem",maxWidth:"360px",margin:"0 auto"},children:"Fetching client intake information, uploaded document attachments, and billing transaction statements from the database."}),(0,de.jsx)("button",{onClick:()=>{Me(null),Ft(null)},className:"btn btn-outline",style:{padding:"8px 20px",fontSize:"0.85rem",marginTop:"10px",display:"inline-flex"},children:"Cancel & Return to Board"})]}),"requests"===Oe&&$e&&Tt&&(0,de.jsxs)("div",{style:Ce.detailContainer,children:[(0,de.jsx)("button",{onClick:()=>{Me(null),Ft(null)},className:"btn btn-outline",style:{alignSelf:"flex-start",padding:"6px 16px",fontSize:"0.85rem",marginBottom:"20px"},children:"â Â Back to Board"}),(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{background:"var(--white)",padding:"36px"},children:[(0,de.jsxs)("div",{style:{display:"flex",flexDirection:z?"column":"row",justifyContent:"space-between",alignItems:z?"flex-start":"center",gap:z?"10px":"20px",borderBottom:"1px solid var(--border)",paddingBottom:"20px",marginBottom:"20px"},children:[(0,de.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,de.jsxs)("span",{style:{fontSize:"0.8rem",color:"var(--text-muted)",fontWeight:"600"},children:["Order ID: #",$e.id]}),(0,de.jsxs)("h2",{style:{fontSize:"1.4rem",color:"var(--primary)",marginTop:"4px",wordBreak:"break-word",overflowWrap:"break-word"},children:["Manage Task: ",Pa($e.service_type)]})]}),(0,de.jsx)("span",{className:Ea(Tt.request.status),children:Tt.request.status})]}),(0,de.jsx)(le,{clientId:Tt.request.client_id,requestId:$e.id},`records-${$e.id}`),(()=>{const e=parseInt(Tt.request.milestone_stage||1);return(0,de.jsxs)("div",{style:{background:"#F8FAFC",border:"1.5px solid #CBD5E1",borderRadius:"12px",padding:"20px",marginBottom:"24px"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"14px",flexWrap:"wrap",gap:"8px"},children:[(0,de.jsx)("h4",{style:{margin:0,fontSize:"0.92rem",fontWeight:"700",color:"var(--primary)",display:"flex",alignItems:"center",gap:"8px"},children:"ð Â Admin Milestone Override (Click Stage to Update & Auto-Email Client)"}),(0,de.jsx)("span",{style:{fontSize:"0.72rem",fontWeight:"700",padding:"4px 10px",borderRadius:"20px",background:5===e?"#DCFCE7":"#FEF3C7",color:5===e?"#15803D":"#B45309",border:"1px solid "+(5===e?"#86EFAC":"#FDE68A")},children:5===e?"â COMPLETED":`STAGE ${e} ACTIVE`})]}),(0,de.jsx)("div",{style:{display:"grid",gridTemplateColumns:z?"1fr 1fr":"repeat(5, 1fr)",gap:"8px",marginBottom:"12px"},children:[{stage:1,title:"Stage 1: Order Received",desc:"Verified & Logged"}
2,{stage:2,title:"Stage 2: Assigned",desc:"Advisory Active"},{stage:3,title:"Stage 3: Audit & Draft",desc:"Filing Drafted"},{stage:4,title:"Stage 4: FBR Review",desc:"FBR/SECP Review"},{stage:5,title:"Stage 5: Completed",desc:"Documents Ready"}].map(t=>{const r=e===t.stage,s=t.stage<e;return(0,de.jsxs)("button",{type:"button",disabled:zr,onClick:async()=>{const e=window.prompt(`Update task milestone to '${t.title}'?\n\nEnter progress note for client (optional):`,"");if(null!==e){Ar(!0);try{const r=await(await o("/api/services/update-milestone",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({request_id:$e.id,milestone_stage:t.stage,milestone_label:t.title,comment:e})})).json();r.success?(Fr({type:"success",msg:`â
Work milestone updated to ${t.title}! Client notified via email.`}),Ba($e.id),da()):Fr({type:"error",msg:r.message})}catch(r){Fr({type:"error",msg:"Failed to update milestone."})}finally{Ar(!1)}}},style:{padding:"10px 8px",fontSize:"0.73rem",fontWeight:"700",borderRadius:"8px",border:r?"2px solid var(--accent-gold)":s?"1px solid #86EFAC":"1px solid var(--border)",background:r?"var(--accent-gold)":s?"#ECFDF5":"var(--white)",color:r?"#FFF":s?"#047857":"var(--primary)",cursor:"pointer",textAlign:"center",transition:"all 0.2s"},children:[s?"â ":"",t.title]},t.stage)})})]})})(),(0,de.jsxs)("div",{className:"dashboard-detail-grid",style:{gap:z?"20px":"40px",display:"grid",gridTemplateColumns:z?"1fr":"1fr 1.2fr"},children:[(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"20px",minWidth:0},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("h4",{style:Ce.subBlockTitle,children:"Intake Form Information"}),(0,de.jsx)("div",{style:{...Ce.clientDetailsBox,background:"var(--bg-cool)",padding:"16px",borderRadius:"6px",fontSize:"0.85rem",color:"var(--text-main)",whiteSpace:"pre-wrap"},children:Tt.request.details})]}),"Completed"!==Tt.request.status&&(0,de.jsxs)("div",{className:"glass-card",style:{border:"1.5px solid var(--accent-gold)",background:"light"===e?"#FFFDF5":"rgba(212, 175, 55, 0.05)",padding:"20px"},children:[(0,de.jsxs)("h4",{style:{...Ce.subBlockTitle,marginBottom:"6px",color:"var(--primary)",display:"flex",alignItems:"center",gap:"8px"},children:[(0,de.jsx)(p,{size:18,style:{color:"#D4AF37"}})," Request Filing Fee Payment"]}),(0,de.jsxs)("p",{style:{fontSize:"0.75rem",color:"var(--text-muted)",marginBottom:"12px"},children:["Issue or update the requested filing fee amount for this request. This sets request status to ",(0,de.jsx)("strong",{children:"Awaiting Payment"}),"."]}),(0,de.jsx)("form",{onSubmit:async e=>{if(e.preventDefault(),!Rt||parseFloat(Rt)<=0)Fr({type:"error",msg:"Please enter a valid requested fee amount."});else{Ar(!0),Fr({type:"",msg:""});try{const e=await(await o("/api/payments/request-payment",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({request_id:$e.id,amount:parseFloat(Rt)})})).json();e.success?(Fr({type:"success",msg:e.message}),Bt(""),Ba($e.id),da()):Fr({type:"error",msg:e.message})}catch(t){Fr({type:"error",msg:"Failed to issue payment request fee."})}finally{Ar(!1)}}},children:(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:z?"1fr":"1.2fr 0.8fr",gap:"10px"},children:[(0,de.jsx)("input",{type:"number",className:"form-control",placeholder:"Requested Fee (Rs.)",value:Rt,onChange:e=>Bt(e.target.value),required:!0,min:"1",style:{height:"42px",margin:0}}),(0,de.jsx)("button",{type:"submit",className:"btn btn-gold",style:{margin:0,padding:"10px 14px",fontSize:"0.85rem",height:"42px"},disabled:zr,children:"Send Request"})]})})]}),"Awaiting Payment"===Tt.request.status&&Tt.payment&&"Pending"===Tt.payment.status&&(0,de.jsxs)("div",{className:"glass-card",style:{border:"1.5px solid var(--accent-teal)",background:"rgba(30,168,199,0.02)",padding:"20px"},children:[(0,de.jsx)("h4",{style:Ce.subBlockTitle,children:"Verify Client Payment Screenshot"}),(0,de.jsxs)("p",{style:{fontSize:"0.75rem",color:"var(--text-muted)",marginBottom:"12px"},children:["Verify the transaction receipt before moving the request to ",(0,de.jsx)("strong",{children:"Processing"}),"."]}),(0,de.jsxs)("div",{className:"form-group",style:{marginBottom:"15px"},children:[(0,de.jsx)("label",{className:"form-label",style:{fontSize:"0.8rem"},children:"Rejection Reason (If rejecting slip):"}
2),(0,de.jsx)("input",{type:"text",value:zt,onChange:e=>At(e.target.value),placeholder:"e.g. Transaction ID did not match account statement.",className:"form-control"})]}),(0,de.jsxs)("div",{style:{display:"flex",gap:"10px"},children:[(0,de.jsx)("button",{onClick:()=>Ra($e.id,"Verified","receipt",Tt.payment),className:"btn btn-primary",style:{flex:1,padding:"10px",fontSize:"0.85rem"},disabled:zr,children:"Verify & Approve"}),(0,de.jsx)("button",{onClick:()=>Ra($e.id,"Rejected"),className:"btn btn-danger",style:{flex:1,padding:"10px",fontSize:"0.85rem"},disabled:zr,children:"Reject Receipt"})]})]}),Tt.payment&&("Requested"===Tt.payment.status||"Partial"===Tt.payment.status)&&(0,de.jsxs)("div",{className:"glass-card",style:{border:"1.5px solid #D4AF37",background:"rgba(212,175,55,0.06)",padding:"20px"},children:[(0,de.jsx)("h4",{style:Ce.subBlockTitle,children:"Partial"===Tt.payment.status?"Confirm Direct / Manual Payment":"Confirm Cash or Direct Online Payment"}),(0,de.jsx)("p",{style:{fontSize:"0.75rem",color:"var(--text-muted)",marginBottom:"12px"},children:"Partial"===Tt.payment.status?"If the client has paid another installment in Cash or Direct Bank Transfer without uploading a receipt, you can record it directly below.":"If the client has paid in Cash or Direct Online Transfer without uploading a receipt on the portal, approve it directly below."}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:z?"1fr":"1fr 1fr",gap:"10px"},children:[(0,de.jsxs)("button",{onClick:()=>Ra($e.id,"Verified","cash",Tt.payment),className:"btn btn-primary",style:{padding:"10px 8px",fontSize:"0.82rem",margin:0,width:"100%"},disabled:zr,children:["ðµ ","Partial"===Tt.payment.status?"Receive Cash":"Mark Cash Received"]}),(0,de.jsxs)("button",{onClick:()=>Ra($e.id,"Verified","online",Tt.payment),className:"btn btn-gold",style:{padding:"10px 8px",fontSize:"0.82rem",margin:0,width:"100%"},disabled:zr,children:["ð³ ","Partial"===Tt.payment.status?"Receive Online":"Mark Online Received"]})]}),(0,de.jsx)("div",{style:{marginTop:"12px",paddingTop:"12px",borderTop:"1px dashed rgba(212,175,55,0.3)"},children:(0,de.jsx)("button",{type:"button",onClick:()=>Ia($e.id),className:"btn btn-outline",style:{padding:"8px 12px",fontSize:"0.8rem",margin:0,width:"100%",borderColor:"#D4AF37",color:"#B45309",background:"rgba(212, 175, 55, 0.08)",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",fontWeight:"600"},disabled:zr,title:"Send an immediate payment reminder email to the client with bank details",children:"ð Send Payment Reminder to Client"})})]}),Tt.payment&&(0,de.jsx)("div",{style:{padding:"14px",background:"var(--bg-cool)",borderRadius:"6px",fontSize:"0.85rem"},children:(()=>{const e=Fa(Tt.payment);return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("strong",{children:"Payment Status:"})," ",(0,de.jsx)("span",{style:{fontWeight:"700",color:"Verified"===Tt.payment.status?"#10B981":"Rejected"===Tt.payment.status?"#EF4444":"#F59E0B"},children:Tt.payment.status}),(0,de.jsx)("br",{}),(0,de.jsx)("strong",{children:"Requested Amount:"})," Rs. ",e.requestedAmount.toLocaleString(),e.receivedAmount>0?(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("br",{}),(0,de.jsx)("strong",{children:"Received Amount:"})," Rs. ",e.receivedAmount.toLocaleString()]}):null,e.hasPending?(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("br",{}),(0,de.jsx)("strong",{children:"Pending Balance:"})," Rs. ",e.pendingAmount.toLocaleString()]}):null,e.hasDiscount?(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("br",{}),(0,de.jsx)("strong",{children:"Discount:"})," Rs. ",e.discountAmount.toLocaleString()]}):null,!Tt.payment.receipt_path&&(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("br",{}),(0,de.jsx)("strong",{children:"Payment Mode:"})," ",Tt.payment.payment_method&&Tt.payment.payment_method.toLowerCase().includes("online")?"ð³ Online Bank Transfer":"Verified"===Tt.payment.status||"Partial"===Tt.payment.status?"ðµ Cash Received":"Receipt Pending"]})]})})()}),(0,de.jsxs)("div",{children:[(0,de.jsxs)("h4",{style:Ce.subBlockTitle,children:["Submitted Documents (",Tt.files.filter(e=>e.uploaded_by===Tt.request.client_id).length,")"]}),(0,de.jsx)("div",{style:Ce.fileList,children:0===Tt.files.filter(e=>e.uploaded_by===Tt.request.client_id).length?(0,de.jsx)("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"No attachments uploaded by client."}):Tt.files.filter(e=>e.uploaded_by===Tt.request.client_id).map(e=>(0,de.jsxs)("div",{style:Ce.fileItem,children:[(0,de.jsx)("span",{style:Ce.fileName,children:e.file_name}),(0,de.jsx)("a",{href:`/api/${e.file_path}`,target:"_blank",rel:"noreferrer",style:Ce.fileDownload,children:(0,de.jsx)(r,{size:16})})]},e.id))})]})]}),(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"20px",minWidth:0},children:[Tt.payment&&Tt.payment.receipt_path&&(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[(0,de.jsx)("h4",{style:Ce.subBlockTitle,children:"Transaction Receipt Screenshot"}),(0,de.jsx)("div",{style:Ce.receiptFrame,children:(0,de.jsx)("img",{src:`/api/${Tt.payment.receipt_path}`,alt:"Filing Fee Receipt",style:{width:"100%",height:"100%",objectFit:"contain"}})}),(0,de.jsxs)("a",{href:`/api/${Tt.payment.receipt_path}`,target:"_blank",rel:"noreferrer",className:"btn btn-outline",style:{marginTop:"12px",padding:"6px 12px",fontSize:"0.75rem",display:"flex",gap:"6px"},children:[(0,de.jsx)(r,{size:12})," Open Full Receipt image"]})]}),(0,de.jsxs)("div",{children:[(0,de.jsxs)("h3",{style:Ce.subBlockTitle,children:[(0,de.jsx)(b,{size:18})," Client Consultation timeline"]}),(0,de.jsx)("div",{style:{...Ce.commentsList,maxHeight:"250px",overflowY:"auto",background:"var(--bg-cool)",padding:"12px",borderRadius:"6px"},children:0===Tt.comments.length?(0,de.jsx)("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"No logs recorded."}):Tt.comments.map(e=>(0,de.jsxs)("div",{style:{...Ce.commentBubble,..."client"===e.user_role?Ce.commentClient:Ce.commentAdvisory,marginBottom:"10px"},children:[(0,de.jsxs)("div",{style:Ce.commentHeader,children:[(0,de.jsxs)("strong",{children:[e.user_name,"
2(",e.user_role,")"]}),(0,de.jsx)("span",{children:new Date(e.created_at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),(0,de.jsx)("p",{style:Ce.commentText,children:e.comment})]},e.id))}),(0,de.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),It.trim())try{(await(await o("/api/services/add-comment",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({request_id:$e.id,comment:It})})).json()).success&&(Dt(""),Ba($e.id))}catch(t){}},style:{...Ce.commentForm,marginTop:"10px"},children:[(0,de.jsx)("input",{type:"text",value:It,onChange:e=>Dt(e.target.value),placeholder:"Reply to client thread...",className:"form-control",style:{borderRadius:"var(--radius-full)",paddingRight:"48px"}}),(0,de.jsx)("button",{type:"submit",style:Ce.commentSendBtn,children:(0,de.jsx)(y,{size:16})})]})]})]})]})]})]}),"clients"===Oe&&(0,de.jsx)(ue,{tasks:G,onUpdateTask:da}),"users"===Oe&&(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"30px"},children:[(0,de.jsxs)("div",{className:"glass-card platform-registry-card",children:[(0,de.jsxs)("h3",{style:Ce.subBlockTitle,children:[(0,de.jsx)($,{size:18})," ",nt?`Modify Account: ${nt.name}`:"Platform Registry"]}),(0,de.jsx)("p",{style:{color:"var(--text-muted)",fontSize:"0.8rem",marginBottom:"20px"},children:nt?"Update user contact details, role permissions, or reset their account login password key.":"Add platform accounts individually or upload complete corporate client lists from sheets."}),!nt&&(0,de.jsxs)("div",{style:{display:"flex",borderBottom:"1px solid var(--border)",marginBottom:"20px"},children:[(0,de.jsx)("button",{onClick:()=>dt("single"),style:{flex:1,padding:"10px",background:"none",border:"none",borderBottom:"single"===ot?"2px solid var(--accent-gold)":"none",color:"single"===ot?"var(--primary)":"var(--text-muted)",fontWeight:"single"===ot?"700":"500",cursor:"pointer",fontSize:"0.85rem",fontFamily:"var(--font-heading)"},children:"Single Registration"}),(0,de.jsx)("button",{onClick:()=>dt("bulk"),style:{flex:1,padding:"10px",background:"none",border:"none",borderBottom:"bulk"===ot?"2px solid var(--accent-gold)":"none",color:"bulk"===ot?"var(--primary)":"var(--text-muted)",fontWeight:"bulk"===ot?"700":"500",cursor:"pointer",fontSize:"0.85rem",fontFamily:"var(--font-heading)"},children:"Excel/CSV Importer"})]}),"client"===nt?.role&&(0,de.jsx)(le,{clientId:nt.id},`user-records-${nt.id}`),nt||"single"===ot?(0,de.jsxs)("form",{onSubmit:async e=>{e.preventDefault(),Ar(!0),Fr({type:"",msg:""});const t=nt?{...at,id:nt.id}:at;try{const e=await(await o("/api/admin/users",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify(t)})).json();e.success?(Fr({type:"success",msg:nt?"User details successfully updated!":"User account created successfully!"}),it({name:"",email:"",password:"",phone:"",company_name:"",role:"consultant"}),lt(null),ca(),oa()):Fr({type:"error",msg:e.message})}catch(r){Fr({type:"error",msg:"Account action failed."})}finally{Ar(!1)}},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Full Name"}),(0,de.jsx)("input",{type:"text",value:at.name,onChange:e=>it({...at,name:e.target.value}),className:"form-control",placeholder:"e.g. Dr. Haris",required:!0})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Email Address"}),(0,de.jsx)("input",{type:"email",value:at.email,onChange:e=>it({...at,email:e.target.value}),className:"form-control",placeholder:"e.g. [email protected]",required:!0})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Company Name"}),(0,de.jsx)("input",{type:"text",value:at.company_name||"",onChange:e=>it({...at,company_name:e.target.value}),className:"form-control",placeholder:"e.g. TechSolutions Ltd"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:nt?"Reset Account Password (Optional)":"Temporary Password"}),(0,de.jsx)("input",{type:"password",value:at.password,onChange:e=>it({...at,password:e.target.value}),className:"form-control",placeholder:nt?"Leave blank to retain current password":"At least 10 characters",minLength:10,required:!nt})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Phone"}),(0,de.jsx)("input",{type:"text",value:at.phone,onChange:e=>it({...at,phone:e.target.value}),className:"form-control",placeholder:"03001234567"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Role Access Level"}),(0,de.jsxs)("select",{value:at.role,onChange:e=>it({...at,role:e.target.value}),className:"form-control",children:[(0,de.jsx)("option",{value:"consultant",children:"Consultant"}),(0,de.jsx)("option",{value:"admin",children:"Super Admin"}),(0,de.jsx)("option",{value:"client",children:"Client"}),(0,de.jsx)("option",{value:"marketing_agent",children:"Marketing Agent"})]})]}),(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"10px",marginTop:"15p
2x"},children:[(0,de.jsx)("button",{type:"submit",className:"btn btn-gold",style:{width:"100%"},disabled:zr,children:zr?nt?"Saving...":"Generating...":nt?"Save Profile Changes":"Generate New User Account"}),nt&&(0,de.jsx)("button",{type:"button",onClick:()=>{lt(null),it({name:"",email:"",password:"",phone:"",company_name:"",role:"consultant"})},className:"btn btn-outline",style:{width:"100%"},children:"Cancel Edit"})]})]}):(0,de.jsxs)("div",{className:"animate-fade-in",style:{display:"flex",flexDirection:"column",gap:"20px"},children:[(0,de.jsxs)("div",{style:{background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:"8px",padding:"16px",fontSize:"0.8rem",color:"var(--text-muted)"},children:[(0,de.jsxs)("h4",{style:{color:"var(--primary)",fontWeight:"700",marginBottom:"8px",display:"flex",alignItems:"center",gap:"6px"},children:[(0,de.jsx)(V,{size:16,style:{color:"var(--accent-gold)"}})," Excel / Google Sheets Importer"]}),(0,de.jsx)("p",{style:{margin:"0 0 10px 0",lineHeight:"1.4"},children:"Upload a standard comma-separated **.csv** file. Make sure the headers map cleanly (spelling can vary slightly, case-insensitive)."}),(0,de.jsx)("div",{style:{background:"var(--white)",border:"1px solid var(--border)",borderRadius:"6px",padding:"8px",fontFamily:"monospace",fontSize:"0.75rem",color:"var(--text-main)"},children:"Name, Email, Phone, Company, Password"}),(0,de.jsx)("span",{style:{display:"block",marginTop:"8px",fontSize:"0.72rem",color:"var(--accent-teal)",fontWeight:"600"},children:"* Phone, Company, and Password columns are optional. Missing passwords will be auto-generated."})]}),(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[(0,de.jsx)("label",{className:"form-label",style:{fontWeight:"700"},children:"Choose CSV Spreadsheet File"}),(0,de.jsxs)("div",{style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",border:"2px dashed var(--accent-gold)",borderRadius:"10px",padding:"30px 20px",cursor:"pointer",transition:"var(--transition)",background:"rgba(212,175,55,0.02)"},className:"csv-upload-dropzone",children:[(0,de.jsx)("input",{type:"file",accept:".csv",onChange:e=>{const t=e.target.files[0];if(t){const e=new FileReader;e.onload=e=>{(async e=>{try{const r=(e=>{const t=[];let r=[""],s=!1;for(let a=0;a<e.length;a++){const i=e[a],n=e[a+1];'"'===i?s&&'"'===n?(r[r.length-1]+='"',a++):s=!s:","!==i||s?"\r"!==i&&"\n"!==i||s?r[r.length-1]+=i:("\r"===i&&"\n"===n&&a++,t.push(r),r=[""]):r.push("")}return(r.length>1||""!==r[0])&&t.push(r),t})(e);if(r.length<2)return void Fr({type:"error",msg:"CSV file must contain a header row and at least one client row."});const s=r[0].map(e=>e.trim().toLowerCase()),a=s.findIndex(e=>e.includes("name")),i=s.findIndex(e=>e.includes("email")||e.includes("mail")),n=s.findIndex(e=>e.includes("phone")||e.includes("contact")||e.includes("mobile")),l=s.findIndex(e=>e.includes("company")||e.includes("firm")||e.includes("org")),d=s.findIndex(e=>e.includes("password")||e.includes("pass"));if(-1===a||-1===i)return void Fr({type:"error",msg:'CSV must contain at least "Name" and "Email" columns.'});const c=[],p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*",x=()=>{let e="Client@";for(let t=0;t<8;t++)e+=p.charAt(Math.floor(70*Math.random()));return e};for(let e=1;e<r.length;e++){const t=r[e];if(1===t.length&&""===t[0])continue;const s=t[a]?t[a].trim():"",o=t[i]?t[i].trim():"";if(!s||!o)continue;const p=-1!==n&&t[n]?t[n].trim():"",m=-1!==l&&t[l]?t[l].trim():"",g=-1!==d&&t[d]&&t[d].trim()?t[d].trim():x();c.push({name:s,email:o,phone:p,company_name:m,password:g,role:"client"})}if(0===c.length)return void Fr({type:"error",msg:"No valid client records found in CSV file."});pt({total:c.length,current:0,status:"processing"}),mt([`Found ${c.length} clients in CSV. Commencing bulk upload...`]);let m=0,u=0;for(let e=0;e<c.length;e++){const r=c[e];mt(t=>[...t,`[${e+1}/${c.length}] Creating account for ${r.name}...`]);try{const e=await(await o("/api/admin/users",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify(r)})).json();e.success?(m++,mt(e=>[...e,`â Success: ${r.name} (${r.email}) registered! Password: ${r.password}`])):(u++,mt(t=>[...t,`â Failed: ${r.name} (${r.email}) - ${e.message}`]))}catch(t){u++,mt(e=>[...e,`â Failed: ${r.name} (${r.email}) - Connection failed.`])}pt(t=>({...t,current:e+1}))}pt(e=>({...e,status:"completed"})),mt(e=>[...e,`ð Bulk processing completed! Success: ${m}, Failures: ${u}.`]),Fr({type:"success",msg:`Bulk upload finished. Registered ${m} clients successfully.`}),ca(),oa()}catch(r){Fr({type:"error",msg:`Error parsing CSV: ${r.message}`})}})(e.target.result)},e.readAsText(t)}},style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",opacity:0,cursor:"pointer"},disabled:"processing"===ct.status}),(0,de.jsxs)("div",{style:{textAlign:"center",pointerEvents:"none"},children:[(0,de.jsx)(Y,{size:36,style:{color:"var(--accent-gold)",marginBottom:"8px"}}),(0,de.jsx)("span",{style:{display:"block",fontSize:"0.85rem",fontWeight:"700",color:"var(--primary)"},children:"processing"===ct.status?"Processing Upload...":"Click to Upload .CSV File"}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)"},children:"Excel & Google Sheet CSV Formats"})]})]})]}),"processing"===ct.status&&(0,de.jsxs)("div",{style:{marginTop:"10px"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"0.8rem",fontWeight:"700",marginBottom:"6px"},children:[(0,de.jsx)("span",{style:{color:"var(--primary)"},children:"Registering Client Accounts..."}),(0,de.jsxs)("span",{style:{color:"var(--accent-gold)"},children:[ct.current," / ",ct.total," (",Math.round(ct.current/ct.total*100),"%)"]})]}),(0,de.jsx)("div",{style:{height:"8px",background:"#F1F5F9",borderRadius:"4px",overflow:"hidden",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.06)"},children:(0,de.jsx)("div",{style:{height:"100%",width:ct.current/ct.total*100+"%",background:"linear-gradient(90deg, var(--accent-gold), var(--accent-teal))",transition:"width 0.2s ease",boxShadow:"0 0 8px var(--accent-gold)"}})})]}),xt.length>0&&(0,de.jsxs)("div",{style:{marginTop:"10px",display:"flex",flexDirection:"column",gap:"8px"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,de.jsx)("span",{style:{fontSize:"0.8rem",fontWeight:"700",color:"var(--primary)"},children:"Real-Time Processing Console"}),(0,de.jsx)("button",{onClick:()=>{mt([]),pt({total:0,current:0,status:"idle"})},className:"btn btn-outline",style:{padding:"4px 10px",fontSize:"0.7rem",margin:0},children:"Clear Log"})]}),(0,de.jsx)("div",{style:{background:"#0F172A",border:"1px solid #334155",borderRadius:"8px",padding:"12px",height:"160px",overflowY:"auto",fontFamily:"monospace",fontSize:"0.75rem",color:"#38BDF8",dis
2play:"flex",flexDirection:"column",gap:"4px",boxShadow:"inset 0 2px 4px rgba(0,0,0,0.3)"},className:"terminal-logs-console",children:xt.map((e,t)=>(0,de.jsx)("div",{style:{color:e.includes("â")?"#F87171":e.includes("â")?"#34D399":"#38BDF8"},children:e},t))})]})]})]}),(0,de.jsxs)("div",{className:"glass-card",children:[(0,de.jsx)("h2",{style:Ce.tabTitle,children:"System Directory"}),(0,de.jsx)("p",{style:Ce.tabText,children:"Complete directory listing of active Clients, Providers, and Administrative staff."}),(0,de.jsxs)("div",{style:{marginBottom:"20px",position:"relative"},children:[(0,de.jsx)("input",{type:"text",value:Ns,onChange:e=>ks(e.target.value),placeholder:"Search registered accounts by name, email, phone, company...",className:"form-control",style:{paddingLeft:"40px",borderRadius:"8px"}}),(0,de.jsx)(s,{size:18,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:"var(--text-muted)"}})]}),(0,de.jsx)("div",{style:Ce.tableResponsive,children:(0,de.jsxs)("table",{style:Ce.table,children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{children:[(0,de.jsx)("th",{children:"User ID"}),(0,de.jsx)("th",{children:"Account Name"}),(0,de.jsx)("th",{children:"Email ID"}),(0,de.jsx)("th",{children:"Access Level"}),(0,de.jsx)("th",{children:"Joined Date"}),(0,de.jsx)("th",{children:"Action"})]})}),(0,de.jsx)("tbody",{children:pe.filter(e=>{const t=Ns.toLowerCase().trim();return!t||String(e.id).includes(t)||e.name&&e.name.toLowerCase().includes(t)||e.email&&e.email.toLowerCase().includes(t)||e.phone&&e.phone.toLowerCase().includes(t)||e.company_name&&e.company_name.toLowerCase().includes(t)||e.role&&e.role.toLowerCase().includes(t)}).map(e=>(0,de.jsxs)("tr",{children:[(0,de.jsx)("td",{children:(0,de.jsx)("strong",{style:{color:"var(--accent-gold)"},children:e.id})}),(0,de.jsxs)("td",{children:[(0,de.jsx)("strong",{children:e.name}),(0,de.jsx)("br",{}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)"},children:e.phone||"No phone"}),"marketing_agent"===e.role&&e.payment_details&&(0,de.jsxs)("div",{style:{fontSize:"0.75rem",marginTop:"6px",padding:"6px",background:"rgba(212, 175, 55, 0.08)",borderRadius:"4px",border:"1px solid rgba(212, 175, 55, 0.3)",color:"var(--accent-gold)"},children:[(0,de.jsx)("strong",{children:"Payout Account:"})," ",(()=>{try{const t=JSON.parse(e.payment_details);return`${t.bank_name||""} - ${t.account_title||""} (${t.account_number||""}) ${t.mobile_wallet?`[Wallet: ${t.mobile_wallet}]`:""}`}catch(t){return e.payment_details}})()]})]}),(0,de.jsx)("td",{children:e.email}),(0,de.jsx)("td",{children:(()=>{const t="admin"===e.role,r="consultant"===e.role,s="marketing_agent"===e.role,a=!r&&!t&&("provider"===e.marketplace_role||e.provider_status&&"none"!==e.provider_status&&"removed"!==e.provider_status);return(0,de.jsx)("span",{style:{padding:"4px 10px",borderRadius:"4px",fontSize:"0.75rem",fontWeight:"600",backgroundColor:t?"#FEE2E2":r?"#E0F2FE":s?"#FEF3C7":a?"#EEF2FF":"#F1F5F9",color:t?"#EF4444":r?"#0369A1":s?"#B45309":a?"#4F46E5":"var(--text-main)"},children:t?"ADMIN":r?"CONSULTANT":s?"MARKETING AGENT":a?"PROVIDER":"CLIENT"})})()}),(0,de.jsx)("td",{children:new Date(e.created_at).toLocaleDateString()}),(0,de.jsxs)("td",{children:[(0,de.jsx)("button",{onClick:()=>{lt(e),it({name:e.name||"",email:e.email||"",password:"",phone:e.phone||"",company_name:e.company_name||"",role:e.role||"client"});const t=document.querySelector(".platform-registry-card");t&&t.scrollIntoView({behavior:"smooth"})},className:"btn btn-outline",style:{padding:"6px 12px",fontSize:"0.75rem",margin:0},children:"Edit Profile"}),(0,de.jsx)("button",{onClick:()=>(async(e,t)=>{if(window.confirm(`Are you sure you want to permanently delete user account: ${t}? This action cannot be undone.`)){Ar(!0),Fr({type:"",msg:""});try{const t=await(await o("/api/admin/users",{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({id:e})})).json();t.success?(Fr({type:"success",msg:"User account successfully deleted."}),ca(),oa()):Fr({type:"error",msg:t.message})}catch(r){Fr({type:"error",msg:"Failed to delete user account."})}finally{Ar(!1)}}})(e.id,e.name),className:"btn btn-outline",style:{padding:"6px 12px",fontSize:"0.75rem",margin:"0 0 0 8px",color:"#EF4444",borderColor:"#FCA5A5",backgroundColor:"rgba(239, 68, 68, 0.02)"},children:"Delete Account"})]})]},e.id))})]})})]})]}),"blogs"===Oe&&(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"30px"},children:[(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{background:"#FFFDF5",border:"1.5px solid var(--accent-gold)"},children:[(0,de.jsxs)("h3",{style:{...Ce.subBlockTitle,display:"flex",alignItems:"center",gap:"8px",color:"#92400E"},children:[(0,de.jsx)(l,{size:18,style:{color:"#D4AF37"}})," Consultant Articles Awaiting Approval (",Te.length,")"]}),(0,de.jsx)("p",{style:{color:"var(--text-muted)",fontSize:"0.82rem",marginBottom:"16
2px"},children:"These articles were submitted by consultants. Review and approve or reject before publication."}),0===Te.length?(0,de.jsx)("p",{style:{color:"var(--text-muted)",fontSize:"0.9rem",textAlign:"center",padding:"20px 0"},children:"â³ No articles currently awaiting approval. When consultants submit new articles, they will appear here for review."}):(0,de.jsx)("div",{style:Ce.tableResponsive,children:(0,de.jsxs)("table",{style:Ce.table,children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{children:[(0,de.jsx)("th",{children:"Article Title"}),(0,de.jsx)("th",{children:"Submitted By"}),(0,de.jsx)("th",{children:"Excerpt"}),(0,de.jsx)("th",{children:"Date"}),(0,de.jsx)("th",{children:"Review"})]})}),(0,de.jsx)("tbody",{children:Te.map(e=>(0,de.jsxs)("tr",{children:[(0,de.jsx)("td",{children:(0,de.jsx)("strong",{children:e.title})}),(0,de.jsx)("td",{style:{fontSize:"0.8rem",color:"var(--text-muted)"},children:e.author_name||"Senior Consultant"}),(0,de.jsx)("td",{style:{fontSize:"0.8rem",maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.excerpt}),(0,de.jsx)("td",{style:{fontSize:"0.8rem"},children:new Date(e.created_at).toLocaleDateString()}),(0,de.jsx)("td",{children:(0,de.jsxs)("div",{style:{display:"flex",gap:"6px"},children:[(0,de.jsxs)("button",{onClick:()=>ha(e.id,!0),className:"btn btn-primary",style:{padding:"6px 10px",fontSize:"0.75rem",margin:0,display:"inline-flex",alignItems:"center",gap:"4px"},disabled:zr,title:"Approve & Publish",children:[(0,de.jsx)(d,{size:13})," Approve"]}),(0,de.jsxs)("button",{onClick:()=>ha(e.id,!1),className:"btn btn-danger",style:{padding:"6px 10px",fontSize:"0.75rem",margin:0,display:"inline-flex",alignItems:"center",gap:"4px"},disabled:zr,title:"Reject and retain article history",children:[(0,de.jsx)(O,{size:13})," Reject"]})]})})]},e.id))})]})})]}),(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{background:"var(--white)",border:"1px solid var(--border)"},children:[(0,de.jsxs)("h3",{style:{...Ce.subBlockTitle,display:"flex",alignItems:"center",gap:"8px"},children:[(0,de.jsx)(b,{size:18,style:{color:"var(--accent-teal)"}})," Article Comments Awaiting Moderation (",Re.length,")"]}),(0,de.jsx)("p",{style:{color:"var(--text-muted)",fontSize:"0.82rem",marginBottom:"16px"},children:"Approve useful reader discussion or reject spam. Rejected comments are retained in moderation history and are never published."}),0===Re.length?(0,de.jsx)("p",{style:{color:"var(--text-muted)",fontSize:"0.9rem",textAlign:"center",padding:"18px 0"},children:"No comments are waiting for review."}):(0,de.jsx)("div",{style:Ce.tableResponsive,children:(0,de.jsxs)("table",{style:Ce.table,children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{children:[(0,de.jsx)("th",{children:"Reader"}),(0,de.jsx)("th",{children:"Article"}),(0,de.jsx)("th",{children:"Comment"}),(0,de.jsx)("th",{children:"Submitted"}),(0,de.jsx)("th",{children:"Decision"})]})}),(0,de.jsx)("tbody",{children:Re.map(e=>(0,de.jsxs)("tr",{children:[(0,de.jsx)("td",{children:(0,de.jsx)("strong",{children:e.display_name})}),(0,de.jsx)("td",{style:{maxWidth:"220px",fontSize:"0.8rem"},children:(0,de.jsx)("a",{href:`/resources/${e.article_slug}`,target:"_blank",rel:"noreferrer",style:{color:"var(--accent-teal)",fontWeight:700},children:e.article_title})}),(0,de.jsx)("td",{style:{maxWidth:"360px",whiteSpace:"pre-wrap",overflowWrap:"anywhere",fontSize:"0.8rem",lineHeight:1.5},children:e.content}),(0,de.jsx)("td",{style:{fontSize:"0.78rem"},children:new Date(e.created_at).toLocaleString()}),(0,de.jsx)("td",{children:(0,de.jsxs)("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:[(0,de.jsxs)("button",{type:"button",onClick:()=>ua(e.id,"approved"),className:"btn btn-primary",disabled:zr,style:{padding:"6px 10px",margin:0,fontSize:"0.74rem",display:"inline-flex",gap:"4px",alignItems:"center"},children:[(0,de.jsx)(d,{size:13})," Approve"]}),(0,de.jsxs)("button",{type:"button",onClick:()=>ua(e.id,"rejected"),className:"btn btn-danger",disabled:zr,style:{padding:"6px 10px",margin:0,fontSize:"0.74rem",display:"inline-flex",gap:"4px",alignItems:"center"},children:[(0,de.jsx)(O,{size:13})," Reject"]})]})})]},e.id))})]})})]}),(0,de.jsxs)("div",{className:"dashboard-detail-grid",style:{gap:"30px"},children:[(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{background:"var(--white)",alignSelf:"start"},children:[(0,de.jsxs)("h3",{style:Ce.subBlockTitle,children:[(0,de.jsx)(u,{size:18})," ",null!==wt?"Edit Article Details":"Publish New Article"]}),(0,de.jsx)("p",{style:{color:"var(--text-muted)",fontSize:"0.8rem",marginBottom:"20px"},children:null!==wt?"Modify and update the details of your published tax article."
2:"Write high-quality legal tax articles to get fast Google AdSense approval."}),(0,de.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),!gt.title.trim()||!gt.content.trim())return Fr({type:"error",msg:"Please provide both an Article Title and Content."}),void Ar(!1);try{const e=null!==wt,s=e?"/api/articles/update":"/api/articles/create",a=new FormData;e&&a.append("id",wt),a.append("title",gt.title.trim()),a.append("excerpt",gt.excerpt.trim()),a.append("content",gt.content),a.append("cover_image",gt.cover_image||""),a.append("category",gt.category||"Tax Guide"),a.append("slug",gt.slug||""),a.append("seo_title",gt.seo_title||""),a.append("meta_description",gt.meta_description||""),a.append("social_caption",gt.social_caption||""),a.append("focus_keywords",gt.focus_keywords||""),a.append("tax_year",gt.tax_year||""),a.append("is_featured",gt.is_featured?"1":"0"),ht&&a.append("cover_image_file",ht),vt&&a.append("pdf_file",vt);const i=await o(s,{method:"POST",headers:{Authorization:`Bearer ${g}`},body:a});let n=null;try{n=await i.json()}catch(t){}if(n&&n.success){Fr({type:"success",msg:n.message||"Article successfully saved!"}),ut({title:"",excerpt:"",content:"",cover_image:"",category:"Tax Guide",slug:"",seo_title:"",meta_description:"",social_caption:"",focus_keywords:"",tax_year:"",is_featured:0}),yt(null),bt(""),jt(null),Ct(""),_t(null),kt(!1);try{await xa()}catch(r){}}else{const e=n?.message||(413===i.status?"Uploaded image or file is too large for server.":null!==wt?"Failed to update blog post.":"Failed to publish blog post.");Fr({type:"error",msg:e})}}catch(s){Fr({type:"error",msg:s.message||(null!==wt?"Failed to update blog post.":"Failed to publish blog post.")})}finally{Ar(!1)}},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Article Title"}),(0,de.jsx)("input",{type:"text",value:gt.title,onChange:e=>ut({...gt,title:e.target.value}),className:"form-control",placeholder:"e.g. Benefits of SECP Registrations",required:!0})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Excerpt Summary"}),(0,de.jsx)("input",{type:"text",value:gt.excerpt,onChange:e=>ut({...gt,excerpt:e.target.value}),className:"form-control",placeholder:"e.g. Learn how registered businesses save...",required:!0})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Article Cover Image"}),(0,de.jsxs)("div",{style:{width:"100%",height:"180px",border:"2px dashed rgba(212, 175, 55, 0.3)",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",background:"rgba(255,255,255,0.02)",overflow:"hidden",marginBottom:"12px"},children:[ft?(0,de.jsxs)("div",{style:{width:"100%",height:"100%",position:"relative"},children:[(0,de.jsx)("img",{src:ft,alt:"Cover Preview",style:{width:"100%",height:"100%",objectFit:"cover"}}),(0,de.jsx)("button",{type:"button",onClick:()=>{yt(null),bt(""),ut({...gt,cover_image:""})},style:{position:"absolute",top:"8px",right:"8px",background:"#E02424",color:"#FFFFFF",border:"none",borderRadius:"50%",width:"28px",height:"28px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"bold",zIndex:10,boxShadow:"0 2px 4px rgba(0,0,0,0.3)"},children:"Ã"})]}):(0,de.jsxs)("div",{style:{textAlign:"center",pointerEvents:"none"},children:[(0,de.jsx)("div",{style:{width:"48px",height:"48px",background:"rgba(212,175,55,0.1)",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 10px auto"},children:(0,de.jsx)(Y,{size:24})}),(0,de.jsx)("span",{style:{fontSize:"0.85rem",color:"var(--text-muted)"},children:"Drag & drop or browse to upload cover image"}),(0,de.jsx)("p",{style:{fontSize:"0.7rem",color:"var(--text-muted)",margin:"4px 0 0 0"},children:"Supports JPG, PNG, WEBP or GIF"})]}),(0,de.jsx)("input",{type:"file",accept:"image/*",onChange:e=>{const t=e.target.files[0];t&&(yt(t),bt(URL.createObjectURL(t)))},style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",opacity:0,cursor:"pointer"}})]}),(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},children:[(0,de.jsx)("span",{style:{height:"1px",flex:1,background:"rgba(255,255,255,0.08)"}}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:"bold",textTransform:"uppercase"},children:"OR"}),(0,de.jsx)("span",{style:{height:"1px",flex:1,background:"rgba(255,255,255,0.08)"}})]}),(0,de.jsx)("input",{type:"text",value:gt.cover_image||"",onChange:e=>{ut({...gt,cover_image:e.target.value}),e.target.value&&(bt(e.target.value),yt(null))},className:"form-control",placeholder:"e.g. Paste external Image URL (https://images.unsplash.com/...)"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Article Category"}
2),(0,de.jsxs)("select",{value:Nt?"custom":gt.category||"Tax Guide",onChange:e=>{"custom"===e.target.value?(kt(!0),ut({...gt,category:""})):(kt(!1),ut({...gt,category:e.target.value}))},className:"form-control",style:{background:"rgba(255,255,255,0.03)",color:"#fff",border:"1px solid var(--border)"},children:[(()=>{const e=(ye||[]).map(e=>e.category).filter(Boolean),t=gt.category?[gt.category]:[];return Array.from(new Set(["Tax Guide","Income Tax","Sales Tax","Corporate Compliance","Business Registration","WHT Tax Card",...e,...t])).filter(e=>"custom"!==e).map(e=>(0,de.jsx)("option",{value:e,style:{background:"var(--primary)"},children:e},e))})(),(0,de.jsx)("option",{value:"custom",style:{background:"var(--primary)",color:"#D4AF37"},children:"+ Add New Category..."})]}),Nt&&(0,de.jsx)("input",{type:"text",value:gt.category,onChange:e=>ut({...gt,category:e.target.value}),className:"form-control",placeholder:"Enter custom category name (e.g. Freelancing Tax)",style:{marginTop:"8px"},required:!0})]}),"WHT Tax Card"===gt.category&&(0,de.jsxs)(de.Fragment,{children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Tax Year (e.g. TY 2026)"}),(0,de.jsxs)("select",{value:gt.tax_year||"",onChange:e=>ut({...gt,tax_year:e.target.value}),className:"form-control",style:{background:"rgba(255,255,255,0.03)",color:"#fff",border:"1px solid var(--border)"},children:[(0,de.jsx)("option",{value:"",style:{background:"var(--primary)"},children:"-- Select Tax Year --"}),["Combined","TY 2027","TY 2026","TY 2025","TY 2024","TY 2023","TY 2022"].map(e=>(0,de.jsx)("option",{value:e,style:{background:"var(--primary)"},children:"Combined"===e?"Combined WHT Card (Multi-Year)":e},e))]})]}),"Combined"===gt.tax_year&&(0,de.jsxs)("div",{className:"form-group animate-fade-in",children:[(0,de.jsx)("label",{className:"form-label",children:"Supported Years (comma-separated, e.g. TY 2026, TY 2025, TY 2024)"}),(0,de.jsx)("input",{type:"text",value:gt.content||"",onChange:e=>ut({...gt,content:e.target.value}),placeholder:"e.g. TY 2026, TY 2025, TY 2024",className:"form-control",style:{background:"rgba(255,255,255,0.03)",color:"#fff",border:"1px solid var(--border)"},required:!0}),(0,de.jsx)("p",{style:{margin:"4px 0 0 0",fontSize:"0.72rem",color:"var(--text-muted)"},children:"Enter the years in order of their pages in the PDF (Page 1 = first year, Page 2 = second year, etc.)"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Upload WHT Tax Card PDF"}),(0,de.jsxs)("div",{style:{width:"100%",padding:"20px",border:vt?"2px solid rgba(212,175,55,0.6)":"2px dashed rgba(212,175,55,0.3)",borderRadius:"12px",background:vt?"rgba(212,175,55,0.06)":"rgba(255,255,255,0.02)",textAlign:"center",position:"relative",cursor:"pointer"},children:[vt?(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"12px"},children:[(0,de.jsx)("div",{style:{width:"40px",height:"40px",background:"rgba(212,175,55,0.15)",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,de.jsx)(_,{size:22,style:{color:"#D4AF37"}})}),(0,de.jsxs)("div",{style:{textAlign:"left"},children:[(0,de.jsx)("p",{style:{margin:0,fontSize:"0.85rem",color:"#fff",fontWeight:"600"},children:St}),(0,de.jsx)("p",{style:{margin:0,fontSize:"0.72rem",color:"var(--text-muted)"},children:"PDF ready to upload"})]}),(0,de.jsx)("button",{type:"button",onClick:()=>{jt(null),Ct("")},style:{marginLeft:"auto",background:"#E02424",color:"#fff",border:"none",borderRadius:"50%",width:"26px",height:"26px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"bold",flexShrink:0},children:"Ã"})]}):(0,de.jsxs)("div",{style:{pointerEvents:"none"},children:[(0,de.jsx)("div",{style:{width:"48px",height:"48px",background:"rgba(212,175,55,0.1)",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 10px auto"},children:(0,de.jsx)(Y,{size:24,style:{color:"#D4AF37"}})}),(0,de.jsx)("p",{style:{margin:0,fontSize:"0.85rem",color:"var(--text-muted)"},children:"Click or drag to upload PDF Tax Card"}),(0,de.jsx)("p",{style:{margin:"4px 0 0 0",fontSize:"0.72rem",color:"var(--text-muted)"},children:"Only PDF files accepted ⢠Max 20MB"})]}),(0,de.jsx)("input",{type:"file",accept:"application/pdf",onChange:e=>{const t=e.target.files[0];t&&(jt(t),Ct(t.name))},style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",opacity:0,cursor:"pointer"}})]}),wt&&!vt&&(0,de.jsx)("small",{style:{color:"var(--text-muted)",fontSize:"0.72rem",marginTop:"4px",display:"block"},children:"Leave empty to keep existing PDF file."})]})]}),!("WHT Tax Card"===gt.category&&"Combined"===gt.tax_year)&&(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"},children:[(0,de.jsx)("label",{className:"form-label",style:{marginBottom:0},children:"Full Article Rich HTML Body"}),(0,de.jsxs)("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[(0,de.jsxs)("button",{type:"button",onClick:()=>{const e=document.createElement("input");e.type="file",e.accept="image/*",e.onchange=async e=>{const t=e.target.files[0];if(!t)return;const r=new FormData;r.append("image",t);try{const e=await(await o("/api/articles/upload-image",{method:"POST",headers:{Authorization:`Bearer ${g}`},body:r})).json();if(e.success){const r=`<img src="/api/${e.data.url}" alt="${t.name.split(".")[0]}" style="max-width:100%; height:auto; border-radius:8px; margin:16px 0; display:block;" />`;Da(r)}else Tr(e.message)}catch(s){Tr("Failed to upload image.")}},e.click()},className:"btn btn-outline",style:{padding:"3px 8px",fontSize:"0.75rem",display:"flex",alignItems:"center",gap:"4px",border:"1px solid rgba(212,175,55,0.4)",color:"#D4AF37",background:"transparent"},children:[(0,de.jsx)(Y,{size:12})," Upload & Insert Image"]}),(0,de.jsxs)("button",{type:"button",onClick:()=>{const e=prompt("Enter Image URL:");e&&Da(`<img src="${e}" alt="Image" style="max-width:100%; height:auto; border-radius:8px; margin:16px 0; display:block;" />`)},className:"btn btn-outline",style:{padding:"3px 8px",fontSize:"0.75rem",display:"flex",alignItems:"center",gap:"4px",border:"1px solid rgba(212,175,55,0.4)",color:"#D4AF37",background:"transparent"},children:[(0,de.jsx)(M,{size:12})," Insert Image URL"]})]})]}),(0,de.jsx)("textarea",{id:"article-content-textarea",value:gt.content,onChange:e=>ut({...gt,content:e.target.value}),rows:"8",className:"form-control",placeholder:"Use standard HTML markup: <h2>Subheading</h2> <p>Paragraph text</p> <ul><li>Bullet</li></ul>",required:!0})]}),(0,de.jsxs)("div",{style:{marginTop:"24px",paddingTop:"20px",borderTop:"1px solid var(--border)",marginBottom:"20px"},children:[(0,de.jsxs)("h4",{style:{fontSize:"0.95rem",fontWeight:"600",color:"#D4AF37",marginBottom:"16
2px",display:"flex",alignItems:"center",gap:"8px"},children:[(0,de.jsx)(T,{size:16}),"SEO & Meta Settings (Optional)"]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"SEO Title"}),(0,de.jsx)("input",{type:"text",value:gt.seo_title||"",onChange:e=>ut({...gt,seo_title:e.target.value}),className:"form-control",placeholder:"e.g. Finance Bill 2026 Salary Tax Relief in Pakistan"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Slug / URL Path"}),(0,de.jsx)("input",{type:"text",value:gt.slug||"",onChange:e=>ut({...gt,slug:e.target.value}),className:"form-control",placeholder:"e.g. finance-bill-2026-salary-tax-relief-pakistan"}),(0,de.jsx)("small",{style:{color:"var(--text-muted)",fontSize:"0.72rem",marginTop:"4px",display:"block"},children:"Custom URL path. Leave empty to auto-generate from Title."})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Focus Keywords"}
2),(0,de.jsx)("input",{type:"text",value:gt.focus_keywords||"",onChange:e=>ut({...gt,focus_keywords:e.target.value}),className:"form-control",placeholder:"e.g. Finance Bill 2026 salary tax, salary tax relief Pakistan"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Meta Description"}),(0,de.jsx)("textarea",{value:gt.meta_description||"",onChange:e=>ut({...gt,meta_description:e.target.value}),rows:"3",className:"form-control",placeholder:"e.g. Learn about Finance Bill 2026 salary tax relief in Pakistan, including revised slabs and rates."})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Short Social Caption"}),(0,de.jsx)("textarea",{value:gt.social_caption||"",onChange:e=>ut({...gt,social_caption:e.target.value}),rows:"3",className:"form-control",placeholder:"e.g. Finance Bill 2026 brings proposed salary tax relief for salaried individuals in Pakistan."})]}),(0,de.jsxs)("div",{className:"form-group",style:{display:"flex",alignItems:"center",gap:"10px",marginTop:"15px",marginBottom:"15px"},children:[(0,de.jsx)("input",{type:"checkbox",id:"is_featured_checkbox",checked:!!gt.is_featured,onChange:e=>ut({...gt,is_featured:e.target.checked?1:0}),style:{cursor:"pointer",width:"18px",height:"18px",margin:0}}),(0,de.jsx)("label",{htmlFor:"is_featured_checkbox",style:{cursor:"pointer",fontSize:"0.9rem",color:"var(--text-main)",userSelect:"none",fontWeight:"600",margin:0},children:"Pin / Feature in Recent Guides Sidebar"})]})]}),(0,de.jsx)("button",{type:"submit",className:"btn btn-gold",style:{width:"100%",marginTop:"10px"},disabled:zr,children:null!==wt?zr?"Updating...":"Update Article Details":zr?"Publishing...":"Publish Article Live"}),null!==wt&&(0,de.jsx)("button",{type:"button",onClick:()=>{_t(null),ut({title:"",excerpt:"",content:"",cover_image:"",category:"Tax Guide",slug:"",seo_title:"",meta_description:"",social_caption:"",focus_keywords:"",tax_year:""}),yt(null),bt(""),jt(null),Ct(""),kt(!1)},className:"btn btn-secondary",style:{width:"100%",marginTop:"8px",backgroundColor:"#6B7280",color:"#fff",border:"none"},disabled:zr,children:"Cancel Edit"})]})]}),(0,de.jsxs)("div",{className:"glass-card",children:[(0,de.jsx)("h2",{style:Ce.tabTitle,children:"Google AdSense Article Manager"}),(0,de.jsx)("p",{style:Ce.tabText,children:"List of active tax guides and company incorporation articles published for Google SEO."}),(0,de.jsx)("div",{style:Ce.tableResponsive,children:(0,de.jsxs)("table",{style:{...Ce.table,border:"1px solid var(--border)"},className:"distinct-table",children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{children:[(0,de.jsx)("th",{children:"Article Title"}),(0,de.jsx)("th",{children:"Slug Address"}),(0,de.jsx)("th",{children:"Published Date"}),(0,de.jsx)("th",{children:"Action"})]})}),(0,de.jsx)("tbody",{children:0===ye.length?(0,de.jsx)("tr",{children:(0,de.jsx)("td",{colSpan:"4",style:{textAlign:"center",padding:"20px"},children:"No articles published yet."})}):ye.map(e=>(0,de.jsxs)("tr",{children:[(0,de.jsx)("td",{style:{borderBottom:"1px solid var(--border)"},children:(0,de.jsx)("strong",{children:e.title})}),(0,de.jsx)("td",{style:{borderBottom:"1px solid var(--border)"},children:(0,de.jsxs)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",fontFamily:"Courier, monospace"},children:["/",e.slug]})}),(0,de.jsx)("td",{style:{borderBottom:"1px solid var(--border)"},children:new Date(e.created_at).toLocaleDateString()}),(0,de.jsxs)("td",{style:{borderBottom:"1px solid var(--border)"},children:[(0,de.jsx)("button",{onClick:()=>(async e=>{Ar(!0),Fr({type:"",msg:""});try{const t=await(await o(`/api/articles/detail?slug=${e.slug}`)).json();if(t.success){_t(e.id),kt(!1),jt(null),Ct("");const r=t.data.article;
2if(ut({title:r.title||"",excerpt:r.excerpt||"",content:r.content||"",cover_image:r.cover_image||"",category:r.category||"Tax Guide",tax_year:r.tax_year||"",slug:r.slug||"",seo_title:r.seo_title||"",meta_description:r.meta_description||"",social_caption:r.social_caption||"",focus_keywords:r.focus_keywords||"",is_featured:1===parseInt(r.is_featured)||!0===r.is_featured||"1"===r.is_featured?1:0}),r.cover_image){const e=r.cover_image,t=e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")?e:`/api/${e.startsWith("/")?e.substring(1):e}`;bt(t)}else bt("");yt(null),jt(null),Ct("");const s=document.querySelector("form[onSubmit]");s&&s.scrollIntoView({behavior:"smooth",block:"center"})}else Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"Failed to fetch article details."})}finally{Ar(!1)}})(e),className:"btn btn-primary",style:{padding:"6px",borderRadius:"50%",display:"inline-flex",alignItems:"center",justifyContent:"center",marginRight:"6px",backgroundColor:"var(--accent-teal)",borderColor:"var(--accent-teal)"},title:"Edit Article",disabled:zr,children:(0,de.jsx)(F,{size:14,style:{color:"#fff"}})}),(0,de.jsx)("button",{onClick:()=>(async e=>{if(window.confirm("Are you sure you want to delete this article?")){Ar(!0),Fr({type:"",msg:""});try{const t=await(await o("/api/articles/delete",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({id:e})})).json();t.success?(Fr({type:"success",msg:t.message}),xa()):Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"Delete request failed."})}finally{Ar(!1)}}})(e.id),className:"btn btn-danger",style:{padding:"6px",borderRadius:"50%",display:"inline-flex",alignItems:"center",justifyContent:"center"},title:"Delete Article",disabled:zr,children:(0,de.jsx)(A,{size:14})})]})]},e.id))})]})})]})]})]}),"tickets"===Oe&&(0,de.jsxs)("div",{className:"glass-card",children:[(0,de.jsx)("h2",{style:Ce.tabTitle,children:"Contact Form Inquiries"}),(0,de.jsx)("p",{style:Ce.tabText,children:"Review tickets and messages submitted by public homepage visitors."}),0===me.length?(0,de.jsx)("p",{style:{textAlign:"center",padding:"40px 0",color:"var(--text-muted)"},children:"No messages received yet."}):(0,de.jsx)("div",{style:Ce.inquiriesList,children:me.map(e=>(0,de.jsxs)("div",{style:Ce.inquiryCard,children:[(0,de.jsxs)("div",{style:Ce.inquiryHeader,children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("strong",{children:e.name}),"  | ",(0,de.jsxs)("span",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:[e.email," ⢠",e.phone]})]}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)"},children:new Date(e.created_at).toLocaleString()})]}),(0,de.jsx)("h4",{style:Ce.inquirySubject,children:e.subject}),(0,de.jsx)("p",{style:Ce.inquiryMessage,children:e.message})]},e.id))})]}),"reports"===Oe&&(0,de.jsxs)("div",{className:"glass-card animate-fade-in report-printable-area",style:{padding:z?"14px":"24px"},children:[(0,de.jsxs)("div",{className:"report-print-header",style:{display:"none"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("h2",{style:{fontSize:"1.4rem",fontWeight:800,color:"#0F172A",margin:0},children:"AM TAX AND CORPORATE HUB"}),(0,de.jsxs)("p",{style:{fontSize:"0.78rem",color:"#0F766E",margin:"2px 0 0 0",fontWeight:700},children:["Official Executive Analytics & Audit Report â ","payments_audit"===Za?"Client Payments & Revenue Audit":"task_board"===Za?"Tasks & Filings Status":"ledger"===Za?"Financial Ledger & Expenses":"Agent & Team Commissions"]})]}),(0,de.jsxs)("div",{style:{textAlign:"right",fontSize:"0.75rem",color:"#64748B"},children:[(0,de.jsx)("strong",{children:"Date:"})," ",(new Date).toLocaleDateString("en-PK",{day:"numeric",month:"short",year:"numeric"}),(0,de.jsx)("br",{}),(0,de.jsx)("strong",{children:"Generated By:"})," Super Admin Portal"]})]}),(0,de.jsxs)("div",{className:"no-print",style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px",flexWrap:"wrap",gap:"14px"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("h2",{style:{...Ce.tabTitle,margin:0},children:"Reports & Executive Analytics Desk"}),(0,de.jsx)("p",{style:{...Ce.tabText,margin:"4px 0 0 0"},children:"Generate, audit, and export client revenue reports, discount logs, task boards, and financial statements."})]}),(0,de.jsxs)("div",{style:{display:"flex",gap:"10px",flexWrap:"wrap"},children:[(0,de.jsxs)("button",{type:"button",onClick:()=>{const e=[["Transaction ID","Request ID","Client Name","Company Name","Service Name","Invoiced Amount (PKR)","Verified Received (PKR)","Discount Given (PKR)","Pending Balance (PKR)","Payment Method","Verification Status","Date"]];ni.forEach(t=>{e.push([t.id,t.request_id||"",`"${(t.client_name||"").replace(/"/g,'""')}"`,`"${(t.client_company||"Client profile not specified").replace(/"/g,'""')}"`,`"${(Pa(t.service_type)||t.service_type||"").replace(/"/g,'""')}"`,t.requestedAmount||0,t.receivedAmount||0,t.discountAmount||0,t.pendingAmount||0,`"${(t.payment_method||(t.receipt_path?"Online Slip":"C
2ash")).replace(/"/g,'""')}"`,t.status||"",t.submitted_at||t.created_at||""])});const t="data:text/csv;charset=utf-8,"+e.map(e=>e.join(",")).join("\n"),r=encodeURI(t),s=document.createElement("a");s.setAttribute("href",r),s.setAttribute("download",`AMTaxHub_Client_Payments_Revenue_Report_${(new Date).toISOString().split("T")[0]}.csv`),document.body.appendChild(s),s.click(),document.body.removeChild(s)},className:"btn btn-gold",style:{padding:"10px 18px",fontSize:"0.85rem",display:"inline-flex",alignItems:"center",gap:"8px",margin:0},children:[(0,de.jsx)(r,{size:16})," Export CSV Audit"]}),(0,de.jsxs)("button",{type:"button",onClick:()=>window.print(),className:"btn btn-outline",style:{padding:"10px 18px",fontSize:"0.85rem",display:"inline-flex",alignItems:"center",gap:"8px",margin:0},children:[(0,de.jsx)(x,{size:16})," Print / Save PDF"]})]})]}),(0,de.jsx)("div",{className:"no-print",style:{display:"flex",gap:"10px",marginBottom:"24px",overflowX:"auto",paddingBottom:"4px"},children:[{id:"payments_audit",label:"ð° Client Payments & Revenue Audit",badge:`${Pt.length} Records`},{id:"task_board",label:"ð Tasks & Filings Status",badge:`${G.length} Tasks`},{id:"ledger",label:"ð Financial Ledger & Expenses",badge:`Rs. ${(Us?.summary?.total_income||li.totalReceived||0).toLocaleString()}`},{id:"commissions",label:"ð¤ Agent & Team Commissions",badge:`${Rs.length} Claims`}].map(e=>(0,de.jsxs)("button",{type:"button",onClick:()=>ei(e.id),style:{padding:"10px 18px",borderRadius:"50px",fontSize:"0.84rem",fontWeight:"700",cursor:"pointer",border:Za===e.id?"2px solid var(--accent-gold)":"1px solid var(--border)",background:Za===e.id?"rgba(201, 151, 26, 0.15)":"var(--white)",color:Za===e.id?"var(--accent-gold)":"var(--text-main)",display:"inline-flex",alignItems:"center",gap:"8px",whiteSpace:"nowrap",transition:"all 0.2s ease"},children:[(0,de.jsx)("span",{children:e.label}),(0,de.jsx)("span",{style:{fontSize:"0.7rem",padding:"2px 8px",borderRadius:"10px",background:Za===e.id?"var(--accent-gold)":"var(--bg-cool)",color:Za===e.id?"#07111F":"var(--text-muted)",fontWeight:"800"},children:e.badge})]},e.id))}),"payments_audit"===Za&&(0,de.jsxs)("div",{children:[(0,de.jsxs)("div",{style:{...Ce.statsGrid,gridTemplateColumns:z?"1fr 1fr":"repeat(4, 1fr)",gap:z?"10px":"16px",marginBottom:"24px"},children:[(0,de.jsxs)("div",{className:"glass-card",style:{padding:"18px",borderLeft:"4px solid #10B981",background:"rgba(16, 185, 129, 0.05)"},children:[(0,de.jsx)("div",{style:{fontSize:"0.73rem",fontWeight:"700",color:"#0F766E",textTransform:"uppercase",letterSpacing:"0.5px"},children:"Total Verified Revenue"}),(0,de.jsxs)("h3",{style:{fontSize:"1.45rem",fontWeight:"800",color:"#059669",margin:"6px 0 2px 0"},children:["Rs. ",li.totalReceived.toLocaleString()]}),(0,de.jsx)("span",{style:{fontSize:"0.72rem",color:"var(--text-muted)"},children:"Confirmed in Bank & Cash pool"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"18px",borderLeft:"4px solid var(--primary)",background:"rgba(7, 17, 31, 0.04)"},children:[(0,de.jsx)("div",{style:{fontSize:"0.73rem",fontWeight:"700",color:"var(--primary)",textTransform:"uppercase",letterSpacing:"0.5px"},children:"Total Invoiced Fee"}),(0,de.jsxs)("h3",{style:{fontSize:"1.45rem",fontWeight:"800",color:"var(--primary)",margin:"6px 0 2px 0"},children:["Rs. ",li.totalRequested.toLocaleString()]}),(0,de.jsx)("span",{style:{fontSize:"0.72rem",color:"var(--text-muted)"},children:"Original total fee across clients"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"18px",borderLeft:"4px solid #D4AF37",background:"rgba(212, 175, 55, 0.05)"},children:[(0,de.jsx)("div",{style:{fontSize:"0.73rem",fontWeight:"700",color:"#B45309",textTransform:"uppercase",letterSpacing:"0.5px"},children:"Total Discounts Waived"}),(0,de.jsxs)("h3",{style:{fontSize:"1.45rem",fontWeight:"800",color:"#B45309",margin:"6px 0 2px 0"},children:["Rs. ",li.totalDiscount.toLocaleString()]}),(0,de.jsx)("span",{style:{fontSize:"0.72rem",color:"var(--text-muted)"},children:"Approved price concessions"})]}),(0,de.jsxs)("div",{className:"glass-card",style:{padding:"18px",borderLeft:"4px solid #0284C7",background:"rgba(2, 132, 199, 0.05)"},children:[(0,de.jsx)("div",{style:{fontSize:"0.73rem",fontWeight:"700",color:"#0369A1",textTransform:"uppercase",letterSpacing:"0.5px"},children:"Total Outstanding Balance"}),(0,de.jsxs)("h3",{style:{fontSize:"1.45rem",fontWeight:"800",color:"#0284C7",margin:"6px 0 2px 0"}
2,children:["Rs. ",li.totalPending.toLocaleString()]}),(0,de.jsx)("span",{style:{fontSize:"0.72rem",color:"var(--text-muted)"},children:"Pending client installments"})]})]}),(0,de.jsxs)("div",{className:"no-print",style:{background:"rgba(248, 250, 252, 0.85)",border:"1px solid var(--border)",borderRadius:"12px",padding:"14px 16px",marginBottom:"20px",display:"flex",gap:"12px",flexWrap:"wrap",alignItems:"center"},children:[(0,de.jsxs)("div",{style:{flex:"1 1 240px",position:"relative"},children:[(0,de.jsx)("input",{type:"text",value:ti,onChange:e=>ri(e.target.value),placeholder:"Filter client, company, service or request ID...",className:"form-control",style:{paddingLeft:"36px",height:"38px",fontSize:"0.84rem",borderRadius:"8px"}}),(0,de.jsx)(s,{size:16,style:{position:"absolute",left:"12px",top:"50%",transform:"translateY(-50%)",color:"var(--text-muted)"}})]}),(0,de.jsx)("div",{style:{flex:"0 1 180px"},children:(0,de.jsxs)("select",{value:si,onChange:e=>ai(e.target.value),className:"form-control",style:{height:"38px",fontSize:"0.82rem",borderRadius:"8px",cursor:"pointer"},children:[(0,de.jsx)("option",{value:"all",children:"Status Filter: All"}),(0,de.jsx)("option",{value:"Verified",children:"Verified Payments"}),(0,de.jsx)("option",{value:"Partial",children:"Partial Payments"}),(0,de.jsx)("option",{value:"Requested",children:"Requested / Pending"}),(0,de.jsx)("option",{value:"Rejected",children:"Rejected"})]})}),ti||"all"!==si?(0,de.jsx)("button",{type:"button",onClick:()=>{ri(""),ai("all")},className:"btn btn-outline",style:{padding:"6px 12px",fontSize:"0.78rem",height:"38px"},children:"Reset Filters"}):null]}),(0,de.jsx)("div",{style:Ce.tableResponsive,className:"table-responsive",children:(0,de.jsxs)("table",{style:Ce.table,children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{children:[(0,de.jsx)("th",{children:"# Request & ID"}),(0,de.jsx)("th",{children:"Client & Company"}),(0,de.jsx)("th",{children:"Service Category"}),(0,de.jsx)("th",{children:"Invoiced Fee"}),(0,de.jsx)("th",{children:"Verified Received"}),(0,de.jsx)("th",{children:"Discount Given"}),(0,de.jsx)("th",{children:"Pending Balance"}),(0,de.jsx)("th",{children:"Payment Mode"}),(0,de.jsx)("th",{children:"Status"})]})}),(0,de.jsx)("tbody",{children:0===ni.length?(0,de.jsx)("tr",{children:(0,de.jsx)("td",{colSpan:"9",style:{textAlign:"center",padding:"30px",color:"var(--text-muted)"},children:"No payment records found matching current report filters."})}):ni.map(e=>(0,de.jsxs)("tr",{children:[(0,de.jsxs)("td",{children:[(0,de.jsxs)("strong",{children:["Tx #",e.id]}),(0,de.jsx)("br",{}),(0,de.jsxs)("span",{style:{fontSize:"0.74rem",color:"var(--text-muted)"},children:["Req #",e.request_id]})]}),(0,de.jsxs)("td",{children:[(0,de.jsx)("strong",{style:{color:"var(--primary)"},children:e.client_name}),(0,de.jsx)("br",{}),(0,de.jsx)("span",{style:{fontSize:"0.74rem",color:"var(--text-muted)"},children:e.client_company||"Client profile not specified"})]}),(0,de.jsx)("td",{children:(0,de.jsx)("span",{style:{fontSize:"0.82rem",fontWeight:"600"},children:Pa(e.service_type)||e.service_type||"Custom Filing"})}),(0,de.jsxs)("td",{style:{fontWeight:"700"},children:["Rs. ",e.requestedAmount.toLocaleString()]}),(0,de.jsx)("td",{children:(0,de.jsxs)("strong",{style:{color:"#059669",fontSize:"0.88rem"},children:["Rs. ",e.receivedAmount.toLocaleString()]})}),(0,de.jsx)("td",{children:e.discountAmount>0?(0,de.jsxs)("span",{style:{color:"#B45309",fontWeight:"700",fontSize:"0.84rem"},children:["Rs. ",e.discountAmount.toLocaleString()]}):(0,de.jsx)("span",{style:{color:"var(--text-muted)",fontSize:"0.78rem"},children:"Rs. 0"})}),(0,de.jsx)("td",{children:e.pendingAmount>0?(0,de.jsxs)("span",{style:{color:"#0284C7",fontWeight:"700",fontSize:"0.84rem"},children:["Rs. ",e.pendingAmount.toLocaleString()]}):(0,de.jsx)("span",{style:{color:"#059669",fontSize:"0.78rem",fontWeight:"600"},children:"Cleared"})}),(0,de.jsx)("td",{children:e.receipt_path?(0,de.jsx)("span",{style:{fontSize:"0.78rem",color:"var(--accent-teal)",fontWeight:"600"},children:"ð Slip Uploaded"}):(0,de.jsx)("span",{style:{fontSize:"0.78rem",fontWeight:"700",color:e.payment_method&&e.payment_method.toLowerCase().includes("online")?"#0284C7":"#0F766E"},children:e.payment_method&&e.payment_method.toLowerCase().includes("online")?"ð³ Online":"ðµ Cash"})}),(0,de.jsx)("td",{children:(0,de.jsx)("span",{className:"Verified"===e.status?"badge badge-completed":"Partial"===e.status?"badge badge-awaiting":"Rejected"===e.status?"badge badge-danger":"badge badge-awaiting",style:{backgroundColor:"Rejected"===e.status?"#FEE2E2":"Partial"===e.status?"#FEF3C7":void 0,color:"Rejected"===e.status?"#B91C1C":"Partial"===e.status?"#92400E":void 0},children:e.status})})]},e.id))})]})})]}),"task_board"===Za&&(0,de.jsxs)("div",{children:[(0,de.jsx)("h4",{style:{fontSize:"1rem",fontWeight:"700",color:"var(--primary)",marginBottom:"14px"},children:"Task Filings & Assignments Audit Report"}),(0,de.jsx)("div",{style:Ce.tableResponsive,className:"table-responsive",children:(0,de.jsxs)("table",{style:Ce.table,children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{children:[(0,de.jsx)("th",{children:"Req #"}),(0,de.jsx)("th",{children:"Client Name"}),(0,de.jsx)("th",{children:"Service Requested"}),(0,de.jsx)("th",{children:"Assigned Handler"}),(0,de.jsx)("th",{children:"Filing Status"}),(0,de.jsx)("th",{children:"Date Created"})]})}),(0,de.jsx)("tbody",{children:G.map(e=>(0,de.jsxs)("tr",{children:[(0,de.jsx)("td",{children:(0,de.jsxs)("strong",{children:["#",e.id]})}),(0,de.jsx)("td",{children:(0,de.jsx)("strong",{children:e.client_name})}),(0,de.jsx)("td",{children:Pa(e.service_type)}),(0,de.jsx)("td",{children:e.consultant_name||(0,de.jsx)("span",{style:{color:"#B45309",fontWeight:600},children:"Unassigned"})}),(0,de.jsx)("td",{children:(0,de.jsx)("span",{className:"badge badge-completed",children:e.status})}),(0,de.jsx)("td",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:e.created_at||"Recent"})]},e.id))})]})})]}),"ledger"===Za&&(0,de.jsxs)("div",{children:[(0,de.jsx)("h4",{style:{fontSize:"1rem",fontWeight:"700",color:"var(--primary)",marginBottom:"14px"},children:"Financial Ledger & Operational Expense Audit Report"}),(0,de.jsx)("div",{style:Ce.tableResponsive,className:"table-responsive",children:(0,de.jsxs)("table",{style:Ce.table,children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{children:[(0,de.jsx)("th",{children:"Date"}),(0,de.jsx)("th",{children:"Type"}),(0,de.jsx)("th",{children:"Category"}),(0,de.jsx)("th",{children:"Description / Service"}),(0,de.jsx)("th",{children:"Client / Reference"}),(0,de.jsx)("th",{children:"Amount (PKR)"})]})}),(0,de.jsx)("tbody",{children:Xa.map((e,t)=>(0,de.jsxs)("tr",{children:[(0,de.jsx)("td",{style:{fontSize:"0.8rem"},children:e.date}),(0,de.jsx)("td",{children:(0,de.jsx)("span",{style:{fontSize:"0.72rem",fontWeight:700,padding:"3px 8px",borderRadius:"6px",background:"income"===e.type?"#DEF7EC":"#FEE2E2",color:"income"===e.type?"#03543F":"#991B1B"},children:"income"===e.type?"INCOME":"EXPENSE"})}),(0,de.jsx)("td",{style:{fontWeight:600},children:e.category}),(0,de.jsx)("td",{children:e.title||e.service_name||e.service_type}),(0,de.jsx)("td",{children:e.client_name||"N/A"}),(0,de.jsxs)("td",{style:{fontWeight:700,color:"income"===e.type?"#059669":"#DC2626"},children:["income"===e.type?"+":"-"," Rs. ",e.amount.toLocaleStr
2ing()]})]},t))})]})})]}),"commissions"===Za&&(0,de.jsxs)("div",{children:[(0,de.jsx)("h4",{style:{fontSize:"1rem",fontWeight:"700",color:"var(--primary)",marginBottom:"14px"},children:"Agent & Team Commissions Audit Report"}),(0,de.jsx)("div",{style:Ce.tableResponsive,className:"table-responsive",children:(0,de.jsxs)("table",{style:Ce.table,children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{children:[(0,de.jsx)("th",{children:"Claim ID"}),(0,de.jsx)("th",{children:"Agent Name"}),(0,de.jsx)("th",{children:"Service Task"}),(0,de.jsx)("th",{children:"Calculated Commission"}),(0,de.jsx)("th",{children:"Status"})]})}),(0,de.jsx)("tbody",{children:Rs.map(e=>(0,de.jsxs)("tr",{children:[(0,de.jsx)("td",{children:(0,de.jsxs)("strong",{children:["#",e.id]})}),(0,de.jsx)("td",{children:(0,de.jsx)("strong",{children:e.agent_name||e.agent_email})}),(0,de.jsx)("td",{children:e.service_type||`Request #${e.request_id}`}),(0,de.jsxs)("td",{style:{fontWeight:"700",color:"#059669"},children:["Rs. ",parseFloat(e.commission_amount||0).toLocaleString()]}),(0,de.jsx)("td",{children:(0,de.jsx)("span",{className:"paid"===e.commission_status?"badge badge-completed":"badge badge-awaiting",children:"paid"===e.commission_status?"PAID":"UNPAID"})})]},e.id))})]})})]})]}),"payments"===Oe&&(0,de.jsxs)("div",{className:"glass-card animate-fade-in",children:[(0,de.jsx)("h2",{style:Ce.tabTitle,children:"Payments Ledger Manager"}),(0,de.jsx)("p",{style:Ce.tabText,children:"Verify user-submitted transaction receipts, review payment requests, and track total filing revenues."}),0===Pt.length?(0,de.jsx)("p",{style:{textAlign:"center",padding:"40px 0",color:"var(--text-muted)"},children:"No payment transactions found in database."}):(0,de.jsx)("div",{style:Ce.tableResponsive,className:"table-responsive",children:(0,de.jsxs)("table",{style:Ce.table,children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{children:[(0,de.jsx)("th",{children:"Transaction Info"}),(0,de.jsx)("th",{children:"Client Details"}),(0,de.jsx)("th",{children:"Amount Slabs"}),(0,de.jsx)("th",{children:"Receipt Attachment"}),(0,de.jsx)("th",{children:"Filing Status"}),(0,de.jsx)("th",{children:"Verifications"})]})}),(0,de.jsx)("tbody",{children:Pt.map(e=>(0,de.jsxs)("tr",{children:[(0,de.jsxs)("td",{children:[(0,de.jsxs)("strong",{children:["Transaction #",e.id]}),(0,de.jsx)("br",{}),(0,de.jsxs)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)"},children:["Request ID: #",e.request_id]})]}),(0,de.jsxs)("td",{children:[(0,de.jsx)("strong",{children:e.client_name}),(0,de.jsx)("br",{}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)"},children:e.client_company||"Client profile not specified"})]}),(0,de.jsx)("td",{children:(()=>{const t=Fa(e);return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsxs)("strong",{style:{color:"var(--primary)"},children:["Rs. ",t.requestedAmount.toLocaleString()]}),e.verified_amount?(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("br",{}),(0,de.jsxs)("span",{style:{fontSize:"0.75rem",color:"#0F766E"},children:["Received: Rs. ",t.receivedAmount.toLocaleString()]})]}):null,t.hasDiscount?(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("br",{}),(0,de.jsxs)("span",{style:{fontSize:"0.75rem",color:"#B45309"},children:["Discount: Rs. ",t.discountAmount.toLocaleString()]})]}):null]})})()}),(0,de.jsx)("td",{children:e.receipt_path?(0,de.jsxs)("a",{href:`/api/${e.receipt_path}`,target:"_blank",rel:"noreferrer",className:"btn btn-outline",style:{padding:"6px 12px",fontSize:"0.75rem",margin:0,display:"inline-flex",gap:"4px"},children:[(0,de.jsx)(r,{size:12})," View Slip"]}):"Verified"===e.status||"Partial"===e.status?(0,de.jsx)("span",{style:{fontSize:"0.8rem",color:e.payment_method&&e.payment_method.toLowerCase().includes("online")?"#0284C7":"#0F766E",fontWeight:"700",display:"inline-flex",alignItems:"center",gap:"4px"},children:e.payment_method&&e.payment_method.toLowerCase().includes("online")?"ð³ Online received":"ðµ Cash received"}):(0,de.jsx)("span",{style:{fontSize:"0.8rem",color:"var(--text-muted)",fontStyle:"italic"},children:"No receipt (Requested)"})}),(0,de.jsx)("td",{children:(0,de.jsx)("span",{className:"Verified"===e.status?"badge badge-completed":"Partial"===e.status?"badge badge-awaiting":"Rejected"===e.status?"badge badge-danger":"badge badge-awaiting",style:{backgroundColor:"Rejected"===e.status?"#FEE2E2":"Partial"===e.status?"#FEF3C7":void 0,color:"Rejected"===e.status?"#B91C1C":"Partial"===e.status?"#92400E":void 0},children:e.status})}),(0,de.jsx)("td",{children:(0,de.jsxs)("div",{style:{display:"flex",gap:"6px",alignItems:"center"},children:["Pending"===e.status?(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("button",{onClick:()=>Ra(e.request_id,"Verified","receipt",e),className:"btn btn-primary",style:{padding:"6px 12px",fontSize:"0.75rem",margin:0},disabled:zr,children:"Approve"}),(0,de.jsx)("button",{onClick:()=>{const t=prompt("Enter Rejection Reason:","Invalid transaction receipt screenshot. Please re-upload.");null!==t&&(At(t),o("/api/payments/verify",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({request_id:e.request_id,status:"Rejected",comment:t})}).then(e=>e.json()).then(e=>{e.success?(Fr({type:"success",msg:e.message}),ya(),oa()):Fr({type:"error",msg:e.message})}))},className:"btn btn-danger",style:{padding:"6px 12px",fontSize:"0.75rem",margin:0},disabled:zr,children:"Reject"})]}):"Requested"===e.status||"Partial"===e.status?(0,de.jsxs)("div",{style:{display:"inline-flex",gap:"6px"},children:[(0,de.jsx)("button",{onClick:()=>Ra(e.request_id,"Verified","cash",e),className:"btn btn-primary",style:{padding:"6px 10px",fontSize:"0.73rem",margin:0},disabled:zr,title:"Mark payment as received in cash",children:"ðµ Cash"}),(0,de.jsx)("button",{onClick:()=>Ra(e.request_id,"Verified","online",e),className:"btn btn-gold",style:{padding:"6px 10px",fontSize:"0.73rem",margin:0},disabled:zr,title:"Mark payment as received via direct online bank transfer",children:"ð³ Online"}),(0,de.jsx)("button",{type:"button",onClick:()=>Ia(e.request_id),className:"btn btn-outline",style:{padding:"6px 10px",fontSize:"0.73rem",margin:0,borderColor:"#D4AF37",color:"#B45309",display:"inline-flex",alignItems:"center",gap:"3px"},disabled:zr,title:"Send reminder email for pending payment",children:"ð Remind"})]}):(0,de.jsx)("span",{style:{fontSize:"0.8rem",color:"var(--text-muted)"},children:"Processed"}),(0,de.jsxs)("button",{onClick:()=>(async e=>{if(window.confirm("Are you sure you want to permanently delete this payment record?")){Ar(!0);try{const t=await(await o("/api/payments/delete",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({id:e})})).json();t.success?(Fr({type:"success",msg:t.message}),ya(),oa()):Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"Failed to delete payment record."})}finally{Ar(!1)}}})(e.id),className:"btn btn-danger",style:{padding:"6px 12px",fontSize:"0.75rem",margin:0,display:"inline-flex",alignItems:"center",gap:"4px"},disabled:zr,title:"Delete Payment Record",children:[(0,de.jsx)(A,{size:12})," Delete"]})]})})]},e.id))})]})})]}),"commissions"===Oe&&(0,de.jsxs)("div",{className:"glass-card animate-fade-in",children:[(0,de.jsx)("h2",{style:Ce.tabTitle,children:"Referred Clients Commissions Desk"}),(0,de.jsx)("p",{style:Ce.tabText,children:"Manage marketing agent referred clients, verify received payments, assign referral commissions, and process payout statuses."}),Nr?(0,de.jsx)("p",{style:{textAlign:"center",padding:"40px 0",color:"var(--text-muted)"},children:"Loading referred commission logs..."}):0===Rs.length?(0,de.jsx)("p",{style:{textAlign:"center",padding:"40px 0",color:"var(--text-muted)"},children:"No referrals or marketing agent request logs found."}):(0,de.jsx)("div",{style:Ce.tableResponsive,children:(0,de.jsxs)("table",{style:Ce.table,children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{children:[(0,de.jsx)("th",{children:"Request ID"}),(0,de.jsx)("th",{children:"Agent Partner"}),(0,de.jsx)("th",{children:"Client Referral"}),(0,de.jsx)("th",{children:"Service Type"}),(0,de.jsx)("th",{children:"Client Payment"}),(0,de.jsx)("th",{children:"Commission (Rs.)"}),(0,de.jsx)("th",{children:"Payout Status"}),(0,de.jsx)("th",{children:"Actions"})]})}),(0,de.jsx)("tbody",{children:Rs.map(e=>{const t=Is===e.id;return(0,de.jsxs)("tr",{children:[(0,de.jsxs)("td",{children:["#",e.id]}),(0,de.jsxs)("td",{children:[(0,de.jsx)("strong",{children:e.agent_name}),(0,de.jsx)("br",{}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)"},children:e.agent_email})]}),(0,de.jsxs)("td",{children:[(0,de.jsx)("strong",{children:e.client_name||"N/A"}),(0,de.jsx)("br",{}),(0,de.jsxs)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)"},children:["Mob: ",e.client_phone||"N/A"]})]}),(0,de.jsx)("td",{children:Pa(e.service_type)}),(0,de.jsxs)("td",{children:[(0,de.jsxs)("strong",{children:["Rs. ",e.payment_amount?parseFloat(e.payment_amount).toLocaleStr
2ing():"0"]}),(0,de.jsx)("br",{}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",fontWeight:"700",color:"Verified"===e.payment_status?"#16A34A":"#EA580C"},children:e.payment_status||"Unpaid"})]}),(0,de.jsx)("td",{children:t?(0,de.jsx)("input",{type:"number",value:Ps.commission_amount,onChange:e=>Es({...Ps,commission_amount:e.target.value}),className:"form-control",style:{margin:0,padding:"4px 8px",fontSize:"0.85rem",width:"100px"}}):(0,de.jsx)("strong",{children:e.commission_amount?`Rs. ${parseFloat(e.commission_amount).toLocaleString()}`:"Not set"})}),(0,de.jsx)("td",{children:t?(0,de.jsxs)("select",{value:Ps.commission_status,onChange:e=>Es({...Ps,commission_status:e.target.value}),className:"form-control",style:{margin:0,padding:"4px 8px",fontSize:"0.85rem",width:"100px"},children:[(0,de.jsx)("option",{value:"unpaid",children:"UNPAID"}),(0,de.jsx)("option",{value:"paid",children:"PAID"})]}):(0,de.jsx)("span",{style:{padding:"4px 10px",borderRadius:"50px",fontSize:"0.75rem",fontWeight:"700",textTransform:"uppercase",backgroundColor:"paid"===e.commission_status?"#DEF7EC":"#FDE8E8",color:"paid"===e.commission_status?"#03543F":"#9B1C1C"},children:e.commission_status||"unpaid"})}),(0,de.jsx)("td",{children:(0,de.jsx)("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:t?(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("button",{onClick:()=>(async(e,t,r)=>{Ar(!0);try{const s=await(await o("/api/admin/update-commission",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({request_id:e,commission_amount:t,commission_status:r})})).json();s.success?(Fr({type:"success",msg:s.message}),Ds(null),Na()):Fr({type:"error",msg:s.message})}catch(s){Fr({type:"error",msg:"Failed to update commission details."})}finally{Ar(!1)}})(e.id,Ps.commission_amount,Ps.commission_status),className:"btn btn-gold",style:{padding:"6px 12px",fontSize:"0.75rem",margin:0},children:"Save"}),(0,de.jsx)("button",{onClick:()=>Ds(null),className:"btn btn-outline",style:{padding:"6px 12px",fontSize:"0.75rem",margin:0},children:"Cancel"})]}):(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("button",{onClick:()=>{Ds(e.id),Es({commission_amount:e.commission_amount||"",commission_status:e.commission_status||"unpaid"})},className:"btn btn-outline",style:{padding:"6px 12px",fontSize:"0.75rem",margin:0},children:"Edit"}),(0,de.jsx)("button",{onClick:()=>{let t=null;try{t=JSON.parse(e.agent_payment_details)}catch(r){t=e.agent_payment_details}Ls({agent_name:e.agent_name,details:t})},className:"btn btn-primary",style:{padding:"6px 12px",fontSize:"0.75rem",margin:0,borderRadius:"4px"},children:"Payout Account"})]})})})]},e.id)})})]})})]}),"services"===Oe&&(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"30px"},children:[(0,de.jsxs)("div",{style:{display:"flex",gap:"12px",background:"var(--card-bg)",padding:"12px 18px",borderRadius:"14px",border:"1px solid var(--border)"},children:[(0,de.jsx)("button",{onClick:()=>Xt("pakistan"),style:{padding:"10px 22px",borderRadius:"50px",fontWeight:"800",fontSize:"0.88rem",border:"pakistan"===Kt?"none":"1px solid var(--border)",cursor:"pointer",background:"pakistan"===Kt?"var(--accent-teal)":"transparent",color:"pakistan"===Kt?"#FFFFFF":"var(--text-muted)",transition:"all 0.2s ease"},children:"ðµð° Pakistan Services Directory"}),(0,de.jsxs)("button",{onClick:()=>Xt("uae"),style:{padding:"10px 22px",borderRadius:"50px",fontWeight:"800",fontSize:"0.88rem",border:"uae"===Kt?"none":"1px solid var(--border)",cursor:"pointer",background:"uae"===Kt?"var(--accent-gold)":"transparent",color:"uae"===Kt?"#000000":"var(--text-muted)",transition:"all 0.2s ease"},children:["ð¦ðª UAE Corporate Services Hub (",Qt.length,")"]})]}),"uae"===Kt&&(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{display:"flex",flexDirection:"column",gap:"24px"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:"12px"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("h2",{style:{...Ce.tabTitle,display:"flex",alignItems:"center",gap:"8px"},children:"ð¦ðª UAE Corporate Services Directory"}),(0,de.jsx)("p",{style:Ce.tabText,children:"Add, edit, or remove UAE Corporate Tax, VAT, and Freezone/Mainland company formation services."})]}),(0,de.jsxs)("button",{onClick:()=>{tr("new"),sr({id:`uae-${Date.now()}`,service_key:`uae_custom_${Date.now()}`,service_name:"",category:"Taxation & Compliance",price_label:"Free Consult / Best Quote",short_description:"",eligibility:"",processing_time:"3 - 5 Days",icon_name:"Building",slug:"",is_featured:!0,required_docs:""})},className:"btn btn-gold",style:{display:"inline-flex",alignItems:"center",gap:"8px",padding:"10px 18px",fontSize:"0.85rem"},children:[(0,de.jsx)(n,{size:16})," Add New UAE Service"]})]}),er&&(0,de.jsxs)("div",{style:{background:"var(--bg-cool)",border:"2px s
2olid var(--accent-gold)",borderRadius:"16px",padding:"24px",boxShadow:"var(--shadow-md)"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"18px"},children:[(0,de.jsx)("h3",{style:{margin:0,fontSize:"1.1rem",fontWeight:"800",color:"var(--primary)"},children:"new"===er?"â Add New UAE Service":`âï¸ Edit UAE Service: ${rr.service_name}`}),(0,de.jsxs)("button",{onClick:()=>tr(null),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)"},children:[(0,de.jsx)(A,{size:16})," Close Form"]})]}),(0,de.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),!rr.service_name.trim())return void Fr({type:"error",msg:"Service Name is required."});const t=rr.required_docs.split("\n").map(e=>e.trim()).filter(Boolean),r=rr.slug||rr.service_name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),s={...rr,slug:r,required_docs:t.length>0?t:["Trade License","Passport Copy","Emirates ID"]};let a=[];a="new"===er?[s,...Qt]:Qt.map(e=>e.id===s.id?s:e),Zt(a),ie(a),tr(null),Fr({type:"success",msg:"UAE Service saved successfully!"})},children:[(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:z?"1fr":"1fr 1fr",gap:"16px",marginBottom:"16px"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:{display:"block",fontSize:"0.82rem",fontWeight:"700",marginBottom:"6px",color:"var(--text-main)"},children:"Service Title / Name *"}),(0,de.jsx)("input",{type:"text",required:!0,placeholder:"e.g. UAE Corporate Tax Registration",value:rr.service_name,onChange:e=>sr({...rr,service_name:e.target.value}),style:{width:"100%",padding:"10px 14px",borderRadius:"10px",border:"1px solid var(--border)",background:"var(--card-bg)",color:"var(--text-main)",fontSize:"0.88rem"}})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:{display:"block",fontSize:"0.82rem",fontWeight:"700",marginBottom:"6px",color:"var(--text-main)"},children:"Category *"}),(0,de.jsxs)("select",{value:rr.category,onChange:e=>sr({...rr,category:e.target.value}),style:{width:"100%",padding:"10px 14px",borderRadius:"10px",border:"1px solid var(--border)",background:"var(--card-bg)",color:"var(--text-main)",fontSize:"0.88rem"},children:[(0,de.jsx)("option",{value:"Taxation & Compliance",children:"Taxation & Compliance"}),(0,de.jsx)("option",{value:"Company Formation",children:"Company Formation"}),(0,de.jsx)("option",{value:"Advisory & Audit",children:"Advisory & Audit"})]})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:{display:"block",fontSize:"0.82rem",fontWeight:"700",marginBottom:"6px",color:"var(--text-main)"},children:"Processing Time"}),(0,de.jsx)("input",{type:"text",placeholder:"e.g. 3 - 5 Days",value:rr.processing_time,onChange:e=>sr({...rr,processing_time:e.target.value}),style:{width:"100%",padding:"10px 14px",borderRadius:"10px",border:"1px solid var(--border)",background:"var(--card-bg)",color:"var(--text-main)",fontSize:"0.88rem"}})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:{display:"block",fontSize:"0.82rem",fontWeight:"700",marginBottom:"6px",color:"var(--text-main)"},children:"Icon Name"}),(0,de.jsxs)("select",{value:rr.icon_name,onChange:e=>sr({...rr,icon_name:e.target.value}),style:{width:"100%",padding:"10px 14px",borderRadius:"10px",border:"1px solid var(--border)",background:"var(--card-bg)",color:"var(--text-main)",fontSize:"0.88rem"},children:[(0,de.jsx)("option",{value:"Building",children:"Building (Company/Mainland)"}),(0,de.jsx)("option",{value:"FileText",children:"FileText (Tax/VAT)"}),(0,de.jsx)("option",{value:"FileSpreadsheet",children:"FileSpreadsheet (Returns)"}),(0,de.jsx)("option",{value:"CheckCircle2",children:"CheckCircle2 (Compliance)"}),(0,de.jsx)("option",{value:"Award",children:"Award (Freezone)"}),(0,de.jsx)("option",{value:"ShieldCheck",children:"ShieldCheck (Refunds/Audit)"}),(0,de.jsx)("option",{value:"Briefcase",children:"Briefcase (General)"})]})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:{display:"block",fontSize:"0.82rem",fontWeight:"700",marginBottom:"6px",color:"var(--text-main)"},children:"Price in AED (Dirhams) â Enter 0 for Free Consult"}),(0,de.jsx)("input",{type:"number",min:"0",placeholder:"0 (e.g. 500, 1200)",value:rr.price||0,onChange:e=>{const t=parseFloat(e.target.value)||0;sr({...rr,price:t,price_label:t>
20?`AED ${t.toLocaleString()}`:"Free Consult / Best Quote"})},style:{width:"100%",padding:"10px 14px",borderRadius:"10px",border:"1px solid var(--border)",background:"var(--card-bg)",color:"var(--text-main)",fontSize:"0.88rem"}})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("label",{style:{display:"block",fontSize:"0.82rem",fontWeight:"700",marginBottom:"6px",color:"var(--text-main)"},children:"Display Price Tag / Badge"}),(0,de.jsx)("input",{type:"text",placeholder:"e.g. Free Consult / Best Quote or AED 500",value:rr.price_label||(rr.price>0?`AED ${rr.price}`:"Free Consult / Best Quote"),onChange:e=>sr({...rr,price_label:e.target.value}),style:{width:"100%",padding:"10px 14px",borderRadius:"10px",border:"1px solid var(--border)",background:"var(--card-bg)",color:"var(--text-main)",fontSize:"0.88rem"}})]})]}),(0,de.jsxs)("div",{style:{marginBottom:"16px"},children:[(0,de.jsx)("label",{style:{display:"block",fontSize:"0.82rem",fontWeight:"700",marginBottom:"6px",color:"var(--text-main)"},children:"Short Description / Scope"}),(0,de.jsx)("textarea",{rows:2,placeholder:"Brief description of what this service covers...",value:rr.short_description,onChange:e=>sr({...rr,short_description:e.target.value}),style:{width:"100%",padding:"10px 14px",borderRadius:"10px",border:"1px solid var(--border)",background:"var(--card-bg)",color:"var(--text-main)",fontSize:"0.88rem"}})]}),(0,de.jsxs)("div",{style:{marginBottom:"16px"},children:[(0,de.jsx)("label",{style:{display:"block",fontSize:"0.82rem",fontWeight:"700",marginBottom:"6px",color:"var(--text-main)"},children:"Required Documents (Enter 1 document per line)"}),(0,de.jsx)("textarea",{rows:4,placeholder:"Trade License / Certificate of Incorporation\nPassport Copies of Directors\nEmirates ID\nBank Account Statement",value:rr.required_docs,onChange:e=>sr({...rr,required_docs:e.target.value}),style:{width:"100%",padding:"10px 14px",borderRadius:"10px",border:"1px solid var(--border)",background:"var(--card-bg)",color:"var(--text-main)",fontSize:"0.88rem",fontFamily:"monospace"}})]}),(0,de.jsxs)("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end"},children:[(0,de.jsx)("button",{type:"button",onClick:()=>tr(null),className:"btn btn-outline",style:{padding:"8px 18px",fontSize:"0.85rem"},children:"Cancel"}),(0,de.jsx)("button",{type:"submit",className:"btn btn-gold",style:{padding:"8px 24px",fontSize:"0.85rem"},children:"Save UAE Service"})]})]})]}),(0,de.jsx)("div",{style:{overflowX:"auto"},children:(0,de.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",textAlign:"left",fontSize:"0.88rem"},children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{style:{background:"var(--bg-cool)",borderBottom:"2px solid var(--border)"},children:[(0,de.jsx)("th",{style:{padding:"12px 16px",color:"var(--text-muted)"},children:"Service Name"}),(0,de.jsx)("th",{style:{padding:"12px 16px",color:"var(--text-muted)"},children:"Category"}),(0,de.jsx)("th",{style:{padding:"12px 16px",color:"var(--text-muted)"},children:"Fee (AED)"}),(0,de.jsx)("th",{style:{padding:"12px 16px",color:"var(--text-muted)"},children:"Timeline"}),(0,de.jsx)("th",{style:{padding:"12px 16px",color:"var(--text-muted)"},children:"Required Docs"}),(0,de.jsx)("th",{style:{padding:"12px 16px",color:"var(--text-muted)",textAlign:"right"},children:"Actions"})]})}),(0,de.jsx)("tbody",{children:Qt.map(e=>(0,de.jsxs)("tr",{style:{borderBottom:"1px solid var(--border)"},children:[(0,de.jsx)("td",{style:{padding:"14px 16px",fontWeight:"700",color:"var(--primary)"},children:(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,de.jsx)("span",{children:"ð¦ðª"}),(0,de.jsx)("span",{children:e.service_name})]})}),(0,de.jsx)("td",{style:{padding:"14px 16px"},children:(0,de.jsx)("span",{style:{background:"rgba(30,168,199,0.1)",color:"var(--accent-teal)",padding:"3px 10px",borderRadius:"50px",fontSize:"0.75rem",fontWeight:"700"},children:e.category})}),(0,de.jsx)("td",{style:{padding:"14px 16px",fontWeight:"700",color:"var(--accent-gold)"},children:Number(e.price)>
20?`AED ${parseFloat(e.price).toLocaleString()}`:e.price_label||"Free Consult / Best Quote"}),(0,de.jsx)("td",{style:{padding:"14px 16px",color:"var(--text-muted)"},children:e.processing_time||"3-5 Days"}),(0,de.jsx)("td",{style:{padding:"14px 16px"},children:(0,de.jsxs)("span",{style:{fontWeight:"700",color:"var(--accent-gold)"},children:[Array.isArray(e.required_docs)?e.required_docs.length:0," Docs Listed"]})}),(0,de.jsx)("td",{style:{padding:"14px 16px",textAlign:"right"},children:(0,de.jsxs)("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[(0,de.jsxs)("button",{onClick:()=>{tr(e),sr({...e,required_docs:Array.isArray(e.required_docs)?e.required_docs.join("\n"):""})},className:"btn btn-outline",style:{padding:"6px 12px",fontSize:"0.78rem",gap:"4px"},children:[(0,de.jsx)(F,{size:14})," Edit"]}),(0,de.jsx)("button",{onClick:()=>{if(window.confirm(`Are you sure you want to delete UAE Service "${e.service_name}"?`)){const t=Qt.filter(t=>t.id!==e.id);Zt(t),ie(t),Fr({type:"success",msg:"UAE Service deleted."})}},className:"btn btn-outline",style:{padding:"6px 12px",fontSize:"0.78rem",color:"#EF4444",borderColor:"rgba(239, 68, 68, 0.3)"},children:(0,de.jsx)(A,{size:14})})]})})]},e.id))})]})})]}),"pakistan"===Kt&&(0,de.jsxs)("div",{className:"glass-card animate-fade-in",children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("h2",{style:Ce.tabTitle,children:"Corporate Services Directory"}),(0,de.jsx)("p",{style:Ce.tabText,children:"Configure standard pricing models and required intake documents for each advisory service."})]}),(0,de.jsxs)("button",{onClick:()=>{qt("new"),Gt(!1),Ht(""),Jt(""),Mt({id:0,service_name:"",price:0,required_docs:"",short_description:"",processing_time:"",eligible_persons:"",icon_name:"",slug:"",sort_order:1,is_featured:!1,is_active:!0}),setTimeout(()=>{document.getElementById("service-form-card")?.scrollIntoView({behavior:"smooth"})},100)},className:"btn btn-gold",style:{display:"inline-flex",alignItems:"center",gap:"8px",padding:"10px 16px",fontSize:"0.85rem"},children:[(0,de.jsx)(n,{size:16})," Add New Service"]})]}),0===Wt.length?(0,de.jsxs)("div",{style:{padding:"40px 20px",textAlign:"center",background:"#FFFDF5",border:"1.5px dashed var(--accent-gold)",borderRadius:"8px"},children:[(0,de.jsx)(E,{size:36,style:{color:"#D4AF37",marginBottom:"12px",display:"inline-block"}}),(0,de.jsx)("h4",{style:{color:"var(--primary)",fontFamily:"var(--font-heading)",fontWeight:"700",marginBottom:"8px"},children:"No Services Catalog Found"}),(0,de.jsx)("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem",maxWidth:"440px",margin:"0 auto 16px auto",lineHeight:"1.5"},children:"It looks like the dynamic services catalog table is empty in your live database. You can seed the default corporate services (Income Tax, Sales Tax, SECP, Trademarks) with a single click."}),(0,de.jsx)("button",{onClick:async()=>{Ar(!0),Fr({type:"",msg:""});try{const e=await(await o("/api/admin/seed-services",{method:"POST",headers:{Authorization:`Bearer ${g}`}})).json();e.success?(Fr({type:"success",msg:e.message}),fa()):Fr({type:"error",msg:e.message})}catch(e){Fr({type:"error",msg:"Connection error: Failed to seed services."})}finally{Ar(!1)}},className:"btn btn-gold",style:{margin:0,padding:"10px 24px",fontSize:"0.85rem"},disabled:zr,children:zr?"Initializing Catalog...":"Seed Default Services Catalog"})]}):(0,de.jsx)("div",{style:Ce.tableResponsive,className:"table-responsive",children:(0,de.jsxs)("table",{style:Ce.table,children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{children:[(0,de.jsx)("th",{style:{width:"80px",textAlign:"center"},children:"Pos"}),(0,de.jsx)("th",{children:"Service Title"}),(0,de.jsx)("th",{children:"Filing Price Slab"}),(0,de.jsx)("th",{style:{width:"150px",textAlign:"center"},children:"Status on Site"}),(0,de.jsx)("th",{style:{width:"150px"},children:"Action"})]})}),(0,de.jsx)("tbody",{children:Wt.map(e=>{const t=void 0===e.is_active||!!e.is_active;return(0,de.jsxs)("tr",{children:[(0,de.jsx)("td",{style:{textAlign:"center"},children:(0,de.jsx)("span",{style:{padding:"4px 10px",background:"var(--bg-cool)",color:"var(--primary)",borderRadius:"6px",fontWeight:"700",fontSize:"0.8rem",border:"1px solid var(--border)"},children:e.sort_order||1})}),(0,de.jsx)("td",{children:(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[(0,de.jsx)("strong",{style:{color:"var(--primary)"},children:e.service_name}),!!e.is_featured&&(0,de.jsx)("span",{style:{fontSize:"0.65rem",fontWeight:"800",color:"#D4AF37",letterSpacing:"0.3px",textTransform:"uppercase"},children:"â
Featured"})]})}),(0,de.jsx)("td",{children:(0,de.jsxs)("strong",{style:{color:"var(--accent-teal)"}
2,children:["Rs. ",parseFloat(e.price).toLocaleString()]})}),(0,de.jsx)("td",{style:{textAlign:"center"},children:(0,de.jsxs)("button",{type:"button",onClick:()=>(async e=>{Ar(!0),Fr({type:"",msg:""});try{const t=void 0===e.is_active||!!e.is_active,r={id:e.id,service_name:e.service_name||"",price:parseFloat(e.price)||0,required_docs:e.required_docs||"",short_description:e.short_description||"",processing_time:e.processing_time||"",eligible_persons:e.eligible_persons||"",icon_name:e.icon_name||"",slug:e.slug||"",sort_order:parseInt(e.sort_order)||1,is_featured:!!e.is_featured,is_active:!t},s=await(await o("/api/services/update-service",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify(r)})).json();s.success?(Fr({type:"success",msg:`"${e.service_name}" status updated successfully.`}),fa()):Fr({type:"error",msg:s.message})}catch(t){Fr({type:"error",msg:"Failed to update service status."})}finally{Ar(!1)}})(e),disabled:zr,style:{padding:"5px 12px",fontSize:"0.75rem",borderRadius:"50px",fontWeight:"800",cursor:"pointer",border:"none",transition:"all 0.2s",background:t?"rgba(37, 211, 102, 0.15)":"rgba(100, 116, 139, 0.12)",color:t?"#25D366":"#64748B",display:"inline-flex",alignItems:"center",gap:"5px"},children:[(0,de.jsx)("span",{style:{width:"6px",height:"6px",borderRadius:"50%",background:t?"#25D366":"#64748B",display:"inline-block"}}),t?"Show (Active)":"Hide (Draft)"]})}),(0,de.jsx)("td",{children:(0,de.jsxs)("div",{style:{display:"flex",gap:"6px"},children:[(0,de.jsx)("button",{type:"button",onClick:()=>{qt(e);let t=!1,r="",s="";try{if(e.required_docs&&e.required_docs.startsWith("{")){const a=JSON.parse(e.required_docs);a&&a.has_dual&&(t=!0,r=a.individual||"",s=a.business||"")}}catch(a){}Gt(t),Ht(r),Jt(s),Mt({id:e.id,service_name:e.service_name||"",price:e.price||0,required_docs:e.required_docs||"",short_description:e.short_description||"",processing_time:e.processing_time||"",eligible_persons:e.eligible_persons||"",icon_name:e.icon_name||"",slug:e.slug||"",sort_order:e.sort_order||1,is_featured:!!e.is_featured,is_active:void 0===e.is_active||!!e.is_active}),setTimeout(()=>{document.getElementById("service-form-card")?.scrollIntoView({behavior:"smooth"})},100)},className:"btn btn-outline",style:{padding:"6px 12px",fontSize:"0.75rem",margin:0},children:"Edit Settings"}),(0,de.jsx)("button",{type:"button",onClick:()=>(async e=>{if(window.confirm("Are you sure you want to permanently delete this service?")){Ar(!0),Fr({type:"",msg:""});try{const t=await(await o("/api/services/delete-service",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({id:e})})).json();t.success?(Fr({type:"success",msg:t.message}),fa()):Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"Failed to delete service."})}finally{Ar(!1)}}})(e.id),className:"btn btn-danger",style:{padding:"6px 10px",fontSize:"0.75rem",margin:0,display:"inline-flex",alignItems:"center"},title:"Delete Service",children:(0,de.jsx)(A,{size:13})})]})})]},e.id)})})]})})]}),(0,de.jsxs)("div",{id:"service-form-card",className:"glass-card animate-fade-in",style:{background:"var(--white)",alignSelf:"start"},children:[(0,de.jsxs)("h3",{style:Ce.subBlockTitle,children:[(0,de.jsx)(E,{size:18})," ","new"===Ot?"Add New Corporate Service":Ot?`Edit Service: ${Ot.service_name}`:"Select Service to Configure"]}),(0,de.jsx)("p",{style:{color:"var(--text-muted)",fontSize:"0.8rem",marginBottom:"20px"},children:Ot?"Update the details, pricing, required documents, and public display settings for this service.":'Click "Edit Settings" on any service on the left directory to customize its details.'}),Ot&&(0,de.jsxs)("form",{onSubmit:async e=>{e.preventDefault(),Ar(!0),Fr({type:"",msg:""});try{const e="new"===Ot,t=e?"/api/services/add-service":"/api/services/update-service";let r=$t.required_docs;Ut&&(r=JSON.stringify({has_dual:!0,individual:Vt,business:Yt}));const s={service_name:$t.service_name,price:parseFloat($t.price),required_docs:r,short_description:$t.short_description,processing_time:$t.processing_time,eligible_persons:$t.eligible_persons,icon_name:$t.icon_name,slug:$t.slug,sort_order:parseInt($t.sort_order)||0,is_featured:!!$t.is_featured,is_active:!!$t.is_active};e||(s.id=$t.id);const a=await(await o(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify(s)})).json();a.success?(Fr({type:"success",msg:a.message}),qt(null),Gt(!1),Ht(""),Jt(""),Mt({id:0,service_name:"",price:0,required_docs:"",short_description:"",processing_time:"",eligible_persons:"",icon_name:"",slug:"",sort_order:1,is_featured:!1,is_active:!0}),fa()):Fr({type:"error",msg:a.message})}catch(t){Fr({type:"error",msg:"Failed to update service details."})}finally{Ar(!1)}},children:[(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:z?"1fr":"1fr 1fr",gap:z?"16px":"20px"},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Service Public Title"}),(0,de.jsx)("input",{type:"text",value:$t.service_name,onChange:e=>Mt({...$t,service_name:e.target.value}),className:"form-control",required:!0})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Filing Price (Rs.)"}),(0,de.jsx)("input",{type:"number",value:$t.price,onChange:e=>Mt({...$t,price:e.target.value}),className:"form-control",required:!0,min:"0"})]})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Short Description"}),(0,de.jsx)("input",{type:"text",value:$t.short_description,onChange:e=>Mt({...$t,short_description:e.target.value}),className:"form-control",placeholder:"e.g. Complete SECP Registration with fast processing"})]}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:z?"1fr":"1fr 1fr",gap:z?"16px":"20px"},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"URL Slug (Auto-generated if empty)"}),(0,de.jsx)("input",{type:"text",value:$t.slug,onChange:e=>Mt({...$t,slug:e.target.value}),className:"form-control",placeholder:"e.g. ntn-registration"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Display Sort Order"}),(0,de.jsx)("select",{value:$t.sort_order,onChange:e=>Mt({...$t,sort_order:parseInt(e.target.value)||1}),className:"form-control",children:Array.from({length:Math.max(50,(Wt?.length||0)+10)},(e,t)=>t+1).map(e=>(0,de.jsxs)("option",{value:e,children:[e," ",1===e?"(First)":2===e?"(Second)":3===e?"(Third)":""]},e))})]})]}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:z?"1fr":"1fr 1fr",gap:z?"16px":"20px"},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Processing Time"}),(0,de.jsx)("input",{type:"text",value:$t.processing_time,onChange:e=>Mt({...$t,processing_time:e.target.value}),className:"form-control",placeholder:"e.g. 5-7 Business Days"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Eligible Persons (Comma Separated)"}),(0,de.jsx)("input",{type:"text",value:$t.eligible_persons,onChange:e=>Mt({...$t,eligible_persons:e.target.value}),className:"form-control",placeholder:"e.g. Salaried, Freelancers, Business Owners"})]})]}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:z?"1fr":"1fr 1fr",gap:z?"16px":"20px"},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Icon Name (Lucide React)"}),(0,de.jsx)("input",{type:"text",value:$t.icon_name,onChange:e=>Mt({...$t,icon_name:e.target.value}),className:"form-control",placeholder:"e.g. FileText, Briefcase, Building"})]}),(0,de.jsxs)("div",{className:"form-group",style:{display:"flex",alignItems:"center",marginTop:"30px"},children:[(0,de.jsx)("input",{type:"checkbox",id:"is_featured",checked:$t.is_featured,onChange:e=>{e.target.checked&&Wt.filter(e=>(1===e.is_featured||!0===e.is_featured)&&e.id!==$t.id).length>=4?Tr("You can only feature a maximum of 4 services. Please unfeature another service first."):Mt({...$t,is_featured:e.target.checked})},style:{width:"20px",height:"20px",marginRight:"10px"}}),(0,de.jsx)("label",{htmlFor:"is_featured",className:"form-label",style:{marginBottom:0,cursor:"pointer"},children:"Featured Service (Max 4)"})]}),(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",marginTop:"15p
2x"},children:[(0,de.jsx)("input",{type:"checkbox",id:"is_active",checked:$t.is_active,onChange:e=>{Mt({...$t,is_active:e.target.checked})},style:{width:"20px",height:"20px",marginRight:"10px"}}),(0,de.jsx)("label",{htmlFor:"is_active",className:"form-label",style:{marginBottom:0,cursor:"pointer"},children:"Active (Show on Website) / Draft (Hide)"})]})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginTop:"20px",marginBottom:"20px",padding:"14px",background:"rgba(30,168,199,0.03)",border:"1px dashed rgba(30,168,199,0.3)",borderRadius:"8px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[(0,de.jsx)("input",{type:"checkbox",id:"has_dual_docs",checked:Ut,onChange:e=>{Gt(e.target.checked)},style:{width:"20px",height:"20px",marginRight:"10px",cursor:"pointer"}}),(0,de.jsx)("label",{htmlFor:"has_dual_docs",className:"form-label",style:{marginBottom:0,cursor:"pointer",fontWeight:"800",color:"var(--primary)"},children:"Separate Individual & Business Requirements"})]}),(0,de.jsx)("span",{style:{fontSize:"0.7rem",color:"var(--text-muted)",marginTop:"4px",display:"block"},children:"Check this box if this service requires different intake documents for Individual clients versus Business/Company clients."})]}),Ut?(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:z?"1fr":"1fr 1fr",gap:"20px",marginBottom:"20px"},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",style:{fontWeight:"700"},children:"Required Intake Documents (Individual)"}),(0,de.jsx)("textarea",{value:Vt,onChange:e=>Ht(e.target.value),className:"form-control",rows:"4",placeholder:"e.g. CNIC Copy, Salary Slip, Bank Statement",required:Ut})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",style:{fontWeight:"700"},children:"Required Intake Documents (Business / Corporate)"}),(0,de.jsx)("textarea",{value:Yt,onChange:e=>Jt(e.target.value),className:"form-control",rows:"4",placeholder:"e.g. CNIC of Directors, Business NTN, Rent Agreement, Utility Bill",required:Ut})]})]}):(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Required Intake Documents (Comma-Separated)"}),(0,de.jsx)("textarea",{value:$t.required_docs,onChange:e=>Mt({...$t,required_docs:e.target.value}),className:"form-control",rows:"4",placeholder:"e.g. CNIC Copy, Bank Statement, Paid Utility Bill",required:!Ut})]}),(0,de.jsx)("span",{style:{fontSize:"0.7rem",color:"var(--text-muted)",marginTop:"-10px",marginBottom:"20px",display:"block"},children:"*Note: Separate each required file category with a comma. Client portals will automatically create separate individual upload tabs for each one!"}),(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"10px",marginTop:"15px"},children:[(0,de.jsx)("button",{type:"submit",className:"btn btn-gold",style:{width:"100%"},disabled:zr,children:zr?"Saving...":"new"===Ot?"Create Service":"Save Configuration"}),(0,de.jsx)("button",{type:"button",onClick:()=>{qt(null),Gt(!1),Ht(""),Jt(""),Mt({id:0,service_name:"",price:0,required_docs:"",short_description:"",processing_time:"",eligible_persons:"",icon_name:"",slug:"",sort_order:1,is_featured:!1,is_active:!0})},className:"btn btn-outline",style:{width:"100%"},children:"Cancel"})]})]})]})]}),"marketing"===Oe&&(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:[(0,de.jsx)("style",{children:"\n @keyframes spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n .animate-spin {\n animation: spin 1s linear infinite;\n }\n .campaign-history-item:hover {\n border-color: var(--accent-gold) !important;\n background-color: #FFFDF5 !important;\n box-shadow: 0 4px 12px rgba(212,175,55,0.06);\n }\n "}),(0,de.jsxs)("div",{style:{background:"linear-gradient(135deg, #0A1324, #1E293B)",borderRadius:"var(--radius-md)",padding:"24px 28px",color:"#FFFFFF",border:"2px s
2olid var(--accent-gold)"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"8px"},children:[(0,de.jsx)(q,{size:24,style:{color:"#D4AF37"}}),(0,de.jsx)("h2",{style:{fontSize:"1.3rem",fontWeight:"800",fontFamily:"var(--font-heading)",margin:0},children:"Broadcast Marketing Email"})]}),(0,de.jsx)("p",{style:{fontSize:"0.85rem",color:"#94A3B8",margin:0,lineHeight:"1.6"},children:"Compose and audit marketing and advisory broadcast email campaigns. Monitor real-time delivery logs, identify failed addresses, and instantly retry failed deliveries in one click."})]}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:z?"1fr":"1.2fr 0.8fr",gap:z?"16px":"24px"},className:"dashboard-detail-grid",children:[(0,de.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:as?(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{background:"var(--white)",padding:"28px"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid var(--border)",paddingBottom:"16px",marginBottom:"20px"},children:[(0,de.jsx)("button",{onClick:()=>{is(null),ls([])},className:"btn btn-outline",style:{padding:"6px 12px",fontSize:"0.8rem",display:"flex",alignItems:"center",gap:"6px",margin:0},children:"â Â Back to Composer"}),(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,de.jsx)("span",{style:{padding:"4px 10px",borderRadius:"12px",fontSize:"0.72rem",fontWeight:"700",backgroundColor:"completed"===as.status?"#DCFCE7":"#FEF3C7",color:"completed"===as.status?"#15803D":"#D97706",textTransform:"uppercase"},children:as.status}),(0,de.jsxs)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)"},children:["ID: #",as.id]})]})]}),(0,de.jsxs)("div",{style:{marginBottom:"24px"},children:[(0,de.jsx)("h4",{style:{margin:0,fontSize:"0.82rem",textTransform:"uppercase",color:"var(--text-muted)",fontWeight:"700",letterSpacing:"0.5px"},children:"Campaign Subject"}),(0,de.jsx)("h3",{style:{margin:"4px 0 16px 0",fontSize:"1.2rem",color:"var(--primary)",fontWeight:"800"},children:as.subject}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",marginBottom:"16px",fontSize:"0.82rem"},children:[(0,de.jsxs)("div",{style:{padding:"10px 14px",background:"var(--bg-cool)",borderRadius:"6px"},children:[(0,de.jsx)("span",{style:{color:"var(--text-muted)"},children:"Target Group:"})," ",(0,de.jsx)("strong",{style:{textTransform:"capitalize"},children:"all"===as.target?"Clients & Staff":"Verified Clients"})]}),(0,de.jsxs)("div",{style:{padding:"10px 14px",background:"var(--bg-cool)",borderRadius:"6px"},children:[(0,de.jsx)("span",{style:{color:"var(--text-muted)"},children:"Sent Date:"})," ",(0,de.jsxs)("strong",{children:[new Date(as.created_at).toLocaleDateString()," ",new Date(as.created_at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]})]}),(0,de.jsxs)("details",{style:{cursor:"pointer",outline:"none"},children:[(0,de.jsx)("summary",{style:{fontSize:"0.82rem",color:"var(--accent-teal)",fontWeight:"600",padding:"4px 0"},children:"View Branded Email Message Body"}),(0,de.jsx)("div",{style:{marginTop:"8px",padding:"16px",background:"var(--bg-cool)",border:"1px dashed var(--border)",borderRadius:"6px",fontSize:"0.85rem",color:"var(--text-main)",whiteSpace:"pre-wrap",maxHeight:"160px",overflowY:"auto"},children:as.body})]})]}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"16px",marginBottom:"24px"},children:[(0,de.jsxs)("div",{style:{textAlign:"center",padding:"16px",background:"var(--bg-cool)",borderRadius:"6px",border:"1px solid var(--border)"},children:[(0,de.jsx)("div",{style:{fontSize:"1.8rem",fontWeight:"800",color:"var(--primary)"},children:as.total_recipients}),(0,de.jsx)("div",{style:{fontSize:"0.75rem",color:"var(--text-muted)",fontWeight:"600",marginTop:"2px"},children:"Total Recipients"})]}),(0,de.jsxs)("div",{style:{textAlign:"center",padding:"16px",background:"#F0FDF4",borderRadius:"6px",border:"1px solid #BBF7D0"},children:[(0,de.jsx)("div",{style:{fontSize:"1.8rem",fontWeight:"800",color:"#16A34A"},children:as.sent_count}),(0,de.jsx)("div",{style:{fontSize:"0.75rem",color:"#15803D",fontWeight:"600",marginTop:"2px"},children:"Successful"})]}),(0,de.jsxs)("div",{style:{textAlign:"center",padding:"16px",background:as.failed_count>0?"#FEF2F2":"var(--bg-cool)",borderRadius:"6px",border:as.failed_count>0?"1px solid #FCA5A5":"1px solid var(--border)"},children:[(0,de.jsx)("div",{style:{fontSize:"1.8rem",fontWeight:"800",color:as.failed_count>0?"#DC2626":"var(--text-muted)"},children:as.failed_count}),(0,de.jsx)("div",{style:{fontSize:"0.75rem",color:as.failed_count>0?"#991B1B":"var(--text-muted)",fontWeight:"600",marginTop:"2px"},children:"Failed"})]})]}),as.failed_count>0&&(0,de.jsxs)("div",{style:{background:"#FFFBEB",border:"1.5px solid #F59E0B",padding:"16px 20px",borderRadius:"8px",marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[(0,de.jsxs)("div",{style:{flex:1},children:[(0,de.jsxs)("h4",{style:{margin:0,fontSize:"0.85rem",color:"#92400E",fontWeight:"700",display:"flex",alignItems:"center",gap:"6px"},children:[(0,de.jsx)(k,{size:16})," Failed Addresses Detected"]}),(0,de.jsxs)("p",{style:{margin:"4px 0 0 0",fontSize:"0.75rem",color:"#B45309",lineHeight:"1.4"},children:[as.failed_count," emails encountered transport blocks. You can retry sending to failed recipients instantly."]})]}),(0,de.jsxs)("button",{onClick:()=>(async e=>{if(window.confirm("Are you sure you want to retry sending emails to all failed recipients in this campaign?")){ms(!0),Fr({type:"",msg:""});try{const t=await(await o("/api/admin/retry-failed-marketing",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({campaign_id:e})})).json();t.success?(Fr({type:"success",msg:t.message||"Failed emails rescheduled for safe background retry!"}),await Oa(),qa(e),t.data.recipients&&t.data.recipients.length>0&&La(t.data.campaign_id,t.data.recipients)):Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"An unexpected error occurred."})}finally{ms(!1)}}})(as.id),className:"btn btn-gold",style:{margin:0,display:"flex",alignItems:"center",gap:"8px",padding:"10px 18px",fontSize:"0.82rem",whiteSpace:"nowrap",backgroundColor:"#D97706",borderColor:"#D97706"},disabled:xs,children:[xs?(0,de.jsx)(t,{className:"animate-spin",size:14}):(0,de.jsx)(t,{size:14}),xs?"Retrying...":"Retry Failed Emails"]}
2)]}),"sending"===as.status&&(0,de.jsxs)("div",{style:{background:"#FEF2F2",border:"1.5px solid #EF4444",padding:"16px 20px",borderRadius:"8px",marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[(0,de.jsxs)("div",{style:{flex:1},children:[(0,de.jsxs)("h4",{style:{margin:0,fontSize:"0.85rem",color:"#991B1B",fontWeight:"700",display:"flex",alignItems:"center",gap:"6px"},children:[(0,de.jsx)(k,{size:16})," Campaign in Progress"]}),(0,de.jsx)("p",{style:{margin:"4px 0 0 0",fontSize:"0.75rem",color:"#B91C1C",lineHeight:"1.4"},children:"This campaign is currently sending emails in the background. You can stop it if you noticed a mistake."})]}),(0,de.jsxs)("button",{onClick:()=>(async e=>{if(window.confirm("Are you sure you want to stop sending emails for this campaign? Pending emails will remain pending but will not be sent.")){Ar(!0),Fr({type:"",msg:""});try{const t=await(await o("/api/admin/stop-campaign",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({campaign_id:e})})).json();t.success?(Fr({type:"success",msg:t.message}),await Oa()):Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"An unexpected error occurred."})}finally{Ar(!1)}}})(as.id),className:"btn btn-gold",style:{margin:0,display:"flex",alignItems:"center",gap:"8px",padding:"10px 18px",fontSize:"0.82rem",whiteSpace:"nowrap",backgroundColor:"#EF4444",borderColor:"#EF4444"},disabled:zr,children:[(0,de.jsx)(t,{size:14})," Stop Campaign"]})]}),(0,de.jsxs)("div",{style:{borderTop:"1px solid var(--border)",paddingTop:"20px"},children:[(0,de.jsx)("h4",{style:{margin:0,fontSize:"0.95rem",color:"var(--primary)",fontWeight:"700",marginBottom:"12px"},children:"Recipient Delivery Logs"}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:z?"1fr":"1.2fr 0.8fr",gap:"10px",marginBottom:"16px"},children:[(0,de.jsxs)("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[(0,de.jsx)(s,{size:14,style:{position:"absolute",left:"12px",color:"var(--text-muted)"}}),(0,de.jsx)("input",{type:"text",placeholder:"Search by name or email...",value:gs,onChange:e=>us(e.target.value),className:"form-control",style:{margin:0,paddingLeft:"34px",fontSize:"0.8rem",height:"38px"}})]}),(0,de.jsxs)("select",{value:hs,onChange:e=>ys(e.target.value),className:"form-control",style:{margin:0,fontSize:"0.8rem",height:"38px"},children:[(0,de.jsx)("option",{value:"all",children:"All Delivery Statuses"}),(0,de.jsx)("option",{value:"sent",children:"Sent Successfully"}),(0,de.jsx)("option",{value:"failed",children:"Failed / Bounced"}),(0,de.jsx)("option",{value:"pending",children:"Pending"})]})]}),cs?(0,de.jsxs)("div",{style:{textAlign:"center",padding:"24px 0",color:"var(--text-muted)",fontSize:"0.85rem"},children:[(0,de.jsx)(t,{className:"animate-spin",size:20,style:{display:"block",margin:"0 auto 8px auto"}}),"Loading campaign recipient logs..."]}):0===ns.length?(0,de.jsx)("p",{style:{textAlign:"center",padding:"20px 0",color:"var(--text-muted)",fontSize:"0.8rem"},children:"No recipient records found for this campaign."}):(()=>{const e=ns.filter(e=>{const t=e.name.toLowerCase().includes(gs.toLowerCase())||e.email.toLowerCase().includes(gs.toLowerCase()),r="all"===hs||e.status===hs;return t&&r});return(0,de.jsx)("div",{style:{maxHeight:"300px",overflow:"auto",border:"1px solid var(--border)",borderRadius:"6px"},children:0===e.length?(0,de.jsx)("p",{style:{textAlign:"center",padding:"20px",color:"var(--text-muted)",fontSize:"0.8rem",margin:0},children:"No matching records found."}):(0,de.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"0.8rem",textAlign:"left"},children:[(0,de.jsx)("thead",{style:{position:"sticky",top:0,background:"var(--bg-cool)",zIndex:1,boxShadow:"inset 0 -1px 0 var(--border)"},children:(0,de.jsxs)("tr",{children:[(0,de.jsx)("th",{style:{padding:"10px 14px",color:"var(--primary)",fontWeight:"700"},children:"Recipient Details"}),(0,de.jsx)("th",{style:{padding:"10px 14px",color:"var(--primary)",fontWeight:"700",width:"110px"},children:"Delivery Status"})]})}),(0,de.jsx)("tbody",{children:e.map(e=>(0,de.jsxs)("tr",{style:{borderBottom:"1px solid var(--border)"},children:[(0,de.jsxs)("td",{style:{padding:"10px 14px"},children:[(0,de.jsx)("strong",{style:{color:"var(--primary)",fontSize:"0.82rem"},children:e.name}),(0,de.jsx)("div",{style:{color:"var(--text-muted)",fontSize:"0.75rem",marginTop:"2px"},children:e.email}),"failed"===e.status&&e.error_message&&(0,de.jsxs)("div",{style:{color:"#DC2626",fontSize:"0.72rem",marginTop:"4px",background:"#FEF2F2",padding:"4px 8px",borderRadius:"4px",border:"1px solid #FEE2E2",display:"inline-block"},children:["â ï¸Â ",e.error_message]})]}),(0,de.jsx)("td",{style:{padding:"10px 14px",verticalAlign:"top"},children:(0,de.jsx)("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:"4px",fontSize:"0.7rem",fontWeight:"700",backgroundColor:"sent"===e.status?"#DCFCE7":"failed"===e.status?"#FEE2E2":"#FEF3C7",color:"sent"===e.status?"#15803D":"failed"===e.status?"#991B1B":"#D97706",textTransform:"uppercase"},children:e.status})})]},e.id))})]})})})()]})]}):ws.sending?(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{background:"#0A1324",padding:"32px",color:"#FFFFFF",border:"2px s
2olid var(--accent-gold)",borderRadius:"var(--radius-md)"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"20px"},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[(0,de.jsx)(t,{className:"animate-spin",size:22,style:{color:"#D4AF37"}}),(0,de.jsx)("h3",{style:{color:"#FFFFFF",fontFamily:"var(--font-heading)",fontWeight:"800",fontSize:"1.2rem",margin:0},children:"Progressive Bulk Sending"})]}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",background:"rgba(212,175,55,0.15)",color:"#D4AF37",padding:"4px 10px",borderRadius:"12px",fontWeight:"700",textTransform:"uppercase",letterSpacing:"0.5px"},children:"Active Dispatch Loop"})]}),(0,de.jsx)("p",{style:{color:"#94A3B8",fontSize:"0.85rem",marginBottom:"24px",lineHeight:"1.5"},children:ws.statusText}),(0,de.jsxs)("div",{style:{marginBottom:"25px"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"0.8rem",fontWeight:"700",marginBottom:"8px"},children:[(0,de.jsx)("span",{style:{color:"#94A3B8"},children:"Delivery Progress"}),(0,de.jsxs)("span",{style:{color:"#D4AF37"},children:[ws.current," of ",ws.total," (",ws.total>0?Math.round(ws.current/ws.total*100):0,"%)"]})]}),(0,de.jsx)("div",{style:{height:"10px",background:"rgba(255,255,255,0.08)",borderRadius:"5px",overflow:"hidden"},children:(0,de.jsx)("div",{style:{height:"100%",width:(ws.total>0?ws.current/ws.total*100:0)+"%",background:"linear-gradient(90deg, #D4AF37, #1EA8C7)",transition:"width 0.3s ease"}})})]}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px",marginBottom:"25px"},children:[(0,de.jsxs)("div",{style:{background:"rgba(22,163,74,0.1)",border:"1px solid rgba(22,163,74,0.25)",borderRadius:"6px",padding:"12px",textAlign:"center"},children:[(0,de.jsx)("div",{style:{fontSize:"1.6rem",fontWeight:"800",color:"#4ADE80"},children:ws.success}),(0,de.jsx)("div",{style:{fontSize:"0.72rem",color:"#A7F3D0",fontWeight:"600",marginTop:"2px",textTransform:"uppercase"},children:"Delivered Successfully"})]}),(0,de.jsxs)("div",{style:{background:"rgba(239,68,68,0.1)",border:"1px solid rgba(239,68,68,0.25)",borderRadius:"6px",padding:"12px",textAlign:"center"},children:[(0,de.jsx)("div",{style:{fontSize:"1.6rem",fontWeight:"800",color:"#F87171"},children:ws.failed}),(0,de.jsx)("div",{style:{fontSize:"0.72rem",color:"#FECACA",fontWeight:"600",marginTop:"2px",textTransform:"uppercase"},children:"Failed / Bounced"})]})]}),(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,de.jsx)("span",{style:{fontSize:"0.8rem",fontWeight:"700",color:"#E2E8F0"},children:"Live Delivery Log Stream"}),ws.current>=ws.total&&(0,de.jsx)("button",{onClick:()=>{_s({sending:!1,current:0,total:0,success:0,failed:0,statusText:"",logs:[]})},className:"btn btn-gold",style:{padding:"4px 12px",fontSize:"0.75rem",margin:0},children:"Close Progress Dashboard"})]}),(0,de.jsx)("div",{style:{background:"#020617",border:"1px solid rgba(255,255,255,0.08)",borderRadius:"8px",padding:"14px",height:"180px",overflowY:"auto",fontFamily:"monospace",fontSize:"0.75rem",color:"#38BDF8",display:"flex",flexDirection:"column",gap:"6px"},className:"terminal-logs-console",children:ws.logs.map((e,t)=>(0,de.jsx)("div",{style:{color:e.includes("failed")||e.includes("Error")?"#F87171":e.includes("complete")||e.includes("Delivered")||e.includes("completed")?"#4ADE80":"#38BDF8"},children:e},t))})]})]}):(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{background:"var(--white)",padding:"28px"},children:[(0,de.jsxs)("h3",{style:{...Ce.subBlockTitle,display:"flex",alignItems:"center",gap:"8px",margin:0,marginBottom:"8px"},children:[(0,de.jsx)(y,{size:18,style:{color:"#D4AF37"}})," Compose Email Campaign"]}),(0,de.jsx)("p",{style:{color:"var(--text-muted)",fontSize:"0.82rem",marginBottom:"24px"},children:"Create a personalized campaign. The system wraps plain text in a professional branded HTML template."}),(0,de.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),"custom"===Qr.target&&0===fs.length)return void Fr({type:"error",msg:"Please select at least one contact to send the campaign."});const t="custom"===Qr.target?`${fs.length} custom selected contacts`:"all"===Qr.target?"clients, providers & c
2onsultants":"providers"===Qr.target?"marketplace providers":"consultants"===Qr.target?"internal consultants":"clients";if(window.confirm(`Send marketing email to all registered ${t}? This cannot be undone.`)){Ar(!0),Fr({type:"",msg:""}),ts(null);try{const e={...Qr,user_ids:"custom"===Qr.target?fs:[]},t=await(await o("/api/admin/send-marketing",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify(e)})).json();t.success?(Fr({type:"success",msg:t.message||"Campaign successfully created and scheduled!"}),Zr({subject:"",body:"",target:"clients"}),bs([]),await Oa(),t.data.recipients&&t.data.recipients.length>0&&La(t.data.campaign_id,t.data.recipients)):Fr({type:"error",msg:t.message})}catch(r){Fr({type:"error",msg:"Failed to send marketing emails. Please try again."})}finally{Ar(!1)}}},children:[(0,de.jsxs)("div",{className:"form-group",style:{marginBottom:"16px"},children:[(0,de.jsx)("label",{className:"form-label",style:{fontWeight:"600",fontSize:"0.85rem"},children:"Recipient Group"}),(0,de.jsxs)("select",{value:Qr.target,onChange:e=>Zr({...Qr,target:e.target.value}),className:"form-control",style:{marginTop:"6px"},children:[(0,de.jsx)("option",{value:"clients",children:"All Verified Clients Only"}),(0,de.jsx)("option",{value:"providers",children:"All Marketplace Providers Only"}),(0,de.jsx)("option",{value:"consultants",children:"All Internal Consultants / Team Only (3)"}),(0,de.jsx)("option",{value:"all",children:"All Registered Contacts (Clients + Providers + Consultants)"}),(0,de.jsx)("option",{value:"custom",children:"Select Specific Contacts (Custom Checklist)"})]})]}),"custom"===Qr.target&&(0,de.jsxs)("div",{className:"animate-fade-in",style:{background:"#F8FAFC",border:"1px solid var(--border)",borderRadius:"8px",padding:"16px",marginBottom:"16px"},children:[(0,de.jsxs)("label",{className:"form-label",style:{fontWeight:"700",fontSize:"0.85rem",display:"block",marginBottom:"8px"},children:["Select Recipients (",fs.length," Selected)"]}),(0,de.jsx)("div",{style:{display:"flex",gap:"6px",marginBottom:"10px",flexWrap:"wrap"},children:[{key:"all",label:"All"},{key:"clients",label:"Clients Only"},{key:"providers",label:"Providers Only"},{key:"consultants",label:"Consultants Only"}].map(e=>(0,de.jsx)("button",{type:"button",onClick:()=>Cs(e.key),style:{padding:"4px 12px",fontSize:"0.72rem",fontWeight:"700",borderRadius:"20px",border:Ss===e.key?"2px solid var(--accent-gold)":"1px solid var(--border)",background:Ss===e.key?"var(--accent-gold)":"transparent",color:Ss===e.key?"#fff":"var(--text-muted)",cursor:"pointer",transition:"all 0.2s"},children:e.label},e.key))}),(0,de.jsxs)("div",{style:{position:"relative",display:"flex",alignItems:"center",marginBottom:"12px"},children:[(0,de.jsx)(s,{size:14,style:{position:"absolute",left:"10px",color:"var(--text-muted)"}}),(0,de.jsx)("input",{type:"text",placeholder:"Filter contacts by ID, name, email, company...",value:vs,onChange:e=>js(e.target.value),className:"form-control",style:{margin:0,paddingLeft:"32px",fontSize:"0.8rem",height:"36px"}})]}),(0,de.jsxs)("div",{style:{display:"flex",gap:"10px",marginBottom:"12px"},children:[(0,de.jsx)("button",{type:"button",onClick:()=>{const e=pe.filter(e=>{const t="consultant"===e.role,r=!t&&("provider"===e.marketplace_role||e.provider_status&&"removed"!==e.provider_status);return"clients"===Ss?!t&&!r:"providers"===Ss?r:"consultants"!==Ss||t}).filter(e=>{const t=vs.toLowerCase().trim();return!t||String(e.id).includes(t)||e.name&&e.name.toLowerCase().includes(t)||e.email&&e.email.toLowerCase().includes(t)||e.company_name&&e.company_name.toLowerCase().includes(t)}).map(e=>e.id);bs(t=>Array.from(new Set([...t,...e])))},className:"btn btn-outline",style:{flex:1,padding:"6px 12px",fontSize:"0.75rem",margin:0,whiteSpace:"nowrap"},children:"Select All Filtered"}),(0,de.jsx)("button",{type:"button",onClick:()=>{bs([])},className:"btn btn-outline",style:{flex:1,padding:"6px 12px",fontSize:"0.75rem",margin:0,whiteSpace:"nowrap"},children:"Clear Selection"})]}),(0,de.jsx)("div",{style:{maxHeight:"220px",overflowY:"auto",border:"1px solid var(--border)",borderRadius:"6px",background:"var(--white)"},children:(()=>{const e=pe.filter(e=>{const t="consultant"===e.role,r=!t&&("provider"===e.marketplace_role||e.provider_status&&"removed"!==e.provider_status);return"clients"===Ss?!t&&!r:"providers"===Ss?r:"consultants"!==Ss||t}).filter(e=>{const t=vs.toLowerCase().trim();return!t||String(e.id).includes(t)||e.name&&e.name.toLowerCase().includes(t)||e.email&&e.email.toLowerCase().includes(t)||e.company_name&&e.company_name.toLowerCase().includes(t)});return 0===e.length?(0,de.jsx)("div",{style:{padding:"20px",textAlign:"center",fontSize:"0.8rem",color:"var(--text-muted)"},children:"No contacts match your filter."}):e.map(e=>{const t=fs.includes(e.id),r="consultant"===e.role,s=!r&&("provider"===e.marketplace_role||e.provider_status&&"removed"!==e.provider_status),a=r?"CONSULTANT":s?"PROVIDER":"CLIENT",i=r?"#EEF2FF":s?"#FEF3C7":"#F1F5F9",n=r?"#4F46E5":s?"#B45309":"var(--text-main)";return(0,de.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderBottom:"1px solid var(--border)",cursor:"pointer",userSelect:"none",background:t?"rgba(212,175,55,0.05)":"var(--white)",transition:"background 0.2s",margin:0},children:[(0,de.jsx)("input",{type:"checkbox",checked:t,onChange:()=>{bs(t?t=>t.filter(t=>t!==e.id):t=>[...t,e.id])},style:{width:"16px",height:"16px",accentColor:"var(--accent-gold)",cursor:"pointer"}}),(0,de.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,de.jsxs)("span",{style:{fontSize:"0.82rem",fontWeight:"700",color:"var(--primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[(0,de.jsxs)("span",{style:{fontSize:"0.7rem",color:"var(--text-muted)",fontWeight:"600",marginRight:"6px"},children:[e.id," â"]}),e.name]}),(0,de.jsx)("span",{style:{fontSize:"0.65rem",fontWeight:"700",padding:"2px 6px",borderRadius:"4px",backgroundColor:i,
2color:n,textTransform:"uppercase",flexShrink:0,marginLeft:"8px"},children:a})]}),(0,de.jsxs)("div",{style:{fontSize:"0.72rem",color:"var(--text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:[e.email," ",e.company_name?`⢠${e.company_name}`:""]})]})]},e.id)})})()})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginBottom:"16px"},children:[(0,de.jsx)("label",{className:"form-label",style:{fontWeight:"600",fontSize:"0.85rem"},children:"Email Subject Line"}),(0,de.jsx)("input",{type:"text",value:Qr.subject,onChange:e=>Zr({...Qr,subject:e.target.value}),className:"form-control",placeholder:"e.g. Important FBR Tax Filing Deadline â Action Required",required:!0,style:{marginTop:"6px"}}),(0,de.jsx)("span",{style:{fontSize:"0.72rem",color:"var(--text-muted)",marginTop:"4px",display:"block"},children:"Keep subject under 60 characters for best open rates."})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginBottom:"20px"},children:[(0,de.jsx)("label",{className:"form-label",style:{fontWeight:"600",fontSize:"0.85rem"},children:"Email Body Message"}),(0,de.jsx)("textarea",{value:Qr.body,onChange:e=>Zr({...Qr,body:e.target.value}),rows:"10",className:"form-control",placeholder:"Dear [Client Name],\n\nWrite your message here...\n\nWarm Regards,\nAM Tax & Corporate Hub Team",required:!0,style:{marginTop:"6px"}}),(0,de.jsxs)("span",{style:{fontSize:"0.72rem",color:"var(--text-muted)",marginTop:"4px",display:"block"},children:[Qr.body.length," characters â Note: The recipient's first name is automatically personalized at the top of each email."]})]}),(0,de.jsxs)("button",{type:"submit",className:"btn btn-gold",style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"12px"},disabled:zr,children:[zr?(0,de.jsx)(t,{className:"animate-spin",size:16}):(0,de.jsx)(y,{size:16}),zr?"Sending Emails... Please Wait":"custom"===Qr.target?`Send to Selected Contacts (${fs.length})`:"Send to All "+("all"===Qr.target?"Clients & Providers":"providers"===Qr.target?"Verified Providers":"Verified Clients")]})]})]})}),(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"20px"},children:[as&&(0,de.jsxs)("button",{onClick:()=>{is(null),ls([])},className:"btn btn-gold animate-fade-in",style:{margin:0,width:"100%",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"12px"},children:[(0,de.jsx)(n,{size:16})," Compose New Campaign"]}),(0,de.jsxs)("div",{className:"glass-card",style:{background:"var(--white)",padding:"24px"},children:[(0,de.jsxs)("h3",{style:{...Ce.subBlockTitle,display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[(0,de.jsx)(c,{size:18,style:{color:"#D4AF37"}})," Broadcast History"]}),(0,de.jsx)("p",{style:{color:"var(--text-muted)",fontSize:"0.8rem",marginBottom:"20px"},children:"Audit delivery execution across sent email campaigns. Click any campaign to view full audit logs."}),os?(0,de.jsxs)("div",{style:{textAlign:"center",padding:"30px 0",color:"var(--text-muted)",fontSize:"0.85rem"},children:[(0,de.jsx)(t,{className:"animate-spin",size:20,style:{display:"block",margin:"0 auto 8px auto"}}),"Loading previous campaigns..."]}):0===rs.length?(0,de.jsx)("div",{style:{textAlign:"center",padding:"30px 10px",color:"var(--text-muted)",fontSize:"0.8rem",border:"1px dashed var(--border)",borderRadius:"6px"},children:"No sent email campaigns recorded."}):(0,de.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"12px",maxHeight:"560px",overflowY:"auto",paddingRight:"4px"},children:rs.map(e=>{const t=as&&as.id===e.id,r=e.total_recipients>0?Math.round(e.sent_count/e.total_recipients*100):0;return(0,de.jsxs)("div",{onClick:()=>{is(e),us(""),ys("all"),qa(e.id)},style:{border:t?"1.5px solid var(--accent-gold)":"1px solid var(--border)",borderRadius:"8px",padding:"16px",background:t?"linear-gradient(135deg, rgba(212,175,55,0.1), rgba(212,175,55,0.03))":"var(--bg-cool)",cursor:"pointer",transition:"all 0.2s ease",boxShadow:t?"0 4px 12px rgba(212,175,55,0.1)":"none"},className:"campaign-history-item",children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",ga
2p:"10px",marginBottom:"6px"},children:[(0,de.jsx)("h4",{style:{margin:0,fontSize:"0.88rem",color:t?"var(--primary)":"var(--text-main)",fontWeight:"700",lineHeight:"1.4",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:e.subject}),(0,de.jsx)(h,{size:14,style:{color:t?"var(--accent-gold)":"var(--text-muted)",flexShrink:0,marginTop:"2px"}})]}),(0,de.jsxs)("div",{style:{fontSize:"0.72rem",color:"var(--text-muted)",display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"},children:[(0,de.jsx)("span",{children:new Date(e.created_at).toLocaleDateString(void 0,{month:"short",day:"numeric"})}),(0,de.jsx)("span",{children:"â¢"}),(0,de.jsx)("span",{style:{textTransform:"capitalize"},children:"all"===e.target?"All Staff & Clients":"Clients"})]}),(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"0.72rem",color:"var(--text-muted)",fontWeight:"600"},children:[(0,de.jsxs)("span",{children:[e.sent_count," / ",e.total_recipients," Delivered"]}),(0,de.jsxs)("span",{style:{color:e.failed_count>0?"#DC2626":"#16A34A"},children:[r,"% Success"]})]}),(0,de.jsxs)("div",{style:{height:"5px",width:"100%",background:"rgba(0,0,0,0.06)",borderRadius:"3px",overflow:"hidden",display:"flex"},children:[(0,de.jsx)("div",{style:{height:"100%",width:e.sent_count/e.total_recipients*100+"%",background:"#16A34A"}}),(0,de.jsx)("div",{style:{height:"100%",width:e.failed_count/e.total_recipients*100+"%",background:"#DC2626"}})]})]})]},e.id)})})]}),(0,de.jsxs)("div",{className:"glass-card",style:{background:"light"===e?"#FFFDF5":"rgba(212, 175, 55, 0.05)",border:"1.5px solid var(--accent-gold)",padding:"20px"},children:[(0,de.jsx)("h4",{style:{color:"light"===e?"#92400E":"var(--accent-gold)",fontFamily:"var(--font-heading)",fontWeight:"700",fontSize:"0.9rem",marginBottom:"12px",display:"flex",alignItems:"center",gap:"6px"},children:"ð§ Broadcast Guidelines"}),(0,de.jsxs)("ul",{style:{fontSize:"0.78rem",color:"var(--text-muted)",paddingLeft:"14px",lineHeight:"1.8",margin:0},children:[(0,de.jsx)("li",{children:"Subject lines should be descriptive and urgent"}),(0,de.jsxs)("li",{children:["First names are personalized via ",(0,de.jsx)("code",{style:{fontFamily:"Courier, monospace",color:"var(--accent-gold)"},children:"Dear [First Name],"})," automatically"]}),(0,de.jsx)("li",{children:'Avoid spam triggers like "FREE", "100%", "URGENT!!!"'}),(0,de.jsxs)("li",{children:["Send summary copy is archived at ",(0,de.jsx)("strong",{style:{color:"var(--primary)"},children:"[email protected]"})]})]})]})]})]})]}),"applications"===Oe&&(0,de.jsxs)("div",{className:"glass-card animate-fade-in",children:[(0,de.jsx)("h2",{style:Ce.tabTitle,children:"Career Job Applications"}),(0,de.jsx)("p",{style:Ce.tabText,children:"Review all submitted candidate profiles, download their CV/Resume, and preview CNIC identification documents."}),0===Rr.length?(0,de.jsxs)("div",{style:{textAlign:"center",padding:"50px 0",color:"var(--text-muted)"},children:[(0,de.jsx)(N,{size:48,style:{color:"var(--border)",marginBottom:"16px",display:"block",margin:"0 auto 16px auto"}}),(0,de.jsx)("h3",{style:{color:"var(--primary)",marginBottom:"8px"},children:"No Applications Received Yet"}),(0,de.jsx)("p",{style:{fontSize:"0.85rem"},children:"Submitted candidate applications will appear here automatically."})]}):(0,de.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"20px"},children:Rr.map(e=>(0,de.jsx)("div",{style:{border:"1px solid var(--border)",borderRadius:"var(--radius-md)",padding:"24px",background:"var(--white)",transition:"box-shadow 0.2s"},children:(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"20px",alignItems:"start"},children:[(0,de.jsxs)("div",{children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"12px"},children:[(0,de.jsx)("div",{style:{width:"44px",height:"44px",borderRadius:"50%",background:"linear-gradient(135deg, var(--accent-teal), var(--primary))",display:"flex",alignItems:"center",justifyContent:"center",color:"#FFF",fontWeight:"800",fontSize:"1.1rem",flexShrink:0},children:e.name.charAt(0).toUpperCase()}),(0,de.jsxs)("div",{children:[(0,de.jsx)("h4",{style:{margin:0,color:"var(--primary)",fontWeight:"700"},children:e.name}),(0,de.jsxs)("span",{style:{fontSize:"0.75rem",color:"var(--accent-teal)",fontWeight:"600"},children:["Applied for: ",e.position]})]})]}),(0,de.jsxs)("div",{style:{fontSize:"0.82rem",color:"var(--text-muted)",display:"flex",flexDirection:"column",gap:"4px"},children:[(0,de.jsxs)("span",{children:["ð§ ",e.email]}),(0,de.jsxs)("span",{children:["ð ",e.phone]}
2),(0,de.jsxs)("span",{children:["ð Experience: ",e.experience]}),(0,de.jsxs)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)",marginTop:"4px"},children:["Submitted: ",new Date(e.created_at).toLocaleString()]})]}),e.cover_letter&&(0,de.jsxs)("div",{style:{marginTop:"12px",padding:"10px",background:"var(--bg-cool)",border:"1px solid var(--border)",borderRadius:"6px",fontSize:"0.8rem",color:"var(--text-main)",lineHeight:"1.5"},children:[(0,de.jsx)("strong",{children:"Cover Letter:"}),(0,de.jsx)("br",{}),e.cover_letter]})]}),(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[(0,de.jsx)("h5",{style:{margin:0,color:"var(--primary)",fontWeight:"700",fontSize:"0.9rem",borderBottom:"1px solid var(--border)",paddingBottom:"8px"},children:"ð CV / Resume"}),e.cv_path?(0,de.jsxs)("a",{href:`/api/${e.cv_path}`,target:"_blank",rel:"noreferrer",className:"btn btn-primary",style:{display:"inline-flex",alignItems:"center",gap:"8px",padding:"10px 16px",fontSize:"0.82rem",width:"fit-content"},children:[(0,de.jsx)(r,{size:14})," Download CV"]}):(0,de.jsx)("span",{style:{fontSize:"0.8rem",color:"var(--text-muted)",fontStyle:"italic"},children:"No CV uploaded"})]}),(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[(0,de.jsx)("h5",{style:{margin:0,color:"var(--primary)",fontWeight:"700",fontSize:"0.9rem",borderBottom:"1px solid var(--border)",paddingBottom:"8px"},children:"𪪠CNIC Documents"}),(0,de.jsxs)("div",{style:{display:"flex",gap:"10px",flexWrap:"wrap"},children:[e.cnic_front_path?(0,de.jsxs)("a",{href:`/api/${e.cnic_front_path}`,target:"_blank",rel:"noreferrer",style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",textDecoration:"none"},children:[(0,de.jsx)("div",{style:{width:"90px",height:"60px",background:"var(--bg-cool)",border:"2px solid var(--border)",borderRadius:"6px",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,de.jsx)("img",{src:`/api/${e.cnic_front_path}`,alt:"CNIC Front",style:{width:"100%",height:"100%",objectFit:"cover"},onError:e=>{e.target.style.display="none"}})}),(0,de.jsx)("span",{style:{fontSize:"0.7rem",color:"var(--accent-teal)",fontWeight:"600"},children:"CNIC Front"})]}):null,e.cnic_back_path?(0,de.jsxs)("a",{href:`/api/${e.cnic_back_path}`,target:"_blank",rel:"noreferrer",style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",textDecoration:"none"},children:[(0,de.jsx)("div",{style:{width:"90px",height:"60px",background:"var(--bg-cool)",border:"2px solid var(--border)",borderRadius:"6px",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,de.jsx)("img",{src:`/api/${e.cnic_back_path}`,alt:"CNIC Back",style:{width:"100%",height:"100%",objectFit:"cover"},onError:e=>{e.target.style.display="none"}})}),(0,de.jsx)("span",{style:{fontSize:"0.7rem",color:"var(--accent-teal)",fontWeight:"600"},children:"CNIC Back"})]}):null,!e.cnic_front_path&&!e.cnic_back_path&&(0,de.jsx)("span",{style:{fontSize:"0.8rem",color:"var(--text-muted)",fontStyle:"italic"},children:"No CNIC uploaded"})]})]})]})},e.id))})]}),"reviews"===Oe&&(0,de.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"30px"},children:(0,de.jsxs)("div",{className:"dashboard-detail-grid",style:{gap:z?"20px":"30px",display:"grid",gridTemplateColumns:z?"1fr":"1.2fr 0.8fr"},children:[(0,de.jsxs)("div",{className:"glass-card",children:[(0,de.jsx)("h2",{style:Ce.tabTitle,children:"Testimonials & Reviews"}),(0,de.jsx)("p",{style:Ce.tabText,children:"Only reviews marked Published appear on the homepage. Paid-service reviews use a completed request; calculator and website reviews use a recorded email, WhatsApp or other identity-verification note."}),Nr?(0,de.jsx)("p",{style:{textAlign:"center",padding:"40px 0",color:"var(--text-muted)"},children:"Loading reviews..."}):0===Ie.length?(0,de.jsx)("p",{style:{textAlign:"center",padding:"40px 0",color:"var(--text-muted)"},children:"No feedback reviews in the database."}):(0,de.jsx)("div",{style:Ce.tableResponsive,children:(0,de.jsxs)("table",{style:Ce.table,children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{children:[(0,de.jsx)("th",{children:"Client Name & Role"}),(0,de.jsx)("th",{children:"Review Text"}),(0,de.jsx)("th",{children:"Rating"}),(0,de.jsx)("th",{children:"Status"}),(0,de.jsx)("th",{children:"Actions"})]})}),(0,de.jsx)("tbody",{children:Ie.map(e=>{const t=ve(e),r=t?"PUBLISHED":"approved"===e.status?"VERIFY REQUIRED":e.status.toUpperCase();return(0,de.jsxs)("tr",{children:[(0,de.jsxs)("td",{children:[(0,de.jsx)("strong",{children:e.name}),(0,de.jsx)("br",{}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)"},children:e.role||"Valued User"}),e.reviewer_email&&(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("br",{}),(0,de.jsx)("span",{style:{fontSize:"0.68rem",color:"var(--text-muted)"},children:e.reviewer_email})]})]}),(0,de.jsx)("td",{children:(0,de.jsxs)("p",{style:{fontSize:"0.8rem",maxWidth:"240px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal",lineHeight:"1.4"},children:['"',e.review_text,'"']})}),(0,de.jsx)("td",{children:(0,de.jsx)("span",{style:{color:"#F59E0B",fontWeight:"bold"},children:Array.from({length:5}).map((t,r)=>(0,de.jsx)("span",{children:r<(parseInt(e.rating)||5)?"â
":"â"},r))})}),(0,de.jsx)("td",{children:(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",ga
2p:"5px"},children:[(0,de.jsx)("span",{style:{padding:"4px 8px",borderRadius:"4px",fontSize:"0.75rem",fontWeight:"700",backgroundColor:t?"#ECFDF5":"#FFFBEB",color:t?"#10B981":"#F59E0B"},children:r}),Number(e.service_request_id)>0&&(0,de.jsxs)("span",{style:{fontSize:"0.7rem",color:"var(--text-muted)"},children:["Request #",e.service_request_id]}),(0,de.jsx)("span",{style:{fontSize:"0.68rem",color:"var(--text-muted)"},children:je[e.review_source]||"Not Classified"})]})}),(0,de.jsx)("td",{children:(0,de.jsxs)("div",{style:{display:"flex",gap:"6px",alignItems:"center"},children:[(0,de.jsx)("button",{onClick:()=>(async e=>{if(ve(e)){if(window.confirm("Remove this published review from the homepage?")){Ar(!0),Fr({type:"",msg:""});try{const t=await(await o("/api/reviews/approve",{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({id:e.id,status:"pending",verified:!1,consent_confirmed:1===Number(e.consent_confirmed),service_request_id:e.service_request_id||null,review_source:e.review_source,verification_note:e.verification_note||""})})).json();t.success?(Fr({type:"success",msg:t.message}),_a()):Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"Failed to update review status."})}finally{Ar(!1)}}}else Le({review:e,review_source:["client_service","calculator_user","website_visitor"].includes(e.review_source)?e.review_source:"website_visitor",service_request_id:e.service_request_id||"",verification_note:e.verification_note||""})})(e),className:"btn btn-outline",style:{padding:"6px 10px",fontSize:"0.75rem",margin:0,color:t?"#F59E0B":"#10B981",borderColor:t?"#F59E0B":"#10B981",backgroundColor:"transparent"},disabled:zr,title:t?"Remove from homepage":"Verify evidence and publish on homepage",children:t?"Unpublish":"Verify & Publish"}),(0,de.jsx)("button",{onClick:()=>(async e=>{if(window.confirm("Are you sure you want to delete this review?")){Ar(!0),Fr({type:"",msg:""});try{const t=await(await o(`/api/reviews/delete?id=${e}`,{method:"DELETE",headers:{Authorization:`Bearer ${g}`}})).json();t.success?(Fr({type:"success",msg:t.message}),_a()):Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"Failed to delete review."})}finally{Ar(!1)}}})(e.id),className:"btn btn-danger",style:{padding:"6px",borderRadius:"6px",display:"inline-flex",alignItems:"center",justifyContent:"center",margin:0},disabled:zr,title:"Delete Review",children:(0,de.jsx)(A,{size:13})})]})})]},e.id)})})]})})]}),(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{background:"var(--white)",alignSelf:"start"},children:[(0,de.jsxs)("h3",{style:Ce.subBlockTitle,children:[(0,de.jsx)(b,{size:18})," Add Custom Testimonial"]}),(0,de.jsx)("p",{style:{color:"var(--text-muted)",fontSize:"0.8rem",marginBottom:"20px"},children:"Manually add a genuine, consented client, calculator-user or website-user testimonial."}),(0,de.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),window.confirm("Confirm identity/evidence verification and written consent to publish this testimonial.")){Ar(!0),Fr({type:"",msg:""});try{const e=await(await o("/api/reviews/add-approved",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({...Pe,verified:!0,consent_confirmed:!0})})).json();e.success?(Fr({type:"success",msg:e.message}),Ee({name:"",role:"",reviewer_email:"",rating:5,review_text:"",review_source:"website_visitor",service_request_id:"",verification_note:""}),_a()):Fr({type:"error",msg:e.message})}catch(t){Fr({type:"error",msg:"Failed to add approved review."})}finally{Ar(!1)}}},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Client Name"}),(0,de.jsx)("input",{type:"text",className:"form-control",placeholder:"e.g. Zainab Bibi",value:Pe.name,onChange:e=>Ee({...Pe,name:e.target.value}),required:!0})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginTop:"12px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Role or Company Title"}),(0,de.jsx)("input",{type:"text",className:"form-control",placeholder:"e.g. Managing Director, PeakRetail Pvt Ltd",value:Pe.role,onChange:e=>Ee({...Pe,role:e.target.value})})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginTop:"12px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Verification
2Email (private)"}),(0,de.jsx)("input",{type:"email",className:"form-control",placeholder:"[email protected]",value:Pe.reviewer_email,onChange:e=>Ee({...Pe,reviewer_email:e.target.value})})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginTop:"12px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Experience Type"}),(0,de.jsxs)("select",{className:"form-control",value:Pe.review_source,onChange:e=>Ee({...Pe,review_source:e.target.value,service_request_id:"",verification_note:""}),children:[(0,de.jsx)("option",{value:"website_visitor",children:"Website / Tax Resources"}),(0,de.jsx)("option",{value:"calculator_user",children:"Free Tax Calculator"}),(0,de.jsx)("option",{value:"client_service",children:"Paid / Advisory Service"})]})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginTop:"12px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Rating"}),(0,de.jsxs)("select",{className:"form-control",value:Pe.rating,onChange:e=>Ee({...Pe,rating:parseInt(e.target.value)}),children:[(0,de.jsx)("option",{value:"5",children:"5 Stars (Excellent)"}),(0,de.jsx)("option",{value:"4",children:"4 Stars (Good)"}),(0,de.jsx)("option",{value:"3",children:"3 Stars (Average)"}),(0,de.jsx)("option",{value:"2",children:"2 Stars (Poor)"}),(0,de.jsx)("option",{value:"1",children:"1 Star (Very Bad)"})]})]}),"client_service"===Pe.review_source?(0,de.jsxs)("div",{className:"form-group",style:{marginTop:"12px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Completed Service Request ID"}),(0,de.jsx)("input",{type:"number",min:"1",className:"form-control",placeholder:"e.g. 125",value:Pe.service_request_id,onChange:e=>Ee({...Pe,service_request_id:e.target.value}),required:!0})]}):(0,de.jsxs)("div",{className:"form-group",style:{marginTop:"12px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Verification Record"}),(0,de.jsx)("textarea",{className:"form-control",rows:"2",maxLength:"255",placeholder:"e.g. Email reply confirmed on 19 July 2026",value:Pe.verification_note,onChange:e=>Ee({...Pe,verification_note:e.target.value}),required:!0})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginTop:"12px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Review Details"}),(0,de.jsx)("textarea",{className:"form-control",rows:"4",placeholder:"Enter review feedback text...",value:Pe.review_text,onChange:e=>Ee({...Pe,review_text:e.target.value}),required:!0})]}),(0,de.jsx)("button",{type:"submit",className:"btn btn-gold",style:{width:"100%",marginTop:"16px"},disabled:zr,children:zr?"Saving...":"Add Approved Testimonial"})]})]})]})}),"careers"===Oe&&(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"30px"},children:[(0,de.jsxs)("div",{className:"glass-card animate-fade-in",children:[(0,de.jsxs)("h2",{style:Ce.tabTitle,children:[(0,de.jsx)(j,{size:20,style:{display:"inline",marginRight:"8px",verticalAlign:"middle",color:"var(--accent-teal)"}}),ze?"Edit Job Vacancy":"Post New Job Vacancy"]}),(0,de.jsxs)("p",{style:Ce.tabText,children:["Create or edit active job openings. Set the status to ",(0,de.jsx)("strong",{children:"Active"})," to make them visible on the public Careers page."]}),(0,de.jsxs)("form",{onSubmit:async e=>{e.preventDefault();try{const e=ze?"/api/careers/update":"/api/careers/add",t={...Ne};ze&&(t.id=ze);const r=await(await o(e,{method:"POST",headers:{Authorization:`Bearer ${g}`,"Content-Type":"application/json"},body:JSON.stringify(t)})).json();r.success?(Fr({type:"success",msg:r.message}),ke({title:"",description:"",job_type:"Full-Time",prerequisites:"",status:"Draft"}),Ae(null),pa()):Fr({type:"error",msg:r.message})}catch(t){}},children:[(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"20px"},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsxs)("label",{className:"form-label",children:["Job Title ",(0,de.jsx)("span",{style:{color:"#EF4444"},children:"*"})]}),(0,de.jsx)("input",{type:"text",className:"form-control",placeholder:"e.g. Senior Tax Consultant",value:Ne.title,onChange:e=>ke({...Ne,title:e.target.value}),required:!0})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Job Type"}),(0,de.jsxs)("select",{className:"form-control",value:Ne.job_type,onCh
2ange:e=>ke({...Ne,job_type:e.target.value}),children:[(0,de.jsx)("option",{value:"Full-Time",children:"Full-Time"}),(0,de.jsx)("option",{value:"Part-Time",children:"Part-Time"}),(0,de.jsx)("option",{value:"Contract",children:"Contract / Freelance"}),(0,de.jsx)("option",{value:"Remote",children:"Remote"}),(0,de.jsx)("option",{value:"Internship",children:"Internship"})]})]})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginTop:"16px"},children:[(0,de.jsxs)("label",{className:"form-label",children:["Job Description ",(0,de.jsx)("span",{style:{color:"#EF4444"},children:"*"})]}),(0,de.jsx)("textarea",{className:"form-control",rows:"4",placeholder:"Describe the role, responsibilities, and team environment...",value:Ne.description,onChange:e=>ke({...Ne,description:e.target.value}),required:!0})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginTop:"16px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Prerequisites / Requirements"}),(0,de.jsx)("textarea",{className:"form-control",rows:"3",placeholder:"e.g. 2+ years experience, FBR IRIS knowledge, ACCA/CA qualification...",value:Ne.prerequisites,onChange:e=>ke({...Ne,prerequisites:e.target.value})})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginTop:"16px",maxWidth:"260px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Listing Status"}),(0,de.jsxs)("select",{className:"form-control",value:Ne.status,onChange:e=>ke({...Ne,status:e.target.value}),children:[(0,de.jsx)("option",{value:"Draft",children:"Draft (Hidden from public)"}),(0,de.jsx)("option",{value:"Active",children:"Active (Visible on Careers page)"}),(0,de.jsx)("option",{value:"Closed",children:"Closed (Applications ended)"})]})]}),(0,de.jsxs)("div",{style:{display:"flex",gap:"12px",marginTop:"24px"},children:[(0,de.jsx)("button",{type:"submit",className:"btn btn-glow-primary",disabled:zr,style:{minWidth:"160px"},children:zr?"Saving...":ze?"âï¸ Update Vacancy":"â Post Vacancy"}),ze&&(0,de.jsx)("button",{type:"button",className:"btn btn-outline",onClick:()=>{Ae(null),ke({title:"",description:"",job_type:"Full-Time",prerequisites:"",status:"Draft"})},children:"Cancel Edit"})]})]})]}),(0,de.jsxs)("div",{className:"glass-card animate-fade-in",children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"6px"},children:[(0,de.jsx)("h2",{style:{...Ce.tabTitle,marginBottom:0},children:"Manage Vacancies"}),(0,de.jsxs)("button",{className:"btn btn-outline",style:{padding:"8px 16px",fontSize:"0.8rem",display:"flex",alignItems:"center",gap:"6px",margin:0},onClick:pa,disabled:Nr,children:[(0,de.jsx)(t,{size:14})," Refresh"]})]}),(0,de.jsxs)("p",{style:Ce.tabText,children:[we.length," total job listing(s) in the system."]}),0===we.length?(0,de.jsxs)("div",{style:{textAlign:"center",padding:"50px 0",color:"var(--text-muted)"},children:[(0,de.jsx)(j,{size:40,style:{opacity:.3,marginBottom:"12px"}}),(0,de.jsx)("p",{children:"No job vacancies posted yet. Use the form above to add your first listing."})]}):(0,de.jsx)("div",{style:{overflowX:"auto"},children:(0,de.jsxs)("table",{style:Ce.table,children:[(0,de.jsx)("thead",{children:(0,de.jsxs)("tr",{children:[(0,de.jsx)("th",{style:{background:"var(--bg-cool)",padding:"12px 16px",fontWeight:"700",color:"var(--primary)",borderBottom:"2px solid var(--border)",textAlign:"left"},children:"Job Title"}),(0,de.jsx)("th",{style:{background:"var(--bg-cool)",padding:"12px 16px",fontWeight:"700",color:"var(--primary)",borderBottom:"2px solid var(--border)",textAlign:"left"},children:"Type"}),(0,de.jsx)("th",{style:{background:"var(--bg-cool)",padding:"12px 16px",fontWeight:"700",color:"var(--primary)",borderBottom:"2px solid var(--border)",textAlign:"left"},children:"Status"}),(0,de.jsx)("th",{style:{background:"var(--bg-cool)",padding:"12px 16px",fontWeight:"700",color:"var(--primary)",borderBottom:"2px solid var(--border)",textAlign:"left"},children:"Description"}),(0,de.jsx)("th",{style:{background:"var(--bg-cool)",padding:"12px 16px",fontWeight:"700",color:"var(--primary)",borderBottom:"2px s
2olid var(--border)",textAlign:"left"},children:"Actions"})]})}),(0,de.jsx)("tbody",{children:we.map(e=>(0,de.jsxs)("tr",{style:{transition:"background 0.15s ease"},onMouseEnter:e=>e.currentTarget.style.background="#F8FAFC",onMouseLeave:e=>e.currentTarget.style.background="transparent",children:[(0,de.jsx)("td",{style:{padding:"14px 16px",borderBottom:"1px solid var(--border)",fontWeight:"600",color:"var(--primary)"},children:e.title}),(0,de.jsx)("td",{style:{padding:"14px 16px",borderBottom:"1px solid var(--border)",fontSize:"0.85rem",color:"var(--text-muted)"},children:(0,de.jsx)("span",{style:{padding:"3px 10px",borderRadius:"20px",background:"rgba(30,168,199,0.08)",color:"var(--accent-teal)",fontWeight:"600",fontSize:"0.75rem"},children:e.job_type})}),(0,de.jsx)("td",{style:{padding:"14px 16px",borderBottom:"1px solid var(--border)"},children:(0,de.jsx)("span",{className:"badge badge-"+("Active"===e.status?"completed":"Closed"===e.status?"awaiting":"submitted"),children:e.status})}),(0,de.jsx)("td",{style:{padding:"14px 16px",borderBottom:"1px solid var(--border)",fontSize:"0.8rem",color:"var(--text-muted)",maxWidth:"280px"},children:(0,de.jsx)("span",{style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:e.description})}),(0,de.jsx)("td",{style:{padding:"14px 16px",borderBottom:"1px solid var(--border)"},children:(0,de.jsxs)("div",{style:{display:"flex",gap:"8px"},children:[(0,de.jsx)("button",{onClick:()=>{Ae(e.id),ke({title:e.title,description:e.description,job_type:e.job_type,prerequisites:e.prerequisites||"",status:e.status}),window.scrollTo({top:0,behavior:"smooth"})},title:"Edit job vacancy",style:{padding:"7px",background:"rgba(30,168,199,0.08)",border:"1px solid rgba(30,168,199,0.3)",borderRadius:"6px",cursor:"pointer",color:"var(--accent-teal)",display:"flex",alignItems:"center",transition:"all 0.2s"},children:(0,de.jsx)(F,{size:15})}),(0,de.jsx)("button",{onClick:()=>(async e=>{if(window.confirm("Are you sure you want to delete this job vacancy?"))try{const t=await(await o("/api/careers/delete",{method:"POST",headers:{Authorization:`Bearer ${g}`,"Content-Type":"application/json"},body:JSON.stringify({id:e})})).json();t.success&&(Fr({type:"success",msg:t.message}),pa())}catch(t){}})(e.id),title:"Delete job vacancy",style:{padding:"7px",background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.3)",borderRadius:"6px",cursor:"pointer",color:"#EF4444",display:"flex",alignItems:"center",transition:"all 0.2s"},children:(0,de.jsx)(A,{size:15})})]})})]},e.id))})]})})]})]}),"syssettings"===Oe&&(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"30px"},children:[(0,de.jsxs)("div",{className:"glass-card animate-fade-in",children:[(0,de.jsx)("h2",{style:Ce.tabTitle,children:"Global System Settings"}),(0,de.jsx)("p",{style:Ce.tabText,children:"Update contact information globally across the website."}),(0,de.jsxs)("form",{onSubmit:async e=>{e.preventDefault(),Ar(!0),Fr({type:"",msg:""});try{const e={...Wr,whatsapp_link:Ca(Wr.whatsapp_link),free_consultation_link:Ca(Wr.free_consultation_link,{allowRelative:!0}),facebook_url:Ca(Wr.facebook_url),x_url:Ca(Wr.x_url),instagram_url:Ca(Wr.instagram_url),youtube_url:Ca(Wr.youtube_url),linkedin_url:Ca(Wr.linkedin_url),threads_url:Ca(Wr.threads_url),google_review_url:Ca(Wr.google_review_url)},t=await(await o("/api/admin/system-settings",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify(e)})).json();t.success?(Lr(e),wa&&wa.setSettings&&wa.setSettings(t=>({...t,...e})),Fr({type:"success",msg:"System Settings updated successfully!"}),ja()):Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"Failed to update system settings."})}finally{Ar(!1)}},children:[(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"20px"},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Contact Number"}),(0,de.jsx)("input",{type:"text",value:Wr.contact_number,onChange:e=>Lr({...Wr,contact_number:e.target.value}),className:"form-control",placeholder:"e.g. +92 300 1234567"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Email Address"}),(0,de.jsx)("input",{type:"email",value:Wr.email,onChange:e=>Lr({...Wr,email:e.target.value}),className:"form-control",placeholder:"e.g. [email protected]"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",htmlFor:"office-hours",children:"Office hours (Pakistan time)"}),(0,de.jsx)("input",{id:"office-hours",className:"form-control",maxLength:180,value:Wr.office_hours||"",placeholder:"MonâFri: 9 AMâ6 PM; Sat: 10 AMâ3 PM (PKT)",onChange:e=>Lr({...Wr,office_hours:e.target.value})}),(0,de.jsx)("label",{className:"form-label",children:"Full Public Office Address"}),(0,de.jsx)("input",{type:"text",value:Wr.address,onChange:e=>Lr({...Wr,address:e.target.value}),className:"form-control",placeholder:"e.g. Office 123, Building Name, Street, Blue Area, Islamabad 44000"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"WhatsApp Link"}),(0,de.jsx)("input",{type:"text",value:Wr.whatsapp_link,onChange:e=>Lr({...Wr,whatsapp_link:e.target.value}),className:"form-control",placeholder:"e.g. https://wa.me/923001234567"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Website Title"}),(0,de.jsx)("input",{type:"text",value:Wr.website_title,onChange:e=>Lr({...Wr,website_title:e.target.value}),className:"form-control",placeholder:"e.g. AM Tax Hub"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Free Consultation Link"}),(0,de.jsx)("input",{type:"text",value:Wr.free_consultation_link,onChange:e=>Lr({...Wr,free_consultation_link:e.target.value}),className:"form-control",placeholder:"e.g. /register or https://example.com/register"})]}),(0,de.jsxs)("div",{style:{gridColumn:"span 2",borderTop:"1px solid var(--border)",paddingTop:"20px"},children:[(0,de.jsx)("h3",{style:{fontSize:"1rem",color:"var(--accent-gold)",marginBottom:"8px",fontWeight:"700"},children:"Verified Postal Address for Google Schema"}),(0,de.jsx)("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"20px"},children:"Enter only the real office details that can be verified on official records and your Google Business Profile."}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:z?"1fr":"2fr 1fr",gap:"20px"},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Office / Building / Street"}),(0,de.jsx)("input",{type:"text",value:Wr.street_address||"",onChange:e=>Lr({...Wr,street_address:e.target.value}),className:"form-control",placeholder:"Office no., building and street"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"City"}),(0,de.jsx)("input",{type:"text",value:Wr.address_locality||"",onChange:e=>Lr({...Wr,address_locality:e.target.value}),className:"form-control",placeholder:"Islamabad"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Province / Region"}
2),(0,de.jsx)("input",{type:"text",value:Wr.address_region||"",onChange:e=>Lr({...Wr,address_region:e.target.value}),className:"form-control",placeholder:"Islamabad Capital Territory"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Postal Code"}),(0,de.jsx)("input",{type:"text",value:Wr.postal_code||"",onChange:e=>Lr({...Wr,postal_code:e.target.value}),className:"form-control",placeholder:"44000"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Country Code"}),(0,de.jsx)("input",{type:"text",maxLength:"2",value:Wr.address_country||"PK",onChange:e=>Lr({...Wr,address_country:e.target.value.toUpperCase()}),className:"form-control",placeholder:"PK"})]})]})]}),(0,de.jsxs)("div",{style:{gridColumn:"span 2",marginTop:"8px",borderTop:"1px solid var(--border)",paddingTop:"20px"},children:[(0,de.jsx)("h3",{style:{fontSize:"1rem",color:"var(--accent-gold)",marginBottom:"15px",fontWeight:"700"},children:"Social Media & Review Links"}),(0,de.jsx)("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"20px"},children:"Update these URLs here, and the website topbar, footer, and Google review button will refresh automatically."}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:z?"1fr":"1fr 1fr",gap:"20px"},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Facebook URL"}),(0,de.jsx)("input",{type:"text",value:Wr.facebook_url||"",onChange:e=>Lr({...Wr,facebook_url:e.target.value}),className:"form-control",placeholder:"https://www.facebook.com/yourpage"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"X (Twitter) URL"}),(0,de.jsx)("input",{type:"text",value:Wr.x_url||"",onChange:e=>Lr({...Wr,x_url:e.target.value}),className:"form-control",placeholder:"https://x.com/yourhandle"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Instagram URL"}),(0,de.jsx)("input",{type:"text",value:Wr.instagram_url||"",onChange:e=>Lr({...Wr,instagram_url:e.target.value}),className:"form-control",placeholder:"https://www.instagram.com/yourhandle"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"YouTube URL"}),(0,de.jsx)("input",{type:"text",value:Wr.youtube_url||"",onChange:e=>Lr({...Wr,youtube_url:e.target.value}),className:"form-control",placeholder:"https://www.youtube.com/@yourchannel"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"LinkedIn URL"}),(0,de.jsx)("input",{type:"text",value:Wr.linkedin_url||"",onChange:e=>Lr({...Wr,linkedin_url:e.target.value}),className:"form-control",placeholder:"https://www.linkedin.com/company/yourcompany"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Threads URL"}),(0,de.jsx)("input",{type:"text",value:Wr.threads_url||"",onChange:e=>Lr({...Wr,threads_url:e.target.value}),className:"form-control",placeholder:"https://www.threads.net/@yourhandle"})]}),(0,de.jsxs)("div",{className:"form-group",style:{gridColumn:z?"span 1":"span 2"},children:[(0,de.jsx)("label",{className:"form-label",children:"Google Review URL"}),(0,de.jsx)("input",{type:"text",value:Wr.google_review_url||"",onChange:e=>Lr({...Wr,google_review_url:e.target.value}),className:"form-control",placeholder:"Paste your Google review/share URL"})]})]})]}),(0,de.jsxs)("div",{className:"form-group",style:{gridColumn:"span 2"},children:[(0,de.jsx)("label",{className:"form-label",style:{display:"flex",alignItems:"center",gap:"6px"},children:"ð Google Gemini API Key (Low-Credit 1.5 Flash Model)"}),(0,de.jsx)("input",{type:"password",value:Wr.gemini_api_key||"",onChange:e=>Lr({...Wr,gemini_api_key:e.target.value}),className:"form-control",placeholder:Wr.gemini_api_key_configured?"Configured â enter a new key only to replace it":"Paste a Gemini API key to enable the AI adviser",style:{border:"1.5px solid var(--accent-gold)"}}),(0,de.jsx)("small",{style:{color:"var(--text-muted)",fontSize:"0.75rem",marginTop:"4px",display:"block"},children:"ð¡ Leave blank to use our fast local database keyword search logic."})]}),(0,de.jsxs)("div",{className:"form-group",style:{gridColumn:"span 2"},children:[(0,de.jsx)("label",{className:"form-label",style:{display:"flex",alignItems:"center",gap:"6px"},children:'ð Â Google Client ID (For "Continue with Google" Auth)'}),(0,de.jsx)("input",{type:"text",value:Wr.google_client_id||"",onChange:e=>Lr({...Wr,google_client_id:e.target.value}),className:"form-control",placeholder:"e.g. 1234567890-abcdefghijklmnopqrstuvwxyz.a
2pps.googleusercontent.com",style:{border:"1.5px solid var(--accent-gold)"}}),(0,de.jsx)("small",{style:{color:"var(--text-muted)",fontSize:"0.75rem",marginTop:"4px",display:"block"},children:"ð¡ Leave blank to disable Google Sign-In. You can get a free Client ID from the Google Cloud Console."})]}),(0,de.jsxs)("div",{style:{gridColumn:"span 2",marginTop:"20px",borderTop:"1px solid var(--border)",paddingTop:"20px"},children:[(0,de.jsx)("h3",{style:{fontSize:"1rem",color:"var(--accent-gold)",marginBottom:"8px",fontWeight:"700"},children:"Google AdSense Readiness"}),(0,de.jsx)("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"18px",lineHeight:1.55},children:"Keep ads disabled until Google approves the site. No ad script or placeholder is currently rendered; future placements are reserved for article and calculator pages only."}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:z?"1fr":"1fr 1fr",gap:"20px"},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Publisher ID"}),(0,de.jsx)("input",{type:"text",value:Wr.adsense_publisher_id||"",onChange:e=>Lr({...Wr,adsense_publisher_id:e.target.value.trim()}),className:"form-control",placeholder:"ca-pub-0000000000000000"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Application Status"}),(0,de.jsxs)("select",{value:Wr.adsense_status||"not_applied",onChange:e=>Lr({...Wr,adsense_status:e.target.value,adsense_enabled:"approved"===e.target.value?Wr.adsense_enabled:"0"}),className:"form-control",children:[(0,de.jsx)("option",{value:"not_applied",children:"Not applied"}),(0,de.jsx)("option",{value:"pending",children:"Application pending"}),(0,de.jsx)("option",{value:"approved",children:"Approved"}),(0,de.jsx)("option",{value:"rejected",children:"Needs correction / rejected"})]})]}),(0,de.jsx)("div",{style:{gridColumn:z?"span 1":"span 2",padding:"11px 13px",borderRadius:"8px",border:"1px solid rgba(0,166,180,0.24)",background:"rgba(0,166,180,0.07)",color:"var(--text-muted)",fontSize:"0.8rem",lineHeight:1.55},children:"Advertising remains hard-disabled in this release. After approval, the final placement module can be activated only on article and calculator templates following a consent and speed review."})]})]}),(0,de.jsxs)("div",{style:{gridColumn:"span 2",marginTop:"20px",borderTop:"1px solid var(--border)",paddingTop:"20px"},children:[(0,de.jsx)("h3",{style:{fontSize:"1rem",color:"var(--accent-gold)",marginBottom:"15px",fontWeight:"700"},children:"ð¨ Secure SMTP Outbound Email Server Configuration"}),(0,de.jsx)("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"20px"},children:"Configure a custom SMTP account (e.g. Hostinger, Gmail, Outlook) to send transactional emails (OTPs, notifications, and invoices) reliably. If left blank, it will automatically fall back to native PHP mail()."}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:z?"1fr":"1fr 1fr",gap:"20px"},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"SMTP Hostname"}),(0,de.jsx)("input",{type:"text",value:Wr.smtp_host||"",onChange:e=>Lr({...Wr,smtp_host:e.target.value}),className:"form-control",placeholder:"e.g. smtp.hostinger.com or smtp.gmail.com"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"SMTP Port"}),(0,de.jsx)("input",{type:"text",value:Wr.smtp_port||"",onChange:e=>Lr({...Wr,smtp_port:e.target.value}),className:"form-control",placeholder:"e.g. 465 or 587"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"SMTP Username (Email)"}),(0,de.jsx)("input",{type:"text",value:Wr.smtp_username||"",onChange:e=>Lr({...Wr,smtp_username:e.target.value}),className:"form-control",placeholder:"e.g. [email protected]"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"SMTP Password"}),(0,de.jsx)("input",{type:"password",value:Wr.smtp_password||"",onChange:e=>Lr({...Wr,smtp_password:e.target.value}),className:"form-control",placeholder:Wr.smtp_password_configured?"Configured â enter a new password only to replace it":"Email account password"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"SMTP Security"}),(0,de.jsxs)("select",{value:Wr.smtp_secure||"ssl",onChange:e=>Lr({...Wr,smtp_secure:e.target.value}),className:"form-control",style:{background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)",borderRadius:"6px",padding:"10px"},children:[(0,de.jsx)("option",{value:"ssl",children:"SSL (Recommended for Port 465)"}),(0,de.jsx)("option",{value:"tls",children:"TLS (Recommended for Port 587)"})]})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Sender Display Name"}),(0,de.jsx)("input",{type:"text",value:Wr.smtp_sender_name||"",onChange:e=>Lr({...Wr,smtp_sender_name:e.target.value}),className:"form-control",placeholder:"e.g. AM Tax & Corporate Hub"})]})]})]})]}),(0,de.jsx)("button",{type:"submit",className:"btn btn-gold",style:{marginTop:"20px",padding:"12px 32px"},disabled:zr,children:zr?"Saving...":"Save System Settings"})]})]}),(0,de.jsxs)("div",{className:"glass-card animate-fade-in",children:[(0,de.jsx)("h2",{style:Ce.tabTitle,children:"AI Assistant Knowledge Base"}),(0,de.jsx)("p",{style:Ce.tabText,children:"Train the website's AI ChatBot with your custom documents and knowledge so it can answer visitor questions accurately."}),(0,de.jsxs)("form",{onSubmit:async e=>{e.preventDefault(),Ar(!0),Fr({type:"",msg:""});try{const e=await(await o("/api/admin/bot-knowledge",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({id:Or.id||0,question:Or.question||"",answer:Or.answer||""})})).json();e.success?(Fr({type:"success",msg:"Bot Knowledge updated successfully!"}),Sa()):Fr({type:"error",msg:e.message})}
2catch(t){Fr({type:"error",msg:"Failed to update bot knowledge."})}finally{Ar(!1)}},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"System Prompt (Instructions/Question)"}),(0,de.jsx)("input",{type:"text",value:Or.question,onChange:e=>qr({...Or,question:e.target.value}),className:"form-control",placeholder:"e.g. System Prompt"})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Knowledge Text Base"}),(0,de.jsx)("textarea",{value:Or.answer,onChange:e=>qr({...Or,answer:e.target.value}),className:"form-control",rows:"8",placeholder:"Paste website text, FAQs, and pricing here to train the bot...",required:!0})]}),(0,de.jsx)("button",{type:"submit",className:"btn btn-gold",style:{marginTop:"20px",padding:"12px 32px"},disabled:zr,children:zr?"Saving & Training...":"Update Knowledge Base"})]})]}),(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{background:"var(--white)",marginTop:"20px",border:"1.5px dashed var(--accent-gold)"},children:[(0,de.jsx)("h3",{style:{...Ce.tabTitle,color:"var(--primary)",display:"flex",alignItems:"center",gap:"8px",marginBottom:"10px"},children:"ð Â Bulk Document Training (.txt Upload)"}),(0,de.jsx)("p",{style:Ce.tabText,children:"Upload a plain text document containing your legal guidelines, tax codes, or company policies. The AI Bot will automatically index its paragraphs and use them to answer questions!"}),(0,de.jsxs)("div",{style:{display:"flex",gap:"12px",alignItems:"center",marginTop:"16px",flexWrap:"wrap"},children:[(0,de.jsx)("input",{type:"file",accept:".txt",id:"bot-training-file",style:{display:"none"},onChange:e=>{const t=e.target.files[0];t&&Gr(t)}}),(0,de.jsx)("button",{type:"button",onClick:()=>document.getElementById("bot-training-file").click(),className:"btn btn-outline",style:{borderRadius:"6px",cursor:"pointer",padding:"10px 20px",fontSize:"0.85rem"},children:"Choose .txt Document"}),(0,de.jsx)("span",{style:{fontSize:"0.85rem",color:"var(--text-muted)",fontWeight:"600"},children:Ur?Ur.name:"No document selected"}),Ur&&(0,de.jsx)("button",{type:"button",onClick:async e=>{if(e&&e.preventDefault(),Ur){Ar(!0),Fr({type:"",msg:""});try{const e=new FormData;e.append("file",Ur);const t=await(await o("/api/admin/bot-knowledge",{method:"POST",headers:{Authorization:`Bearer ${g}`},body:e})).json();if(t.success){Fr({type:"success",msg:t.message||"Bot trained successfully with uploaded file!"}),Gr(null);const e=document.getElementById("bot-training-file");e&&(e.value=""),Sa()}else Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"Failed to upload training document."})}finally{Ar(!1)}}else Fr({type:"error",msg:"Please select a plain text (.txt) document first."})},className:"btn btn-gold",style:{borderRadius:"6px",display:"flex",gap:"6px",alignItems:"center",padding:"10px 20px",fontSize:"0.85rem"},disabled:zr,children:"ð Start Training"})]})]}),(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{background:"var(--white)",marginTop:"20px"},children:[(0,de.jsxs)("h3",{style:{...Ce.tabTitle,color:"var(--primary)",marginBottom:"10px"},children:["ð Active AI Knowledge Indices (",$r.length,")"]}),(0,de.jsx)("p",{style:Ce.tabText,children:"The following documents, system prompts, and Q&A blocks are currently loaded into the AI Assistant's memory context."}),0===$r.length?(0,de.jsx)("div",{style:{padding:"20px",textAlign:"center",background:"var(--bg-light)",borderRadius:"8px",color:"var(--text-muted)"},children:"No active knowledge indexes found. Seeding default tax base..."}):(0,de.jsx)("div",{style:{...Ce.tableResponsive,maxHeight:"350px",overflowY:"auto",border:"1px solid var(--border)",borderRadius:"8px"},children:(0,de.jsxs)("table",{style:Ce.table,children:[(0,de.jsx)("thead",{style:{position:"sticky",top:0,background:"#F8FAFC",zIndex:1},children:(0,de.jsxs)("tr",{children:[(0,de.jsx)("th",{children:"Context Title / Question"}),(0,de.jsx)("th",{children:"Type"}),(0,de.jsx)("th",{children:"Content Preview"}),(0,de.jsx)("th",{children:"Created At"}),(0,de.jsx)("th",{children:"Action"})]})}),(0,de.jsx)("tbody",{children:$r.map(e=>(0,de.jsxs)("tr",{children:[(0,de.jsx)("td",{style:{fontWeight:"700",fontSize:"0.85rem",color:"var(--primary)",maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.question||"Global System Prompt"}),(0,de.jsx)("td",{children:(0,de.jsx)("span",{style:{padding:"2px 8px",borderRadius:"4px",fontSize:"0.75rem",fontWeight:"bold",background:"file"===e.type?"#E0F2FE":"paragraph"===e.type?"#FEF3C7":"#DCFCE7",color:"file"===e.type?"#0369A1":"paragraph"===e.type?"#B45309":"#15803D"},children:(e.type||"text").toUpperCase()})}),(0,de.jsx)("td",{style:{fontSize:"0.8rem",color:"var(--text-muted)",maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.answer}),(0,de.jsx)("td",{style:{fontSize:"0.8rem",color:"var(--text-muted)"},children:new Date(e.created_at||Date.now()).toLocaleDateString("en-PK")}),(0,de.jsx)("td",{children:(0,de.jsx)("button",{onClick:()=>(async e=>{if(window.confirm("Are you sure you want to delete this knowledge base entry?")){Ar(!0),Fr({type:"",msg:""});try{const t=await(await o(`/api/admin/bot-knowledge?id=${e}`,{method:"DELETE",headers:{Authorization:`Bearer ${g}`}})).json();t.success?(Fr({type:"success",msg:"Knowledge entry deleted successfully!"}),Sa()):Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"Failed to delete knowledge entry."})}finally{Ar(!1)}}})(e.id),className:"btn btn-outline",style:{padding:"4px 8px",fontSize:"0.75rem",margin:0,color:"#EF4444",border:"1px solid #EF4444"},disabled:zr,children:"Delete"})})]},e.id))})]})})]}),(0,de.jsxs)("div",{className:"glass-card animate-fade-in",children:[(0,de.jsx)("h2",{style:Ce.tabTitle,children:"Bank Payment Credentials"}),(0,de.jsx)("p",{style:Ce.tabText,children:"Update the bank account details and payment QR code shown to clients in the billing section of their portal."}),(0,de.jsxs)("form",{onSubmit:async e=>{e.preventDefault(),Ar(!0),Fr({type:"",msg:""});try{const e=new FormData;
2e.append("bank_name",Vr.bank_name),e.append("account_title",Vr.account_title),e.append("account_no",Vr.account_no),e.append("iban_no",Vr.iban_no),Yr&&e.append("qr_code",Yr);const t=await(await o("/api/admin/update-payment-settings",{method:"POST",headers:{Authorization:`Bearer ${g}`},body:e})).json();t.success?(Fr({type:"success",msg:"Payment credentials updated successfully!"}),Jr(null),va()):Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"Failed to update payment settings."})}finally{Ar(!1)}},children:[(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"20px"},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Bank Name"}),(0,de.jsx)("input",{type:"text",value:Vr.bank_name,onChange:e=>Hr({...Vr,bank_name:e.target.value}),className:"form-control",placeholder:"e.g. Meezan Bank Ltd",required:!0})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Account Title"}),(0,de.jsx)("input",{type:"text",value:Vr.account_title,onChange:e=>Hr({...Vr,account_title:e.target.value}),className:"form-control",placeholder:"e.g. AM Tax Hub",required:!0})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Account Number"}),(0,de.jsx)("input",{type:"text",value:Vr.account_no,onChange:e=>Hr({...Vr,account_no:e.target.value}),className:"form-control",placeholder:"e.g. 0340-1020304",required:!0})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"IBAN Number"}),(0,de.jsx)("input",{type:"text",value:Vr.iban_no,onChange:e=>Hr({...Vr,iban_no:e.target.value}),className:"form-control",placeholder:"e.g. PK98MEZN00340102030405",required:!0})]})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginTop:"10px"},children:[(0,de.jsx)("label",{className:"form-label",children:"Upload Payment QR Code Image (Optional)"}),(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"16px",marginTop:"6px"},children:[(0,de.jsx)("input",{type:"file",id:"qr-upload",accept:"image/*",onChange:e=>Jr(e.target.files[0]),style:{display:"none"}}),(0,de.jsxs)("label",{htmlFor:"qr-upload",className:"btn btn-outline",style:{cursor:"pointer",margin:0,padding:"10px 20px",fontSize:"0.85rem",display:"inline-flex",gap:"8px"},children:[(0,de.jsx)(Y,{size:16})," ",Yr?Yr.name:"Choose QR Image"]}),Pr?.qr_path&&(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,de.jsx)("img",{src:`/api/${Pr.qr_path}`,alt:"Current QR",style:{width:"60px",height:"60px",objectFit:"contain",border:"1px solid var(--border)",borderRadius:"6px",padding:"3px"}}),(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)"},children:"Current QR"})]})]})]}),(0,de.jsx)("button",{type:"submit",className:"btn btn-gold",style:{marginTop:"20px",padding:"12px 32px"},disabled:zr,children:zr?"Saving...":"Save Payment Settings"})]})]}),(0,de.jsxs)("div",{className:"glass-card animate-fade-in",children:[(0,de.jsx)("h2",{style:Ce.tabTitle,children:"Scrolling News Ticker Manager"}),(0,de.jsx)("p",{style:Ce.tabText,children:"Add or remove live announcements displayed in the scrolling news bar at the top of the website."}),(0,de.jsx)("form",{onSubmit:async e=>{if(e.preventDefault(),Kr.trim()){Ar(!0),Fr({type:"",msg:""});try{const e=await(await o("/api/ticker-news",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({content:Kr.trim()})})).json();e.success?(Fr({type:"success",msg:"News published to ticker successfully!"}),Xr(""),ba()):Fr({type:"error",msg:e.message})}catch(t){Fr({type:"error",msg:"Failed to publish news."})}finally{Ar(!1)}}},style:{marginBottom:"30px"},children:(0,de.jsxs)("div",{style:{display:"flex",gap:"12px",alignItems:"flex-end"},children:[(0,de.jsxs)("div",{className:"form-group",style:{flex:1,marginBottom:0},children:[(0,de.jsx)("label",{className:"form-label",children:"New Alert / Announcement"}),(0,de.jsx)("input",{type:"text",value:Kr,onChange:e=>Xr(e.target.value),className:"form-control",placeholder:"e.g. ð¢ FBR Tax Filing Deadline extended to September 30, 2026!",required:!0})]}),(0,de.jsx)("button",{type:"submit",className:"btn btn-gold",style:{margin:0,padding:"12px 24px",whiteSpace:"nowrap"},disabled:zr,children:"+ Publish Alert"})]})}),0===Ir.length?(0,de.jsx)("p",{style:{textAlign:"center",color:"var(--text-muted)",padding:"20px 0"},children:"No active news alerts in the ticker."}):(0,de.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:Ir.map(e=>(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"14px 18px",background:"linear-gradient(90deg, rgba(212,175,55,0.06), #FFFDF5)",border:"1px solid rgba(212,175,55,0.25)",borderRadius:"var(--radius-sm)"},children:[(0,de.jsx)("span",{style:{fontSize:"0.9rem",color:"var(--primary)",fontWeight:"500",flex:1,paddingRight:"20px"},children:e.content}),(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",flexShrink:0},children:[(0,de.jsx)("span",{style:{fontSize:"0.72rem",color:"var(--text-muted)"},children:new Date(e.created_at).toLocaleDateString()}),(0,de.jsx)("button",{onClick:()=>(async e=>{if(window.confirm("Remove this news alert from the scrolling ticker?")){Ar(!0);try{const t=await(await o(`/api/ticker-news?id=${e}`,{method:"DELETE",headers:{Authorization:`Bearer ${g}`}})).json();t.success?(Fr({type:"success",msg:"News item deleted."}),ba()):Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"Failed to delete news."})}finally{Ar(!1)}}})(e.id),className:"btn btn-danger",style:{padding:"6px",borderRadius:"6px",display:"inline-flex",alignItems:"center",justifyContent:"center"},title:"Remove from ticker",disabled:zr,children:(0,de.jsx)(A,{size:14})})]})]},e.id))})]})]}),"team"===Oe&&(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"30px"},children:[(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{background:"var(--white)",padding:"24px",borderRadius:"var(--radius-md)",border:"1px solid var(--border)"},children:[(0,de.jsx)("h2",{style:Ce.tabTitle,children:"Corporate Team Directory"}),(0,de.jsx)("p",{style:Ce.tabText,children:"Add, modify, or remove executive members of the team. Control which members are highlighted on the landing page and specify their exact display positions."})]}),(0,de.jsxs)("div",{className:"dashboard-detail-grid",style:{gap:"30px"},children:[(0,de.jsxs)("div",{id:"team-form-card",className:"glass-card animate-fade-in",style:{background:"var(--white)",alignSelf:"start",padding:"24px",borderRadius:"var(--radius-md)",border:"1px solid var(--border)"},children:[(0,de.jsxs)("h3",{style:{...Ce.subBlockTitle,display:"flex",alignItems:"center",gap:"8px",margin:0,paddingBottom:"16
2px",borderBottom:"1px solid var(--border)"},children:[(0,de.jsx)($,{size:18})," ",Os?`Edit Member: ${Os.name}`:"Register New Member"]}),(0,de.jsxs)("form",{onSubmit:async e=>{e.preventDefault(),Ar(!0),Fr({type:"",msg:""});try{const e=new FormData;e.append("id",$s.id||0),e.append("name",$s.name.trim()),e.append("role",$s.role.trim()),e.append("credentials",($s.credentials||"").trim()),e.append("credentials_verified",$s.credentials_verified?1:0),e.append("verification_reference",($s.verification_reference||"").trim()),e.append("specialization",($s.specialization||"").trim()),e.append("bio",($s.bio||"").trim()),e.append("show_on_home",$s.show_on_home?1:0),$s.show_on_home&&e.append("home_position",$s.home_position||""),aa&&e.append("avatar_photo",aa);const t=await(await o("/api/admin/save-team-member",{method:"POST",headers:{Authorization:`Bearer ${g}`},body:e})).json();t.success?(Fr({type:"success",msg:t.message}),qs(null),Ms({id:"",name:"",role:"",credentials:"",credentials_verified:!1,verification_reference:"",specialization:"",bio:"",show_on_home:!1,home_position:""}),ia(null),la(""),ka()):Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"Failed to save team member details."})}finally{Ar(!1)}},style:{marginTop:"20px"},children:[(0,de.jsxs)("div",{className:"form-group",style:{marginBottom:"16px"},children:[(0,de.jsx)("label",{className:"form-label",style:{fontWeight:"600",fontSize:"0.85rem"},children:"Full Name *"}),(0,de.jsx)("input",{type:"text",className:"form-control",placeholder:"e.g. Barrister Ali Khan",value:$s.name,onChange:e=>Ms({...$s,name:e.target.value}),required:!0})]}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(180px, 0.7fr) 1.3fr",gap:"16px",marginBottom:"16px",alignItems:"end"},children:[(0,de.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:"10px",minHeight:"42px",fontWeight:"700",fontSize:"0.85rem"},children:[(0,de.jsx)("input",{type:"checkbox",checked:$s.credentials_verified,onChange:e=>Ms({...$s,credentials_verified:e.target.checked})}),"Credentials independently verified"]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",style:{fontWeight:"600",fontSize:"0.85rem"},children:"Verification Reference URL"}),(0,de.jsx)("input",{type:"url",className:"form-control",placeholder:"Official registry/profile URL",value:$s.verification_reference,onChange:e=>Ms({...$s,verification_reference:e.target.value}),required:$s.credentials_verified})]})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginBottom:"16px"},children:[(0,de.jsx)("label",{className:"form-label",style:{fontWeight:"600",fontSize:"0.85rem"},children:"Professional Title / Role *"}),(0,de.jsx)("input",{type:"text",className:"form-control",placeholder:"e.g. Lead Tax Consultant",value:$s.role,onChange:e=>Ms({...$s,role:e.target.value}),required:!0})]}),(0,de.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px",marginBottom:"16px"},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",style:{fontWeight:"600",fontSize:"0.85rem"},children:"Credentials"}),(0,de.jsx)("input",{type:"text",className:"form-control",placeholder:"e.g. ACA, LL.M (LSE)",value:$s.credentials,onChange:e=>Ms({...$s,credentials:e.target.value})})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",style:{fontWeight:"600",fontSize:"0.85rem"},children:"Specialization"}),(0,de.jsx)("input",{type:"text",className:"form-control",placeholder:"e.g. Corporate Law, FBR Audit",value:$s.specialization,onChange:e=>Ms({...$s,specialization:e.target.value})})]})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginBottom:"16px"},children:[(0,de.jsx)("label",{className:"form-label",style:{fontWeight:"600",fontSize:"0.85rem"},children:"Biography / Summary"}),(0,de.jsx)("textarea",{className:"form-control",rows:"3",placeholder:"Brief overview of their qualifications, expertise, or background...",value:$s.bio,onChange:e=>Ms({...$s,bio:e.target.value})})]}),(0,de.jsxs)("div",{className:"form-group",style:{marginBottom:"20px"},children:[(0,de.jsx)("label",{className:"form-label",style:{fontWeight:"600",fontSize:"0.85rem"},children:"Profile Picture (Square recommended)"}),(0,de.jsxs)("div",{style:{border:"2px dashed var(--border)",borderRadius:"8px",padding:"20px",textAlign:"center",background:"rgba(212,175,55,0.01)",position:"relative",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"12px",marginTop:"6px"},children:[na?(0,de.jsxs)("div",{style:{position:"relative"},children:[(0,de.jsx)("img",{src:na,alt:"Avatar Preview",style:{width:"100px",height:"100px",borderRadius:"50%",objectFit:"cover",border:"2px s
2olid var(--accent-gold)"}}),(0,de.jsx)("button",{type:"button",onClick:()=>{ia(null),la("")},style:{position:"absolute",top:"-4px",right:"-4px",background:"#E02424",color:"#FFFFFF",border:"none",borderRadius:"50%",width:"24px",height:"24px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"var(--shadow-md)"},title:"Remove picture",children:(0,de.jsx)(A,{size:12})})]}):(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"8px"},children:[(0,de.jsx)("div",{style:{width:"54px",height:"54px",borderRadius:"50%",background:"rgba(212,175,55,0.08)",color:"var(--accent-gold)",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,de.jsx)(Y,{size:24})}),(0,de.jsx)("span",{style:{fontSize:"0.8rem",color:"var(--text-muted)"},children:"Drag & drop or browse image"})]}),(0,de.jsx)("input",{type:"file",id:"avatar-upload-input",accept:"image/*",onChange:e=>{const t=e.target.files[0];t&&(ia(t),la(URL.createObjectURL(t)))},style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",opacity:0,cursor:"pointer"}})]})]}),(0,de.jsxs)("div",{style:{background:"rgba(212,175,55,0.04)",border:"1px solid rgba(212,175,55,0.15)",borderRadius:"8px",padding:"16px",marginBottom:"24px"},children:[(0,de.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0},children:[(0,de.jsx)("input",{type:"checkbox",checked:$s.show_on_home,onChange:e=>Ms({...$s,show_on_home:e.target.checked}),style:{width:"16px",height:"16px",accentColor:"var(--accent-gold)",cursor:"pointer"}}),(0,de.jsx)("span",{style:{fontSize:"0.9rem",fontWeight:"700",color:"var(--primary)"},children:"Feature on Landing Page"})]}),(0,de.jsx)("p",{style:{fontSize:"0.75rem",color:"var(--text-muted)",margin:"4px 0 0 26px"},children:"Highlight this member on the main page corporate carousel (maximum of 4 members)."}),$s.show_on_home&&(0,de.jsxs)("div",{className:"animate-fade-in",style:{marginTop:"16px",paddingLeft:"26px"},children:[(0,de.jsx)("label",{className:"form-label",style:{fontWeight:"700",fontSize:"0.8rem",color:"var(--primary)",marginBottom:"8px",display:"block"},children:"Display Priority Slot"}),(0,de.jsx)("div",{style:{display:"flex",gap:"10px"},children:[1,2,3,4].map(e=>(0,de.jsxs)("button",{type:"button",onClick:()=>Ms({...$s,home_position:e}),style:{flex:1,padding:"10px",border:$s.home_position===e?"2px solid var(--accent-gold)":"1px solid var(--border)",background:$s.home_position===e?"rgba(212,175,55,0.1)":"var(--white)",color:$s.home_position===e?"var(--primary)":"var(--text-muted)",borderRadius:"6px",fontWeight:"700",cursor:"pointer",fontSize:"0.85rem",transition:"all 0.2s ease",display:"flex",flexDirection:"column",alignItems:"center",gap:"2px"},children:[(0,de.jsxs)("span",{children:["Slot ",e]}),(0,de.jsxs)("span",{style:{fontSize:"0.65rem",fontWeight:"500",opacity:.7},children:["Position ",e]})]},e))}),(0,de.jsx)("p",{style:{fontSize:"0.7rem",color:"var(--accent-teal)",marginTop:"8px",fontWeight:"500"},children:"Note: Assigning a slot will automatically replace any team member currently occupying that slot."})]})]}),(0,de.jsxs)("div",{style:{display:"flex",gap:"12px"},children:[(0,de.jsx)("button",{type:"submit",className:"btn btn-gold",style:{flex:2,padding:"12px"},disabled:zr,children:zr?"Saving...":Os?"Update Profile":"Add Team Member"}),(Os||$s.name||$s.role||na)&&(0,de.jsx)("button",{type:"button",className:"btn btn-outline",style:{flex:1,padding:"12px",border:"1px solid var(--border)",background:"var(--white)"},onClick:()=>{qs(null),Ms({id:"",name:"",role:"",credentials:"",credentials_verified:!1,verification_reference:"",specialization:"",bio:"",show_on_home:!1,home_position:""}),ia(null),la("")},children:"Cancel"})]})]})]}),(0,de.jsxs)("div",{className:"glass-card animate-fade-in",style:{background:"var(--white)",padding:"24px",borderRadius:"var(--radius-md)",border:"1px solid var(--border)"},children:[(0,de.jsx)("h3",{style:{...Ce.subBlockTitle,margin:0,paddingBottom:"16px",borderBottom:"1px solid var(--border)"},children:"Active Team Directory"}),Ts?(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"50px 0",gap:"12px"},children:[(0,de.jsx)("div",{className:"loader",style:{border:"3px solid rgba(212,175,55,0.1)",borderTop:"3px solid #D4AF37",borderRadius:"50%",width:"32px",height:"32px",animation:"spin 1s linear infinite"}}),(0,de.jsx)("span",{style:{fontSize:"0.85rem",color:"var(--text-muted)"},children:"Fetching team roster..."})]}):0===zs.length?(0,de.jsxs)("div",{style:{textAlign:"center",padding:"50px 20px",color:"var(--text-muted)"},children:[(0,de.jsx)(C,{size:40,style:{color:"var(--border)",marginBottom:"16
2px"}}),(0,de.jsx)("p",{style:{fontSize:"0.9rem",fontWeight:"500",margin:0},children:"No team members registered yet."}),(0,de.jsx)("p",{style:{fontSize:"0.8rem",marginTop:"4px"},children:"Fill out the form to add the first executive team member."})]}):(0,de.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"16px",marginTop:"20px"},children:zs.map(e=>(0,de.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:"16px",padding:"16px",background:"rgba(212,175,55,0.01)",border:"1px solid var(--border)",borderRadius:"8px",transition:"all 0.2s ease"},children:[(0,de.jsx)("div",{style:{flexShrink:0},children:e.avatar_path?(0,de.jsx)("img",{src:`/api/${e.avatar_path}`,alt:e.name,style:{width:"60px",height:"60px",borderRadius:"50%",objectFit:"cover",border:"1px solid var(--border)"}}):(0,de.jsx)("div",{style:{width:"60px",height:"60px",borderRadius:"50%",background:"rgba(212,175,55,0.08)",color:"var(--accent-gold)",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"700",fontSize:"1.2rem",border:"1px solid rgba(212,175,55,0.2)"},children:e.name?e.name.split(" ").map(e=>e[0]).join("").substring(0,2).toUpperCase():"AM"})}),(0,de.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,de.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[(0,de.jsx)("h4",{style:{margin:0,fontSize:"1rem",fontWeight:"700",color:"var(--primary)"},children:e.name}),e.credentials&&(0,de.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--accent-gold)",background:"rgba(212,175,55,0.08)",padding:"2px 8px",borderRadius:"4px",fontWeight:"700"},children:e.credentials}),1===parseInt(e.show_on_home)&&(0,de.jsxs)("span",{style:{fontSize:"0.75rem",color:"#10B981",background:"rgba(16,185,129,0.08)",padding:"2px 8px",borderRadius:"4px",fontWeight:"700",display:"inline-flex",alignItems:"center",gap:"4px"},children:["Featured (Slot ",e.home_position,")"]})]}),(0,de.jsx)("p",{style:{margin:"4px 0 0 0",fontSize:"0.85rem",color:"var(--text-muted)",fontWeight:"600"},children:e.role}),e.specialization&&(0,de.jsxs)("p",{style:{margin:"6px 0 0 0",fontSize:"0.75rem",color:"var(--accent-teal)",fontWeight:"500"},children:[(0,de.jsx)("strong",{children:"Expertise:"})," ",e.specialization]}),e.bio&&(0,de.jsx)("p",{style:{margin:"8px 0 0 0",fontSize:"0.8rem",color:"var(--text-muted)",lineHeight:"1.4",display:"-webkit-box",WebkitLineClamp:"2",WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},title:e.bio,children:e.bio})]}),(0,de.jsxs)("div",{style:{display:"flex",gap:"8px",flexShrink:0},children:[(0,de.jsx)("button",{onClick:()=>(e=>{qs(e),Ms({id:e.id,name:e.name||"",role:e.role||"",credentials:e.credentials||"",credentials_verified:1===parseInt(e.credentials_verified),verification_reference:e.verification_reference||"",specialization:e.specialization||"",bio:e.bio||"",show_on_home:1===parseInt(e.show_on_home),home_position:e.home_position||""}),ia(null),la(e.avatar_path?`/api/${e.avatar_path}`:""),setTimeout(()=>{const e=document.getElementById("team-form-card");e&&e.scrollIntoView({behavior:"smooth",block:"start"})},100)})(e),className:"btn btn-outline",style:{padding:"8px",borderRadius:"6px",minWidth:"auto",background:"var(--white)",border:"1px solid var(--border)"},title:"Edit profile details",disabled:zr,children:(0,de.jsx)($,{size:14,style:{color:"var(--primary)"}})}),(0,de.jsx)("button",{onClick:()=>(async e=>{if(window.confirm("Are you sure you want to permanently delete this team member? This will remove them from the database and delete their photo.")){Ar(!0),Fr({type:"",msg:""});try{const t=await(await o("/api/admin/delete-team-member",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({id:e})})).json();t.success?(Fr({type:"success",msg:t.message}),ka()):Fr({type:"error",msg:t.message})}catch(t){Fr({type:"error",msg:"Failed to delete team member."})}finally{Ar(!1)}}})(e.id),className:"btn btn-danger",style:{padding:"8px",borderRadius:"6px",minWidth:"auto"},title:"Delete team member",disabled:zr,children:(0,de.jsx)(A,{size:14})})]})]},e.id))})]})]})]})]}),We?.review&&(0,de.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e4,padding:"20px",backgroundColor:"rgba(15, 23, 42, 0.72)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,de.jsxs)("div",{style:{width:"100%",maxWidth:"560px",maxHeight:"90vh",overflowY:"auto",background:"light"===e?"#FFFFFF":"#0F172A",border:"2px s
2olid var(--accent-gold)",borderRadius:"16px",padding:z?"22px":"30px",boxShadow:"var(--shadow-lg), 0 0 25px rgba(212, 175, 55, 0.2)"},children:[(0,de.jsx)("h3",{style:{fontSize:"1.25rem",fontWeight:"800",color:"var(--primary)",marginBottom:"8px"},children:"Verify & Publish Review"}),(0,de.jsxs)("p",{style:{color:"var(--text-muted)",fontSize:"0.84rem",lineHeight:"1.55",marginBottom:"20px"},children:[(0,de.jsx)("strong",{children:We.review.name})," â ",We.review.reviewer_email||"legacy review without stored email"]}),(0,de.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),!We?.review)return;const t="client_service"===We.review_source;if(!t||/^\d+$/.test(String(We.service_request_id))){if(!t&&String(We.verification_note||"").trim().length<5)Fr({type:"error",msg:"Record how the website or calculator user was verified."});else if(window.confirm("Confirm that identity/evidence was checked and written publication consent is on record.")){Ar(!0),Fr({type:"",msg:""});try{const e=await(await o("/api/reviews/approve",{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({id:We.review.id,status:"approved",verified:!0,consent_confirmed:!0,review_source:We.review_source,service_request_id:t?We.service_request_id:null,verification_note:We.verification_note})})).json();e.success?(Fr({type:"success",msg:"Review verified and published on the homepage."}),Le(null),_a()):Fr({type:"error",msg:e.message})}catch(r){Fr({type:"error",msg:"Failed to verify and publish the review."})}finally{Ar(!1)}}}else Fr({type:"error",msg:"Enter the completed service request ID for a paid/advisory review."})},style:{display:"flex",flexDirection:"column",gap:"16px"},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Experience Type"}),(0,de.jsxs)("select",{className:"form-control",value:We.review_source,onChange:e=>Le({...We,review_source:e.target.value,service_request_id:"",verification_note:""}),required:!0,children:[(0,de.jsx)("option",{value:"website_visitor",children:"Website / Tax Resources"}),(0,de.jsx)("option",{value:"calculator_user",children:"Free Tax Calculator"}),(0,de.jsx)("option",{value:"client_service",children:"Paid / Advisory Service"})]})]}),"client_service"===We.review_source?(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Completed Service Request ID"}),(0,de.jsx)("input",{type:"number",min:"1",className:"form-control",value:We.service_request_id,onChange:e=>Le({...We,service_request_id:e.target.value}),placeholder:"e.g. 125",required:!0})]}):(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Verification Record"}),(0,de.jsx)("textarea",{className:"form-control",rows:"3",maxLength:"255",value:We.verification_note,onChange:e=>Le({...We,verification_note:e.target.value}),placeholder:"e.g. Reviewer confirmed ownership by replying from the submitted email on 19 July 2026",required:!0}),(0,de.jsx)("small",{style:{color:"var(--text-muted)",lineHeight:"1.45"},children:"Record the real check performed. This note stays private and is never shown on the homepage."})]}),(0,de.jsxs)("div",{style:{display:"flex",gap:"10px",justifyContent:"flex-end"},children:[(0,de.jsx)("button",{type:"button",className:"btn btn-outline",onClick:()=>Le(null),disabled:zr,children:"Cancel"}),(0,de.jsx)("button",{type:"submit",className:"btn btn-gold",disabled:zr,children:zr?"Publishing...":"Verify & Publish"})]})]})]})}),Ws&&(0,de.jsx)("div",{style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(15, 23, 42, 0.7)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"20px"},children:(0,de.jsxs)("div",{style:{background:"light"===e?"#FFFFFF":"radial-gradient(circle at top right, #1E293B 0%, #0F172A 100%)",border:"2px solid var(--accent-gold)",borderRadius:"16px",padding:"30px",maxWidth:"500px",width:"100%",boxShadow:"var(--shadow-lg), 0 0 25px rgba(212, 175, 55, 0.2)"},children:[(0,de.jsxs)("h3",{style:{fontSize:"1.25rem",fontWeight:"800",color:"var(--primary)",borderBottom:"2.5px solid var(--accent-gold)",paddingBottom:"8px",marginBottom:"16
2px"},children:["Payout Account: ",Ws.agent_name]}),Ws.details?"object"==typeof Ws.details?(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"12px",fontSize:"0.9rem",color:"var(--text-main)"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("strong",{style:{color:"var(--text-muted)"},children:"Bank / Mobile Provider:"}),(0,de.jsx)("div",{style:{fontWeight:"700",marginTop:"2px"},children:Ws.details.bank_name||"N/A"})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("strong",{style:{color:"var(--text-muted)"},children:"Account Title Name:"}),(0,de.jsx)("div",{style:{fontWeight:"700",marginTop:"2px"},children:Ws.details.account_title||"N/A"})]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("strong",{style:{color:"var(--text-muted)"},children:"Account Number / IBAN:"}),(0,de.jsx)("div",{style:{fontWeight:"700",color:"var(--accent-teal)",marginTop:"2px"},children:Ws.details.account_number||"N/A"})]}),Ws.details.mobile_wallet&&(0,de.jsxs)("div",{children:[(0,de.jsx)("strong",{style:{color:"var(--text-muted)"},children:"Alternative Mobile Wallet Phone:"}),(0,de.jsx)("div",{style:{fontWeight:"700",marginTop:"2px"},children:Ws.details.mobile_wallet})]})]}):(0,de.jsx)("div",{style:{fontSize:"0.9rem",color:"var(--text-main)",whiteSpace:"pre-wrap",background:"var(--bg-cool)",padding:"12px",borderRadius:"6px",border:"1px solid var(--border)"},children:Ws.details}):(0,de.jsx)("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"No payment receiving coordinates saved by this agent yet."}),(0,de.jsx)("button",{onClick:()=>Ls(null),className:"btn btn-gold",style:{width:"100%",marginTop:"24px"},children:"Close Details View"})]})}),Ue&&(0,de.jsx)("div",{style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(15, 23, 42, 0.7)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"20px"},children:(0,de.jsxs)("div",{style:{background:"light"===e?"#FFFFFF":"radial-gradient(circle at top right, #1E293B 0%, #0F172A 100%)",border:"2px solid var(--accent-gold)",borderRadius:"16px",padding:"30px",maxWidth:"600px",width:"100%",maxHeight:"90vh",overflowY:"auto",boxShadow:"var(--shadow-lg), 0 0 25px rgba(212, 175, 55, 0.2)"},children:[(0,de.jsx)("h3",{style:{fontSize:"1.25rem",fontWeight:"800",color:"var(--primary)",borderBottom:"2.5px solid var(--accent-gold)",paddingBottom:"8px",marginBottom:"20px"},children:"Create New Service Task"}),(0,de.jsxs)("form",{onSubmit:async e=>{e.preventDefault(),Ar(!0),Fr({type:"",msg:""});try{const e=await(await o("/api/admin/create-task",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify(rt)})).json();e.success?(Fr({type:"success",msg:e.message}),Ge(!1),st({client_type:"existing",client_id:"",client_name:"",client_email:"",client_phone:"",service_type:"",details:"",assigned_consultant_id:""}),await da(),await ca()):Fr({type:"error",msg:e.message})}catch(t){Fr({type:"error",msg:"Failed to create task."})}finally{Ar(!1)}},style:{display:"flex",flexDirection:"column",gap:"16px"},children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",style:{display:"block",marginBottom:"8px"},children:"Client Type"}),(0,de.jsxs)("div",{style:{display:"flex",gap:"20px"},children:[(0,de.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",fontSize:"0.9rem",color:"var(--text-main)"},children:[(0,de.jsx)("input",{type:"radio",name:"client_type",value:"existing",checked:"existing"===rt.client_type,onChange:e=>st({...rt,client_type:e.target.value})}),"Existing Registered Client"]}),(0,de.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",fontSize:"0.9rem",color:"var(--text-main)"},children:[(0,de.jsx)("input",{type:"radio",name:"client_type",value:"new",checked:"new"===rt.client_type,onChange:e=>st({...rt,client_type:e.target.value})}),"New Client (Auto-register account)"]})]})]}),"existing"===rt.client_type?(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"6px"},children:[(0,de.jsx)("label",{className:"form-label",style:{margin:0},children:"Select Client *"}),Ve&&(0,de.jsxs)("span",{style:{fontSize:"11px",color:"#10b981",fontWeight:600},children:["Filtering clients... (",pe.filter(e=>"client"===e.role).filter(e=>(e.name||"").toLowerCase().includes(Ve.toLowerCase())||(e.email||"").toLowerCase().includes(Ve.toLowerCase())||String(e.id).includes(Ve)).length," found)"]})]}),(0,de.jsxs)("div",{style:{position:"relative",marginBottom:"8px"},children:[(0,de.jsx)("input",{type:"text",placeholder:"ð Â Type Client Name, Email, or ID to search...",value:Ve,onChange:e=>He(e.target.value),className:"form-control",style:{background:"rgba(255, 255, 255, 0.08)",color:"#ffffff",border:"1px solid #10b981",borderRadius:"8px",padding:"10px 14px",fontSize:"13px",fontWeight:600,outline:"none"}}),Ve&&(0,de.jsx)("button",{type:"button",onClick:()=>He(""),style:{position:"absolute",right:"10px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",color:"#9ca3af",fontSize:"14px",cursor:"pointer"},children:"â"})]}),(0,de.jsxs)("select",{value:rt.client_id,onChange:e=>st({...rt,client_id:e.target.value}),className:"form-control",required:!0,style:{background:"rgba(255,255,255,0.03)",color:"#fff",border:"1px solid var(--border)",borderRadius:"8px"},children:[(0,de.jsxs)("option",{value:"",style:{background:"var(--primary)"},children:["-- Select Registered Client (",pe.filter(e=>"client"===e.role).length," total) --"]}),pe.filter(e=>"client"===e.role).filter(e=>{if(!Ve.trim())return!0;
2const t=Ve.toLowerCase().trim(),r=(e.name||"").toLowerCase().includes(t),s=(e.email||"").toLowerCase().includes(t),a=String(e.id).includes(t),i=(e.cnic||"").includes(t),n=(e.phone||"").includes(t);return r||s||a||i||n}).map(e=>(0,de.jsxs)("option",{value:e.id,style:{background:"var(--primary)"},children:[e.id," â ",e.name," (",e.email||"No email",")"]},e.id))]})]}):(0,de.jsxs)(de.Fragment,{children:[(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Client Full Name *"}),(0,de.jsx)("input",{type:"text",className:"form-control",value:rt.client_name,onChange:e=>st({...rt,client_name:e.target.value}),placeholder:"e.g. Muhammad Ali",required:!0})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Client Email Address *"}),(0,de.jsx)("input",{type:"email",className:"form-control",value:rt.client_email,onChange:e=>st({...rt,client_email:e.target.value}),placeholder:"e.g. [email protected]",required:!0})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Client Mobile / Phone Number"}),(0,de.jsx)("input",{type:"text",className:"form-control",value:rt.client_phone,onChange:e=>st({...rt,client_phone:e.target.value}),placeholder:"e.g. 0300-1234567"})]})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Service Type *"}),(0,de.jsxs)("select",{value:rt.service_type,onChange:e=>st({...rt,service_type:e.target.value}),className:"form-control",required:!0,style:{background:"rgba(255,255,255,0.03)",color:"#fff",border:"1px solid var(--border)"},children:[(0,de.jsx)("option",{value:"",style:{background:"var(--primary)"},children:"-- Select Service Type --"}),Wt&&Wt.length>0?Wt.map(e=>(0,de.jsx)("option",{value:e.service_key,style:{background:"var(--primary)"},children:e.service_name},e.id)):[{key:"income_tax_salaried",label:"Income Tax Return â Salaried Individual"},{key:"income_tax_business",label:"Income Tax Return â Business/Self-Employed"},{key:"ntn_registration",label:"NTN Registration (FBR)"},{key:"sales_tax_pra",label:"Sales Tax Registration â PRA (Punjab)"},{key:"sales_tax_srb",label:"Sales Tax Registration â SRB (Sindh)"},{key:"sales_tax_monthly",label:"Monthly Sales Tax Filing"},{key:"secp_pvt",label:"SECP Private Limited Company Registration"},{key:"secp_smc",label:"SECP Single Member Company (SMC-Pvt Ltd)"},{key:"secp_aop",label:"Partnership / AOP Deed Registration"},{key:"trademark",label:"Trademark & Brand Registration"},{key:"fbr_return_company",label:"Corporate Annual Tax Return Filing"},{key:"withholding_tax",label:"Withholding Tax Statement Filing"}].map(e=>(0,de.jsx)("option",{value:e.key,style:{background:"var(--primary)"},children:e.label},e.key))]})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Task Description / Instructions *"}),(0,de.jsx)("textarea",{value:rt.details,onChange:e=>st({...rt,details:e.target.value}),placeholder:"Provide details about the task, requirements, or documents provided...",rows:"4",className:"form-control",required:!0})]}),(0,de.jsxs)("div",{className:"form-group",children:[(0,de.jsx)("label",{className:"form-label",children:"Assign Consultant directly (Optional)"}),(0,de.jsxs)("select",{value:rt.assigned_consultant_id,onChange:e=>st({...rt,assigned_consultant_id:e.target.value}),className:"form-control",style:{background:"rgba(255,255,255,0.03)",color:"#fff",border:"1px solid var(--border)"},children:[(0,de.jsx)("option",{value:"",style:{background:"var(--primary)"},children:"-- Awaiting Assignment (Unassigned) --"}),X.map(e=>(0,de.jsxs)("option",{value:e.id,style:{background:"var(--primary)"},children:[e.id," â ",e.name," (",e.email,")"]},e.id))]})]}),(0,de.jsxs)("div",{style:{display:"flex",gap:"12px",marginTop:"12px"},children:[(0,de.jsx)("button",{type:"button",onClick:()=>Ge(!1),className:"btn btn-outline",style:{flex:1,margin:0},disabled:zr,children:"Cancel"}),(0,de.jsx)("button",{type:"submit",className:"btn btn-glow-gold",style:{flex:1,margin:0},disabled:zr,children:zr?"Creating Task...":"Create Task"})]})]})]})})]})}var Ce={container:{display:"grid",gridTemplateColumns:"280px 1fr",gap:"30px",padding:"50px 24px",minHeight:"75vh"},sidebar:{display:"flex",flexDirection:"column",gap:"24px"},userCard:{background:"var(--white)",border:"1px solid var(--border)",borderRadius:"var(--radius-md)",padding:"20px",display:"flex",alignItems:"center",gap:"12px",boxShadow:"var(--shadow-sm)"},userAvatar:{width:"46px",height:"46px",borderRadius:"50%",background:"linear-gradient(135deg, var(--accent-teal), var(--accent-teal-dark))",color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1.25rem",fontWeight:"700"},userName:{fontSize:"1rem",color:"var(--primary)",fontWeight:"700"},userBadge:{fontSize:"0.75rem",color:"var(--accent-teal)",fontWeight:"600"},sideNav:{background:"var(--white)",border:"1px solid var(--border)",borderRadius:"var(--radius-md)",padding:"10px",display:"flex",flexDirection:"column",gap:"6px",boxShadow:"var(--shadow-sm)"},navBtn:{width:"100%",padding:"12px 16px",background:"transparent",border:"none",borderRadius:"var(--radius-sm)",color:"var(--text-muted)",fontFamily:"var(--font-heading)",fontWeight:"600",fontSize:"0.9rem",cursor:"pointer",textAlign:"left",display:"flex",alignItems:"center",gap:"10px",transition:"all 0.2s ease"},navBtnActive:{background:"rgba(30, 168, 199, 0.08)",color:"var(--accent-teal)"},badgeAlert:{marginLeft:"auto",backgroundColor:"#EF4444",color:"#FFFFFF",borderRadius:"10px",padding:"2px 8px",fontSize:"0.72rem",fontWeight:"700",lineHeight:"1",display:"inline-block",animation:"pulse 2s infinite ease-in-out"},mainContent:{flex:1},statsGrid:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"24px"},statBox:{display:"flex",alignItems:"center",gap:"20px",background:"var(--white)",padding:"24px",border:"1px solid var(--border)"},statIcon:{width:"52px",height:"52px",borderRadius:"var(--radius-md)",background:"rgba(212,175,55,0.1)",color:"#D4AF37",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},statText:{fontSize:"0.7rem",color:"var(--text-muted)",fontWeight:"600",letterSpacing:"0.5px"},statVal:{fontSize:"1.4rem",color:"var(--primary)",fontWeight:"800",marginTop:"4px"},subBlockTitle:{fontFamily:"var(--font-heading)",fontSize:"1.15rem",color:"var(--primary)",fontWeight:"700",marginBottom:"15px"},miniStat:{"& h2":{fontSize:"2rem",color:"var(--primary)",fontWeight:"800"},"& p":{fontSize:"0.8rem",color:"var(--text-muted)",marginTop:"4px"}},tabTitle:{fontSize:"1.5rem",color:"var(--primary)",fontWeight:"700",marginBottom:"6px"},tabText:{color:"var(--text-muted)",fontSize:"0.85rem",borderBottom:"1px solid var(--border)",paddingBottom:"16
2px",marginBottom:"24px"},tableResponsive:{width:"100%",overflowX:"auto"},table:{width:"100%",borderCollapse:"collapse",textAlign:"left",fontSize:"0.85rem","& th":{background:"var(--bg-cool)",padding:"12px 16px",fontWeight:"700",color:"var(--primary)",borderBottom:"2px solid var(--border)"},"& td":{padding:"16px",borderBottom:"1px solid var(--border)"}},tableSelect:{padding:"6px 12px",border:"1px solid var(--border)",borderRadius:"4px",outline:"none",fontSize:"0.8rem",background:"var(--white)",color:"var(--text-main)"},detailContainer:{display:"flex",flexDirection:"column"},infoField:{display:"flex",flexDirection:"column",gap:"4px",borderBottom:"1px solid var(--border)",paddingBottom:"10px",marginBottom:"15px","& strong":{fontSize:"0.75rem",color:"var(--text-muted)"},"& span":{fontSize:"0.95rem",fontWeight:"600",color:"var(--primary)"}},receiptFrame:{width:"100%",maxWidth:"300px",height:"240px",background:"var(--bg-cool)",border:"2px dashed var(--border)",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},simReceiptText:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"},inquiriesList:{display:"flex",flexDirection:"column",gap:"16px"},inquiryCard:{background:"var(--bg-cool)",border:"1px solid var(--border)",padding:"20px",borderRadius:"var(--radius-sm)"},inquiryHeader:{display:"flex",justifyContent:"space-between",fontSize:"0.8rem",borderBottom:"1px solid rgba(0,0,0,0.04)",paddingBottom:"8px",marginBottom:"12px"},inquirySubject:{fontSize:"1rem",color:"var(--primary)",fontWeight:"700",marginBottom:"8px"},inquiryMessage:{fontSize:"0.85rem",lineHeight:"1.5",color:"var(--text-main)",whiteSpace:"pre-wrap"},commentsList:{display:"flex",flexDirection:"column",gap:"12px"},commentBubble:{padding:"12px 16px",borderRadius:"var(--radius-md)",maxWidth:"85%",fontSize:"0.85rem"},commentClient:{background:"var(--bg-cool)",border:"1px solid var(--border)",alignSelf:"flex-start",borderBottomLeftRadius:"2px"},commentAdvisory:{background:"rgba(30, 168, 199, 0.08)",border:"1px solid rgba(30, 168, 199, 0.15)",alignSelf:"flex-end",borderBottomRightRadius:"2px"},commentHeader:{display:"flex",justifyContent:"space-between",gap:"20px",marginBottom:"4px",fontSize:"0.75rem",color:"var(--text-muted)"},commentText:{color:"var(--primary)",lineHeight:"1.4"},commentForm:{position:"relative"},commentSendBtn:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",width:"32px",height:"32px",borderRadius:"50%",background:"linear-gradient(135deg, var(--accent-teal), var(--accent-teal-dark))",color:"#FFFFFF",border:"none",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"}};export{Se as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.