1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4883],{9704:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>T});var a=s(37876),r=s(52042),l=s(14232),n=s(89099),d=s(37497),i=s(30223),c=s(53403);function o(e){var t,s,n,d,i;let{customerId:o}=e,{hasRole:x}=(0,r.bn)(),u=x("Admin")||x("Compliance Officer"),[m,p]=(0,l.useState)([]),[h,g]=(0,l.useState)([]),[y,b]=(0,l.useState)(!0),[f,j]=(0,l.useState)(null),[N,v]=(0,l.useState)(!1),[w,C]=(0,l.useState)(!1),[k,S]=(0,l.useState)(!1),[D,A]=(0,l.useState)(null),[F,R]=(0,l.useState)([]),[I,T]=(0,l.useState)(!1),[L,E]=(0,l.useState)(null),[K,P]=(0,l.useState)(!1),[B,M]=(0,l.useState)(!1),[U,V]=(0,l.useState)(null),[Y,O]=(0,l.useState)(""),[z,G]=(0,l.useState)(null),[_,J]=(0,l.useState)(null),[W,q]=(0,l.useState)(!1),[H,Z]=(0,l.useState)(!1),[$,Q]=(0,l.useState)(!1),[X,ee]=(0,l.useState)({fullName:"",firstName:"",surName:"",idNumber:"",gender:"",country:"",dateOfBirth:"",isAmlSucceed:!1,amlJobId:"",kycJobId:"",kycUserId:"",reason:""});(0,l.useEffect)(()=>{et()},[o]),(0,l.useEffect)(()=>{if(U){let e=setTimeout(()=>V(null),5e3);return()=>clearTimeout(e)}},[U]);let et=async()=>{try{b(!0),j(null);let[e,t,s,a]=await Promise.all([c.KD.getCustomerKycResults(o),c.KD.getKycDocuments(o),c.KD.getCustomerRegulatoryQnA(o),c.KD.getCustomerAddressVerification(o)]);e.success&&e.data?p(e.data):j(e.error||"Failed to load KYC results"),t.success&&t.data&&g(t.data),s.success&&s.data?R(s.data):console.warn("[KYC] Q&A fetch failed:",s.error,"status:",s.statusCode),a.success&&a.data?E(a.data):console.warn("[KYC] Address fetch failed:",a.error,"status:",a.statusCode)}catch(e){j(e.message||"Failed to load KYC data")}finally{b(!1)}},es=async()=>{P(!0);try{let e=await c.KD.getCustomerAddressVerification(o);e.success&&e.data&&E(e.data)}catch(e){V({type:"error",text:"Failed to reload address verification"})}finally{P(!1)}},ea=async e=>{q(!0);try{var t,s;let a=await c.KD.getKycDocumentUrl(o,e);a.success&&(null==(s=a.data)||null==(t=s.urls)?void 0:t.length)?window.open(a.data.urls[0],"_blank"):V({type:"error",text:"Failed to get document URL"})}catch(e){V({type:"error",text:"Failed to get document URL"})}finally{q(!1)}},er=async e=>{let t=e.includes("proof_of_address/")?e.split("proof_of_address/").pop():e.split("/").pop();try{var s;let e=await c.KD.getAddressFileUrl(o,t);e.success&&(null==(s=e.data)?void 0:s.url)?window.open(e.data.url,"_blank"):V({type:"error",text:"Failed to get file URL"})}catch(e){V({type:"error",text:"Failed to get file URL"})}},el=async e=>{M(!0);try{let t=await c.KD.updateAddressVerificationStatus(o,{filePath:e,isApproved:!0});t.success?(V({type:"success",text:"File approved successfully"}),es()):V({type:"error",text:t.error||"Failed to approve file"})}catch(e){V({type:"error",text:e.message||"Failed to approve file"})}finally{M(!1)}},en=async e=>{if(Y.trim()){M(!0);try{let t=await c.KD.updateAddressVerificationStatus(o,{filePath:e,isApproved:!1,rejectionReason:Y.trim()});t.success?(V({type:"success",text:"File rejected successfully"}),G(null),O(""),es()):V({type:"error",text:t.error||"Failed to reject file"})}catch(e){V({type:"error",text:e.message||"Failed to reject file"})}finally{M(!1)}}},ed=e=>{A(e),S(!0)},ei=async()=>{if(!u)return void V({type:"error",text:"You are not authorised to force bypass KYC"});if(X.reason.trim().length<10)return void V({type:"error",text:"Reason must be at least 10 characters"});Q(!0);try{let e=await c.KD.forceBypassKyc(o,X);e.success?(V({type:"success",text:"KYC force bypass completed successfully"}),Z(!1),ee({fullName:"",firstName:"",surName:"",idNumber:"",gender:"",country:"",dateOfBirth:"",isAmlSucceed:!1,amlJobId:"",kycJobId:"",kycUserId:"",reason:""}),et()):V({type:"error",text:e.error||"Failed to force bypass KYC"})}catch(e){V({type:"error",text:e.message||"Failed to force bypass KYC"})}finally{Q(!1)}},ec=m.some(e=>{var t;return(null==(t=e.amlResult)?void 0:t.isEligibile)===!0}),eo=e=>{if(!e)return"bg-gray-100 text-gray-800";switch(e.toLowerCase()){case"green":case"approved":case"completed":return"bg-emerald-100 text-emerald-800";case"red":case"rejected":return"bg-red-100 text-red-800";
1case"pending":case"init":case"queued":return"bg-amber-100 text-amber-800";default:return"bg-gray-100 text-gray-800"}},ex=m.some(e=>e.sumsubReviewStatus||e.sumsubApplicantId);m.length;let eu=F.length>0,em=!!((null==L?void 0:L.address)||(null==L?void 0:L.files)&&L.files.length>0);return y?(0,a.jsx)("div",{className:"flex justify-center py-8",children:(0,a.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"})}):f?(0,a.jsxs)("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:[(0,a.jsx)("p",{className:"text-red-800",children:f}),(0,a.jsx)("button",{onClick:et,className:"mt-2 text-sm text-red-600 hover:text-red-800 underline",children:"Retry"})]}):(0,a.jsxs)("div",{className:"space-y-6",children:[U&&(0,a.jsxs)("div",{className:"fixed top-4 right-4 z-[60] flex items-center gap-3 rounded-md px-4 py-3 shadow-lg border ".concat("success"===U.type?"bg-green-50 border-green-200 text-green-800":"bg-red-50 border-red-200 text-red-800"),children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:U.text}),(0,a.jsx)("button",{onClick:()=>V(null),className:"ml-2 text-sm font-medium underline hover:no-underline",children:"Dismiss"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,a.jsx)("button",{onClick:et,className:"px-4 py-2 text-sm font-medium rounded-md border bg-gray-500 border-gray-500 text-white hover:bg-gray-600 transition-colors",children:"Refresh Results"}),u&&(0,a.jsx)("button",{onClick:()=>{let e=m[0];e&&ee(t=>{var s,a;return{...t,fullName:e.fullName||"",firstName:e.sumsubFirstName||"",surName:e.sumsubLastName||"",idNumber:e.idNumber||"",gender:e.sumsubGender||"",country:e.countryOfResidence||e.countryOfCitizenship||"",dateOfBirth:e.sumsubDob||"",isAmlSucceed:(null==(s=e.amlResult)?void 0:s.isEligibile)||!1,amlJobId:(null==(a=e.amlResult)?void 0:a.jobId)||"",kycJobId:e.biometricKycJobId||"",kycUserId:e.sumsubExternalUserId||o}}),Z(!0)},disabled:ec,className:"px-4 py-2 text-sm font-medium rounded-md border transition-colors ".concat(ec?"bg-gray-100 border-gray-200 text-gray-400 cursor-not-allowed":"bg-blue-600 border-blue-600 text-white hover:bg-blue-700"),children:"Force Bypass KYC"}),(0,a.jsx)("button",{onClick:()=>{v(!N),N||C(!1)},disabled:!eu,className:"px-4 py-2 text-sm font-medium rounded-md border transition-colors ".concat(N?"bg-green-700 border-green-700 text-white hover:bg-green-800":eu?"bg-green-600 border-green-600 text-white hover:bg-green-700":"bg-gray-100 border-gray-200 text-gray-400 cursor-not-allowed"),children:"View Regulatory Q&A"}),(0,a.jsx)("button",{onClick:()=>{C(!w),w||v(!1)},disabled:!em,className:"px-4 py-2 text-sm font-medium rounded-md border transition-colors ".concat(w?"bg-cyan-700 border-cyan-700 text-white hover:bg-cyan-800":em?"bg-cyan-600 border-cyan-600 text-white hover:bg-cyan-700":"bg-gray-100 border-gray-200 text-gray-400 cursor-not-allowed"),children:"Verify Address Documents"}),(0,a.jsx)("button",{onClick:()=>{let e=m.find(e=>e.sumsubReviewStatus||e.sumsubApplicantId);e&&ed(e)},disabled:!ex,className:"px-4 py-2 text-sm font-medium rounded-md border transition-colors ".concat(ex?"bg-amber-500 border-amber-500 text-white hover:bg-amber-600":"bg-gray-100 border-gray-200 text-gray-400 cursor-not-allowed"),children:"Partner Verification Data"})]}),N&&(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg overflow-hidden",children:[(0,a.jsx)("div",{className:"px-6 py-4 border-b border-gray-200 bg-gray-50",children:(0,a.jsx)("h3",{className:"text-sm font-semibold text-gray-900",children:"Regulatory Q&A"})}),0===F.length?(0,a.jsx)("p",{className:"text-gray-500 text-center py-8 text-sm",children:"No regulatory Q&A data available"}):(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Questionnaire"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Question"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Answer"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Brokerage Info"})]})}),(0,a.jsx)("tbody",{className:"divide-y divide-gray-200",children:F.map((e,t)=>(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"px-4 py-3 text-sm text-gray-900",children:e.questionnaire||"-"}),(0,a.jsx)("td",{className:"px-4 py-3 text-sm text-gray-900",children:e.question||"-"}),(0,a.jsx)("td",{className:"px-4 py-3 text-sm text-gray-900",children:e.answer||"-"}),(0,a.jsx)("td",{className:"px-4 py-3 text-sm text-gray-500",children:e.brokerageInfo||"-"})]},t))})]})})]}),w&&L&&(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg overflow-hidden",children:[(0,a.jsx)("div",{className:"px-6 py-4 border-b border-gray-200 bg-gray-50",children:(0,a.jsx)("h3",{className:"text-sm font-semibold text-gray-900",children:"Address Verification"})}),(0,a.jsxs)("div",{className:"p-6 space-y-6",children:[L.address&&(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Captured Address"}),(0,a.jsxs)("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-y-3 gap-x-6 text-sm",children:[L.address.streetNumber&&(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Street Number"}),(0,a.jsx)("dd",{className:"text-gray-900",children:L.address.streetNumber})]}),L.address.road&&(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Road"}),(0,a.jsx)("dd",{className:"text-gray-900",children:L.address.road})]}),L.address.line1&&(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Line 1"}),(0,a.jsx)("dd",{className:"text-gray-900",children:L.address.line1})]}),L.address.line2&&(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Line 2"}),(0,a.jsx)("dd",{className:"text-gray-900",children:L.address.line2})]}),L.address.suburb&&(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Suburb"}),(0,a.jsx)("dd",{className:"text-gray-900",children:L.address.suburb})]}),L.address.city&&(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"City"}),(0,a.jsx)("dd",{className:"text-gray-900",children:L.address.city})]}),L.address.province&&(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Province"}),(0,a.jsx)("dd",{className:"text-gray-900",children:L.address.province})]}),L.address.postalCode&&(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Postal Code"}),(0,a.jsx)("dd",{className:"text-gray-900",children:L.address.postalCode})]}),L.address.country&&(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Country"}),(0,a.jsx)("dd",{className:"text-gray-900",children:L.address.country})]})]})]}),L.files&&L.files.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Uploaded Files"}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"File"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Status"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Rejection Reason"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Actioned By"}),(0,a.jsx)("th",{className:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase",children:"Actions"})]})}),(0,a.jsx)("tbody",{className:"divide-y divide-gray-200",children:L.files.map((e,t)=>(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"px-4 py-3 text-sm text-gray-900",children:(0,a.jsx)("button",{onClick:()=>er(e.fileName),className:"text-blue-600 hover:text-blue-800 underline",children:e.fileName})}),(0,a.jsx)("td",{className:"px-4 py-3",children:(0,a.jsx)("span",{className:"px-2 py-1 text-xs rounded-full ".concat(eo(e.status)),children:e.status})}),(0,a.jsx)("td",{className:"px-4 py-3 text-sm text-gray-500",children:e.rejectionReason||"-"}),(0,a.jsx)("td",{className:"px-4 py-3 text-sm text-gray-500",children:e.verifiedBy||"-"}),(0,a.jsx)("td",{className:"px-4 py-3 text-right",children:"Pending"===e.status&&(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)("button",{onClick:()=>el(e.fileName),disabled:B,className:"px-2 py-1 text-xs font-medium text-green-700 bg-green-50 rounded hover:bg-green-100 disabled:opacity-50",children:"Approve"}),z===e.fileName?(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)("input",{type:"text",value:Y,onChange:e=>O(e.target.value),placeholder:"Reason...",className:"px-2 py-1 text-xs border border-gray-300 rounded w-40"}),(0,a.jsx)("button",{onClick:()=>en(e.fileName),disabled:B||!Y.trim(),className:"px-2 py-1 text-xs font-medium text-red-700 bg-red-50 rounded hover:bg-red-100 disabled:opacity-50",children:"Confirm"}),(0,a.jsx)("button",{onClick:()=>{G(null),O("")},className:"px-2 py-1 text-xs text-gray-500 hover:text-gray-700",children:"Cancel"})]}):(0,a.jsx)("button",{onClick:()=>G(e.fileName),disabled:B,className:"px-2 py-1 text-xs font-medium text-red-700 bg-red-50 rounded hover:bg-red-100 disabled:opacity-50",children:"Reject"})]})})]},t))})]})})]}),!L.address&&(0,a.jsx)("p",{className:"text-gray-500 text-center py-4 text-sm",children:"No address data available"})]})]}),0===m.length?(0,a.jsx)("p",{className:"text-gray-500 text-center py-8 text-sm",children:"No KYC results found"}):(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg overflow-hidden",children:[(0,a.jsx)("div",{className:"px-6 py-4 border-b border-gray-200 bg-gray-50",children:(0,a.jsx)("h3",{className:"text-sm font-semibold text-gray-900",children:"KYC Results"})}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Partner"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"KYC Status"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"AML Status"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Sumsub Review"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Review Answer"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"ID Number"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Full Name"}),(0,a.jsx)("th",{className:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase",children:"Actions"})]})}),(0,a.jsx)("tbody",{className:"divide-y divide-gray-200",children:m.map((e,t)=>{var s;return(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"px-4 py-3 text-sm text-gray-900",children:e.partner||"-"}),(0,a.jsx)("td",{className:"px-4 py-3",children:(0,a.jsx)("span",{className:"px-2 py-1 text-xs rounded-full ".concat(eo(e.kycStatus)),children:e.kycStatus||"-"})}),(0,a.jsx)("td",{className:"px-4 py-3",children:(0,a.jsx)("span",{className:"px-2 py-1 text-xs rounded-full ".concat(eo(e.amlStatus)),children:e.amlStatus||"-"})}),(0,a.jsx)("td",{className:"px-4 py-3",children:(0,a.jsx)("span",{className:"px-2 py-1 text-xs rounded-full ".concat(eo(e.sumsubReviewStatus)),children:e.sumsubReviewStatus||"-"})}),(0,a.jsx)("td",{className:"px-4 py-3 text-sm text-gray-900",children:(null==(s=e.sumsubReviewResult)?void 0:s.reviewAnswer)||"-"}),(0,a.jsx)("td",{className:"px-4 py-3 text-sm font-mono text-gray-900",children:e.idNumber||"-"}),(0,a.jsx)("td",{className:"px-4 py-3 text-sm text-gray-900",children:e.fullName||"-"}),(0,a.jsx)("td",{className:"px-4 py-3 text-right",children:(e.sumsubReviewStatus||e.sumsubApplicantId)&&(0,a.jsx)("button",{onClick:()=>ed(e),className:"text-blue-600 hover:text-blue-800 text-sm font-medium",children:"View Details"})})]},e.kycResultId||t)})})]})})]}),H&&u&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex min-h-full items-center justify-center p-4",children:[(0,a.jsx)("div",{className:"fixed inset-0 bg-gray-900/60 backdrop-blur-sm",onClick:()=>Z(!1)}),(0,a.jsxs)("div",{className:"relative bg-white rounded-lg shadow-lg max-w-2xl w-full max-h-[90vh] overflow-y-auto",children:[(0,a.jsxs)("div",{className:"px-6 py-4 border-b border-gray-200 flex justify-between items-center sticky top-0 bg-white z-10",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold text-gray-900",children:"Force Bypass KYC (Manual Resolve)"}),(0,a.jsx)("button",{onClick:()=>Z(!1),className:"text-gray-500 hover:text-gray-700 text-sm font-medium",children:"Close"})]}),(0,a.jsxs)("div",{className:"p-6 space-y-4",children:[(0,a.jsx)("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-3 text-sm text-yellow-800",children:"This will manually resolve the customer's KYC verification. Use with caution."}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Full Name *"}),(0,a.jsx)("input",{type:"text",value:X.fullName,onChange:e=>ee(t=>({...t,fullName:e.target.value})),className:"w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"ID Number *"}),(0,a.jsx)("input",{type:"text",value:X.idNumber,onChange:e=>ee(t=>({...t,idNumber:e.target.value})),className:"w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"First Name"}),(0,a.jsx)("input",{type:"text",value:X.firstName,onChange:e=>ee(t=>({...t,firstName:e.target.value})),className:"w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Surname"}),(0,a.jsx)("input",{type:"text",value:X.surName,onChange:e=>ee(t=>({...t,surName:e.target.value})),className:"w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Gender"}
1),(0,a.jsxs)("select",{value:X.gender,onChange:e=>ee(t=>({...t,gender:e.target.value})),className:"w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500",children:[(0,a.jsx)("option",{value:"",children:"Select..."}),(0,a.jsx)("option",{value:"M",children:"Male"}),(0,a.jsx)("option",{value:"F",children:"Female"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Country *"}),(0,a.jsx)("input",{type:"text",value:X.country,onChange:e=>ee(t=>({...t,country:e.target.value})),className:"w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Date of Birth *"}),(0,a.jsx)("input",{type:"date",value:X.dateOfBirth,onChange:e=>ee(t=>({...t,dateOfBirth:e.target.value})),className:"w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pt-6",children:[(0,a.jsx)("input",{type:"checkbox",id:"isAmlSucceed",checked:X.isAmlSucceed,onChange:e=>ee(t=>({...t,isAmlSucceed:e.target.checked})),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),(0,a.jsx)("label",{htmlFor:"isAmlSucceed",className:"text-sm font-medium text-gray-700",children:"AML Succeeded"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"AML Job ID"}),(0,a.jsx)("input",{type:"text",value:X.amlJobId,onChange:e=>ee(t=>({...t,amlJobId:e.target.value})),className:"w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"KYC Job ID *"}),(0,a.jsx)("input",{type:"text",value:X.kycJobId,onChange:e=>ee(t=>({...t,kycJobId:e.target.value})),className:"w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"KYC User ID *"}),(0,a.jsx)("input",{type:"text",value:X.kycUserId,onChange:e=>ee(t=>({...t,kycUserId:e.target.value})),className:"w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Reason * (min 10 characters)"}),(0,a.jsx)("textarea",{value:X.reason,onChange:e=>ee(t=>({...t,reason:e.target.value})),rows:3,className:"w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500",placeholder:"Provide a detailed reason for bypassing KYC..."}),X.reason.length>0&&X.reason.length<10&&(0,a.jsxs)("p",{className:"mt-1 text-xs text-red-500",children:[10-X.reason.length," more characters required"]})]}),(0,a.jsxs)("div",{className:"flex justify-end gap-3 pt-4 border-t border-gray-200",children:[(0,a.jsx)("button",{onClick:()=>Z(!1),className:"px-4 py-2 text-sm font-medium rounded-md border border-gray-300 text-gray-700 hover:bg-gray-50",children:"Cancel"}),(0,a.jsx)("button",{onClick:ei,disabled:$||!X.fullName.trim()||!X.idNumber.trim()||!X.country.trim()||!X.dateOfBirth.trim()||!X.kycJobId.trim()||!X.kycUserId.trim()||X.reason.trim().length<10,className:"px-4 py-2 text-sm font-medium rounded-md bg-blue-600 text-white hover:bg-blue-700 disabled:bg-gray-300 disabled:text-gray-500 disabled:cursor-not-allowed",children:$?"Processing...":"Force Bypass KYC"})]})]})]})]})}),k&&D&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex min-h-full items-center justify-center p-4",children:[(0,a.jsx)("div",{className:"fixed inset-0 bg-gray-900/60 backdrop-blur-sm",onClick:()=>S(!1)}),(0,a.jsxs)("div",{className:"relative bg-white rounded-lg shadow-lg max-w-3xl w-full max-h-[90vh] overflow-y-auto",children:[(0,a.jsxs)("div",{className:"px-6 py-4 border-b border-gray-200 flex justify-between items-center sticky top-0 bg-white z-10",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold text-gray-900",children:"Partner Verification Data"}),(0,a.jsx)("button",{onClick:()=>S(!1),className:"text-gray-500 hover:text-gray-700 text-sm font-medium",children:"Close"})]}),(0,a.jsxs)("div",{className:"p-6 space-y-6",children:[(0,a.jsx)("div",{className:"p-4 rounded-lg border-2 ".concat((null==(t=D.sumsubReviewResult)?void 0:t.reviewAnswer)==="RED"?"border-red-300 bg-red-50":(null==(s=D.sumsubReviewResult)?void 0:s.reviewAnswer)==="GREEN"?"border-green-300 bg-green-50":"border-gray-300 bg-gray-50"),children:(0,a.jsxs)("dl",{className:"grid grid-cols-2 gap-y-3 gap-x-6 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"KYC Status"}),(0,a.jsx)("dd",{children:(0,a.jsx)("span",{className:"px-2 py-1 text-xs rounded-full ".concat(eo(D.kycStatus)),children:D.kycStatus||"-"})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"AML Status"}),(0,a.jsx)("dd",{children:(0,a.jsx)("span",{className:"px-2 py-1 text-xs rounded-full ".concat(eo(D.amlStatus)),children:D.amlStatus||"-"})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Sumsub Review Status"}),(0,a.jsx)("dd",{children:(0,a.jsx)("span",{className:"px-2 py-1 text-xs rounded-full ".concat(eo(D.sumsubReviewStatus)),children:D.sumsubReviewStatus||"-"})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Review Answer"}),(0,a.jsx)("dd",{className:"font-medium text-gray-900",children:(null==(n=D.sumsubReviewResult)?void 0:n.reviewAnswer)||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Sumsub Applicant ID"}),(0,a.jsx)("dd",{className:"font-mono text-xs text-gray-900",children:D.sumsubApplicantId||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Exter
1nal User ID"}),(0,a.jsx)("dd",{className:"font-mono text-xs text-gray-900",children:D.sumsubExternalUserId||"-"})]})]})}),(null==(d=D.sumsubReviewResult)?void 0:d.reviewAnswer)==="RED"&&(0,a.jsxs)("div",{className:"border border-red-200 rounded-lg p-4 bg-red-50",children:[(0,a.jsx)("h4",{className:"text-sm font-semibold text-red-800 mb-2",children:"Rejection Details"}),(0,a.jsxs)("dl",{className:"space-y-2 text-sm",children:[D.sumsubReviewResult.reviewRejectType&&(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-red-600",children:"Reject Type"}),(0,a.jsx)("dd",{className:"text-red-900",children:D.sumsubReviewResult.reviewRejectType})]}),D.sumsubReviewResult.clientComment&&(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-red-600",children:"Client Comment"}),(0,a.jsx)("dd",{className:"text-red-900",children:D.sumsubReviewResult.clientComment})]}),D.sumsubReviewResult.moderationComment&&(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-red-600",children:"Moderation Comment"}),(0,a.jsx)("dd",{className:"text-red-900",children:D.sumsubReviewResult.moderationComment})]}),(null==(i=D.sumsubReviewResult.rejectLabels)?void 0:i.length)?(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-red-600",children:"Reject Labels"}),(0,a.jsx)("dd",{className:"flex flex-wrap gap-1 mt-1",children:D.sumsubReviewResult.rejectLabels.map((e,t)=>(0,a.jsx)("span",{className:"px-2 py-0.5 text-xs bg-red-100 text-red-800 rounded",children:e},t))})]}):null]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-sm font-semibold text-gray-900 mb-3",children:"Personal Information"}),(0,a.jsxs)("dl",{className:"grid grid-cols-2 gap-y-3 gap-x-6 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Full Name"}),(0,a.jsx)("dd",{className:"text-gray-900",children:D.fullName||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"ID Number"}),(0,a.jsx)("dd",{className:"font-mono text-gray-900",children:D.idNumber||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Sumsub Name"}),(0,a.jsx)("dd",{className:"text-gray-900",children:[D.sumsubFirstName,D.sumsubLastName].filter(Boolean).join(" ")||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Date of Birth"}),(0,a.jsx)("dd",{className:"text-gray-900",children:D.sumsubDob||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Gender"}),(0,a.jsx)("dd",{className:"text-gray-900",children:D.sumsubGender||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Nationality"}),(0,a.jsx)("dd",{className:"text-gray-900",children:D.sumsubNationality||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Country of Residence"}),(0,a.jsx)("dd",{className:"text-gray-900",children:D.countryOfResidence||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Country of Citizenship"}),(0,a.jsx)("dd",{className:"text-gray-900",children:D.countryOfCitizenship||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Place of Birth"}),(0,a.jsx)("dd",{className:"text-gray-900",children:D.sumsubPlaceOfBirth||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"TIN"}),(0,a.jsx)("dd",{className:"font-mono text-gray-900",children:D.sumsubTin||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Investor Classification"}),(0,a.jsx)("dd",{className:"text-gray-900",children:D.investorClassification||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"US Tax Resident"}),(0,a.jsx)("dd",{className:"text-gray-900",children:D.isUSTaxResident||"-"})]})]})]}),D.workInformation&&(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-sm font-semibold text-gray-900 mb-3",children:"Work Information"}),(0,a.jsxs)("dl",{className:"grid grid-cols-2 gap-y-3 gap-x-6 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Employment Status"}),(0,a.jsx)("dd",{className:"text-gray-900",children:D.workInformation.employmentStatus||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Industry"}),(0,a.jsx)("dd",{className:"text-gray-900",children:D.workInformation.industry||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Role"}),(0,a.jsx)("dd",{className:"text-gray-900",children:D.workInformation.role||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Source of Fund"}),(0,a.jsx)("dd",{className:"text-gray-900",children:D.workInformation.sourceOfFund||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Source of Wealth"}),(0,a.jsx)("dd",{className:"text-gray-900",children:D.workInformation.sourceOfWealth||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Total Income"}),(0,a.jsx)("dd",{className:"text-gray-900",children:D.workInformation.totalIncome||"-"})]})]})]}),D.amlResult&&(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-sm font-semibold text-gray-900 mb-3",children:"AML Screening Results"}),(0,a.jsxs)("dl",{className:"grid grid-cols-2 gap-y-3 gap-x-6 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"AML Job ID"}),(0,a.jsx)("dd",{className:"font-mono text-xs text-gray-900",children:D.amlResult.jobId||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500",children:"Is Eligible"}),(0,a.jsx)("dd",{children:(0,a.jsx)("span",{className:"px-2 py-1 text-xs rounded-full ".concat(D.amlResult.isEligibile?"bg-green-100 text-green-800":"bg-red-100 text-red-800"),children:D.amlResult.isEligibile?"Yes":"No"})})]})]})]}),h.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-sm font-semibold text-gray-900 mb-3",children:"Submitted Documents"}),(0,a.jsx)("div",{className:"space-y-2",children:h.map(e=>{var t,s,r;return(0,a.jsxs)("div",{className:"flex items-center justify-between border border-gray-200 rounded p-3",children:[(0,a.jsx)("span",{className:"text-sm text-gray-900",children:1===e.type?"ID Document":"Selfie"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[e.hasFrontDocument&&(null==(t=e.result)?void 0:t.documentFrontFile)&&(0,a.jsx)("button",{onClick:()=>ea(e.result.documentFrontFile),className:"px-2 py-1 text-xs text-blue-700 bg-blue-50 rounded hover:bg-blue-100",children:"Front"}),e.hasBackDocument&&(null==(s=e.result)?void 0:s.documentBackFile)&&(0,a.jsx)("button",{onClick:()=>ea(e.result.documentBackFile),className:"px-2 py-1 text-xs text-blue-700 bg-blue-50 rounded hover:bg-blue-100",children:"Back"}),e.hasSelfieDocument&&(null==(r=e.result)?void 0:r.documentFile)&&(0,a.jsx)("button",{onClick:()=>ea(e.result.documentFile),className:"px-2 py-1 text-xs text-blue-700 bg-blue-50 rounded hover:bg-blue-100",children:"Selfie"})]})]},e.id)})})]})]})]})]})})]})}var x=s(29498),u=s(85999),m=s(72063);let p=["loan","creditcard","credit"],h=["investment","property","crypto","cryptocurrency"];function g(e){let{customerId:t}=e,[s,r]=(0,l.useState)(!0),[n,d]=(0,l.useState)(null),[i,c]=(0,l.useState)([]),[o,g]=(0,l.useState)(!1),y=(0,l.useRef)(null),b=function(e){if(!e)return"V22-UNKNOWN";let t=e.replace(/[^a-zA-Z0-9]/g,"").toUpperCase();return t?"V22-".concat(t.slice(0,8)):"V22-UNKNOWN"}(t);(0,l.useEffect)(()=>
1{if(!t)return;let e=!1;return r(!0),d(null),x.KD.getCustomerAccounts(t,"active").then(t=>{var s;e||c((null!=(s=t.data)?s:[]).flatMap(e=>{var t;return null!=(t=e.accounts)?t:[]}).filter(e=>!e.deactivated&&!e.isDeleted))}).catch(()=>{e||d("Could not load customer accounts.")}).finally(()=>{e||r(!1)}),()=>{e=!0}},[t]);let f=(0,l.useMemo)(()=>{var e,t,s,a,r;let l=[],n=[],d=new Map;for(let e of i){let i=(null==(t=e.currentBalance)?void 0:t.currencyCode)||"UNKNOWN",c=Math.abs(null!=(a=null==(s=e.currentBalance)?void 0:s.amount)?a:0),o=(e.accountClass||"").toLowerCase(),x=e.friendlyName||e.displayName||e.accountClass||"Account",u=null!=(r=d.get(i))?r:{assets:0,liabilities:0};p.includes(o)?(u.liabilities+=c,l.push({lender:x,balance:c,currency:i,source:"Linked account"})):(u.assets+=c,h.includes(o)&&n.push({name:x,type:e.accountClass,value:c,currency:i,source:"Linked account"})),d.set(i,u)}let c=Array.from(d.entries()).map(e=>{let[t,s]=e;return{currency:t,assets:s.assets,liabilities:s.liabilities,net:s.assets-s.liabilities}}).sort((e,t)=>t.assets-e.assets);return{currency:(null==(e=c[0])?void 0:e.currency)||"USD",netWorth:null,totalAssets:null,totalLiabilities:null,currencyBreakdown:c,monthlyIncome:null,monthlyDebt:null,liquidAssetsCurrency:null,dti:null,healthScore:null,healthLevel:null,employment:null,debts:l,assets:n,insurancePolicies:null,customerScopedDataAvailable:!1}},[i]),j=async()=>{g(!0);try{await (0,u.H)(y.current,"cfi-report-".concat(b),{footer:"Vault22 \xb7 Client Financial Intelligence Report \xb7 ".concat(b)})}finally{g(!1)}};return s?(0,a.jsx)("div",{className:"py-10 text-center text-gray-400",children:"Loading intelligence reportâ¦"}):n?(0,a.jsx)("div",{className:"py-10 text-center text-red-500",children:n}):(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-lg font-semibold text-gray-900",children:"Client Financial Intelligence Report"}),(0,a.jsxs)("p",{className:"text-xs text-gray-500",children:["Client identity masked as ",(0,a.jsx)("span",{className:"font-mono",children:b})," \xb7 internal cross-sell included"]})]}),(0,a.jsx)("button",{type:"button",onClick:j,disabled:o,className:"px-4 py-2 rounded-lg bg-[#00C389] hover:bg-[#01a878] text-white text-sm font-semibold disabled:opacity-60",children:o?"Preparingâ¦":"Download PDF"})]}),(0,a.jsx)("div",{ref:y,className:"bg-[#F4F6F9] p-1 rounded-2xl",children:(0,a.jsx)(m.A,{data:f,showCrossSell:!0,identity:{mode:"uid",value:b}})})]})}var y=s(46257),b=s(48230),f=s.n(b),j=s(32295);let N=[{value:j.GZ.General,label:"General"},{value:j.GZ.EDD,label:"EDD (Enhanced Due Diligence)"},{value:j.GZ.DocumentReview,label:"Document Review"},{value:j.GZ.SanctionsCheck,label:"Sanctions Check"}];function v(e){var t;let{customerId:s}=e,[r,n]=(0,l.useState)(null),[d,i]=(0,l.useState)(!0),[o,x]=(0,l.useState)(null),[u,m]=(0,l.useState)(""),[p,h]=(0,l.useState)(null),[g,y]=(0,l.useState)([]),[b,f]=(0,l.useState)([]),[v,w]=(0,l.useState)(!1),[C,k]=(0,l.useState)(!1),S=(0,l.useRef)(null),[D,A]=(0,l.useState)({open:!1,type:"approve"}),[F,R]=(0,l.useState)(""),[I,T]=(0,l.useState)(!1),[L,E]=(0,l.useState)(1),[K,P]=(0,l.useState)(new Set),[B,M]=(0,l.useState)(null),U=(0,l.useCallback)(async()=>{try{i(!0),x(null);let e=await c.KD.getComplianceActions(s);e.success&&e.data?n(e.data):x(e.error||"Failed to load compliance data")}catch(e){x(e.message||"Failed to load compliance data")}finally{i(!1)}},[s]);(0,l.useEffect)(()=>{U()},[U]),(0,l.useEffect)(()=>{if(B){let e=setTimeout(()=>M(null),1e4);return()=>clearTimeout(e)}},[B]);let V=async e=>{let t=[],s=[];for(let r=0;r<e.length;r++){var a;if(g.length+t.length>=10){M({type:"error",text:"Maximum ".concat(10," files allowed")});break}let l=e[r];if(l.size>0x1e00000){M({type:"error",text:"".concat(l.name," exceeds 30MB limit")});continue}let n=(null==(a=l.name.split(".").pop())?void 0:a.toLowerCase())||"";if(!["pdf","jpg","jpeg","png","docx"].includes(n)){M({type:"error",text:"".concat(l.name,": unsupported file type")});continue}let d=await Y(l);t.push({fileName:l.name,fileExtension:n,fileSizeBytes:l.size,base64Content:d}),s.push(l.name)}y(e=>[...e,...t]),f(e=>[...e,...s])},Y=e=>new Promise((t,s)=>{let a=new FileReader;a.onload=()=>{let e=a.result;t(e.split(",")[1]||e)},a.onerror=s,a.readAsDataURL(e)}),O=async()=>
1{if(u.trim())try{w(!0);let e=g.length>0?j.YD.DocumentsUploaded:j.YD.NoteAdded,t={note:u.trim(),noteType:null!=p?p:void 0,actionType:e,files:g},a=await c.KD.addComplianceAction(s,t);a.success?(M({type:"success",text:"Compliance note saved successfully"}),z(),await U()):M({type:"error",text:a.error||"Failed to save note"})}catch(e){M({type:"error",text:e.message||"Failed to save note"})}finally{w(!1)}},z=()=>{m(""),h(null),y([]),f([])},G=async()=>{if(F.trim())try{T(!0);let e="approve"===D.type?j.v9.ApprovedForInvestment:j.v9.RejectedForInvestment,t="approve"===D.type?j.YD.Approved:j.YD.Rejected,a={note:F.trim(),actionType:t,investmentStatus:e,files:[]},r=await c.KD.addComplianceAction(s,a);r.success?(M({type:"success",text:"Customer ".concat("approve"===D.type?"approved":"rejected"," for investment")}),A({open:!1,type:"approve"}),R(""),await U()):M({type:"error",text:r.error||"Failed to save decision"})}catch(e){M({type:"error",text:e.message||"Failed to save decision"})}finally{T(!1)}},_=async e=>{try{var t;let a=await c.KD.getComplianceDocumentUrl(s,e.filePath);a.success&&(null==(t=a.data)?void 0:t.url)?window.open(a.data.url,"_blank"):M({type:"error",text:"Failed to get document URL"})}catch(e){M({type:"error",text:e.message||"Failed to download document"})}},J=e=>e.displayName||e.fileName||e.filePath.split("/").pop()||"Document",W=(null==r?void 0:r.actionHistory)||[],q=Math.ceil(W.length/10),H=W.slice((L-1)*10,10*L),Z=Math.min(10*L,W.length);if(d)return(0,a.jsx)("div",{className:"flex justify-center py-12",children:(0,a.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"})});if(o)return(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("p",{className:"text-red-600 mb-4",children:o}),(0,a.jsx)("button",{onClick:U,className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700",children:"Retry"})]});let $=(e=>{switch(e){case j.v9.ApprovedForInvestment:return{bg:"bg-emerald-100 text-emerald-800 border border-emerald-300",text:"Approved for Investment"};case j.v9.RejectedForInvestment:return{bg:"bg-red-100 text-red-800 border border-red-300",text:"Rejected for Investment"};default:return{bg:"bg-amber-100 text-amber-800 border border-amber-300",text:"Pending Review"}}})(null!=(t=null==r?void 0:r.complianceStatus)?t:j.v9.PendingReview);return(0,a.jsxs)("div",{className:"space-y-6",children:[B&&(0,a.jsx)("div",{className:"p-3 rounded-lg text-sm ".concat("success"===B.type?"bg-emerald-50 text-emerald-800 border border-emerald-200":"bg-red-50 text-red-800 border border-red-200"),children:B.text}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold text-gray-900",children:"Compliance Status"}),(0,a.jsx)("span",{className:"px-3 py-1 text-sm font-medium rounded-full ".concat($.bg),children:$.text})]}),(0,a.jsx)("button",{onClick:U,className:"px-3 py-1.5 text-sm bg-gray-500 text-white rounded hover:bg-gray-600",children:"Refresh"})]}),(0,a.jsxs)("div",{className:"border border-gray-200 rounded-lg p-5 space-y-4",children:[(0,a.jsx)("h4",{className:"text-sm font-semibold text-gray-700 uppercase tracking-wide",children:"Add Compliance Note"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-600 mb-1",children:"Note Type (Optional)"}),(0,a.jsxs)("select",{value:null!=p?p:"",onChange:e=>h(""!==e.target.value?parseInt(e.target.value):null),className:"w-full max-w-xs border border-gray-300 rounded px-3 py-2 text-sm focus:ring-blue-500 focus:border-blue-500",children:[(0,a.jsx)("option",{value:"",children:"-- Select --"}),N.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-600 mb-1",children:"Note *"}),(0,a.jsx)("textarea",{value:u,onChange:e=>m(e.target.value),rows:4,placeholder:"Enter compliance note...",className:"w-full border border-gray-300 rounded px-3 py-2 text-sm focus:ring-blue-500 focus:border-blue-500"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-600 mb-1",children:"Attachments (PDF, JPG, PNG, DOCX â max 30MB, up to 10 files)"}),(0,a.jsxs)("div",{onDragOver:e=>{e.preventDefault(),k(!0)},onDragLeave:()=>k(!1),onDrop:e=>{e.preventDefault(),k(!1),e.dataTransfer.files.length>0&&V(e.dataTransfer.files)},onClick:()=>{var e;return null==(e=S.current)?void 0:e.click()},className:"border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors ".concat(C?"border-blue-400 bg-blue-50":"border-gray-300 hover:border-gray-400"),children:[(0,a.jsxs)("p",{className:"text-sm text-gray-500",children:["Drag & drop files here, or ",(0,a.jsx)("span",{className:"text-blue-600 underline",children:"click to browse"})]}),(0,a.jsx)("input",{ref:S,type:"file",accept:".pdf,.jpg,.jpeg,.png,.docx",multiple:!0,onChange:e=>{e.target.files&&e.target.files.length>0&&(V(e.target.files),e.target.value="")},className:"hidden"})]}),b.length>0&&(0,a.jsx)("div",{className:"mt-2 space-y-1",children:b.map((e,t)=>{var s,r;return(0,a.jsxs)("div",{className:"flex items-center justify-between bg-blue-50 border border-blue-200 px-3 py-1.5 rounded text-sm",children:[(0,a.jsx)("span",{className:"text-gray-700 truncate",children:e}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("span",{className:"text-gray-400 text-xs",children:(r=(null==(s=g[t])?void 0:s.fileSizeBytes)||0)<1024?"".concat(r," B"):r<1048576?"".concat((r/1024).toFixed(1)," KB"):"".concat((r/1048576).toFixed(1)," MB")}),(0,a.jsx)("button",{onClick:e=>{e.stopPropagation(),y(e=>e.filter((e,s)=>s!==t)),f(e=>e.filter((e,s)=>s!==t))},className:"text-red-500 hover:text-red-700 text-xs font-medium",children:"Remove"})]})]},t)})})]}),(0,a.jsxs)("div",{className:"flex space-x-3",children:[(0,a.jsx)("button",{onClick:O,disabled:!u.trim()||v,className:"px-4 py-2 bg-blue-600 text-white text-sm rounded hover:bg-blue-700 disabled:bg-gray-300 disabled:cursor-not-allowed",children:v?"Saving...":"Save Note"}),(0,a.jsx)("button",{onClick:z,className:"px-4 py-2 border border-gray-300 text-gray-700 text-sm rounded hover:bg-gray-50",children:"Clear"})]})]}),(0,a.jsxs)("div",{className:"border border-gray-200 rounded-lg p-5",children:[(0,a.jsx)("h4",{className:"text-sm font-semibold text-gray-700 uppercase tracking-wide mb-4",children:"Investment Decision"}),(0,a.jsxs)("div",{className:"flex space-x-3",children:[(0,a.jsx)("button",{onClick:()=>A({open:!0,type:"approve"}),className:"px-4 py-2 bg-emerald-600 text-white text-sm rounded hover:bg-emerald-700",children:"Approve for Investment"}),(0,a.jsx)("button",{onClick:()=>A({open:!0,type:"reject"}),className:"px-4 py-2 bg-red-700 text-white text-sm rounded hover:bg-red-800",children:"Reject for Investment"})]})]}),(0,a.jsxs)("div",{className:"border border-gray-200 rounded-lg",children:[(0,a.jsx)("div",{className:"p-4 border-b border-gray-200",children:(0,a.jsx)("h4",{className:"text-sm font-semibold text-gray-700 uppercase tracking-wide",children:"Compliance Action History"})}),0===W.length?(0,a.jsx)("p",{className:"text-gray-500 text-center py-8 text-sm",children:"No compliance actions recorded"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Date & Time"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Action"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Type"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"User"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Details"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Attachments"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:H.map((e,t)=>{let s=(L-1)*10+t,r=K.has(s);return(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"px-4 py-3 text-sm text-gray-500 whitespace-nowrap",children:(e=>{let t=e.createdAt||(e.createdAtTimestamp?e.createdAtTimestamp:null);if(!t)return"-";let s=new Date(t);if(isNaN(s.getTime()))return"-";let a=s.getFullYear(),r=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0"),n=String(s.getHours()).padStart(2,"0"),d=String(s.getMinutes()).padStart(2,"0");return"".concat(a,"-").concat(r,"-").concat(l," ").concat(n,":").concat(d)})(e)}),(0,a.jsx)("td",{className:"px-4 py-3",children:(0,a.jsx)("span",{className:"px-2 py-1 text-xs rounded-full font-medium ".concat((e=>{switch(e){case j.YD.NoteAdded:return"bg-gray-100 text-gray-700";case j.YD.DocumentsUploaded:return"bg-blue-100 text-blue-700";case j.YD.Approved:return"bg-emerald-100 text-emerald-700";case j.YD.Rejected:return"bg-red-100 text-red-700";default:return"bg-gray-100 text-gray-700"}})(e.actionType)),children:(e=>{switch(e){case j.YD.NoteAdded:return"Note added";case j.YD.DocumentsUploaded:return"Documents uploaded";case j.YD.Approved:return"Approved";case j.YD.Rejected:return"Rejected";default:return String(e)}})(e.actionType)})}),(0,a.jsx)("td",{className:"px-4 py-3",children:e.actionType===j.YD.Approved||e.actionType===j.YD.Rejected?(0,a.jsx)("span",{className:"px-2 py-1 text-xs rounded-full bg-gray-200 text-gray-700",children:"Decision"}):null!=e.noteType?(0,a.jsx)("span",{className:"px-2 py-1 text-xs rounded-full bg-gray-100 text-gray-600",children:(e=>{var t;if(null==e)return null;let s=N.find(t=>t.value===e);return null!=(t=null==s?void 0:s.label)?t:null}
1)(e.noteType)}):(0,a.jsx)("span",{className:"text-gray-400 text-xs",children:"-"})}),(0,a.jsx)("td",{className:"px-4 py-3 text-sm text-gray-500",children:e.userEmail||e.createdBy||"-"}),(0,a.jsx)("td",{className:"px-4 py-3 text-sm text-gray-700 max-w-xs truncate",title:e.note,children:e.note||"-"}),(0,a.jsx)("td",{className:"px-4 py-3",children:e.documents&&e.documents.length>0?(0,a.jsxs)("div",{children:[(0,a.jsxs)("button",{onClick:()=>{P(e=>{let t=new Set(e);return t.has(s)?t.delete(s):t.add(s),t})},className:"text-blue-600 hover:text-blue-800 text-xs font-medium",children:[e.documents.length," file(s) ",r?"â²":"â¼"]}),r&&(0,a.jsx)("div",{className:"mt-1 space-y-1",children:e.documents.map((e,t)=>(0,a.jsx)("button",{onClick:()=>_(e),className:"block text-xs text-blue-600 hover:text-blue-800 underline truncate max-w-[200px]",title:J(e),children:J(e)},t))})]}):(0,a.jsx)("span",{className:"text-gray-400 text-xs",children:"-"})})]},s)})})]})}),q>1&&(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-200",children:[(0,a.jsxs)("span",{className:"text-sm text-gray-500",children:["Showing ",(L-1)*10+1," - ",Z," of ",W.length," entries"]}),(0,a.jsxs)("div",{className:"flex space-x-1",children:[(0,a.jsx)("button",{onClick:()=>E(1),disabled:1===L,className:"px-2 py-1 text-xs border rounded disabled:opacity-50 hover:bg-gray-50",children:"First"}),(0,a.jsx)("button",{onClick:()=>E(e=>Math.max(1,e-1)),disabled:1===L,className:"px-2 py-1 text-xs border rounded disabled:opacity-50 hover:bg-gray-50",children:"Prev"}),(0,a.jsxs)("span",{className:"px-3 py-1 text-xs text-gray-600",children:["Page ",L," of ",q]}),(0,a.jsx)("button",{onClick:()=>E(e=>Math.min(q,e+1)),disabled:L===q,className:"px-2 py-1 text-xs border rounded disabled:opacity-50 hover:bg-gray-50",children:"Next"}),(0,a.jsx)("button",{onClick:()=>E(q),disabled:L===q,className:"px-2 py-1 text-xs border rounded disabled:opacity-50 hover:bg-gray-50",children:"Last"})]})]})]})]}),D.open&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:(0,a.jsxs)("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-md p-6",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"approve"===D.type?"Approve for Investment":"Reject for Investment"}),(0,a.jsxs)("p",{className:"text-sm text-gray-600 mb-4",children:["Are you sure you want to"," ","approve"===D.type?"approve":"reject"," this customer for investment?"]}),(0,a.jsxs)("div",{className:"mb-4",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-600 mb-1",children:"Reason / Note *"}),(0,a.jsx)("textarea",{value:F,onChange:e=>R(e.target.value),rows:3,placeholder:"Enter reason...",className:"w-full border border-gray-300 rounded px-3 py-2 text-sm focus:ring-blue-500 focus:border-blue-500"})]}),(0,a.jsxs)("div",{className:"flex justify-end space-x-3",children:[(0,a.jsx)("button",{onClick:()=>{A({open:!1,type:"approve"}),R("")},className:"px-4 py-2 border border-gray-300 text-gray-700 text-sm rounded hover:bg-gray-50",children:"Cancel"}),(0,a.jsx)("button",{onClick:G,disabled:!F.trim()||I,className:"px-4 py-2 text-white text-sm rounded disabled:bg-gray-300 disabled:cursor-not-allowed ".concat("approve"===D.type?"bg-emerald-600 hover:bg-emerald-700":"bg-red-700 hover:bg-red-800"),children:I?"Saving...":"Confirm"})]})]})})]})}function w(e){return 1===e||"Staff"===e||"staff"===e?"Staff":2===e||"Vip"===e||"vip"===e||"VIP"===e?"Vip":"None"}function C(e){let{customerId:t,onStatusChange:s}=e,[r,n]=(0,l.useState)(!0),[d,i]=(0,l.useState)(!1),[o,x]=(0,l.useState)(null),[u,m]=(0,l.useState)(null),[p,h]=(0,l.useState)(null),[g,y]=(0,l.useState)("Staff"),[b,f]=(0,l.useState)(""),[j,N]=(0,l.useState)(""),[v,C]=(0,l.useState)(""),[k,S]=(0,l.useState)("");(0,l.useEffect)(()=>{D()},[t]);let D=async()=>{try{n(!0),x(null);let r=await c.KD.getStaffVipStatus(t);if(r.success&&r.data&&"object"==typeof r.data){var e,s,a;let t=w(r.data.status);r.data.status=t,h(r.data),y("None"!==t?t:"Staff"),f((null==(e=r.data.atCostKycFee)?void 0:e.toString())||""),N((null==(s=r.data.atCostBrokerageFeePercent)?void 0:s.toString())||""),C((null==(a=r.data.atCostBrokerageFeeFixedAmount)?void 0:a.toString())||"")}else h(null),y("Staff")}catch(e){h(null)}finally{n(!1)}},A=async()=>{try{i(!0),x(null),m(null);let e=await c.KD.assignStaffVipStatus({customerId:t,status:g,atCostKycFee:b?parseFloat(b):null,atCostBrokerageFeePercent:j?parseFloat(j):null,atCostBrokerageFeeFixedAmount:v?parseFloat(v):null,reason:k||null});e.success&&e.data&&"object"==typeof e.data?(e.data.status=w(e.data.status),h(e.data),m("Status updated to ".concat(g," successfully")),null==s||s(e.data)):x(e.error||"Failed to assign status. Ensure the backend has the staff-vip endpoint deployed.")}catch(e){x(e.message||"Failed to assign status")}finally{i(!1)}},F=async()=>
1{if(confirm("Are you sure you want to revoke Staff/VIP status for this customer?"))try{i(!0),x(null),m(null);let e=await c.KD.revokeStaffVipStatus(t);e.success&&e.data&&"object"==typeof e.data?(e.data.status=w(e.data.status),h(e.data),y("None"),f(""),N(""),C(""),S(""),m("Staff/VIP status revoked successfully"),null==s||s(null)):x(e.error||"Failed to revoke status")}catch(e){x(e.message||"Failed to revoke status")}finally{i(!1)}};if(r)return(0,a.jsx)("div",{className:"flex justify-center py-8",children:(0,a.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"})});let R="Staff"===g,I="Vip"===g,T=(null==p?void 0:p.status)&&"None"!==p.status;return(0,a.jsxs)("div",{className:"space-y-6",children:[T&&(0,a.jsxs)("div",{className:"bg-white border rounded-lg p-4",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-gray-900 mb-3",children:"Current Status"}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-gray-500",children:"Status:"}),(0,a.jsx)("span",{className:"ml-2 px-2 py-0.5 rounded-full text-xs font-semibold ".concat((null==p?void 0:p.status)==="Staff"?"bg-blue-100 text-blue-800":"bg-yellow-100 text-yellow-800"),children:(null==p?void 0:p.status)==="Staff"?"Staff":"VIP"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-gray-500",children:"Granted by:"}),(0,a.jsx)("span",{className:"ml-2 text-gray-900",children:(null==p?void 0:p.grantedBy)||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-gray-500",children:"Granted at:"}),(0,a.jsx)("span",{className:"ml-2 text-gray-900",children:(null==p?void 0:p.grantedAt)?new Date(p.grantedAt).toLocaleString():"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-gray-500",children:"Reason:"}),(0,a.jsx)("span",{className:"ml-2 text-gray-900",children:(null==p?void 0:p.reason)||"-"})]}),(null==p?void 0:p.atCostBrokerageFeePercent)!=null&&(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-gray-500",children:"Brokerage fee:"}),(0,a.jsxs)("span",{className:"ml-2 text-gray-900",children:[p.atCostBrokerageFeePercent,"% + $",p.atCostBrokerageFeeFixedAmount||0," fixed"]})]}),(null==p?void 0:p.atCostKycFee)!=null&&(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-gray-500",children:"KYC fee:"}),(0,a.jsxs)("span",{className:"ml-2 text-gray-900",children:["$",p.atCostKycFee]})]})]}),(0,a.jsx)("button",{onClick:F,disabled:d,className:"mt-4 px-4 py-2 text-sm font-medium text-red-700 bg-red-50 border border-red-200 rounded-lg hover:bg-red-100 disabled:opacity-50",children:d?"Revoking...":"Revoke Status"})]}),(0,a.jsxs)("div",{className:"bg-white border rounded-lg p-4",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-gray-900 mb-4",children:T?"Update Status":"Assign Status"}),o&&(0,a.jsx)("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-800",children:o}),u&&(0,a.jsx)("div",{className:"mb-4 p-3 bg-green-50 border border-green-200 rounded-lg text-sm text-green-800",children:u}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Status"}),(0,a.jsxs)("select",{value:g,onChange:e=>y(e.target.value),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500",children:[(0,a.jsx)("option",{value:"Staff",children:"Staff"}),(0,a.jsx)("option",{value:"Vip",children:"VIP"})]})]}),(0,a.jsxs)("div",{className:"bg-gray-50 rounded-lg p-3 text-xs text-gray-600",children:[(0,a.jsxs)("p",{className:"font-medium text-gray-800 mb-1",children:["Fee benefits for ",g,":"]}),(0,a.jsxs)("ul",{className:"list-disc list-inside space-y-0.5",children:[(0,a.jsxs)("li",{children:["Platform Fee: ",(0,a.jsx)("span",{className:"text-green-600 font-medium",children:"Free"})]}),(0,a.jsxs)("li",{children:["Advisory Fee: ",(0,a.jsx)("span",{className:"text-green-600 font-medium",children:"Free"})]}),(0,a.jsxs)("li",{children:["KYC/Onboarding Fee: ",R?(0,a.jsx)("span",{className:"text-green-600 font-medium",children:"Free"}):(0,a.jsx)("span",{className:"text-blue-600 font-medium",children:"Configurable at-cost"})]}),(0,a.jsxs)("li",{children:["Brokerage Fee: ",(0,a.jsx)("span",{className:"text-blue-600 font-medium",children:"Configurable at-cost"})]})]})]}),I&&(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"At-Cost KYC Fee ($)"}),(0,a.jsx)("input",{type:"number",step:"0.01",min:"0",value:b,onChange:e=>f(e.target.value),placeholder:"e.g., 2.00",className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),(0,a.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"Leave empty for default. Staff get this waived."})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Brokerage Fee (%)"}),(0,a.jsx)("input",{type:"number",step:"0.01",min:"0",value:j,onChange:e=>N(e.target.value),placeholder:"e.g., 0.05",className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Brokerage Fixed ($)"}),(0,a.jsx)("input",{type:"number",step:"0.01",min:"0",value:v,onCh
1ange:e=>C(e.target.value),placeholder:"e.g., 1.00",className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Reason"}),(0,a.jsx)("textarea",{value:k,onChange:e=>S(e.target.value),placeholder:"Reason for granting Staff/VIP status",rows:2,className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),(0,a.jsx)("button",{onClick:A,disabled:d||"None"===g,className:"w-full px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:d?"Saving...":T?"Update Status":"Assign Status"})]})]})]})}var k=s(94282),S=s(13125);function D(e){let{customerId:t}=e,[s,r]=(0,l.useState)(null),[n,d]=(0,l.useState)(!0),[i,o]=(0,l.useState)(null),[x,u]=(0,l.useState)(!1),[m,p]=(0,l.useState)(!1),[h,g]=(0,l.useState)(""),y=(0,l.useCallback)(async()=>{d(!0),o(null);try{let e=await c.KD.getIncomeVerificationSources(t);if(!e.success)throw Error(e.error||"request failed");r(e.data)}catch(e){o("Could not load income sources (".concat(e.message,")."))}finally{d(!1)}},[t]);(0,l.useEffect)(()=>{y()},[y]);let b=async e=>{if(e||h.trim()){u(!0),o(null);try{let s=await c.KD.verifyIncome(t,{approve:e,rejectionReason:e?null:h.trim()});if(!s.success)throw Error(s.error||"request failed");p(!1),g(""),await y()}catch(e){o("Review failed (".concat(e.message,")."))}finally{u(!1)}}},f=async e=>{try{var s;let a=await c.KD.getIncomeVerificationDocumentUrl(t,e);a.success&&(null==(s=a.data)?void 0:s.url)?window.open(a.data.url,"_blank","noopener,noreferrer"):o("Could not open the document.")}catch(e){o("Could not open the document.")}};if(n)return(0,a.jsx)("div",{className:"p-6 text-gray-500",children:"Loading incomeâ¦"});if(i)return(0,a.jsx)("div",{className:"p-4 rounded-lg bg-red-50 text-red-700 text-sm",children:i});if(!s)return null;let j=s.documents.length>0,N=j&&!s.salaryVerified&&s.documents.some(e=>"Pending"===e.status);return(0,a.jsxs)("div",{className:"max-w-4xl",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-lg font-semibold text-gray-900",children:"Income"}),(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Every income figure on record, and the documents to verify it."})]}),s.salaryVerified&&(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs font-semibold text-[#01875F] bg-[#E7F7F0] px-2.5 py-1 rounded-full",children:[(0,a.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",strokeWidth:"3",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M20 6L9 17l-5-5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Income verified"]})]}),(0,a.jsx)("div",{className:"bg-white border border-gray-200 rounded-xl overflow-hidden mb-6",children:(0,a.jsxs)("table",{className:"w-full text-sm",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"text-left text-gray-500 text-xs uppercase tracking-wide border-b border-gray-200",children:[(0,a.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Source"}),(0,a.jsx)("th",{className:"px-4 py-3 font-semibold text-right",children:"Amount"}),(0,a.jsx)("th",{className:"px-4 py-3 font-semibold text-center",children:"Status"})]})}),(0,a.jsx)("tbody",{children:0===s.sources.length?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:3,className:"px-4 py-6 text-center text-gray-500",children:"No income on record for this customer."})}):s.sources.map(e=>{let t,s;return(0,a.jsxs)("tr",{className:"border-b border-gray-100 last:border-0",children:[(0,a.jsx)("td",{className:"px-4 py-3 text-gray-900",children:e.label}),(0,a.jsx)("td",{className:"px-4 py-3 text-right font-medium text-gray-900",children:(t=e.amount,s=e.currencyCode,"".concat(s||"ZAR"," ").concat(Math.round(t).toLocaleString("en-ZA")))}),(0,a.jsx)("td",{className:"px-4 py-3 text-center",children:e.verified?(0,a.jsx)("span",{className:"inline-flex items-center gap-1 text-xs font-semibold text-[#01875F] bg-[#E7F7F0] px-2 py-0.5 rounded-full",children:"Verified"}):(0,a.jsx)("span",{className:"text-xs text-gray-400",children:"â"})})]},e.source)})})]})}),(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-xl p-5",children:[(0,a.jsx)("div",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide mb-3",children:"Documents"}),j?(0,a.jsx)("div",{className:"space-y-2 mb-4",children:s.documents.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>f(e.id),className:"w-full flex items-center gap-2 p-2.5 rounded-lg border border-gray-200 hover:border-[#01C38D] hover:bg-[#F8FBFA] transition-colors group text-left",children:[(0,a.jsxs)("svg",{className:"w-4 h-4 text-gray-500 flex-shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,a.jsx)("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,a.jsx)("path",{d:"M14 2v6h6",strokeLinecap:"round",strokeLinejoin:"round"})]}),(0,a.jsx)("span",{className:"text-sm text-gray-900 truncate group-hover:text-[#01875F]",children:e.fileName}),e.source&&(0,a.jsxs)("span",{className:"text-xs text-gray-400",children:["from ",e.source]}),(0,a.jsx)("span",{className:"text-xs text-gray-400 ml-auto flex-shrink-0",children:new Date(e.uploadedAt).toLocaleStr
1ing("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})})]},e.id))}):(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"No documents uploaded."}),j&&!s.salaryVerified&&(m?(0,a.jsxs)("div",{className:"border-t border-gray-100 pt-4",children:[(0,a.jsxs)("label",{className:"text-sm font-medium text-gray-700",children:["Reason for rejection ",(0,a.jsx)("span",{className:"text-red-600",children:"*"})]}),(0,a.jsx)("p",{className:"text-xs text-gray-500 mb-2",children:'Shown to the customer, so be specific (e.g. "Payslip shows R3,000 but you entered R12,000").'}),(0,a.jsx)("textarea",{value:h,onChange:e=>g(e.target.value),rows:3,className:"w-full rounded-lg border border-gray-300 text-sm p-3 focus:border-[#01C38D] focus:outline-none",placeholder:"Explain what the customer needs to correctâ¦"}),(0,a.jsxs)("div",{className:"flex gap-2 mt-3",children:[(0,a.jsx)("button",{disabled:x||!h.trim(),onClick:()=>b(!1),className:"h-10 px-4 rounded-lg bg-[#B3261E] text-white text-sm font-semibold hover:bg-[#8f1e18] disabled:opacity-50",children:x?"Workingâ¦":"Confirm rejection"}),(0,a.jsx)("button",{disabled:x,onClick:()=>{p(!1),g("")},className:"h-10 px-3 rounded-lg border border-gray-300 text-gray-700 text-sm font-medium",children:"Cancel"})]})]}):(0,a.jsxs)("div",{className:"flex gap-2 border-t border-gray-100 pt-4",children:[(0,a.jsx)("button",{disabled:x,onClick:()=>b(!0),className:"h-11 px-5 rounded-lg bg-[#01C38D] text-white text-sm font-semibold hover:bg-[#00A87A] disabled:opacity-50",children:x?"Workingâ¦":"Approve income"}),(0,a.jsx)("button",{disabled:x,onClick:()=>p(!0),className:"h-11 px-5 rounded-lg border border-gray-300 text-[#B3261E] text-sm font-semibold hover:bg-[#FDECEA] disabled:opacity-50",children:"Reject"})]})),N&&(0,a.jsx)("p",{className:"text-xs text-gray-400 mt-2",children:"Awaiting review."})]}),(0,a.jsx)(S.A,{activity:s.activity,rejectionHistory:s.rejectionHistory,className:"mt-5"})]})}var A=s(11345),F=s(24338);function R(e){let{customerId:t}=e,[s,r]=(0,l.useState)([]),[n,d]=(0,l.useState)(1),[i,c]=(0,l.useState)(!0),[o,u]=(0,l.useState)(null),[m,p]=(0,l.useState)(""),[h,g]=(0,l.useState)(""),[y,b]=(0,l.useState)(void 0),[f,j]=(0,l.useState)(void 0),N=(0,l.useCallback)(async(e,s,a)=>{c(!0),u(null);try{var l,n;let d=await x.KD.getAggregatedRevenue({pageNumber:e,pageSize:20,from:s||void 0,to:a||void 0,customerId:t});d.success&&d.data?r(null!=(l=d.data.items)?l:[]):u(null!=(n=d.error)?n:"Failed to load fees data.")}catch(e){u("An unexpected error occurred.")}finally{c(!1)}},[t]);return(0,l.useEffect)(()=>{let e=!0;return(async()=>{c(!0),u(null);try{var s,a;let l=await x.KD.getAggregatedRevenue({pageNumber:1,pageSize:20,from:void 0,to:void 0,customerId:t});if(!e)return;l.success&&l.data?r(null!=(s=l.data.items)?s:[]):u(null!=(a=l.error)?a:"Failed to load fees data.")}catch(t){e&&u("An unexpected error occurred.")}finally{e&&c(!1)}})(),()=>{e=!1}},[t]),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-end gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:"From"}),(0,a.jsx)("input",{type:"date",value:m,onChange:e=>p(e.target.value),className:"border border-gray-300 rounded px-3 py-1.5 text-sm"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:"To"}),(0,a.jsx)("input",{type:"date",value:h,onChange:e=>g(e.target.value),className:"border border-gray-300 rounded px-3 py-1.5 text-sm"})]}),(0,a.jsx)("button",{onClick:()=>{let e=m||void 0,t=h||void 0;b(e),j(t),d(1),N(1,e,t)},disabled:i,className:"px-4 py-1.5 bg-blue-600 text-white text-sm rounded hover:bg-blue-700 disabled:opacity-50",children:"Apply"}),(0,a.jsx)("button",{onClick:()=>{p(""),g(""),b(void 0),j(void 0),d(1),N(1)},disabled:i,className:"px-4 py-1.5 bg-gray-200 text-gray-700 text-sm rounded hover:bg-gray-300 disabled:opacity-50",children:"Reset"})]}),!i&&o&&(0,a.jsx)("div",{className:"bg-red-50 border border-red-200 text-red-700 rounded px-4 py-3 text-sm",children:o}),!o&&(0,a.jsx)(F.A,{data:s,loading:i,currentPage:n,pageSize:20,onPageChange:e=>{d(e),N(e,y,f)}})]})}var I=s(79207);function T(){var e,t;let s=(0,n.useRouter)(),{id:u}=s.query,{idToken:m,adminUser:p}=(0,r.bn)(),h=!!(null==p||null==(e=p.roles)?void 0:e.includes("Admin")),[b,j]=(0,l.useState)(null),[N,w]=(0,l.useState)(null),[S,F]=(0,l.useState)([]),[T,L]=(0,l.useState)([]),[E,K]=(0,l.useState)([]),[P,B]=(0,l.useState)([]),[M,U]=(0,l.useState)([]),[V,Y]=(0,l.useState)([]),[O,z]=(0,l.useState)(""),[G,_]=(0,l.useState)(""),[J,W]=(0,l.useState)(!1),[q,H]=(0,l.useState)("active"),[Z,$]=(0,l.useState)({date:"",description:"",category:""}),[Q,X]=(0,l.useState)(!1),[ee,et]=(0,l.useState)({key:"transactionDate",dir:"desc"}),[es,ea]=(0,l.useState)(new Set),[er,el]=(0,l.useState)(!1),[en,ed]=(0,l.useState)(null),[ei,ec]=(0,l.useState)({status:"loading"}),[eo,ex]=(0,l.useState)("accounts"),eu=function(){let[e,t]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{let e=!1;return x.KD.getFeatureToggles().then(s=>{var a;if(e)return;let r=(null!=(a=s.data)?a:[]).find(e=>e.featureName===y.nS);t(!!(null==r?void 0:r.isEnabled))}).catch(()=>{}),()=>{e=!0}},[]),e}(),em=(0,A.c)(),[ep,eh]=(0,l.useState)(!0),[eg,ey]=(0,l.useState)(!1),[eb,ef]=(0,l.useState)(null);(0,l.useEffect)(()=>{u&&m&&eS()},[u,m]),(0,l.useEffect)(()=>
1{if(!s.isReady)return;let e=s.query.tab;e&&["accounts","transactions","login","integration-logs","audit-logs","kyc","compliance","staff-vip","fees-billing","refresh-history"].includes(e)&&ex(e)},[s.isReady,s.query.tab]);let ej="all"===q?S:S.map(e=>({...e,accounts:e.accounts.filter(e=>{switch(q){case"active":default:return!e.deactivated&&!e.isDeleted;case"deactivated":return e.deactivated&&!e.isDeleted;case"deleted":return e.isDeleted}})})).filter(e=>e.accounts.length>0),eN=e=>{var t;let s=e.amount;return"".concat((null==s?void 0:s.currency)||(null==s?void 0:s.currencyCode)||"",":").concat(null!=(t=null==s?void 0:s.amount)?t:"")},ev=new Set(Object.entries(T.reduce((e,t)=>{let s=t.transactionDate?new Date(t.transactionDate).toISOString().slice(0,10):"",a=(t.description||"").trim().toLowerCase(),r=eN(t),l="".concat(s,"|").concat(a,"|").concat(r);return e[l]=(e[l]||0)+1,e},{})).filter(e=>{let[,t]=e;return t>1}).map(e=>{let[t]=e;return t})),ew=[...T].filter(e=>{let t=e.transactionDate?new Date(e.transactionDate).toLocaleDateString():"",s="".concat(e.transactionDate?new Date(e.transactionDate).toISOString().slice(0,10):"","|").concat((e.description||"").trim().toLowerCase(),"|").concat(eN(e));return(!Q||!!ev.has(s))&&(!Z.date||!!t.toLowerCase().includes(Z.date.toLowerCase())||!!(e.transactionDate||"").toLowerCase().includes(Z.date.toLowerCase()))&&(!Z.description||!!(e.description||"").toLowerCase().includes(Z.description.toLowerCase()))&&(!Z.category||!!(e.categoryName||"").toLowerCase().includes(Z.category.toLowerCase()))}).sort((e,t)=>{let s="asc"===ee.dir?1:-1,a=e=>{var t,s,a,r;return"transactionDate"===ee.key?new Date(e.transactionDate||0).getTime():"amount"===ee.key?null!=(a=null==(t=e.amount)?void 0:t.amount)?a:0:"balance"===ee.key?null!=(r=null==(s=e.balance)?void 0:s.amount)?r:0:"description"===ee.key?(e.description||"").toLowerCase():(e.categoryName||"").toLowerCase()},r=a(e),l=a(t);return("number"==typeof r&&"number"==typeof l?r-l:String(r).localeCompare(String(l)))*s}),eC=e=>{et(t=>t.key===e?{key:e,dir:"asc"===t.dir?"desc":"asc"}:{key:e,dir:"asc"})},ek={active:S.reduce((e,t)=>e+t.accounts.filter(e=>!e.deactivated&&!e.isDeleted).length,0),deactivated:S.reduce((e,t)=>e+t.accounts.filter(e=>e.deactivated&&!e.isDeleted).length,0),deleted:S.reduce((e,t)=>e+t.accounts.filter(e=>e.isDeleted).length,0),all:S.reduce((e,t)=>e+t.accounts.length,0)},eS=async()=>{try{var e,t;eh(!0),ef(null);let[s,a]=await Promise.all([c.KD.getCustomerProfile(u),c.KD.getCustomerAccounts(u,"all")]);s.success&&s.data?j(s.data):ef(s.error||"Failed to load customer profile"),a.success&&a.data&&F(a.data);try{let t=await c.KD.getStaffVipStatus(u);t.success&&t.data&&"object"==typeof t.data&&(t.data.status=(e=t.data.status,1===e||"Staff"===e||"staff"===e?"Staff":2===e||"Vip"===e||"vip"===e||"VIP"===e?"Vip":"None"),"None"!==t.data.status&&ed(t.data))}catch(e){}try{let e=await c.KD.getCustomerProfileExtended(u);e.success&&e.data?ec({status:"ok",info:e.data}):(console.warn("[admin] customer tier lookup failed",null!=(t=e.error)?t:e),ec({status:"failed",httpStatus:e.statusCode}))}catch(e){console.warn("[admin] customer tier lookup threw",e),ec({status:"failed"})}try{let e=await c.KD.getTotpStatus(u);e.success&&e.data&&"object"==typeof e.data&&w(e.data)}catch(e){}}catch(e){ef(e.message||"Failed to load customer data")}finally{eh(!1)}},eD=async()=>{if(G&&u)try{ey(!0);let e=await c.KD.getAccountTransactions(u,G,J);e.success&&e.data&&L(e.data)}catch(e){}finally{ey(!1)}},eA=async()=>{if(u)try{ey(!0);let e=await c.KD.getIntegrationLogDates(u);e.success&&e.data&&(Y(e.data),e.data.length>0&&z(e.data[0]))}catch(e){}finally{ey(!1)}},eF=async()=>{if(u&&O)try{ey(!0);let e=await c.KD.getIntegrationLogs(u,O);e.success&&e.data&&K(e.data)}catch(e){}finally{ey(!1)}},eR=async()=>{if(!u)return[];try{ey(!0);let e=await c.KD.getAuditLogs(u);if(e.success&&e.data)return B(e.data),e.data}catch(e){}finally{ey(!1)}return[]},eI=async()=>{if(!u)return;let e=async()=>{let e=await eR();U((e.length?e:P).filter(eP).map(eM))};try{ey(!0);let t=await c.KD.getCustomerLoginAudit(u),s=t.success&&t.data&&t.data.entries||[];s.length>0?U(s.map(eU)):await e()}catch(t){await e()}finally{ey(!1)}};(0,l.useEffect)(()=>{"integration-logs"===eo&&0===V.length?eA():"audit-logs"===eo&&0===P.length?eR():"login"===eo&&0===M.length&&eI()},[eo]),(0,l.useEffect)(()=>{O&&eF()},[O]),(0,l.useEffect)(()=>{G&&eD()},[G,J]);let eT=e=>{switch(null==e?void 0:e.toLowerCase()){case"active":return"bg-green-100 text-green-800";
1case"frozen":return"bg-blue-100 text-blue-800";case"locked":return"bg-yellow-100 text-yellow-800";case"deleted":return"bg-red-100 text-red-800";default:return"bg-gray-100 text-gray-800"}},eL=(0,I.M)(ei),eE=e=>{if(!e)return"-";let t=(e.currency||e.currencyCode||"USD").trim();if(!/^[A-Z]{3}$/.test(t)){let s=new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:8}).format(e.amount);return"".concat(s," ").concat(t)}try{return new Intl.NumberFormat("en-US",{style:"currency",currency:t}).format(e.amount)}catch(a){let s=new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:8}).format(e.amount);return"".concat(s," ").concat(t)}},eK=e=>e?new Date(e).toLocaleString():"-",eP=e=>{let t="".concat(e.logType||""," ").concat(e.action||""," ").concat(e.message||""," ").concat(e.controller||"").toLowerCase();return t.includes("login")||t.includes("password")||t.includes("lockout")||t.includes("locked out")},eB=e=>{let t="".concat(e.action||""," ").concat(e.message||""," ").concat(e.logType||""," ").concat(e.type||"").toLowerCase();return t.includes("incorrect")||t.includes("wrong password")||t.includes("invalid password")||t.includes("failed password")?"customer used incorrect password":t.includes("lockout")||t.includes("locked out")||t.includes("locked")?"customer locked out":t.includes("success")||t.includes("logged in")||t.includes("login succeeded")?"successful login":e.action||e.message||"Login event"},eM=e=>({dateTime:e.dateTime,platform:e.platform||e.controller||"-",type:e.logType||"Login",action:eB(e),message:e.message}),eU=e=>({dateTime:e.timestamp,platform:e.deviceType||e.osVersion||"-",type:e.status||"Login",action:(e=>{let t="".concat(e.status||""," ").concat(e.failureReason||""," ").concat(e.message||"").toLowerCase();return t.includes("incorrect")||t.includes("wrong password")||t.includes("invalid")||t.includes("failed password")?"customer used incorrect password":t.includes("lock")?"customer locked out":(e.status||"").toLowerCase().includes("success")||t.includes("logged in")?"successful login":e.failureReason||e.message||e.status||"Login event"})(e),message:e.message});return ep?(0,a.jsx)(d.A,{children:(0,a.jsx)("div",{className:"flex justify-center py-12",children:(0,a.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500"})})}):(0,a.jsx)(d.A,{children:(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)(f(),{href:"/admin/customers",className:"text-blue-600 hover:text-blue-800 text-sm flex items-center",children:[(0,a.jsx)("svg",{className:"w-4 h-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),"Back to Customers"]}),eb&&(0,a.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:(0,a.jsx)("p",{className:"text-red-800",children:eb})}),b&&(0,a.jsxs)("div",{className:"bg-white shadow rounded-lg p-6",children:[(0,a.jsxs)("div",{className:"flex justify-between items-start mb-6",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold text-gray-900",children:"Profile Details"}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("span",{className:"px-3 py-1 text-sm rounded-full ".concat(eT(b.status)),children:b.status}),en&&(0,a.jsx)("span",{className:"px-3 py-1 text-sm rounded-full font-semibold ".concat("Staff"===en.status?"bg-blue-100 text-blue-800":"bg-yellow-100 text-yellow-800"),children:"Staff"===en.status?"â Staff":"\uD83D\uDC51 VIP"}),eL&&(0,a.jsx)("span",{className:"px-3 py-1 text-sm rounded-full font-semibold ".concat((e=>{switch(null==e?void 0:e.toLowerCase()){case"premium":return"bg-purple-100 text-purple-800";case"basic":return"bg-teal-100 text-teal-800";case"familyfinance":return"bg-indigo-100 text-indigo-800";default:return"bg-gray-100 text-gray-800"}})(eL.tier)),title:eL.title,children:eL.label}),(0,a.jsx)(i.A,{customerId:u,profile:b,isTotpEnabled:null==N?void 0:N.isEnabled,onActionComplete:eS})]})]}),(0,a.jsxs)("dl",{className:"grid grid-cols-1 md:grid-cols-2 gap-y-4 gap-x-12 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500 mb-1",children:"Profile ID"}),(0,a.jsx)("dd",{className:"font-mono text-xs text-gray-900",children:b.id})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500 mb-1",children:"Organization"}),(0,a.jsx)("dd",{className:"text-gray-900",children:b.organizationName||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500 mb-1",children:"Date Created"}),(0,a.jsx)("dd",{className:"text-gray-900",children:eK(b.createdDate||b.createdAt)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500 mb-1",children:"Name"}),(0,a.jsx)("dd",{className:"text-gray-900",children:b.name||b.firstName||b.legalFirstNames||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500 mb-1",children:"Surname"}),(0,a.jsx)("dd",{className:"text-gray-900",children:b.surname||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500 mb-1",children:"Email"}),(0,a.jsx)("dd",{className:"text-gray-900",children:b.email||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500 mb-1",children:"Is Frozen"}),(0,a.jsx)("dd",{className:"text-gray-900",children:b.isFrozen?"True":"False"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500 mb-1",children:"Is Locked Out"}),(0,a.jsx)("dd",{className:"text-gray-900",children:b.isLockedOut?"True":"False"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-gray-500 mb-1",children:"Google Authenticator"}),(0,a.jsx)("dd",{className:"text-gray-900",children:null==N?"â":N.isEnabled?"Enabled".concat(N.enabledAt?" (since ".concat(new Date(N.enabledAt).toLocaleDateString(),")"):""):"Not set"})]}),(0,a.jsxs)("div",{className:"md:col-span-2",children:[(0,a.jsx)("dt",{className:"text-gray-500 mb-1",children:"Phone Numbers"}),(0,a.jsx)("dd",{className:"text-gray-900",children:(null==(t=b.mobileNumbers)?void 0:t.length)?b.mobileNumbers.map(e=>"(".concat(e.countryCode||"",") ").concat(e.number)).join(" ; "):b.mobileNumber?"(".concat(b.countryCode||"",") ").concat(b.mobileNumber):"-"})]})]})]}),(0,a.jsxs)("div",{className:"bg-white shadow rounded-lg",children:[(0,a.jsx)("div",{className:"border-b border-gray-200",children:(0,a.jsx)("nav",{className:"flex -mb-px",children:[{id:"accounts",label:"Accounts"},{id:"transactions",label:"Transactions"},{id:"login",label:"Login"},{id:"refresh-history",label:"Refresh History"},{id:"kyc",label:"KYC"},...em?[{id:"income",label:"Income"}]:[],{id:"integration-logs",label:"Integration Logs"},{id:"audit-logs",label:"Audit Logs"},{id:"compliance",label:"Compliance Actions"},{id:"staff-vip",label:"Staff/VIP"},{id:"fees-billing",label:"Fees & Billing"},...eu?[{id:"intelligence-report",label:"Intelligence Report"}]:[]].map(e=>(0,a.jsx)("button",{onClick:()=>ex(e.id),className:"py-4 px-6 text-sm font-medium border-b-2 ".concat(eo===e.id?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"),children:e.label},e.id))})}),(0,a.jsx)("div",{className:"p-6",children:eg?(0,a.jsx)("div",{className:"flex justify-center py-8",children:(0,a.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"})}):(0,a.jsxs)(a.Fragment,{children:["accounts"===eo&&(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("div",{className:"flex items-center gap-1 bg-gray-100 p-1 rounded-lg w-fit",children:[{value:"active",label:"Active",activeClasses:"bg-emerald-50 text-emerald-700 ring-1 ring-emerald-200",countClasses:"bg-emerald-100 text-emerald-600"},{value:"deactivated",label:"Deactivated",activeClasses:"bg-amber-50 text-amber-700 ring-1 ring-amber-200",countClasses:"bg-amber-100 text-amber-600"},{value:"deleted",label:"Deleted",activeClasses:"bg-red-50 text-red-700 ring-1 ring-red-200",countClasses:"bg-red-100 text-red-600"},{value:"all",label:"Consolidated",activeClasses:"bg-blue-50 text-blue-700 ring-1 ring-blue-200",countClasses:"bg-blue-100 text-blue-600"}].map(e=>(0,a.jsxs)("button",{onClick:()=>H(e.value),className:"px-4 py-1.5 text-sm font-medium rounded-md transition-colors ".concat(q===e.value?e.activeClasses:"text-gray-600 hover:text-gray-900"),children:[e.label,(0,a.jsx)("span",{className:"ml-1.5 px-1.5 py-0.5 text-xs rounded-full ".concat(q===e.value?e.countClasses:"bg-gray-200 text-gray-500"),children:ek[e.value]})]},e.value))}),0===ej.length?(0,a.jsxs)("p",{className:"text-gray-500 text-center py-8",children:["No ","all"===q?"":q," accounts found"]}
1):ej.map(e=>(0,a.jsxs)("div",{className:"border border-gray-200 rounded-lg p-4",children:[(0,a.jsxs)("div",{className:"flex justify-between items-start mb-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"font-semibold text-gray-900",children:e.serviceProviderName}),e.username&&(0,a.jsx)("p",{className:"text-sm text-gray-500",children:e.username})]}),(0,a.jsx)("span",{className:"px-2 py-1 text-xs rounded-full ".concat(eT(e.status)),children:e.status})]}),e.lastRefreshDate&&(0,a.jsxs)("p",{className:"text-xs text-gray-500 mb-3",children:["Last refresh: ",eK(e.lastRefreshDate)]}),e.accounts.length>0&&(0,a.jsx)("div",{className:"mt-2 space-y-2",children:e.accounts.map(e=>(0,a.jsxs)("div",{className:"p-3 rounded border ".concat(e.isDeleted?"bg-red-50 border-red-200 opacity-75":e.deactivated?"bg-gray-50 border-gray-200":"bg-white border-gray-100"),children:[(0,a.jsxs)("div",{className:"flex justify-between items-start",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"font-medium text-sm",children:[e.displayName||e.friendlyName||e.accountNumber||"Unknown Account",e.isDeleted&&(0,a.jsx)("span",{className:"ml-2 px-1.5 py-0.5 text-xs font-medium bg-red-100 text-red-700 rounded",children:"Deleted"}),e.deactivated&&!e.isDeleted&&(0,a.jsx)("span",{className:"ml-2 px-1.5 py-0.5 text-xs font-medium bg-amber-100 text-amber-700 rounded",children:"Deactivated"})]}),(0,a.jsxs)("p",{className:"text-xs text-gray-500",children:[e.accountClass," ",e.accountDisplayType&&"- ".concat(e.accountDisplayType)]}),e.accountNumber&&(0,a.jsx)("p",{className:"text-xs text-gray-400",children:e.accountNumber})]}),(0,a.jsxs)("div",{className:"text-right",children:[(0,a.jsx)("p",{className:"font-semibold text-sm",children:eE(e.currentBalance)}),e.availableBalance&&(0,a.jsxs)("p",{className:"text-xs text-gray-500",children:["Available: ",eE(e.availableBalance)]})]})]}),(0,a.jsxs)("div",{className:"mt-2 flex items-center gap-3",children:[(0,a.jsx)("button",{onClick:()=>{_(e.id),ex("transactions")},className:"text-xs text-blue-600 hover:text-blue-800",children:"View Transactions"}),(0,a.jsx)(f(),{href:"/admin/customers/".concat(u,"/accounts/").concat(e.id),className:"text-xs font-medium text-blue-700 hover:text-blue-900","data-testid":"open-account-".concat(e.id),children:"Open account details â"})]})]},e.id))})]},e.id))]}),"transactions"===eo&&(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex gap-4 items-end",children:[(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Select Account"}),(0,a.jsxs)("select",{value:G,onChange:e=>_(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md",children:[(0,a.jsx)("option",{value:"",children:"Select an account..."}),ej.flatMap(e=>e.accounts.map(t=>(0,a.jsxs)("option",{value:t.id,children:[e.serviceProviderName," - ",t.displayName||t.friendlyName||t.accountNumber||t.id]},t.id)))]})]}),(0,a.jsxs)("label",{className:"flex items-center gap-2 pb-2",children:[(0,a.jsx)("input",{type:"checkbox",checked:J,onChange:e=>W(e.target.checked),className:"rounded border-gray-300"}),(0,a.jsx)("span",{className:"text-sm text-gray-700",children:"Include archived"})]}),(0,a.jsxs)("label",{className:"flex items-center gap-2 pb-2",children:[(0,a.jsx)("input",{type:"checkbox",checked:Q,onChange:e=>X(e.target.checked),className:"rounded border-gray-300","data-testid":"cust-tx-duplicate-filter"}),(0,a.jsx)("span",{className:"text-sm text-gray-700",children:"Duplicate transactions"})]})]}),G&&(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[(0,a.jsx)("input",{type:"text",value:Z.date,onChange:e=>$(t=>({...t,date:e.target.value})),placeholder:"Search date",className:"px-3 py-2 border border-gray-300 rounded-md text-sm","data-testid":"cust-tx-filter-date"}),(0,a.jsx)("input",{type:"text",value:Z.description,onChange:e=>$(t=>({...t,description:e.target.value})),placeholder:"Search description",className:"px-3 py-2 border border-gray-300 rounded-md text-sm","data-testid":"cust-tx-filter-description"}),(0,a.jsx)("input",{type:"text",value:Z.category,onChange:e=>$(t=>({...t,category:e.target.value})),placeholder:"Search category",className:"px-3 py-2 border border-gray-300 rounded-md text-sm","data-testid":"cust-tx-filter-category"})]}),G&&es.size>0&&(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 bg-blue-50 border border-blue-200 rounded-md px-3 py-2","data-testid":"cust-tx-bulk-bar",children:[(0,a.jsxs)("span",{className:"text-sm text-blue-900",children:[es.size," transaction",1===es.size?"":"s"," selected"]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("button",{onClick:()=>ea(new Set),className:"px-2 py-1 text-xs font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50","data-testid":"cust-tx-bulk-clear",children:"Clear"}),(0,a.jsx)("button",{disabled:er,onClick:async()=>
1{if(confirm("Archive ".concat(es.size," transactions? This soft-deletes â they can be restored later.")))try{el(!0);let e=Array.from(es),t=await c.KD.bulkArchiveCustomerTransactions(u,G,e);if(!t.success)return void alert(t.error||"Bulk archive failed");ea(new Set),await eD()}finally{el(!1)}},className:"px-3 py-1 text-xs font-medium text-white bg-red-600 rounded-md hover:bg-red-700 disabled:opacity-50","data-testid":"cust-tx-bulk-archive",children:er?"Archivingâ¦":"Archive selected"})]})]}),G?0===T.length?(0,a.jsx)("p",{className:"text-gray-500 text-center py-8",children:"No transactions found"}):0===ew.length?(0,a.jsx)("p",{className:"text-gray-500 text-center py-8",children:"No transactions match the current filters"}):(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-2 py-3 w-8",children:(0,a.jsx)("input",{type:"checkbox",checked:ew.length>0&&ew.filter(e=>!e.isArchived).every(e=>es.has(e.id)),onChange:e=>{e.target.checked?ea(new Set(ew.filter(e=>!e.isArchived).map(e=>e.id))):ea(new Set)},className:"rounded border-gray-300","data-testid":"cust-tx-select-all"})}),(0,a.jsxs)("th",{onClick:()=>eC("transactionDate"),className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase cursor-pointer select-none",children:["Date","transactionDate"===ee.key?"asc"===ee.dir?" â²":" â¼":""]}),(0,a.jsxs)("th",{onClick:()=>eC("description"),className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase cursor-pointer select-none",children:["Description","description"===ee.key?"asc"===ee.dir?" â²":" â¼":""]}),(0,a.jsxs)("th",{onClick:()=>eC("categoryName"),className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase cursor-pointer select-none",children:["Category","categoryName"===ee.key?"asc"===ee.dir?" â²":" â¼":""]}),h&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("th",{onClick:()=>eC("amount"),className:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase cursor-pointer select-none",children:["Amount","amount"===ee.key?"asc"===ee.dir?" â²":" â¼":""]}),(0,a.jsxs)("th",{onClick:()=>eC("balance"),className:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase cursor-pointer select-none",children:["Balance","balance"===ee.key?"asc"===ee.dir?" â²":" â¼":""]})]}),(0,a.jsx)("th",{className:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase",children:"Actions"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:ew.map(e=>(0,a.jsxs)("tr",{className:e.isArchived?"bg-gray-50":"",children:[(0,a.jsx)("td",{className:"px-2 py-3",children:!e.isArchived&&(0,a.jsx)("input",{type:"checkbox",checked:es.has(e.id),onChange:t=>{let s=new Set(es);t.target.checked?s.add(e.id):s.delete(e.id),ea(s)},className:"rounded border-gray-300","data-testid":"cust-tx-select-".concat(e.id)})}),(0,a.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-500",children:new Date(e.transactionDate).toLocaleDateString()}),(0,a.jsxs)("td",{className:"px-4 py-3 text-sm text-gray-900",children:[e.description,e.isArchived&&(0,a.jsx)("span",{className:"ml-2 text-xs text-gray-400",children:"(Archived)"})]}),(0,a.jsx)("td",{className:"px-4 py-3 text-sm text-gray-500",children:e.categoryName||"-"}),h&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-right font-medium ".concat(e.amount.amount<0?"text-red-600":"text-green-600"),children:eE(e.amount)}),(0,a.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-right text-gray-500",children:eE(e.balance)})]}),(0,a.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-right space-x-1",children:e.isArchived?(0,a.jsx)("button",{onClick:async()=>{let t=await c.KD.restoreCustomerTransaction(u,G,e.id);t.success?await eD():alert(t.error||"Failed to restore transaction")},className:"px-2 py-1 text-xs font-medium text-green-700 bg-green-50 rounded-md hover:bg-green-100","data-testid":"cust-tx-restore-".concat(e.id),children:"Restore"}):(0,a.jsx)("button",{onClick:async()=>{let t=h?" (".concat(eE(e.amount),")"):"";if(!confirm('Archive transaction "'.concat(e.description,'"').concat(t,"?\n\nThis hides the transaction from the customer's app but preserves the underlying row.")))return;let s=await c.KD.archiveCustomerTransaction(u,G,e.id);s.success?await eD():alert(s.error||"Failed to archive transaction")},className:"px-2 py-1 text-xs font-medium text-red-700 bg-red-50 rounded-md hover:bg-red-100","data-testid":"cust-tx-archive-".concat(e.id),children:"Delete"})})]},e.id))})]})}):(0,a.jsx)("p",{className:"text-gray-500 text-center py-8",children:"Select an account to view transactions"})]}),"login"===eo&&(0,a.jsx)("div",{children:0===M.length?(0,a.jsx)("p",{className:"text-gray-500 text-center py-8",children:"No login events found"}):(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"min-w-full divide-y divide-gray-200","data-testid":"customer-login-table",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Date/Time"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Platform"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Type"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Action"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:M.map((e,t)=>(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-500",children:eK(e.dateTime)}),(0,a.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-900",children:e.platform||"-"}),(0,a.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-900",children:e.type||"L
1ogin"}),(0,a.jsx)("td",{className:"px-4 py-3 text-sm text-gray-500",children:eB(e)})]},"".concat(e.dateTime,"-").concat(t)))})]})})}),"kyc"===eo&&u&&(0,a.jsx)(o,{customerId:u}),"income"===eo&&u&&em&&(0,a.jsx)(D,{customerId:u}),"integration-logs"===eo&&(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Select Date"}),(0,a.jsx)("select",{value:O,onChange:e=>z(e.target.value),className:"px-3 py-2 border border-gray-300 rounded-md",children:V.map(e=>(0,a.jsx)("option",{value:e,children:e},e))})]}),0===V.length?(0,a.jsx)("p",{className:"text-gray-500 text-center py-8",children:"No integration logs available"}):0===E.length?(0,a.jsx)("p",{className:"text-gray-500 text-center py-8",children:"No logs for selected date"}):(0,a.jsx)("div",{className:"space-y-2",children:E.map(e=>(0,a.jsxs)("div",{className:"p-3 rounded border text-sm ".concat("Error"===e.level?"bg-red-50 border-red-200":"Warning"===e.level?"bg-yellow-50 border-yellow-200":"bg-gray-50 border-gray-200"),children:[(0,a.jsxs)("div",{className:"flex justify-between items-start",children:[(0,a.jsx)("span",{className:"text-xs text-gray-500",children:eK(e.timestamp)}),(0,a.jsx)("span",{className:"text-xs px-2 py-0.5 rounded ".concat("Error"===e.level?"bg-red-100 text-red-700":"Warning"===e.level?"bg-yellow-100 text-yellow-700":"bg-gray-100 text-gray-700"),children:e.level})]}),(0,a.jsx)("p",{className:"mt-1 text-gray-900",children:e.message}),e.accountRefreshId&&(0,a.jsxs)("p",{className:"mt-1 text-xs text-gray-500",children:["Refresh ID: ",e.accountRefreshId]})]},e.id))})]}),"compliance"===eo&&u&&(0,a.jsx)(v,{customerId:u}),"staff-vip"===eo&&u&&(0,a.jsx)(C,{customerId:u,onStatusChange:e=>{e&&"None"!==e.status?ed(e):ed(null)}}),"fees-billing"===eo&&u&&(0,a.jsx)(R,{customerId:u}),"intelligence-report"===eo&&u&&eu&&(0,a.jsx)(g,{customerId:u}),"refresh-history"===eo&&u&&(0,a.jsx)(k.A,{customerId:u}),"audit-logs"===eo&&(0,a.jsx)("div",{children:0===P.length?(0,a.jsx)("p",{className:"text-gray-500 text-center py-8",children:"No audit logs found"}):(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Date/Time"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Type"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Action"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Message"}),(0,a.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Controller"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:P.map((e,t)=>(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-500",children:eK(e.dateTime)}),(0,a.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-900",children:e.logType}),(0,a.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-900",children:eP(e)?eB(e):e.action}),(0,a.jsx)("td",{className:"px-4 py-3 text-sm text-gray-500",children:eP(e)?eB(e):e.message}),(0,a.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-500",children:e.controller})]},t))})]})})})]})})]})]})})}},11345:(e,t,s)=>{"use strict";s.d(t,{c:()=>n});var a=s(14232),r=s(29498),l=s(83743);function n(){let[e,t]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let e=!1;return r.KD.getFeatureToggles().then(s=>{var a;if(e)return;let r=(null!=(a=s.data)?a:[]).find(e=>e.featureName===l.P);t(!!(null==r?void 0:r.isEnabled))}).catch(()=>{}),()=>{e=!0}},[]),e}},13125:(e,t,s)=>{"use strict";s.d(t,{A:()=>l});var a=s(37876);let r={Submitted:{dot:"#9AA3AD",label:"Documents submitted",who:()=>"by customer"},InfoRequested:{dot:"#F0C36D",label:"Info requested",who:e=>e?"by ".concat(e):""},IncomeProposed:{dot:"#01C38D",label:"Income proposed",who:e=>e?"by ".concat(e):""},CustomerReplied:{dot:"#6C7A8C",label:"Customer replied",who:()=>"by customer"},CustomerConfirmed:{dot:"#01875F",label:"Customer confirmed",who:()=>"by customer"},Rejected:{dot:"#B3261E",label:"Declined",who:e=>e?"by ".concat(e):""},Approved:{dot:"#01875F",label:"Approved",who:e=>e?"by ".concat(e):""}};function l(e){let{activity:t,rejectionHistory:s,className:l}=e,n=t&&t.length>0?t:(null!=s?s:[]).map(e=>({type:"Rejected",at:e.rejectedAt,actor:e.reviewedBy,message:e.reason,documentNames:e.documentNames}));return 0===n.length?null:(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-xl p-5 ".concat(null!=l?l:""),children:[(0,a.jsx)("div",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide mb-3",children:"Activity"}),(0,a.jsx)("div",{className:"space-y-3",children:n.map((e,t)=>{var s;let l,d=null!=(s=r[e.type])?s:{dot:"#9AA3AD",label:e.type,who:()=>""},i=d.who(e.actor);return(0,a.jsxs)("div",{className:"flex gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col items-center pt-1",children:[(0,a.jsx)("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:d.dot}}),t<n.length-1&&(0,a.jsx)("span",{className:"w-px flex-1 bg-gray-200 mt-1"})]}),(0,a.jsxs)("div",{className:"pb-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 text-xs text-gray-500",children:[(0,a.jsx)("span",{className:"font-semibold",style:{color:d.dot},children:d.label}),"number"==typeof e.amount&&e.amount>0&&(0,a.jsx)("span",{className:"font-medium text-gray-800",children:(l=e.amount,"R ".concat(Math.round(l).toLocaleStr
1ing("en-ZA")))}),(0,a.jsxs)("span",{children:["\xb7 ",new Date(e.at).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})]}),i&&(0,a.jsxs)("span",{children:["\xb7 ",i]})]}),e.message&&(0,a.jsxs)("div",{className:"text-sm text-gray-800 mt-0.5 break-words",children:["â",e.message,"â"]}),e.documentNames&&e.documentNames.length>0&&(0,a.jsx)("div",{className:"text-xs text-gray-400 mt-0.5 break-words",children:e.documentNames.join(", ")})]})]},t)})})]})}},24338:(e,t,s)=>{"use strict";s.d(t,{A:()=>d});var a=s(37876),r=s(14232),l=s(48230),n=s.n(l);function d(e){let{data:t,loading:s,currentPage:l,pageSize:d,onPageChange:i,showCustomerColumns:c=!1}=e,[o,x]=(0,r.useState)("transactionDate"),[u,m]=(0,r.useState)("desc"),p=e=>{o===e?m("asc"===u?"desc":"asc"):(x(e),m("asc"))},h=(0,r.useMemo)(()=>[...t].sort((e,t)=>{let s,a;switch(o){case"amount":s=e.amount,a=t.amount;break;case"transactionDate":s=e.transactionDate?new Date(e.transactionDate).getTime():0,a=t.transactionDate?new Date(t.transactionDate).getTime():0;break;case"customerName":s=e.customerName||"",a=t.customerName||"";break;default:s=0,a=0}return"string"==typeof s?"asc"===u?s.localeCompare(a):a.localeCompare(s):"asc"===u?s-a:a-s}),[t,o,u]),g=e=>{let{field:t}=e;return o!==t?(0,a.jsx)("span",{className:"text-gray-400 text-xs",children:"â"}):"asc"===u?(0,a.jsx)("span",{className:"text-blue-600 text-xs",children:"â"}):(0,a.jsx)("span",{className:"text-blue-600 text-xs",children:"â"})};return(0,a.jsxs)("div",{className:"bg-white rounded-lg shadow overflow-hidden",children:[s?(0,a.jsx)("div",{className:"p-6 text-center text-gray-500",children:"Loading revenue data..."}):0===t.length?(0,a.jsx)("div",{className:"p-6 text-center text-gray-500",children:"No revenue data found for this page."}):(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"No"}),c&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:(0,a.jsxs)("button",{onClick:()=>p("customerName"),className:"flex items-center gap-1 hover:text-gray-900",children:["Customer Name",(0,a.jsx)(g,{field:"customerName"})]})}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"Email"})]}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"Source"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"Source Type"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"Status"}),(0,a.jsx)("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-700 uppercase tracking-wider",children:(0,a.jsxs)("button",{onClick:()=>p("amount"),className:"flex items-center justify-end gap-1 hover:text-gray-900 w-full",children:["Amount",(0,a.jsx)(g,{field:"amount"})]})}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"Currency"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:(0,a.jsxs)("button",{onClick:()=>p("transactionDate"),className:"flex items-center gap-1 hover:text-gray-900",children:["Transaction Date",(0,a.jsx)(g,{field:"transactionDate"})]})})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:h.map((e,t)=>{var s,r;return(0,a.jsxs)("tr",{className:t%2==0?"bg-white":"bg-gray-50",children:[(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-600",children:(l-1)*d+t+1}),c&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900",children:e.customerId?(0,a.jsx)(n(),{href:"/admin/customers/".concat(e.customerId,"?tab=fees-billing"),className:"text-blue-600 hover:text-blue-800 hover:underline",children:e.customerName}):e.customerName}),(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-600",children:e.customerEmail})]}),(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-600",children:e.source}),(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-600",children:e.sourceType||"â"}),(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,a.jsx)("span",{className:"px-2 py-1 text-xs font-semibold rounded ".concat(function(e){let t=(null==e?void 0:e.toLowerCase())||"";return"completed"===t||"active"===t?"bg-green-100 text-green-800":"pending"===t?"bg-yellow-100 text-yellow-800":"failed"===t?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"}(e.status||"")),children:e.status||"â"})}),(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-semibold text-gray-900 text-right",children:(s=e.amount,r=e.currency,new Intl.NumberFormat("en-US",{style:"currency",currency:r||"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(s))}),(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-600",children:e.currency||"USD"}),(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-600",children:function(e){if(!e)return"â";try{return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(t){return e}}(e.transactionDate)})]},e.id)})})]})}),!s&&(0,a.jsxs)("div",{className:"bg-white px-6 py-3 flex items-center justify-between border-t border-gray-200",children:[(0,a.jsxs)("div",{className:"text-sm text-gray-500",children:["Page ",l," ⢠Showing ",h.length," items"]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{onClick:()=>i(Math.max(1,l-1)),disabled:1===l,className:"px-3 py-1 border border-gray-300 rounded text-sm disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50",children:"Previous"}),(0,a.jsxs)("span",{className:"px-3 py-1 text-sm",children:["Page ",l]}),(0,a.jsx)("button",{onClick:()=>i(l+1),disabled:h.length<d,className:"px-3 py-1 border border-gray-300 rounded text-sm disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50",children:"Next"})]})]})]})}},32295:(e,t,s)=>{"use strict";s.d(t,{$3:()=>i,GZ:()=>d,TM:()=>r,YD:()=>l,eV:()=>a,q_:()=>c,v9:()=>n});let a={TransactionalCommunication:"Transactional Communication",CustomerSupport:"Customer Support",RegulatoryReporting:"Regulatory Reporting",SecurityIncident:"Security Incident Response",FraudInvestigation:"Fraud Investigation",LegalDispute:"Legal / Dispute Resolution",Marketing:"Marketing"},r={TransactionalCommunication:0,CustomerSupport:1,RegulatoryReporting:2,SecurityIncident:3,FraudInvestigation:4,LegalDispute:5,Marketing:6};var l=function(e){return e[e.NoteAdded=0]="NoteAdded",e[e.DocumentsUploaded=1]="DocumentsUploaded",e[e.Approved=2]="Approved",e[e.Rejected=3]="Rejected",e}({}),n=function(e){return e[e.PendingReview=0]="PendingReview",e[e.ApprovedForInvestment=1]="ApprovedForInvestment",e[e.RejectedForInvestment=2]="RejectedForInvestment",e}({}),d=function(e){return e[e.General=0]="General",e[e.EDD=1]="EDD",e[e.DocumentReview=2]="DocumentReview",e[e.SanctionsCheck=3]="SanctionsCheck",e}({}),i=function(e){return e[e.Free=0]="Free",e[e.Basic=2]="Basic",e[e.Premium=3]="Premium",e}({});
1let c={LaunchTrialStartDate:"launchTrialStartDate",LaunchTrialExistingDays:"launchTrialExistingDays",LaunchTrialNewDays:"launchTrialNewDays"}},36654:(e,t,s)=>{"use strict";s.d(t,{BR:()=>i,D0:()=>n,D3:()=>l,Ev:()=>d,Fu:()=>r});var a=s(37876);function r(e){let{title:t,subtitle:s,source:r,testId:l,children:n}=e;return(0,a.jsxs)("div",{"data-testid":l,"data-pdf-keep-together":!0,className:"rounded-2xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 p-5 break-inside-avoid",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 mb-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-base font-semibold text-gray-900 dark:text-white",children:t}),s&&(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:s})]}),r&&(0,a.jsx)("span",{className:"shrink-0 text-[10px] uppercase tracking-wide text-gray-400 border border-gray-200 dark:border-gray-600 rounded-full px-2 py-0.5",children:r})]}),n]})}function l(e){let{label:t}=e;return(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-amber-700 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 rounded px-1.5 py-0.5",children:[(0,a.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400"}),t||"Not collected"]})}function n(e){let{label:t,value:s,notCollectedLabel:r,testId:n}=e,d=null==s||""===s||"â"===s;return(0,a.jsxs)("div",{"data-testid":n,children:[(0,a.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-0.5",children:t}),(0,a.jsx)("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:d?(0,a.jsx)(l,{label:r}):s})]})}function d(e){let{children:t,cols:s=2}=e;return(0,a.jsx)("div",{className:3===s?"grid grid-cols-1 sm:grid-cols-3 gap-x-6 gap-y-4":"grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-4",children:t})}function i(e){let{stats:t}=e;return(0,a.jsx)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-px bg-gray-200 dark:bg-gray-700 rounded-2xl overflow-hidden",children:t.map(e=>{var t;return(0,a.jsxs)("div",{"data-testid":"report-stat-".concat(e.label.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")),className:"bg-white dark:bg-gray-800 p-4 text-center",children:[(0,a.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e.label}),(0,a.jsx)("div",{className:"text-lg font-bold ".concat(null!=(t=e.tone)?t:"text-gray-900 dark:text-white"),children:e.value}),e.meta&&(0,a.jsx)("div",{className:"text-[11px] text-gray-400 mt-0.5",children:e.meta})]},e.label)})})}s(14232)},59233:(e,t,s)=>{"use strict";s.d(t,{V:()=>l});var a=s(90758);let r=/^[A-Z]{3}$/;function l(e,t,s,l){let n=t&&r.test(t)?t:r.test(s||"")?s:"USD";try{return(0,a.up)(e,n,!0,l)}catch(t){try{return(0,a.up)(e,"USD",!0,l)}catch(t){return null==e?"â":String(e)}}}},70595:(e,t,s)=>{"use strict";s.d(t,{A:()=>o});var a=s(37876);s(14232);var r=s(75049),l=s(79025),n=s(59233),d=s(36654);let i=new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"short",year:"numeric",timeZone:"UTC"});function c(e){let{policy:t,displayCurrency:s}=e;return(0,a.jsx)("div",{className:"space-y-0.5",children:(0,l.bK)(t).map((e,t)=>{var r;return(0,a.jsxs)("div",{children:[(0,a.jsxs)("span",{className:"text-gray-500 dark:text-gray-400",children:[e.label,": "]}),(0,a.jsx)("span",{className:"font-medium text-gray-900 dark:text-white",children:null!=(r=e.text)?r:(0,n.V)(e.amount,e.currencyCode,s)})]},"".concat(e.label,"-").concat(t))})})}function o(e){let{policies:t,displayCurrency:s,customerScopedDataAvailable:l=!0}=e;return(0,a.jsx)(d.Fu,{title:"Insurance Policy Schedule",subtitle:"Policies registered in Vault22",source:"Insurance register",children:null===t?(0,a.jsx)("p",{role:"status",className:"text-sm text-gray-500 dark:text-gray-400",children:l?"Registered policy data is currently unavailable.":"The policy register is unavailable in this admin report because customer-scoped insurance data was not supplied."}):0===t.length?(0,a.jsx)("p",{role:"status",className:"text-sm text-gray-500 dark:text-gray-400",children:"No insurance policies have been registered in Vault22."}):(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full min-w-[760px] text-sm",children:[(0,a.jsx)("caption",{className:"sr-only",children:"Registered insurance policies"}),(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-gray-100 text-left text-xs uppercase text-gray-400 dark:border-gray-700",children:[(0,a.jsx)("th",{className:"py-2 pr-4",children:"Type"}),(0,a.jsx)("th",{className:"py-2 pr-4",children:"Provider"}),(0,a.jsx)("th",{className:"py-2 pr-4",children:"Benefit or cover"}),(0,a.jsx)("th",{className:"py-2 pr-4 text-right",children:"Monthly premium"}),(0,a.jsx)("th",{className:"py-2 text-right",children:"Renewal"})]})}),(0,a.jsx)("tbody",{children:t.map(e=>{var t,l;return(0,a.jsxs)("tr",{className:"border-b border-gray-50 align-top last:border-0 dark:border-gray-700/50",children:[(0,a.jsx)("td",{className:"py-3 pr-4 font-medium text-gray-900 dark:text-white",children:null!=(l=r.tt[e.policyType])?l:"Other"}),(0,a.jsx)("td",{className:"py-3 pr-4 text-gray-700 dark:text-gray-200",children:(null==(t=e.provider)?void 0:t.trim())||"Not recorded"}),(0,a.jsx)("td",{className:"py-3 pr-4 text-gray-700 dark:text-gray-200",children:(0,a.jsx)(c,{policy:e,displayCurrency:s})}),(0,a.jsx)("td",{className:"py-3 pr-4 text-right font-medium text-gray-900 dark:text-white",children:Number.isFinite(e.monthlyPremium)?(0,n.V)(e.monthlyPremium,e.premiumCurrencyCode,s):"Not recorded"}),(0,a.jsx)("td",{className:"py-3 text-right text-gray-700 dark:text-gray-200",children:function(e){if(!e)return"Not recorded";let t=new Date(e);return Number.isNaN(t.getTime())?"Not recorded":i.format(t)}(e.renewalDate)})]},e.id)})})]})})})}},79207:(e,t,s)=>{"use strict";function a(e){var t;if("loading"===e.status)return null;if("failed"===e.status)return{tier:"unknown",label:"Tier unavailable",title:404===e.httpStatus?"The tier endpoint is not available on this environment â the backend is likely behind the frontend here. This is not a statement about the customer.":"Could not load this customer's tier".concat(e.httpStatus?" (HTTP ".concat(e.httpStatus,")"):"",". This is a panel problem, not a customer without a plan.")};let{tier:s,effectiveTier:a}=e.info;if(!a)return s?{tier:s,label:"Billing: ".concat(s),title:"Entitlement is unavailable, so this is the BILLING tier â what the customer is charged for. A customer on a trial is billed Free while holding Premium."}:{tier:"Free",label:"Free",title:"No subscription record on this customer, which counts as Free everywhere in core."};let r=null!=s&&a!==s,l=!0===e.info.trialingSubscription,n=null!=(t=e.info.launchTrialDaysRemaining)?t:0,d=r?e.
1info.isOnLaunchTrial&&n>0?" (trial, ".concat(n,"d)"):" (trial)":l?" (trial)":"",i=r?"Entitled to ".concat(a," â billed ").concat(null!=s?s:"Free").concat(e.info.isOnLaunchTrial?" (on the launch trial)":" (trialing subscription)","."):l?"Entitled to ".concat(a," on a trial â not charged yet; becomes a paid ").concat(a," when the first payment succeeds."):"Entitled to ".concat(a,", and billed for it.");return{tier:a,label:"".concat(a).concat(d),title:i}}function r(e){return e.effectiveTier||e.tier||"Free"}s.d(t,{C:()=>r,M:()=>a})},83743:(e,t,s)=>{"use strict";s.d(t,{P:()=>r,X:()=>l});var a=s(82980);let r="income_verification";function l(){return{enabled:(0,a.J)(e=>{var t,s;return(null!=(s=null==(t=e.featureToggles[r])?void 0:t.version)?s:0)>0}),loaded:(0,a.J)(e=>e.isLoaded)}}},85999:(e,t,s)=>{"use strict";async function a(e,t,a){var r;if(!e)return;let{default:l}=await s.e(2366).then(s.t.bind(s,43028,23)),{default:n}=await Promise.all([s.e(347),s.e(4155),s.e(140)]).then(s.bind(s,14312)),d=null!=(r=null==a?void 0:a.background)?r:"#ffffff",i=await l(e,{scale:1.5,useCORS:!0,logging:!1,backgroundColor:d}),c=new n({orientation:"portrait",unit:"mm",format:"a4",compress:!0}),o=c.internal.pageSize.getWidth(),x=c.internal.pageSize.getHeight(),u=o-16,m=e.getBoundingClientRect(),p=i.height/Math.max(1,e.scrollHeight),h=Array.from(e.querySelectorAll("[data-pdf-keep-together]")).map(t=>{let s=t.getBoundingClientRect(),a=s.top-m.top+e.scrollTop;return{top:a*p,bottom:(a+s.height)*p}}),g=function(e,t,s,a){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];if(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(s)||!Number.isFinite(a)||e<=0||t<=0||s<=0||a<=0)return[];let l=Math.max(1,Math.ceil(s*t/a)),n=r.map(t=>{let{top:s,bottom:a}=t;return{top:Math.max(0,Math.floor(s)),bottom:Math.min(e,Math.ceil(a))}}).filter(e=>{let{top:t,bottom:s}=e;return Number.isFinite(t)&&Number.isFinite(s)&&s>t}).sort((e,t)=>e.top-t.top),d=[],i=0;for(;i<e;){let t=Math.min(i+l,e);if(t<e){let e=Math.max(16,Math.floor(.1*l)),s=n.filter(e=>{let{top:s,bottom:a}=e;return s<t&&a>t}).map(e=>{let{top:t}=e;return t}).find(t=>t-i>=e);void 0!==s&&(t=s)}d.push({srcY:i,height:t-i}),i=t}let c=d[d.length-1];return d.length>1&&c.height<=2&&(d[d.length-2].height+=c.height,d.pop()),d}(i.height,i.width,x-16,u,h);if(!g.length)return;g.forEach((e,t)=>{t>0&&c.addPage();let s=document.createElement("canvas");s.width=i.width,s.height=e.height,s.getContext("2d").drawImage(i,0,e.srcY,i.width,e.height,0,0,i.width,e.height);let r=s.toDataURL("image/jpeg",.88),l=e.height*u/i.width;c.addImage(r,"JPEG",8,8,u,l,void 0,"FAST"),(null==a?void 0:a.footer)&&(c.setFontSize(7),c.setTextColor(156,163,175),c.text("".concat(a.footer," â page ").concat(t+1),o/2,x-4,{align:"center"}))});let y=t.endsWith(".pdf")?t:"".concat(t,".pdf");c.save(y)}s.d(t,{H:()=>a})},90630:(e,t,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/customers/[id]",function(){return s(9704)}])}},e=>{e.O(0,[7497,9025,2063,2604,4282,636,6593,8792],()=>e(e.s=90630)),_N_E=e.O()}]);
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.