@vpdev2/metakyc-sdk 1.0.43 → 1.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CreateApplicantForm.d.ts.map +1 -1
- package/dist/components/core/Select.d.ts +1 -1
- package/dist/components/core/Select.d.ts.map +1 -1
- package/dist/index.cjs +17 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1146 -1099
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
"use strict";var ar=Object.defineProperty;var nr=(t,r,s)=>r in t?ar(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s;var Q=(t,r,s)=>nr(t,typeof r!="symbol"?r+"":r,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ir=require("axios"),l=require("react"),e=require("react/jsx-runtime"),ke=require("react-hook-form"),ve=require("zod");function lr(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const a=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(r,s,a.get?a:{enumerable:!0,get:()=>t[s]})}}return r.default=t,Object.freeze(r)}const Ke=lr(l);var z=(t=>(t[t.IdentitySdk=0]="IdentitySdk",t[t.RiskScoring=1]="RiskScoring",t[t.Questionaries=2]="Questionaries",t[t.AdditionalData=3]="AdditionalData",t[t.AppropriatenessTest=4]="AppropriatenessTest",t[t.UploadDocument=5]="UploadDocument",t[t.ManualReview=6]="ManualReview",t[t.Overview=7]="Overview",t[t.InvestorCategorization=8]="InvestorCategorization",t))(z||{}),Re=(t=>(t[t.NotStarted=0]="NotStarted",t[t.InProgress=1]="InProgress",t[t.Success=2]="Success",t[t.PartialSuccess=3]="PartialSuccess",t[t.Failed=4]="Failed",t[t.Skipped=5]="Skipped",t[t.AdminReview=6]="AdminReview",t[t.SkippedAndAdminReview=7]="SkippedAndAdminReview",t))(Re||{}),me=(t=>(t[t.None=0]="None",t[t.InProgress=1]="InProgress",t[t.Finished=2]="Finished",t[t.OnHold=3]="OnHold",t[t.IdentityPending=4]="IdentityPending",t))(me||{}),He=(t=>(t[t.None=0]="None",t[t.RepresentativeKYC=1]="RepresentativeKYC",t[t.ManualRiskCriteria=2]="ManualRiskCriteria",t[t.UploadDocumentReview=3]="UploadDocumentReview",t[t.AdminReview=4]="AdminReview",t))(He||{}),We=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(We||{}),we=(t=>(t[t.None=0]="None",t[t.Pending=1]="Pending",t[t.Approved=2]="Approved",t[t.Rejected=3]="Rejected",t[t.ResendRequested=4]="ResendRequested",t[t.Unknown=5]="Unknown",t[t.InProgress=6]="InProgress",t))(we||{}),je=(t=>(t[t.Approved=0]="Approved",t[t.Reject=1]="Reject",t[t.UnderReview=2]="UnderReview",t[t.Closed=3]="Closed",t[t.AdminReview=4]="AdminReview",t[t.New=5]="New",t[t.InProgress=6]="InProgress",t))(je||{}),Ye=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(Ye||{}),Qe=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(Qe||{}),ue=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(ue||{}),Ve=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(Ve||{}),Ie=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(Ie||{}),Ge=(t=>(t[t.Image=0]="Image",t[t.Video=1]="Video",t[t.PDF=2]="PDF",t[t.OfficePDF=3]="OfficePDF",t[t.Custom=4]="Custom",t))(Ge||{}),Ze=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(Ze||{}),Je=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))(Je||{}),fe=(t=>(t[t.String=0]="String",t[t.Integer=1]="Integer",t[t.Decimal=2]="Decimal",t[t.Boolean=3]="Boolean",t[t.Date=4]="Date",t[t.Country=5]="Country",t[t.DigitOnly=6]="DigitOnly",t))(fe||{}),Xe=(t=>(t[t.Text=0]="Text",t[t.Radio=1]="Radio",t[t.Checkbox=2]="Checkbox",t[t.Dropdown=3]="Dropdown",t[t.Country=4]="Country",t))(Xe||{}),et=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))(et||{}),ce=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(ce||{}),tt=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(tt||{});const Fe={firstName:{label:"First Name",type:"text"},lastName:{label:"Last Name",type:"text"},email:{label:"Email",type:"email"},phonenumber:{label:"Phone Number",type:"tel"},dateOfBirth:{label:"Date of Birth",type:"date"},salutation:{label:"Salutation",type:"select"},title:{label:"Title",type:"text"},mobileCountryCode:{label:"Mobile Country Code",type:"text"},street:{label:"Street",type:"text"},streetNumber:{label:"Street Number",type:"text"},zip:{label:"ZIP / Postal Code",type:"text"},city:{label:"City",type:"text"},country:{label:"Country",type:"select"},nationality:{label:"Nationality",type:"select"},otherNationality:{label:"Other Nationalities",type:"multiselect"},countryOfBirth:{label:"Country of Birth",type:"select"},placeOfBirth:{label:"Place of Birth",type:"text"},taxCountry:{label:"Tax Country",type:"select"},taxNumber:{label:"Tax Number",type:"text"},defaultLanguage:{label:"Default Language",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"}},rt=["firstName","lastName","email","phonenumber","dateOfBirth"],ze=[{value:"EN",label:"English"},{value:"DE",label:"German"},{value:"FR",label:"French"},{value:"ES",label:"Spanish"},{value:"IT",label:"Italian"},{value:"PT",label:"Portuguese"},{value:"NL",label:"Dutch"},{value:"PL",label:"Polish"},{value:"RU",label:"Russian"},{value:"ZH",label:"Chinese"},{value:"JA",label:"Japanese"},{value:"AR",label:"Arabic"},{value:"TR",label:"Turkish"},{value:"SV",label:"Swedish"},{value:"DA",label:"Danish"},{value:"FI",label:"Finnish"},{value:"NO",label:"Norwegian"}];var ee=(t=>(t.Default="default",t.Corporate="corporate",t.Fintech="fintech",t.Healthcare="healthcare",t.Modern="modern",t.Minimal="minimal",t))(ee||{});const st={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class at{constructor(r){this.config=r}build(r,s){const a=`${r}.${s}`;if(this.config.customPaths&&this.config.customPaths[a])return this.config.customPaths[a];switch(this.config.pattern){case"host-controller":return`/api/${r}/${s}`;case"application-service":return`/services/app/${this.getServiceName(r)}/${s}`;case"custom":throw new Error(`Custom endpoint path not found for ${a}. Please provide it in customPaths.`);default:throw new Error(`Unknown endpoint pattern: ${this.config.pattern}`)}}getServiceName(r){return{Applicant:"MetaKYCVerification",Questionnaire:"MetaKYCVerification",UploadDocument:"MetaKYCVerification",AppropriatenessTest:"MetaKYCVerification",BaseInformation:"MetaKYCVerification"}[r]||r}}class xe extends Error{constructor(s,a,n,i,o){super(s);Q(this,"response");this.code=a,this.details=n,this.validationErrors=i,this.name="MetaKYCError",this.response=o,Object.setPrototypeOf(this,xe.prototype)}}class Ce{static handleApiError(r){return new xe(r.message||"An unknown error occurred",r.code,r.details||void 0,r.validationErrors||void 0)}static handleAxiosError(r){if(r.response){const s=r.response.data;return s&&s.error?new xe(s.error.message||"An unknown error occurred",s.error.code,s.error.details||void 0,s.error.validationErrors||void 0,r.response):s&&s.result&&s.result.message?new xe(s.result.message,r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response):new xe((s==null?void 0:s.message)||r.message||"Request failed",r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response)}else return r.request?new xe("No response from server",0,"The request was made but no response was received. Please check your network connection."):new xe(r.message||"An unexpected error occurred",0,r.toString())}static isMetaKYCError(r){return r instanceof xe}}class nt{constructor(r){Q(this,"axiosInstance");Q(this,"endpointBuilder");Q(this,"config");this.config={...st,...r},this.endpointBuilder=new at(this.config.endpoints),this.axiosInstance=ir.create({baseURL:this.config.baseUrl,timeout:this.config.timeout,headers:{"Content-Type":"application/json"}}),this.axiosInstance.interceptors.request.use(s=>(s.headers["Abp-TenantId"]=this.config.tenantId.toString(),s.headers.ApiKey=this.config.apiKey,s.headers["X-API-KEY"]=this.config.apiKey,this.config.locale&&(s.headers["Accept-Language"]=this.config.locale),s),s=>Promise.reject(s)),this.axiosInstance.interceptors.response.use(s=>s,async s=>{var n;const a=s.config;return((n=s.response)==null?void 0:n.status)>=500&&!a._retry&&(a._retry=!0,a._retryCount=(a._retryCount||0)+1,a._retryCount<(this.config.retries||3))?(await new Promise(i=>setTimeout(i,1e3*a._retryCount)),this.axiosInstance(a)):Promise.reject(s)})}buildEndpoint(r,s){return this.endpointBuilder.build(r,s)}async get(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.get(n,{params:a});return this.handleResponse(i)}catch(n){throw Ce.handleAxiosError(n)}}async post(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.post(n,a);return this.handleResponse(i)}catch(n){throw Ce.handleAxiosError(n)}}async put(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.put(n,a);return this.handleResponse(i)}catch(n){throw Ce.handleAxiosError(n)}}async delete(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.delete(n,{params:a});return this.handleResponse(i)}catch(n){throw Ce.handleAxiosError(n)}}handleResponse(r){const s=r.data;if(!s.success&&s.error)throw Ce.handleApiError(s.error);return s}getAxiosInstance(){return this.axiosInstance}}class it{constructor(r){this.httpClient=r}async createApplicant(r){return(await this.httpClient.post("Applicant","ApplicantRegistrationRequest",r)).result}async createCompanyApplicant(r){return(await this.httpClient.post("Applicant","ApplicantCompanyRegistrationRequest",r)).result}async duplicateApplicant(r){return(await this.httpClient.post("Applicant","DuplicateApplicantRegistrationRequest",r)).result}async getProgress(r){return(await this.httpClient.get("Applicant","GetApplicantProgress",{applicantId:r})).result}async getProgressStatus(r){return(await this.httpClient.get("Applicant","GetApplicantProgressStaus",{applicantId:r})).result}async getApplicantData(r){return(await this.httpClient.get("Applicant","GetApplicantData",{applicantId:r})).result}async getApplicantStatus(r){return(await this.httpClient.get("Applicant","GetApplicantStatus",{applicantId:r})).result}async stopProgress(r){await this.httpClient.get("Applicant","StopProgress",{applicantId:r})}async progressStepBack(r){await this.httpClient.get("Applicant","ProgressStepBack",{applicantId:r})}async setLanguage(r,s){await this.httpClient.post("Applicant","SetApplicantLng",{applicantId:r,language:s})}async activateApplicant(r){await this.httpClient.get("Applicant","ActivateApplicant",{applicantId:r})}async deleteApplicant(r){await this.httpClient.delete("Applicant","DeleteApplicant",{applicantId:r})}async checkApplicantExists(r){return(await this.httpClient.get("Applicant","CheckApplicantIfExists",{externalRefId:r})).result}}class lt{constructor(r){this.httpClient=r}async getQuestionnaire(r){return(await this.httpClient.get("Questionnaire","GetQuestionnaire",{applicantid:r})).result}async fillQuestionnaire(r){return(await this.httpClient.post("Applicant","FillQuestionnarie",r)).result}}class ot{constructor(r){this.httpClient=r}async getUploadDocument(r){return(await this.httpClient.get("UploadDocument","GetUploadDocument",{applicantid:r})).result}async fillUploadDocument(r){await this.httpClient.post("Applicant","FillUploadDocument",r)}async reviewUploadDocument(r){await this.httpClient.post("UploadDocument","ReviewUploadDocument",r)}}class ct{constructor(r){this.httpClient=r}async getAppropriatenessTest(r){return(await this.httpClient.get("AppropriatenessTest","GetAppropriatenessTest",{applicantid:r})).result}async fillAppropriatenessTest(r){return(await this.httpClient.post("Applicant","FillAppropriatenessTest",r)).result}}class dt{constructor(r){this.httpClient=r}async getOverviewData(r){return(await this.httpClient.get("Applicant","GetOverviewData",{ApplicantId:r})).result}async passOverview(r){await this.httpClient.get("Applicant","PassOverview",{applicantId:r})}}class ut{constructor(r){this.httpClient=r}async getRiskScoringPlan(){return(await this.httpClient.get("Applicant","GetRiskScoringPlanInfo")).result}async getRiskCriterias(r){return(await this.httpClient.get("Risk","GetCriterias",{applicantId:r})).result}async submitRiskScoring(r){return(await this.httpClient.post("Applicant","RiskScoringRequest",r)).result}}class mt{constructor(r){this.httpClient=r}async identityRequest(r){console.log("[IdentityService] Calling IdentityRequest with input:",r);const s=await this.httpClient.post("Applicant","IdentityRequest",r);return console.log("[IdentityService] IdentityRequest response:",s),s.result}async identityCompanyRequest(r){return(await this.httpClient.post("Applicant","IdentityCompanyRequest",r)).result}async restartIdentityRequest(r){const s={applicantId:r,restart:!0,redirectUrl:"",ttl:604800};return console.log("[IdentityService] Restarting identity with restart=true:",s),this.identityRequest(s)}async restartIdentityCompanyRequest(r){const s={applicantId:r,restart:!0,redirectUrl:"",ttl:604800};return this.identityCompanyRequest(s)}}class pt{constructor(r){this.httpClient=r}async getCountries(r,s,a){return(await this.httpClient.get("BaseInformation","GetAllCountries",{filter:r||"",lng:s||"en",type:a})).result}async getBranches(){return(await this.httpClient.get("BaseInformation","GetBranches")).result}async getLegalEntities(){return(await this.httpClient.get("BaseInformation","GetLegalEntities")).result}}class ht{constructor(r){this.httpClient=r}async setInvestorCategorization(r){return(await this.httpClient.post("Applicant","SetInvestorCategorization",r)).result}async getInvestorCategorization(r){return(await this.httpClient.get("Applicant","GetInvestorCategorisation",{applicantId:r})).result}}const ne={name:"Default",title:"KYC Verification",logo:{url:"",height:"40px",visible:!0},colors:{primary:"#2563eb",primaryHover:"#1d4ed8",primaryLight:"#dbeafe",primaryDark:"#1e40af",secondary:"#64748b",secondaryHover:"#475569",success:"#10b981",warning:"#f59e0b",danger:"#ef4444",info:"#3b82f6",background:"#ffffff",surface:"#f9fafb",border:"#e5e7eb",textPrimary:"#111827",textSecondary:"#6b7280",textMuted:"#9ca3af"},typography:{fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},spacing:{borderRadius:"0.5rem",cardPadding:"1.5rem",inputHeight:"2.5rem"},darkMode:{colors:{background:"#111827",surface:"#1f2937",border:"#374151",textPrimary:"#f9fafb",textSecondary:"#d1d5db",textMuted:"#9ca3af"}}},gt={name:"Corporate",logo:{url:"",height:"40px",visible:!0},colors:{primary:"#0052CC",primaryHover:"#0747A6",primaryLight:"#DEEBFF",primaryDark:"#0747A6",secondary:"#6B778C",secondaryHover:"#5E6C84",success:"#00875A",warning:"#FF991F",danger:"#DE350B",info:"#0065FF",background:"#ffffff",surface:"#F4F5F7",border:"#DFE1E6",textPrimary:"#172B4D",textSecondary:"#5E6C84",textMuted:"#97A0AF"},typography:{fontFamily:"system-ui, -apple-system, sans-serif"},spacing:{borderRadius:"0.25rem",cardPadding:"1.5rem",inputHeight:"2.5rem"}},xt={name:"Fintech",logo:{url:"",height:"36px",visible:!0},colors:{primary:"#00B386",primaryHover:"#009973",primaryLight:"#D1FAE5",primaryDark:"#047857",secondary:"#7C3AED",secondaryHover:"#6D28D9",success:"#10B981",warning:"#F59E0B",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#F9FAFB",border:"#E5E7EB",textPrimary:"#111827",textSecondary:"#6B7280",textMuted:"#9CA3AF"},typography:{fontFamily:"Montserrat, system-ui, sans-serif"},spacing:{borderRadius:"0.75rem",cardPadding:"2rem",inputHeight:"3rem"}},yt={name:"Healthcare",logo:{url:"",height:"44px",visible:!0},colors:{primary:"#06B6D4",primaryHover:"#0891B2",primaryLight:"#CFFAFE",primaryDark:"#0E7490",secondary:"#8B5CF6",secondaryHover:"#7C3AED",success:"#059669",warning:"#D97706",danger:"#DC2626",info:"#0284C7",background:"#ffffff",surface:"#F0F9FF",border:"#E0F2FE",textPrimary:"#0F172A",textSecondary:"#475569",textMuted:"#94A3B8"},typography:{fontFamily:"Lato, system-ui, sans-serif"},spacing:{borderRadius:"0.5rem",cardPadding:"1.75rem",inputHeight:"2.75rem"},darkMode:{colors:{background:"#0F172A",surface:"#1E293B",border:"#334155",textPrimary:"#F1F5F9",textSecondary:"#CBD5E1"}}},ft={name:"Modern",logo:{url:"",height:"38px",visible:!0},colors:{primary:"#8B5CF6",primaryHover:"#7C3AED",primaryLight:"#EDE9FE",primaryDark:"#6D28D9",secondary:"#EC4899",secondaryHover:"#DB2777",success:"#10B981",warning:"#F59E0B",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#FAFAFA",border:"#E5E5E5",textPrimary:"#171717",textSecondary:"#737373",textMuted:"#A3A3A3"},typography:{fontFamily:"Poppins, system-ui, sans-serif"},spacing:{borderRadius:"1rem",cardPadding:"2rem",inputHeight:"3rem"}},bt={name:"Minimal",logo:{url:"",height:"32px",visible:!0},colors:{primary:"#000000",primaryHover:"#18181B",primaryLight:"#F4F4F5",primaryDark:"#000000",secondary:"#71717A",secondaryHover:"#52525B",success:"#22C55E",warning:"#EAB308",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#FAFAFA",border:"#E4E4E7",textPrimary:"#09090B",textSecondary:"#71717A",textMuted:"#A1A1AA"},typography:{fontFamily:"system-ui, -apple-system, sans-serif"},spacing:{borderRadius:"0.25rem",cardPadding:"1.25rem",inputHeight:"2.25rem"}},vt={[ee.Default]:ne,[ee.Corporate]:gt,[ee.Fintech]:xt,[ee.Healthcare]:yt,[ee.Modern]:ft,[ee.Minimal]:bt};function Ae(t){return vt[t]||ne}class kt{constructor(r){this.httpClient=r}async getThemeConfiguration(){var r;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return Ae(ee.Default);let a=s.result.preset?Ae(s.result.preset):Ae(ee.Default);if(s.result.title&&(a.title=s.result.title),s.result.logo&&(a.logo={...a.logo,...s.result.logo}),s.result.colors&&(a.colors={...a.colors,...s.result.colors}),s.result.typography&&(a.typography={...a.typography,...s.result.typography}),s.result.spacing&&(a.spacing={...a.spacing,...s.result.spacing}),s.result.customCSS&&(a.customCSS=s.result.customCSS),s.result.darkMode&&(a.darkMode={colors:{...(r=a.darkMode)==null?void 0:r.colors,...s.result.darkMode.colors}}),s.result.applicantFormVisibleFields&&s.result.applicantFormVisibleFields.length>0&&(a.applicantFormVisibleFields=s.result.applicantFormVisibleFields),s.result.applicantFormRequiredFields&&s.result.applicantFormRequiredFields.length>0&&(a.applicantFormRequiredFields=s.result.applicantFormRequiredFields),s.result.allowedLanguages&&s.result.allowedLanguages.length>0&&(a.allowedLanguages=s.result.allowedLanguages),s.result.applicantFormPages)try{const n=typeof s.result.applicantFormPages=="string"?JSON.parse(s.result.applicantFormPages):s.result.applicantFormPages;Array.isArray(n)&&n.length>0&&(a.applicantFormPages=n)}catch{}return a}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),Ae(ee.Default)}}async saveThemeConfiguration(r){await this.httpClient.post("Tenant","SaveThemeConfiguration",r)}getAvailablePresets(){return[{id:ee.Default,name:"Default"},{id:ee.Corporate,name:"Corporate"},{id:ee.Fintech,name:"Fintech"},{id:ee.Healthcare,name:"Healthcare"},{id:ee.Modern,name:"Modern"},{id:ee.Minimal,name:"Minimal"}]}getPreviewTheme(r,s){const a=Ae(r);return s?{...a,...s,logo:{...a.logo,...s.logo},colors:{...a.colors,...s.colors},typography:s.typography?{...a.typography,...s.typography}:a.typography,spacing:s.spacing?{...a.spacing,...s.spacing}:a.spacing}:a}}class wt{constructor(){Q(this,"listeners",new Map)}on(r,s){return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(s),()=>{this.off(r,s)}}off(r,s){const a=this.listeners.get(r);a&&a.delete(s)}emit(r,s){const a=this.listeners.get(r);a&&a.forEach(n=>{try{n(s)}catch(i){console.error(`Error in event listener for "${r}":`,i)}})}clear(){this.listeners.clear()}clearEvent(r){this.listeners.delete(r)}}class jt{constructor(){Q(this,"events",new wt);Q(this,"_applicantId",null);Q(this,"_progress",null);Q(this,"_error",null)}get applicantId(){return this._applicantId}get progress(){return this._progress}get currentStep(){var r;return((r=this._progress)==null?void 0:r.currentStep)||null}get steps(){var r;return((r=this._progress)==null?void 0:r.stepInfoList)||[]}get status(){var r;return((r=this._progress)==null?void 0:r.status)||me.None}get workflowResult(){var r;return((r=this._progress)==null?void 0:r.workflowResult)||null}get error(){return this._error}get isComplete(){return this.status===me.Finished}get isOnHold(){return this.status===me.OnHold}get isInProgress(){return this.status===me.InProgress}setApplicantId(r){this._applicantId=r}updateProgress(r){var a,n;const s=(a=this._progress)==null?void 0:a.currentStep;this._progress=r,this._applicantId=r.applicantId,this._error=null,this.events.emit("progressUpdated",r),(s==null?void 0:s.order)!==((n=r.currentStep)==null?void 0:n.order)&&this.events.emit("stepChanged",r.currentStep),this.events.emit("statusChanged",r.status),r.status===me.Finished&&r.workflowResult&&this.events.emit("completed",r.workflowResult)}setError(r){this._error=r,this.events.emit("error",r)}clearError(){this._error=null}reset(){this._applicantId=null,this._progress=null,this._error=null}onProgressUpdated(r){return this.events.on("progressUpdated",r)}onStepChanged(r){return this.events.on("stepChanged",r)}onStatusChanged(r){return this.events.on("statusChanged",r)}onError(r){return this.events.on("error",r)}onCompleted(r){return this.events.on("completed",r)}clearListeners(){this.events.clear()}}class Nt{constructor(){Q(this,"handlers",new Map)}registerHandler(r,s){this.handlers.set(r,s)}getHandler(r){return this.handlers.get(r)}hasHandler(r){return this.handlers.has(r)}async loadStepData(r,s){const a=this.getHandler(r);if(!a)throw new Error(`No handler registered for step action: ${z[r]}`);return a.loadData(s)}async submitStepData(r,s){const a=this.getHandler(r);if(!a)throw new Error(`No handler registered for step action: ${z[r]}`);return a.submitData(s)}}class St{constructor(r,s,a,n,i,o,c,d){Q(this,"state");Q(this,"stepRouter");this.applicantService=r,this.questionnaireService=s,this.uploadDocumentService=a,this.appropriatenessTestService=n,this.overviewService=i,this.riskScoringService=o,this.investorCategorizationService=d,this.state=new jt,this.stepRouter=new Nt,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(z.Questionaries,{loadData:r=>this.questionnaireService.getQuestionnaire(r),submitData:async r=>{await this.questionnaireService.fillQuestionnaire(r)}}),this.stepRouter.registerHandler(z.UploadDocument,{loadData:r=>this.uploadDocumentService.getUploadDocument(r),submitData:r=>this.uploadDocumentService.fillUploadDocument(r)}),this.stepRouter.registerHandler(z.AppropriatenessTest,{loadData:r=>this.appropriatenessTestService.getAppropriatenessTest(r),submitData:async r=>{await this.appropriatenessTestService.fillAppropriatenessTest(r)}}),this.stepRouter.registerHandler(z.Overview,{loadData:r=>this.overviewService.getOverviewData(r),submitData:r=>this.overviewService.passOverview(r.applicantId)}),this.stepRouter.registerHandler(z.RiskScoring,{loadData:r=>this.riskScoringService.getRiskCriterias(r),submitData:async r=>{await this.riskScoringService.submitRiskScoring(r)}}),this.stepRouter.registerHandler(z.IdentitySdk,{loadData:async r=>({applicantId:r,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(z.InvestorCategorization,{loadData:r=>this.investorCategorizationService.getInvestorCategorization(r),submitData:async r=>{await this.investorCategorizationService.setInvestorCategorization(r)}}),this.stepRouter.registerHandler(z.ManualReview,{loadData:async r=>({applicantId:r,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(z.AdditionalData,{loadData:async r=>({applicantId:r,message:"Additional data required"}),submitData:async()=>{}})}async initialize(r){try{this.state.setApplicantId(r);const s=await this.applicantService.getProgress(r);return this.state.updateProgress(s),s}catch(s){throw this.state.setError(s),s}}async refreshProgress(){if(!this.state.applicantId)throw new Error("Workflow not initialized. Call initialize() first.");try{const r=await this.applicantService.getProgress(this.state.applicantId);return this.state.updateProgress(r),r}catch(r){throw this.state.setError(r),r}}async getCurrentStepData(){if(!this.state.currentStep)throw new Error("No current step available");if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.stepRouter.loadStepData(this.state.currentStep.action,this.state.applicantId)}catch(r){throw this.state.setError(r),r}}async submitCurrentStep(r){if(!this.state.currentStep)throw new Error("No current step available");try{await this.stepRouter.submitStepData(this.state.currentStep.action,r),await this.refreshProgress()}catch(s){throw this.state.setError(s),s}}async moveToNextStep(){return this.refreshProgress()}async moveToPreviousStep(){if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.applicantService.progressStepBack(this.state.applicantId),await this.refreshProgress()}catch(r){throw this.state.setError(r),r}}getState(){return this.state}getStepRouter(){return this.stepRouter}}function $e(t,r){return new Promise((s,a)=>{if(r&&document.getElementById(r)){s();return}const n=document.createElement("script");n.src=t,r&&(n.id=r),n.async=!0,n.onload=()=>s(),n.onerror=()=>a(new Error(`Failed to load script: ${t}`)),document.head.appendChild(n)})}function or(t){return!!document.getElementById(t)}function cr(t){const r=document.getElementById(t);r&&r.remove()}class Ct{constructor(r){Q(this,"sdk",null);Q(this,"config");this.config=r}async loadSDK(){await $e("https://cdn.sumsub.com/websdk/v2/production/websdk.js","sumsub-sdk")}async initialize(r){if(window.snsWebSdk||await this.loadSDK(),!window.snsWebSdk)throw new Error("Sumsub SDK failed to load");this.sdk=window.snsWebSdk.init(this.config.accessToken,()=>this.config.accessToken).withConf({lang:this.config.lang||"en",email:this.config.applicantEmail,phone:this.config.applicantPhone,i18n:{}}).on("idCheck.onStepCompleted",s=>{console.log("Sumsub step completed:",s)}).on("idCheck.onError",s=>{console.error("Sumsub error:",s)}).build(),this.sdk.launch(`#${r}`)}destroy(){this.sdk&&(this.sdk.destroy(),this.sdk=null)}onComplete(r){this.sdk&&this.sdk.on("idCheck.applicantStatus",s=>{s.applicantStatus==="completed"&&r(s)})}onError(r){this.sdk&&this.sdk.on("idCheck.onError",r)}}class At{constructor(r){Q(this,"sdk",null);Q(this,"config");this.config=r}async loadSDK(){await $e("https://sdk.onfido.com/v12.0.0/onfido.min.js","onfido-sdk")}async initialize(r){if(window.Onfido||await this.loadSDK(),!window.Onfido)throw new Error("Onfido SDK failed to load");this.sdk=window.Onfido.init({token:this.config.token,containerId:r,steps:this.config.steps||[{type:"welcome",options:{title:"Identity Verification"}},{type:"document",options:{documentTypes:{passport:!0,driving_licence:!0,national_identity_card:!0}}},{type:"face",options:{requestedVariant:"standard"}},{type:"complete"}],onComplete:()=>{this.config.onComplete&&this.config.onComplete()},onError:s=>{this.config.onError&&this.config.onError(s)}})}destroy(){this.sdk&&(this.sdk.tearDown(),this.sdk=null)}}class Et{constructor(r){Q(this,"sardineContext",null);Q(this,"config");Q(this,"sessionKey");this.config=r,this.sessionKey=r.sessionKey||this.generateSessionKey()}generateSessionKey(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){const s=Math.random()*16|0;return(r==="x"?s:s&3|8).toString(16)})}getSardineHost(){const{environment:r,region:s}=this.config;if(r==="sandbox")return"api.sandbox.sardine.ai";switch(s){case"eu":return"api.eu.sardine.ai";case"ca":return"api.ca.sardine.ai";case"au":return"api.au.sardine.ai";default:return"api.sardine.ai"}}async loadSDK(){return new Promise((r,s)=>{if(window._Sardine){r();return}const a=this.getSardineHost(),n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=`https://${a}/assets/loader.min.js`,n.onload=()=>{console.log("[SardinAI] SDK loaded successfully"),r()},n.onerror=()=>{s(new Error("Failed to load SardinAI SDK"))};const i=document.getElementsByTagName("script")[0];i&&i.parentNode?i.parentNode.insertBefore(n,i):document.head.appendChild(n)})}async initialize(){try{if(await this.loadSDK(),!window._Sardine)throw new Error("SardinAI SDK not available after loading");const r=this.getSardineHost(),{clientId:s,environment:a,flow:n,enableBiometrics:i,enablePortScanning:o}=this.config;this.sardineContext=window._Sardine.createContext({clientId:s,sessionKey:this.sessionKey,userIdHash:void 0,flow:n||window.location.pathname,environment:a||"production",parentElement:document.body,enableBiometrics:i!==!1,enablePortScanning:o===!0,region:this.config.region,onDeviceResponse:c=>{console.log(`[SardinAI] Device ID: ${c.deviceId}`)},onConfigUpdate:(c,d,m)=>{switch(c){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",m);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",d);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",c)}}}),this.addNoScriptFallback(r),console.log("[SardinAI] SDK initialized with sessionKey:",this.sessionKey)}catch(r){throw console.error("[SardinAI] Initialization failed:",r),r}}addNoScriptFallback(r){const s=document.createElement("noscript"),a=document.createElement("img"),{clientId:n,flow:i}=this.config;a.src=`https://${r}/v1/a.png?clientId=${n}&sessionKey=${this.sessionKey}&flow=${i||"kyc"}&ns=1`,a.style.display="none",s.appendChild(a),document.body.appendChild(s)}updateConfig(r){if(!this.sardineContext){console.warn("[SardinAI] Cannot update config - SDK not initialized");return}r.sessionKey&&(this.sessionKey=r.sessionKey),this.sardineContext.updateConfig({...r,onConfigUpdate:(s,a,n)=>{switch(s){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Config update failed:",n);break;case"SESSION_UPDATED":console.log("[SardinAI] Config updated:",a);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No config update needed");break}}})}getSessionKey(){return this.sessionKey}destroy(){this.sardineContext&&(this.sardineContext=null)}}class Ne{static createProvider(r,s){switch(r){case ue.Sumsub:return new Ct(s);case ue.Onfido:return new At(s);case ue.SardinAI:return new Et(s);default:throw new Error(`Unsupported identity provider: ${r}`)}}static parseProviderConfig(r,s,a){var n;switch(r){case ue.Sumsub:return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:s.lang||"en"};case ue.Onfido:return{token:s.token||s.sdkToken};case ue.SardinAI:const i=((n=a==null?void 0:a.identityProviders)==null?void 0:n.sardinai)||{};return{clientId:i.clientId||s.clientId,sessionKey:i.sessionKey||s.sessionKey,environment:i.environment||s.environment||"production",flow:i.flow||s.flow,region:i.region,enableBiometrics:i.enableBiometrics,enablePortScanning:i.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${r}`)}}}class Rt{constructor(r){Q(this,"currentTheme",ne);Q(this,"customStyleElement",null);Q(this,"container");this.container=r||document.documentElement}applyTheme(r){this.currentTheme=this.mergeWithDefault(r),this.applyColors(this.currentTheme.colors),this.currentTheme.typography&&this.applyTypography(this.currentTheme.typography),this.currentTheme.spacing&&this.applySpacing(this.currentTheme.spacing),this.currentTheme.customCSS&&this.injectCustomCSS(this.currentTheme.customCSS),console.log("[ThemeManager] Theme applied:",this.currentTheme.name||"Custom")}applyColors(r){var a;const s={primary:r.primary,"primary-hover":r.primaryHover,"primary-light":r.primaryLight,"primary-dark":r.primaryDark,secondary:r.secondary,"secondary-hover":r.secondaryHover,success:r.success,warning:r.warning,danger:r.danger,info:r.info,background:r.background,surface:r.surface,border:r.border,"text-primary":r.textPrimary,"text-secondary":r.textSecondary,"text-muted":r.textMuted};Object.entries(s).forEach(([n,i])=>{this.container.style.setProperty(`--metakyc-${n}`,i)}),(a=this.currentTheme.darkMode)!=null&&a.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(r){Object.entries(r).forEach(([s,a])=>{if(a){const n=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)}})}applyTypography(r){r&&(r.fontFamily&&this.container.style.setProperty("--metakyc-font-family",r.fontFamily),r.headingFont&&this.container.style.setProperty("--metakyc-heading-font",r.headingFont),r.fontSize&&Object.entries(r.fontSize).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-size-${s}`,a)}),r.fontWeight&&Object.entries(r.fontWeight).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-weight-${s}`,a.toString())}))}applySpacing(r){r&&Object.entries(r).forEach(([s,a])=>{const n=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)})}injectCustomCSS(r){this.customStyleElement&&this.customStyleElement.remove(),this.customStyleElement=document.createElement("style"),this.customStyleElement.id="metakyc-custom-css",this.customStyleElement.textContent=r,document.head.appendChild(this.customStyleElement)}mergeWithDefault(r){var s;return{name:r.name||ne.name,title:r.title||ne.title,logo:{...ne.logo,...r.logo},colors:{...ne.colors,...r.colors},typography:r.typography?{...ne.typography,...r.typography}:ne.typography,spacing:r.spacing?{...ne.spacing,...r.spacing}:ne.spacing,customCSS:r.customCSS,darkMode:r.darkMode?{colors:{...(s=ne.darkMode)==null?void 0:s.colors,...r.darkMode.colors}}:ne.darkMode,applicantFormVisibleFields:r.applicantFormVisibleFields,applicantFormRequiredFields:r.applicantFormRequiredFields,allowedLanguages:r.allowedLanguages,applicantFormPages:r.applicantFormPages}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(ne)}cleanup(){this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(r){return r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const Ue=l.createContext(null),dr=({config:t,children:r})=>{const[s,a]=l.useState(null),n=l.useRef(!1),i=l.useRef(!1),o=l.useMemo(()=>{const d=new nt(t),m=new it(d),v=new lt(d),w=new ot(d),x=new ct(d),h=new dt(d),g=new ut(d),k=new mt(d),f=new pt(d),p=new ht(d),R=new kt(d),N=new Rt;return{httpClient:d,applicantService:m,questionnaireService:v,uploadDocumentService:w,appropriatenessTestService:x,overviewService:h,riskScoringService:g,identityService:k,baseInformationService:f,investorCategorizationService:p,themeService:R,themeManager:N}},[t]),c=l.useMemo(()=>({config:t,...o,currentTheme:s,createOrchestrator:()=>new St(o.applicantService,o.questionnaireService,o.uploadDocumentService,o.appropriatenessTestService,o.overviewService,o.riskScoringService,o.identityService,o.investorCategorizationService)}),[t,o,s]);return l.useEffect(()=>((async()=>{if(n.current||i.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}n.current=!0;try{if(t.theme){console.log("[MetaKYC] Applying static theme from config"),o.themeManager.applyTheme(t.theme),a(o.themeManager.getCurrentTheme()),i.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const m=await o.themeService.getThemeConfiguration();o.themeManager.applyTheme(m),a(o.themeManager.getCurrentTheme()),i.current=!0,console.log("[MetaKYC] Theme loaded and applied",m)}catch(m){console.warn("[MetaKYC] Failed to load theme, using default:",m),a(o.themeManager.getCurrentTheme()),i.current=!0}finally{n.current=!1}})(),()=>{o.themeManager.cleanup()}),[]),e.jsx(Ue.Provider,{value:c,children:r})};function de(){const t=l.useContext(Ue);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function It(t){return new Promise((r,s)=>{const a=new FileReader;a.readAsDataURL(t),a.onload=()=>{const i=a.result.split(",")[1];r(i)},a.onerror=n=>s(n)})}function ur(t,r){return t.size<=r}function mr(t,r){return r.split(",").map(a=>a.trim()).some(a=>{if(a.endsWith("/*")){const n=a.slice(0,-2);return t.type.startsWith(n)}return t.type===a})}function Pe(t){if(t===0)return"0 Bytes";const r=1024,s=["Bytes","KB","MB","GB"],a=Math.floor(Math.log(t)/Math.log(r));return Math.round(t/Math.pow(r,a)*100)/100+" "+s[a]}function pr(t){return t}function te(...t){return t.filter(Boolean).join(" ")}const Ee={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function Dt(t){try{localStorage.setItem(Ee.APPLICANT_ID,t.toString())}catch(r){console.warn("Failed to save applicant ID to storage:",r)}}function Ft(){try{const t=localStorage.getItem(Ee.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function Pt(){try{localStorage.removeItem(Ee.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function Lt(t){try{localStorage.setItem(Ee.WORKFLOW_STATE,JSON.stringify(t))}catch(r){console.warn("Failed to save workflow state to storage:",r)}}function hr(){try{const t=localStorage.getItem(Ee.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function Tt(){try{localStorage.removeItem(Ee.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function gr(){Pt(),Tt()}function Mt(t){const{createOrchestrator:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(null),d=l.useRef(null),m=t||Ft();l.useEffect(()=>{d.current||(d.current=r())},[r]),l.useEffect(()=>{var N;s&&m&&(Dt(m),Lt({applicantId:m,currentStepOrder:(N=s.currentStep)==null?void 0:N.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,m]);const v=l.useRef(!1),w=l.useRef(!1),x=l.useCallback(async()=>{if(!(!m||!d.current)){if(v.current){console.log("[Workflow] Load already in progress, skipping...");return}v.current=!0,i(!0),c(null);try{const N=await d.current.initialize(m);a(N),w.current=!0}catch(N){c(N)}finally{i(!1),v.current=!1}}},[m]);l.useEffect(()=>{m&&!w.current&&x()},[m,x]);const h=l.useCallback(async()=>{if(d.current){if(v.current){console.log("[Workflow] Refresh already in progress, skipping...");return}v.current=!0,i(!0),c(null);try{const N=await d.current.refreshProgress();a(N)}catch(N){c(N)}finally{i(!1),v.current=!1}}},[]),g=l.useCallback(async()=>{if(d.current){i(!0),c(null);try{const N=await d.current.moveToNextStep();a(N)}catch(N){c(N)}finally{i(!1)}}},[]),k=l.useCallback(async()=>{if(d.current){i(!0),c(null);try{const N=await d.current.moveToPreviousStep();a(N)}catch(N){c(N)}finally{i(!1)}}},[]),f=l.useCallback(async N=>{if(d.current){i(!0),c(null);try{await d.current.submitCurrentStep(N);const b=await d.current.refreshProgress();a(b)}catch(b){throw c(b),b}finally{i(!1)}}},[]),p=Ke.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((N,b)=>N.order-b.order):[],[s==null?void 0:s.stepInfoList]),R=Ke.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:m,currentStep:(s==null?void 0:s.currentStep)||null,steps:p,status:(s==null?void 0:s.status)||me.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:R,isLoading:n,error:o,isComplete:(s==null?void 0:s.status)===me.Finished,isOnHold:(s==null?void 0:s.status)===me.OnHold,refreshProgress:h,moveToNext:g,moveBack:k,submitCurrentStep:f,orchestrator:d.current}}function Ot(t){const{questionnaireService:r,applicantService:s}=de(),[a,n]=l.useState(null),[i,o]=l.useState({}),[c,d]=l.useState(!1),[m,v]=l.useState(!1),[w,x]=l.useState(null),h=l.useRef(!1),g=l.useRef(null),k=l.useCallback(async()=>{var p,R;if(t){if(h.current){console.log("[Questionnaire] Load already in progress, skipping...");return}h.current=!0,d(!0),x(null);try{const[N,b]=await Promise.all([r.getQuestionnaire(t),s.getApplicantData(t).catch(()=>null)]);if(n(N),(p=b==null?void 0:b.questionnaireResults)!=null&&p.length&&N){const _=new Map;for(const y of b.questionnaireResults)y.question&&((R=y.answers)!=null&&R.length)&&_.set(y.question.trim().toLowerCase(),y.answers);const W={},P=N.questionGroups.flatMap(y=>y.questions??[]);for(const y of P){const S=y.text.trim().toLowerCase();_.has(S)&&(W[y.id]=_.get(S))}o(W)}g.current=t}catch(N){x(N)}finally{d(!1),h.current=!1}}},[t,r,s]);l.useEffect(()=>{t&&g.current!==t&&k()},[t]);const f=l.useCallback(async p=>{v(!0),x(null);try{return await r.fillQuestionnaire(p)}catch(R){throw x(R),R}finally{v(!1)}},[r]);return{questionnaire:a,initialAnswers:i,isLoading:c,isSubmitting:m,error:w,load:k,submit:f}}function zt(t){const{uploadDocumentService:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(!1),[d,m]=l.useState(0),[v,w]=l.useState(null),x=l.useRef(!1),h=l.useRef(null),g=l.useCallback(async()=>{if(t){if(x.current){console.log("[UploadDocument] Load already in progress, skipping...");return}x.current=!0,i(!0),w(null);try{const f=await r.getUploadDocument(t);a(f),h.current=t}catch(f){w(f)}finally{i(!1),x.current=!1}}},[t,r]);l.useEffect(()=>{t&&h.current!==t&&g()},[t]);const k=l.useCallback(async f=>{c(!0),m(0),w(null);try{await r.fillUploadDocument(f),m(100)}catch(p){throw w(p),p}finally{c(!1)}},[r]);return{uploadDocument:s,isLoading:n,isSubmitting:o,uploadProgress:d,error:v,load:g,submit:k}}function xr(t){const{appropriatenessTestService:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(!1),[d,m]=l.useState(null),[v,w]=l.useState(null),x=l.useRef(!1),h=l.useRef(null),g=l.useCallback(async()=>{if(t){if(x.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}x.current=!0,i(!0),m(null);try{const f=await r.getAppropriatenessTest(t);a(f),h.current=t}catch(f){m(f)}finally{i(!1),x.current=!1}}},[t,r]);l.useEffect(()=>{t&&h.current!==t&&g()},[t]);const k=l.useCallback(async f=>{c(!0),m(null);try{const p=await r.fillAppropriatenessTest(f);return w(p),p}catch(p){throw m(p),p}finally{c(!1)}},[r]);return{test:s,result:v,isLoading:n,isSubmitting:o,error:d,load:g,submit:k}}function Bt(t){const{overviewService:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(!1),[d,m]=l.useState(null),v=l.useRef(!1),w=l.useRef(null),x=l.useCallback(async()=>{if(t){if(v.current){console.log("[Overview] Load already in progress, skipping...");return}v.current=!0,i(!0),m(null);try{const g=await r.getOverviewData(t);a(g),w.current=t}catch(g){m(g)}finally{i(!1),v.current=!1}}},[t,r]);l.useEffect(()=>{t&&w.current!==t&&x()},[t]);const h=l.useCallback(async()=>{if(t){c(!0),m(null);try{await r.passOverview(t)}catch(g){throw m(g),g}finally{c(!1)}}},[t,r]);return{overview:s,isLoading:n,isSubmitting:o,error:d,load:x,passOverview:h}}function $t(t){const{identityService:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(null),d=l.useRef(!1),m=l.useCallback(async(x,h)=>{if(t){if(d.current){console.log("[Identity] Request already in progress, skipping...");return}d.current=!0,i(!0),c(null);try{const g={applicantId:t,restart:!1,redirectUrl:x||"",ttl:h||604800};console.log("Identity request input:",g);const k=await r.identityRequest(g);return console.log("Identity request result:",k),a(k),k}catch(g){throw c(g),g}finally{i(!1),d.current=!1}}},[t,r]),v=l.useCallback(async(x,h)=>{if(t){i(!0),c(null);try{const g={applicantId:t,restart:!1,redirectUrl:x,ttl:h},k=await r.identityCompanyRequest(g);return a(k),k}catch(g){throw c(g),g}finally{i(!1)}}},[t,r]),w=l.useCallback(async()=>{if(t){if(d.current){console.log("[Identity] Restart already in progress, skipping...");return}d.current=!0,i(!0),c(null);try{const x={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",x);const h=await r.identityRequest(x);return console.log("Restart identity result:",h),a(h),h}catch(x){throw c(x),x}finally{i(!1),d.current=!1}}},[t,r]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:n,error:o,requestIdentity:m,requestCompanyIdentity:v,restartIdentity:w}}function Ut(t){const{riskScoringService:r,applicantService:s}=de(),[a,n]=l.useState(null),[i,o]=l.useState({}),[c,d]=l.useState(!1),[m,v]=l.useState(!1),[w,x]=l.useState(null),[h,g]=l.useState(null),k=l.useRef(!1),f=l.useRef(null),p=l.useCallback(async()=>{var N;if(t){if(k.current){console.log("[RiskScoring] Load already in progress, skipping...");return}k.current=!0,d(!0),x(null);try{const[b,_]=await Promise.all([r.getRiskCriterias(t),s.getApplicantData(t).catch(()=>null)]);if(n(b),(N=_==null?void 0:_.riskScoringResults)!=null&&N.length){const W=_.riskScoringResults[0],P={};for(const y of W.riskCriteriaResults??[])if(y.riskCriteriaId!=null&&y.answer!=null&&y.answer!==""){const S=[...new Set(y.answer.split(",").map(I=>I.trim()).filter(I=>I!==""))];S.length>0&&(P[y.riskCriteriaId]=S)}o(P)}f.current=t}catch(b){x(b)}finally{d(!1),k.current=!1}}},[t,r,s]);l.useEffect(()=>{t&&f.current!==t&&p()},[t]);const R=l.useCallback(async N=>{v(!0),x(null);try{const b=await r.submitRiskScoring(N);return g(b),b}catch(b){throw x(b),b}finally{v(!1)}},[r]);return{criteria:a,initialAnswers:i,result:h,isLoading:c,isSubmitting:m,error:w,load:p,submit:R}}function _t(){const{applicantService:t,config:r}=de(),[s,a]=l.useState(!1),[n,i]=l.useState(null),o=l.useRef(!1),c=l.useRef(!1),d=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(h){const g=Math.random()*16|0;return(h==="x"?g:g&3|8).toString(16)}),m=l.useCallback(async h=>{var g;if(o.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");o.current=!0,a(!0),i(null);try{if(h.applicantAdditionalDatas||(h.applicantAdditionalDatas=[]),(g=r.identityProviders)!=null&&g.sardinai){const f=d();console.log("[SardinAI] Generated session key:",f),h.applicantAdditionalDatas.push({paramName:"sessionKey",value:f})}return await t.createApplicant(h)}catch(k){throw i(k),k}finally{a(!1),o.current=!1}},[t,r]),v=l.useCallback(async h=>{a(!0),i(null);try{return await t.createCompanyApplicant(h)}catch(g){throw i(g),g}finally{a(!1)}},[t]),w=l.useCallback(async h=>{if(c.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");c.current=!0,a(!0),i(null);try{return await t.getApplicantData(h)}catch(g){throw i(g),g}finally{a(!1),c.current=!1}},[t]),x=l.useCallback(async h=>{a(!0),i(null);try{await t.stopProgress(h)}catch(g){throw i(g),g}finally{a(!1)}},[t]);return{isLoading:s,error:n,createApplicant:m,createCompanyApplicant:v,getApplicantData:w,stopProgress:x}}const B=({children:t,variant:r="primary",size:s="md",isLoading:a=!1,disabled:n,className:i,...o})=>{const c="inline-flex items-center justify-center rounded-lg font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",d={primary:"bg-primary-500 text-white hover:bg-primary-600 focus:ring-primary-500",secondary:"bg-gray-200 text-gray-900 hover:bg-gray-300 focus:ring-gray-400",outline:"border-2 border-primary-500 text-primary-500 hover:bg-primary-50 focus:ring-primary-500",danger:"bg-danger-500 text-white hover:bg-danger-600 focus:ring-danger-500",ghost:"text-gray-700 hover:bg-gray-100 focus:ring-gray-400"},m={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-base",lg:"px-6 py-3 text-lg"};return e.jsxs("button",{className:te(c,d[r],m[s],i),disabled:n||a,...o,children:[a&&e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t]})},ie=l.forwardRef(({label:t,error:r,helperText:s,leftIcon:a,rightIcon:n,className:i,...o},c)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t,o.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"relative",children:[a&&e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:a}),e.jsx("input",{ref:c,className:te("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","disabled:bg-gray-100 disabled:cursor-not-allowed",r?"border-danger-500 focus:ring-danger-500":"border-gray-300 dark:border-gray-600","dark:bg-gray-800 dark:text-white",a?"pl-10":"",n?"pr-10":"",i),...o}),n&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:n})]}),r&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s})]}));ie.displayName="Input";const T=({children:t,className:r,...s})=>e.jsx("div",{className:te("metakyc-card rounded-xl shadow-sm border",r),style:{backgroundColor:"var(--metakyc-surface, #ffffff)",borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),se=({children:t,className:r,...s})=>e.jsx("div",{className:te("px-6 py-4 border-b",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),M=({children:t,className:r,...s})=>e.jsx("div",{className:te("px-6 py-4",r),...s,children:t}),le=({children:t,className:r,...s})=>e.jsx("div",{className:te("px-6 py-4 border-t",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),ye=({children:t,variant:r="default",className:s,...a})=>{const n={default:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",success:"bg-success-100 text-success-800 dark:bg-success-900 dark:text-success-300",danger:"bg-danger-100 text-danger-800 dark:bg-danger-900 dark:text-danger-300",warning:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300",info:"bg-primary-100 text-primary-800 dark:bg-primary-900 dark:text-primary-300"};return e.jsx("span",{className:te("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",n[r],s),...a,children:t})},pe=({size:t="md",className:r,...s})=>{const a={sm:"h-4 w-4",md:"h-8 w-8",lg:"h-12 w-12"};return e.jsx("div",{className:te("flex items-center justify-center",r),...s,children:e.jsxs("svg",{className:te("animate-spin text-primary-500",a[t]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})},be=l.forwardRef(({label:t,error:r,helperText:s,options:a,placeholder:n,className:i,...o},c)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t,o.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("select",{ref:c,className:te("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","disabled:bg-gray-100 disabled:cursor-not-allowed",r?"border-danger-500 focus:ring-danger-500":"border-gray-300 dark:border-gray-600","dark:bg-gray-800 dark:text-white",i),...o,children:[n&&e.jsx("option",{value:"",disabled:!0,children:n},"__placeholder__"),a.map((d,m)=>e.jsx("option",{value:d.value,disabled:d.disabled,children:d.label},d.value||`option-${m}`))]}),r&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s})]}));be.displayName="Select";const Kt=({label:t,value:r,onChange:s,options:a,placeholder:n="Select...",disabled:i=!1,required:o=!1})=>{const[c,d]=l.useState(!1),[m,v]=l.useState(""),w=l.useRef(null);l.useEffect(()=>{const f=p=>{w.current&&!w.current.contains(p.target)&&(d(!1),v(""))};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const x=a.filter(f=>f.label.toLowerCase().includes(m.toLowerCase())),h=f=>{i||(r.includes(f)?s(r.filter(p=>p!==f)):s([...r,f]))},g=(f,p)=>{p.stopPropagation(),i||s(r.filter(R=>R!==f))},k=f=>{var p;return((p=a.find(R=>R.value===f))==null?void 0:p.label)||f};return e.jsxs("div",{className:"w-full metakyc-multiselect",ref:w,children:[t&&e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t,o&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{onClick:()=>!i&&d(!c),className:te("metakyc-multiselect-trigger","min-h-[42px] w-full px-3 py-2 rounded-lg border text-sm transition-colors","bg-white dark:bg-gray-800","border-gray-300 dark:border-gray-600",c&&"ring-2 ring-blue-500 border-transparent",i?"opacity-50 cursor-not-allowed":"cursor-pointer"),children:[r.length===0?e.jsx("span",{className:"metakyc-multiselect-placeholder text-gray-400 dark:text-gray-500 leading-6",children:n}):e.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:r.map(f=>e.jsxs("span",{className:"metakyc-multiselect-chip inline-flex items-center gap-1 px-2 py-0.5 rounded bg-blue-100 dark:bg-blue-900/40 text-blue-800 dark:text-blue-300 text-xs font-medium",children:[k(f),!i&&e.jsx("button",{type:"button",onClick:p=>g(f,p),className:"metakyc-multiselect-chip-remove",style:{background:"transparent",border:"none",padding:"0 0 0 2px",margin:0,cursor:"pointer",fontSize:"14px",lineHeight:1,fontWeight:"bold",display:"inline-flex",alignItems:"center",boxShadow:"none",transform:"none",minWidth:0,width:"auto",height:"auto",letterSpacing:"normal",textTransform:"none"},children:"×"})]},f))}),e.jsx("span",{className:"metakyc-multiselect-arrow absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none text-xs",children:c?"▲":"▼"})]}),c&&e.jsxs("div",{className:"metakyc-multiselect-dropdown absolute z-50 w-full mt-1 rounded-lg shadow-lg",style:{background:"inherit",border:"1px solid #d1d5db"},children:[e.jsx("div",{className:"metakyc-multiselect-search-wrapper p-2",style:{borderBottom:"1px solid #e5e7eb"},children:e.jsx("input",{type:"text",value:m,onChange:f=>v(f.target.value),placeholder:"Search...",autoFocus:!0,onClick:f=>f.stopPropagation(),className:"metakyc-multiselect-search w-full px-2 py-1.5 text-sm rounded focus:outline-none focus:ring-1 focus:ring-blue-500",style:{border:"1px solid #d1d5db"}})}),e.jsx("ul",{className:"max-h-48 overflow-y-auto py-1",children:x.length===0?e.jsx("li",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"No results"}):x.map(f=>e.jsxs("li",{onClick:()=>h(f.value),className:te("metakyc-multiselect-option","flex items-center gap-2 px-3 py-2 text-sm cursor-pointer","hover:bg-gray-50 dark:hover:bg-gray-700",r.includes(f.value)&&"metakyc-multiselect-option-selected bg-blue-50 dark:bg-blue-900/20"),children:[e.jsx("input",{type:"checkbox",checked:r.includes(f.value),readOnly:!0,className:"rounded border-gray-300 text-blue-600 pointer-events-none"}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100",children:f.label})]},f.value))}),r.length>0&&e.jsx("div",{className:"metakyc-multiselect-clear p-2 border-t border-gray-100 dark:border-gray-700",children:e.jsxs("button",{type:"button",onClick:()=>{s([]),v("")},className:"text-xs text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:["Clear all (",r.length," selected)"]})})]})]})]})},qt=({label:t,error:r,accept:s,multiple:a=!1,maxSize:n,onChange:i,value:o=[],className:c})=>{const[d,m]=l.useState(!1),v=l.useRef(null),w=p=>{if(!p)return;const R=Array.from(p);if(n&&R.filter(b=>b.size>n).length>0){const b=Pe(n);alert(`Some files exceed the maximum size of ${b}`);return}i==null||i(a?[...o,...R]:[R[0]])},x=p=>{p.preventDefault(),m(!0)},h=()=>{m(!1)},g=p=>{p.preventDefault(),m(!1),w(p.dataTransfer.files)},k=()=>{var p;(p=v.current)==null||p.click()},f=p=>{const R=o.filter((N,b)=>b!==p);i==null||i(R)};return e.jsxs("div",{className:te("w-full",c),children:[t&&e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t}),e.jsxs("div",{className:te("border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors",d?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-300 dark:border-gray-600 hover:border-primary-500",r&&"border-danger-500"),onDragOver:x,onDragLeave:h,onDrop:g,onClick:k,children:[e.jsx("input",{ref:v,type:"file",className:"hidden",accept:s,multiple:a,onChange:p=>w(p.target.files)}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",stroke:"currentColor",fill:"none",viewBox:"0 0 48 48",children:e.jsx("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("span",{className:"font-medium text-primary-500",children:"Click to upload"})," or drag and drop"]}),n&&e.jsxs("p",{className:"text-xs text-gray-500",children:["Maximum file size: ",Pe(n)]})]})]}),o.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:o.map((p,R)=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsxs("div",{className:"flex items-center space-x-2 flex-1 min-w-0",children:[e.jsx("svg",{className:"h-5 w-5 text-gray-400 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",children:p.name}),e.jsxs("span",{className:"text-xs text-gray-500",children:["(",Pe(p.size),")"]})]}),e.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),f(R)},className:"ml-2 text-danger-500 hover:text-danger-700 focus:outline-none",children:e.jsx("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]},R))}),r&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:r})]})},Ht=l.forwardRef(({countryCode:t="+1",onCountryCodeChange:r,className:s,...a},n)=>e.jsxs("div",{className:"w-full",children:[a.label&&e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[a.label,a.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:i=>r==null?void 0:r(i.target.value),className:te("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white"),placeholder:"+1"}),e.jsx(ie,{ref:n,type:"tel",className:te("flex-1",s),...a,label:""})]}),a.error&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:a.error})]}));Ht.displayName="PhoneInput";/**
|
|
1
|
+
"use strict";var or=Object.defineProperty;var cr=(t,r,s)=>r in t?or(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s;var Y=(t,r,s)=>cr(t,typeof r!="symbol"?r+"":r,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const dr=require("axios"),l=require("react"),e=require("react/jsx-runtime"),ke=require("react-hook-form"),ve=require("zod");function ur(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const a=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(r,s,a.get?a:{enumerable:!0,get:()=>t[s]})}}return r.default=t,Object.freeze(r)}const Ye=ur(l);var z=(t=>(t[t.IdentitySdk=0]="IdentitySdk",t[t.RiskScoring=1]="RiskScoring",t[t.Questionaries=2]="Questionaries",t[t.AdditionalData=3]="AdditionalData",t[t.AppropriatenessTest=4]="AppropriatenessTest",t[t.UploadDocument=5]="UploadDocument",t[t.ManualReview=6]="ManualReview",t[t.Overview=7]="Overview",t[t.InvestorCategorization=8]="InvestorCategorization",t))(z||{}),De=(t=>(t[t.NotStarted=0]="NotStarted",t[t.InProgress=1]="InProgress",t[t.Success=2]="Success",t[t.PartialSuccess=3]="PartialSuccess",t[t.Failed=4]="Failed",t[t.Skipped=5]="Skipped",t[t.AdminReview=6]="AdminReview",t[t.SkippedAndAdminReview=7]="SkippedAndAdminReview",t))(De||{}),me=(t=>(t[t.None=0]="None",t[t.InProgress=1]="InProgress",t[t.Finished=2]="Finished",t[t.OnHold=3]="OnHold",t[t.IdentityPending=4]="IdentityPending",t))(me||{}),Ve=(t=>(t[t.None=0]="None",t[t.RepresentativeKYC=1]="RepresentativeKYC",t[t.ManualRiskCriteria=2]="ManualRiskCriteria",t[t.UploadDocumentReview=3]="UploadDocumentReview",t[t.AdminReview=4]="AdminReview",t))(Ve||{}),Ge=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(Ge||{}),we=(t=>(t[t.None=0]="None",t[t.Pending=1]="Pending",t[t.Approved=2]="Approved",t[t.Rejected=3]="Rejected",t[t.ResendRequested=4]="ResendRequested",t[t.Unknown=5]="Unknown",t[t.InProgress=6]="InProgress",t))(we||{}),je=(t=>(t[t.Approved=0]="Approved",t[t.Reject=1]="Reject",t[t.UnderReview=2]="UnderReview",t[t.Closed=3]="Closed",t[t.AdminReview=4]="AdminReview",t[t.New=5]="New",t[t.InProgress=6]="InProgress",t))(je||{}),Ze=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(Ze||{}),Je=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(Je||{}),ue=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(ue||{}),Xe=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(Xe||{}),Fe=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(Fe||{}),et=(t=>(t[t.Image=0]="Image",t[t.Video=1]="Video",t[t.PDF=2]="PDF",t[t.OfficePDF=3]="OfficePDF",t[t.Custom=4]="Custom",t))(et||{}),tt=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(tt||{}),rt=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))(rt||{}),ye=(t=>(t[t.String=0]="String",t[t.Integer=1]="Integer",t[t.Decimal=2]="Decimal",t[t.Boolean=3]="Boolean",t[t.Date=4]="Date",t[t.Country=5]="Country",t[t.DigitOnly=6]="DigitOnly",t))(ye||{}),st=(t=>(t[t.Text=0]="Text",t[t.Radio=1]="Radio",t[t.Checkbox=2]="Checkbox",t[t.Dropdown=3]="Dropdown",t[t.Country=4]="Country",t))(st||{}),at=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))(at||{}),ce=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(ce||{}),nt=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(nt||{});const Te={firstName:{label:"First Name",type:"text"},lastName:{label:"Last Name",type:"text"},email:{label:"Email",type:"email"},phonenumber:{label:"Phone Number",type:"tel"},dateOfBirth:{label:"Date of Birth",type:"date"},salutation:{label:"Salutation",type:"select"},title:{label:"Title",type:"text"},mobileCountryCode:{label:"Mobile Country Code",type:"text"},street:{label:"Street",type:"text"},streetNumber:{label:"Street Number",type:"text"},zip:{label:"ZIP / Postal Code",type:"text"},city:{label:"City",type:"text"},country:{label:"Country",type:"select"},nationality:{label:"Nationality",type:"select"},otherNationality:{label:"Other Nationalities",type:"multiselect"},countryOfBirth:{label:"Country of Birth",type:"select"},placeOfBirth:{label:"Place of Birth",type:"text"},taxCountry:{label:"Tax Country",type:"select"},taxNumber:{label:"Tax Number",type:"text"},defaultLanguage:{label:"Default Language",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"}},it=["firstName","lastName","email","phonenumber","dateOfBirth"],$e=[{value:"EN",label:"English"},{value:"DE",label:"German"},{value:"FR",label:"French"},{value:"ES",label:"Spanish"},{value:"IT",label:"Italian"},{value:"PT",label:"Portuguese"},{value:"NL",label:"Dutch"},{value:"PL",label:"Polish"},{value:"RU",label:"Russian"},{value:"ZH",label:"Chinese"},{value:"JA",label:"Japanese"},{value:"AR",label:"Arabic"},{value:"TR",label:"Turkish"},{value:"SV",label:"Swedish"},{value:"DA",label:"Danish"},{value:"FI",label:"Finnish"},{value:"NO",label:"Norwegian"}];var X=(t=>(t.Default="default",t.Corporate="corporate",t.Fintech="fintech",t.Healthcare="healthcare",t.Modern="modern",t.Minimal="minimal",t))(X||{});const lt={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class ot{constructor(r){this.config=r}build(r,s){const a=`${r}.${s}`;if(this.config.customPaths&&this.config.customPaths[a])return this.config.customPaths[a];switch(this.config.pattern){case"host-controller":return`/api/${r}/${s}`;case"application-service":return`/services/app/${this.getServiceName(r)}/${s}`;case"custom":throw new Error(`Custom endpoint path not found for ${a}. Please provide it in customPaths.`);default:throw new Error(`Unknown endpoint pattern: ${this.config.pattern}`)}}getServiceName(r){return{Applicant:"MetaKYCVerification",Questionnaire:"MetaKYCVerification",UploadDocument:"MetaKYCVerification",AppropriatenessTest:"MetaKYCVerification",BaseInformation:"MetaKYCVerification"}[r]||r}}class xe extends Error{constructor(s,a,n,i,o){super(s);Y(this,"response");this.code=a,this.details=n,this.validationErrors=i,this.name="MetaKYCError",this.response=o,Object.setPrototypeOf(this,xe.prototype)}}class Ce{static handleApiError(r){return new xe(r.message||"An unknown error occurred",r.code,r.details||void 0,r.validationErrors||void 0)}static handleAxiosError(r){if(r.response){const s=r.response.data;return s&&s.error?new xe(s.error.message||"An unknown error occurred",s.error.code,s.error.details||void 0,s.error.validationErrors||void 0,r.response):s&&s.result&&s.result.message?new xe(s.result.message,r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response):new xe((s==null?void 0:s.message)||r.message||"Request failed",r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response)}else return r.request?new xe("No response from server",0,"The request was made but no response was received. Please check your network connection."):new xe(r.message||"An unexpected error occurred",0,r.toString())}static isMetaKYCError(r){return r instanceof xe}}class ct{constructor(r){Y(this,"axiosInstance");Y(this,"endpointBuilder");Y(this,"config");this.config={...lt,...r},this.endpointBuilder=new ot(this.config.endpoints),this.axiosInstance=dr.create({baseURL:this.config.baseUrl,timeout:this.config.timeout,headers:{"Content-Type":"application/json"}}),this.axiosInstance.interceptors.request.use(s=>(s.headers["Abp-TenantId"]=this.config.tenantId.toString(),s.headers.ApiKey=this.config.apiKey,s.headers["X-API-KEY"]=this.config.apiKey,this.config.locale&&(s.headers["Accept-Language"]=this.config.locale),s),s=>Promise.reject(s)),this.axiosInstance.interceptors.response.use(s=>s,async s=>{var n;const a=s.config;return((n=s.response)==null?void 0:n.status)>=500&&!a._retry&&(a._retry=!0,a._retryCount=(a._retryCount||0)+1,a._retryCount<(this.config.retries||3))?(await new Promise(i=>setTimeout(i,1e3*a._retryCount)),this.axiosInstance(a)):Promise.reject(s)})}buildEndpoint(r,s){return this.endpointBuilder.build(r,s)}async get(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.get(n,{params:a});return this.handleResponse(i)}catch(n){throw Ce.handleAxiosError(n)}}async post(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.post(n,a);return this.handleResponse(i)}catch(n){throw Ce.handleAxiosError(n)}}async put(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.put(n,a);return this.handleResponse(i)}catch(n){throw Ce.handleAxiosError(n)}}async delete(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.delete(n,{params:a});return this.handleResponse(i)}catch(n){throw Ce.handleAxiosError(n)}}handleResponse(r){const s=r.data;if(!s.success&&s.error)throw Ce.handleApiError(s.error);return s}getAxiosInstance(){return this.axiosInstance}}class dt{constructor(r){this.httpClient=r}async createApplicant(r){return(await this.httpClient.post("Applicant","ApplicantRegistrationRequest",r)).result}async createCompanyApplicant(r){return(await this.httpClient.post("Applicant","ApplicantCompanyRegistrationRequest",r)).result}async duplicateApplicant(r){return(await this.httpClient.post("Applicant","DuplicateApplicantRegistrationRequest",r)).result}async getProgress(r){return(await this.httpClient.get("Applicant","GetApplicantProgress",{applicantId:r})).result}async getProgressStatus(r){return(await this.httpClient.get("Applicant","GetApplicantProgressStaus",{applicantId:r})).result}async getApplicantData(r){return(await this.httpClient.get("Applicant","GetApplicantData",{applicantId:r})).result}async getApplicantStatus(r){return(await this.httpClient.get("Applicant","GetApplicantStatus",{applicantId:r})).result}async stopProgress(r){await this.httpClient.get("Applicant","StopProgress",{applicantId:r})}async progressStepBack(r){await this.httpClient.get("Applicant","ProgressStepBack",{applicantId:r})}async setLanguage(r,s){await this.httpClient.post("Applicant","SetApplicantLng",{applicantId:r,language:s})}async activateApplicant(r){await this.httpClient.get("Applicant","ActivateApplicant",{applicantId:r})}async deleteApplicant(r){await this.httpClient.delete("Applicant","DeleteApplicant",{applicantId:r})}async checkApplicantExists(r){return(await this.httpClient.get("Applicant","CheckApplicantIfExists",{externalRefId:r})).result}}class ut{constructor(r){this.httpClient=r}async getQuestionnaire(r){return(await this.httpClient.get("Questionnaire","GetQuestionnaire",{applicantid:r})).result}async fillQuestionnaire(r){return(await this.httpClient.post("Applicant","FillQuestionnarie",r)).result}}class mt{constructor(r){this.httpClient=r}async getUploadDocument(r){return(await this.httpClient.get("UploadDocument","GetUploadDocument",{applicantid:r})).result}async fillUploadDocument(r){await this.httpClient.post("Applicant","FillUploadDocument",r)}async reviewUploadDocument(r){await this.httpClient.post("UploadDocument","ReviewUploadDocument",r)}}class pt{constructor(r){this.httpClient=r}async getAppropriatenessTest(r){return(await this.httpClient.get("AppropriatenessTest","GetAppropriatenessTest",{applicantid:r})).result}async fillAppropriatenessTest(r){return(await this.httpClient.post("Applicant","FillAppropriatenessTest",r)).result}}class ht{constructor(r){this.httpClient=r}async getOverviewData(r){return(await this.httpClient.get("Applicant","GetOverviewData",{ApplicantId:r})).result}async passOverview(r){await this.httpClient.get("Applicant","PassOverview",{applicantId:r})}}class gt{constructor(r){this.httpClient=r}async getRiskScoringPlan(){return(await this.httpClient.get("Applicant","GetRiskScoringPlanInfo")).result}async getRiskCriterias(r){return(await this.httpClient.get("Risk","GetCriterias",{applicantId:r})).result}async submitRiskScoring(r){return(await this.httpClient.post("Applicant","RiskScoringRequest",r)).result}}class xt{constructor(r){this.httpClient=r}async identityRequest(r){console.log("[IdentityService] Calling IdentityRequest with input:",r);const s=await this.httpClient.post("Applicant","IdentityRequest",r);return console.log("[IdentityService] IdentityRequest response:",s),s.result}async identityCompanyRequest(r){return(await this.httpClient.post("Applicant","IdentityCompanyRequest",r)).result}async restartIdentityRequest(r){const s={applicantId:r,restart:!0,redirectUrl:"",ttl:604800};return console.log("[IdentityService] Restarting identity with restart=true:",s),this.identityRequest(s)}async restartIdentityCompanyRequest(r){const s={applicantId:r,restart:!0,redirectUrl:"",ttl:604800};return this.identityCompanyRequest(s)}}class ft{constructor(r){this.httpClient=r}async getCountries(r,s,a){return(await this.httpClient.get("BaseInformation","GetAllCountries",{filter:r||"",lng:s||"en",type:a})).result}async getBranches(){return(await this.httpClient.get("BaseInformation","GetBranches")).result}async getLegalEntities(){return(await this.httpClient.get("BaseInformation","GetLegalEntities")).result}}class yt{constructor(r){this.httpClient=r}async setInvestorCategorization(r){return(await this.httpClient.post("Applicant","SetInvestorCategorization",r)).result}async getInvestorCategorization(r){return(await this.httpClient.get("Applicant","GetInvestorCategorisation",{applicantId:r})).result}}const ne={name:"Default",title:"KYC Verification",logo:{url:"",height:"40px",visible:!0},colors:{primary:"#2563eb",primaryHover:"#1d4ed8",primaryLight:"#dbeafe",primaryDark:"#1e40af",secondary:"#64748b",secondaryHover:"#475569",success:"#10b981",warning:"#f59e0b",danger:"#ef4444",info:"#3b82f6",background:"#ffffff",surface:"#f9fafb",border:"#e5e7eb",textPrimary:"#111827",textSecondary:"#6b7280",textMuted:"#9ca3af"},typography:{fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},spacing:{borderRadius:"0.5rem",cardPadding:"1.5rem",inputHeight:"2.5rem"},darkMode:{colors:{background:"#111827",surface:"#1f2937",border:"#374151",textPrimary:"#f9fafb",textSecondary:"#d1d5db",textMuted:"#9ca3af"}}},bt={name:"Corporate",logo:{url:"",height:"40px",visible:!0},colors:{primary:"#0052CC",primaryHover:"#0747A6",primaryLight:"#DEEBFF",primaryDark:"#0747A6",secondary:"#6B778C",secondaryHover:"#5E6C84",success:"#00875A",warning:"#FF991F",danger:"#DE350B",info:"#0065FF",background:"#ffffff",surface:"#F4F5F7",border:"#DFE1E6",textPrimary:"#172B4D",textSecondary:"#5E6C84",textMuted:"#97A0AF"},typography:{fontFamily:"system-ui, -apple-system, sans-serif"},spacing:{borderRadius:"0.25rem",cardPadding:"1.5rem",inputHeight:"2.5rem"}},vt={name:"Fintech",logo:{url:"",height:"36px",visible:!0},colors:{primary:"#00B386",primaryHover:"#009973",primaryLight:"#D1FAE5",primaryDark:"#047857",secondary:"#7C3AED",secondaryHover:"#6D28D9",success:"#10B981",warning:"#F59E0B",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#F9FAFB",border:"#E5E7EB",textPrimary:"#111827",textSecondary:"#6B7280",textMuted:"#9CA3AF"},typography:{fontFamily:"Montserrat, system-ui, sans-serif"},spacing:{borderRadius:"0.75rem",cardPadding:"2rem",inputHeight:"3rem"}},kt={name:"Healthcare",logo:{url:"",height:"44px",visible:!0},colors:{primary:"#06B6D4",primaryHover:"#0891B2",primaryLight:"#CFFAFE",primaryDark:"#0E7490",secondary:"#8B5CF6",secondaryHover:"#7C3AED",success:"#059669",warning:"#D97706",danger:"#DC2626",info:"#0284C7",background:"#ffffff",surface:"#F0F9FF",border:"#E0F2FE",textPrimary:"#0F172A",textSecondary:"#475569",textMuted:"#94A3B8"},typography:{fontFamily:"Lato, system-ui, sans-serif"},spacing:{borderRadius:"0.5rem",cardPadding:"1.75rem",inputHeight:"2.75rem"},darkMode:{colors:{background:"#0F172A",surface:"#1E293B",border:"#334155",textPrimary:"#F1F5F9",textSecondary:"#CBD5E1"}}},wt={name:"Modern",logo:{url:"",height:"38px",visible:!0},colors:{primary:"#8B5CF6",primaryHover:"#7C3AED",primaryLight:"#EDE9FE",primaryDark:"#6D28D9",secondary:"#EC4899",secondaryHover:"#DB2777",success:"#10B981",warning:"#F59E0B",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#FAFAFA",border:"#E5E5E5",textPrimary:"#171717",textSecondary:"#737373",textMuted:"#A3A3A3"},typography:{fontFamily:"Poppins, system-ui, sans-serif"},spacing:{borderRadius:"1rem",cardPadding:"2rem",inputHeight:"3rem"}},jt={name:"Minimal",logo:{url:"",height:"32px",visible:!0},colors:{primary:"#000000",primaryHover:"#18181B",primaryLight:"#F4F4F5",primaryDark:"#000000",secondary:"#71717A",secondaryHover:"#52525B",success:"#22C55E",warning:"#EAB308",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#FAFAFA",border:"#E4E4E7",textPrimary:"#09090B",textSecondary:"#71717A",textMuted:"#A1A1AA"},typography:{fontFamily:"system-ui, -apple-system, sans-serif"},spacing:{borderRadius:"0.25rem",cardPadding:"1.25rem",inputHeight:"2.25rem"}},Nt={[X.Default]:ne,[X.Corporate]:bt,[X.Fintech]:vt,[X.Healthcare]:kt,[X.Modern]:wt,[X.Minimal]:jt};function Ae(t){return Nt[t]||ne}class St{constructor(r){this.httpClient=r}async getThemeConfiguration(){var r;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return Ae(X.Default);let a=s.result.preset?Ae(s.result.preset):Ae(X.Default);if(s.result.title&&(a.title=s.result.title),s.result.logo&&(a.logo={...a.logo,...s.result.logo}),s.result.colors&&(a.colors={...a.colors,...s.result.colors}),s.result.typography&&(a.typography={...a.typography,...s.result.typography}),s.result.spacing&&(a.spacing={...a.spacing,...s.result.spacing}),s.result.customCSS&&(a.customCSS=s.result.customCSS),s.result.darkMode&&(a.darkMode={colors:{...(r=a.darkMode)==null?void 0:r.colors,...s.result.darkMode.colors}}),s.result.applicantFormVisibleFields&&s.result.applicantFormVisibleFields.length>0&&(a.applicantFormVisibleFields=s.result.applicantFormVisibleFields),s.result.applicantFormRequiredFields&&s.result.applicantFormRequiredFields.length>0&&(a.applicantFormRequiredFields=s.result.applicantFormRequiredFields),s.result.allowedLanguages&&s.result.allowedLanguages.length>0&&(a.allowedLanguages=s.result.allowedLanguages),s.result.applicantFormPages)try{const n=typeof s.result.applicantFormPages=="string"?JSON.parse(s.result.applicantFormPages):s.result.applicantFormPages;Array.isArray(n)&&n.length>0&&(a.applicantFormPages=n)}catch{}return a}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),Ae(X.Default)}}async saveThemeConfiguration(r){await this.httpClient.post("Tenant","SaveThemeConfiguration",r)}getAvailablePresets(){return[{id:X.Default,name:"Default"},{id:X.Corporate,name:"Corporate"},{id:X.Fintech,name:"Fintech"},{id:X.Healthcare,name:"Healthcare"},{id:X.Modern,name:"Modern"},{id:X.Minimal,name:"Minimal"}]}getPreviewTheme(r,s){const a=Ae(r);return s?{...a,...s,logo:{...a.logo,...s.logo},colors:{...a.colors,...s.colors},typography:s.typography?{...a.typography,...s.typography}:a.typography,spacing:s.spacing?{...a.spacing,...s.spacing}:a.spacing}:a}}class Ct{constructor(){Y(this,"listeners",new Map)}on(r,s){return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(s),()=>{this.off(r,s)}}off(r,s){const a=this.listeners.get(r);a&&a.delete(s)}emit(r,s){const a=this.listeners.get(r);a&&a.forEach(n=>{try{n(s)}catch(i){console.error(`Error in event listener for "${r}":`,i)}})}clear(){this.listeners.clear()}clearEvent(r){this.listeners.delete(r)}}class At{constructor(){Y(this,"events",new Ct);Y(this,"_applicantId",null);Y(this,"_progress",null);Y(this,"_error",null)}get applicantId(){return this._applicantId}get progress(){return this._progress}get currentStep(){var r;return((r=this._progress)==null?void 0:r.currentStep)||null}get steps(){var r;return((r=this._progress)==null?void 0:r.stepInfoList)||[]}get status(){var r;return((r=this._progress)==null?void 0:r.status)||me.None}get workflowResult(){var r;return((r=this._progress)==null?void 0:r.workflowResult)||null}get error(){return this._error}get isComplete(){return this.status===me.Finished}get isOnHold(){return this.status===me.OnHold}get isInProgress(){return this.status===me.InProgress}setApplicantId(r){this._applicantId=r}updateProgress(r){var a,n;const s=(a=this._progress)==null?void 0:a.currentStep;this._progress=r,this._applicantId=r.applicantId,this._error=null,this.events.emit("progressUpdated",r),(s==null?void 0:s.order)!==((n=r.currentStep)==null?void 0:n.order)&&this.events.emit("stepChanged",r.currentStep),this.events.emit("statusChanged",r.status),r.status===me.Finished&&r.workflowResult&&this.events.emit("completed",r.workflowResult)}setError(r){this._error=r,this.events.emit("error",r)}clearError(){this._error=null}reset(){this._applicantId=null,this._progress=null,this._error=null}onProgressUpdated(r){return this.events.on("progressUpdated",r)}onStepChanged(r){return this.events.on("stepChanged",r)}onStatusChanged(r){return this.events.on("statusChanged",r)}onError(r){return this.events.on("error",r)}onCompleted(r){return this.events.on("completed",r)}clearListeners(){this.events.clear()}}class Et{constructor(){Y(this,"handlers",new Map)}registerHandler(r,s){this.handlers.set(r,s)}getHandler(r){return this.handlers.get(r)}hasHandler(r){return this.handlers.has(r)}async loadStepData(r,s){const a=this.getHandler(r);if(!a)throw new Error(`No handler registered for step action: ${z[r]}`);return a.loadData(s)}async submitStepData(r,s){const a=this.getHandler(r);if(!a)throw new Error(`No handler registered for step action: ${z[r]}`);return a.submitData(s)}}class It{constructor(r,s,a,n,i,o,c,u){Y(this,"state");Y(this,"stepRouter");this.applicantService=r,this.questionnaireService=s,this.uploadDocumentService=a,this.appropriatenessTestService=n,this.overviewService=i,this.riskScoringService=o,this.investorCategorizationService=u,this.state=new At,this.stepRouter=new Et,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(z.Questionaries,{loadData:r=>this.questionnaireService.getQuestionnaire(r),submitData:async r=>{await this.questionnaireService.fillQuestionnaire(r)}}),this.stepRouter.registerHandler(z.UploadDocument,{loadData:r=>this.uploadDocumentService.getUploadDocument(r),submitData:r=>this.uploadDocumentService.fillUploadDocument(r)}),this.stepRouter.registerHandler(z.AppropriatenessTest,{loadData:r=>this.appropriatenessTestService.getAppropriatenessTest(r),submitData:async r=>{await this.appropriatenessTestService.fillAppropriatenessTest(r)}}),this.stepRouter.registerHandler(z.Overview,{loadData:r=>this.overviewService.getOverviewData(r),submitData:r=>this.overviewService.passOverview(r.applicantId)}),this.stepRouter.registerHandler(z.RiskScoring,{loadData:r=>this.riskScoringService.getRiskCriterias(r),submitData:async r=>{await this.riskScoringService.submitRiskScoring(r)}}),this.stepRouter.registerHandler(z.IdentitySdk,{loadData:async r=>({applicantId:r,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(z.InvestorCategorization,{loadData:r=>this.investorCategorizationService.getInvestorCategorization(r),submitData:async r=>{await this.investorCategorizationService.setInvestorCategorization(r)}}),this.stepRouter.registerHandler(z.ManualReview,{loadData:async r=>({applicantId:r,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(z.AdditionalData,{loadData:async r=>({applicantId:r,message:"Additional data required"}),submitData:async()=>{}})}async initialize(r){try{this.state.setApplicantId(r);const s=await this.applicantService.getProgress(r);return this.state.updateProgress(s),s}catch(s){throw this.state.setError(s),s}}async refreshProgress(){if(!this.state.applicantId)throw new Error("Workflow not initialized. Call initialize() first.");try{const r=await this.applicantService.getProgress(this.state.applicantId);return this.state.updateProgress(r),r}catch(r){throw this.state.setError(r),r}}async getCurrentStepData(){if(!this.state.currentStep)throw new Error("No current step available");if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.stepRouter.loadStepData(this.state.currentStep.action,this.state.applicantId)}catch(r){throw this.state.setError(r),r}}async submitCurrentStep(r){if(!this.state.currentStep)throw new Error("No current step available");try{await this.stepRouter.submitStepData(this.state.currentStep.action,r),await this.refreshProgress()}catch(s){throw this.state.setError(s),s}}async moveToNextStep(){return this.refreshProgress()}async moveToPreviousStep(){if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.applicantService.progressStepBack(this.state.applicantId),await this.refreshProgress()}catch(r){throw this.state.setError(r),r}}getState(){return this.state}getStepRouter(){return this.stepRouter}}function _e(t,r){return new Promise((s,a)=>{if(r&&document.getElementById(r)){s();return}const n=document.createElement("script");n.src=t,r&&(n.id=r),n.async=!0,n.onload=()=>s(),n.onerror=()=>a(new Error(`Failed to load script: ${t}`)),document.head.appendChild(n)})}function mr(t){return!!document.getElementById(t)}function pr(t){const r=document.getElementById(t);r&&r.remove()}class Rt{constructor(r){Y(this,"sdk",null);Y(this,"config");this.config=r}async loadSDK(){await _e("https://cdn.sumsub.com/websdk/v2/production/websdk.js","sumsub-sdk")}async initialize(r){if(window.snsWebSdk||await this.loadSDK(),!window.snsWebSdk)throw new Error("Sumsub SDK failed to load");this.sdk=window.snsWebSdk.init(this.config.accessToken,()=>this.config.accessToken).withConf({lang:this.config.lang||"en",email:this.config.applicantEmail,phone:this.config.applicantPhone,i18n:{}}).on("idCheck.onStepCompleted",s=>{console.log("Sumsub step completed:",s)}).on("idCheck.onError",s=>{console.error("Sumsub error:",s)}).build(),this.sdk.launch(`#${r}`)}destroy(){this.sdk&&(this.sdk.destroy(),this.sdk=null)}onComplete(r){this.sdk&&this.sdk.on("idCheck.applicantStatus",s=>{s.applicantStatus==="completed"&&r(s)})}onError(r){this.sdk&&this.sdk.on("idCheck.onError",r)}}class Dt{constructor(r){Y(this,"sdk",null);Y(this,"config");this.config=r}async loadSDK(){await _e("https://sdk.onfido.com/v12.0.0/onfido.min.js","onfido-sdk")}async initialize(r){if(window.Onfido||await this.loadSDK(),!window.Onfido)throw new Error("Onfido SDK failed to load");this.sdk=window.Onfido.init({token:this.config.token,containerId:r,steps:this.config.steps||[{type:"welcome",options:{title:"Identity Verification"}},{type:"document",options:{documentTypes:{passport:!0,driving_licence:!0,national_identity_card:!0}}},{type:"face",options:{requestedVariant:"standard"}},{type:"complete"}],onComplete:()=>{this.config.onComplete&&this.config.onComplete()},onError:s=>{this.config.onError&&this.config.onError(s)}})}destroy(){this.sdk&&(this.sdk.tearDown(),this.sdk=null)}}class Ft{constructor(r){Y(this,"sardineContext",null);Y(this,"config");Y(this,"sessionKey");this.config=r,this.sessionKey=r.sessionKey||this.generateSessionKey()}generateSessionKey(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){const s=Math.random()*16|0;return(r==="x"?s:s&3|8).toString(16)})}getSardineHost(){const{environment:r,region:s}=this.config;if(r==="sandbox")return"api.sandbox.sardine.ai";switch(s){case"eu":return"api.eu.sardine.ai";case"ca":return"api.ca.sardine.ai";case"au":return"api.au.sardine.ai";default:return"api.sardine.ai"}}async loadSDK(){return new Promise((r,s)=>{if(window._Sardine){r();return}const a=this.getSardineHost(),n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=`https://${a}/assets/loader.min.js`,n.onload=()=>{console.log("[SardinAI] SDK loaded successfully"),r()},n.onerror=()=>{s(new Error("Failed to load SardinAI SDK"))};const i=document.getElementsByTagName("script")[0];i&&i.parentNode?i.parentNode.insertBefore(n,i):document.head.appendChild(n)})}async initialize(){try{if(await this.loadSDK(),!window._Sardine)throw new Error("SardinAI SDK not available after loading");const r=this.getSardineHost(),{clientId:s,environment:a,flow:n,enableBiometrics:i,enablePortScanning:o}=this.config;this.sardineContext=window._Sardine.createContext({clientId:s,sessionKey:this.sessionKey,userIdHash:void 0,flow:n||window.location.pathname,environment:a||"production",parentElement:document.body,enableBiometrics:i!==!1,enablePortScanning:o===!0,region:this.config.region,onDeviceResponse:c=>{console.log(`[SardinAI] Device ID: ${c.deviceId}`)},onConfigUpdate:(c,u,p)=>{switch(c){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",p);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",u);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",c)}}}),this.addNoScriptFallback(r),console.log("[SardinAI] SDK initialized with sessionKey:",this.sessionKey)}catch(r){throw console.error("[SardinAI] Initialization failed:",r),r}}addNoScriptFallback(r){const s=document.createElement("noscript"),a=document.createElement("img"),{clientId:n,flow:i}=this.config;a.src=`https://${r}/v1/a.png?clientId=${n}&sessionKey=${this.sessionKey}&flow=${i||"kyc"}&ns=1`,a.style.display="none",s.appendChild(a),document.body.appendChild(s)}updateConfig(r){if(!this.sardineContext){console.warn("[SardinAI] Cannot update config - SDK not initialized");return}r.sessionKey&&(this.sessionKey=r.sessionKey),this.sardineContext.updateConfig({...r,onConfigUpdate:(s,a,n)=>{switch(s){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Config update failed:",n);break;case"SESSION_UPDATED":console.log("[SardinAI] Config updated:",a);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No config update needed");break}}})}getSessionKey(){return this.sessionKey}destroy(){this.sardineContext&&(this.sardineContext=null)}}class Ne{static createProvider(r,s){switch(r){case ue.Sumsub:return new Rt(s);case ue.Onfido:return new Dt(s);case ue.SardinAI:return new Ft(s);default:throw new Error(`Unsupported identity provider: ${r}`)}}static parseProviderConfig(r,s,a){var n;switch(r){case ue.Sumsub:return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:s.lang||"en"};case ue.Onfido:return{token:s.token||s.sdkToken};case ue.SardinAI:const i=((n=a==null?void 0:a.identityProviders)==null?void 0:n.sardinai)||{};return{clientId:i.clientId||s.clientId,sessionKey:i.sessionKey||s.sessionKey,environment:i.environment||s.environment||"production",flow:i.flow||s.flow,region:i.region,enableBiometrics:i.enableBiometrics,enablePortScanning:i.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${r}`)}}}class Pt{constructor(r){Y(this,"currentTheme",ne);Y(this,"customStyleElement",null);Y(this,"container");this.container=r||document.documentElement}applyTheme(r){this.currentTheme=this.mergeWithDefault(r),this.applyColors(this.currentTheme.colors),this.currentTheme.typography&&this.applyTypography(this.currentTheme.typography),this.currentTheme.spacing&&this.applySpacing(this.currentTheme.spacing),this.currentTheme.customCSS&&this.injectCustomCSS(this.currentTheme.customCSS),console.log("[ThemeManager] Theme applied:",this.currentTheme.name||"Custom")}applyColors(r){var a;const s={primary:r.primary,"primary-hover":r.primaryHover,"primary-light":r.primaryLight,"primary-dark":r.primaryDark,secondary:r.secondary,"secondary-hover":r.secondaryHover,success:r.success,warning:r.warning,danger:r.danger,info:r.info,background:r.background,surface:r.surface,border:r.border,"text-primary":r.textPrimary,"text-secondary":r.textSecondary,"text-muted":r.textMuted};Object.entries(s).forEach(([n,i])=>{this.container.style.setProperty(`--metakyc-${n}`,i)}),(a=this.currentTheme.darkMode)!=null&&a.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(r){Object.entries(r).forEach(([s,a])=>{if(a){const n=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)}})}applyTypography(r){r&&(r.fontFamily&&this.container.style.setProperty("--metakyc-font-family",r.fontFamily),r.headingFont&&this.container.style.setProperty("--metakyc-heading-font",r.headingFont),r.fontSize&&Object.entries(r.fontSize).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-size-${s}`,a)}),r.fontWeight&&Object.entries(r.fontWeight).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-weight-${s}`,a.toString())}))}applySpacing(r){r&&Object.entries(r).forEach(([s,a])=>{const n=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)})}injectCustomCSS(r){this.customStyleElement&&this.customStyleElement.remove(),this.customStyleElement=document.createElement("style"),this.customStyleElement.id="metakyc-custom-css",this.customStyleElement.textContent=r,document.head.appendChild(this.customStyleElement)}mergeWithDefault(r){var s;return{name:r.name||ne.name,title:r.title||ne.title,logo:{...ne.logo,...r.logo},colors:{...ne.colors,...r.colors},typography:r.typography?{...ne.typography,...r.typography}:ne.typography,spacing:r.spacing?{...ne.spacing,...r.spacing}:ne.spacing,customCSS:r.customCSS,darkMode:r.darkMode?{colors:{...(s=ne.darkMode)==null?void 0:s.colors,...r.darkMode.colors}}:ne.darkMode,applicantFormVisibleFields:r.applicantFormVisibleFields,applicantFormRequiredFields:r.applicantFormRequiredFields,allowedLanguages:r.allowedLanguages,applicantFormPages:r.applicantFormPages}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(ne)}cleanup(){this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(r){return r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const Ke=l.createContext(null),hr=({config:t,children:r})=>{const[s,a]=l.useState(null),n=l.useRef(!1),i=l.useRef(!1),o=l.useMemo(()=>{const u=new ct(t),p=new dt(u),v=new ut(u),w=new mt(u),x=new pt(u),h=new ht(u),g=new gt(u),k=new xt(u),y=new ft(u),m=new yt(u),I=new St(u),j=new Pt;return{httpClient:u,applicantService:p,questionnaireService:v,uploadDocumentService:w,appropriatenessTestService:x,overviewService:h,riskScoringService:g,identityService:k,baseInformationService:y,investorCategorizationService:m,themeService:I,themeManager:j}},[t]),c=l.useMemo(()=>({config:t,...o,currentTheme:s,createOrchestrator:()=>new It(o.applicantService,o.questionnaireService,o.uploadDocumentService,o.appropriatenessTestService,o.overviewService,o.riskScoringService,o.identityService,o.investorCategorizationService)}),[t,o,s]);return l.useEffect(()=>((async()=>{if(n.current||i.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}n.current=!0;try{if(t.theme){console.log("[MetaKYC] Applying static theme from config"),o.themeManager.applyTheme(t.theme),a(o.themeManager.getCurrentTheme()),i.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const p=await o.themeService.getThemeConfiguration();o.themeManager.applyTheme(p),a(o.themeManager.getCurrentTheme()),i.current=!0,console.log("[MetaKYC] Theme loaded and applied",p)}catch(p){console.warn("[MetaKYC] Failed to load theme, using default:",p),a(o.themeManager.getCurrentTheme()),i.current=!0}finally{n.current=!1}})(),()=>{o.themeManager.cleanup()}),[]),e.jsx(Ke.Provider,{value:c,children:r})};function de(){const t=l.useContext(Ke);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function Lt(t){return new Promise((r,s)=>{const a=new FileReader;a.readAsDataURL(t),a.onload=()=>{const i=a.result.split(",")[1];r(i)},a.onerror=n=>s(n)})}function gr(t,r){return t.size<=r}function xr(t,r){return r.split(",").map(a=>a.trim()).some(a=>{if(a.endsWith("/*")){const n=a.slice(0,-2);return t.type.startsWith(n)}return t.type===a})}function Me(t){if(t===0)return"0 Bytes";const r=1024,s=["Bytes","KB","MB","GB"],a=Math.floor(Math.log(t)/Math.log(r));return Math.round(t/Math.pow(r,a)*100)/100+" "+s[a]}function fr(t){return t}function ee(...t){return t.filter(Boolean).join(" ")}const Ee={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function Tt(t){try{localStorage.setItem(Ee.APPLICANT_ID,t.toString())}catch(r){console.warn("Failed to save applicant ID to storage:",r)}}function Mt(){try{const t=localStorage.getItem(Ee.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function Ot(){try{localStorage.removeItem(Ee.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function zt(t){try{localStorage.setItem(Ee.WORKFLOW_STATE,JSON.stringify(t))}catch(r){console.warn("Failed to save workflow state to storage:",r)}}function yr(){try{const t=localStorage.getItem(Ee.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function Bt(){try{localStorage.removeItem(Ee.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function br(){Ot(),Bt()}function $t(t){const{createOrchestrator:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(null),u=l.useRef(null),p=t||Mt();l.useEffect(()=>{u.current||(u.current=r())},[r]),l.useEffect(()=>{var j;s&&p&&(Tt(p),zt({applicantId:p,currentStepOrder:(j=s.currentStep)==null?void 0:j.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,p]);const v=l.useRef(!1),w=l.useRef(!1),x=l.useCallback(async()=>{if(!(!p||!u.current)){if(v.current){console.log("[Workflow] Load already in progress, skipping...");return}v.current=!0,i(!0),c(null);try{const j=await u.current.initialize(p);a(j),w.current=!0}catch(j){c(j)}finally{i(!1),v.current=!1}}},[p]);l.useEffect(()=>{p&&!w.current&&x()},[p,x]);const h=l.useCallback(async()=>{if(u.current){if(v.current){console.log("[Workflow] Refresh already in progress, skipping...");return}v.current=!0,i(!0),c(null);try{const j=await u.current.refreshProgress();a(j)}catch(j){c(j)}finally{i(!1),v.current=!1}}},[]),g=l.useCallback(async()=>{if(u.current){i(!0),c(null);try{const j=await u.current.moveToNextStep();a(j)}catch(j){c(j)}finally{i(!1)}}},[]),k=l.useCallback(async()=>{if(u.current){i(!0),c(null);try{const j=await u.current.moveToPreviousStep();a(j)}catch(j){c(j)}finally{i(!1)}}},[]),y=l.useCallback(async j=>{if(u.current){i(!0),c(null);try{await u.current.submitCurrentStep(j);const b=await u.current.refreshProgress();a(b)}catch(b){throw c(b),b}finally{i(!1)}}},[]),m=Ye.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((j,b)=>j.order-b.order):[],[s==null?void 0:s.stepInfoList]),I=Ye.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:p,currentStep:(s==null?void 0:s.currentStep)||null,steps:m,status:(s==null?void 0:s.status)||me.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:I,isLoading:n,error:o,isComplete:(s==null?void 0:s.status)===me.Finished,isOnHold:(s==null?void 0:s.status)===me.OnHold,refreshProgress:h,moveToNext:g,moveBack:k,submitCurrentStep:y,orchestrator:u.current}}function Ut(t){const{questionnaireService:r,applicantService:s}=de(),[a,n]=l.useState(null),[i,o]=l.useState({}),[c,u]=l.useState(!1),[p,v]=l.useState(!1),[w,x]=l.useState(null),h=l.useRef(!1),g=l.useRef(null),k=l.useCallback(async()=>{var m,I;if(t){if(h.current){console.log("[Questionnaire] Load already in progress, skipping...");return}h.current=!0,u(!0),x(null);try{const[j,b]=await Promise.all([r.getQuestionnaire(t),s.getApplicantData(t).catch(()=>null)]);if(n(j),(m=b==null?void 0:b.questionnaireResults)!=null&&m.length&&j){const U=new Map;for(const f of b.questionnaireResults)f.question&&((I=f.answers)!=null&&I.length)&&U.set(f.question.trim().toLowerCase(),f.answers);const q={},L=j.questionGroups.flatMap(f=>f.questions??[]);for(const f of L){const S=f.text.trim().toLowerCase();U.has(S)&&(q[f.id]=U.get(S))}o(q)}g.current=t}catch(j){x(j)}finally{u(!1),h.current=!1}}},[t,r,s]);l.useEffect(()=>{t&&g.current!==t&&k()},[t]);const y=l.useCallback(async m=>{v(!0),x(null);try{return await r.fillQuestionnaire(m)}catch(I){throw x(I),I}finally{v(!1)}},[r]);return{questionnaire:a,initialAnswers:i,isLoading:c,isSubmitting:p,error:w,load:k,submit:y}}function _t(t){const{uploadDocumentService:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(!1),[u,p]=l.useState(0),[v,w]=l.useState(null),x=l.useRef(!1),h=l.useRef(null),g=l.useCallback(async()=>{if(t){if(x.current){console.log("[UploadDocument] Load already in progress, skipping...");return}x.current=!0,i(!0),w(null);try{const y=await r.getUploadDocument(t);a(y),h.current=t}catch(y){w(y)}finally{i(!1),x.current=!1}}},[t,r]);l.useEffect(()=>{t&&h.current!==t&&g()},[t]);const k=l.useCallback(async y=>{c(!0),p(0),w(null);try{await r.fillUploadDocument(y),p(100)}catch(m){throw w(m),m}finally{c(!1)}},[r]);return{uploadDocument:s,isLoading:n,isSubmitting:o,uploadProgress:u,error:v,load:g,submit:k}}function vr(t){const{appropriatenessTestService:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(!1),[u,p]=l.useState(null),[v,w]=l.useState(null),x=l.useRef(!1),h=l.useRef(null),g=l.useCallback(async()=>{if(t){if(x.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}x.current=!0,i(!0),p(null);try{const y=await r.getAppropriatenessTest(t);a(y),h.current=t}catch(y){p(y)}finally{i(!1),x.current=!1}}},[t,r]);l.useEffect(()=>{t&&h.current!==t&&g()},[t]);const k=l.useCallback(async y=>{c(!0),p(null);try{const m=await r.fillAppropriatenessTest(y);return w(m),m}catch(m){throw p(m),m}finally{c(!1)}},[r]);return{test:s,result:v,isLoading:n,isSubmitting:o,error:u,load:g,submit:k}}function Kt(t){const{overviewService:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(!1),[u,p]=l.useState(null),v=l.useRef(!1),w=l.useRef(null),x=l.useCallback(async()=>{if(t){if(v.current){console.log("[Overview] Load already in progress, skipping...");return}v.current=!0,i(!0),p(null);try{const g=await r.getOverviewData(t);a(g),w.current=t}catch(g){p(g)}finally{i(!1),v.current=!1}}},[t,r]);l.useEffect(()=>{t&&w.current!==t&&x()},[t]);const h=l.useCallback(async()=>{if(t){c(!0),p(null);try{await r.passOverview(t)}catch(g){throw p(g),g}finally{c(!1)}}},[t,r]);return{overview:s,isLoading:n,isSubmitting:o,error:u,load:x,passOverview:h}}function qt(t){const{identityService:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(null),u=l.useRef(!1),p=l.useCallback(async(x,h)=>{if(t){if(u.current){console.log("[Identity] Request already in progress, skipping...");return}u.current=!0,i(!0),c(null);try{const g={applicantId:t,restart:!1,redirectUrl:x||"",ttl:h||604800};console.log("Identity request input:",g);const k=await r.identityRequest(g);return console.log("Identity request result:",k),a(k),k}catch(g){throw c(g),g}finally{i(!1),u.current=!1}}},[t,r]),v=l.useCallback(async(x,h)=>{if(t){i(!0),c(null);try{const g={applicantId:t,restart:!1,redirectUrl:x,ttl:h},k=await r.identityCompanyRequest(g);return a(k),k}catch(g){throw c(g),g}finally{i(!1)}}},[t,r]),w=l.useCallback(async()=>{if(t){if(u.current){console.log("[Identity] Restart already in progress, skipping...");return}u.current=!0,i(!0),c(null);try{const x={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",x);const h=await r.identityRequest(x);return console.log("Restart identity result:",h),a(h),h}catch(x){throw c(x),x}finally{i(!1),u.current=!1}}},[t,r]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:n,error:o,requestIdentity:p,requestCompanyIdentity:v,restartIdentity:w}}function Ht(t){const{riskScoringService:r,applicantService:s}=de(),[a,n]=l.useState(null),[i,o]=l.useState({}),[c,u]=l.useState(!1),[p,v]=l.useState(!1),[w,x]=l.useState(null),[h,g]=l.useState(null),k=l.useRef(!1),y=l.useRef(null),m=l.useCallback(async()=>{var j;if(t){if(k.current){console.log("[RiskScoring] Load already in progress, skipping...");return}k.current=!0,u(!0),x(null);try{const[b,U]=await Promise.all([r.getRiskCriterias(t),s.getApplicantData(t).catch(()=>null)]);if(n(b),(j=U==null?void 0:U.riskScoringResults)!=null&&j.length){const q=U.riskScoringResults[0],L={};for(const f of q.riskCriteriaResults??[])if(f.riskCriteriaId!=null&&f.answer!=null&&f.answer!==""){const S=[...new Set(f.answer.split(",").map(R=>R.trim()).filter(R=>R!==""))];S.length>0&&(L[f.riskCriteriaId]=S)}o(L)}y.current=t}catch(b){x(b)}finally{u(!1),k.current=!1}}},[t,r,s]);l.useEffect(()=>{t&&y.current!==t&&m()},[t]);const I=l.useCallback(async j=>{v(!0),x(null);try{const b=await r.submitRiskScoring(j);return g(b),b}catch(b){throw x(b),b}finally{v(!1)}},[r]);return{criteria:a,initialAnswers:i,result:h,isLoading:c,isSubmitting:p,error:w,load:m,submit:I}}function Wt(){const{applicantService:t,config:r}=de(),[s,a]=l.useState(!1),[n,i]=l.useState(null),o=l.useRef(!1),c=l.useRef(!1),u=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(h){const g=Math.random()*16|0;return(h==="x"?g:g&3|8).toString(16)}),p=l.useCallback(async h=>{var g;if(o.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");o.current=!0,a(!0),i(null);try{if(h.applicantAdditionalDatas||(h.applicantAdditionalDatas=[]),(g=r.identityProviders)!=null&&g.sardinai){const y=u();console.log("[SardinAI] Generated session key:",y),h.applicantAdditionalDatas.push({paramName:"sessionKey",value:y})}return await t.createApplicant(h)}catch(k){throw i(k),k}finally{a(!1),o.current=!1}},[t,r]),v=l.useCallback(async h=>{a(!0),i(null);try{return await t.createCompanyApplicant(h)}catch(g){throw i(g),g}finally{a(!1)}},[t]),w=l.useCallback(async h=>{if(c.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");c.current=!0,a(!0),i(null);try{return await t.getApplicantData(h)}catch(g){throw i(g),g}finally{a(!1),c.current=!1}},[t]),x=l.useCallback(async h=>{a(!0),i(null);try{await t.stopProgress(h)}catch(g){throw i(g),g}finally{a(!1)}},[t]);return{isLoading:s,error:n,createApplicant:p,createCompanyApplicant:v,getApplicantData:w,stopProgress:x}}const B=({children:t,variant:r="primary",size:s="md",isLoading:a=!1,disabled:n,className:i,...o})=>{const c="inline-flex items-center justify-center rounded-lg font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",u={primary:"bg-primary-500 text-white hover:bg-primary-600 focus:ring-primary-500",secondary:"bg-gray-200 text-gray-900 hover:bg-gray-300 focus:ring-gray-400",outline:"border-2 border-primary-500 text-primary-500 hover:bg-primary-50 focus:ring-primary-500",danger:"bg-danger-500 text-white hover:bg-danger-600 focus:ring-danger-500",ghost:"text-gray-700 hover:bg-gray-100 focus:ring-gray-400"},p={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-base",lg:"px-6 py-3 text-lg"};return e.jsxs("button",{className:ee(c,u[r],p[s],i),disabled:n||a,...o,children:[a&&e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t]})},ie=l.forwardRef(({label:t,error:r,helperText:s,leftIcon:a,rightIcon:n,className:i,...o},c)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t,o.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"relative",children:[a&&e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:a}),e.jsx("input",{ref:c,className:ee("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","disabled:bg-gray-100 disabled:cursor-not-allowed",r?"border-danger-500 focus:ring-danger-500":"border-gray-300 dark:border-gray-600","dark:bg-gray-800 dark:text-white",a?"pl-10":"",n?"pr-10":"",i),...o}),n&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:n})]}),r&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s})]}));ie.displayName="Input";const M=({children:t,className:r,...s})=>e.jsx("div",{className:ee("metakyc-card rounded-xl shadow-sm border",r),style:{backgroundColor:"var(--metakyc-surface, #ffffff)",borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),se=({children:t,className:r,...s})=>e.jsx("div",{className:ee("px-6 py-4 border-b",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),O=({children:t,className:r,...s})=>e.jsx("div",{className:ee("px-6 py-4",r),...s,children:t}),le=({children:t,className:r,...s})=>e.jsx("div",{className:ee("px-6 py-4 border-t",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),fe=({children:t,variant:r="default",className:s,...a})=>{const n={default:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",success:"bg-success-100 text-success-800 dark:bg-success-900 dark:text-success-300",danger:"bg-danger-100 text-danger-800 dark:bg-danger-900 dark:text-danger-300",warning:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300",info:"bg-primary-100 text-primary-800 dark:bg-primary-900 dark:text-primary-300"};return e.jsx("span",{className:ee("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",n[r],s),...a,children:t})},pe=({size:t="md",className:r,...s})=>{const a={sm:"h-4 w-4",md:"h-8 w-8",lg:"h-12 w-12"};return e.jsx("div",{className:ee("flex items-center justify-center",r),...s,children:e.jsxs("svg",{className:ee("animate-spin text-primary-500",a[t]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})},be=l.forwardRef(({label:t,error:r,helperText:s,options:a,placeholder:n,className:i,style:o,...c},u)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,c.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("select",{ref:u,className:ee("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-offset-0","disabled:opacity-60 disabled:cursor-not-allowed",r?"border-danger-500":"",i),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-primary, #111827)",borderColor:r?"var(--metakyc-error, #ef4444)":"var(--metakyc-border, #d1d5db)",...o},...c,children:[n&&e.jsx("option",{value:"",disabled:!0,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-secondary, #6b7280)"},children:n},"__placeholder__"),a.map((p,v)=>e.jsx("option",{value:p.value,disabled:p.disabled,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:p.disabled?"var(--metakyc-text-secondary, #9ca3af)":"var(--metakyc-text-primary, #111827)"},children:p.label},p.value||`option-${v}`))]}),r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-error, #ef4444)"},children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s})]}));be.displayName="Select";const Yt=({label:t,value:r,onChange:s,options:a,placeholder:n="Select...",disabled:i=!1,required:o=!1})=>{const[c,u]=l.useState(!1),[p,v]=l.useState(""),w=l.useRef(null);l.useEffect(()=>{const y=m=>{w.current&&!w.current.contains(m.target)&&(u(!1),v(""))};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]);const x=a.filter(y=>y.label.toLowerCase().includes(p.toLowerCase())),h=y=>{i||(r.includes(y)?s(r.filter(m=>m!==y)):s([...r,y]))},g=(y,m)=>{m.stopPropagation(),i||s(r.filter(I=>I!==y))},k=y=>{var m;return((m=a.find(I=>I.value===y))==null?void 0:m.label)||y};return e.jsxs("div",{className:"w-full metakyc-multiselect",ref:w,children:[t&&e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t,o&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{onClick:()=>!i&&u(!c),className:ee("metakyc-multiselect-trigger","min-h-[42px] w-full px-3 py-2 rounded-lg border text-sm transition-colors","bg-white dark:bg-gray-800","border-gray-300 dark:border-gray-600",c&&"ring-2 ring-blue-500 border-transparent",i?"opacity-50 cursor-not-allowed":"cursor-pointer"),children:[r.length===0?e.jsx("span",{className:"metakyc-multiselect-placeholder text-gray-400 dark:text-gray-500 leading-6",children:n}):e.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:r.map(y=>e.jsxs("span",{className:"metakyc-multiselect-chip inline-flex items-center gap-1 px-2 py-0.5 rounded bg-blue-100 dark:bg-blue-900/40 text-blue-800 dark:text-blue-300 text-xs font-medium",children:[k(y),!i&&e.jsx("button",{type:"button",onClick:m=>g(y,m),className:"metakyc-multiselect-chip-remove",style:{background:"transparent",border:"none",padding:"0 0 0 2px",margin:0,cursor:"pointer",fontSize:"14px",lineHeight:1,fontWeight:"bold",display:"inline-flex",alignItems:"center",boxShadow:"none",transform:"none",minWidth:0,width:"auto",height:"auto",letterSpacing:"normal",textTransform:"none"},children:"×"})]},y))}),e.jsx("span",{className:"metakyc-multiselect-arrow absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none text-xs",children:c?"▲":"▼"})]}),c&&e.jsxs("div",{className:"metakyc-multiselect-dropdown absolute z-50 w-full mt-1 rounded-lg shadow-lg",style:{background:"inherit",border:"1px solid #d1d5db"},children:[e.jsx("div",{className:"metakyc-multiselect-search-wrapper p-2",style:{borderBottom:"1px solid #e5e7eb"},children:e.jsx("input",{type:"text",value:p,onChange:y=>v(y.target.value),placeholder:"Search...",autoFocus:!0,onClick:y=>y.stopPropagation(),className:"metakyc-multiselect-search w-full px-2 py-1.5 text-sm rounded focus:outline-none focus:ring-1 focus:ring-blue-500",style:{border:"1px solid #d1d5db"}})}),e.jsx("ul",{className:"max-h-48 overflow-y-auto py-1",children:x.length===0?e.jsx("li",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"No results"}):x.map(y=>e.jsxs("li",{onClick:()=>h(y.value),className:ee("metakyc-multiselect-option","flex items-center gap-2 px-3 py-2 text-sm cursor-pointer","hover:bg-gray-50 dark:hover:bg-gray-700",r.includes(y.value)&&"metakyc-multiselect-option-selected bg-blue-50 dark:bg-blue-900/20"),children:[e.jsx("input",{type:"checkbox",checked:r.includes(y.value),readOnly:!0,className:"rounded border-gray-300 text-blue-600 pointer-events-none"}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100",children:y.label})]},y.value))}),r.length>0&&e.jsx("div",{className:"metakyc-multiselect-clear p-2 border-t border-gray-100 dark:border-gray-700",children:e.jsxs("button",{type:"button",onClick:()=>{s([]),v("")},className:"text-xs text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:["Clear all (",r.length," selected)"]})})]})]})]})},Qt=({label:t,error:r,accept:s,multiple:a=!1,maxSize:n,onChange:i,value:o=[],className:c})=>{const[u,p]=l.useState(!1),v=l.useRef(null),w=m=>{if(!m)return;const I=Array.from(m);if(n&&I.filter(b=>b.size>n).length>0){const b=Me(n);alert(`Some files exceed the maximum size of ${b}`);return}i==null||i(a?[...o,...I]:[I[0]])},x=m=>{m.preventDefault(),p(!0)},h=()=>{p(!1)},g=m=>{m.preventDefault(),p(!1),w(m.dataTransfer.files)},k=()=>{var m;(m=v.current)==null||m.click()},y=m=>{const I=o.filter((j,b)=>b!==m);i==null||i(I)};return e.jsxs("div",{className:ee("w-full",c),children:[t&&e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t}),e.jsxs("div",{className:ee("border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors",u?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-300 dark:border-gray-600 hover:border-primary-500",r&&"border-danger-500"),onDragOver:x,onDragLeave:h,onDrop:g,onClick:k,children:[e.jsx("input",{ref:v,type:"file",className:"hidden",accept:s,multiple:a,onChange:m=>w(m.target.files)}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",stroke:"currentColor",fill:"none",viewBox:"0 0 48 48",children:e.jsx("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("span",{className:"font-medium text-primary-500",children:"Click to upload"})," or drag and drop"]}),n&&e.jsxs("p",{className:"text-xs text-gray-500",children:["Maximum file size: ",Me(n)]})]})]}),o.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:o.map((m,I)=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsxs("div",{className:"flex items-center space-x-2 flex-1 min-w-0",children:[e.jsx("svg",{className:"h-5 w-5 text-gray-400 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",children:m.name}),e.jsxs("span",{className:"text-xs text-gray-500",children:["(",Me(m.size),")"]})]}),e.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),y(I)},className:"ml-2 text-danger-500 hover:text-danger-700 focus:outline-none",children:e.jsx("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]},I))}),r&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:r})]})},Vt=l.forwardRef(({countryCode:t="+1",onCountryCodeChange:r,className:s,...a},n)=>e.jsxs("div",{className:"w-full",children:[a.label&&e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[a.label,a.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:i=>r==null?void 0:r(i.target.value),className:ee("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white"),placeholder:"+1"}),e.jsx(ie,{ref:n,type:"tel",className:ee("flex-1",s),...a,label:""})]}),a.error&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:a.error})]}));Vt.displayName="PhoneInput";/**
|
|
2
2
|
* @license lucide-react v0.574.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const Gt=(...t)=>t.filter((r,s,a)=>!!r&&r.trim()!==""&&a.indexOf(r)===s).join(" ").trim();/**
|
|
7
7
|
* @license lucide-react v0.574.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const
|
|
11
|
+
*/const kr=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
|
|
12
12
|
* @license lucide-react v0.574.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const wr=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,s,a)=>a?a.toUpperCase():s.toLowerCase());/**
|
|
17
17
|
* @license lucide-react v0.574.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const Qe=t=>{const r=wr(t);return r.charAt(0).toUpperCase()+r.slice(1)};/**
|
|
22
22
|
* @license lucide-react v0.574.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/var
|
|
26
|
+
*/var jr={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
27
27
|
* @license lucide-react v0.574.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const
|
|
31
|
+
*/const Nr=t=>{for(const r in t)if(r.startsWith("aria-")||r==="role"||r==="title")return!0;return!1};/**
|
|
32
32
|
* @license lucide-react v0.574.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const
|
|
36
|
+
*/const Sr=l.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:s=2,absoluteStrokeWidth:a,className:n="",children:i,iconNode:o,...c},u)=>l.createElement("svg",{ref:u,...jr,width:r,height:r,stroke:t,strokeWidth:a?Number(s)*24/Number(r):s,className:Gt("lucide",n),...!i&&!Nr(c)&&{"aria-hidden":"true"},...c},[...o.map(([p,v])=>l.createElement(p,v)),...Array.isArray(i)?i:[i]]));/**
|
|
37
37
|
* @license lucide-react v0.574.0 - ISC
|
|
38
38
|
*
|
|
39
39
|
* This source code is licensed under the ISC license.
|
|
40
40
|
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const
|
|
41
|
+
*/const Zt=(t,r)=>{const s=l.forwardRef(({className:a,...n},i)=>l.createElement(Sr,{ref:i,iconNode:r,className:Gt(`lucide-${kr(Qe(t))}`,`lucide-${t}`,a),...n}));return s.displayName=Qe(t),s};/**
|
|
42
42
|
* @license lucide-react v0.574.0 - ISC
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the ISC license.
|
|
45
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const
|
|
46
|
+
*/const Cr=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Jt=Zt("chevron-left",Cr);/**
|
|
47
47
|
* @license lucide-react v0.574.0 - ISC
|
|
48
48
|
*
|
|
49
49
|
* This source code is licensed under the ISC license.
|
|
50
50
|
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const jr=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Vt=Yt("chevron-right",jr);function Nr(t,r){const s=!r||r.length===0||r.every(a=>!a||!a.trim());if(t.isRequired&&s)return t.errorMessage||"This field is required";if(!s){const a=r[0]??"";if(a&&t.regex)try{if(!new RegExp(t.regex).test(a))return t.errorMessage||"Invalid format"}catch{}if(a!==""){const n=Number(a);if(!isNaN(n)&&a.trim()!==""){if(t.min!==void 0&&t.min!==null&&n<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&n>t.max)return`Maximum value is ${t.max}`}else{if(t.min!==void 0&&t.min!==null&&a.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&a.length>t.max)return`Maximum length is ${t.max} characters`}}}return null}function Sr(t){const r=t.flatMap((a,n)=>(a.questions??[]).map((i,o)=>({question:i,groupIndex:n,qIdx:o}))),s=new Map;for(const a of r){const n=a.question.pageNumber!=null&&a.question.pageNumber>0?a.question.pageNumber:1;s.has(n)||s.set(n,[]),s.get(n).push(a)}return Array.from(s.entries()).sort(([a],[n])=>a-n).map(([,a])=>a)}const Gt=({applicantId:t,onComplete:r,onBack:s})=>{const{questionnaire:a,initialAnswers:n,isLoading:i,isSubmitting:o,error:c,submit:d}=Ot(t),[m,v]=l.useState({}),[w,x]=l.useState({}),[h,g]=l.useState(0);l.useEffect(()=>{n&&Object.keys(n).length>0&&Object.keys(m).length===0&&v(n)},[n]);const k=l.useMemo(()=>a?Sr(a.questionGroups):[],[a]),f=h===k.length-1,p=k[h]??[],R=l.useCallback((P,y)=>{v(S=>({...S,[P]:y})),x(S=>{const I={...S};return delete I[P],I})},[]),N=l.useCallback(()=>{const P={};for(const{question:y}of p){const S=Nr(y,m[y.id]??[]);S&&(P[y.id]=S)}return x(y=>({...y,...P})),Object.keys(P).length===0},[p,m]),b=()=>{N()&&g(P=>P+1)},_=()=>{h>0?g(P=>P-1):s==null||s()},W=async()=>{if(!(!N()||!a))try{const P=a.questionGroups.flatMap(S=>(S.questions??[]).map(I=>({questionId:I.id,values:m[I.id]??[]}))),y={applicantId:t,questionnarieId:a.id,questionResults:P};await d(y),r==null||r()}catch(P){console.error("Questionnaire submit error:",P)}};return i?e.jsx(T,{children:e.jsx(M,{children:e.jsx(pe,{className:"my-8"})})}):c?e.jsx(T,{children:e.jsx(M,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading questionnaire: ",c.message]})})}):a?e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.displayName}),a.subtitle&&e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a.subtitle}),k.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",h+1," of ",k.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:k.map((P,y)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:y===h?"20px":"6px",backgroundColor:y<=h?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},y))})]})]}),e.jsx(M,{className:"space-y-6",children:p.map(({question:P})=>e.jsx(Cr,{question:P,value:m[P.id]??[],error:w[P.id],onChange:y=>R(P.id,y)},P.id))}),e.jsxs(le,{className:"flex items-center justify-between",children:[e.jsxs(B,{type:"button",variant:"outline",onClick:_,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Qt,{size:14}),h>0?"Previous":"Back"]}),f?e.jsx(B,{type:"button",isLoading:o,onClick:W,children:"Continue"}):e.jsxs(B,{type:"button",onClick:b,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(Vt,{size:14})]})]}),c&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:c.message})})]}):null},Cr=({question:t,value:r,error:s,onChange:a})=>{var o;const i=(((o=t.defaultAnswers)==null?void 0:o.length)??0)>0?t.showAsDropdown?t.canMultipleAnswer?"multi-select":"single-select":t.canMultipleAnswer?"checkbox":"radio":"text";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.text,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.subtitle&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.subtitle}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.description}),i==="text"&&e.jsx(ie,{value:r[0]??"",onChange:c=>a([c.target.value]),placeholder:t.subtitle?void 0:"Enter your answer…",error:s,required:t.isRequired}),i==="single-select"&&e.jsx(be,{value:r[0]??"",onChange:c=>a([c.target.value]),options:(t.defaultAnswers??[]).map(c=>({value:c,label:c})),placeholder:"Select an option…",error:s,required:t.isRequired}),i==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(c=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===c,onChange:()=>a([c]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:c})]},c)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),(i==="checkbox"||i==="multi-select")&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(c=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(c),onChange:d=>{d.target.checked?a([...r,c]):a(r.filter(m=>m!==c))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:c})]},c)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),s&&i==="text"&&null]})},Zt=({applicantId:t,onComplete:r,onBack:s})=>{const{uploadDocument:a,isLoading:n,isSubmitting:i,error:o,submit:c}=zt(t),[d,m]=l.useState({}),v=async w=>{if(w.preventDefault(),!a)return;const x=await Promise.all(a.uploadDocumentFiles.map(async g=>{const k=d[g.id]||[],f=await Promise.all(k.map(async p=>({fileName:p.name,fileData:await It(p)})));return{uploadDocumentFileId:g.id,valueList:f}})),h={applicantId:t,uploadDocumentId:a.id,uploadDocumentResults:x};await c(h),r==null||r()};return n?e.jsx(T,{children:e.jsx(M,{children:e.jsx(pe,{className:"my-8"})})}):o?e.jsx(T,{children:e.jsx(M,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading document requirements: ",o.message]})})}):a?e.jsx("form",{onSubmit:v,children:e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.displayName}),a.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:a.subtitle})]}),e.jsx(M,{className:"space-y-6",children:a.uploadDocumentFiles.map(w=>e.jsx(qt,{label:w.displayName,accept:w.allowedTypes,multiple:w.multipleFile,maxSize:w.maxEachFileSizeByte,value:d[w.id]||[],onChange:x=>{m(h=>({...h,[w.id]:x}))}},w.id))}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(B,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(B,{type:"submit",isLoading:i,children:"Continue"})]})]})}):null},Jt=({applicantId:t,onComplete:r,onBack:s})=>{const{overview:a,isLoading:n,isSubmitting:i,error:o,passOverview:c}=Bt(t),d=async()=>{await c(),r==null||r()};return n?e.jsx(T,{children:e.jsx(M,{children:e.jsx(pe,{className:"my-8"})})}):o?e.jsx(T,{children:e.jsx(M,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading overview: ",o.message]})})}):a?e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.title||"Overview"}),a.description&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:a.description})]}),e.jsx(M,{className:"space-y-8",children:a.steps&&a.steps.length>0?a.steps.sort((m,v)=>m.order-v.order).map(m=>e.jsxs("div",{className:"metakyc-overview-step-item flex items-center space-x-3",children:[e.jsx("div",{className:"metakyc-step-icon flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary-500 text-white flex items-center justify-center font-medium text-sm",children:m.order+1})}),e.jsxs("div",{className:"metakyc-step-content",style:{flex:1,border:"none",height:"auto",background:"transparent"},children:[e.jsx("span",{className:"metakyc-step-title text-sm font-semibold text-gray-900 dark:text-white",children:m.title}),m.description&&e.jsx("p",{className:"metakyc-step-description text-sm text-gray-600 dark:text-gray-400",children:m.description})]})]},m.order)):e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Loading overview data..."})})}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(B,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(B,{onClick:d,isLoading:i,children:"Continue"})]})]}):null};function Ar(t,r){const s=!r||r.length===0||r.every(a=>!a||!a.trim());if(t.isRequired&&s)return t.errorMessage||`${t.displayName} is required`;if(!s){const a=r[0]??"";if(a&&t.regex)try{if(!new RegExp(t.regex).test(a))return t.errorMessage||"Invalid format"}catch{}const n=t.valueDataType===fe.Integer||t.valueDataType===fe.Decimal||t.valueDataType===fe.DigitOnly;if(n&&a.trim()!==""){const i=Number(a);if(!isNaN(i)){if(t.min!==void 0&&t.min!==null&&i<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&i>t.max)return`Maximum value is ${t.max}`}}else if(!n&&a!==""){if(t.min!==void 0&&t.min!==null&&a.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&a.length>t.max)return`Maximum length is ${t.max} characters`}}return null}function Er(t){const r=new Map;return t.forEach((s,a)=>{const n=s.pageNumber!=null&&s.pageNumber>0?s.pageNumber:1;r.has(n)||r.set(n,[]),r.get(n).push({criterion:s,idx:a})}),Array.from(r.entries()).sort(([s],[a])=>s-a).map(([,s])=>s)}function Rr(t){return t.builtInType===1?"country":!t.defaultValues||t.defaultValues.length===0?"text":t.multipleValue?"checkbox":"radio"}const Xt=({applicantId:t,onComplete:r,onBack:s})=>{const{criteria:a,initialAnswers:n,isLoading:i,isSubmitting:o,error:c,submit:d}=Ut(t),[m,v]=l.useState({}),[w,x]=l.useState({}),[h,g]=l.useState(0),[k,f]=l.useState(!1);l.useEffect(()=>{n&&Object.keys(n).length>0&&Object.keys(m).length===0&&v(n)},[n]);const p=l.useMemo(()=>a&&a.length>0?Er(a):[],[a]),R=h===p.length-1,N=p[h]??[];l.useEffect(()=>{!i&&a&&a.length===0&&!k&&!o&&(f(!0),d({applicantId:t,criteriaValueInputs:[]}).then(()=>r==null?void 0:r()).catch(console.error))},[i,a,k,o,d,t,r]);const b=l.useCallback((S,I)=>{v(Y=>({...Y,[S]:I})),x(Y=>{const q={...Y};return delete q[S],q})},[]),_=l.useCallback(()=>{const S={};for(const{criterion:I}of N){const Y=Ar(I,m[I.id]??[]);Y&&(S[I.id]=Y)}return x(I=>({...I,...S})),Object.keys(S).length===0},[N,m]),W=()=>{_()&&g(S=>S+1)},P=()=>{h>0?g(S=>S-1):s==null||s()},y=async()=>{if(!(!_()||!a))try{const S=a.map(Y=>{const q=(m[Y.id]??[]).filter(D=>D&&D.trim());return q.length>0?{riskCriteriaId:Y.id,values:q}:null}).filter(Y=>Y!==null);await d({applicantId:t,criteriaValueInputs:S}),r==null||r()}catch(S){console.error("Risk scoring submit error:",S)}};return i?e.jsx(T,{children:e.jsxs(M,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading risk scoring criteria…"})]})}):!i&&a&&a.length===0?e.jsx(T,{children:e.jsxs(M,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"No criteria required. Moving to next step…"})]})}):c?e.jsx(T,{children:e.jsx(M,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading criteria: ",c.message]})})}):a?e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Risk Assessment"}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please answer the following questions for risk evaluation"}),p.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",h+1," of ",p.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:p.map((S,I)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:I===h?"20px":"6px",backgroundColor:I<=h?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},I))})]})]}),e.jsx(M,{className:"space-y-6",children:N.map(({criterion:S})=>e.jsx(Ir,{criterion:S,value:m[S.id]??[],error:w[S.id],onChange:I=>b(S.id,I)},S.id))}),e.jsxs(le,{className:"flex items-center justify-between",children:[e.jsxs(B,{type:"button",variant:"outline",onClick:P,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Qt,{size:14}),h>0?"Previous":"Back"]}),R?e.jsx(B,{type:"button",isLoading:o,onClick:y,children:"Continue"}):e.jsxs(B,{type:"button",onClick:W,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(Vt,{size:14})]})]}),c&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:c.message})})]}):null},Ir=({criterion:t,value:r,error:s,onChange:a})=>{const n=Rr(t),i=t.valueDataType===fe.Integer||t.valueDataType===fe.Decimal||t.valueDataType===fe.DigitOnly;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.displayName,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.description}),i&&(t.min!==void 0||t.max!==void 0)&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.min!==void 0&&t.max!==void 0?`Range: ${t.min} – ${t.max}`:t.min!==void 0?`Minimum: ${t.min}`:`Maximum: ${t.max}`}),n==="text"&&e.jsx(ie,{value:r[0]??"",onChange:o=>a([o.target.value]),type:i?"number":"text",placeholder:"Enter your answer…",error:s,required:t.isRequired,min:t.min,max:t.max,onKeyDown:o=>{t.valueDataType===fe.DigitOnly&&["e","E","+","-","."].includes(o.key)&&o.preventDefault()}}),n==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(o=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===o,onChange:()=>a([o]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:o})]},o)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),n==="checkbox"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(o=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(o),onChange:c=>{c.target.checked?a([...r,o]):a(r.filter(d=>d!==o))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:o})]},o)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),n==="country"&&e.jsx(be,{value:r[0]??"",onChange:o=>a([o.target.value]),options:[{value:"US",label:"United States"},{value:"GB",label:"United Kingdom"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"AE",label:"United Arab Emirates"}],placeholder:"Select a country…",error:s,required:t.isRequired})]})},er=({applicantId:t,onComplete:r,onBack:s})=>{const{investorCategorizationService:a}=de(),[n,i]=l.useState(null),[o,c]=l.useState(!1),[d,m]=l.useState(null),v=async w=>{if(w.preventDefault(),n===null){m("Please select an investor type");return}c(!0),m(null);try{const x={applicantId:t,investorType:n};console.log("Submitting investor categorization:",x);const h=await a.setInvestorCategorization(x);console.log("Investor categorization result:",h),r==null||r()}catch(x){console.error("Error submitting investor categorization:",x),m(x.message||"Failed to submit investor categorization")}finally{c(!1)}};return e.jsx("form",{onSubmit:v,children:e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:"Which statement best describes you?"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:"All Tokenise clients are treated as Retail Investors under EU regulation, which gives you the highest level of investor protection. For our internal purposes, we ask you to select the description that best matches your situation"})]}),e.jsxs(M,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:"Choose one"}),e.jsx("label",{className:`
|
|
51
|
+
*/const Ar=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Xt=Zt("chevron-right",Ar);function Er(t,r){const s=!r||r.length===0||r.every(a=>!a||!a.trim());if(t.isRequired&&s)return t.errorMessage||"This field is required";if(!s){const a=r[0]??"";if(a&&t.regex)try{if(!new RegExp(t.regex).test(a))return t.errorMessage||"Invalid format"}catch{}if(a!==""){const n=Number(a);if(!isNaN(n)&&a.trim()!==""){if(t.min!==void 0&&t.min!==null&&n<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&n>t.max)return`Maximum value is ${t.max}`}else{if(t.min!==void 0&&t.min!==null&&a.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&a.length>t.max)return`Maximum length is ${t.max} characters`}}}return null}function Ir(t){const r=t.flatMap((a,n)=>(a.questions??[]).map((i,o)=>({question:i,groupIndex:n,qIdx:o}))),s=new Map;for(const a of r){const n=a.question.pageNumber!=null&&a.question.pageNumber>0?a.question.pageNumber:1;s.has(n)||s.set(n,[]),s.get(n).push(a)}return Array.from(s.entries()).sort(([a],[n])=>a-n).map(([,a])=>a)}const er=({applicantId:t,onComplete:r,onBack:s})=>{const{questionnaire:a,initialAnswers:n,isLoading:i,isSubmitting:o,error:c,submit:u}=Ut(t),[p,v]=l.useState({}),[w,x]=l.useState({}),[h,g]=l.useState(0);l.useEffect(()=>{n&&Object.keys(n).length>0&&Object.keys(p).length===0&&v(n)},[n]);const k=l.useMemo(()=>a?Ir(a.questionGroups):[],[a]),y=h===k.length-1,m=k[h]??[],I=l.useCallback((L,f)=>{v(S=>({...S,[L]:f})),x(S=>{const R={...S};return delete R[L],R})},[]),j=l.useCallback(()=>{const L={};for(const{question:f}of m){const S=Er(f,p[f.id]??[]);S&&(L[f.id]=S)}return x(f=>({...f,...L})),Object.keys(L).length===0},[m,p]),b=()=>{j()&&g(L=>L+1)},U=()=>{h>0?g(L=>L-1):s==null||s()},q=async()=>{if(!(!j()||!a))try{const L=a.questionGroups.flatMap(S=>(S.questions??[]).map(R=>({questionId:R.id,values:p[R.id]??[]}))),f={applicantId:t,questionnarieId:a.id,questionResults:L};await u(f),r==null||r()}catch(L){console.error("Questionnaire submit error:",L)}};return i?e.jsx(M,{children:e.jsx(O,{children:e.jsx(pe,{className:"my-8"})})}):c?e.jsx(M,{children:e.jsx(O,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading questionnaire: ",c.message]})})}):a?e.jsxs(M,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.displayName}),a.subtitle&&e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a.subtitle}),k.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",h+1," of ",k.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:k.map((L,f)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:f===h?"20px":"6px",backgroundColor:f<=h?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},f))})]})]}),e.jsx(O,{className:"space-y-6",children:m.map(({question:L})=>e.jsx(Rr,{question:L,value:p[L.id]??[],error:w[L.id],onChange:f=>I(L.id,f)},L.id))}),e.jsxs(le,{className:"flex items-center justify-between",children:[e.jsxs(B,{type:"button",variant:"outline",onClick:U,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Jt,{size:14}),h>0?"Previous":"Back"]}),y?e.jsx(B,{type:"button",isLoading:o,onClick:q,children:"Continue"}):e.jsxs(B,{type:"button",onClick:b,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(Xt,{size:14})]})]}),c&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:c.message})})]}):null},Rr=({question:t,value:r,error:s,onChange:a})=>{var o;const i=(((o=t.defaultAnswers)==null?void 0:o.length)??0)>0?t.showAsDropdown?t.canMultipleAnswer?"multi-select":"single-select":t.canMultipleAnswer?"checkbox":"radio":"text";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.text,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.subtitle&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.subtitle}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.description}),i==="text"&&e.jsx(ie,{value:r[0]??"",onChange:c=>a([c.target.value]),placeholder:t.subtitle?void 0:"Enter your answer…",error:s,required:t.isRequired}),i==="single-select"&&e.jsx(be,{value:r[0]??"",onChange:c=>a([c.target.value]),options:(t.defaultAnswers??[]).map(c=>({value:c,label:c})),placeholder:"Select an option…",error:s,required:t.isRequired}),i==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(c=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===c,onChange:()=>a([c]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:c})]},c)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),(i==="checkbox"||i==="multi-select")&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(c=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(c),onChange:u=>{u.target.checked?a([...r,c]):a(r.filter(p=>p!==c))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:c})]},c)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),s&&i==="text"&&null]})},tr=({applicantId:t,onComplete:r,onBack:s})=>{const{uploadDocument:a,isLoading:n,isSubmitting:i,error:o,submit:c}=_t(t),[u,p]=l.useState({}),v=async w=>{if(w.preventDefault(),!a)return;const x=await Promise.all(a.uploadDocumentFiles.map(async g=>{const k=u[g.id]||[],y=await Promise.all(k.map(async m=>({fileName:m.name,fileData:await Lt(m)})));return{uploadDocumentFileId:g.id,valueList:y}})),h={applicantId:t,uploadDocumentId:a.id,uploadDocumentResults:x};await c(h),r==null||r()};return n?e.jsx(M,{children:e.jsx(O,{children:e.jsx(pe,{className:"my-8"})})}):o?e.jsx(M,{children:e.jsx(O,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading document requirements: ",o.message]})})}):a?e.jsx("form",{onSubmit:v,children:e.jsxs(M,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.displayName}),a.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:a.subtitle})]}),e.jsx(O,{className:"space-y-6",children:a.uploadDocumentFiles.map(w=>e.jsx(Qt,{label:w.displayName,accept:w.allowedTypes,multiple:w.multipleFile,maxSize:w.maxEachFileSizeByte,value:u[w.id]||[],onChange:x=>{p(h=>({...h,[w.id]:x}))}},w.id))}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(B,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(B,{type:"submit",isLoading:i,children:"Continue"})]})]})}):null},rr=({applicantId:t,onComplete:r,onBack:s})=>{const{overview:a,isLoading:n,isSubmitting:i,error:o,passOverview:c}=Kt(t),u=async()=>{await c(),r==null||r()};return n?e.jsx(M,{children:e.jsx(O,{children:e.jsx(pe,{className:"my-8"})})}):o?e.jsx(M,{children:e.jsx(O,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading overview: ",o.message]})})}):a?e.jsxs(M,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.title||"Overview"}),a.description&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:a.description})]}),e.jsx(O,{className:"space-y-8",children:a.steps&&a.steps.length>0?a.steps.sort((p,v)=>p.order-v.order).map(p=>e.jsxs("div",{className:"metakyc-overview-step-item flex items-center space-x-3",children:[e.jsx("div",{className:"metakyc-step-icon flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary-500 text-white flex items-center justify-center font-medium text-sm",children:p.order+1})}),e.jsxs("div",{className:"metakyc-step-content",style:{flex:1,border:"none",height:"auto",background:"transparent"},children:[e.jsx("span",{className:"metakyc-step-title text-sm font-semibold text-gray-900 dark:text-white",children:p.title}),p.description&&e.jsx("p",{className:"metakyc-step-description text-sm text-gray-600 dark:text-gray-400",children:p.description})]})]},p.order)):e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Loading overview data..."})})}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(B,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(B,{onClick:u,isLoading:i,children:"Continue"})]})]}):null};function Dr(t,r){const s=!r||r.length===0||r.every(a=>!a||!a.trim());if(t.isRequired&&s)return t.errorMessage||`${t.displayName} is required`;if(!s){const a=r[0]??"";if(a&&t.regex)try{if(!new RegExp(t.regex).test(a))return t.errorMessage||"Invalid format"}catch{}const n=t.valueDataType===ye.Integer||t.valueDataType===ye.Decimal||t.valueDataType===ye.DigitOnly;if(n&&a.trim()!==""){const i=Number(a);if(!isNaN(i)){if(t.min!==void 0&&t.min!==null&&i<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&i>t.max)return`Maximum value is ${t.max}`}}else if(!n&&a!==""){if(t.min!==void 0&&t.min!==null&&a.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&a.length>t.max)return`Maximum length is ${t.max} characters`}}return null}function Fr(t){const r=new Map;return t.forEach((s,a)=>{const n=s.pageNumber!=null&&s.pageNumber>0?s.pageNumber:1;r.has(n)||r.set(n,[]),r.get(n).push({criterion:s,idx:a})}),Array.from(r.entries()).sort(([s],[a])=>s-a).map(([,s])=>s)}function Pr(t){return t.builtInType===1?"country":!t.defaultValues||t.defaultValues.length===0?"text":t.multipleValue?"checkbox":"radio"}const sr=({applicantId:t,onComplete:r,onBack:s})=>{const{criteria:a,initialAnswers:n,isLoading:i,isSubmitting:o,error:c,submit:u}=Ht(t),[p,v]=l.useState({}),[w,x]=l.useState({}),[h,g]=l.useState(0),[k,y]=l.useState(!1);l.useEffect(()=>{n&&Object.keys(n).length>0&&Object.keys(p).length===0&&v(n)},[n]);const m=l.useMemo(()=>a&&a.length>0?Fr(a):[],[a]),I=h===m.length-1,j=m[h]??[];l.useEffect(()=>{!i&&a&&a.length===0&&!k&&!o&&(y(!0),u({applicantId:t,criteriaValueInputs:[]}).then(()=>r==null?void 0:r()).catch(console.error))},[i,a,k,o,u,t,r]);const b=l.useCallback((S,R)=>{v(W=>({...W,[S]:R})),x(W=>{const H={...W};return delete H[S],H})},[]),U=l.useCallback(()=>{const S={};for(const{criterion:R}of j){const W=Dr(R,p[R.id]??[]);W&&(S[R.id]=W)}return x(R=>({...R,...S})),Object.keys(S).length===0},[j,p]),q=()=>{U()&&g(S=>S+1)},L=()=>{h>0?g(S=>S-1):s==null||s()},f=async()=>{if(!(!U()||!a))try{const S=a.map(W=>{const H=(p[W.id]??[]).filter(D=>D&&D.trim());return H.length>0?{riskCriteriaId:W.id,values:H}:null}).filter(W=>W!==null);await u({applicantId:t,criteriaValueInputs:S}),r==null||r()}catch(S){console.error("Risk scoring submit error:",S)}};return i?e.jsx(M,{children:e.jsxs(O,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading risk scoring criteria…"})]})}):!i&&a&&a.length===0?e.jsx(M,{children:e.jsxs(O,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"No criteria required. Moving to next step…"})]})}):c?e.jsx(M,{children:e.jsx(O,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading criteria: ",c.message]})})}):a?e.jsxs(M,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Risk Assessment"}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please answer the following questions for risk evaluation"}),m.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",h+1," of ",m.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:m.map((S,R)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:R===h?"20px":"6px",backgroundColor:R<=h?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},R))})]})]}),e.jsx(O,{className:"space-y-6",children:j.map(({criterion:S})=>e.jsx(Lr,{criterion:S,value:p[S.id]??[],error:w[S.id],onChange:R=>b(S.id,R)},S.id))}),e.jsxs(le,{className:"flex items-center justify-between",children:[e.jsxs(B,{type:"button",variant:"outline",onClick:L,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Jt,{size:14}),h>0?"Previous":"Back"]}),I?e.jsx(B,{type:"button",isLoading:o,onClick:f,children:"Continue"}):e.jsxs(B,{type:"button",onClick:q,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(Xt,{size:14})]})]}),c&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:c.message})})]}):null},Lr=({criterion:t,value:r,error:s,onChange:a})=>{const n=Pr(t),i=t.valueDataType===ye.Integer||t.valueDataType===ye.Decimal||t.valueDataType===ye.DigitOnly;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.displayName,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.description}),i&&(t.min!==void 0||t.max!==void 0)&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.min!==void 0&&t.max!==void 0?`Range: ${t.min} – ${t.max}`:t.min!==void 0?`Minimum: ${t.min}`:`Maximum: ${t.max}`}),n==="text"&&e.jsx(ie,{value:r[0]??"",onChange:o=>a([o.target.value]),type:i?"number":"text",placeholder:"Enter your answer…",error:s,required:t.isRequired,min:t.min,max:t.max,onKeyDown:o=>{t.valueDataType===ye.DigitOnly&&["e","E","+","-","."].includes(o.key)&&o.preventDefault()}}),n==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(o=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===o,onChange:()=>a([o]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:o})]},o)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),n==="checkbox"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(o=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(o),onChange:c=>{c.target.checked?a([...r,o]):a(r.filter(u=>u!==o))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:o})]},o)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),n==="country"&&e.jsx(be,{value:r[0]??"",onChange:o=>a([o.target.value]),options:[{value:"US",label:"United States"},{value:"GB",label:"United Kingdom"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"AE",label:"United Arab Emirates"}],placeholder:"Select a country…",error:s,required:t.isRequired})]})},ar=({applicantId:t,onComplete:r,onBack:s})=>{const{investorCategorizationService:a}=de(),[n,i]=l.useState(null),[o,c]=l.useState(!1),[u,p]=l.useState(null),v=async w=>{if(w.preventDefault(),n===null){p("Please select an investor type");return}c(!0),p(null);try{const x={applicantId:t,investorType:n};console.log("Submitting investor categorization:",x);const h=await a.setInvestorCategorization(x);console.log("Investor categorization result:",h),r==null||r()}catch(x){console.error("Error submitting investor categorization:",x),p(x.message||"Failed to submit investor categorization")}finally{c(!1)}};return e.jsx("form",{onSubmit:v,children:e.jsxs(M,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:"Which statement best describes you?"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:"All Tokenise clients are treated as Retail Investors under EU regulation, which gives you the highest level of investor protection. For our internal purposes, we ask you to select the description that best matches your situation"})]}),e.jsxs(O,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:"Choose one"}),e.jsx("label",{className:`
|
|
52
52
|
block p-4 border-2 rounded-lg cursor-pointer transition-all
|
|
53
53
|
${n===ce.Individual?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}
|
|
54
54
|
`,children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:ce.Individual,checked:n===ce.Individual,onChange:()=>i(ce.Individual),className:"mt-1 h-4 w-4 text-primary-500 border-gray-300 focus:ring-primary-500"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Individual investor"}),e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:"(Recommended) Most of our clients choose this option. Provides the strongest protection and aligns with our mission to make investing accessible to everyone."})]})]})}),e.jsx("label",{className:`
|
|
@@ -57,13 +57,13 @@
|
|
|
57
57
|
`,children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:ce.Sophisticated,checked:n===ce.Sophisticated,onChange:()=>i(ce.Sophisticated),className:"mt-1 h-4 w-4 text-primary-500 border-gray-300 focus:ring-primary-500"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Sophisticated investor"}),e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:"In the last 2 years, I have done one or more of the following:"}),e.jsxs("ul",{className:"text-sm text-gray-600 dark:text-gray-400 mt-2 space-y-1 list-none",children:[e.jsx("li",{children:"Worked in private equity or provided capital to small and medium enterprises, and/or"}),e.jsx("li",{children:"Been the director of a company with an annual turnover of at least (USD) $2m million, and/or"}),e.jsx("li",{children:"Invested directly in at least 2 private (not listed) companies."})]})]})]})}),e.jsx("label",{className:`
|
|
58
58
|
block p-4 border-2 rounded-lg cursor-pointer transition-all
|
|
59
59
|
${n===ce.HighNetWorth?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}
|
|
60
|
-
`,children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:ce.HighNetWorth,checked:n===ce.HighNetWorth,onChange:()=>i(ce.HighNetWorth),className:"mt-1 h-4 w-4 text-primary-500 border-gray-300 focus:ring-primary-500"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"High networth investor"}),e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:["I earn more than (USD/EUR) $150,000 per year, and/or",e.jsx("br",{}),"I have net assets (excluding my main property) of at least $/EUR 300,000"]})]})]})}),
|
|
60
|
+
`,children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:ce.HighNetWorth,checked:n===ce.HighNetWorth,onChange:()=>i(ce.HighNetWorth),className:"mt-1 h-4 w-4 text-primary-500 border-gray-300 focus:ring-primary-500"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"High networth investor"}),e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:["I earn more than (USD/EUR) $150,000 per year, and/or",e.jsx("br",{}),"I have net assets (excluding my main property) of at least $/EUR 300,000"]})]})]})}),u&&e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsxs("p",{className:"text-red-600 dark:text-red-400 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",u]})})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(B,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(B,{type:"submit",isLoading:o,disabled:n===null,children:"Submit"})]})]})})},nr=({applicantId:t,onComplete:r,onBack:s})=>{const{appropriatenessTestService:a}=de(),[n,i]=l.useState(null),[o,c]=l.useState(!0),[u,p]=l.useState(!1),[v,w]=l.useState(null),[x,h]=l.useState({}),[g,k]=l.useState(0),[y,m]=l.useState(!1),[I,j]=l.useState(!1),[b,U]=l.useState(0);l.useEffect(()=>{(async()=>{try{c(!0),w(null),console.log("Loading appropriateness test for applicant:",t);const E=await a.getAppropriatenessTest(t);if(console.log("Appropriateness test data:",E),i(E),E.waitTimeSpanForNextTry&&E.waitTimeSpanForNextTry!=="00:00:00"){const Q=q(E.waitTimeSpanForNextTry);Q>0&&U(Q)}}catch(E){console.error("Error loading appropriateness test:",E),w(E.message||"Failed to load appropriateness test")}finally{c(!1)}})()},[t,a]);const q=D=>{const E=D.split(":").map(Number);if(E.length===3){const[Q,_,ae]=E;return Q*3600+_*60+ae}return 0},L=D=>{const E=Math.floor(D/60),Q=D%60;return`${E.toString().padStart(2,"0")}:${Q.toString().padStart(2,"0")}`};l.useEffect(()=>{if(!y||g<=0)return;const D=setInterval(()=>{k(E=>E<=1?(j(!0),0):E-1)},1e3);return()=>clearInterval(D)},[y,g]),l.useEffect(()=>{if(b<=0)return;const D=setInterval(()=>{U(E=>E<=1?0:E-1)},1e3);return()=>clearInterval(D)},[b]),l.useEffect(()=>{I&&!u&&R()},[I]);const f=()=>{n&&(m(!0),k(n.testDurationSec))},S=(D,E)=>{h(Q=>({...Q,[D]:E}))},R=async D=>{if(D&&D.preventDefault(),!!n){if(!I){const E=n.appropriatenessQuestions.length-Object.keys(x).length;if(E>0){w(`Please answer all questions. ${E} question(s) remaining.`);return}}p(!0),w(null);try{const E=n.appropriatenessQuestions.map(_=>({appropriatenessQuestionId:_.id,value:x[_.id]||""})),Q={applicantId:t,appropriatenessTestId:n.id,appropriatenessQuestionResults:E};console.log("Submitting appropriateness test:",Q);try{const _=await a.fillAppropriatenessTest(Q);console.log("Appropriateness test result:",_),_.message&&(_.message.toLowerCase().includes("pass")||_.message.toLowerCase().includes("success")||_.message.toLowerCase().includes("congratulations"))?r==null||r():(w(_.message||"Test completed. Please check the result."),m(!1),j(!1),h({}),setTimeout(()=>W(),1e3))}catch(_){if(_.code===400&&_.message){const ae=_.message;console.log("Test failed:",ae),w(ae),m(!1),j(!1),h({}),setTimeout(()=>W(),1500)}else throw _}}catch(E){console.error("Error submitting appropriateness test:",E),w(E.message||"Failed to submit test. Please try again."),m(!1),j(!1),h({})}finally{p(!1)}}},W=async()=>{try{const D=await a.getAppropriatenessTest(t);if(console.log("Reloaded test data:",D),i(D),D.waitTimeSpanForNextTry&&D.waitTimeSpanForNextTry!=="00:00:00"){const E=q(D.waitTimeSpanForNextTry);E>0&&U(E)}}catch(D){console.error("Error reloading test data:",D),w(E=>E+`
|
|
61
61
|
|
|
62
|
-
Failed to reload test data. Please refresh the page.`)}};if(o)return e.jsx(
|
|
62
|
+
Failed to reload test data. Please refresh the page.`)}};if(o)return e.jsx(M,{children:e.jsxs(O,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading appropriateness test..."})]})});if(!n)return e.jsx(M,{children:e.jsxs(O,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-danger-500 text-lg mb-4",children:"No test data available"}),v&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:v})]})});if(b>0)return e.jsxs(M,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:n.displayName}),n.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:n.subtitle})]}),e.jsxs(O,{className:"py-12 text-center",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"text-6xl font-bold text-primary-500 mb-2",children:L(b)}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please wait before attempting the test again"})]}),v&&e.jsx("div",{className:"mt-4 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsx("p",{className:"text-red-600 dark:text-red-400 text-sm",children:v})})]})]});const H=n.testAllowedMaxTry-n.totalFailedTries;return y?e.jsx("form",{onSubmit:R,children:e.jsxs(M,{children:[e.jsx(se,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:n.displayName}),n.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:n.subtitle})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:`text-3xl font-bold ${g<=60?"text-danger-500":"text-primary-500"}`,children:L(g)}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Time Remaining"})]})]})}),e.jsxs(O,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs(fe,{variant:"info",children:["Question ",Object.keys(x).length," of ",n.totalQuestionCount]}),e.jsxs(fe,{variant:H>1?"success":"warning",children:[H," attempt",H!==1?"s":""," remaining"]})]}),n.appropriatenessQuestions.map((D,E)=>e.jsxs("div",{className:"p-4 border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsxs("div",{className:"mb-4",children:[e.jsxs("span",{className:"inline-block px-2 py-1 text-xs font-semibold text-primary-700 bg-primary-100 dark:text-primary-300 dark:bg-primary-900/30 rounded mb-2",children:["Question ",E+1]}),D.groupName&&e.jsx("span",{className:"ml-2 text-xs text-gray-500 dark:text-gray-400",children:D.groupName}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mt-2",children:D.question})]}),e.jsx("div",{className:"space-y-2",children:D.answers.map((Q,_)=>e.jsxs("label",{className:`
|
|
63
63
|
flex items-center p-3 border-2 rounded-lg cursor-pointer transition-all
|
|
64
|
-
${x[D.id]===
|
|
65
|
-
`,children:[e.jsx("input",{type:"radio",name:`question-${D.id}`,value:V,checked:x[D.id]===V,onChange:ae=>S(D.id,ae.target.value),className:"h-4 w-4 text-primary-500 border-gray-300 focus:ring-primary-500",disabled:d}),e.jsx("span",{className:"ml-3 text-gray-700 dark:text-gray-300",children:V})]},K))})]},D.id)),v&&!R&&e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsxs("p",{className:"text-red-600 dark:text-red-400 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",v]})}),R&&e.jsx("div",{className:"p-4 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-700 dark:text-yellow-400 text-sm",children:[e.jsx("strong",{children:"Time's up!"})," Your answers are being submitted automatically."]})})]}),e.jsxs(le,{className:"flex justify-between",children:[e.jsx(B,{type:"button",variant:"outline",onClick:s,disabled:d,children:"Cancel"}),e.jsx(B,{type:"submit",isLoading:d,disabled:Object.keys(x).length<n.totalQuestionCount,children:R?"Submitting...":"Submit Test"})]})]})}):e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:n.displayName}),n.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:n.subtitle})]}),e.jsxs(M,{children:[n.description&&e.jsx("div",{className:"mb-6 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg",children:e.jsx("p",{className:"text-gray-700 dark:text-gray-300",children:n.description})}),e.jsxs("div",{className:"space-y-4 mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:"Total Questions:"}),e.jsx(ye,{variant:"info",children:n.totalQuestionCount})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:"Time Limit:"}),e.jsx(ye,{variant:"info",children:P(n.testDurationSec)})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:"Correct Answers Required:"}),e.jsx(ye,{variant:"info",children:n.testCorrectAnswerPassLimit})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:"Attempts Remaining:"}),e.jsx(ye,{variant:q>1?"success":"warning",children:q})]})]}),v&&e.jsx("div",{className:"mb-4 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsxs("p",{className:"text-red-600 dark:text-red-400 text-sm",children:[e.jsx("strong",{children:"Previous Attempt:"})," ",v]})}),q<=0&&e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsx("p",{className:"text-red-600 dark:text-red-400",children:"You have used all your attempts. Please contact support for assistance."})})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(B,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(B,{type:"button",onClick:y,disabled:q<=0,children:"Start Test"})]})]})},rr=({applicantId:t,onComplete:r,onBack:s})=>{var V,K,ae,J;const{applicantService:a,baseInformationService:n,config:i}=de(),{identityData:o,provider:c,token:d,isLoading:m,error:v,requestIdentity:w,restartIdentity:x}=$t(t),[h,g]=l.useState(null),[k,f]=l.useState(null),[p,R]=l.useState([]),[N,b]=l.useState(!0),[_,W]=l.useState(!1),[P,y]=l.useState(null),[S,I]=l.useState(!1),Y=l.useRef(!1),q=ke.useForm({defaultValues:{street:"",streetNumber:"",city:"",zip:"",country:"",nationality:"",phonenumber:""}});l.useEffect(()=>{(async()=>{try{const[F,X]=await Promise.all([a.getApplicantData(t),n.getCountries("","en")]);f(F);const G=new Set,oe=X.filter(ge=>{const u=ge.abbreviation3||ge.abbreviation;return!u||G.has(u)?!1:(G.add(u),!0)});R(oe);const $=F.applicantRequestData;if(q.reset({street:($==null?void 0:$.street)||"",streetNumber:($==null?void 0:$.streetNumber)||"",city:($==null?void 0:$.city)||"",zip:($==null?void 0:$.zip)||"",country:($==null?void 0:$.country)||"",nationality:($==null?void 0:$.nationality)||"",phonenumber:($==null?void 0:$.phonenumber)||""}),F.kycRecords&&F.kycRecords.length>0&&F.kycRecords[0].providerTokenObject!==null&&!Y.current){console.log("[Identity] Found existing identity verification, auto-requesting..."),Y.current=!0;try{await w(),W(!0)}catch(ge){console.error("[Identity] Auto-request failed:",ge)}}}catch(F){console.error("Error loading applicant data:",F)}finally{b(!1)}})()},[t]),l.useEffect(()=>{o&&!_&&(console.log("[Identity] Identity data already loaded, showing provider"),W(!0))},[o,_]),l.useEffect(()=>{if(d){if(d.expiresAt){const O=new Date(d.expiresAt).getTime();if(Date.now()>=O){console.warn("[Identity] Token has expired (expiresAt)"),I(!0),y("Your verification session has expired. Please restart.");return}}if(d.url)try{const F=new URL(d.url).toString().toLowerCase();if(F.includes("expired")||F.includes("invalid")||F.includes("error")){console.warn("[Identity] Token URL indicates expiration"),I(!0),y("Your verification link has expired. Please restart.");return}}catch{console.error("[Identity] Invalid token URL")}if(d.status==="expired"||d.error==="expired"||d.expired===!0){console.warn("[Identity] Token object indicates expiration"),I(!0),y("Your verification session has expired. Please restart.");return}}},[d]),l.useEffect(()=>{if(c!==null&&d&&!h&&_&&!S){const O=c;if(d.url){console.log("[Identity] Loading provider URL for user verification:",d.url),y(null);try{if(new URL(d.url),O===ue.SardinAI){console.log("[SardinAI] Initializing Risk SDK in background...");try{const F=Ne.parseProviderConfig(c,d,i);Ne.createProvider(c,F).initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully in background")}).catch(G=>{console.warn("[SardinAI] Risk SDK initialization failed (non-blocking):",G)})}catch(F){console.warn("[SardinAI] Risk SDK setup failed (non-blocking):",F)}}g({type:"url",url:d.url})}catch(F){console.error("[Identity] Invalid URL:",F),y("Invalid verification URL. Please restart."),I(!0)}return}if(O===ue.SardinAI){console.log("[SardinAI] No URL provided - initializing Risk SDK only..."),y(null);try{const F=Ne.parseProviderConfig(c,d,i),X=Ne.createProvider(c,F);X.initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully"),g(X),setTimeout(()=>{r==null||r()},2e3)}).catch(G=>{var $;console.error("[SardinAI] Failed to initialize:",G);const oe=(($=G.message)==null?void 0:$.toLowerCase())||"";oe.includes("expired")||oe.includes("invalid")||oe.includes("401")||oe.includes("400")?(I(!0),y("Session expired or invalid. Please restart verification.")):y(`Failed to initialize: ${G.message}`)})}catch(F){console.error("[SardinAI] Error creating provider:",F),y(`Configuration error: ${F.message}`)}return}try{y(null);const F=Ne.parseProviderConfig(c,d,i),X=Ne.createProvider(c,F);O===ue.Sumsub?(X.initialize("identity-container").catch(G=>{var oe;console.error("[Sumsub] Initialization error:",G),y(`Failed to initialize: ${G.message}`),(oe=G.message)!=null&&oe.toLowerCase().includes("expired")&&I(!0)}),X.onComplete&&X.onComplete(()=>{r==null||r()})):O===ue.Onfido&&X.initialize("identity-container").catch(G=>{console.error("[Onfido] Initialization error:",G),y(`Failed to initialize: ${G.message}`)}),g(X)}catch(F){console.error("[Identity] Provider setup error:",F),y(`Setup error: ${F.message}`)}}return()=>{if(h&&h.destroy)try{h.destroy()}catch(O){console.error("[Identity] Error destroying provider:",O)}}},[c,d,h,_,r,S]);const D=async()=>{try{y(null),I(!1),await w(),W(!0)}catch(O){console.error("Error starting identity verification:",O)}},A=async()=>{try{y(null),I(!1),g(null),console.log("[Identity] Restarting verification..."),await x(),W(!0)}catch(O){console.error("Error restarting identity verification:",O),y(O.message||"Failed to restart verification")}};if(N||m)return e.jsx(T,{children:e.jsxs(M,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading identity verification..."})]})});if(v)return e.jsx(T,{children:e.jsx(M,{children:e.jsxs("p",{className:"text-danger-500",children:["Error: ",v.message]})})});if(_&&(P||S))return e.jsxs(T,{children:[e.jsx(se,{children:e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Verification Session Issue"})}),e.jsxs(M,{children:[e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg mb-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("svg",{className:"h-6 w-6 text-red-600 dark:text-red-400 mr-3 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-1",children:S?"Session Expired":"Verification Error"}),e.jsx("p",{className:"text-red-800 dark:text-red-200 text-sm",children:P||"Your verification session has expired and needs to be restarted."})]})]})}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What to do next:"}),e.jsxs("ul",{className:"text-blue-800 dark:text-blue-200 text-sm space-y-1 list-disc list-inside",children:[e.jsx("li",{children:'Click "Restart Verification" below to generate a new session'}),e.jsx("li",{children:"Complete the verification process without delays"}),e.jsx("li",{children:"If issues persist, contact support"})]})]})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(B,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(B,{type:"button",onClick:A,disabled:m,children:m?"Restarting...":"Restart Verification"})]})]});if(_&&o){const O=c;return d!=null&&d.url?e.jsxs(T,{children:[e.jsx(se,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(B,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:m,children:"Restart"})]})}),e.jsxs(M,{children:[e.jsx("div",{className:"mb-4 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-800 dark:text-yellow-200 text-sm",children:[e.jsx("strong",{children:"Important:"}),' If you see an "expired" or "invalid link" message below, click the "Restart" button above to generate a new verification session.']})}),e.jsx("div",{className:"w-full",style:{height:"600px"},children:e.jsx("iframe",{src:d.url,className:"w-full h-full border-0 rounded-lg",allow:"camera; microphone; geolocation",title:"Identity Verification",onLoad:F=>{var X,G,oe;console.log("[Identity] Iframe loaded");try{const $=F.target,Se=$.contentDocument||((X=$.contentWindow)==null?void 0:X.document);if(Se){const ge=((oe=(G=Se.body)==null?void 0:G.textContent)==null?void 0:oe.toLowerCase())||"";(ge.includes("expired")||ge.includes("invalid")||ge.includes("error"))&&(console.warn("[Identity] Iframe shows expiration message"),I(!0),y("Your verification link has expired."))}}catch{console.log("[Identity] Cannot check iframe content (CORS)")}}})})]}),s&&e.jsx(le,{children:e.jsx(B,{variant:"outline",onClick:s,children:"Back"})})]}):O===ue.SardinAI?e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Device Risk Assessment"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Analyzing device security and behavioral patterns..."})]}),e.jsx(M,{children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(pe,{className:"mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please wait while we verify your device security"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-500 mt-2",children:"This process is automatic and will complete in a few seconds"})]})})]}):e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(M,{children:e.jsx("div",{id:"identity-container",className:"min-h-[400px]"})}),s&&e.jsx(le,{children:e.jsx(B,{variant:"outline",onClick:s,children:"Back"})})]})}return e.jsx("form",{onSubmit:q.handleSubmit(D),children:e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Review Your Information"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please review and confirm your information before starting identity verification"})]}),e.jsxs(M,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-500 dark:text-gray-400",children:"Name"}),e.jsxs("p",{className:"mt-1 text-base",children:[(V=k==null?void 0:k.applicantRequestData)==null?void 0:V.firstName," ",(K=k==null?void 0:k.applicantRequestData)==null?void 0:K.lastName]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-500 dark:text-gray-400",children:"Email"}),e.jsx("p",{className:"mt-1 text-base",children:(ae=k==null?void 0:k.applicantRequestData)==null?void 0:ae.email})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-500 dark:text-gray-400",children:"Date of Birth"}),e.jsx("p",{className:"mt-1 text-base",children:((J=k==null?void 0:k.applicantRequestData)==null?void 0:J.dateOfBirth)||"Not provided"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Address Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(ke.Controller,{control:q.control,name:"country",render:({field:O})=>e.jsx(be,{...O,label:"Country",options:[{value:"",label:"Select country..."},...p.map(F=>({value:F.abbreviation3||F.abbreviation,label:F.name}))]})}),e.jsx(ke.Controller,{control:q.control,name:"nationality",render:({field:O})=>e.jsx(be,{...O,label:"Nationality",options:[{value:"",label:"Select nationality..."},...p.map(F=>({value:F.abbreviation3||F.abbreviation,label:F.name}))]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(ke.Controller,{control:q.control,name:"street",render:({field:O})=>e.jsx(ie,{...O,label:"Street"})}),e.jsx(ke.Controller,{control:q.control,name:"streetNumber",render:({field:O})=>e.jsx(ie,{...O,label:"Street Number"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(ke.Controller,{control:q.control,name:"city",render:({field:O})=>e.jsx(ie,{...O,label:"City"})}),e.jsx(ke.Controller,{control:q.control,name:"zip",render:({field:O})=>e.jsx(ie,{...O,label:"ZIP/Postal Code"})})]}),e.jsx(ke.Controller,{control:q.control,name:"phonenumber",render:({field:O})=>e.jsx(ie,{...O,label:"Phone Number",type:"tel"})})]})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(B,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(B,{type:"submit",isLoading:m,children:"Confirm and Start Verification"})]})]})})},Be=({kycStatus:t,reviewStatus:r,workflowResult:s,customMessage:a,onContinue:n,onContactSupport:i})=>{const c=t===we.Approved?{type:"success",title:"Verification Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your identity verification has been successfully approved."}:t===we.Rejected?{type:"error",title:"Verification Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Unfortunately, your identity verification was not approved."}:t===we.Pending||t===we.InProgress?{type:"pending",title:"Verification Pending",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your identity verification is currently being processed."}:r===je.Approved?{type:"success",title:"Application Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your application has been approved."}:r===je.Reject?{type:"error",title:"Application Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Your application has been rejected."}:r===je.UnderReview||r===je.AdminReview?{type:"pending",title:"Under Review",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application is currently under manual review."}:s===Re.Success?{type:"success",title:"Process Complete",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your verification process has been completed successfully."}:s===Re.Failed?{type:"error",title:"Process Failed",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"The verification process could not be completed."}:s===Re.AdminReview?{type:"pending",title:"Admin Review Required",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application requires administrator review."}:{type:"pending",title:"Processing",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your application is being reviewed."};return e.jsxs(T,{children:[e.jsxs(M,{className:"py-12",children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx("div",{className:`w-24 h-24 rounded-full flex items-center justify-center ${c.iconBg}`,children:e.jsx("span",{className:`text-5xl ${c.iconColor}`,children:c.icon})})}),e.jsx("h2",{className:"text-3xl font-bold text-center text-gray-900 dark:text-white mb-4",children:c.title}),e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx(ye,{variant:c.type==="success"?"success":c.type==="error"?"danger":c.type==="pending"?"warning":"info",children:t!=null?we[t]:je[r]})}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mb-6 max-w-md mx-auto",children:a||c.message}),c.type==="success"&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-green-900 dark:text-green-100 mb-2",children:"What's Next?"}),e.jsxs("ul",{className:"text-sm text-green-800 dark:text-green-200 space-y-1",children:[e.jsx("li",{children:"✓ Your identity has been verified"}),e.jsx("li",{children:"✓ You can now proceed with your application"}),e.jsx("li",{children:"✓ All features are now accessible"})]})]}),c.type==="error"&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-2",children:"What Can You Do?"}),e.jsxs("ul",{className:"text-sm text-red-800 dark:text-red-200 space-y-2",children:[e.jsx("li",{children:"• Review the requirements and ensure all information is correct"}),e.jsx("li",{children:"• Contact our support team for assistance"}),e.jsx("li",{children:"• You may be able to resubmit your application"})]})]}),c.type==="pending"&&e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What Happens Next?"}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-2",children:[e.jsx("li",{children:"• Our team is reviewing your information"}),e.jsx("li",{children:"• You will be notified via email once the review is complete"}),e.jsx("li",{children:"• This typically takes 24-48 hours"}),e.jsx("li",{children:"• No action is required from you at this time"})]})]}),e.jsx("div",{className:"mt-6 pt-6 border-t border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"KYC Status:"}),e.jsx("div",{className:"font-medium text-gray-900 dark:text-white mt-1",children:t!=null?we[t]:"Not Available"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Review Status:"}),e.jsx("div",{className:"font-medium text-gray-900 dark:text-white mt-1",children:je[r]})]})]})})]}),e.jsxs(le,{className:"flex justify-center gap-4",children:[c.type==="success"&&n&&e.jsx(B,{onClick:n,size:"lg",children:"Continue"}),c.type==="error"&&e.jsxs(e.Fragment,{children:[i&&e.jsx(B,{variant:"outline",onClick:i,children:"Contact Support"}),n&&e.jsx(B,{onClick:n,children:"Try Again"})]}),c.type==="pending"&&e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Please check back later or wait for our email notification"})})]})]})},sr=({config:t,className:r=""})=>!(t!=null&&t.visible)||!(t!=null&&t.url)?null:e.jsx("div",{className:`metakyc-logo ${r}`,children:e.jsx("img",{src:t.url,alt:t.alt||"Company Logo",style:{width:t.width||"auto",height:t.height||"40px",maxWidth:"100%",objectFit:"contain"},onError:s=>{console.warn("[Logo] Failed to load logo:",t.url),s.target.style.display="none"}})}),Le=({title:t,subtitle:r,className:s=""})=>{const{currentTheme:a}=de(),n=t||(a==null?void 0:a.title)||"",i=!!(a!=null&&a.logo&&a.logo.visible&&a.logo.url),o=!!n;return!i&&!o?null:e.jsxs("div",{className:`metakyc-header ${s}`,children:[e.jsxs("div",{className:"metakyc-header-title flex items-center text-xl font-bold text-gray-900 dark:text-white",children:[i&&e.jsx(sr,{config:a.logo}),i&&o&&e.jsx("span",{className:"text-gray-400 dark:text-gray-500 mx-3",style:{fontSize:"1.5rem",fontWeight:300},children:"|"}),o&&e.jsx("span",{children:n})]}),r&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:r})]})},Me=["firstName","lastName","email","phonenumber","dateOfBirth"];function Oe(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const De={width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"},Dr=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:a})=>{var $,Se,ge;const{config:n,baseInformationService:i,currentTheme:o}=de(),{createApplicant:c,isLoading:d}=_t(),m=t||(($=n.applicantForm)==null?void 0:$.workflowKey);if(!m)throw new Error("workflowKey is required. Provide it either as a prop to CreateApplicantForm or set it in config.applicantForm.workflowKey");const v=r||((Se=n.applicantForm)==null?void 0:Se.externalRefId)||"",[w,x]=l.useState([]),[h,g]=l.useState(!0),k=l.useRef(!1),f=l.useRef(!1);l.useEffect(()=>{(async()=>{if(!(k.current||f.current)){k.current=!0,g(!0);try{const C=await i.getCountries("",n.locale||"en"),L=new Set;x(C.map(j=>({value:j.abbreviation3||j.abbreviation,label:j.name})).filter(j=>!j.value||L.has(j.value)?!1:(L.add(j.value),!0))),f.current=!0}catch(C){console.error("Failed to load countries:",C)}finally{g(!1),k.current=!1}}})()},[]);const p=l.useMemo(()=>o!=null&&o.applicantFormPages&&o.applicantFormPages.length>0?o.applicantFormPages:null,[o==null?void 0:o.applicantFormPages]),R=l.useMemo(()=>{const u=new Set(Me),C=o==null?void 0:o.applicantFormRequiredFields;if(C)for(const L of C)u.add(L);if(p)for(const L of p)for(const j of L.fields)!j.isCustom&&j.name&&j.required&&u.add(j.name);return Array.from(u)},[o==null?void 0:o.applicantFormRequiredFields,p]),N=l.useMemo(()=>{var L;if(p){const j=p.flatMap(U=>U.fields).filter(U=>!U.isCustom&&U.name).map(U=>U.name),E=new Set(j);for(const U of Me)E.add(U);return Array.from(E)}let u;(L=n.applicantForm)!=null&&L.visibleFields?u=n.applicantForm.visibleFields:o!=null&&o.applicantFormVisibleFields&&o.applicantFormVisibleFields.length>0?u=o.applicantFormVisibleFields:u=rt;const C=new Set(u);for(const j of Me)C.add(j);return Array.from(C)},[(ge=n.applicantForm)==null?void 0:ge.visibleFields,o==null?void 0:o.applicantFormVisibleFields,p]),[b,_]=l.useState({workflowKey:m,firstName:"",lastName:"",title:"",email:"",dateOfBirth:"",phonenumber:"",externalRefId:v,mobileCountryCode:"",street:"",streetNumber:"",zip:"",city:"",country:"",nationality:"",otherNationality:[],defaultLanguage:"EN",taxCountry:"",placeOfBirth:"",countryOfBirth:"",salutation:null,educationLevel:"",occupation:"",taxNumber:""}),[W,P]=l.useState({}),[y,S]=l.useState(0),[I,Y]=l.useState({}),[q,D]=l.useState(null),[A,V]=l.useState(!1),K=(u,C)=>_(L=>({...L,[u]:C})),ae=(u,C)=>P(L=>({...L,[u]:C})),J=l.useMemo(()=>p?p.filter(u=>!u.conditionalOn||W[u.conditionalOn]==="true"):null,[p,W]);l.useEffect(()=>{J&&y>=J.length&&J.length>0&&S(J.length-1)},[J==null?void 0:J.length]);const O=u=>{var L;const C={};for(const j of u.fields)if(j.isCustom){if(j.required&&j.paramName){const E=W[j.paramName],U=j.displayText||j.label||j.paramName;j.customType==="checkbox"||j.customType==="link_checkbox"?E!=="true"&&(C[j.paramName]=`${U} is required.`):(!E||E.trim()==="")&&(C[j.paramName]=`${U} is required.`)}}else if(j.name){const E=j.name;if(R.includes(E)&&Oe(b[E])){const U=j.displayText||((L=Fe[E])==null?void 0:L.label)||E;C[E]=`${U} is required.`}}return C},F=async u=>{var L;const C=J;if(C&&!u){const j=O(C[y]);if(Object.keys(j).length>0){Y(j);return}Y({}),S(E=>E+1);return}if(C){let j={};for(const E of C)j={...j,...O(E)};if(Object.keys(j).length>0){Y(j);return}}V(!0),D(null);try{if(!b.externalRefId||b.externalRefId.trim()===""){D("External Reference ID is required. Please pass it via config.applicantForm.externalRefId.");return}for(const H of R)if(Oe(b[H])){const Z=((L=Fe[H])==null?void 0:L.label)||H;D(`${Z} is required.`);return}const j={workflowKey:b.workflowKey,externalRefId:b.externalRefId.trim()};N.forEach(H=>{if(H==="externalRefId")return;const Z=b[H];Oe(Z)||(j[H]=Z)});const E=[];if(C){for(const H of C)for(const Z of H.fields)if(Z.isCustom&&Z.paramName){const he=W[Z.paramName]??"";E.push({paramName:Z.paramName,paramValue:he})}}E.length>0&&(j.applicantAdditionalDatas=E);const U=await c(j);s(U.applicantId)}catch(j){console.error("Error creating applicant:",j),D(j.message||"Failed to create applicant")}finally{V(!1)}},X=(u,C,L)=>{var _e;const j=Fe[u];if(!j)return null;const E=R.includes(u),U=I[u],H=L||j.label,Z=C??u,he={required:E};switch(j.type){case"select":if(u==="country"||u==="nationality"||u==="taxCountry"||u==="countryOfBirth")return e.jsx(be,{...he,label:H,value:b[u]||"",onChange:re=>K(u,re.target.value),options:[{value:"",label:`Select ${H.toLowerCase()}...`},...w],disabled:h},Z);if(u==="salutation")return e.jsx(be,{...he,label:H,value:((_e=b[u])==null?void 0:_e.toString())||"",onChange:re=>K(u,re.target.value?Number(re.target.value):null),options:[{value:"",label:"Select salutation..."},{value:Ie.Male.toString(),label:"Male"},{value:Ie.Female.toString(),label:"Female"},{value:Ie.Other.toString(),label:"Other"}]},Z);if(u==="defaultLanguage"){const re=o!=null&&o.allowedLanguages&&o.allowedLanguages.length>0?ze.filter(Te=>o.allowedLanguages.includes(Te.value)):ze;return e.jsx(be,{...he,label:H,value:b[u]||"",onChange:Te=>K(u,Te.target.value),options:[{value:"",label:"Select language..."},...re]},Z)}return null;case"multiselect":return u==="otherNationality"?e.jsx(Kt,{...he,label:H,value:b[u]||[],onChange:re=>K(u,re),options:w,placeholder:"Select other nationalities...",disabled:h},Z):null;case"date":return e.jsx(ie,{...he,type:"date",label:H,value:b[u]||"",onChange:re=>K(u,re.target.value),error:U},Z);case"email":return e.jsx(ie,{...he,type:"email",label:H,value:b[u]||"",onChange:re=>K(u,re.target.value),error:U},Z);case"tel":return e.jsx(ie,{...he,type:"tel",label:H,value:b[u]||"",onChange:re=>K(u,re.target.value),error:U},Z);default:return e.jsx(ie,{...he,type:"text",label:H,value:b[u]||"",onChange:re=>K(u,re.target.value),error:U},Z)}},G=(u,C)=>{if(!u.paramName)return null;const L=I[u.paramName],j=u.displayText||u.label||u.paramName;if(u.customType==="checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:W[u.paramName]==="true",onChange:E=>ae(u.paramName,E.target.checked?"true":"false"),className:"metakyc-option-input",style:De}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[j,u.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),L&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:L})]},`custom-${C}`);if(u.customType==="link_checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:W[u.paramName]==="true",onChange:E=>ae(u.paramName,E.target.checked?"true":"false"),className:"metakyc-option-input",style:{...De,alignSelf:"flex-start",marginTop:"2px"}}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[j," ",u.linkUrl&&e.jsx("a",{href:u.linkUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",style:{color:"var(--metakyc-primary, #2563eb)"},onClick:E=>E.stopPropagation(),children:u.linkText||u.linkUrl}),u.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),L&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:L})]},`custom-${C}`);if(u.customType==="group_checkbox"){const E=(W[u.paramName]||"").split(",").filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[j,u.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(u.options||[]).map(U=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:E.includes(U.value),onChange:H=>{const Z=H.target.checked?[...E,U.value]:E.filter(he=>he!==U.value);ae(u.paramName,Z.join(","))},className:"metakyc-option-input",style:De}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:U.label})]},U.value))}),L&&e.jsx("p",{className:"text-red-500 text-xs",children:L})]},`custom-${C}`)}return u.customType==="radio_group"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[j,u.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(u.options||[]).map(E=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:W[u.paramName]===E.value,onChange:()=>ae(u.paramName,E.value),name:`radio-group-${u.paramName}-${C}`,className:"metakyc-option-input",style:De}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:E.label})]},E.value))}),L&&e.jsx("p",{className:"text-red-500 text-xs",children:L})]},`custom-${C}`):e.jsx(ie,{type:"text",label:`${j}${u.required?" *":""}`,value:W[u.paramName]||"",onChange:E=>ae(u.paramName,E.target.value),required:u.required,error:L},`custom-${C}`)},oe=u=>e.jsx("div",{className:"grid grid-cols-2 gap-4",children:u.fields.map((C,L)=>{const j=C.colSpan===1?"col-span-1":"col-span-2",E=C.isCustom?`custom-${L}-${C.paramName}`:`builtin-${C.name}-${L}`;return e.jsx("div",{className:j,children:C.isCustom?G(C,L):X(C.name,E,C.displayText)},E)})});if(h)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(T,{children:e.jsxs(M,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading form..."})]})})});if(J){const u=J[y]??J[0],C=y===0,L=y===J.length-1,j=J.length,E=Object.values(I);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(T,{children:[e.jsx(se,{children:e.jsx(Le,{title:(o==null?void 0:o.title)||"Create Applicant"})}),e.jsxs(M,{children:[(u.title||u.subtitle||u.description)&&e.jsxs("div",{className:"mb-4",children:[u.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:u.title}),u.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:u.subtitle}),u.description&&u.description!==u.subtitle&&e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:u.description})]}),(q||E.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[q&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",q]}),E.map((U,H)=>e.jsx("p",{className:"text-red-600 text-sm",children:U},H))]}),j>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[J.map((U,H)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${H===y?"bg-blue-600 flex-1":H<y?"bg-blue-300 w-8":"bg-gray-200 w-8"}`,style:H===y?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:H<y?{backgroundColor:"var(--metakyc-primary-light, #dbeafe)",opacity:.7}:void 0},H)),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[y+1," / ",j]})]}),oe(u)]}),e.jsxs(le,{className:"flex justify-between",children:[e.jsxs("div",{children:[!C&&e.jsx(B,{type:"button",variant:"outline",onClick:()=>{S(U=>U-1),Y({})},disabled:A||d,children:"Previous"}),C&&a&&e.jsx(B,{type:"button",variant:"outline",onClick:a,disabled:A||d,children:"Cancel"})]}),e.jsx(B,{type:"button",isLoading:A||d,onClick:()=>F(L),children:L?"Submit":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:async u=>{u.preventDefault(),await F(!0)},children:e.jsxs(T,{children:[e.jsx(se,{children:e.jsx(Le,{title:(o==null?void 0:o.title)||"Create Applicant"})}),e.jsxs(M,{children:[q&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",q]})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:N.map(u=>X(u))})]}),e.jsxs(le,{className:"flex justify-between",children:[a&&e.jsx(B,{type:"button",variant:"outline",onClick:a,disabled:A||d,children:"Cancel"}),e.jsx(B,{type:"submit",isLoading:A||d,children:"Create Applicant"})]})]})})})},Fr=({applicantId:t,onComplete:r,onError:s,theme:a="light",className:n})=>{const{progress:i,currentStep:o,steps:c,workflowKey:d,nextWorkflowKey:m,hasWorkflowChanged:v,isLoading:w,error:x,moveBack:h,refreshProgress:g}=Mt(t),[k,f]=l.useState(!1);if(l.useEffect(()=>{x&&s&&s(x)},[x,s]),l.useEffect(()=>{i!=null&&i.workflowResult&&r&&r(i.workflowResult)},[i==null?void 0:i.workflowResult,r]),l.useEffect(()=>{a==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},[a]),l.useEffect(()=>{v&&f(!1)},[v]),w||!i)return e.jsx("div",{className:n,children:e.jsx(T,{children:e.jsxs(M,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading workflow..."})]})})});if(x)return e.jsx("div",{className:n,children:e.jsx(T,{children:e.jsx(M,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-danger-500 text-lg mb-4",children:"An error occurred"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:x.message})]})})})});if(v&&!k)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(T,{children:e.jsx(M,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-blue-100 dark:bg-blue-900 mb-4",children:e.jsx("svg",{className:"w-8 h-8 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 dark:text-white mb-2",children:"Workflow Transition"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:"Your application workflow has been updated based on your progress."}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-lg p-4 mb-6 max-w-md mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-1",children:"Previous Workflow"}),e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:d})]}),e.jsx("svg",{className:"w-6 h-6 text-gray-400 mx-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7l5 5m0 0l-5 5m5-5H6"})}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-1",children:"New Workflow"}),e.jsx("p",{className:"font-medium text-blue-600 dark:text-blue-400",children:m})]})]}),i.nextWorkflowName&&e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-2 text-xs",children:i.nextWorkflowName})]}),e.jsx("button",{onClick:()=>f(!0),className:"px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg transition-colors",children:"Continue with New Workflow"})]})})})});if(i.status===me.Finished||i.status===me.OnHold)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(Be,{kycStatus:i.kycStatus,reviewStatus:i.reviewStatus,workflowResult:i.workflowResult,customMessage:i.customMessage,onContinue:r&&i.workflowResult?()=>r(i.workflowResult):void 0,onContactSupport:()=>{typeof window<"u"&&(window.location.href="mailto:support@example.com")}})});if(!o)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(T,{children:e.jsxs(M,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:i.status===me.IdentityPending?"Loading identity verification...":"Loading current step..."})]})})});const p=b=>{switch(b){case z.Overview:return"Overview";case z.Questionaries:return"Questionnaire";case z.UploadDocument:return"Documents";case z.IdentitySdk:return"Identity";case z.RiskScoring:return"Risk Assessment";case z.InvestorCategorization:return"Investor Categorization";case z.AppropriatenessTest:return"Appropriateness Test";case z.AdditionalData:return"Additional Data";case z.ManualReview:return"Review";default:return""}},R=()=>{const b=c.filter(y=>y.visibility!==!1),_=b.findIndex(y=>y.order===o.order),W=_>=0?_+1:1,P=b.length;return e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsx(Le,{}),e.jsxs(ye,{variant:i.status===1?"info":"success",children:["Step ",W," of ",P]})]}),e.jsx("div",{className:"flex items-center",children:b.map((y,S)=>{const I=S<_,Y=y.order===o.order;return e.jsxs(l.Fragment,{children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`
|
|
64
|
+
${x[D.id]===Q?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}
|
|
65
|
+
`,children:[e.jsx("input",{type:"radio",name:`question-${D.id}`,value:Q,checked:x[D.id]===Q,onChange:ae=>S(D.id,ae.target.value),className:"h-4 w-4 text-primary-500 border-gray-300 focus:ring-primary-500",disabled:u}),e.jsx("span",{className:"ml-3 text-gray-700 dark:text-gray-300",children:Q})]},_))})]},D.id)),v&&!I&&e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsxs("p",{className:"text-red-600 dark:text-red-400 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",v]})}),I&&e.jsx("div",{className:"p-4 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-700 dark:text-yellow-400 text-sm",children:[e.jsx("strong",{children:"Time's up!"})," Your answers are being submitted automatically."]})})]}),e.jsxs(le,{className:"flex justify-between",children:[e.jsx(B,{type:"button",variant:"outline",onClick:s,disabled:u,children:"Cancel"}),e.jsx(B,{type:"submit",isLoading:u,disabled:Object.keys(x).length<n.totalQuestionCount,children:I?"Submitting...":"Submit Test"})]})]})}):e.jsxs(M,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:n.displayName}),n.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:n.subtitle})]}),e.jsxs(O,{children:[n.description&&e.jsx("div",{className:"mb-6 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg",children:e.jsx("p",{className:"text-gray-700 dark:text-gray-300",children:n.description})}),e.jsxs("div",{className:"space-y-4 mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:"Total Questions:"}),e.jsx(fe,{variant:"info",children:n.totalQuestionCount})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:"Time Limit:"}),e.jsx(fe,{variant:"info",children:L(n.testDurationSec)})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:"Correct Answers Required:"}),e.jsx(fe,{variant:"info",children:n.testCorrectAnswerPassLimit})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:"Attempts Remaining:"}),e.jsx(fe,{variant:H>1?"success":"warning",children:H})]})]}),v&&e.jsx("div",{className:"mb-4 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsxs("p",{className:"text-red-600 dark:text-red-400 text-sm",children:[e.jsx("strong",{children:"Previous Attempt:"})," ",v]})}),H<=0&&e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsx("p",{className:"text-red-600 dark:text-red-400",children:"You have used all your attempts. Please contact support for assistance."})})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(B,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(B,{type:"button",onClick:f,disabled:H<=0,children:"Start Test"})]})]})},ir=({applicantId:t,onComplete:r,onBack:s})=>{var Q,_,ae,he;const{applicantService:a,baseInformationService:n,config:i}=de(),{identityData:o,provider:c,token:u,isLoading:p,error:v,requestIdentity:w,restartIdentity:x}=qt(t),[h,g]=l.useState(null),[k,y]=l.useState(null),[m,I]=l.useState([]),[j,b]=l.useState(!0),[U,q]=l.useState(!1),[L,f]=l.useState(null),[S,R]=l.useState(!1),W=l.useRef(!1),H=ke.useForm({defaultValues:{street:"",streetNumber:"",city:"",zip:"",country:"",nationality:"",phonenumber:""}});l.useEffect(()=>{(async()=>{try{const[F,G]=await Promise.all([a.getApplicantData(t),n.getCountries("","en")]);y(F);const V=new Set,te=G.filter(ge=>{const Ie=ge.abbreviation3||ge.abbreviation;return!Ie||V.has(Ie)?!1:(V.add(Ie),!0)});I(te);const K=F.applicantRequestData;if(H.reset({street:(K==null?void 0:K.street)||"",streetNumber:(K==null?void 0:K.streetNumber)||"",city:(K==null?void 0:K.city)||"",zip:(K==null?void 0:K.zip)||"",country:(K==null?void 0:K.country)||"",nationality:(K==null?void 0:K.nationality)||"",phonenumber:(K==null?void 0:K.phonenumber)||""}),F.kycRecords&&F.kycRecords.length>0&&F.kycRecords[0].providerTokenObject!==null&&!W.current){console.log("[Identity] Found existing identity verification, auto-requesting..."),W.current=!0;try{await w(),q(!0)}catch(ge){console.error("[Identity] Auto-request failed:",ge)}}}catch(F){console.error("Error loading applicant data:",F)}finally{b(!1)}})()},[t]),l.useEffect(()=>{o&&!U&&(console.log("[Identity] Identity data already loaded, showing provider"),q(!0))},[o,U]),l.useEffect(()=>{if(u){if(u.expiresAt){const T=new Date(u.expiresAt).getTime();if(Date.now()>=T){console.warn("[Identity] Token has expired (expiresAt)"),R(!0),f("Your verification session has expired. Please restart.");return}}if(u.url)try{const F=new URL(u.url).toString().toLowerCase();if(F.includes("expired")||F.includes("invalid")||F.includes("error")){console.warn("[Identity] Token URL indicates expiration"),R(!0),f("Your verification link has expired. Please restart.");return}}catch{console.error("[Identity] Invalid token URL")}if(u.status==="expired"||u.error==="expired"||u.expired===!0){console.warn("[Identity] Token object indicates expiration"),R(!0),f("Your verification session has expired. Please restart.");return}}},[u]),l.useEffect(()=>{if(c!==null&&u&&!h&&U&&!S){const T=c;if(u.url){console.log("[Identity] Loading provider URL for user verification:",u.url),f(null);try{if(new URL(u.url),T===ue.SardinAI){console.log("[SardinAI] Initializing Risk SDK in background...");try{const F=Ne.parseProviderConfig(c,u,i);Ne.createProvider(c,F).initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully in background")}).catch(V=>{console.warn("[SardinAI] Risk SDK initialization failed (non-blocking):",V)})}catch(F){console.warn("[SardinAI] Risk SDK setup failed (non-blocking):",F)}}g({type:"url",url:u.url})}catch(F){console.error("[Identity] Invalid URL:",F),f("Invalid verification URL. Please restart."),R(!0)}return}if(T===ue.SardinAI){console.log("[SardinAI] No URL provided - initializing Risk SDK only..."),f(null);try{const F=Ne.parseProviderConfig(c,u,i),G=Ne.createProvider(c,F);G.initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully"),g(G),setTimeout(()=>{r==null||r()},2e3)}).catch(V=>{var K;console.error("[SardinAI] Failed to initialize:",V);const te=((K=V.message)==null?void 0:K.toLowerCase())||"";te.includes("expired")||te.includes("invalid")||te.includes("401")||te.includes("400")?(R(!0),f("Session expired or invalid. Please restart verification.")):f(`Failed to initialize: ${V.message}`)})}catch(F){console.error("[SardinAI] Error creating provider:",F),f(`Configuration error: ${F.message}`)}return}try{f(null);const F=Ne.parseProviderConfig(c,u,i),G=Ne.createProvider(c,F);T===ue.Sumsub?(G.initialize("identity-container").catch(V=>{var te;console.error("[Sumsub] Initialization error:",V),f(`Failed to initialize: ${V.message}`),(te=V.message)!=null&&te.toLowerCase().includes("expired")&&R(!0)}),G.onComplete&&G.onComplete(()=>{r==null||r()})):T===ue.Onfido&&G.initialize("identity-container").catch(V=>{console.error("[Onfido] Initialization error:",V),f(`Failed to initialize: ${V.message}`)}),g(G)}catch(F){console.error("[Identity] Provider setup error:",F),f(`Setup error: ${F.message}`)}}return()=>{if(h&&h.destroy)try{h.destroy()}catch(T){console.error("[Identity] Error destroying provider:",T)}}},[c,u,h,U,r,S]);const D=async()=>{try{f(null),R(!1),await w(),q(!0)}catch(T){console.error("Error starting identity verification:",T)}},E=async()=>{try{f(null),R(!1),g(null),console.log("[Identity] Restarting verification..."),await x(),q(!0)}catch(T){console.error("Error restarting identity verification:",T),f(T.message||"Failed to restart verification")}};if(j||p)return e.jsx(M,{children:e.jsxs(O,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading identity verification..."})]})});if(v)return e.jsx(M,{children:e.jsx(O,{children:e.jsxs("p",{className:"text-danger-500",children:["Error: ",v.message]})})});if(U&&(L||S))return e.jsxs(M,{children:[e.jsx(se,{children:e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Verification Session Issue"})}),e.jsxs(O,{children:[e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg mb-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("svg",{className:"h-6 w-6 text-red-600 dark:text-red-400 mr-3 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-1",children:S?"Session Expired":"Verification Error"}),e.jsx("p",{className:"text-red-800 dark:text-red-200 text-sm",children:L||"Your verification session has expired and needs to be restarted."})]})]})}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What to do next:"}),e.jsxs("ul",{className:"text-blue-800 dark:text-blue-200 text-sm space-y-1 list-disc list-inside",children:[e.jsx("li",{children:'Click "Restart Verification" below to generate a new session'}),e.jsx("li",{children:"Complete the verification process without delays"}),e.jsx("li",{children:"If issues persist, contact support"})]})]})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(B,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(B,{type:"button",onClick:E,disabled:p,children:p?"Restarting...":"Restart Verification"})]})]});if(U&&o){const T=c;return u!=null&&u.url?e.jsxs(M,{children:[e.jsx(se,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(B,{type:"button",variant:"outline",size:"sm",onClick:E,disabled:p,children:"Restart"})]})}),e.jsxs(O,{children:[e.jsx("div",{className:"mb-4 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-800 dark:text-yellow-200 text-sm",children:[e.jsx("strong",{children:"Important:"}),' If you see an "expired" or "invalid link" message below, click the "Restart" button above to generate a new verification session.']})}),e.jsx("div",{className:"w-full",style:{height:"600px"},children:e.jsx("iframe",{src:u.url,className:"w-full h-full border-0 rounded-lg",allow:"camera; microphone; geolocation",title:"Identity Verification",onLoad:F=>{var G,V,te;console.log("[Identity] Iframe loaded");try{const K=F.target,Se=K.contentDocument||((G=K.contentWindow)==null?void 0:G.document);if(Se){const ge=((te=(V=Se.body)==null?void 0:V.textContent)==null?void 0:te.toLowerCase())||"";(ge.includes("expired")||ge.includes("invalid")||ge.includes("error"))&&(console.warn("[Identity] Iframe shows expiration message"),R(!0),f("Your verification link has expired."))}}catch{console.log("[Identity] Cannot check iframe content (CORS)")}}})})]}),s&&e.jsx(le,{children:e.jsx(B,{variant:"outline",onClick:s,children:"Back"})})]}):T===ue.SardinAI?e.jsxs(M,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Device Risk Assessment"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Analyzing device security and behavioral patterns..."})]}),e.jsx(O,{children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(pe,{className:"mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please wait while we verify your device security"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-500 mt-2",children:"This process is automatic and will complete in a few seconds"})]})})]}):e.jsxs(M,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(O,{children:e.jsx("div",{id:"identity-container",className:"min-h-[400px]"})}),s&&e.jsx(le,{children:e.jsx(B,{variant:"outline",onClick:s,children:"Back"})})]})}return e.jsx("form",{onSubmit:H.handleSubmit(D),children:e.jsxs(M,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Review Your Information"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please review and confirm your information before starting identity verification"})]}),e.jsxs(O,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-500 dark:text-gray-400",children:"Name"}),e.jsxs("p",{className:"mt-1 text-base",children:[(Q=k==null?void 0:k.applicantRequestData)==null?void 0:Q.firstName," ",(_=k==null?void 0:k.applicantRequestData)==null?void 0:_.lastName]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-500 dark:text-gray-400",children:"Email"}),e.jsx("p",{className:"mt-1 text-base",children:(ae=k==null?void 0:k.applicantRequestData)==null?void 0:ae.email})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-500 dark:text-gray-400",children:"Date of Birth"}),e.jsx("p",{className:"mt-1 text-base",children:((he=k==null?void 0:k.applicantRequestData)==null?void 0:he.dateOfBirth)||"Not provided"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Address Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(ke.Controller,{control:H.control,name:"country",render:({field:T})=>e.jsx(be,{...T,label:"Country",options:[{value:"",label:"Select country..."},...m.map(F=>({value:F.abbreviation3||F.abbreviation,label:F.name}))]})}),e.jsx(ke.Controller,{control:H.control,name:"nationality",render:({field:T})=>e.jsx(be,{...T,label:"Nationality",options:[{value:"",label:"Select nationality..."},...m.map(F=>({value:F.abbreviation3||F.abbreviation,label:F.name}))]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(ke.Controller,{control:H.control,name:"street",render:({field:T})=>e.jsx(ie,{...T,label:"Street"})}),e.jsx(ke.Controller,{control:H.control,name:"streetNumber",render:({field:T})=>e.jsx(ie,{...T,label:"Street Number"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(ke.Controller,{control:H.control,name:"city",render:({field:T})=>e.jsx(ie,{...T,label:"City"})}),e.jsx(ke.Controller,{control:H.control,name:"zip",render:({field:T})=>e.jsx(ie,{...T,label:"ZIP/Postal Code"})})]}),e.jsx(ke.Controller,{control:H.control,name:"phonenumber",render:({field:T})=>e.jsx(ie,{...T,label:"Phone Number",type:"tel"})})]})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(B,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(B,{type:"submit",isLoading:p,children:"Confirm and Start Verification"})]})]})})},Ue=({kycStatus:t,reviewStatus:r,workflowResult:s,customMessage:a,onContinue:n,onContactSupport:i})=>{const c=t===we.Approved?{type:"success",title:"Verification Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your identity verification has been successfully approved."}:t===we.Rejected?{type:"error",title:"Verification Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Unfortunately, your identity verification was not approved."}:t===we.Pending||t===we.InProgress?{type:"pending",title:"Verification Pending",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your identity verification is currently being processed."}:r===je.Approved?{type:"success",title:"Application Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your application has been approved."}:r===je.Reject?{type:"error",title:"Application Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Your application has been rejected."}:r===je.UnderReview||r===je.AdminReview?{type:"pending",title:"Under Review",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application is currently under manual review."}:s===De.Success?{type:"success",title:"Process Complete",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your verification process has been completed successfully."}:s===De.Failed?{type:"error",title:"Process Failed",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"The verification process could not be completed."}:s===De.AdminReview?{type:"pending",title:"Admin Review Required",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application requires administrator review."}:{type:"pending",title:"Processing",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your application is being reviewed."};return e.jsxs(M,{children:[e.jsxs(O,{className:"py-12",children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx("div",{className:`w-24 h-24 rounded-full flex items-center justify-center ${c.iconBg}`,children:e.jsx("span",{className:`text-5xl ${c.iconColor}`,children:c.icon})})}),e.jsx("h2",{className:"text-3xl font-bold text-center text-gray-900 dark:text-white mb-4",children:c.title}),e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx(fe,{variant:c.type==="success"?"success":c.type==="error"?"danger":c.type==="pending"?"warning":"info",children:t!=null?we[t]:je[r]})}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mb-6 max-w-md mx-auto",children:a||c.message}),c.type==="success"&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-green-900 dark:text-green-100 mb-2",children:"What's Next?"}),e.jsxs("ul",{className:"text-sm text-green-800 dark:text-green-200 space-y-1",children:[e.jsx("li",{children:"✓ Your identity has been verified"}),e.jsx("li",{children:"✓ You can now proceed with your application"}),e.jsx("li",{children:"✓ All features are now accessible"})]})]}),c.type==="error"&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-2",children:"What Can You Do?"}),e.jsxs("ul",{className:"text-sm text-red-800 dark:text-red-200 space-y-2",children:[e.jsx("li",{children:"• Review the requirements and ensure all information is correct"}),e.jsx("li",{children:"• Contact our support team for assistance"}),e.jsx("li",{children:"• You may be able to resubmit your application"})]})]}),c.type==="pending"&&e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What Happens Next?"}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-2",children:[e.jsx("li",{children:"• Our team is reviewing your information"}),e.jsx("li",{children:"• You will be notified via email once the review is complete"}),e.jsx("li",{children:"• This typically takes 24-48 hours"}),e.jsx("li",{children:"• No action is required from you at this time"})]})]}),e.jsx("div",{className:"mt-6 pt-6 border-t border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"KYC Status:"}),e.jsx("div",{className:"font-medium text-gray-900 dark:text-white mt-1",children:t!=null?we[t]:"Not Available"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Review Status:"}),e.jsx("div",{className:"font-medium text-gray-900 dark:text-white mt-1",children:je[r]})]})]})})]}),e.jsxs(le,{className:"flex justify-center gap-4",children:[c.type==="success"&&n&&e.jsx(B,{onClick:n,size:"lg",children:"Continue"}),c.type==="error"&&e.jsxs(e.Fragment,{children:[i&&e.jsx(B,{variant:"outline",onClick:i,children:"Contact Support"}),n&&e.jsx(B,{onClick:n,children:"Try Again"})]}),c.type==="pending"&&e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Please check back later or wait for our email notification"})})]})]})},lr=({config:t,className:r=""})=>!(t!=null&&t.visible)||!(t!=null&&t.url)?null:e.jsx("div",{className:`metakyc-logo ${r}`,children:e.jsx("img",{src:t.url,alt:t.alt||"Company Logo",style:{width:t.width||"auto",height:t.height||"40px",maxWidth:"100%",objectFit:"contain"},onError:s=>{console.warn("[Logo] Failed to load logo:",t.url),s.target.style.display="none"}})}),Oe=({title:t,subtitle:r,className:s=""})=>{const{currentTheme:a}=de(),n=t||(a==null?void 0:a.title)||"",i=!!(a!=null&&a.logo&&a.logo.visible&&a.logo.url),o=!!n;return!i&&!o?null:e.jsxs("div",{className:`metakyc-header ${s}`,children:[e.jsxs("div",{className:"metakyc-header-title flex items-center text-xl font-bold text-gray-900 dark:text-white",children:[i&&e.jsx(lr,{config:a.logo}),i&&o&&e.jsx("span",{className:"text-gray-400 dark:text-gray-500 mx-3",style:{fontSize:"1.5rem",fontWeight:300},children:"|"}),o&&e.jsx("span",{children:n})]}),r&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:r})]})},Be=["firstName","lastName","email","phonenumber","dateOfBirth"];function Pe(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const Le={width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"},Tr=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:a})=>{var qe,He,We;const{config:n,baseInformationService:i,currentTheme:o}=de(),{createApplicant:c,isLoading:u}=Wt(),p=t||((qe=n.applicantForm)==null?void 0:qe.workflowKey);if(!p)throw new Error("workflowKey is required. Provide it either as a prop to CreateApplicantForm or set it in config.applicantForm.workflowKey");const v=r||((He=n.applicantForm)==null?void 0:He.externalRefId)||"",[w,x]=l.useState([]),[h,g]=l.useState(!0),k=l.useRef(!1),y=l.useRef(!1);l.useEffect(()=>{(async()=>{if(!(k.current||y.current)){k.current=!0,g(!0);try{const C=await i.getCountries("",n.locale||"en"),P=new Set;x(C.map(N=>({value:N.abbreviation3||N.abbreviation,label:N.name})).filter(N=>!N.value||P.has(N.value)?!1:(P.add(N.value),!0))),y.current=!0}catch(C){console.error("Failed to load countries:",C)}finally{g(!1),k.current=!1}}})()},[]);const m=l.useMemo(()=>o!=null&&o.applicantFormPages&&o.applicantFormPages.length>0?o.applicantFormPages:null,[o==null?void 0:o.applicantFormPages]),I=l.useMemo(()=>{const d=new Set(Be),C=o==null?void 0:o.applicantFormRequiredFields;if(C)for(const P of C)d.add(P);if(m)for(const P of m)for(const N of P.fields)!N.isCustom&&N.name&&N.required&&d.add(N.name);return Array.from(d)},[o==null?void 0:o.applicantFormRequiredFields,m]),j=l.useMemo(()=>{var P;if(m){const N=m.flatMap($=>$.fields).filter($=>!$.isCustom&&$.name).map($=>$.name),A=new Set(N);for(const $ of Be)A.add($);return Array.from(A)}let d;(P=n.applicantForm)!=null&&P.visibleFields?d=n.applicantForm.visibleFields:o!=null&&o.applicantFormVisibleFields&&o.applicantFormVisibleFields.length>0?d=o.applicantFormVisibleFields:d=it;const C=new Set(d);for(const N of Be)C.add(N);return Array.from(C)},[(We=n.applicantForm)==null?void 0:We.visibleFields,o==null?void 0:o.applicantFormVisibleFields,m]),[b,U]=l.useState({workflowKey:p,firstName:"",lastName:"",title:"",email:"",dateOfBirth:"",phonenumber:"",externalRefId:v,mobileCountryCode:"",street:"",streetNumber:"",zip:"",city:"",country:"",nationality:"",otherNationality:[],defaultLanguage:"EN",taxCountry:"",placeOfBirth:"",countryOfBirth:"",salutation:null,educationLevel:"",occupation:"",taxNumber:""}),[q,L]=l.useState({}),[f,S]=l.useState(0),[R,W]=l.useState({}),[H,D]=l.useState(null),[E,Q]=l.useState(!1),_=(d,C)=>U(P=>({...P,[d]:C})),ae=(d,C)=>L(P=>({...P,[d]:C})),he=d=>!d.conditionalOn||q[d.conditionalOn]==="true",T=l.useMemo(()=>{if(!m)return-1;for(let d=f+1;d<m.length;d++)if(he(m[d]))return d;return-1},[m,f,q]),F=l.useMemo(()=>{if(!m)return-1;for(let d=f-1;d>=0;d--)if(he(m[d]))return d;return-1},[m,f,q]),G=d=>{var P;const C={};for(const N of d.fields)if(N.isCustom){if(N.required&&N.paramName){const A=q[N.paramName],$=N.displayText||N.label||N.paramName;N.customType==="checkbox"||N.customType==="link_checkbox"?A!=="true"&&(C[N.paramName]=`${$} is required.`):(!A||A.trim()==="")&&(C[N.paramName]=`${$} is required.`)}}else if(N.name){const A=N.name;if(I.includes(A)&&Pe(b[A])){const $=N.displayText||((P=Te[A])==null?void 0:P.label)||A;C[A]=`${$} is required.`}}return C},V=async()=>{if(!m)return;const d=G(m[f]);if(Object.keys(d).length>0){W(d);return}W({}),T>=0?S(T):await te()},te=async()=>{if(m){let d={};for(const C of m)he(C)&&(d={...d,...G(C)});if(Object.keys(d).length>0){W(d);return}}Q(!0),D(null);try{if(!b.externalRefId||b.externalRefId.trim()===""){D("External Reference ID is required. Please pass it via config.applicantForm.externalRefId.");return}const d={workflowKey:b.workflowKey,externalRefId:b.externalRefId.trim()};if(m){for(const N of m)if(he(N)){for(const A of N.fields)if(!A.isCustom&&A.name){const $=A.name,Z=b[$];Pe(Z)||(d[$]=Z)}}}else j.forEach(N=>{if(N==="externalRefId")return;const A=b[N];Pe(A)||(d[N]=A)});const C=[];if(m){for(const N of m)if(he(N)){for(const A of N.fields)if(A.isCustom&&A.paramName){const $=q[A.paramName]??"";C.push({paramName:A.paramName,paramValue:$})}}}C.length>0&&(d.applicantAdditionalDatas=C);const P=await c(d);s(P.applicantId)}catch(d){console.error("Error creating applicant:",d),D(d.message||"Failed to create applicant")}finally{Q(!1)}},K=async d=>{var C;d.preventDefault();for(const P of I)if(Pe(b[P])){const N=((C=Te[P])==null?void 0:C.label)||P;D(`${N} is required.`);return}await te()},Se=(d,C,P)=>{var Re;const N=Te[d];if(!N)return null;const A=I.includes(d),$=R[d],Z=P||N.label,oe=C??d,J={required:A};switch(N.type){case"select":if(d==="country"||d==="nationality"||d==="taxCountry"||d==="countryOfBirth")return e.jsx(be,{...J,label:Z,value:b[d]||"",onChange:re=>_(d,re.target.value),options:[{value:"",label:`Select ${Z.toLowerCase()}...`},...w],disabled:h},oe);if(d==="salutation")return e.jsx(be,{...J,label:Z,value:((Re=b[d])==null?void 0:Re.toString())||"",onChange:re=>_(d,re.target.value?Number(re.target.value):null),options:[{value:"",label:"Select salutation..."},{value:Fe.Male.toString(),label:"Male"},{value:Fe.Female.toString(),label:"Female"},{value:Fe.Other.toString(),label:"Other"}]},oe);if(d==="defaultLanguage"){const re=o!=null&&o.allowedLanguages&&o.allowedLanguages.length>0?$e.filter(ze=>o.allowedLanguages.includes(ze.value)):$e;return e.jsx(be,{...J,label:Z,value:b[d]||"",onChange:ze=>_(d,ze.target.value),options:[{value:"",label:"Select language..."},...re]},oe)}return null;case"multiselect":return d==="otherNationality"?e.jsx(Yt,{...J,label:Z,value:b[d]||[],onChange:re=>_(d,re),options:w,placeholder:"Select other nationalities...",disabled:h},oe):null;case"date":return e.jsx(ie,{...J,type:"date",label:Z,value:b[d]||"",onChange:re=>_(d,re.target.value),error:$},oe);case"email":return e.jsx(ie,{...J,type:"email",label:Z,value:b[d]||"",onChange:re=>_(d,re.target.value),error:$},oe);case"tel":return e.jsx(ie,{...J,type:"tel",label:Z,value:b[d]||"",onChange:re=>_(d,re.target.value),error:$},oe);default:return e.jsx(ie,{...J,type:"text",label:Z,value:b[d]||"",onChange:re=>_(d,re.target.value),error:$},oe)}},ge=(d,C)=>{if(!d.paramName)return null;const P=R[d.paramName],N=d.displayText||d.label||d.paramName;if(d.customType==="checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:q[d.paramName]==="true",onChange:A=>ae(d.paramName,A.target.checked?"true":"false"),className:"metakyc-option-input",style:Le}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[N,d.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),P&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:P})]},`custom-${C}`);if(d.customType==="link_checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:q[d.paramName]==="true",onChange:A=>ae(d.paramName,A.target.checked?"true":"false"),className:"metakyc-option-input",style:{...Le,alignSelf:"flex-start",marginTop:"2px"}}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[N," ",d.linkUrl&&e.jsx("a",{href:d.linkUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",style:{color:"var(--metakyc-primary, #2563eb)"},onClick:A=>A.stopPropagation(),children:d.linkText||d.linkUrl}),d.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),P&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:P})]},`custom-${C}`);if(d.customType==="group_checkbox"){const A=(q[d.paramName]||"").split(",").filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[N,d.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(d.options||[]).map($=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:A.includes($.value),onChange:Z=>{const oe=Z.target.checked?[...A,$.value]:A.filter(J=>J!==$.value);ae(d.paramName,oe.join(","))},className:"metakyc-option-input",style:Le}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:$.label})]},$.value))}),P&&e.jsx("p",{className:"text-red-500 text-xs",children:P})]},`custom-${C}`)}return d.customType==="radio_group"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[N,d.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(d.options||[]).map(A=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:q[d.paramName]===A.value,onChange:()=>ae(d.paramName,A.value),name:`radio-group-${d.paramName}-${C}`,className:"metakyc-option-input",style:Le}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:A.label})]},A.value))}),P&&e.jsx("p",{className:"text-red-500 text-xs",children:P})]},`custom-${C}`):e.jsx(ie,{type:"text",label:`${N}${d.required?" *":""}`,value:q[d.paramName]||"",onChange:A=>ae(d.paramName,A.target.value),required:d.required,error:P},`custom-${C}`)},Ie=d=>e.jsx("div",{className:"grid grid-cols-2 gap-4",children:d.fields.map((C,P)=>{const N=C.colSpan===1?"col-span-1":"col-span-2",A=C.isCustom?`custom-${P}-${C.paramName}`:`builtin-${C.name}-${P}`;return e.jsx("div",{className:N,children:C.isCustom?ge(C,P):Se(C.name,A,C.displayText)},A)})});if(h)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(M,{children:e.jsxs(O,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading form..."})]})})});if(m){const d=m[f]??m[0],C=F===-1,P=T===-1,N=m.length,A=m.filter(he).length,$=m.slice(0,f+1).filter(he).length,Z=Object.values(R);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(M,{children:[e.jsx(se,{children:e.jsx(Oe,{title:(o==null?void 0:o.title)||"Create Applicant"})}),e.jsxs(O,{children:[(d.title||d.subtitle||d.description)&&e.jsxs("div",{className:"mb-4",children:[d.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:d.title}),d.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:d.subtitle}),d.description&&d.description!==d.subtitle&&e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:d.description})]}),(H||Z.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[H&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",H]}),Z.map((oe,J)=>e.jsx("p",{className:"text-red-600 text-sm",children:oe},J))]}),N>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[m.map((oe,J)=>{const Re=he(oe);return e.jsx("div",{className:`h-1.5 rounded-full transition-all ${J===f?"flex-1":"w-8"} ${Re?"":"opacity-30"}`,style:J===f?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:J<f?{backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:Re?.7:.2}:{backgroundColor:"#e5e7eb"}},J)}),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[$," / ",A]})]}),Ie(d)]}),e.jsxs(le,{className:"flex justify-between",children:[e.jsxs("div",{children:[!C&&e.jsx(B,{type:"button",variant:"outline",onClick:()=>{S(F),W({})},disabled:E||u,children:"Previous"}),C&&a&&e.jsx(B,{type:"button",variant:"outline",onClick:a,disabled:E||u,children:"Cancel"})]}),e.jsx(B,{type:"button",isLoading:E||u,onClick:P?te:V,children:P?"Submit":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:K,children:e.jsxs(M,{children:[e.jsx(se,{children:e.jsx(Oe,{title:(o==null?void 0:o.title)||"Create Applicant"})}),e.jsxs(O,{children:[H&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",H]})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:j.map(d=>Se(d))})]}),e.jsxs(le,{className:"flex justify-between",children:[a&&e.jsx(B,{type:"button",variant:"outline",onClick:a,disabled:E||u,children:"Cancel"}),e.jsx(B,{type:"submit",isLoading:E||u,children:"Create Applicant"})]})]})})})},Mr=({applicantId:t,onComplete:r,onError:s,theme:a="light",className:n})=>{const{progress:i,currentStep:o,steps:c,workflowKey:u,nextWorkflowKey:p,hasWorkflowChanged:v,isLoading:w,error:x,moveBack:h,refreshProgress:g}=$t(t),[k,y]=l.useState(!1);if(l.useEffect(()=>{x&&s&&s(x)},[x,s]),l.useEffect(()=>{i!=null&&i.workflowResult&&r&&r(i.workflowResult)},[i==null?void 0:i.workflowResult,r]),l.useEffect(()=>{a==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},[a]),l.useEffect(()=>{v&&y(!1)},[v]),w||!i)return e.jsx("div",{className:n,children:e.jsx(M,{children:e.jsxs(O,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading workflow..."})]})})});if(x)return e.jsx("div",{className:n,children:e.jsx(M,{children:e.jsx(O,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-danger-500 text-lg mb-4",children:"An error occurred"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:x.message})]})})})});if(v&&!k)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(M,{children:e.jsx(O,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-blue-100 dark:bg-blue-900 mb-4",children:e.jsx("svg",{className:"w-8 h-8 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 dark:text-white mb-2",children:"Workflow Transition"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:"Your application workflow has been updated based on your progress."}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-lg p-4 mb-6 max-w-md mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-1",children:"Previous Workflow"}),e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:u})]}),e.jsx("svg",{className:"w-6 h-6 text-gray-400 mx-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7l5 5m0 0l-5 5m5-5H6"})}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-1",children:"New Workflow"}),e.jsx("p",{className:"font-medium text-blue-600 dark:text-blue-400",children:p})]})]}),i.nextWorkflowName&&e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-2 text-xs",children:i.nextWorkflowName})]}),e.jsx("button",{onClick:()=>y(!0),className:"px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg transition-colors",children:"Continue with New Workflow"})]})})})});if(i.status===me.Finished||i.status===me.OnHold)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(Ue,{kycStatus:i.kycStatus,reviewStatus:i.reviewStatus,workflowResult:i.workflowResult,customMessage:i.customMessage,onContinue:r&&i.workflowResult?()=>r(i.workflowResult):void 0,onContactSupport:()=>{typeof window<"u"&&(window.location.href="mailto:support@example.com")}})});if(!o)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(M,{children:e.jsxs(O,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:i.status===me.IdentityPending?"Loading identity verification...":"Loading current step..."})]})})});const m=b=>{switch(b){case z.Overview:return"Overview";case z.Questionaries:return"Questionnaire";case z.UploadDocument:return"Documents";case z.IdentitySdk:return"Identity";case z.RiskScoring:return"Risk Assessment";case z.InvestorCategorization:return"Investor Categorization";case z.AppropriatenessTest:return"Appropriateness Test";case z.AdditionalData:return"Additional Data";case z.ManualReview:return"Review";default:return""}},I=()=>{const b=c.filter(f=>f.visibility!==!1),U=b.findIndex(f=>f.order===o.order),q=U>=0?U+1:1,L=b.length;return e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsx(Oe,{}),e.jsxs(fe,{variant:i.status===1?"info":"success",children:["Step ",q," of ",L]})]}),e.jsx("div",{className:"flex items-center",children:b.map((f,S)=>{const R=S<U,W=f.order===o.order;return e.jsxs(l.Fragment,{children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`
|
|
66
66
|
w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium
|
|
67
|
-
${
|
|
68
|
-
`,children:S+1}),e.jsx("span",{className:`ml-2 text-sm ${
|
|
67
|
+
${R||W?"bg-primary-500 text-white":"bg-gray-200 text-gray-600 dark:bg-gray-700 dark:text-gray-400"}
|
|
68
|
+
`,children:S+1}),e.jsx("span",{className:`ml-2 text-sm ${W?"font-semibold text-gray-900 dark:text-white":"text-gray-600 dark:text-gray-400"}`,children:f.displayName||f.name||m(f.action)||`Step ${S+1}`})]}),S<b.length-1&&e.jsx("div",{className:`flex-1 h-0.5 mx-4 ${R?"bg-primary-500":"bg-gray-200 dark:bg-gray-700"}`})]},f.order)})})]})},j=()=>{const b={applicantId:t,onComplete:async()=>{await g()},onBack:o.order>0?h:void 0};switch(o.action){case z.Questionaries:return e.jsx(er,{...b});case z.UploadDocument:return e.jsx(tr,{...b});case z.Overview:return e.jsx(rr,{...b});case z.IdentitySdk:return e.jsx(ir,{...b});case z.RiskScoring:return e.jsx(sr,{...b});case z.AdditionalData:case z.InvestorCategorization:return e.jsx(ar,{...b});case z.AppropriatenessTest:return e.jsx(nr,{...b});case z.ManualReview:return e.jsx(Ue,{kycStatus:i.kycStatus,reviewStatus:i.reviewStatus,workflowResult:i.workflowResult,customMessage:i.customMessage});default:return e.jsx(M,{children:e.jsxs(O,{className:"py-12 text-center",children:[e.jsx("div",{className:"mb-4",children:e.jsx(pe,{})}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mb-2",children:["Processing step: ",o.title||o.name]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Action type: ",z[o.action]]})]})})}};return e.jsxs("div",{className:`metakyc-sdk ${n||""}`,children:[I(),j()]})};function Or(t){return ve.z.object({questionResults:ve.z.any()}).passthrough()}function zr(t){let r=ve.z.array(ve.z.instanceof(File));if(t.isRequired?r=r.min(1,`${t.displayName} is required`):r=r.optional(),t.multipleFile||(r=r.refine(s=>!s||s.length<=1,{message:"Only one file is allowed"})),t.maxEachFileSizeByte>0&&(r=r.refine(s=>!s||s.every(a=>a.size<=t.maxEachFileSizeByte),{message:`File size must not exceed ${Math.round(t.maxEachFileSizeByte/1024/1024)}MB`})),t.allowedTypes){const s=t.allowedTypes.split(",").map(a=>a.trim());r=r.refine(a=>a?a.every(n=>s.some(i=>i.endsWith("/*")?n.type.startsWith(i.slice(0,-2)):n.type===i)):!0,{message:"Invalid file type"})}return r}function Br(t){const r={};return t.uploadDocumentFiles.forEach(s=>{const a=`file_${s.id}`;r[a]=zr(s)}),ve.z.object(r)}function $r(t){return ve.z.any()}function Ur(t){return ve.z.string().min(1,"This question is required")}function _r(t){const r={};return t.appropriatenessQuestions.forEach(s=>{const a=`question_${s.id}`;r[a]=Ur()}),ve.z.object(r)}const Kr=ve.z.any();exports.ALLOWED_LANGUAGES=$e;exports.ApplicantProgressOnHoldReason=Ve;exports.ApplicantProgressStatus=me;exports.ApplicantService=dt;exports.ApplicantStatus=Ze;exports.AppropriatenessQuestionType=rt;exports.AppropriatenessTestService=pt;exports.AppropriatenessTestStep=nr;exports.Badge=fe;exports.BaseInformationService=ft;exports.Button=B;exports.Card=M;exports.CardContent=O;exports.CardFooter=le;exports.CardHeader=se;exports.CreateApplicantForm=Tr;exports.CriteriaBuiltInType=at;exports.DEFAULT_VISIBLE_FIELDS=it;exports.DocumentReviewStatus=tt;exports.EndpointBuilder=ot;exports.ErrorHandler=Ce;exports.EventEmitter=Ct;exports.FIELD_METADATA=Te;exports.FileType=et;exports.FileUpload=Qt;exports.GenderType=Fe;exports.Header=Oe;exports.HttpClient=ct;exports.IdentityProviderManager=Ne;exports.IdentityService=xt;exports.IdentityVerificationProvider=ue;exports.IdentityVerificationStep=ir;exports.Input=ie;exports.InvestorCategorizationService=yt;exports.InvestorCategorizationStep=ar;exports.InvestorCategorizationType=ce;exports.InvestorCategoryType=nt;exports.KycProcessStatus=Je;exports.KycStatus=we;exports.KycStatusDisplay=Ue;exports.KycWorkflow=Mr;exports.Logo=lr;exports.MetaKYCContext=Ke;exports.MetaKYCError=xe;exports.MetaKYCProvider=hr;exports.MultiSelect=Yt;exports.OnfidoProvider=Dt;exports.OverviewService=ht;exports.OverviewStep=rr;exports.PhoneInput=Vt;exports.QuestionnaireService=ut;exports.QuestionnaireStep=er;exports.ReviewStatus=je;exports.RiskCriteriaType=st;exports.RiskLevel=Ge;exports.RiskScoringService=gt;exports.RiskScoringStep=sr;exports.SardinAIProvider=Ft;exports.Select=be;exports.Spinner=pe;exports.StepRouter=Et;exports.SumsubProvider=Rt;exports.ThemeManager=Pt;exports.ThemePreset=X;exports.ThemeService=St;exports.UploadDocumentService=mt;exports.UploadDocumentStep=tr;exports.UserType=Xe;exports.ValueDataType=ye;exports.WorkflowOrchestrator=It;exports.WorkflowResultType=De;exports.WorkflowState=At;exports.WorkflowStepAction=z;exports.appropriatenessTestSchema=Kr;exports.clearAllStorage=br;exports.clearApplicantId=Ot;exports.clearWorkflowState=Bt;exports.cn=ee;exports.corporateTheme=bt;exports.defaultConfig=lt;exports.defaultTheme=ne;exports.fileToBase64=Lt;exports.fintechTheme=vt;exports.formatFileSize=Me;exports.generateAppropriatenessSchema=_r;exports.generateQuestionnaireSchema=Or;exports.generateRiskScoringSchema=$r;exports.generateUploadDocumentSchema=Br;exports.getAcceptString=fr;exports.getApplicantId=Mt;exports.getThemePreset=Ae;exports.getWorkflowState=yr;exports.healthcareTheme=kt;exports.isScriptLoaded=mr;exports.loadScript=_e;exports.minimalTheme=jt;exports.modernTheme=wt;exports.removeScript=pr;exports.saveApplicantId=Tt;exports.saveWorkflowState=zt;exports.themePresets=Nt;exports.useApplicant=Wt;exports.useAppropriatenessTest=vr;exports.useIdentityVerification=qt;exports.useKycWorkflow=$t;exports.useMetaKYC=de;exports.useOverview=Kt;exports.useQuestionnaire=Ut;exports.useRiskScoring=Ht;exports.useUploadDocument=_t;exports.validateFileSize=gr;exports.validateFileType=xr;
|
|
69
69
|
//# sourceMappingURL=index.cjs.map
|