@vpdev2/metakyc-sdk 1.0.84 → 1.0.85
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/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/services/theme.service.d.ts.map +1 -1
- package/dist/types/theme.d.ts +7 -0
- package/dist/types/theme.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateApplicantForm.d.ts","sourceRoot":"","sources":["../../src/components/CreateApplicantForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAapE,MAAM,WAAW,wBAAwB;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAsJD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,
|
|
1
|
+
{"version":3,"file":"CreateApplicantForm.d.ts","sourceRoot":"","sources":["../../src/components/CreateApplicantForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAapE,MAAM,WAAW,wBAAwB;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAsJD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAsiClE,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ar=Object.defineProperty;var Ir=(t,r,s)=>r in t?Ar(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s;var oe=(t,r,s)=>Ir(t,typeof r!="symbol"?r+"":r,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Pr=require("axios"),o=require("react"),e=require("react/jsx-runtime"),rt=require("react-dom"),Fe=require("react-hook-form"),Te=require("zod");function Tr(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 dt=Tr(o);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||{}),qe=(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))(qe||{}),Se=(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))(Se||{}),yt=(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))(yt||{}),xt=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(xt||{}),Le=(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))(Le||{}),De=(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))(De||{}),gt=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(gt||{}),ft=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(ft||{}),je=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(je||{}),bt=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(bt||{}),Qe=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(Qe||{}),vt=(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))(vt||{}),kt=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(kt||{}),wt=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))(wt||{}),Ae=(t=>(t[t.String=0]="String",t[t.Integer=1]="Integer",t[t.Money=2]="Money",t[t.Boolean=3]="Boolean",t[t.Date=4]="Date",t[t.Country=5]="Country",t[t.DigitOnly=6]="DigitOnly",t))(Ae||{}),jt=(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))(jt||{}),St=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))(St||{}),ve=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(ve||{}),Nt=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(Nt||{});const $e={Nationality:10,Address:20,CountryOfBirth:30,PhoneNumber:40,UboAddress:50},Me={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:"select",countriesType:$e.PhoneNumber},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",countriesType:$e.Address},nationality:{label:"Nationality",type:"select",countriesType:$e.Nationality},otherNationality:{label:"Other Nationalities",type:"multiselect",countriesType:$e.Nationality},countryOfBirth:{label:"Country of Birth",type:"select",countriesType:$e.CountryOfBirth},placeOfBirth:{label:"Place of Birth",type:"text"},taxCountry:{label:"Tax Country",type:"select",countriesType:$e.Address},taxNumber:{label:"Tax Number",type:"text"},defaultLanguage:{label:"Default Language",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"}},Ct=["firstName","lastName","email","phonenumber","dateOfBirth"],nt=[{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 pe=(t=>(t.Default="default",t.Corporate="corporate",t.Fintech="fintech",t.Healthcare="healthcare",t.Modern="modern",t.Minimal="minimal",t))(pe||{});const Et={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class Rt{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 Re extends Error{constructor(s,a,n,i,d){super(s);oe(this,"response");this.code=a,this.details=n,this.validationErrors=i,this.name="MetaKYCError",this.response=d,Object.setPrototypeOf(this,Re.prototype)}}class Ue{static handleApiError(r){return new Re(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 Re(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 Re(s.result.message,r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response):new Re((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 Re("No response from server",0,"The request was made but no response was received. Please check your network connection."):new Re(r.message||"An unexpected error occurred",0,r.toString())}static isMetaKYCError(r){return r instanceof Re}}class At{constructor(r){oe(this,"axiosInstance");oe(this,"endpointBuilder");oe(this,"config");this.config={...Et,...r},this.endpointBuilder=new Rt(this.config.endpoints),this.axiosInstance=Pr.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 Ue.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 Ue.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 Ue.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 Ue.handleAxiosError(n)}}handleResponse(r){const s=r.data;if(!s.success&&s.error)throw Ue.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 Pt{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 Tt{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 Ft{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 Lt{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 Dt{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 Ot{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 Bt{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 fe={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"}}},zt={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"}},$t={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"}},_t={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"}}},Ht={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"}},Ut={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"}},Kt={[pe.Default]:fe,[pe.Corporate]:zt,[pe.Fintech]:$t,[pe.Healthcare]:_t,[pe.Modern]:Ht,[pe.Minimal]:Ut};function Ke(t){return Kt[t]||fe}class Wt{constructor(r){this.httpClient=r}async getThemeConfiguration(){var r;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return Ke(pe.Default);let a=s.result.preset?Ke(s.result.preset):Ke(pe.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.map(i=>{const d=!i._v||i._v<4;return{...i,fields:(i.fields||[]).map(u=>({...u,colSpan:d?u.colSpan===1?2:4:Math.min(4,Math.max(1,u.colSpan??4))}))}}))}catch{}if(s.result.reviewPageFields)try{const n=typeof s.result.reviewPageFields=="string"?JSON.parse(s.result.reviewPageFields):s.result.reviewPageFields;Array.isArray(n)&&n.length>0&&(a.reviewPageFields=n)}catch{}return s.result.reviewPageDisabled&&(a.reviewPageDisabled=!0),a}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),Ke(pe.Default)}}async saveThemeConfiguration(r){await this.httpClient.post("Tenant","SaveThemeConfiguration",r)}getAvailablePresets(){return[{id:pe.Default,name:"Default"},{id:pe.Corporate,name:"Corporate"},{id:pe.Fintech,name:"Fintech"},{id:pe.Healthcare,name:"Healthcare"},{id:pe.Modern,name:"Modern"},{id:pe.Minimal,name:"Minimal"}]}getPreviewTheme(r,s){const a=Ke(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 Yt{constructor(){oe(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 Vt{constructor(){oe(this,"events",new Yt);oe(this,"_applicantId",null);oe(this,"_progress",null);oe(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)||Se.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===Se.Finished}get isOnHold(){return this.status===Se.OnHold}get isInProgress(){return this.status===Se.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===Se.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 qt{constructor(){oe(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 Qt{constructor(r,s,a,n,i,d,u,h){oe(this,"state");oe(this,"stepRouter");this.applicantService=r,this.questionnaireService=s,this.uploadDocumentService=a,this.appropriatenessTestService=n,this.overviewService=i,this.riskScoringService=d,this.investorCategorizationService=h,this.state=new Vt,this.stepRouter=new qt,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 ot(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 Fr(t){return!!document.getElementById(t)}function Lr(t){const r=document.getElementById(t);r&&r.remove()}class Gt{constructor(r){oe(this,"sdk",null);oe(this,"config");this.config=r}async loadSDK(){await ot("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 Jt{constructor(r){oe(this,"sdk",null);oe(this,"config");this.config=r}async loadSDK(){await ot("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 Zt{constructor(r){oe(this,"sardineContext",null);oe(this,"config");oe(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:d}=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:d===!0,region:this.config.region,onDeviceResponse:u=>{console.log(`[SardinAI] Device ID: ${u.deviceId}`)},onConfigUpdate:(u,h,m)=>{switch(u){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",m);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",h);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",u)}}}),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 _e{static createProvider(r,s){switch(r){case je.Sumsub:return new Gt(s);case je.Onfido:return new Jt(s);case je.SardinAI:return new Zt(s);default:throw new Error(`Unsupported identity provider: ${r}`)}}static parseProviderConfig(r,s,a){var n;switch(r){case je.Sumsub:return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:s.lang||"en"};case je.Onfido:return{token:s.token||s.sdkToken};case je.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}`)}}}function Dr(){return`
|
|
1
|
+
"use strict";var Ar=Object.defineProperty;var Ir=(t,r,s)=>r in t?Ar(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s;var oe=(t,r,s)=>Ir(t,typeof r!="symbol"?r+"":r,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Pr=require("axios"),o=require("react"),e=require("react/jsx-runtime"),rt=require("react-dom"),Fe=require("react-hook-form"),Te=require("zod");function Tr(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 dt=Tr(o);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||{}),qe=(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))(qe||{}),Se=(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))(Se||{}),yt=(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))(yt||{}),xt=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(xt||{}),Le=(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))(Le||{}),De=(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))(De||{}),gt=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(gt||{}),ft=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(ft||{}),je=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(je||{}),bt=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(bt||{}),Qe=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(Qe||{}),vt=(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))(vt||{}),kt=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(kt||{}),wt=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))(wt||{}),Ae=(t=>(t[t.String=0]="String",t[t.Integer=1]="Integer",t[t.Money=2]="Money",t[t.Boolean=3]="Boolean",t[t.Date=4]="Date",t[t.Country=5]="Country",t[t.DigitOnly=6]="DigitOnly",t))(Ae||{}),jt=(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))(jt||{}),St=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))(St||{}),ve=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(ve||{}),Nt=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(Nt||{});const $e={Nationality:10,Address:20,CountryOfBirth:30,PhoneNumber:40,UboAddress:50},Me={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:"select",countriesType:$e.PhoneNumber},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",countriesType:$e.Address},nationality:{label:"Nationality",type:"select",countriesType:$e.Nationality},otherNationality:{label:"Other Nationalities",type:"multiselect",countriesType:$e.Nationality},countryOfBirth:{label:"Country of Birth",type:"select",countriesType:$e.CountryOfBirth},placeOfBirth:{label:"Place of Birth",type:"text"},taxCountry:{label:"Tax Country",type:"select",countriesType:$e.Address},taxNumber:{label:"Tax Number",type:"text"},defaultLanguage:{label:"Default Language",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"}},Ct=["firstName","lastName","email","phonenumber","dateOfBirth"],nt=[{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 pe=(t=>(t.Default="default",t.Corporate="corporate",t.Fintech="fintech",t.Healthcare="healthcare",t.Modern="modern",t.Minimal="minimal",t))(pe||{});const Et={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class Rt{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 Re extends Error{constructor(s,a,n,i,d){super(s);oe(this,"response");this.code=a,this.details=n,this.validationErrors=i,this.name="MetaKYCError",this.response=d,Object.setPrototypeOf(this,Re.prototype)}}class Ue{static handleApiError(r){return new Re(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 Re(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 Re(s.result.message,r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response):new Re((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 Re("No response from server",0,"The request was made but no response was received. Please check your network connection."):new Re(r.message||"An unexpected error occurred",0,r.toString())}static isMetaKYCError(r){return r instanceof Re}}class At{constructor(r){oe(this,"axiosInstance");oe(this,"endpointBuilder");oe(this,"config");this.config={...Et,...r},this.endpointBuilder=new Rt(this.config.endpoints),this.axiosInstance=Pr.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 Ue.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 Ue.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 Ue.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 Ue.handleAxiosError(n)}}handleResponse(r){const s=r.data;if(!s.success&&s.error)throw Ue.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 Pt{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 Tt{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 Ft{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 Lt{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 Dt{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 Ot{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 Bt{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 fe={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"}}},zt={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"}},$t={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"}},_t={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"}}},Ht={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"}},Ut={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"}},Kt={[pe.Default]:fe,[pe.Corporate]:zt,[pe.Fintech]:$t,[pe.Healthcare]:_t,[pe.Modern]:Ht,[pe.Minimal]:Ut};function Ke(t){return Kt[t]||fe}class Wt{constructor(r){this.httpClient=r}async getThemeConfiguration(){var r;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return Ke(pe.Default);let a=s.result.preset?Ke(s.result.preset):Ke(pe.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.map(i=>{const d=!i._v||i._v<4;return{...i,fields:(i.fields||[]).map(u=>({...u,colSpan:d?u.colSpan===1?2:4:Math.min(4,Math.max(1,u.colSpan??4))}))}}))}catch{}if(s.result.reviewPageFields)try{const n=typeof s.result.reviewPageFields=="string"?JSON.parse(s.result.reviewPageFields):s.result.reviewPageFields;Array.isArray(n)&&n.length>0&&(a.reviewPageFields=n)}catch{}return s.result.reviewPageDisabled&&(a.reviewPageDisabled=!0),s.result.fieldLabelMode==="placeholder"&&(a.fieldLabelMode="placeholder"),a}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),Ke(pe.Default)}}async saveThemeConfiguration(r){await this.httpClient.post("Tenant","SaveThemeConfiguration",r)}getAvailablePresets(){return[{id:pe.Default,name:"Default"},{id:pe.Corporate,name:"Corporate"},{id:pe.Fintech,name:"Fintech"},{id:pe.Healthcare,name:"Healthcare"},{id:pe.Modern,name:"Modern"},{id:pe.Minimal,name:"Minimal"}]}getPreviewTheme(r,s){const a=Ke(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 Yt{constructor(){oe(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 Vt{constructor(){oe(this,"events",new Yt);oe(this,"_applicantId",null);oe(this,"_progress",null);oe(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)||Se.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===Se.Finished}get isOnHold(){return this.status===Se.OnHold}get isInProgress(){return this.status===Se.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===Se.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 qt{constructor(){oe(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 Qt{constructor(r,s,a,n,i,d,u,h){oe(this,"state");oe(this,"stepRouter");this.applicantService=r,this.questionnaireService=s,this.uploadDocumentService=a,this.appropriatenessTestService=n,this.overviewService=i,this.riskScoringService=d,this.investorCategorizationService=h,this.state=new Vt,this.stepRouter=new qt,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 ot(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 Fr(t){return!!document.getElementById(t)}function Lr(t){const r=document.getElementById(t);r&&r.remove()}class Gt{constructor(r){oe(this,"sdk",null);oe(this,"config");this.config=r}async loadSDK(){await ot("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 Jt{constructor(r){oe(this,"sdk",null);oe(this,"config");this.config=r}async loadSDK(){await ot("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 Zt{constructor(r){oe(this,"sardineContext",null);oe(this,"config");oe(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:d}=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:d===!0,region:this.config.region,onDeviceResponse:u=>{console.log(`[SardinAI] Device ID: ${u.deviceId}`)},onConfigUpdate:(u,h,m)=>{switch(u){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",m);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",h);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",u)}}}),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 _e{static createProvider(r,s){switch(r){case je.Sumsub:return new Gt(s);case je.Onfido:return new Jt(s);case je.SardinAI:return new Zt(s);default:throw new Error(`Unsupported identity provider: ${r}`)}}static parseProviderConfig(r,s,a){var n;switch(r){case je.Sumsub:return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:s.lang||"en"};case je.Onfido:return{token:s.token||s.sdkToken};case je.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}`)}}}function Dr(){return`
|
|
2
2
|
/* ── metakyc-input-colors (ThemeManager failsafe — same rules as globals.css) ── */
|
|
3
3
|
.metakyc-sdk input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]),
|
|
4
4
|
.metakyc-sdk select,
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
Failed to reload test data. Please refresh the page.`)}};if(d)return e.jsx(K,{children:e.jsxs(W,{children:[e.jsx(Ne,{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(K,{children:e.jsxs(W,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-danger-500 text-lg mb-4",children:"No test data available"}),f&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:f})]})});if(A>0)return e.jsxs(K,{children:[e.jsxs(ye,{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(W,{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:z(A)}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please wait before attempting the test again"})]}),f&&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:f})})]})]});const D=n.testAllowedMaxTry-n.totalFailedTries;return R?e.jsx("form",{onSubmit:X,children:e.jsxs(K,{children:[e.jsx(ye,{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 ${x<=60?"text-danger-500":"text-primary-500"}`,children:z(x)}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Time Remaining"})]})]})}),e.jsxs(W,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs(Ie,{variant:"info",children:["Question ",Object.keys(v).length," of ",n.totalQuestionCount]}),e.jsxs(Ie,{variant:D>1?"success":"warning",children:[D," attempt",D!==1?"s":""," remaining"]})]}),n.appropriatenessQuestions.map((P,L)=>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 ",L+1]}),P.groupName&&e.jsx("span",{className:"ml-2 text-xs text-gray-500 dark:text-gray-400",children:P.groupName}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mt-2",children:P.question})]}),e.jsx("div",{className:"space-y-2",children:P.answers.map((U,G)=>e.jsxs("label",{className:`
|
|
94
94
|
flex items-center p-3 border-2 rounded-lg cursor-pointer transition-all
|
|
95
95
|
${v[P.id]===U?"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"}
|
|
96
|
-
`,children:[e.jsx("input",{type:"radio",name:`question-${P.id}`,value:U,checked:v[P.id]===U,onChange:ne=>H(P.id,ne.target.value),className:"h-4 w-4 text-primary-500 border-gray-300 focus:ring-primary-500",disabled:h}),e.jsx("span",{className:"ml-3 text-gray-700 dark:text-gray-300",children:U})]},G))})]},P.id)),f&&!O&&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:"})," ",f]})}),O&&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(ge,{className:"flex justify-between",children:[e.jsx(V,{type:"button",variant:"outline",onClick:s,disabled:h,children:"Cancel"}),e.jsx(V,{type:"submit",isLoading:h,disabled:Object.keys(v).length<n.totalQuestionCount,children:O?"Submitting...":"Submit Test"})]})]})}):e.jsxs(K,{children:[e.jsxs(ye,{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(W,{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(Ie,{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(Ie,{variant:"info",children:z(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(Ie,{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(Ie,{variant:D>1?"success":"warning",children:D})]})]}),f&&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:"})," ",f]})}),D<=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(ge,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"button",onClick:I,disabled:D<=0,children:"Start Test"})]})]})},Cr=({applicantId:t,onComplete:r,onBack:s})=>{var Be,Je,Ye,Ze;const{applicantService:a,baseInformationService:n,config:i,currentTheme:d}=be(),{identityData:u,provider:h,token:m,isLoading:f,error:k,requestIdentity:v,restartIdentity:w}=dr(t),[x,b]=o.useState(null),[R,N]=o.useState(null),[O,j]=o.useState([]),[A,q]=o.useState([]),[re,z]=o.useState(!0),[I,H]=o.useState(!1),[X,F]=o.useState(null),[D,P]=o.useState(!1),L=o.useRef(!1),[U,G]=o.useState({}),[ne,C]=o.useState({}),_=d!=null&&d.reviewPageFields&&d.reviewPageFields.length>0?d.reviewPageFields[0]:null,ee=!!(d!=null&&d.reviewPageDisabled),me=o.useRef(!1);me.current=ee;const ce=Fe.useForm({defaultValues:{street:"",streetNumber:"",city:"",zip:"",country:"",nationality:"",phonenumber:""}});o.useEffect(()=>{if(ee){L.current||(L.current=!0,v().then(()=>H(!0)).catch(T=>console.error("[Identity] Auto-request failed:",T)).finally(()=>z(!1)));return}(async()=>{try{const[T,$,B]=await Promise.all([a.getApplicantData(t),n.getCountries("","en"),n.getCountries("","en",40)]);N(T);const Q=new Set,Y=$.map(y=>({value:y.abbreviation3||y.abbreviation,label:y.name})).filter(y=>!y.value||Q.has(y.value)?!1:(Q.add(y.value),!0));j(Y);const ie=new Set,l=B.filter(y=>y.countryCode).map(y=>({value:y.countryCode,label:`${y.countryCode} – ${y.name}`})).filter(y=>ie.has(y.value)?!1:(ie.add(y.value),!0));q(l);const c=T.applicantRequestData;if(G({firstName:(c==null?void 0:c.firstName)||"",lastName:(c==null?void 0:c.lastName)||"",email:(c==null?void 0:c.email)||"",dateOfBirth:(c==null?void 0:c.dateOfBirth)||"",title:(c==null?void 0:c.title)||"",salutation:(c==null?void 0:c.salutation)||"",phonenumber:(c==null?void 0:c.phonenumber)||"",mobileCountryCode:(c==null?void 0:c.mobileCountryCode)||"",street:(c==null?void 0:c.street)||"",streetNumber:(c==null?void 0:c.streetNumber)||"",city:(c==null?void 0:c.city)||"",zip:(c==null?void 0:c.zip)||"",country:(c==null?void 0:c.country)||"",nationality:(c==null?void 0:c.nationality)||"",taxCountry:(c==null?void 0:c.taxCountry)||"",countryOfBirth:(c==null?void 0:c.countryOfBirth)||"",placeOfBirth:(c==null?void 0:c.placeOfBirth)||"",educationLevel:(c==null?void 0:c.educationLevel)||"",occupation:(c==null?void 0:c.occupation)||"",taxNumber:(c==null?void 0:c.taxNumber)||"",defaultLanguage:(c==null?void 0:c.defaultLanguage)||""}),ce.reset({street:(c==null?void 0:c.street)||"",streetNumber:(c==null?void 0:c.streetNumber)||"",city:(c==null?void 0:c.city)||"",zip:(c==null?void 0:c.zip)||"",country:(c==null?void 0:c.country)||"",nationality:(c==null?void 0:c.nationality)||"",phonenumber:(c==null?void 0:c.phonenumber)||""}),T.kycRecords&&T.kycRecords.length>0&&T.kycRecords[0].providerTokenObject!==null&&!L.current&&me.current){console.log("[Identity] Review page disabled + existing identity — auto-requesting..."),L.current=!0;try{await v(),H(!0)}catch(y){console.error("[Identity] Auto-request failed:",y)}}}catch(T){console.error("Error loading applicant data:",T)}finally{z(!1)}})()},[t]),o.useEffect(()=>{u&&!I&&me.current&&(console.log("[Identity] Review page disabled — showing cached provider"),H(!0))},[u,I]),o.useEffect(()=>{if(m){if(m.expiresAt){const p=new Date(m.expiresAt).getTime();if(Date.now()>=p){console.warn("[Identity] Token has expired (expiresAt)"),P(!0),F("Your verification session has expired. Please restart.");return}}if(m.url)try{const T=new URL(m.url).toString().toLowerCase();if(T.includes("expired")||T.includes("invalid")||T.includes("error")){console.warn("[Identity] Token URL indicates expiration"),P(!0),F("Your verification link has expired. Please restart.");return}}catch{console.error("[Identity] Invalid token URL")}if(m.status==="expired"||m.error==="expired"||m.expired===!0){console.warn("[Identity] Token object indicates expiration"),P(!0),F("Your verification session has expired. Please restart.");return}}},[m]),o.useEffect(()=>{if(h!==null&&m&&!x&&I&&!D){const p=h;if(m.url){console.log("[Identity] Loading provider URL for user verification:",m.url),F(null);try{if(new URL(m.url),p===je.SardinAI){console.log("[SardinAI] Initializing Risk SDK in background...");try{const T=_e.parseProviderConfig(h,m,i);_e.createProvider(h,T).initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully in background")}).catch(B=>{console.warn("[SardinAI] Risk SDK initialization failed (non-blocking):",B)})}catch(T){console.warn("[SardinAI] Risk SDK setup failed (non-blocking):",T)}}b({type:"url",url:m.url})}catch(T){console.error("[Identity] Invalid URL:",T),F("Invalid verification URL. Please restart."),P(!0)}return}if(p===je.SardinAI){console.log("[SardinAI] No URL provided - initializing Risk SDK only..."),F(null);try{const T=_e.parseProviderConfig(h,m,i),$=_e.createProvider(h,T);$.initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully"),b($),setTimeout(()=>{r==null||r()},2e3)}).catch(B=>{var Y;console.error("[SardinAI] Failed to initialize:",B);const Q=((Y=B.message)==null?void 0:Y.toLowerCase())||"";Q.includes("expired")||Q.includes("invalid")||Q.includes("401")||Q.includes("400")?(P(!0),F("Session expired or invalid. Please restart verification.")):F(`Failed to initialize: ${B.message}`)})}catch(T){console.error("[SardinAI] Error creating provider:",T),F(`Configuration error: ${T.message}`)}return}try{F(null);const T=_e.parseProviderConfig(h,m,i),$=_e.createProvider(h,T);p===je.Sumsub?($.initialize("identity-container").catch(B=>{var Q;console.error("[Sumsub] Initialization error:",B),F(`Failed to initialize: ${B.message}`),(Q=B.message)!=null&&Q.toLowerCase().includes("expired")&&P(!0)}),$.onComplete&&$.onComplete(()=>{r==null||r()})):p===je.Onfido&&$.initialize("identity-container").catch(B=>{console.error("[Onfido] Initialization error:",B),F(`Failed to initialize: ${B.message}`)}),b($)}catch(T){console.error("[Identity] Provider setup error:",T),F(`Setup error: ${T.message}`)}}return()=>{if(x&&x.destroy)try{x.destroy()}catch(p){console.error("[Identity] Error destroying provider:",p)}}},[h,m,x,I,r,D]);const S=async()=>{try{F(null),P(!1),await v(),H(!0)}catch(p){console.error("Error starting identity verification:",p)}},J=async()=>{try{F(null),P(!1),b(null),console.log("[Identity] Restarting verification..."),await w(),H(!0)}catch(p){console.error("Error restarting identity verification:",p),F(p.message||"Failed to restart verification")}};if(re||f)return e.jsx(K,{children:e.jsxs(W,{children:[e.jsx(Ne,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading identity verification..."})]})});if(k)return e.jsx(K,{children:e.jsx(W,{children:e.jsxs("p",{className:"text-danger-500",children:["Error: ",k.message]})})});if(I&&(X||D))return e.jsxs(K,{children:[e.jsx(ye,{children:e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Verification Session Issue"})}),e.jsxs(W,{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:D?"Session Expired":"Verification Error"}),e.jsx("p",{className:"text-red-800 dark:text-red-200 text-sm",children:X||"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(ge,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"button",onClick:J,disabled:f,children:f?"Restarting...":"Restart Verification"})]})]});if(I&&u){const p=h;return m!=null&&m.url?e.jsxs(K,{children:[e.jsx(ye,{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(V,{type:"button",variant:"outline",size:"sm",onClick:J,disabled:f,children:"Restart"})]})}),e.jsxs(W,{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:m.url,className:"w-full h-full border-0 rounded-lg",allow:"camera; microphone; geolocation",title:"Identity Verification",onLoad:T=>{var $,B,Q;console.log("[Identity] Iframe loaded");try{const Y=T.target,ie=Y.contentDocument||(($=Y.contentWindow)==null?void 0:$.document);if(ie){const l=((Q=(B=ie.body)==null?void 0:B.textContent)==null?void 0:Q.toLowerCase())||"";(l.includes("expired")||l.includes("invalid")||l.includes("error"))&&(console.warn("[Identity] Iframe shows expiration message"),P(!0),F("Your verification link has expired."))}}catch{console.log("[Identity] Cannot check iframe content (CORS)")}}})})]}),s&&e.jsx(ge,{children:e.jsx(V,{variant:"outline",onClick:s,children:"Back"})})]}):p===je.SardinAI?e.jsxs(K,{children:[e.jsxs(ye,{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(W,{children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ne,{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(K,{children:[e.jsxs(ye,{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(W,{children:e.jsx("div",{id:"identity-container",className:"min-h-[400px]"})}),s&&e.jsx(ge,{children:e.jsx(V,{variant:"outline",onClick:s,children:"Back"})})]})}const se=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),ae=(p=4)=>({1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4"})[p]||"col-span-4",ke=(p,T)=>{if(!T&&T!==0)return"—";if(se.has(p)&&p!=="mobileCountryCode"){const $=O.find(B=>B.value===T);return $?$.label:String(T)}return String(T)},Oe=({helpText:p})=>{const[T,$]=o.useState(!1),B=o.useRef(null),[,Q]=o.useState({top:0,left:0}),Y=()=>{if(B.current){const ie=B.current.getBoundingClientRect();Q({top:ie.bottom+window.scrollY+6,left:ie.left+window.scrollX})}$(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"metakyc-help-btn",ref:B,onClick:Y,style:{width:18,height:18,borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:11,fontWeight:700,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:1,position:"relative",zIndex:2},children:"?"}),T&&rt.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>$(!1),children:e.jsxs("div",{onClick:ie=>ie.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 8px)",padding:"20px 24px",maxWidth:400,width:"90%",boxShadow:"0 24px 64px rgba(0,0,0,0.4)"},children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:p},style:{fontSize:13,color:"var(--metakyc-text-primary, #111827)",lineHeight:1.6}}),e.jsx("button",{type:"button",onClick:()=>$(!1),style:{marginTop:12,padding:"4px 12px",fontSize:12,border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 6px)",background:"transparent",cursor:"pointer",color:"var(--metakyc-text-secondary, #6b7280)"},children:"Close"})]})}),document.body)]})},Ce=(p,T)=>T?e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:5,flexWrap:"nowrap"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:p}),e.jsx("div",{style:{paddingTop:24},children:e.jsx(Oe,{helpText:T})})]}):p,Ge=(p,T)=>{const $=`cf-${T}`,B=p.paramName??"",Q=ne[B];if(p.customType==="br")return e.jsx("div",{className:ae(p.colSpan),style:{minHeight:"0.5rem"}},$);if(p.customType==="paragraph")return e.jsx("div",{className:ae(p.colSpan),children:e.jsx("div",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:p.label||""}})},$);if(p.customType==="html")return e.jsx("div",{className:ae(p.colSpan),dangerouslySetInnerHTML:{__html:p.label||""}},$);if(p.customType==="link")return e.jsx("div",{className:ae(p.colSpan),children:Ce(e.jsx("a",{href:p.linkUrl??"#",target:"_blank",rel:"noopener noreferrer",className:"text-sm underline",style:{color:"var(--metakyc-primary, #6366f1)"},children:p.displayText||p.label||p.linkText||p.linkUrl}),p.helpText)},$);if(p.customType==="checkbox"||p.customType==="link_checkbox"){const Y=Q==="true"||Q===!0;return e.jsx("div",{className:ae(p.colSpan),children:Ce(e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!Y,onChange:ie=>C(l=>({...l,[B]:String(ie.target.checked)})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:p.customType==="link_checkbox"&&p.linkUrl?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:p.linkUrl,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #6366f1)",textDecoration:"underline"},children:p.linkText||p.label}),p.label&&p.linkText?` ${p.label}`:""]}):p.displayText||p.label})]}),p.helpText)},$)}if(p.customType==="group_checkbox"){const Y=Array.isArray(Q)?Q:Q?[Q]:[],ie=l=>{p.singleSelect?C(c=>({...c,[B]:Y[0]===l?[]:[l]})):C(c=>({...c,[B]:Y.includes(l)?Y.filter(M=>M!==l):[...Y,l]}))};return e.jsx("div",{className:ae(p.colSpan),children:Ce(e.jsxs("div",{className:"space-y-1.5",children:[p.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:p.displayText||p.label}),(p.options||[]).map(l=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:Y.includes(l.value),onChange:()=>ie(l.value),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:l.label})]},l.value))]}),p.helpText)},$)}return p.customType==="radio_group"?e.jsx("div",{className:ae(p.colSpan),children:Ce(e.jsxs("div",{className:"space-y-1.5",children:[p.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:p.displayText||p.label}),(p.options||[]).map(Y=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"radio",name:`rg-${B}`,value:Y.value,checked:Q===Y.value,onChange:()=>C(ie=>({...ie,[B]:Y.value})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:Y.label})]},Y.value))]}),p.helpText)},$):e.jsx("div",{className:ae(p.colSpan),children:Ce(e.jsx(he,{label:p.displayText||p.label||B,value:String(Q??""),onChange:Y=>C(ie=>({...ie,[B]:Y.target.value}))}),p.helpText)},$)},at=(p,T)=>{if(p.isCustom)return Ge(p,T);const $=p.name??"",B=Me[$],Q=p.displayText||(B==null?void 0:B.label)||$,Y=U[$]??"",ie=$==="mobileCountryCode",l=!!(B!=null&&B.countriesType)&&!ie;return p.editable?ie?e.jsx("div",{className:ae(p.colSpan??2),children:Ce(e.jsx(Pe,{label:Q,value:String(Y),onChange:c=>G(M=>({...M,[$]:c})),options:[{value:"",label:"Select country code…"},...A]}),p.helpText)},`epc-${T}`):l?e.jsx("div",{className:ae(p.colSpan??2),children:Ce(e.jsx(Pe,{label:Q,value:String(Y),onChange:c=>G(M=>({...M,[$]:c})),options:[{value:"",label:`Select ${Q.toLowerCase()}…`},...O]}),p.helpText)},`ec-${T}`):e.jsx("div",{className:ae(p.colSpan??2),children:Ce(e.jsx(he,{label:Q,type:(B==null?void 0:B.type)==="date"?"date":(B==null?void 0:B.type)==="email"?"email":"text",value:String(Y),onChange:c=>G(M=>({...M,[$]:c.target.value}))}),p.helpText)},`ei-${T}`):e.jsx("div",{className:ae(p.colSpan??2),children:Ce(e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"block text-sm font-medium mb-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:Q}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)",minHeight:"1.5rem"},children:ke($,Y)})]}),p.helpText)},`ro-${T}`)};if(_){const p=_.title||"Review Your Information",T=_.subtitle||"Please review and confirm your information before starting identity verification";return e.jsx("form",{onSubmit:$=>{$.preventDefault(),S()},children:e.jsxs(K,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:p}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:T})]}),e.jsx(W,{children:e.jsx("div",{className:"grid grid-cols-4 gap-4",children:_.fields.map(($,B)=>at($,B))})}),e.jsxs(ge,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"submit",isLoading:f,children:"Confirm and Start Verification"})]})]})})}return e.jsx("form",{onSubmit:ce.handleSubmit(S),children:e.jsxs(K,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Review Your Information"}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please review and confirm your information before starting identity verification"})]}),e.jsxs(W,{className:"space-y-6",children:[e.jsx("div",{className:"space-y-4 pb-4",style:{borderBottom:"1px solid var(--metakyc-border, #e5e7eb)"},children:[{label:"Name",value:`${((Be=R==null?void 0:R.applicantRequestData)==null?void 0:Be.firstName)||""} ${((Je=R==null?void 0:R.applicantRequestData)==null?void 0:Je.lastName)||""}`.trim()},{label:"Email",value:(Ye=R==null?void 0:R.applicantRequestData)==null?void 0:Ye.email},{label:"Date of Birth",value:((Ze=R==null?void 0:R.applicantRequestData)==null?void 0:Ze.dateOfBirth)||"Not provided"}].map(({label:p,value:T})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:p}),e.jsx("p",{className:"mt-1 text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:T})]},p))}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Address Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Fe.Controller,{control:ce.control,name:"country",render:({field:p})=>e.jsx(Pe,{label:"Country",value:p.value,onChange:p.onChange,options:[{value:"",label:"Select country…"},...O]})}),e.jsx(Fe.Controller,{control:ce.control,name:"nationality",render:({field:p})=>e.jsx(Pe,{label:"Nationality",value:p.value,onChange:p.onChange,options:[{value:"",label:"Select nationality…"},...O]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Fe.Controller,{control:ce.control,name:"street",render:({field:p})=>e.jsx(he,{...p,label:"Street"})}),e.jsx(Fe.Controller,{control:ce.control,name:"streetNumber",render:({field:p})=>e.jsx(he,{...p,label:"Street Number"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Fe.Controller,{control:ce.control,name:"city",render:({field:p})=>e.jsx(he,{...p,label:"City"})}),e.jsx(Fe.Controller,{control:ce.control,name:"zip",render:({field:p})=>e.jsx(he,{...p,label:"ZIP / Postal Code"})})]}),e.jsx(Fe.Controller,{control:ce.control,name:"phonenumber",render:({field:p})=>e.jsx(he,{...p,label:"Phone Number",type:"tel"})})]})]}),e.jsxs(ge,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"submit",isLoading:f,children:"Confirm and Start Verification"})]})]})})},it=({kycStatus:t,reviewStatus:r,workflowResult:s,customMessage:a,onContinue:n,onContactSupport:i})=>{const u=t===Le.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===Le.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===Le.Pending||t===Le.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===De.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===De.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===De.UnderReview||r===De.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===qe.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===qe.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===qe.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(K,{children:[e.jsxs(W,{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 ${u.iconBg}`,children:e.jsx("span",{className:`text-5xl ${u.iconColor}`,children:u.icon})})}),e.jsx("h2",{className:"text-3xl font-bold text-center text-gray-900 dark:text-white mb-4",children:u.title}),e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx(Ie,{variant:u.type==="success"?"success":u.type==="error"?"danger":u.type==="pending"?"warning":"info",children:t!=null?Le[t]:De[r]})}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mb-6 max-w-md mx-auto",children:a||u.message}),u.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"})]})]}),u.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"})]})]}),u.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?Le[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:De[r]})]})]})})]}),e.jsxs(ge,{className:"flex justify-center gap-4",children:[u.type==="success"&&n&&e.jsx(V,{onClick:n,size:"lg",children:"Continue"}),u.type==="error"&&e.jsxs(e.Fragment,{children:[i&&e.jsx(V,{variant:"outline",onClick:i,children:"Contact Support"}),n&&e.jsx(V,{onClick:n,children:"Try Again"})]}),u.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"})})]})]})},Er=({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"}})}),tt=({title:t,subtitle:r,className:s=""})=>{const{currentTheme:a}=be(),n=t||(a==null?void 0:a.title)||"",i=!!(a!=null&&a.logo&&a.logo.visible&&a.logo.url),d=!!n;return!i&&!d?null:e.jsxs("div",{className:`metakyc-header ${s}`,children:[e.jsxs("div",{className:"metakyc-header-title flex items-center text-xl font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:[i&&e.jsx(Er,{config:a.logo}),i&&d&&e.jsx("span",{style:{fontSize:"1.5rem",fontWeight:300,color:"var(--metakyc-text-muted, #9ca3af)",margin:"0 12px"},children:"|"}),d&&e.jsx("span",{style:{color:"var(--metakyc-text-primary, #111827)"},children:n})]}),r&&e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:r})]})},Xe=["firstName","lastName","email","phonenumber","dateOfBirth"];function He(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const Ve={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"},ht=({helpText:t,children:r})=>{const[s,a]=o.useState(!1);if(!t)return e.jsx(e.Fragment,{children:r});const n=s?e.jsx("div",{role:"dialog","aria-modal":"true",onClick:()=>a(!1),style:{position:"fixed",inset:0,zIndex:999999,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"},children:e.jsxs("div",{onClick:i=>i.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"12px",padding:"28px 24px 24px",maxWidth:"480px",width:"100%",maxHeight:"80vh",overflowY:"auto",boxShadow:"0 24px 64px rgba(0,0,0,0.4)",position:"relative"},children:[e.jsx("button",{type:"button",onClick:()=>a(!1),"aria-label":"Close",style:{position:"absolute",top:"12px",right:"12px",width:"28px",height:"28px",borderRadius:"50%",border:"1px solid var(--metakyc-border, #e5e7eb)",background:"var(--metakyc-input-bg, #f3f4f6)",color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:"×"}),e.jsx("div",{style:{color:"var(--metakyc-text-primary, #111827)",fontSize:"14px",lineHeight:1.75},dangerouslySetInnerHTML:{__html:t}})]})}):null;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",flexWrap:"nowrap"},children:[r,e.jsx("button",{type:"button",className:"metakyc-help-btn",onClick:()=>a(!0),"aria-label":"Help",style:{flexShrink:0,marginTop:"2px",width:"18px",height:"18px",borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:"10px",fontWeight:"700",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0,position:"relative",zIndex:2,transition:"background 0.15s, color 0.15s"},onMouseEnter:i=>{i.currentTarget.style.background="var(--metakyc-primary, #2563eb)",i.currentTarget.style.color="#ffffff"},onMouseLeave:i=>{i.currentTarget.style.background="transparent",i.currentTarget.style.color="var(--metakyc-primary, #2563eb)"},children:"?"}),typeof document<"u"&&n?rt.createPortal(n,document.body):null]})},is=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:a})=>{var T,$,B,Q,Y,ie;const{config:n,baseInformationService:i,currentTheme:d}=be(),{createApplicant:u,isLoading:h}=mr(),m=t||((T=n.applicantForm)==null?void 0:T.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 f=r||(($=n.applicantForm)==null?void 0:$.externalRefId)||"",k=((B=n.applicantForm)==null?void 0:B.email)||"",v=((Q=n.applicantForm)==null?void 0:Q.hiddenValues)||{},x=(((Y=n.applicantForm)==null?void 0:Y.fieldLabelMode)||"label")!=="placeholder",b=o.useMemo(()=>d!=null&&d.applicantFormPages&&d.applicantFormPages.length>0?d.applicantFormPages:null,[d==null?void 0:d.applicantFormPages]),R=o.useMemo(()=>{const l=new Set(Xe),c=d==null?void 0:d.applicantFormRequiredFields;if(c)for(const M of c)l.add(M);if(b)for(const M of b)for(const y of M.fields)!y.isCustom&&y.name&&y.required&&l.add(y.name);return Array.from(l)},[d==null?void 0:d.applicantFormRequiredFields,b]),N=o.useMemo(()=>{var M;if(b){const y=b.flatMap(E=>E.fields).filter(E=>!E.isCustom&&E.name).map(E=>E.name),g=new Set(y);for(const E of Xe)g.add(E);return Array.from(g)}let l;(M=n.applicantForm)!=null&&M.visibleFields?l=n.applicantForm.visibleFields:d!=null&&d.applicantFormVisibleFields&&d.applicantFormVisibleFields.length>0?l=d.applicantFormVisibleFields:l=Ct;const c=new Set(l);for(const y of Xe)c.add(y);return Array.from(c)},[(ie=n.applicantForm)==null?void 0:ie.visibleFields,d==null?void 0:d.applicantFormVisibleFields,b]),O=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),j=o.useMemo(()=>{var c,M;const l=new Set;if(b)for(const y of b)for(const g of y.fields)!g.isCustom&&g.name&&O.has(g.name)&&l.add(g.countriesType??((c=Me[g.name])==null?void 0:c.countriesType));else for(const y of N)O.has(y)&&l.add((M=Me[y])==null?void 0:M.countriesType);return l.size===0&&l.add(void 0),Array.from(l)},[N,b]),[A,q]=o.useState({}),[re,z]=o.useState(!0),I=o.useRef(new Set),H=o.useRef(new Set);o.useEffect(()=>{if(!d)return;const l=j.filter(y=>{const g=y!=null?String(y):"all";return!H.current.has(g)&&!I.current.has(g)});if(l.length===0){j.every(g=>{const E=g!=null?String(g):"all";return H.current.has(E)})&&z(!1);return}z(!0);const c=l.map(y=>y!=null?String(y):"all");c.forEach(y=>I.current.add(y)),(async()=>{try{const y=await Promise.all(l.map(async g=>{const E=g!=null?String(g):"all",le=await i.getCountries("",n.locale||"en",g),te=g===40,we=new Set,Ee=le.map(de=>te&&de.countryCode?{value:de.countryCode,label:`${de.countryCode} – ${de.name}`}:{value:de.abbreviation3||de.abbreviation,label:de.name}).filter(de=>!de.value||we.has(de.value)?!1:(we.add(de.value),!0));return H.current.add(E),I.current.delete(E),[E,Ee]}));q(g=>({...g,...Object.fromEntries(y)}))}catch(y){c.forEach(g=>I.current.delete(g)),console.error("Failed to load countries:",y)}finally{j.every(g=>{const E=g!=null?String(g):"all";return H.current.has(E)})&&z(!1)}})()},[j,d]);const X=(l,c)=>{var g;const M=c??((g=Me[l])==null?void 0:g.countriesType),y=M!=null?String(M):"all";return A[y]||[]},F=Object.fromEntries(Object.entries(v).filter(([l])=>l in{firstName:1,lastName:1,title:1,email:1,dateOfBirth:1,phonenumber:1,mobileCountryCode:1,street:1,streetNumber:1,zip:1,city:1,country:1,nationality:1,otherNationality:1,defaultLanguage:1,taxCountry:1,placeOfBirth:1,countryOfBirth:1,salutation:1,educationLevel:1,occupation:1,taxNumber:1})),[D,P]=o.useState({workflowKey:m,firstName:"",lastName:"",title:"",email:k,dateOfBirth:"",phonenumber:"",externalRefId:f,mobileCountryCode:"",street:"",streetNumber:"",zip:"",city:"",country:"",nationality:"",otherNationality:[],defaultLanguage:"EN",taxCountry:"",placeOfBirth:"",countryOfBirth:"",salutation:null,educationLevel:"",occupation:"",taxNumber:"",...F}),L=Object.fromEntries(Object.entries(v).filter(([l])=>!(l in F)&&l!=="externalRefId"&&l!=="workflowKey")),[U,G]=o.useState({...L}),[ne,C]=o.useState(0),[_,ee]=o.useState({}),[me,ce]=o.useState(null),[S,J]=o.useState(!1),se=(l,c)=>P(M=>({...M,[l]:c})),ae=(l,c)=>G(M=>({...M,[l]:c})),ke=l=>!l.conditionalOn||U[l.conditionalOn]==="true",Oe=b&&ne<b.length-1?ne+1:-1,Ce=b&&ne>0?ne-1:-1,Ge=l=>{var M;const c={};for(const y of l.fields)if(y.isCustom){if(y.customType==="paragraph"||y.customType==="html"||y.customType==="br"||y.customType==="link")continue;if(y.required&&y.paramName){const g=U[y.paramName],E=y.displayText||y.label||y.paramName;y.customType==="checkbox"||y.customType==="link_checkbox"?g!=="true"&&(c[y.paramName]=`${E} is required.`):(!g||g.trim()==="")&&(c[y.paramName]=`${E} is required.`)}}else if(y.name){const g=y.name;if(R.includes(g)&&He(D[g])){const E=y.displayText||((M=Me[g])==null?void 0:M.label)||g;c[g]=`${E} is required.`}}return c},at=async()=>{if(!b)return;const l=b[ne];if(l.conditionalOn&&!ke(l)){ee({}),Oe>=0?C(Oe):await Be();return}const c=Ge(l);if(Object.keys(c).length>0){ee(c);return}ee({}),Oe>=0?C(Oe):await Be()},Be=async()=>{if(b){let l={};for(const c of b)ke(c)&&(l={...l,...Ge(c)});if(Object.keys(l).length>0){ee(l);return}}J(!0),ce(null);try{if(!D.externalRefId||D.externalRefId.trim()===""){ce("External Reference ID is required. Please pass it via config.applicantForm.externalRefId.");return}const l={workflowKey:D.workflowKey,externalRefId:D.externalRefId.trim()};if(b){for(const g of b)if(ke(g)){for(const E of g.fields)if(!E.isCustom&&E.name){const le=E.name,te=D[le];He(te)||(l[le]=te)}}for(const g of Xe)if(l[g]===void 0){const E=D[g];He(E)||(l[g]=E)}}else N.forEach(g=>{if(g==="externalRefId")return;const E=D[g];He(E)||(l[g]=E)});const c=[];if(b){for(const g of b)if(ke(g))for(const E of g.fields){if(!E.isCustom||!E.paramName||E.customType==="paragraph"||E.customType==="html"||E.customType==="br"||E.customType==="link")continue;const le=U[E.paramName]??"";let te;if(E.customType==="checkbox"||E.customType==="link_checkbox")te=le==="true"?"yes":"no";else if(te=le,!te&&!E.required)continue;c.push({paramName:E.paramName,value:te})}}for(const[g,E]of Object.entries(F))l[g]===void 0&&!He(E)&&(l[g]=E);const M=new Set(c.map(g=>g.paramName));for(const[g,E]of Object.entries(L))!M.has(g)&&E&&c.push({paramName:g,value:E});c.length>0&&(l.applicantAdditionalDatas=c);const y=await u(l);s(y.applicantId)}catch(l){console.error("Error creating applicant:",l),ce(l.message||"Failed to create applicant")}finally{J(!1)}},Je=async l=>{var c;l.preventDefault();for(const M of R)if(He(D[M])){const y=((c=Me[M])==null?void 0:c.label)||M;ce(`${y} is required.`);return}await Be()},Ye=(l,c,M,y)=>{var ct;const g=Me[l];if(!g)return null;const E=R.includes(l),le=_[l],te=M||g.label,we=c??l,Ee={required:E},de=x?te:void 0,Rr=x?"...":te;switch(g.type){case"select":if(l==="country"||l==="nationality"||l==="taxCountry"||l==="countryOfBirth"||l==="mobileCountryCode"){const xe=X(l,y);return e.jsx(Pe,{...Ee,label:de,value:D[l]||"",onChange:ze=>se(l,ze),options:[{value:"",label:`Select ${Rr.toLowerCase()}`},...xe],disabled:re,error:le},we)}if(l==="salutation")return e.jsx(Pe,{...Ee,label:de,value:((ct=D[l])==null?void 0:ct.toString())||"",onChange:xe=>se(l,xe?Number(xe):null),options:[{value:"",label:x?"Select salutation...":te},{value:Qe.Male.toString(),label:"Male"},{value:Qe.Female.toString(),label:"Female"},{value:Qe.Other.toString(),label:"Other"}],error:le},we);if(l==="defaultLanguage"){const xe=d!=null&&d.allowedLanguages&&d.allowedLanguages.length>0?nt.filter(ze=>d.allowedLanguages.includes(ze.value)):nt;return e.jsx(Pe,{...Ee,label:de,value:D[l]||"",onChange:ze=>se(l,ze),options:[{value:"",label:x?"Select language...":te},...xe],error:le},we)}return null;case"multiselect":if(l==="otherNationality"){const xe=X(l,y);return e.jsx(pr,{...Ee,label:de,value:D[l]||[],onChange:ze=>se(l,ze),options:xe,placeholder:x?"Select other nationalities...":te,disabled:re},we)}return null;case"date":return e.jsx(he,{...Ee,type:"date",label:de,placeholder:x?void 0:te,value:D[l]||"",onChange:xe=>se(l,xe.target.value),error:le},we);case"email":return e.jsx(he,{...Ee,type:"email",label:de,placeholder:x?void 0:te,value:D[l]||"",onChange:xe=>se(l,xe.target.value),error:le},we);case"tel":return e.jsx(he,{...Ee,type:"tel",label:de,placeholder:x?void 0:te,value:D[l]||"",onChange:xe=>se(l,xe.target.value),error:le},we);default:return e.jsx(he,{...Ee,type:"text",label:de,placeholder:x?void 0:te,value:D[l]||"",onChange:xe=>se(l,xe.target.value),error:le},we)}},Ze=(l,c)=>{if(l.customType==="paragraph"){const g=l.displayText||l.label||"";return e.jsx("p",{className:"metakyc-paragraph",style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:g}},`custom-${c}`)}if(l.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:l.label||""}},`custom-${c}`);if(l.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${c}`);if(l.customType==="link"){const g=l.displayText||l.label||l.linkText||l.linkUrl||"";return e.jsx("div",{className:"metakyc-link-field",children:e.jsxs("a",{href:l.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{display:"inline-flex",alignItems:"center",gap:"4px",color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline",cursor:"pointer"},children:[g,e.jsx("span",{style:{fontSize:"10px",opacity:.7},children:"↗"})]})},`custom-${c}`)}if(!l.paramName)return null;const M=_[l.paramName],y=l.displayText||l.label||l.paramName;if(l.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:U[l.paramName]==="true",onChange:g=>ae(l.paramName,g.target.checked?"true":"false"),className:"metakyc-option-input",style:Ve}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[y,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),M&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:M})]},`custom-${c}`);if(l.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:U[l.paramName]==="true",onChange:g=>ae(l.paramName,g.target.checked?"true":"false"),className:"metakyc-option-input",style:{...Ve,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:[y," ",l.linkUrl&&e.jsx("a",{href:l.linkUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",style:{color:"var(--metakyc-primary, #2563eb)"},onClick:g=>g.stopPropagation(),children:l.linkText||l.linkUrl}),l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),M&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:M})]},`custom-${c}`);if(l.customType==="group_checkbox"){const g=(U[l.paramName]||"").split(",").filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[x&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[y,l.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:(l.options||[]).map(E=>{const le=l.singleSelect?U[l.paramName]===E.value:g.includes(E.value);return 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:le,onChange:te=>{if(l.singleSelect)ae(l.paramName,te.target.checked?E.value:"");else{const we=te.target.checked?[...g,E.value]:g.filter(Ee=>Ee!==E.value);ae(l.paramName,we.join(","))}},className:"metakyc-option-input",style:Ve}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:E.label})]},E.value)})}),M&&e.jsx("p",{className:"text-red-500 text-xs",children:M})]},`custom-${c}`)}return l.customType==="radio_group"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[x&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[y,l.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:(l.options||[]).map(g=>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:U[l.paramName]===g.value,onChange:()=>ae(l.paramName,g.value),name:`radio-group-${l.paramName}-${c}`,className:"metakyc-option-input",style:Ve}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:g.label})]},g.value))}),M&&e.jsx("p",{className:"text-red-500 text-xs",children:M})]},`custom-${c}`):e.jsx(he,{type:"text",label:x?`${y}${l.required?" *":""}`:void 0,placeholder:x?void 0:y,value:U[l.paramName]||"",onChange:g=>ae(l.paramName,g.target.value),required:l.required,error:M},`custom-${c}`)},p=(l,c)=>{const M=ke(l);return e.jsxs("div",{className:"space-y-4",children:[l.conditionalOn&&e.jsx(ht,{helpText:l.conditionalHelpText,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:M,onChange:y=>ae(l.conditionalOn,y.target.checked?"true":"false"),className:"metakyc-option-input",style:Ve}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",fontWeight:500},children:l.conditionalOn})]})}),M&&e.jsx("div",{className:"grid grid-cols-4 gap-4",children:l.fields.map((y,g)=>{const E=y.colSpan===1?"col-span-1":y.colSpan===2?"col-span-2":y.colSpan===3?"col-span-3":"col-span-4",le=y.isCustom?`custom-${g}-${y.paramName}`:`builtin-${y.name}-${g}`;return e.jsx("div",{className:E,children:e.jsx(ht,{helpText:y.helpText,children:y.isCustom?Ze(y,g):Ye(y.name,le,y.displayText,y.countriesType)})},le)})})]})};if(!d||re)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(K,{children:e.jsxs(W,{children:[e.jsx(Ne,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(b){const l=b[ne]??b[0],c=Ce===-1,M=Oe===-1,y=b.length,g=ke(l),E=Object.values(_);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(K,{children:[e.jsx(ye,{children:e.jsx(tt,{title:(d==null?void 0:d.title)||"Create Applicant"})}),e.jsxs(W,{children:[(l.title||l.subtitle||l.description)&&e.jsxs("div",{className:"mb-4",children:[l.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:l.title}),l.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.subtitle}),l.description&&l.description!==l.subtitle&&e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.description})]}),(me||E.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[me&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",me]}),E.map((le,te)=>e.jsx("p",{className:"text-red-600 text-sm",children:le},te))]}),y>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[b.map((le,te)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${te===ne?"flex-1":"w-8"}`,style:te===ne?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:te<ne?{backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{backgroundColor:"#e5e7eb"}},te)),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[ne+1," / ",y]})]}),p(l)]}),e.jsxs(ge,{className:"flex justify-between",children:[e.jsxs("div",{children:[!c&&e.jsx(V,{type:"button",variant:"outline",onClick:()=>{C(Ce),ee({})},disabled:S||h,children:"Previous"}),c&&a&&e.jsx(V,{type:"button",variant:"outline",onClick:a,disabled:S||h,children:"Cancel"})]}),e.jsx(V,{type:"button",isLoading:S||h,onClick:M?Be:at,children:M?l.conditionalOn&&!g?"Skip & Submit":"Submit":l.conditionalOn&&!g?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:Je,children:e.jsxs(K,{children:[e.jsx(ye,{children:e.jsx(tt,{title:(d==null?void 0:d.title)||"Create Applicant"})}),e.jsxs(W,{children:[me&&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:"})," ",me]})}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:N.map(l=>e.jsx("div",{className:"col-span-4",children:Ye(l)},l))})]}),e.jsxs(ge,{className:"flex justify-between",children:[a&&e.jsx(V,{type:"button",variant:"outline",onClick:a,disabled:S||h,children:"Cancel"}),e.jsx(V,{type:"submit",isLoading:S||h,children:"Create Applicant"})]})]})})})},os=({applicantId:t,onComplete:r,onError:s,theme:a="light",className:n})=>{const{progress:i,currentStep:d,steps:u,workflowKey:h,nextWorkflowKey:m,hasWorkflowChanged:f,isLoading:k,error:v,moveBack:w,refreshProgress:x}=ir(t),[b,R]=o.useState(!1);if(o.useEffect(()=>{v&&s&&s(v)},[v,s]),o.useEffect(()=>{i!=null&&i.workflowResult&&r&&r(i.workflowResult)},[i==null?void 0:i.workflowResult,r]),o.useEffect(()=>{a==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},[a]),o.useEffect(()=>{f&&R(!1)},[f]),k||!i)return e.jsx("div",{className:n,children:e.jsx(K,{children:e.jsxs(W,{children:[e.jsx(Ne,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading workflow..."})]})})});if(v)return e.jsx("div",{className:n,children:e.jsx(K,{children:e.jsx(W,{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:v.message})]})})})});if(f&&!b)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(K,{children:e.jsx(W,{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:h})]}),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:()=>R(!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===Se.Finished||i.status===Se.OnHold)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(it,{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(!d)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(K,{children:e.jsxs(W,{children:[e.jsx(Ne,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:i.status===Se.IdentityPending?"Loading identity verification...":"Loading current step..."})]})})});const N=A=>{switch(A){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""}},O=()=>{const A=u.filter(I=>I.visibility!==!1),q=A.findIndex(I=>I.order===d.order),re=q>=0?q+1:1,z=A.length;return e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsx(tt,{}),e.jsxs(Ie,{variant:i.status===1?"info":"success",children:["Step ",re," of ",z]})]}),e.jsx("div",{className:"flex items-center",children:A.map((I,H)=>{const X=H<q,F=I.order===d.order;return e.jsxs(o.Fragment,{children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`
|
|
96
|
+
`,children:[e.jsx("input",{type:"radio",name:`question-${P.id}`,value:U,checked:v[P.id]===U,onChange:ne=>H(P.id,ne.target.value),className:"h-4 w-4 text-primary-500 border-gray-300 focus:ring-primary-500",disabled:h}),e.jsx("span",{className:"ml-3 text-gray-700 dark:text-gray-300",children:U})]},G))})]},P.id)),f&&!O&&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:"})," ",f]})}),O&&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(ge,{className:"flex justify-between",children:[e.jsx(V,{type:"button",variant:"outline",onClick:s,disabled:h,children:"Cancel"}),e.jsx(V,{type:"submit",isLoading:h,disabled:Object.keys(v).length<n.totalQuestionCount,children:O?"Submitting...":"Submit Test"})]})]})}):e.jsxs(K,{children:[e.jsxs(ye,{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(W,{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(Ie,{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(Ie,{variant:"info",children:z(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(Ie,{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(Ie,{variant:D>1?"success":"warning",children:D})]})]}),f&&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:"})," ",f]})}),D<=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(ge,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"button",onClick:I,disabled:D<=0,children:"Start Test"})]})]})},Cr=({applicantId:t,onComplete:r,onBack:s})=>{var Be,Je,Ye,Ze;const{applicantService:a,baseInformationService:n,config:i,currentTheme:d}=be(),{identityData:u,provider:h,token:m,isLoading:f,error:k,requestIdentity:v,restartIdentity:w}=dr(t),[x,b]=o.useState(null),[R,N]=o.useState(null),[O,j]=o.useState([]),[A,q]=o.useState([]),[re,z]=o.useState(!0),[I,H]=o.useState(!1),[X,F]=o.useState(null),[D,P]=o.useState(!1),L=o.useRef(!1),[U,G]=o.useState({}),[ne,C]=o.useState({}),_=d!=null&&d.reviewPageFields&&d.reviewPageFields.length>0?d.reviewPageFields[0]:null,ee=!!(d!=null&&d.reviewPageDisabled),me=o.useRef(!1);me.current=ee;const ce=Fe.useForm({defaultValues:{street:"",streetNumber:"",city:"",zip:"",country:"",nationality:"",phonenumber:""}});o.useEffect(()=>{if(ee){L.current||(L.current=!0,v().then(()=>H(!0)).catch(T=>console.error("[Identity] Auto-request failed:",T)).finally(()=>z(!1)));return}(async()=>{try{const[T,$,B]=await Promise.all([a.getApplicantData(t),n.getCountries("","en"),n.getCountries("","en",40)]);N(T);const Q=new Set,Y=$.map(y=>({value:y.abbreviation3||y.abbreviation,label:y.name})).filter(y=>!y.value||Q.has(y.value)?!1:(Q.add(y.value),!0));j(Y);const ie=new Set,l=B.filter(y=>y.countryCode).map(y=>({value:y.countryCode,label:`${y.countryCode} – ${y.name}`})).filter(y=>ie.has(y.value)?!1:(ie.add(y.value),!0));q(l);const c=T.applicantRequestData;if(G({firstName:(c==null?void 0:c.firstName)||"",lastName:(c==null?void 0:c.lastName)||"",email:(c==null?void 0:c.email)||"",dateOfBirth:(c==null?void 0:c.dateOfBirth)||"",title:(c==null?void 0:c.title)||"",salutation:(c==null?void 0:c.salutation)||"",phonenumber:(c==null?void 0:c.phonenumber)||"",mobileCountryCode:(c==null?void 0:c.mobileCountryCode)||"",street:(c==null?void 0:c.street)||"",streetNumber:(c==null?void 0:c.streetNumber)||"",city:(c==null?void 0:c.city)||"",zip:(c==null?void 0:c.zip)||"",country:(c==null?void 0:c.country)||"",nationality:(c==null?void 0:c.nationality)||"",taxCountry:(c==null?void 0:c.taxCountry)||"",countryOfBirth:(c==null?void 0:c.countryOfBirth)||"",placeOfBirth:(c==null?void 0:c.placeOfBirth)||"",educationLevel:(c==null?void 0:c.educationLevel)||"",occupation:(c==null?void 0:c.occupation)||"",taxNumber:(c==null?void 0:c.taxNumber)||"",defaultLanguage:(c==null?void 0:c.defaultLanguage)||""}),ce.reset({street:(c==null?void 0:c.street)||"",streetNumber:(c==null?void 0:c.streetNumber)||"",city:(c==null?void 0:c.city)||"",zip:(c==null?void 0:c.zip)||"",country:(c==null?void 0:c.country)||"",nationality:(c==null?void 0:c.nationality)||"",phonenumber:(c==null?void 0:c.phonenumber)||""}),T.kycRecords&&T.kycRecords.length>0&&T.kycRecords[0].providerTokenObject!==null&&!L.current&&me.current){console.log("[Identity] Review page disabled + existing identity — auto-requesting..."),L.current=!0;try{await v(),H(!0)}catch(y){console.error("[Identity] Auto-request failed:",y)}}}catch(T){console.error("Error loading applicant data:",T)}finally{z(!1)}})()},[t]),o.useEffect(()=>{u&&!I&&me.current&&(console.log("[Identity] Review page disabled — showing cached provider"),H(!0))},[u,I]),o.useEffect(()=>{if(m){if(m.expiresAt){const p=new Date(m.expiresAt).getTime();if(Date.now()>=p){console.warn("[Identity] Token has expired (expiresAt)"),P(!0),F("Your verification session has expired. Please restart.");return}}if(m.url)try{const T=new URL(m.url).toString().toLowerCase();if(T.includes("expired")||T.includes("invalid")||T.includes("error")){console.warn("[Identity] Token URL indicates expiration"),P(!0),F("Your verification link has expired. Please restart.");return}}catch{console.error("[Identity] Invalid token URL")}if(m.status==="expired"||m.error==="expired"||m.expired===!0){console.warn("[Identity] Token object indicates expiration"),P(!0),F("Your verification session has expired. Please restart.");return}}},[m]),o.useEffect(()=>{if(h!==null&&m&&!x&&I&&!D){const p=h;if(m.url){console.log("[Identity] Loading provider URL for user verification:",m.url),F(null);try{if(new URL(m.url),p===je.SardinAI){console.log("[SardinAI] Initializing Risk SDK in background...");try{const T=_e.parseProviderConfig(h,m,i);_e.createProvider(h,T).initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully in background")}).catch(B=>{console.warn("[SardinAI] Risk SDK initialization failed (non-blocking):",B)})}catch(T){console.warn("[SardinAI] Risk SDK setup failed (non-blocking):",T)}}b({type:"url",url:m.url})}catch(T){console.error("[Identity] Invalid URL:",T),F("Invalid verification URL. Please restart."),P(!0)}return}if(p===je.SardinAI){console.log("[SardinAI] No URL provided - initializing Risk SDK only..."),F(null);try{const T=_e.parseProviderConfig(h,m,i),$=_e.createProvider(h,T);$.initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully"),b($),setTimeout(()=>{r==null||r()},2e3)}).catch(B=>{var Y;console.error("[SardinAI] Failed to initialize:",B);const Q=((Y=B.message)==null?void 0:Y.toLowerCase())||"";Q.includes("expired")||Q.includes("invalid")||Q.includes("401")||Q.includes("400")?(P(!0),F("Session expired or invalid. Please restart verification.")):F(`Failed to initialize: ${B.message}`)})}catch(T){console.error("[SardinAI] Error creating provider:",T),F(`Configuration error: ${T.message}`)}return}try{F(null);const T=_e.parseProviderConfig(h,m,i),$=_e.createProvider(h,T);p===je.Sumsub?($.initialize("identity-container").catch(B=>{var Q;console.error("[Sumsub] Initialization error:",B),F(`Failed to initialize: ${B.message}`),(Q=B.message)!=null&&Q.toLowerCase().includes("expired")&&P(!0)}),$.onComplete&&$.onComplete(()=>{r==null||r()})):p===je.Onfido&&$.initialize("identity-container").catch(B=>{console.error("[Onfido] Initialization error:",B),F(`Failed to initialize: ${B.message}`)}),b($)}catch(T){console.error("[Identity] Provider setup error:",T),F(`Setup error: ${T.message}`)}}return()=>{if(x&&x.destroy)try{x.destroy()}catch(p){console.error("[Identity] Error destroying provider:",p)}}},[h,m,x,I,r,D]);const S=async()=>{try{F(null),P(!1),await v(),H(!0)}catch(p){console.error("Error starting identity verification:",p)}},J=async()=>{try{F(null),P(!1),b(null),console.log("[Identity] Restarting verification..."),await w(),H(!0)}catch(p){console.error("Error restarting identity verification:",p),F(p.message||"Failed to restart verification")}};if(re||f)return e.jsx(K,{children:e.jsxs(W,{children:[e.jsx(Ne,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading identity verification..."})]})});if(k)return e.jsx(K,{children:e.jsx(W,{children:e.jsxs("p",{className:"text-danger-500",children:["Error: ",k.message]})})});if(I&&(X||D))return e.jsxs(K,{children:[e.jsx(ye,{children:e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Verification Session Issue"})}),e.jsxs(W,{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:D?"Session Expired":"Verification Error"}),e.jsx("p",{className:"text-red-800 dark:text-red-200 text-sm",children:X||"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(ge,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"button",onClick:J,disabled:f,children:f?"Restarting...":"Restart Verification"})]})]});if(I&&u){const p=h;return m!=null&&m.url?e.jsxs(K,{children:[e.jsx(ye,{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(V,{type:"button",variant:"outline",size:"sm",onClick:J,disabled:f,children:"Restart"})]})}),e.jsxs(W,{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:m.url,className:"w-full h-full border-0 rounded-lg",allow:"camera; microphone; geolocation",title:"Identity Verification",onLoad:T=>{var $,B,Q;console.log("[Identity] Iframe loaded");try{const Y=T.target,ie=Y.contentDocument||(($=Y.contentWindow)==null?void 0:$.document);if(ie){const l=((Q=(B=ie.body)==null?void 0:B.textContent)==null?void 0:Q.toLowerCase())||"";(l.includes("expired")||l.includes("invalid")||l.includes("error"))&&(console.warn("[Identity] Iframe shows expiration message"),P(!0),F("Your verification link has expired."))}}catch{console.log("[Identity] Cannot check iframe content (CORS)")}}})})]}),s&&e.jsx(ge,{children:e.jsx(V,{variant:"outline",onClick:s,children:"Back"})})]}):p===je.SardinAI?e.jsxs(K,{children:[e.jsxs(ye,{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(W,{children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ne,{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(K,{children:[e.jsxs(ye,{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(W,{children:e.jsx("div",{id:"identity-container",className:"min-h-[400px]"})}),s&&e.jsx(ge,{children:e.jsx(V,{variant:"outline",onClick:s,children:"Back"})})]})}const se=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),ae=(p=4)=>({1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4"})[p]||"col-span-4",ke=(p,T)=>{if(!T&&T!==0)return"—";if(se.has(p)&&p!=="mobileCountryCode"){const $=O.find(B=>B.value===T);return $?$.label:String(T)}return String(T)},Oe=({helpText:p})=>{const[T,$]=o.useState(!1),B=o.useRef(null),[,Q]=o.useState({top:0,left:0}),Y=()=>{if(B.current){const ie=B.current.getBoundingClientRect();Q({top:ie.bottom+window.scrollY+6,left:ie.left+window.scrollX})}$(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"metakyc-help-btn",ref:B,onClick:Y,style:{width:18,height:18,borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:11,fontWeight:700,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:1,position:"relative",zIndex:2},children:"?"}),T&&rt.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>$(!1),children:e.jsxs("div",{onClick:ie=>ie.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 8px)",padding:"20px 24px",maxWidth:400,width:"90%",boxShadow:"0 24px 64px rgba(0,0,0,0.4)"},children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:p},style:{fontSize:13,color:"var(--metakyc-text-primary, #111827)",lineHeight:1.6}}),e.jsx("button",{type:"button",onClick:()=>$(!1),style:{marginTop:12,padding:"4px 12px",fontSize:12,border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 6px)",background:"transparent",cursor:"pointer",color:"var(--metakyc-text-secondary, #6b7280)"},children:"Close"})]})}),document.body)]})},Ce=(p,T)=>T?e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:5,flexWrap:"nowrap"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:p}),e.jsx("div",{style:{paddingTop:24},children:e.jsx(Oe,{helpText:T})})]}):p,Ge=(p,T)=>{const $=`cf-${T}`,B=p.paramName??"",Q=ne[B];if(p.customType==="br")return e.jsx("div",{className:ae(p.colSpan),style:{minHeight:"0.5rem"}},$);if(p.customType==="paragraph")return e.jsx("div",{className:ae(p.colSpan),children:e.jsx("div",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:p.label||""}})},$);if(p.customType==="html")return e.jsx("div",{className:ae(p.colSpan),dangerouslySetInnerHTML:{__html:p.label||""}},$);if(p.customType==="link")return e.jsx("div",{className:ae(p.colSpan),children:Ce(e.jsx("a",{href:p.linkUrl??"#",target:"_blank",rel:"noopener noreferrer",className:"text-sm underline",style:{color:"var(--metakyc-primary, #6366f1)"},children:p.displayText||p.label||p.linkText||p.linkUrl}),p.helpText)},$);if(p.customType==="checkbox"||p.customType==="link_checkbox"){const Y=Q==="true"||Q===!0;return e.jsx("div",{className:ae(p.colSpan),children:Ce(e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!Y,onChange:ie=>C(l=>({...l,[B]:String(ie.target.checked)})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:p.customType==="link_checkbox"&&p.linkUrl?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:p.linkUrl,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #6366f1)",textDecoration:"underline"},children:p.linkText||p.label}),p.label&&p.linkText?` ${p.label}`:""]}):p.displayText||p.label})]}),p.helpText)},$)}if(p.customType==="group_checkbox"){const Y=Array.isArray(Q)?Q:Q?[Q]:[],ie=l=>{p.singleSelect?C(c=>({...c,[B]:Y[0]===l?[]:[l]})):C(c=>({...c,[B]:Y.includes(l)?Y.filter(M=>M!==l):[...Y,l]}))};return e.jsx("div",{className:ae(p.colSpan),children:Ce(e.jsxs("div",{className:"space-y-1.5",children:[p.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:p.displayText||p.label}),(p.options||[]).map(l=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:Y.includes(l.value),onChange:()=>ie(l.value),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:l.label})]},l.value))]}),p.helpText)},$)}return p.customType==="radio_group"?e.jsx("div",{className:ae(p.colSpan),children:Ce(e.jsxs("div",{className:"space-y-1.5",children:[p.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:p.displayText||p.label}),(p.options||[]).map(Y=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"radio",name:`rg-${B}`,value:Y.value,checked:Q===Y.value,onChange:()=>C(ie=>({...ie,[B]:Y.value})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:Y.label})]},Y.value))]}),p.helpText)},$):e.jsx("div",{className:ae(p.colSpan),children:Ce(e.jsx(he,{label:p.displayText||p.label||B,value:String(Q??""),onChange:Y=>C(ie=>({...ie,[B]:Y.target.value}))}),p.helpText)},$)},at=(p,T)=>{if(p.isCustom)return Ge(p,T);const $=p.name??"",B=Me[$],Q=p.displayText||(B==null?void 0:B.label)||$,Y=U[$]??"",ie=$==="mobileCountryCode",l=!!(B!=null&&B.countriesType)&&!ie;return p.editable?ie?e.jsx("div",{className:ae(p.colSpan??2),children:Ce(e.jsx(Pe,{label:Q,value:String(Y),onChange:c=>G(M=>({...M,[$]:c})),options:[{value:"",label:"Select country code…"},...A]}),p.helpText)},`epc-${T}`):l?e.jsx("div",{className:ae(p.colSpan??2),children:Ce(e.jsx(Pe,{label:Q,value:String(Y),onChange:c=>G(M=>({...M,[$]:c})),options:[{value:"",label:`Select ${Q.toLowerCase()}…`},...O]}),p.helpText)},`ec-${T}`):e.jsx("div",{className:ae(p.colSpan??2),children:Ce(e.jsx(he,{label:Q,type:(B==null?void 0:B.type)==="date"?"date":(B==null?void 0:B.type)==="email"?"email":"text",value:String(Y),onChange:c=>G(M=>({...M,[$]:c.target.value}))}),p.helpText)},`ei-${T}`):e.jsx("div",{className:ae(p.colSpan??2),children:Ce(e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"block text-sm font-medium mb-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:Q}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)",minHeight:"1.5rem"},children:ke($,Y)})]}),p.helpText)},`ro-${T}`)};if(_){const p=_.title||"Review Your Information",T=_.subtitle||"Please review and confirm your information before starting identity verification";return e.jsx("form",{onSubmit:$=>{$.preventDefault(),S()},children:e.jsxs(K,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:p}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:T})]}),e.jsx(W,{children:e.jsx("div",{className:"grid grid-cols-4 gap-4",children:_.fields.map(($,B)=>at($,B))})}),e.jsxs(ge,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"submit",isLoading:f,children:"Confirm and Start Verification"})]})]})})}return e.jsx("form",{onSubmit:ce.handleSubmit(S),children:e.jsxs(K,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Review Your Information"}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please review and confirm your information before starting identity verification"})]}),e.jsxs(W,{className:"space-y-6",children:[e.jsx("div",{className:"space-y-4 pb-4",style:{borderBottom:"1px solid var(--metakyc-border, #e5e7eb)"},children:[{label:"Name",value:`${((Be=R==null?void 0:R.applicantRequestData)==null?void 0:Be.firstName)||""} ${((Je=R==null?void 0:R.applicantRequestData)==null?void 0:Je.lastName)||""}`.trim()},{label:"Email",value:(Ye=R==null?void 0:R.applicantRequestData)==null?void 0:Ye.email},{label:"Date of Birth",value:((Ze=R==null?void 0:R.applicantRequestData)==null?void 0:Ze.dateOfBirth)||"Not provided"}].map(({label:p,value:T})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:p}),e.jsx("p",{className:"mt-1 text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:T})]},p))}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Address Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Fe.Controller,{control:ce.control,name:"country",render:({field:p})=>e.jsx(Pe,{label:"Country",value:p.value,onChange:p.onChange,options:[{value:"",label:"Select country…"},...O]})}),e.jsx(Fe.Controller,{control:ce.control,name:"nationality",render:({field:p})=>e.jsx(Pe,{label:"Nationality",value:p.value,onChange:p.onChange,options:[{value:"",label:"Select nationality…"},...O]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Fe.Controller,{control:ce.control,name:"street",render:({field:p})=>e.jsx(he,{...p,label:"Street"})}),e.jsx(Fe.Controller,{control:ce.control,name:"streetNumber",render:({field:p})=>e.jsx(he,{...p,label:"Street Number"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Fe.Controller,{control:ce.control,name:"city",render:({field:p})=>e.jsx(he,{...p,label:"City"})}),e.jsx(Fe.Controller,{control:ce.control,name:"zip",render:({field:p})=>e.jsx(he,{...p,label:"ZIP / Postal Code"})})]}),e.jsx(Fe.Controller,{control:ce.control,name:"phonenumber",render:({field:p})=>e.jsx(he,{...p,label:"Phone Number",type:"tel"})})]})]}),e.jsxs(ge,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"submit",isLoading:f,children:"Confirm and Start Verification"})]})]})})},it=({kycStatus:t,reviewStatus:r,workflowResult:s,customMessage:a,onContinue:n,onContactSupport:i})=>{const u=t===Le.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===Le.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===Le.Pending||t===Le.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===De.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===De.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===De.UnderReview||r===De.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===qe.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===qe.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===qe.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(K,{children:[e.jsxs(W,{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 ${u.iconBg}`,children:e.jsx("span",{className:`text-5xl ${u.iconColor}`,children:u.icon})})}),e.jsx("h2",{className:"text-3xl font-bold text-center text-gray-900 dark:text-white mb-4",children:u.title}),e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx(Ie,{variant:u.type==="success"?"success":u.type==="error"?"danger":u.type==="pending"?"warning":"info",children:t!=null?Le[t]:De[r]})}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mb-6 max-w-md mx-auto",children:a||u.message}),u.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"})]})]}),u.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"})]})]}),u.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?Le[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:De[r]})]})]})})]}),e.jsxs(ge,{className:"flex justify-center gap-4",children:[u.type==="success"&&n&&e.jsx(V,{onClick:n,size:"lg",children:"Continue"}),u.type==="error"&&e.jsxs(e.Fragment,{children:[i&&e.jsx(V,{variant:"outline",onClick:i,children:"Contact Support"}),n&&e.jsx(V,{onClick:n,children:"Try Again"})]}),u.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"})})]})]})},Er=({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"}})}),tt=({title:t,subtitle:r,className:s=""})=>{const{currentTheme:a}=be(),n=t||(a==null?void 0:a.title)||"",i=!!(a!=null&&a.logo&&a.logo.visible&&a.logo.url),d=!!n;return!i&&!d?null:e.jsxs("div",{className:`metakyc-header ${s}`,children:[e.jsxs("div",{className:"metakyc-header-title flex items-center text-xl font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:[i&&e.jsx(Er,{config:a.logo}),i&&d&&e.jsx("span",{style:{fontSize:"1.5rem",fontWeight:300,color:"var(--metakyc-text-muted, #9ca3af)",margin:"0 12px"},children:"|"}),d&&e.jsx("span",{style:{color:"var(--metakyc-text-primary, #111827)"},children:n})]}),r&&e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:r})]})},Xe=["firstName","lastName","email","phonenumber","dateOfBirth"];function He(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const Ve={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"},ht=({helpText:t,children:r})=>{const[s,a]=o.useState(!1);if(!t)return e.jsx(e.Fragment,{children:r});const n=s?e.jsx("div",{role:"dialog","aria-modal":"true",onClick:()=>a(!1),style:{position:"fixed",inset:0,zIndex:999999,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"},children:e.jsxs("div",{onClick:i=>i.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"12px",padding:"28px 24px 24px",maxWidth:"480px",width:"100%",maxHeight:"80vh",overflowY:"auto",boxShadow:"0 24px 64px rgba(0,0,0,0.4)",position:"relative"},children:[e.jsx("button",{type:"button",onClick:()=>a(!1),"aria-label":"Close",style:{position:"absolute",top:"12px",right:"12px",width:"28px",height:"28px",borderRadius:"50%",border:"1px solid var(--metakyc-border, #e5e7eb)",background:"var(--metakyc-input-bg, #f3f4f6)",color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:"×"}),e.jsx("div",{style:{color:"var(--metakyc-text-primary, #111827)",fontSize:"14px",lineHeight:1.75},dangerouslySetInnerHTML:{__html:t}})]})}):null;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",flexWrap:"nowrap"},children:[r,e.jsx("button",{type:"button",className:"metakyc-help-btn",onClick:()=>a(!0),"aria-label":"Help",style:{flexShrink:0,marginTop:"2px",width:"18px",height:"18px",borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:"10px",fontWeight:"700",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0,position:"relative",zIndex:2,transition:"background 0.15s, color 0.15s"},onMouseEnter:i=>{i.currentTarget.style.background="var(--metakyc-primary, #2563eb)",i.currentTarget.style.color="#ffffff"},onMouseLeave:i=>{i.currentTarget.style.background="transparent",i.currentTarget.style.color="var(--metakyc-primary, #2563eb)"},children:"?"}),typeof document<"u"&&n?rt.createPortal(n,document.body):null]})},is=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:a})=>{var T,$,B,Q,Y,ie;const{config:n,baseInformationService:i,currentTheme:d}=be(),{createApplicant:u,isLoading:h}=mr(),m=t||((T=n.applicantForm)==null?void 0:T.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 f=r||(($=n.applicantForm)==null?void 0:$.externalRefId)||"",k=((B=n.applicantForm)==null?void 0:B.email)||"",v=((Q=n.applicantForm)==null?void 0:Q.hiddenValues)||{},x=(((Y=n.applicantForm)==null?void 0:Y.fieldLabelMode)||(d==null?void 0:d.fieldLabelMode)||"label")!=="placeholder",b=o.useMemo(()=>d!=null&&d.applicantFormPages&&d.applicantFormPages.length>0?d.applicantFormPages:null,[d==null?void 0:d.applicantFormPages]),R=o.useMemo(()=>{const l=new Set(Xe),c=d==null?void 0:d.applicantFormRequiredFields;if(c)for(const M of c)l.add(M);if(b)for(const M of b)for(const y of M.fields)!y.isCustom&&y.name&&y.required&&l.add(y.name);return Array.from(l)},[d==null?void 0:d.applicantFormRequiredFields,b]),N=o.useMemo(()=>{var M;if(b){const y=b.flatMap(E=>E.fields).filter(E=>!E.isCustom&&E.name).map(E=>E.name),g=new Set(y);for(const E of Xe)g.add(E);return Array.from(g)}let l;(M=n.applicantForm)!=null&&M.visibleFields?l=n.applicantForm.visibleFields:d!=null&&d.applicantFormVisibleFields&&d.applicantFormVisibleFields.length>0?l=d.applicantFormVisibleFields:l=Ct;const c=new Set(l);for(const y of Xe)c.add(y);return Array.from(c)},[(ie=n.applicantForm)==null?void 0:ie.visibleFields,d==null?void 0:d.applicantFormVisibleFields,b]),O=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),j=o.useMemo(()=>{var c,M;const l=new Set;if(b)for(const y of b)for(const g of y.fields)!g.isCustom&&g.name&&O.has(g.name)&&l.add(g.countriesType??((c=Me[g.name])==null?void 0:c.countriesType));else for(const y of N)O.has(y)&&l.add((M=Me[y])==null?void 0:M.countriesType);return l.size===0&&l.add(void 0),Array.from(l)},[N,b]),[A,q]=o.useState({}),[re,z]=o.useState(!0),I=o.useRef(new Set),H=o.useRef(new Set);o.useEffect(()=>{if(!d)return;const l=j.filter(y=>{const g=y!=null?String(y):"all";return!H.current.has(g)&&!I.current.has(g)});if(l.length===0){j.every(g=>{const E=g!=null?String(g):"all";return H.current.has(E)})&&z(!1);return}z(!0);const c=l.map(y=>y!=null?String(y):"all");c.forEach(y=>I.current.add(y)),(async()=>{try{const y=await Promise.all(l.map(async g=>{const E=g!=null?String(g):"all",le=await i.getCountries("",n.locale||"en",g),te=g===40,we=new Set,Ee=le.map(de=>te&&de.countryCode?{value:de.countryCode,label:`${de.countryCode} – ${de.name}`}:{value:de.abbreviation3||de.abbreviation,label:de.name}).filter(de=>!de.value||we.has(de.value)?!1:(we.add(de.value),!0));return H.current.add(E),I.current.delete(E),[E,Ee]}));q(g=>({...g,...Object.fromEntries(y)}))}catch(y){c.forEach(g=>I.current.delete(g)),console.error("Failed to load countries:",y)}finally{j.every(g=>{const E=g!=null?String(g):"all";return H.current.has(E)})&&z(!1)}})()},[j,d]);const X=(l,c)=>{var g;const M=c??((g=Me[l])==null?void 0:g.countriesType),y=M!=null?String(M):"all";return A[y]||[]},F=Object.fromEntries(Object.entries(v).filter(([l])=>l in{firstName:1,lastName:1,title:1,email:1,dateOfBirth:1,phonenumber:1,mobileCountryCode:1,street:1,streetNumber:1,zip:1,city:1,country:1,nationality:1,otherNationality:1,defaultLanguage:1,taxCountry:1,placeOfBirth:1,countryOfBirth:1,salutation:1,educationLevel:1,occupation:1,taxNumber:1})),[D,P]=o.useState({workflowKey:m,firstName:"",lastName:"",title:"",email:k,dateOfBirth:"",phonenumber:"",externalRefId:f,mobileCountryCode:"",street:"",streetNumber:"",zip:"",city:"",country:"",nationality:"",otherNationality:[],defaultLanguage:"EN",taxCountry:"",placeOfBirth:"",countryOfBirth:"",salutation:null,educationLevel:"",occupation:"",taxNumber:"",...F}),L=Object.fromEntries(Object.entries(v).filter(([l])=>!(l in F)&&l!=="externalRefId"&&l!=="workflowKey")),[U,G]=o.useState({...L}),[ne,C]=o.useState(0),[_,ee]=o.useState({}),[me,ce]=o.useState(null),[S,J]=o.useState(!1),se=(l,c)=>P(M=>({...M,[l]:c})),ae=(l,c)=>G(M=>({...M,[l]:c})),ke=l=>!l.conditionalOn||U[l.conditionalOn]==="true",Oe=b&&ne<b.length-1?ne+1:-1,Ce=b&&ne>0?ne-1:-1,Ge=l=>{var M;const c={};for(const y of l.fields)if(y.isCustom){if(y.customType==="paragraph"||y.customType==="html"||y.customType==="br"||y.customType==="link")continue;if(y.required&&y.paramName){const g=U[y.paramName],E=y.displayText||y.label||y.paramName;y.customType==="checkbox"||y.customType==="link_checkbox"?g!=="true"&&(c[y.paramName]=`${E} is required.`):(!g||g.trim()==="")&&(c[y.paramName]=`${E} is required.`)}}else if(y.name){const g=y.name;if(R.includes(g)&&He(D[g])){const E=y.displayText||((M=Me[g])==null?void 0:M.label)||g;c[g]=`${E} is required.`}}return c},at=async()=>{if(!b)return;const l=b[ne];if(l.conditionalOn&&!ke(l)){ee({}),Oe>=0?C(Oe):await Be();return}const c=Ge(l);if(Object.keys(c).length>0){ee(c);return}ee({}),Oe>=0?C(Oe):await Be()},Be=async()=>{if(b){let l={};for(const c of b)ke(c)&&(l={...l,...Ge(c)});if(Object.keys(l).length>0){ee(l);return}}J(!0),ce(null);try{if(!D.externalRefId||D.externalRefId.trim()===""){ce("External Reference ID is required. Please pass it via config.applicantForm.externalRefId.");return}const l={workflowKey:D.workflowKey,externalRefId:D.externalRefId.trim()};if(b){for(const g of b)if(ke(g)){for(const E of g.fields)if(!E.isCustom&&E.name){const le=E.name,te=D[le];He(te)||(l[le]=te)}}for(const g of Xe)if(l[g]===void 0){const E=D[g];He(E)||(l[g]=E)}}else N.forEach(g=>{if(g==="externalRefId")return;const E=D[g];He(E)||(l[g]=E)});const c=[];if(b){for(const g of b)if(ke(g))for(const E of g.fields){if(!E.isCustom||!E.paramName||E.customType==="paragraph"||E.customType==="html"||E.customType==="br"||E.customType==="link")continue;const le=U[E.paramName]??"";let te;if(E.customType==="checkbox"||E.customType==="link_checkbox")te=le==="true"?"yes":"no";else if(te=le,!te&&!E.required)continue;c.push({paramName:E.paramName,value:te})}}for(const[g,E]of Object.entries(F))l[g]===void 0&&!He(E)&&(l[g]=E);const M=new Set(c.map(g=>g.paramName));for(const[g,E]of Object.entries(L))!M.has(g)&&E&&c.push({paramName:g,value:E});c.length>0&&(l.applicantAdditionalDatas=c);const y=await u(l);s(y.applicantId)}catch(l){console.error("Error creating applicant:",l),ce(l.message||"Failed to create applicant")}finally{J(!1)}},Je=async l=>{var c;l.preventDefault();for(const M of R)if(He(D[M])){const y=((c=Me[M])==null?void 0:c.label)||M;ce(`${y} is required.`);return}await Be()},Ye=(l,c,M,y)=>{var ct;const g=Me[l];if(!g)return null;const E=R.includes(l),le=_[l],te=M||g.label,we=c??l,Ee={required:E},de=x?te:void 0,Rr=x?"...":te;switch(g.type){case"select":if(l==="country"||l==="nationality"||l==="taxCountry"||l==="countryOfBirth"||l==="mobileCountryCode"){const xe=X(l,y);return e.jsx(Pe,{...Ee,label:de,value:D[l]||"",onChange:ze=>se(l,ze),options:[{value:"",label:`Select ${Rr.toLowerCase()}`},...xe],disabled:re,error:le},we)}if(l==="salutation")return e.jsx(Pe,{...Ee,label:de,value:((ct=D[l])==null?void 0:ct.toString())||"",onChange:xe=>se(l,xe?Number(xe):null),options:[{value:"",label:x?"Select salutation...":te},{value:Qe.Male.toString(),label:"Male"},{value:Qe.Female.toString(),label:"Female"},{value:Qe.Other.toString(),label:"Other"}],error:le},we);if(l==="defaultLanguage"){const xe=d!=null&&d.allowedLanguages&&d.allowedLanguages.length>0?nt.filter(ze=>d.allowedLanguages.includes(ze.value)):nt;return e.jsx(Pe,{...Ee,label:de,value:D[l]||"",onChange:ze=>se(l,ze),options:[{value:"",label:x?"Select language...":te},...xe],error:le},we)}return null;case"multiselect":if(l==="otherNationality"){const xe=X(l,y);return e.jsx(pr,{...Ee,label:de,value:D[l]||[],onChange:ze=>se(l,ze),options:xe,placeholder:x?"Select other nationalities...":te,disabled:re},we)}return null;case"date":return e.jsx(he,{...Ee,type:"date",label:de,placeholder:x?void 0:te,value:D[l]||"",onChange:xe=>se(l,xe.target.value),error:le},we);case"email":return e.jsx(he,{...Ee,type:"email",label:de,placeholder:x?void 0:te,value:D[l]||"",onChange:xe=>se(l,xe.target.value),error:le},we);case"tel":return e.jsx(he,{...Ee,type:"tel",label:de,placeholder:x?void 0:te,value:D[l]||"",onChange:xe=>se(l,xe.target.value),error:le},we);default:return e.jsx(he,{...Ee,type:"text",label:de,placeholder:x?void 0:te,value:D[l]||"",onChange:xe=>se(l,xe.target.value),error:le},we)}},Ze=(l,c)=>{if(l.customType==="paragraph"){const g=l.displayText||l.label||"";return e.jsx("p",{className:"metakyc-paragraph",style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:g}},`custom-${c}`)}if(l.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:l.label||""}},`custom-${c}`);if(l.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${c}`);if(l.customType==="link"){const g=l.displayText||l.label||l.linkText||l.linkUrl||"";return e.jsx("div",{className:"metakyc-link-field",children:e.jsxs("a",{href:l.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{display:"inline-flex",alignItems:"center",gap:"4px",color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline",cursor:"pointer"},children:[g,e.jsx("span",{style:{fontSize:"10px",opacity:.7},children:"↗"})]})},`custom-${c}`)}if(!l.paramName)return null;const M=_[l.paramName],y=l.displayText||l.label||l.paramName;if(l.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:U[l.paramName]==="true",onChange:g=>ae(l.paramName,g.target.checked?"true":"false"),className:"metakyc-option-input",style:Ve}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[y,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),M&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:M})]},`custom-${c}`);if(l.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:U[l.paramName]==="true",onChange:g=>ae(l.paramName,g.target.checked?"true":"false"),className:"metakyc-option-input",style:{...Ve,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:[y," ",l.linkUrl&&e.jsx("a",{href:l.linkUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",style:{color:"var(--metakyc-primary, #2563eb)"},onClick:g=>g.stopPropagation(),children:l.linkText||l.linkUrl}),l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),M&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:M})]},`custom-${c}`);if(l.customType==="group_checkbox"){const g=(U[l.paramName]||"").split(",").filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[x&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[y,l.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:(l.options||[]).map(E=>{const le=l.singleSelect?U[l.paramName]===E.value:g.includes(E.value);return 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:le,onChange:te=>{if(l.singleSelect)ae(l.paramName,te.target.checked?E.value:"");else{const we=te.target.checked?[...g,E.value]:g.filter(Ee=>Ee!==E.value);ae(l.paramName,we.join(","))}},className:"metakyc-option-input",style:Ve}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:E.label})]},E.value)})}),M&&e.jsx("p",{className:"text-red-500 text-xs",children:M})]},`custom-${c}`)}return l.customType==="radio_group"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[x&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[y,l.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:(l.options||[]).map(g=>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:U[l.paramName]===g.value,onChange:()=>ae(l.paramName,g.value),name:`radio-group-${l.paramName}-${c}`,className:"metakyc-option-input",style:Ve}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:g.label})]},g.value))}),M&&e.jsx("p",{className:"text-red-500 text-xs",children:M})]},`custom-${c}`):e.jsx(he,{type:"text",label:x?`${y}${l.required?" *":""}`:void 0,placeholder:x?void 0:y,value:U[l.paramName]||"",onChange:g=>ae(l.paramName,g.target.value),required:l.required,error:M},`custom-${c}`)},p=(l,c)=>{const M=ke(l);return e.jsxs("div",{className:"space-y-4",children:[l.conditionalOn&&e.jsx(ht,{helpText:l.conditionalHelpText,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:M,onChange:y=>ae(l.conditionalOn,y.target.checked?"true":"false"),className:"metakyc-option-input",style:Ve}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",fontWeight:500},children:l.conditionalOn})]})}),M&&e.jsx("div",{className:"grid grid-cols-4 gap-4",children:l.fields.map((y,g)=>{const E=y.colSpan===1?"col-span-1":y.colSpan===2?"col-span-2":y.colSpan===3?"col-span-3":"col-span-4",le=y.isCustom?`custom-${g}-${y.paramName}`:`builtin-${y.name}-${g}`;return e.jsx("div",{className:E,children:e.jsx(ht,{helpText:y.helpText,children:y.isCustom?Ze(y,g):Ye(y.name,le,y.displayText,y.countriesType)})},le)})})]})};if(!d||re)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(K,{children:e.jsxs(W,{children:[e.jsx(Ne,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(b){const l=b[ne]??b[0],c=Ce===-1,M=Oe===-1,y=b.length,g=ke(l),E=Object.values(_);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(K,{children:[e.jsx(ye,{children:e.jsx(tt,{title:(d==null?void 0:d.title)||"Create Applicant"})}),e.jsxs(W,{children:[(l.title||l.subtitle||l.description)&&e.jsxs("div",{className:"mb-4",children:[l.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:l.title}),l.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.subtitle}),l.description&&l.description!==l.subtitle&&e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.description})]}),(me||E.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[me&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",me]}),E.map((le,te)=>e.jsx("p",{className:"text-red-600 text-sm",children:le},te))]}),y>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[b.map((le,te)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${te===ne?"flex-1":"w-8"}`,style:te===ne?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:te<ne?{backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{backgroundColor:"#e5e7eb"}},te)),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[ne+1," / ",y]})]}),p(l)]}),e.jsxs(ge,{className:"flex justify-between",children:[e.jsxs("div",{children:[!c&&e.jsx(V,{type:"button",variant:"outline",onClick:()=>{C(Ce),ee({})},disabled:S||h,children:"Previous"}),c&&a&&e.jsx(V,{type:"button",variant:"outline",onClick:a,disabled:S||h,children:"Cancel"})]}),e.jsx(V,{type:"button",isLoading:S||h,onClick:M?Be:at,children:M?l.conditionalOn&&!g?"Skip & Submit":"Submit":l.conditionalOn&&!g?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:Je,children:e.jsxs(K,{children:[e.jsx(ye,{children:e.jsx(tt,{title:(d==null?void 0:d.title)||"Create Applicant"})}),e.jsxs(W,{children:[me&&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:"})," ",me]})}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:N.map(l=>e.jsx("div",{className:"col-span-4",children:Ye(l)},l))})]}),e.jsxs(ge,{className:"flex justify-between",children:[a&&e.jsx(V,{type:"button",variant:"outline",onClick:a,disabled:S||h,children:"Cancel"}),e.jsx(V,{type:"submit",isLoading:S||h,children:"Create Applicant"})]})]})})})},os=({applicantId:t,onComplete:r,onError:s,theme:a="light",className:n})=>{const{progress:i,currentStep:d,steps:u,workflowKey:h,nextWorkflowKey:m,hasWorkflowChanged:f,isLoading:k,error:v,moveBack:w,refreshProgress:x}=ir(t),[b,R]=o.useState(!1);if(o.useEffect(()=>{v&&s&&s(v)},[v,s]),o.useEffect(()=>{i!=null&&i.workflowResult&&r&&r(i.workflowResult)},[i==null?void 0:i.workflowResult,r]),o.useEffect(()=>{a==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},[a]),o.useEffect(()=>{f&&R(!1)},[f]),k||!i)return e.jsx("div",{className:n,children:e.jsx(K,{children:e.jsxs(W,{children:[e.jsx(Ne,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading workflow..."})]})})});if(v)return e.jsx("div",{className:n,children:e.jsx(K,{children:e.jsx(W,{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:v.message})]})})})});if(f&&!b)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(K,{children:e.jsx(W,{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:h})]}),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:()=>R(!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===Se.Finished||i.status===Se.OnHold)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(it,{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(!d)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(K,{children:e.jsxs(W,{children:[e.jsx(Ne,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:i.status===Se.IdentityPending?"Loading identity verification...":"Loading current step..."})]})})});const N=A=>{switch(A){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""}},O=()=>{const A=u.filter(I=>I.visibility!==!1),q=A.findIndex(I=>I.order===d.order),re=q>=0?q+1:1,z=A.length;return e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsx(tt,{}),e.jsxs(Ie,{variant:i.status===1?"info":"success",children:["Step ",re," of ",z]})]}),e.jsx("div",{className:"flex items-center",children:A.map((I,H)=>{const X=H<q,F=I.order===d.order;return e.jsxs(o.Fragment,{children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`
|
|
97
97
|
w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium
|
|
98
98
|
${X||F?"bg-primary-500 text-white":"bg-gray-200 text-gray-600 dark:bg-gray-700 dark:text-gray-400"}
|
|
99
99
|
`,children:H+1}),e.jsx("span",{className:`ml-2 text-sm ${F?"font-semibold text-gray-900 dark:text-white":"text-gray-600 dark:text-gray-400"}`,children:I.displayName||I.name||N(I.action)||`Step ${H+1}`})]}),H<A.length-1&&e.jsx("div",{className:`flex-1 h-0.5 mx-4 ${X?"bg-primary-500":"bg-gray-200 dark:bg-gray-700"}`})]},I.order)})})]})},j=()=>{const A={applicantId:t,onComplete:async()=>{await x()},onBack:d.order>0?w:void 0};switch(d.action){case Z.Questionaries:return e.jsx(vr,{...A});case Z.UploadDocument:return e.jsx(kr,{...A});case Z.Overview:return e.jsx(wr,{...A});case Z.IdentitySdk:return e.jsx(Cr,{...A});case Z.RiskScoring:return e.jsx(jr,{...A});case Z.AdditionalData:case Z.InvestorCategorization:return e.jsx(Sr,{...A});case Z.AppropriatenessTest:return e.jsx(Nr,{...A});case Z.ManualReview:return e.jsx(it,{kycStatus:i.kycStatus,reviewStatus:i.reviewStatus,workflowResult:i.workflowResult,customMessage:i.customMessage});default:return e.jsx(K,{children:e.jsxs(W,{className:"py-12 text-center",children:[e.jsx("div",{className:"mb-4",children:e.jsx(Ne,{})}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mb-2",children:["Processing step: ",d.title||d.name]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Action type: ",Z[d.action]]})]})})}};return e.jsxs("div",{className:`metakyc-sdk ${n||""}`,children:[O(),j()]})};function ls(t){return Te.z.object({questionResults:Te.z.any()}).passthrough()}function cs(t){let r=Te.z.array(Te.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 ds(t){const r={};return t.uploadDocumentFiles.forEach(s=>{const a=`file_${s.id}`;r[a]=cs(s)}),Te.z.object(r)}function us(t){return Te.z.any()}function ms(t){return Te.z.string().min(1,"This question is required")}function ps(t){const r={};return t.appropriatenessQuestions.forEach(s=>{const a=`question_${s.id}`;r[a]=ms()}),Te.z.object(r)}const hs=Te.z.any();exports.ALLOWED_LANGUAGES=nt;exports.ApplicantProgressOnHoldReason=yt;exports.ApplicantProgressStatus=Se;exports.ApplicantService=It;exports.ApplicantStatus=gt;exports.AppropriatenessQuestionType=wt;exports.AppropriatenessTestService=Ft;exports.AppropriatenessTestStep=Nr;exports.Badge=Ie;exports.BaseInformationService=Ot;exports.Button=V;exports.Card=K;exports.CardContent=W;exports.CardFooter=ge;exports.CardHeader=ye;exports.CountriesType=$e;exports.CreateApplicantForm=is;exports.CriteriaBuiltInType=St;exports.DEFAULT_VISIBLE_FIELDS=Ct;exports.DocumentReviewStatus=kt;exports.EndpointBuilder=Rt;exports.ErrorHandler=Ue;exports.EventEmitter=Yt;exports.FIELD_METADATA=Me;exports.FileType=vt;exports.FileUpload=hr;exports.GenderType=Qe;exports.Header=tt;exports.HttpClient=At;exports.IdentityProviderManager=_e;exports.IdentityService=Mt;exports.IdentityVerificationProvider=je;exports.IdentityVerificationStep=Cr;exports.Input=he;exports.InvestorCategorizationService=Bt;exports.InvestorCategorizationStep=Sr;exports.InvestorCategorizationType=ve;exports.InvestorCategoryType=Nt;exports.KycProcessStatus=ft;exports.KycStatus=Le;exports.KycStatusDisplay=it;exports.KycWorkflow=os;exports.Logo=Er;exports.MetaKYCContext=lt;exports.MetaKYCError=Re;exports.MetaKYCProvider=Mr;exports.MultiSelect=pr;exports.OnfidoProvider=Jt;exports.OverviewService=Lt;exports.OverviewStep=wr;exports.PhoneInput=yr;exports.QuestionnaireService=Pt;exports.QuestionnaireStep=vr;exports.ReviewStatus=De;exports.RiskCriteriaType=jt;exports.RiskLevel=xt;exports.RiskScoringService=Dt;exports.RiskScoringStep=jr;exports.SardinAIProvider=Zt;exports.SearchableSelect=Pe;exports.Select=st;exports.Spinner=Ne;exports.StepRouter=qt;exports.SumsubProvider=Gt;exports.ThemeManager=Xt;exports.ThemePreset=pe;exports.ThemeService=Wt;exports.UploadDocumentService=Tt;exports.UploadDocumentStep=kr;exports.UserType=bt;exports.ValueDataType=Ae;exports.WorkflowOrchestrator=Qt;exports.WorkflowResultType=qe;exports.WorkflowState=Vt;exports.WorkflowStepAction=Z;exports.appropriatenessTestSchema=hs;exports.clearAllStorage=_r;exports.clearApplicantId=sr;exports.clearWorkflowState=nr;exports.cn=ue;exports.corporateTheme=zt;exports.defaultConfig=Et;exports.defaultTheme=fe;exports.fileToBase64=er;exports.fintechTheme=$t;exports.formatFileSize=et;exports.generateAppropriatenessSchema=ps;exports.generateQuestionnaireSchema=ls;exports.generateRiskScoringSchema=us;exports.generateUploadDocumentSchema=ds;exports.getAcceptString=zr;exports.getApplicantId=rr;exports.getThemePreset=Ke;exports.getWorkflowState=$r;exports.healthcareTheme=_t;exports.isScriptLoaded=Fr;exports.loadScript=ot;exports.minimalTheme=Ut;exports.modernTheme=Ht;exports.removeScript=Lr;exports.saveApplicantId=tr;exports.saveWorkflowState=ar;exports.themePresets=Kt;exports.useApplicant=mr;exports.useAppropriatenessTest=Hr;exports.useIdentityVerification=dr;exports.useKycWorkflow=ir;exports.useMetaKYC=be;exports.useOverview=cr;exports.useQuestionnaire=or;exports.useRiskScoring=ur;exports.useUploadDocument=lr;exports.validateFileSize=Or;exports.validateFileType=Br;
|