@vpdev2/metakyc-sdk 1.0.76 → 1.0.78

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/index.cjs CHANGED
@@ -1,4 +1,54 @@
1
- "use strict";var vr=Object.defineProperty;var kr=(t,r,s)=>r in t?vr(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s;var X=(t,r,s)=>kr(t,typeof r!="symbol"?r+"":r,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const wr=require("axios"),l=require("react"),e=require("react/jsx-runtime"),qe=require("react-dom"),Se=require("react-hook-form"),we=require("zod");function jr(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 rt=jr(l);var G=(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))(G||{}),He=(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))(He||{}),xe=(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))(xe||{}),ot=(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))(ot||{}),lt=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(lt||{}),Ne=(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))(Ne||{}),Ce=(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))(Ce||{}),ct=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(ct||{}),dt=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(dt||{}),he=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(he||{}),ut=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(ut||{}),Ue=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(Ue||{}),pt=(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))(pt||{}),mt=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(mt||{}),ht=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))(ht||{}),be=(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))(be||{}),xt=(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))(xt||{}),gt=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))(gt||{}),pe=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(pe||{}),yt=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(yt||{});const Ie={Nationality:10,Address:20,CountryOfBirth:30,PhoneNumber:40,UboAddress:50},Re={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:Ie.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:Ie.Address},nationality:{label:"Nationality",type:"select",countriesType:Ie.Nationality},otherNationality:{label:"Other Nationalities",type:"multiselect",countriesType:Ie.Nationality},countryOfBirth:{label:"Country of Birth",type:"select",countriesType:Ie.CountryOfBirth},placeOfBirth:{label:"Place of Birth",type:"text"},taxCountry:{label:"Tax Country",type:"select",countriesType:Ie.Address},taxNumber:{label:"Tax Number",type:"text"},defaultLanguage:{label:"Default Language",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"}},ft=["firstName","lastName","email","phonenumber","dateOfBirth"],Ze=[{value:"EN",label:"English"},{value:"DE",label:"German"},{value:"FR",label:"French"},{value:"ES",label:"Spanish"},{value:"IT",label:"Italian"},{value:"PT",label:"Portuguese"},{value:"NL",label:"Dutch"},{value:"PL",label:"Polish"},{value:"RU",label:"Russian"},{value:"ZH",label:"Chinese"},{value:"JA",label:"Japanese"},{value:"AR",label:"Arabic"},{value:"TR",label:"Turkish"},{value:"SV",label:"Swedish"},{value:"DA",label:"Danish"},{value:"FI",label:"Finnish"},{value:"NO",label:"Norwegian"}];var ae=(t=>(t.Default="default",t.Corporate="corporate",t.Fintech="fintech",t.Healthcare="healthcare",t.Modern="modern",t.Minimal="minimal",t))(ae||{});const bt={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class vt{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 fe extends Error{constructor(s,a,i,o,c){super(s);X(this,"response");this.code=a,this.details=i,this.validationErrors=o,this.name="MetaKYCError",this.response=c,Object.setPrototypeOf(this,fe.prototype)}}class Fe{static handleApiError(r){return new fe(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 fe(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 fe(s.result.message,r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response):new fe((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 fe("No response from server",0,"The request was made but no response was received. Please check your network connection."):new fe(r.message||"An unexpected error occurred",0,r.toString())}static isMetaKYCError(r){return r instanceof fe}}class kt{constructor(r){X(this,"axiosInstance");X(this,"endpointBuilder");X(this,"config");this.config={...bt,...r},this.endpointBuilder=new vt(this.config.endpoints),this.axiosInstance=wr.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 i;const a=s.config;return((i=s.response)==null?void 0:i.status)>=500&&!a._retry&&(a._retry=!0,a._retryCount=(a._retryCount||0)+1,a._retryCount<(this.config.retries||3))?(await new Promise(o=>setTimeout(o,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 i=this.buildEndpoint(r,s),o=await this.axiosInstance.get(i,{params:a});return this.handleResponse(o)}catch(i){throw Fe.handleAxiosError(i)}}async post(r,s,a){try{const i=this.buildEndpoint(r,s),o=await this.axiosInstance.post(i,a);return this.handleResponse(o)}catch(i){throw Fe.handleAxiosError(i)}}async put(r,s,a){try{const i=this.buildEndpoint(r,s),o=await this.axiosInstance.put(i,a);return this.handleResponse(o)}catch(i){throw Fe.handleAxiosError(i)}}async delete(r,s,a){try{const i=this.buildEndpoint(r,s),o=await this.axiosInstance.delete(i,{params:a});return this.handleResponse(o)}catch(i){throw Fe.handleAxiosError(i)}}handleResponse(r){const s=r.data;if(!s.success&&s.error)throw Fe.handleApiError(s.error);return s}getAxiosInstance(){return this.axiosInstance}}class wt{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 jt{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 St{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 Nt{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 Ct{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 Rt{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 At{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 Et{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 It{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 ce={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"}}},Pt={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"}},Tt={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"}},Ft={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"}}},Lt={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"}},Dt={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"}},Mt={[ae.Default]:ce,[ae.Corporate]:Pt,[ae.Fintech]:Tt,[ae.Healthcare]:Ft,[ae.Modern]:Lt,[ae.Minimal]:Dt};function Le(t){return Mt[t]||ce}class Ot{constructor(r){this.httpClient=r}async getThemeConfiguration(){var r;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return Le(ae.Default);let a=s.result.preset?Le(s.result.preset):Le(ae.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 i=typeof s.result.applicantFormPages=="string"?JSON.parse(s.result.applicantFormPages):s.result.applicantFormPages;Array.isArray(i)&&i.length>0&&(a.applicantFormPages=i.map(o=>{const c=!o._v||o._v<4;return{...o,fields:(o.fields||[]).map(u=>({...u,colSpan:c?u.colSpan===1?2:4:Math.min(4,Math.max(1,u.colSpan??4))}))}}))}catch{}if(s.result.reviewPageFields)try{const i=typeof s.result.reviewPageFields=="string"?JSON.parse(s.result.reviewPageFields):s.result.reviewPageFields;Array.isArray(i)&&i.length>0&&(a.reviewPageFields=i)}catch{}return s.result.reviewPageDisabled&&(a.reviewPageDisabled=!0),a}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),Le(ae.Default)}}async saveThemeConfiguration(r){await this.httpClient.post("Tenant","SaveThemeConfiguration",r)}getAvailablePresets(){return[{id:ae.Default,name:"Default"},{id:ae.Corporate,name:"Corporate"},{id:ae.Fintech,name:"Fintech"},{id:ae.Healthcare,name:"Healthcare"},{id:ae.Modern,name:"Modern"},{id:ae.Minimal,name:"Minimal"}]}getPreviewTheme(r,s){const a=Le(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 zt{constructor(){X(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(i=>{try{i(s)}catch(o){console.error(`Error in event listener for "${r}":`,o)}})}clear(){this.listeners.clear()}clearEvent(r){this.listeners.delete(r)}}class Bt{constructor(){X(this,"events",new zt);X(this,"_applicantId",null);X(this,"_progress",null);X(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)||xe.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===xe.Finished}get isOnHold(){return this.status===xe.OnHold}get isInProgress(){return this.status===xe.InProgress}setApplicantId(r){this._applicantId=r}updateProgress(r){var a,i;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)!==((i=r.currentStep)==null?void 0:i.order)&&this.events.emit("stepChanged",r.currentStep),this.events.emit("statusChanged",r.status),r.status===xe.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 $t{constructor(){X(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: ${G[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: ${G[r]}`);return a.submitData(s)}}class _t{constructor(r,s,a,i,o,c,u,h){X(this,"state");X(this,"stepRouter");this.applicantService=r,this.questionnaireService=s,this.uploadDocumentService=a,this.appropriatenessTestService=i,this.overviewService=o,this.riskScoringService=c,this.investorCategorizationService=h,this.state=new Bt,this.stepRouter=new $t,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(G.Questionaries,{loadData:r=>this.questionnaireService.getQuestionnaire(r),submitData:async r=>{await this.questionnaireService.fillQuestionnaire(r)}}),this.stepRouter.registerHandler(G.UploadDocument,{loadData:r=>this.uploadDocumentService.getUploadDocument(r),submitData:r=>this.uploadDocumentService.fillUploadDocument(r)}),this.stepRouter.registerHandler(G.AppropriatenessTest,{loadData:r=>this.appropriatenessTestService.getAppropriatenessTest(r),submitData:async r=>{await this.appropriatenessTestService.fillAppropriatenessTest(r)}}),this.stepRouter.registerHandler(G.Overview,{loadData:r=>this.overviewService.getOverviewData(r),submitData:r=>this.overviewService.passOverview(r.applicantId)}),this.stepRouter.registerHandler(G.RiskScoring,{loadData:r=>this.riskScoringService.getRiskCriterias(r),submitData:async r=>{await this.riskScoringService.submitRiskScoring(r)}}),this.stepRouter.registerHandler(G.IdentitySdk,{loadData:async r=>({applicantId:r,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(G.InvestorCategorization,{loadData:r=>this.investorCategorizationService.getInvestorCategorization(r),submitData:async r=>{await this.investorCategorizationService.setInvestorCategorization(r)}}),this.stepRouter.registerHandler(G.ManualReview,{loadData:async r=>({applicantId:r,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(G.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 et(t,r){return new Promise((s,a)=>{if(r&&document.getElementById(r)){s();return}const i=document.createElement("script");i.src=t,r&&(i.id=r),i.async=!0,i.onload=()=>s(),i.onerror=()=>a(new Error(`Failed to load script: ${t}`)),document.head.appendChild(i)})}function Sr(t){return!!document.getElementById(t)}function Nr(t){const r=document.getElementById(t);r&&r.remove()}class Ht{constructor(r){X(this,"sdk",null);X(this,"config");this.config=r}async loadSDK(){await et("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 Ut{constructor(r){X(this,"sdk",null);X(this,"config");this.config=r}async loadSDK(){await et("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 Kt{constructor(r){X(this,"sardineContext",null);X(this,"config");X(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(),i=document.createElement("script");i.type="text/javascript",i.async=!0,i.src=`https://${a}/assets/loader.min.js`,i.onload=()=>{console.log("[SardinAI] SDK loaded successfully"),r()},i.onerror=()=>{s(new Error("Failed to load SardinAI SDK"))};const o=document.getElementsByTagName("script")[0];o&&o.parentNode?o.parentNode.insertBefore(i,o):document.head.appendChild(i)})}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:i,enableBiometrics:o,enablePortScanning:c}=this.config;this.sardineContext=window._Sardine.createContext({clientId:s,sessionKey:this.sessionKey,userIdHash:void 0,flow:i||window.location.pathname,environment:a||"production",parentElement:document.body,enableBiometrics:o!==!1,enablePortScanning:c===!0,region:this.config.region,onDeviceResponse:u=>{console.log(`[SardinAI] Device ID: ${u.deviceId}`)},onConfigUpdate:(u,h,p)=>{switch(u){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",p);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:i,flow:o}=this.config;a.src=`https://${r}/v1/a.png?clientId=${i}&sessionKey=${this.sessionKey}&flow=${o||"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,i)=>{switch(s){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Config update failed:",i);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 Pe{static createProvider(r,s){switch(r){case he.Sumsub:return new Ht(s);case he.Onfido:return new Ut(s);case he.SardinAI:return new Kt(s);default:throw new Error(`Unsupported identity provider: ${r}`)}}static parseProviderConfig(r,s,a){var i;switch(r){case he.Sumsub:return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:s.lang||"en"};case he.Onfido:return{token:s.token||s.sdkToken};case he.SardinAI:const o=((i=a==null?void 0:a.identityProviders)==null?void 0:i.sardinai)||{};return{clientId:o.clientId||s.clientId,sessionKey:o.sessionKey||s.sessionKey,environment:o.environment||s.environment||"production",flow:o.flow||s.flow,region:o.region,enableBiometrics:o.enableBiometrics,enablePortScanning:o.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${r}`)}}}class Wt{constructor(r){X(this,"currentTheme",ce);X(this,"customStyleElement",null);X(this,"container");this.container=r||document.documentElement}applyTheme(r){this.currentTheme=this.mergeWithDefault(r),this.applyColors(this.currentTheme.colors),this.currentTheme.typography&&this.applyTypography(this.currentTheme.typography),this.currentTheme.spacing&&this.applySpacing(this.currentTheme.spacing),this.currentTheme.customCSS&&this.injectCustomCSS(this.currentTheme.customCSS),console.log("[ThemeManager] Theme applied:",this.currentTheme.name||"Custom")}applyColors(r){var a;const s={primary:r.primary,"primary-hover":r.primaryHover,"primary-light":r.primaryLight,"primary-dark":r.primaryDark,secondary:r.secondary,"secondary-hover":r.secondaryHover,success:r.success,warning:r.warning,danger:r.danger,info:r.info,background:r.background,surface:r.surface,border:r.border,"text-primary":r.textPrimary,"text-secondary":r.textSecondary,"text-muted":r.textMuted,"input-bg":r.inputBg||r.background,"input-text":r.inputText||r.textPrimary,"input-border":r.inputBorder||r.border,"input-border-focus":r.inputBorderFocus||r.primary,"input-placeholder":r.inputPlaceholder||r.textMuted};Object.entries(s).forEach(([i,o])=>{this.container.style.setProperty(`--metakyc-${i}`,o)}),(a=this.currentTheme.darkMode)!=null&&a.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(r){Object.entries(r).forEach(([s,a])=>{if(a){const i=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(i,a)}})}applyTypography(r){r&&(r.fontFamily&&this.container.style.setProperty("--metakyc-font-family",r.fontFamily),r.headingFont&&this.container.style.setProperty("--metakyc-heading-font",r.headingFont),r.fontSize&&Object.entries(r.fontSize).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-size-${s}`,a)}),r.fontWeight&&Object.entries(r.fontWeight).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-weight-${s}`,a.toString())}))}applySpacing(r){r&&Object.entries(r).forEach(([s,a])=>{const i=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(i,a)})}injectCustomCSS(r){this.customStyleElement&&this.customStyleElement.remove(),this.customStyleElement=document.createElement("style"),this.customStyleElement.id="metakyc-custom-css",this.customStyleElement.textContent=r,document.head.appendChild(this.customStyleElement)}mergeWithDefault(r){var s;return{name:r.name||ce.name,title:r.title||ce.title,logo:{...ce.logo,...r.logo},colors:{...ce.colors,...r.colors},typography:r.typography?{...ce.typography,...r.typography}:ce.typography,spacing:r.spacing?{...ce.spacing,...r.spacing}:ce.spacing,customCSS:r.customCSS,darkMode:r.darkMode?{colors:{...(s=ce.darkMode)==null?void 0:s.colors,...r.darkMode.colors}}:ce.darkMode,applicantFormVisibleFields:r.applicantFormVisibleFields,applicantFormRequiredFields:r.applicantFormRequiredFields,allowedLanguages:r.allowedLanguages,applicantFormPages:r.applicantFormPages,reviewPageFields:r.reviewPageFields,reviewPageDisabled:r.reviewPageDisabled}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(ce)}cleanup(){this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(r){return r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const tt=l.createContext(null),Cr=({config:t,children:r})=>{const[s,a]=l.useState(null),i=l.useRef(!1),o=l.useRef(!1),c=l.useMemo(()=>{const h=new kt(t),p=new wt(h),v=new jt(h),S=new St(h),y=new Nt(h),j=new Ct(h),f=new Rt(h),F=new At(h),I=new Et(h),E=new It(h),M=new Ot(h),A=new Wt;return{httpClient:h,applicantService:p,questionnaireService:v,uploadDocumentService:S,appropriatenessTestService:y,overviewService:j,riskScoringService:f,identityService:F,baseInformationService:I,investorCategorizationService:E,themeService:M,themeManager:A}},[t]),u=l.useMemo(()=>({config:t,...c,currentTheme:s,createOrchestrator:()=>new _t(c.applicantService,c.questionnaireService,c.uploadDocumentService,c.appropriatenessTestService,c.overviewService,c.riskScoringService,c.identityService,c.investorCategorizationService)}),[t,c,s]);return l.useEffect(()=>((async()=>{if(i.current||o.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}i.current=!0;try{if(t.theme){console.log("[MetaKYC] Applying static theme from config"),c.themeManager.applyTheme(t.theme),a(c.themeManager.getCurrentTheme()),o.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const p=await c.themeService.getThemeConfiguration();c.themeManager.applyTheme(p),a(c.themeManager.getCurrentTheme()),o.current=!0,console.log("[MetaKYC] Theme loaded and applied",p)}catch(p){console.warn("[MetaKYC] Failed to load theme, using default:",p),a(c.themeManager.getCurrentTheme()),o.current=!0}finally{i.current=!1}})(),()=>{c.themeManager.cleanup()}),[]),e.jsx(tt.Provider,{value:u,children:r})};function de(){const t=l.useContext(tt);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function Yt(t){return new Promise((r,s)=>{const a=new FileReader;a.readAsDataURL(t),a.onload=()=>{const o=a.result.split(",")[1];r(o)},a.onerror=i=>s(i)})}function Rr(t,r){return t.size<=r}function Ar(t,r){return r.split(",").map(a=>a.trim()).some(a=>{if(a.endsWith("/*")){const i=a.slice(0,-2);return t.type.startsWith(i)}return t.type===a})}function We(t){if(t===0)return"0 Bytes";const r=1024,s=["Bytes","KB","MB","GB"],a=Math.floor(Math.log(t)/Math.log(r));return Math.round(t/Math.pow(r,a)*100)/100+" "+s[a]}function Er(t){return t}function re(...t){return t.filter(Boolean).join(" ")}const De={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function qt(t){try{localStorage.setItem(De.APPLICANT_ID,t.toString())}catch(r){console.warn("Failed to save applicant ID to storage:",r)}}function Qt(){try{const t=localStorage.getItem(De.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function Gt(){try{localStorage.removeItem(De.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function Vt(t){try{localStorage.setItem(De.WORKFLOW_STATE,JSON.stringify(t))}catch(r){console.warn("Failed to save workflow state to storage:",r)}}function Ir(){try{const t=localStorage.getItem(De.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function Jt(){try{localStorage.removeItem(De.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function Pr(){Gt(),Jt()}function Zt(t){const{createOrchestrator:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(null),h=l.useRef(null),p=t||Qt();l.useEffect(()=>{h.current||(h.current=r())},[r]),l.useEffect(()=>{var A;s&&p&&(qt(p),Vt({applicantId:p,currentStepOrder:(A=s.currentStep)==null?void 0:A.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,p]);const v=l.useRef(!1),S=l.useRef(!1),y=l.useCallback(async()=>{if(!(!p||!h.current)){if(v.current){console.log("[Workflow] Load already in progress, skipping...");return}v.current=!0,o(!0),u(null);try{const A=await h.current.initialize(p);a(A),S.current=!0}catch(A){u(A)}finally{o(!1),v.current=!1}}},[p]);l.useEffect(()=>{p&&!S.current&&y()},[p,y]);const j=l.useCallback(async()=>{if(h.current){if(v.current){console.log("[Workflow] Refresh already in progress, skipping...");return}v.current=!0,o(!0),u(null);try{const A=await h.current.refreshProgress();a(A)}catch(A){u(A)}finally{o(!1),v.current=!1}}},[]),f=l.useCallback(async()=>{if(h.current){o(!0),u(null);try{const A=await h.current.moveToNextStep();a(A)}catch(A){u(A)}finally{o(!1)}}},[]),F=l.useCallback(async()=>{if(h.current){o(!0),u(null);try{const A=await h.current.moveToPreviousStep();a(A)}catch(A){u(A)}finally{o(!1)}}},[]),I=l.useCallback(async A=>{if(h.current){o(!0),u(null);try{await h.current.submitCurrentStep(A);const P=await h.current.refreshProgress();a(P)}catch(P){throw u(P),P}finally{o(!1)}}},[]),E=rt.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((A,P)=>A.order-P.order):[],[s==null?void 0:s.stepInfoList]),M=rt.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:p,currentStep:(s==null?void 0:s.currentStep)||null,steps:E,status:(s==null?void 0:s.status)||xe.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:M,isLoading:i,error:c,isComplete:(s==null?void 0:s.status)===xe.Finished,isOnHold:(s==null?void 0:s.status)===xe.OnHold,refreshProgress:j,moveToNext:f,moveBack:F,submitCurrentStep:I,orchestrator:h.current}}function Xt(t){const{questionnaireService:r,applicantService:s}=de(),[a,i]=l.useState(null),[o,c]=l.useState({}),[u,h]=l.useState(!1),[p,v]=l.useState(!1),[S,y]=l.useState(null),j=l.useRef(!1),f=l.useRef(null),F=l.useCallback(async()=>{var E,M;if(t){if(j.current){console.log("[Questionnaire] Load already in progress, skipping...");return}j.current=!0,h(!0),y(null);try{const[A,P]=await Promise.all([r.getQuestionnaire(t),s.getApplicantData(t).catch(()=>null)]);if(i(A),(E=P==null?void 0:P.questionnaireResults)!=null&&E.length&&A){const Y=new Map;for(const w of P.questionnaireResults)w.question&&((M=w.answers)!=null&&M.length)&&Y.set(w.question.trim().toLowerCase(),w.answers);const J={},R=A.questionGroups.flatMap(w=>w.questions??[]);for(const w of R){const $=w.text.trim().toLowerCase();Y.has($)&&(J[w.id]=Y.get($))}c(J)}f.current=t}catch(A){y(A)}finally{h(!1),j.current=!1}}},[t,r,s]);l.useEffect(()=>{t&&f.current!==t&&F()},[t]);const I=l.useCallback(async E=>{v(!0),y(null);try{return await r.fillQuestionnaire(E)}catch(M){throw y(M),M}finally{v(!1)}},[r]);return{questionnaire:a,initialAnswers:o,isLoading:u,isSubmitting:p,error:S,load:F,submit:I}}function er(t){const{uploadDocumentService:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(!1),[h,p]=l.useState(0),[v,S]=l.useState(null),y=l.useRef(!1),j=l.useRef(null),f=l.useCallback(async()=>{if(t){if(y.current){console.log("[UploadDocument] Load already in progress, skipping...");return}y.current=!0,o(!0),S(null);try{const I=await r.getUploadDocument(t);a(I),j.current=t}catch(I){S(I)}finally{o(!1),y.current=!1}}},[t,r]);l.useEffect(()=>{t&&j.current!==t&&f()},[t]);const F=l.useCallback(async I=>{u(!0),p(0),S(null);try{await r.fillUploadDocument(I),p(100)}catch(E){throw S(E),E}finally{u(!1)}},[r]);return{uploadDocument:s,isLoading:i,isSubmitting:c,uploadProgress:h,error:v,load:f,submit:F}}function Tr(t){const{appropriatenessTestService:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(!1),[h,p]=l.useState(null),[v,S]=l.useState(null),y=l.useRef(!1),j=l.useRef(null),f=l.useCallback(async()=>{if(t){if(y.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}y.current=!0,o(!0),p(null);try{const I=await r.getAppropriatenessTest(t);a(I),j.current=t}catch(I){p(I)}finally{o(!1),y.current=!1}}},[t,r]);l.useEffect(()=>{t&&j.current!==t&&f()},[t]);const F=l.useCallback(async I=>{u(!0),p(null);try{const E=await r.fillAppropriatenessTest(I);return S(E),E}catch(E){throw p(E),E}finally{u(!1)}},[r]);return{test:s,result:v,isLoading:i,isSubmitting:c,error:h,load:f,submit:F}}function tr(t){const{overviewService:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(!1),[h,p]=l.useState(null),v=l.useRef(!1),S=l.useRef(null),y=l.useCallback(async()=>{if(t){if(v.current){console.log("[Overview] Load already in progress, skipping...");return}v.current=!0,o(!0),p(null);try{const f=await r.getOverviewData(t);a(f),S.current=t}catch(f){p(f)}finally{o(!1),v.current=!1}}},[t,r]);l.useEffect(()=>{t&&S.current!==t&&y()},[t]);const j=l.useCallback(async()=>{if(t){u(!0),p(null);try{await r.passOverview(t)}catch(f){throw p(f),f}finally{u(!1)}}},[t,r]);return{overview:s,isLoading:i,isSubmitting:c,error:h,load:y,passOverview:j}}function rr(t){const{identityService:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(null),h=l.useRef(!1),p=l.useCallback(async(y,j)=>{if(t){if(h.current){console.log("[Identity] Request already in progress, skipping...");return}h.current=!0,o(!0),u(null);try{const f={applicantId:t,restart:!1,redirectUrl:y||"",ttl:j||604800};console.log("Identity request input:",f);const F=await r.identityRequest(f);return console.log("Identity request result:",F),a(F),F}catch(f){throw u(f),f}finally{o(!1),h.current=!1}}},[t,r]),v=l.useCallback(async(y,j)=>{if(t){o(!0),u(null);try{const f={applicantId:t,restart:!1,redirectUrl:y,ttl:j},F=await r.identityCompanyRequest(f);return a(F),F}catch(f){throw u(f),f}finally{o(!1)}}},[t,r]),S=l.useCallback(async()=>{if(t){if(h.current){console.log("[Identity] Restart already in progress, skipping...");return}h.current=!0,o(!0),u(null);try{const y={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",y);const j=await r.identityRequest(y);return console.log("Restart identity result:",j),a(j),j}catch(y){throw u(y),y}finally{o(!1),h.current=!1}}},[t,r]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:i,error:c,requestIdentity:p,requestCompanyIdentity:v,restartIdentity:S}}function sr(t){const{riskScoringService:r,applicantService:s}=de(),[a,i]=l.useState(null),[o,c]=l.useState({}),[u,h]=l.useState(!1),[p,v]=l.useState(!1),[S,y]=l.useState(null),[j,f]=l.useState(null),F=l.useRef(!1),I=l.useRef(null),E=l.useCallback(async()=>{var A;if(t){if(F.current){console.log("[RiskScoring] Load already in progress, skipping...");return}F.current=!0,h(!0),y(null);try{const[P,Y]=await Promise.all([r.getRiskCriterias(t),s.getApplicantData(t).catch(()=>null)]);if(i(P),(A=Y==null?void 0:Y.riskScoringResults)!=null&&A.length){const J=Y.riskScoringResults[0],R={};for(const w of J.riskCriteriaResults??[])if(w.riskCriteriaId!=null&&w.answer!=null&&w.answer!==""){const $=[...new Set(w.answer.split(",").map(K=>K.trim()).filter(K=>K!==""))];$.length>0&&(R[w.riskCriteriaId]=$)}c(R)}I.current=t}catch(P){y(P)}finally{h(!1),F.current=!1}}},[t,r,s]);l.useEffect(()=>{t&&I.current!==t&&E()},[t]);const M=l.useCallback(async A=>{v(!0),y(null);try{const P=await r.submitRiskScoring(A);return f(P),P}catch(P){throw y(P),P}finally{v(!1)}},[r]);return{criteria:a,initialAnswers:o,result:j,isLoading:u,isSubmitting:p,error:S,load:E,submit:M}}function ar(){const{applicantService:t,config:r}=de(),[s,a]=l.useState(!1),[i,o]=l.useState(null),c=l.useRef(!1),u=l.useRef(!1),h=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(j){const f=Math.random()*16|0;return(j==="x"?f:f&3|8).toString(16)}),p=l.useCallback(async j=>{var f;if(c.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");c.current=!0,a(!0),o(null);try{if(j.applicantAdditionalDatas||(j.applicantAdditionalDatas=[]),(f=r.identityProviders)!=null&&f.sardinai){const I=h();console.log("[SardinAI] Generated session key:",I),j.applicantAdditionalDatas.push({paramName:"sessionKey",value:I})}return await t.createApplicant(j)}catch(F){throw o(F),F}finally{a(!1),c.current=!1}},[t,r]),v=l.useCallback(async j=>{a(!0),o(null);try{return await t.createCompanyApplicant(j)}catch(f){throw o(f),f}finally{a(!1)}},[t]),S=l.useCallback(async j=>{if(u.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");u.current=!0,a(!0),o(null);try{return await t.getApplicantData(j)}catch(f){throw o(f),f}finally{a(!1),u.current=!1}},[t]),y=l.useCallback(async j=>{a(!0),o(null);try{await t.stopProgress(j)}catch(f){throw o(f),f}finally{a(!1)}},[t]);return{isLoading:s,error:i,createApplicant:p,createCompanyApplicant:v,getApplicantData:S,stopProgress:y}}const W=({children:t,variant:r="primary",size:s="md",isLoading:a=!1,disabled:i,className:o,...c})=>{const u="inline-flex items-center justify-center rounded-lg font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",h={primary:"bg-primary-500 text-white hover:bg-primary-600 focus:ring-primary-500",secondary:"bg-gray-200 text-gray-900 hover:bg-gray-300 focus:ring-gray-400",outline:"border-2 border-primary-500 text-primary-500 hover:bg-primary-50 focus:ring-primary-500",danger:"bg-danger-500 text-white hover:bg-danger-600 focus:ring-danger-500",ghost:"text-gray-700 hover:bg-gray-100 focus:ring-gray-400"},p={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-base",lg:"px-6 py-3 text-lg"};return e.jsxs("button",{className:re(u,h[r],p[s],o),disabled:i||a,...c,children:[a&&e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t]})},ne=l.forwardRef(({label:t,error:r,helperText:s,leftIcon:a,rightIcon:i,className:o,style:c,...u},h)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,u.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"relative",children:[a&&e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:a}),e.jsx("input",{ref:h,className:re("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-offset-0","disabled:opacity-60 disabled:cursor-not-allowed",a?"pl-10":"",i?"pr-10":"",o),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",...c},...u}),i&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:i})]}),r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-danger, #ef4444)"},children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s})]}));ne.displayName="Input";const _=({children:t,className:r,...s})=>e.jsx("div",{className:re("metakyc-card rounded-xl shadow-sm border",r),style:{backgroundColor:"var(--metakyc-surface, #ffffff)",borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),ie=({children:t,className:r,...s})=>e.jsx("div",{className:re("px-6 py-4 border-b",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),H=({children:t,className:r,...s})=>e.jsx("div",{className:re("px-6 py-4",r),...s,children:t}),le=({children:t,className:r,...s})=>e.jsx("div",{className:re("px-6 py-4 border-t",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),ve=({children:t,variant:r="default",className:s,...a})=>{const i={default:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",success:"bg-success-100 text-success-800 dark:bg-success-900 dark:text-success-300",danger:"bg-danger-100 text-danger-800 dark:bg-danger-900 dark:text-danger-300",warning:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300",info:"bg-primary-100 text-primary-800 dark:bg-primary-900 dark:text-primary-300"};return e.jsx("span",{className:re("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",i[r],s),...a,children:t})},ge=({size:t="md",className:r,...s})=>{const a={sm:"h-4 w-4",md:"h-8 w-8",lg:"h-12 w-12"};return e.jsx("div",{className:re("flex items-center justify-center",r),...s,children:e.jsxs("svg",{className:re("animate-spin text-primary-500",a[t]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})},Qe=l.forwardRef(({label:t,error:r,helperText:s,options:a,placeholder:i,className:o,style:c,...u},h)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,u.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("select",{ref:h,className:re("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-offset-0","disabled:opacity-60 disabled:cursor-not-allowed",r?"border-danger-500":"",o),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",...c},...u,children:[i&&e.jsx("option",{value:"",disabled:!0,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-secondary, #6b7280)"},children:i},"__placeholder__"),a.map((p,v)=>e.jsx("option",{value:p.value,disabled:p.disabled,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:p.disabled?"var(--metakyc-text-muted, #9ca3af)":"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))"},children:p.label},p.value||`option-${v}`))]}),r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-error, #ef4444)"},children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s})]}));Qe.displayName="Select";const st=280,nr=({label:t,value:r,onChange:s,options:a,placeholder:i="Select...",disabled:o=!1,required:c=!1})=>{const[u,h]=l.useState(!1),[p,v]=l.useState(""),[S,y]=l.useState(null),j=l.useRef(null),f=l.useRef(null),F=l.useRef(null),I=l.useCallback(()=>{if(!f.current)return null;const C=f.current.getBoundingClientRect(),Z=window.innerHeight-C.bottom<st&&C.top>st;return{top:Z?C.top:C.bottom+4,left:C.left,width:C.width,openUp:Z}},[]),E=l.useCallback(()=>{if(o)return;const C=I();C&&y(C),h(!0)},[o,I]),M=l.useCallback(()=>{h(!1),v("")},[]);l.useEffect(()=>{if(!u)return;const C=U=>{var me,se;const Z=U.target;!((me=j.current)!=null&&me.contains(Z))&&!((se=F.current)!=null&&se.contains(Z))&&M()};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[u,M]),l.useEffect(()=>{if(!u)return;const C=()=>{const U=I();U&&y(U)};return window.addEventListener("scroll",C,!0),window.addEventListener("resize",C),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C)}},[u,I]);const A=a.filter(C=>C.label.toLowerCase().includes(p.toLowerCase())),P=C=>{o||s(r.includes(C)?r.filter(U=>U!==C):[...r,C])},Y=(C,U)=>{U.stopPropagation(),o||s(r.filter(Z=>Z!==C))},J=C=>{var U;return((U=a.find(Z=>Z.value===C))==null?void 0:U.label)||C},R=f.current?getComputedStyle(f.current):null,w=(R==null?void 0:R.getPropertyValue("--metakyc-input-bg").trim())||"#ffffff",$=(R==null?void 0:R.getPropertyValue("--metakyc-input-border").trim())||(R==null?void 0:R.getPropertyValue("--metakyc-border").trim())||"#d1d5db",K=(R==null?void 0:R.getPropertyValue("--metakyc-input-text").trim())||(R==null?void 0:R.getPropertyValue("--metakyc-text-primary").trim())||"#111827",k=(R==null?void 0:R.getPropertyValue("--metakyc-text-secondary").trim())||"#6b7280",z=(R==null?void 0:R.getPropertyValue("--metakyc-primary").trim())||"#2563eb",T=(R==null?void 0:R.getPropertyValue("--metakyc-primary-light").trim())||"#eff6ff",D=(R==null?void 0:R.getPropertyValue("--metakyc-hover-bg").trim())||"#f9fafb",Q=u&&S&&e.jsxs("div",{ref:F,className:"metakyc-multiselect-dropdown",style:{position:"fixed",top:S.openUp?void 0:S.top,bottom:S.openUp?window.innerHeight-S.top+4:void 0,left:S.left,width:S.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${$}`,backgroundColor:w,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${$}`},children:e.jsx("input",{type:"text",value:p,onChange:C=>v(C.target.value),placeholder:"Search...",autoFocus:!0,onClick:C=>C.stopPropagation(),className:"metakyc-multiselect-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${$}`,backgroundColor:w,color:K,outline:"none",boxSizing:"border-box"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"192px",overflowY:"auto"},children:A.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:k},children:"No results"}):A.map(C=>{const U=r.includes(C.value);return e.jsxs("li",{onClick:()=>P(C.value),className:"metakyc-multiselect-option",style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",fontSize:"13px",cursor:"pointer",backgroundColor:U?T:"transparent",color:U?z:K,userSelect:"none"},onMouseEnter:Z=>{U||(Z.currentTarget.style.backgroundColor=D)},onMouseLeave:Z=>{U||(Z.currentTarget.style.backgroundColor="transparent")},children:[e.jsx("input",{type:"checkbox",checked:U,readOnly:!0,style:{accentColor:z,pointerEvents:"none",flexShrink:0}}),e.jsx("span",{children:C.label})]},C.value)})}),r.length>0&&e.jsx("div",{style:{padding:"6px 12px",borderTop:`1px solid ${$}`},children:e.jsxs("button",{type:"button",onClick:()=>{s([]),v("")},style:{fontSize:"12px",color:"#ef4444",background:"none",border:"none",cursor:"pointer",padding:0},children:["Clear all (",r.length," selected)"]})})]});return e.jsxs("div",{className:"w-full metakyc-multiselect",ref:j,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,c&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:f,onClick:()=>u?M():E(),className:re("metakyc-multiselect-trigger","min-h-[42px] w-full px-3 py-2 rounded-lg border text-sm transition-colors relative",o?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",borderColor:u?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",outline:u?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[r.length===0?e.jsx("span",{className:"metakyc-multiselect-placeholder leading-6",style:{color:"var(--metakyc-text-secondary, #9ca3af)"},children:i}):e.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:r.map(C=>e.jsxs("span",{className:"metakyc-multiselect-chip inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium",style:{backgroundColor:"var(--metakyc-primary-light, #eff6ff)",color:"var(--metakyc-primary, #2563eb)"},children:[J(C),!o&&e.jsx("button",{type:"button",onClick:U=>Y(C,U),className:"metakyc-multiselect-chip-remove",style:{background:"transparent",border:"none",padding:"0 0 0 2px",margin:0,cursor:"pointer",fontSize:"14px",lineHeight:1,fontWeight:"bold",display:"inline-flex",alignItems:"center",boxShadow:"none",transform:"none",minWidth:0,width:"auto",height:"auto",letterSpacing:"normal",textTransform:"none"},children:"×"})]},C))}),e.jsx("span",{className:"metakyc-multiselect-arrow absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:u?"▲":"▼"})]}),typeof document<"u"&&Q?qe.createPortal(Q,document.body):null]})},at=260,ke=({label:t,error:r,helperText:s,options:a,placeholder:i="Select...",value:o,onChange:c,disabled:u=!1,required:h=!1,className:p})=>{var se;const[v,S]=l.useState(!1),[y,j]=l.useState(""),[f,F]=l.useState(null),I=l.useRef(null),E=l.useRef(null),M=l.useRef(null),A=l.useRef(null),P=l.useCallback(()=>{if(!E.current)return null;const L=E.current.getBoundingClientRect(),te=window.innerHeight-L.bottom<at&&L.top>at;return{top:te?L.top:L.bottom+4,left:L.left,width:L.width,openUp:te}},[]),Y=l.useCallback(()=>{if(u)return;const L=P();L&&F(L),S(!0)},[u,P]),J=l.useCallback(()=>{S(!1),j("")},[]),R=()=>v?J():Y();l.useEffect(()=>{if(!v)return;const L=V=>{var je,Ae;const te=V.target;!((je=I.current)!=null&&je.contains(te))&&!((Ae=M.current)!=null&&Ae.contains(te))&&J()};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[v,J]),l.useEffect(()=>{if(!v)return;const L=()=>{const V=P();V&&F(V)};return window.addEventListener("scroll",L,!0),window.addEventListener("resize",L),()=>{window.removeEventListener("scroll",L,!0),window.removeEventListener("resize",L)}},[v,P]),l.useEffect(()=>{v&&A.current&&setTimeout(()=>{var L;return(L=A.current)==null?void 0:L.focus()},0)},[v]);const w=a.filter(L=>L.label.toLowerCase().includes(y.toLowerCase())||L.value.toLowerCase().includes(y.toLowerCase())),$=(se=a.find(L=>L.value===o))==null?void 0:se.label,K=(L,V)=>{u||V||(c(L),J())},k=E.current?getComputedStyle(E.current):null,z=(k==null?void 0:k.getPropertyValue("--metakyc-input-bg").trim())||"#ffffff",T=(k==null?void 0:k.getPropertyValue("--metakyc-input-border").trim())||(k==null?void 0:k.getPropertyValue("--metakyc-border").trim())||"#d1d5db",D=(k==null?void 0:k.getPropertyValue("--metakyc-input-text").trim())||(k==null?void 0:k.getPropertyValue("--metakyc-text-primary").trim())||"#111827",Q=(k==null?void 0:k.getPropertyValue("--metakyc-text-secondary").trim())||"#6b7280",C=(k==null?void 0:k.getPropertyValue("--metakyc-primary").trim())||"#2563eb",U=(k==null?void 0:k.getPropertyValue("--metakyc-primary-light").trim())||"#eff6ff",Z=(k==null?void 0:k.getPropertyValue("--metakyc-hover-bg").trim())||"#f9fafb",me=v&&f&&e.jsxs("div",{ref:M,className:"metakyc-searchable-select-dropdown",style:{position:"fixed",top:f.openUp?void 0:f.top,bottom:f.openUp?window.innerHeight-f.top+4:void 0,left:f.left,width:f.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${T}`,backgroundColor:z,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${T}`},children:e.jsx("input",{ref:A,type:"text",value:y,onChange:L=>j(L.target.value),placeholder:"Search...",onClick:L=>L.stopPropagation(),className:"metakyc-searchable-select-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${T}`,backgroundColor:z,color:D,outline:"none",boxSizing:"border-box"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"208px",overflowY:"auto"},children:w.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:Q},children:"No results"}):w.map(L=>{const V=L.value===o;return e.jsx("li",{className:"metakyc-searchable-select-option",onClick:()=>K(L.value,L.disabled),style:{padding:"8px 12px",fontSize:"13px",cursor:L.disabled?"not-allowed":"pointer",opacity:L.disabled?.4:1,backgroundColor:V?U:"transparent",color:V?C:D,userSelect:"none"},onMouseEnter:te=>{!V&&!L.disabled&&(te.currentTarget.style.backgroundColor=Z)},onMouseLeave:te=>{V||(te.currentTarget.style.backgroundColor="transparent")},children:L.label},L.value)})})]});return e.jsxs("div",{className:re("w-full metakyc-searchable-select",p),ref:I,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,h&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:E,role:"button",tabIndex:u?-1:0,onClick:R,onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),R()),L.key==="Escape"&&J()},className:re("metakyc-searchable-select-trigger","w-full px-3 py-2 rounded-lg border text-sm transition-colors text-left","flex items-center justify-between gap-2","focus:outline-none",u?"opacity-60 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:$?"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))":"var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))",borderColor:r?"var(--metakyc-danger, #ef4444)":v?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",minHeight:"42px",outline:v?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[e.jsx("span",{className:"truncate flex-1",children:$||i}),e.jsx("span",{className:"flex-shrink-0 text-xs pointer-events-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:v?"▲":"▼"})]}),typeof document<"u"&&me?qe.createPortal(me,document.body):null,r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-error, #ef4444)"},children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s})]})};ke.displayName="SearchableSelect";const ir=({label:t,error:r,accept:s,multiple:a=!1,maxSize:i,onChange:o,value:c=[],className:u})=>{const[h,p]=l.useState(!1),v=l.useRef(null),S=E=>{if(!E)return;const M=Array.from(E);if(i&&M.filter(P=>P.size>i).length>0){const P=We(i);alert(`Some files exceed the maximum size of ${P}`);return}o==null||o(a?[...c,...M]:[M[0]])},y=E=>{E.preventDefault(),p(!0)},j=()=>{p(!1)},f=E=>{E.preventDefault(),p(!1),S(E.dataTransfer.files)},F=()=>{var E;(E=v.current)==null||E.click()},I=E=>{const M=c.filter((A,P)=>P!==E);o==null||o(M)};return e.jsxs("div",{className:re("w-full",u),children:[t&&e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t}),e.jsxs("div",{className:re("border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors",h?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-300 dark:border-gray-600 hover:border-primary-500",r&&"border-danger-500"),onDragOver:y,onDragLeave:j,onDrop:f,onClick:F,children:[e.jsx("input",{ref:v,type:"file",className:"hidden",accept:s,multiple:a,onChange:E=>S(E.target.files)}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",stroke:"currentColor",fill:"none",viewBox:"0 0 48 48",children:e.jsx("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("span",{className:"font-medium text-primary-500",children:"Click to upload"})," or drag and drop"]}),i&&e.jsxs("p",{className:"text-xs text-gray-500",children:["Maximum file size: ",We(i)]})]})]}),c.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:c.map((E,M)=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsxs("div",{className:"flex items-center space-x-2 flex-1 min-w-0",children:[e.jsx("svg",{className:"h-5 w-5 text-gray-400 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",children:E.name}),e.jsxs("span",{className:"text-xs text-gray-500",children:["(",We(E.size),")"]})]}),e.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),I(M)},className:"ml-2 text-danger-500 hover:text-danger-700 focus:outline-none",children:e.jsx("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]},M))}),r&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:r})]})},or=l.forwardRef(({countryCode:t="+1",onCountryCodeChange:r,className:s,...a},i)=>e.jsxs("div",{className:"w-full",children:[a.label&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[a.label,a.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:o=>r==null?void 0:r(o.target.value),className:re("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-offset-0"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-primary, #111827)",borderColor:"var(--metakyc-border, #d1d5db)"},placeholder:"+1"}),e.jsx(ne,{ref:i,type:"tel",className:re("flex-1",s),...a,label:""})]}),a.error&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:a.error})]}));or.displayName="PhoneInput";/**
1
+ "use strict";var vr=Object.defineProperty;var kr=(t,r,s)=>r in t?vr(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s;var X=(t,r,s)=>kr(t,typeof r!="symbol"?r+"":r,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const wr=require("axios"),l=require("react"),e=require("react/jsx-runtime"),qe=require("react-dom"),Se=require("react-hook-form"),we=require("zod");function jr(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 rt=jr(l);var G=(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))(G||{}),He=(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))(He||{}),xe=(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))(xe||{}),ot=(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))(ot||{}),lt=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(lt||{}),Ne=(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))(Ne||{}),Ce=(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))(Ce||{}),ct=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(ct||{}),dt=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(dt||{}),he=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(he||{}),ut=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(ut||{}),Ue=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(Ue||{}),pt=(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))(pt||{}),mt=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(mt||{}),ht=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))(ht||{}),be=(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))(be||{}),xt=(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))(xt||{}),yt=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))(yt||{}),pe=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(pe||{}),gt=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(gt||{});const Ie={Nationality:10,Address:20,CountryOfBirth:30,PhoneNumber:40,UboAddress:50},Ee={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:Ie.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:Ie.Address},nationality:{label:"Nationality",type:"select",countriesType:Ie.Nationality},otherNationality:{label:"Other Nationalities",type:"multiselect",countriesType:Ie.Nationality},countryOfBirth:{label:"Country of Birth",type:"select",countriesType:Ie.CountryOfBirth},placeOfBirth:{label:"Place of Birth",type:"text"},taxCountry:{label:"Tax Country",type:"select",countriesType:Ie.Address},taxNumber:{label:"Tax Number",type:"text"},defaultLanguage:{label:"Default Language",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"}},ft=["firstName","lastName","email","phonenumber","dateOfBirth"],Ze=[{value:"EN",label:"English"},{value:"DE",label:"German"},{value:"FR",label:"French"},{value:"ES",label:"Spanish"},{value:"IT",label:"Italian"},{value:"PT",label:"Portuguese"},{value:"NL",label:"Dutch"},{value:"PL",label:"Polish"},{value:"RU",label:"Russian"},{value:"ZH",label:"Chinese"},{value:"JA",label:"Japanese"},{value:"AR",label:"Arabic"},{value:"TR",label:"Turkish"},{value:"SV",label:"Swedish"},{value:"DA",label:"Danish"},{value:"FI",label:"Finnish"},{value:"NO",label:"Norwegian"}];var ae=(t=>(t.Default="default",t.Corporate="corporate",t.Fintech="fintech",t.Healthcare="healthcare",t.Modern="modern",t.Minimal="minimal",t))(ae||{});const bt={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class vt{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 fe extends Error{constructor(s,a,i,o,c){super(s);X(this,"response");this.code=a,this.details=i,this.validationErrors=o,this.name="MetaKYCError",this.response=c,Object.setPrototypeOf(this,fe.prototype)}}class Fe{static handleApiError(r){return new fe(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 fe(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 fe(s.result.message,r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response):new fe((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 fe("No response from server",0,"The request was made but no response was received. Please check your network connection."):new fe(r.message||"An unexpected error occurred",0,r.toString())}static isMetaKYCError(r){return r instanceof fe}}class kt{constructor(r){X(this,"axiosInstance");X(this,"endpointBuilder");X(this,"config");this.config={...bt,...r},this.endpointBuilder=new vt(this.config.endpoints),this.axiosInstance=wr.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 i;const a=s.config;return((i=s.response)==null?void 0:i.status)>=500&&!a._retry&&(a._retry=!0,a._retryCount=(a._retryCount||0)+1,a._retryCount<(this.config.retries||3))?(await new Promise(o=>setTimeout(o,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 i=this.buildEndpoint(r,s),o=await this.axiosInstance.get(i,{params:a});return this.handleResponse(o)}catch(i){throw Fe.handleAxiosError(i)}}async post(r,s,a){try{const i=this.buildEndpoint(r,s),o=await this.axiosInstance.post(i,a);return this.handleResponse(o)}catch(i){throw Fe.handleAxiosError(i)}}async put(r,s,a){try{const i=this.buildEndpoint(r,s),o=await this.axiosInstance.put(i,a);return this.handleResponse(o)}catch(i){throw Fe.handleAxiosError(i)}}async delete(r,s,a){try{const i=this.buildEndpoint(r,s),o=await this.axiosInstance.delete(i,{params:a});return this.handleResponse(o)}catch(i){throw Fe.handleAxiosError(i)}}handleResponse(r){const s=r.data;if(!s.success&&s.error)throw Fe.handleApiError(s.error);return s}getAxiosInstance(){return this.axiosInstance}}class wt{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 jt{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 St{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 Nt{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 Ct{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 Et{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 Rt{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 At{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 It{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 ce={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"}}},Pt={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"}},Tt={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"}},Ft={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"}}},Lt={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"}},Dt={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"}},Mt={[ae.Default]:ce,[ae.Corporate]:Pt,[ae.Fintech]:Tt,[ae.Healthcare]:Ft,[ae.Modern]:Lt,[ae.Minimal]:Dt};function Le(t){return Mt[t]||ce}class Ot{constructor(r){this.httpClient=r}async getThemeConfiguration(){var r;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return Le(ae.Default);let a=s.result.preset?Le(s.result.preset):Le(ae.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 i=typeof s.result.applicantFormPages=="string"?JSON.parse(s.result.applicantFormPages):s.result.applicantFormPages;Array.isArray(i)&&i.length>0&&(a.applicantFormPages=i.map(o=>{const c=!o._v||o._v<4;return{...o,fields:(o.fields||[]).map(u=>({...u,colSpan:c?u.colSpan===1?2:4:Math.min(4,Math.max(1,u.colSpan??4))}))}}))}catch{}if(s.result.reviewPageFields)try{const i=typeof s.result.reviewPageFields=="string"?JSON.parse(s.result.reviewPageFields):s.result.reviewPageFields;Array.isArray(i)&&i.length>0&&(a.reviewPageFields=i)}catch{}return s.result.reviewPageDisabled&&(a.reviewPageDisabled=!0),a}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),Le(ae.Default)}}async saveThemeConfiguration(r){await this.httpClient.post("Tenant","SaveThemeConfiguration",r)}getAvailablePresets(){return[{id:ae.Default,name:"Default"},{id:ae.Corporate,name:"Corporate"},{id:ae.Fintech,name:"Fintech"},{id:ae.Healthcare,name:"Healthcare"},{id:ae.Modern,name:"Modern"},{id:ae.Minimal,name:"Minimal"}]}getPreviewTheme(r,s){const a=Le(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 $t{constructor(){X(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(i=>{try{i(s)}catch(o){console.error(`Error in event listener for "${r}":`,o)}})}clear(){this.listeners.clear()}clearEvent(r){this.listeners.delete(r)}}class zt{constructor(){X(this,"events",new $t);X(this,"_applicantId",null);X(this,"_progress",null);X(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)||xe.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===xe.Finished}get isOnHold(){return this.status===xe.OnHold}get isInProgress(){return this.status===xe.InProgress}setApplicantId(r){this._applicantId=r}updateProgress(r){var a,i;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)!==((i=r.currentStep)==null?void 0:i.order)&&this.events.emit("stepChanged",r.currentStep),this.events.emit("statusChanged",r.status),r.status===xe.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 Bt{constructor(){X(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: ${G[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: ${G[r]}`);return a.submitData(s)}}class _t{constructor(r,s,a,i,o,c,u,h){X(this,"state");X(this,"stepRouter");this.applicantService=r,this.questionnaireService=s,this.uploadDocumentService=a,this.appropriatenessTestService=i,this.overviewService=o,this.riskScoringService=c,this.investorCategorizationService=h,this.state=new zt,this.stepRouter=new Bt,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(G.Questionaries,{loadData:r=>this.questionnaireService.getQuestionnaire(r),submitData:async r=>{await this.questionnaireService.fillQuestionnaire(r)}}),this.stepRouter.registerHandler(G.UploadDocument,{loadData:r=>this.uploadDocumentService.getUploadDocument(r),submitData:r=>this.uploadDocumentService.fillUploadDocument(r)}),this.stepRouter.registerHandler(G.AppropriatenessTest,{loadData:r=>this.appropriatenessTestService.getAppropriatenessTest(r),submitData:async r=>{await this.appropriatenessTestService.fillAppropriatenessTest(r)}}),this.stepRouter.registerHandler(G.Overview,{loadData:r=>this.overviewService.getOverviewData(r),submitData:r=>this.overviewService.passOverview(r.applicantId)}),this.stepRouter.registerHandler(G.RiskScoring,{loadData:r=>this.riskScoringService.getRiskCriterias(r),submitData:async r=>{await this.riskScoringService.submitRiskScoring(r)}}),this.stepRouter.registerHandler(G.IdentitySdk,{loadData:async r=>({applicantId:r,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(G.InvestorCategorization,{loadData:r=>this.investorCategorizationService.getInvestorCategorization(r),submitData:async r=>{await this.investorCategorizationService.setInvestorCategorization(r)}}),this.stepRouter.registerHandler(G.ManualReview,{loadData:async r=>({applicantId:r,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(G.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 et(t,r){return new Promise((s,a)=>{if(r&&document.getElementById(r)){s();return}const i=document.createElement("script");i.src=t,r&&(i.id=r),i.async=!0,i.onload=()=>s(),i.onerror=()=>a(new Error(`Failed to load script: ${t}`)),document.head.appendChild(i)})}function Sr(t){return!!document.getElementById(t)}function Nr(t){const r=document.getElementById(t);r&&r.remove()}class Ht{constructor(r){X(this,"sdk",null);X(this,"config");this.config=r}async loadSDK(){await et("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 Ut{constructor(r){X(this,"sdk",null);X(this,"config");this.config=r}async loadSDK(){await et("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 Kt{constructor(r){X(this,"sardineContext",null);X(this,"config");X(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(),i=document.createElement("script");i.type="text/javascript",i.async=!0,i.src=`https://${a}/assets/loader.min.js`,i.onload=()=>{console.log("[SardinAI] SDK loaded successfully"),r()},i.onerror=()=>{s(new Error("Failed to load SardinAI SDK"))};const o=document.getElementsByTagName("script")[0];o&&o.parentNode?o.parentNode.insertBefore(i,o):document.head.appendChild(i)})}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:i,enableBiometrics:o,enablePortScanning:c}=this.config;this.sardineContext=window._Sardine.createContext({clientId:s,sessionKey:this.sessionKey,userIdHash:void 0,flow:i||window.location.pathname,environment:a||"production",parentElement:document.body,enableBiometrics:o!==!1,enablePortScanning:c===!0,region:this.config.region,onDeviceResponse:u=>{console.log(`[SardinAI] Device ID: ${u.deviceId}`)},onConfigUpdate:(u,h,p)=>{switch(u){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",p);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:i,flow:o}=this.config;a.src=`https://${r}/v1/a.png?clientId=${i}&sessionKey=${this.sessionKey}&flow=${o||"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,i)=>{switch(s){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Config update failed:",i);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 Pe{static createProvider(r,s){switch(r){case he.Sumsub:return new Ht(s);case he.Onfido:return new Ut(s);case he.SardinAI:return new Kt(s);default:throw new Error(`Unsupported identity provider: ${r}`)}}static parseProviderConfig(r,s,a){var i;switch(r){case he.Sumsub:return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:s.lang||"en"};case he.Onfido:return{token:s.token||s.sdkToken};case he.SardinAI:const o=((i=a==null?void 0:a.identityProviders)==null?void 0:i.sardinai)||{};return{clientId:o.clientId||s.clientId,sessionKey:o.sessionKey||s.sessionKey,environment:o.environment||s.environment||"production",flow:o.flow||s.flow,region:o.region,enableBiometrics:o.enableBiometrics,enablePortScanning:o.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${r}`)}}}function Cr(t){const r=t.inputBg||t.background,s=t.inputText||t.textPrimary,a=t.inputBorder||t.border,i=t.inputBorderFocus||t.primary,o=t.inputPlaceholder||t.textMuted,c=t.surface||t.background;return`
2
+ /* ── metakyc input overrides (generated by ThemeManager) ── */
3
+ .metakyc-sdk input:not([type="color"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]),
4
+ .metakyc-sdk select,
5
+ .metakyc-sdk textarea,
6
+ .metakyc-sdk .metakyc-input,
7
+ .metakyc-sdk .metakyc-searchable-select-trigger,
8
+ .metakyc-sdk .metakyc-multiselect-trigger {
9
+ background-color: ${r} !important;
10
+ color: ${s} !important;
11
+ border-color: ${a} !important;
12
+ }
13
+ /* Portal dropdown panels (rendered at document.body, outside .metakyc-sdk) */
14
+ .metakyc-searchable-select-dropdown,
15
+ .metakyc-multiselect-dropdown {
16
+ background-color: ${r} !important;
17
+ border-color: ${a} !important;
18
+ color: ${s} !important;
19
+ }
20
+ /* Search input inside portal */
21
+ .metakyc-searchable-select-dropdown input,
22
+ .metakyc-multiselect-dropdown input {
23
+ background-color: ${r} !important;
24
+ color: ${s} !important;
25
+ border-color: ${a} !important;
26
+ }
27
+ /* Option hover rows inside portal */
28
+ .metakyc-searchable-select-dropdown li:hover,
29
+ .metakyc-multiselect-dropdown li:hover {
30
+ background-color: ${c} !important;
31
+ }
32
+ /* Placeholder text */
33
+ .metakyc-sdk input::placeholder,
34
+ .metakyc-sdk textarea::placeholder,
35
+ .metakyc-searchable-select-dropdown input::placeholder,
36
+ .metakyc-multiselect-dropdown input::placeholder {
37
+ color: ${o} !important;
38
+ opacity: 1 !important;
39
+ }
40
+ /* Focus ring */
41
+ .metakyc-sdk input:not([type="color"]):not([type="checkbox"]):not([type="radio"]):focus,
42
+ .metakyc-sdk select:focus,
43
+ .metakyc-sdk textarea:focus,
44
+ .metakyc-sdk .metakyc-searchable-select-trigger:focus,
45
+ .metakyc-searchable-select-dropdown input:focus,
46
+ .metakyc-multiselect-dropdown input:focus {
47
+ border-color: ${i} !important;
48
+ outline-color: ${i} !important;
49
+ box-shadow: 0 0 0 2px ${i}33 !important;
50
+ }
51
+ `}class Wt{constructor(r){X(this,"currentTheme",ce);X(this,"customStyleElement",null);X(this,"inputStyleElement",null);X(this,"container");this.container=r||document.documentElement}applyTheme(r){this.currentTheme=this.mergeWithDefault(r),this.applyColors(this.currentTheme.colors),this.currentTheme.typography&&this.applyTypography(this.currentTheme.typography),this.currentTheme.spacing&&this.applySpacing(this.currentTheme.spacing),this.currentTheme.customCSS&&this.injectCustomCSS(this.currentTheme.customCSS),console.log("[ThemeManager] Theme applied:",this.currentTheme.name||"Custom")}applyColors(r){var a;const s={primary:r.primary,"primary-hover":r.primaryHover,"primary-light":r.primaryLight,"primary-dark":r.primaryDark,secondary:r.secondary,"secondary-hover":r.secondaryHover,success:r.success,warning:r.warning,danger:r.danger,info:r.info,background:r.background,surface:r.surface,border:r.border,"text-primary":r.textPrimary,"text-secondary":r.textSecondary,"text-muted":r.textMuted,"input-bg":r.inputBg||r.background,"input-text":r.inputText||r.textPrimary,"input-border":r.inputBorder||r.border,"input-border-focus":r.inputBorderFocus||r.primary,"input-placeholder":r.inputPlaceholder||r.textMuted};Object.entries(s).forEach(([i,o])=>{o&&this.container.style.setProperty(`--metakyc-${i}`,o)}),this.injectInputColors(r),(a=this.currentTheme.darkMode)!=null&&a.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(r){Object.entries(r).forEach(([s,a])=>{if(a){const i=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(i,a)}})}applyTypography(r){r&&(r.fontFamily&&this.container.style.setProperty("--metakyc-font-family",r.fontFamily),r.headingFont&&this.container.style.setProperty("--metakyc-heading-font",r.headingFont),r.fontSize&&Object.entries(r.fontSize).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-size-${s}`,a)}),r.fontWeight&&Object.entries(r.fontWeight).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-weight-${s}`,a.toString())}))}applySpacing(r){r&&Object.entries(r).forEach(([s,a])=>{const i=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(i,a)})}injectInputColors(r){this.inputStyleElement&&this.inputStyleElement.remove(),this.inputStyleElement=document.createElement("style"),this.inputStyleElement.id="metakyc-input-colors",this.inputStyleElement.textContent=Cr(r),this.customStyleElement&&this.customStyleElement.parentNode?document.head.insertBefore(this.inputStyleElement,this.customStyleElement):document.head.appendChild(this.inputStyleElement)}injectCustomCSS(r){this.customStyleElement&&this.customStyleElement.remove(),this.customStyleElement=document.createElement("style"),this.customStyleElement.id="metakyc-custom-css",this.customStyleElement.textContent=r,document.head.appendChild(this.customStyleElement)}mergeWithDefault(r){var s;return{name:r.name||ce.name,title:r.title||ce.title,logo:{...ce.logo,...r.logo},colors:{...ce.colors,...r.colors},typography:r.typography?{...ce.typography,...r.typography}:ce.typography,spacing:r.spacing?{...ce.spacing,...r.spacing}:ce.spacing,customCSS:r.customCSS,darkMode:r.darkMode?{colors:{...(s=ce.darkMode)==null?void 0:s.colors,...r.darkMode.colors}}:ce.darkMode,applicantFormVisibleFields:r.applicantFormVisibleFields,applicantFormRequiredFields:r.applicantFormRequiredFields,allowedLanguages:r.allowedLanguages,applicantFormPages:r.applicantFormPages,reviewPageFields:r.reviewPageFields,reviewPageDisabled:r.reviewPageDisabled}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(ce)}cleanup(){this.inputStyleElement&&(this.inputStyleElement.remove(),this.inputStyleElement=null),this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(r){return r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const tt=l.createContext(null),Er=({config:t,children:r})=>{const[s,a]=l.useState(null),i=l.useRef(!1),o=l.useRef(!1),c=l.useMemo(()=>{const h=new kt(t),p=new wt(h),v=new jt(h),S=new St(h),g=new Nt(h),j=new Ct(h),f=new Et(h),F=new Rt(h),I=new At(h),A=new It(h),M=new Ot(h),R=new Wt;return{httpClient:h,applicantService:p,questionnaireService:v,uploadDocumentService:S,appropriatenessTestService:g,overviewService:j,riskScoringService:f,identityService:F,baseInformationService:I,investorCategorizationService:A,themeService:M,themeManager:R}},[t]),u=l.useMemo(()=>({config:t,...c,currentTheme:s,createOrchestrator:()=>new _t(c.applicantService,c.questionnaireService,c.uploadDocumentService,c.appropriatenessTestService,c.overviewService,c.riskScoringService,c.identityService,c.investorCategorizationService)}),[t,c,s]);return l.useEffect(()=>((async()=>{if(i.current||o.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}i.current=!0;try{if(t.theme){console.log("[MetaKYC] Applying static theme from config"),c.themeManager.applyTheme(t.theme),a(c.themeManager.getCurrentTheme()),o.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const p=await c.themeService.getThemeConfiguration();c.themeManager.applyTheme(p),a(c.themeManager.getCurrentTheme()),o.current=!0,console.log("[MetaKYC] Theme loaded and applied",p)}catch(p){console.warn("[MetaKYC] Failed to load theme, using default:",p),a(c.themeManager.getCurrentTheme()),o.current=!0}finally{i.current=!1}})(),()=>{c.themeManager.cleanup()}),[]),e.jsx(tt.Provider,{value:u,children:r})};function de(){const t=l.useContext(tt);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function Yt(t){return new Promise((r,s)=>{const a=new FileReader;a.readAsDataURL(t),a.onload=()=>{const o=a.result.split(",")[1];r(o)},a.onerror=i=>s(i)})}function Rr(t,r){return t.size<=r}function Ar(t,r){return r.split(",").map(a=>a.trim()).some(a=>{if(a.endsWith("/*")){const i=a.slice(0,-2);return t.type.startsWith(i)}return t.type===a})}function We(t){if(t===0)return"0 Bytes";const r=1024,s=["Bytes","KB","MB","GB"],a=Math.floor(Math.log(t)/Math.log(r));return Math.round(t/Math.pow(r,a)*100)/100+" "+s[a]}function Ir(t){return t}function re(...t){return t.filter(Boolean).join(" ")}const De={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function qt(t){try{localStorage.setItem(De.APPLICANT_ID,t.toString())}catch(r){console.warn("Failed to save applicant ID to storage:",r)}}function Qt(){try{const t=localStorage.getItem(De.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function Gt(){try{localStorage.removeItem(De.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function Vt(t){try{localStorage.setItem(De.WORKFLOW_STATE,JSON.stringify(t))}catch(r){console.warn("Failed to save workflow state to storage:",r)}}function Pr(){try{const t=localStorage.getItem(De.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function Jt(){try{localStorage.removeItem(De.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function Tr(){Gt(),Jt()}function Zt(t){const{createOrchestrator:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(null),h=l.useRef(null),p=t||Qt();l.useEffect(()=>{h.current||(h.current=r())},[r]),l.useEffect(()=>{var R;s&&p&&(qt(p),Vt({applicantId:p,currentStepOrder:(R=s.currentStep)==null?void 0:R.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,p]);const v=l.useRef(!1),S=l.useRef(!1),g=l.useCallback(async()=>{if(!(!p||!h.current)){if(v.current){console.log("[Workflow] Load already in progress, skipping...");return}v.current=!0,o(!0),u(null);try{const R=await h.current.initialize(p);a(R),S.current=!0}catch(R){u(R)}finally{o(!1),v.current=!1}}},[p]);l.useEffect(()=>{p&&!S.current&&g()},[p,g]);const j=l.useCallback(async()=>{if(h.current){if(v.current){console.log("[Workflow] Refresh already in progress, skipping...");return}v.current=!0,o(!0),u(null);try{const R=await h.current.refreshProgress();a(R)}catch(R){u(R)}finally{o(!1),v.current=!1}}},[]),f=l.useCallback(async()=>{if(h.current){o(!0),u(null);try{const R=await h.current.moveToNextStep();a(R)}catch(R){u(R)}finally{o(!1)}}},[]),F=l.useCallback(async()=>{if(h.current){o(!0),u(null);try{const R=await h.current.moveToPreviousStep();a(R)}catch(R){u(R)}finally{o(!1)}}},[]),I=l.useCallback(async R=>{if(h.current){o(!0),u(null);try{await h.current.submitCurrentStep(R);const P=await h.current.refreshProgress();a(P)}catch(P){throw u(P),P}finally{o(!1)}}},[]),A=rt.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((R,P)=>R.order-P.order):[],[s==null?void 0:s.stepInfoList]),M=rt.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:p,currentStep:(s==null?void 0:s.currentStep)||null,steps:A,status:(s==null?void 0:s.status)||xe.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:M,isLoading:i,error:c,isComplete:(s==null?void 0:s.status)===xe.Finished,isOnHold:(s==null?void 0:s.status)===xe.OnHold,refreshProgress:j,moveToNext:f,moveBack:F,submitCurrentStep:I,orchestrator:h.current}}function Xt(t){const{questionnaireService:r,applicantService:s}=de(),[a,i]=l.useState(null),[o,c]=l.useState({}),[u,h]=l.useState(!1),[p,v]=l.useState(!1),[S,g]=l.useState(null),j=l.useRef(!1),f=l.useRef(null),F=l.useCallback(async()=>{var A,M;if(t){if(j.current){console.log("[Questionnaire] Load already in progress, skipping...");return}j.current=!0,h(!0),g(null);try{const[R,P]=await Promise.all([r.getQuestionnaire(t),s.getApplicantData(t).catch(()=>null)]);if(i(R),(A=P==null?void 0:P.questionnaireResults)!=null&&A.length&&R){const Y=new Map;for(const w of P.questionnaireResults)w.question&&((M=w.answers)!=null&&M.length)&&Y.set(w.question.trim().toLowerCase(),w.answers);const J={},E=R.questionGroups.flatMap(w=>w.questions??[]);for(const w of E){const B=w.text.trim().toLowerCase();Y.has(B)&&(J[w.id]=Y.get(B))}c(J)}f.current=t}catch(R){g(R)}finally{h(!1),j.current=!1}}},[t,r,s]);l.useEffect(()=>{t&&f.current!==t&&F()},[t]);const I=l.useCallback(async A=>{v(!0),g(null);try{return await r.fillQuestionnaire(A)}catch(M){throw g(M),M}finally{v(!1)}},[r]);return{questionnaire:a,initialAnswers:o,isLoading:u,isSubmitting:p,error:S,load:F,submit:I}}function er(t){const{uploadDocumentService:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(!1),[h,p]=l.useState(0),[v,S]=l.useState(null),g=l.useRef(!1),j=l.useRef(null),f=l.useCallback(async()=>{if(t){if(g.current){console.log("[UploadDocument] Load already in progress, skipping...");return}g.current=!0,o(!0),S(null);try{const I=await r.getUploadDocument(t);a(I),j.current=t}catch(I){S(I)}finally{o(!1),g.current=!1}}},[t,r]);l.useEffect(()=>{t&&j.current!==t&&f()},[t]);const F=l.useCallback(async I=>{u(!0),p(0),S(null);try{await r.fillUploadDocument(I),p(100)}catch(A){throw S(A),A}finally{u(!1)}},[r]);return{uploadDocument:s,isLoading:i,isSubmitting:c,uploadProgress:h,error:v,load:f,submit:F}}function Fr(t){const{appropriatenessTestService:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(!1),[h,p]=l.useState(null),[v,S]=l.useState(null),g=l.useRef(!1),j=l.useRef(null),f=l.useCallback(async()=>{if(t){if(g.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}g.current=!0,o(!0),p(null);try{const I=await r.getAppropriatenessTest(t);a(I),j.current=t}catch(I){p(I)}finally{o(!1),g.current=!1}}},[t,r]);l.useEffect(()=>{t&&j.current!==t&&f()},[t]);const F=l.useCallback(async I=>{u(!0),p(null);try{const A=await r.fillAppropriatenessTest(I);return S(A),A}catch(A){throw p(A),A}finally{u(!1)}},[r]);return{test:s,result:v,isLoading:i,isSubmitting:c,error:h,load:f,submit:F}}function tr(t){const{overviewService:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(!1),[h,p]=l.useState(null),v=l.useRef(!1),S=l.useRef(null),g=l.useCallback(async()=>{if(t){if(v.current){console.log("[Overview] Load already in progress, skipping...");return}v.current=!0,o(!0),p(null);try{const f=await r.getOverviewData(t);a(f),S.current=t}catch(f){p(f)}finally{o(!1),v.current=!1}}},[t,r]);l.useEffect(()=>{t&&S.current!==t&&g()},[t]);const j=l.useCallback(async()=>{if(t){u(!0),p(null);try{await r.passOverview(t)}catch(f){throw p(f),f}finally{u(!1)}}},[t,r]);return{overview:s,isLoading:i,isSubmitting:c,error:h,load:g,passOverview:j}}function rr(t){const{identityService:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(null),h=l.useRef(!1),p=l.useCallback(async(g,j)=>{if(t){if(h.current){console.log("[Identity] Request already in progress, skipping...");return}h.current=!0,o(!0),u(null);try{const f={applicantId:t,restart:!1,redirectUrl:g||"",ttl:j||604800};console.log("Identity request input:",f);const F=await r.identityRequest(f);return console.log("Identity request result:",F),a(F),F}catch(f){throw u(f),f}finally{o(!1),h.current=!1}}},[t,r]),v=l.useCallback(async(g,j)=>{if(t){o(!0),u(null);try{const f={applicantId:t,restart:!1,redirectUrl:g,ttl:j},F=await r.identityCompanyRequest(f);return a(F),F}catch(f){throw u(f),f}finally{o(!1)}}},[t,r]),S=l.useCallback(async()=>{if(t){if(h.current){console.log("[Identity] Restart already in progress, skipping...");return}h.current=!0,o(!0),u(null);try{const g={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",g);const j=await r.identityRequest(g);return console.log("Restart identity result:",j),a(j),j}catch(g){throw u(g),g}finally{o(!1),h.current=!1}}},[t,r]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:i,error:c,requestIdentity:p,requestCompanyIdentity:v,restartIdentity:S}}function sr(t){const{riskScoringService:r,applicantService:s}=de(),[a,i]=l.useState(null),[o,c]=l.useState({}),[u,h]=l.useState(!1),[p,v]=l.useState(!1),[S,g]=l.useState(null),[j,f]=l.useState(null),F=l.useRef(!1),I=l.useRef(null),A=l.useCallback(async()=>{var R;if(t){if(F.current){console.log("[RiskScoring] Load already in progress, skipping...");return}F.current=!0,h(!0),g(null);try{const[P,Y]=await Promise.all([r.getRiskCriterias(t),s.getApplicantData(t).catch(()=>null)]);if(i(P),(R=Y==null?void 0:Y.riskScoringResults)!=null&&R.length){const J=Y.riskScoringResults[0],E={};for(const w of J.riskCriteriaResults??[])if(w.riskCriteriaId!=null&&w.answer!=null&&w.answer!==""){const B=[...new Set(w.answer.split(",").map(K=>K.trim()).filter(K=>K!==""))];B.length>0&&(E[w.riskCriteriaId]=B)}c(E)}I.current=t}catch(P){g(P)}finally{h(!1),F.current=!1}}},[t,r,s]);l.useEffect(()=>{t&&I.current!==t&&A()},[t]);const M=l.useCallback(async R=>{v(!0),g(null);try{const P=await r.submitRiskScoring(R);return f(P),P}catch(P){throw g(P),P}finally{v(!1)}},[r]);return{criteria:a,initialAnswers:o,result:j,isLoading:u,isSubmitting:p,error:S,load:A,submit:M}}function ar(){const{applicantService:t,config:r}=de(),[s,a]=l.useState(!1),[i,o]=l.useState(null),c=l.useRef(!1),u=l.useRef(!1),h=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(j){const f=Math.random()*16|0;return(j==="x"?f:f&3|8).toString(16)}),p=l.useCallback(async j=>{var f;if(c.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");c.current=!0,a(!0),o(null);try{if(j.applicantAdditionalDatas||(j.applicantAdditionalDatas=[]),(f=r.identityProviders)!=null&&f.sardinai){const I=h();console.log("[SardinAI] Generated session key:",I),j.applicantAdditionalDatas.push({paramName:"sessionKey",value:I})}return await t.createApplicant(j)}catch(F){throw o(F),F}finally{a(!1),c.current=!1}},[t,r]),v=l.useCallback(async j=>{a(!0),o(null);try{return await t.createCompanyApplicant(j)}catch(f){throw o(f),f}finally{a(!1)}},[t]),S=l.useCallback(async j=>{if(u.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");u.current=!0,a(!0),o(null);try{return await t.getApplicantData(j)}catch(f){throw o(f),f}finally{a(!1),u.current=!1}},[t]),g=l.useCallback(async j=>{a(!0),o(null);try{await t.stopProgress(j)}catch(f){throw o(f),f}finally{a(!1)}},[t]);return{isLoading:s,error:i,createApplicant:p,createCompanyApplicant:v,getApplicantData:S,stopProgress:g}}const W=({children:t,variant:r="primary",size:s="md",isLoading:a=!1,disabled:i,className:o,...c})=>{const u="inline-flex items-center justify-center rounded-lg font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",h={primary:"bg-primary-500 text-white hover:bg-primary-600 focus:ring-primary-500",secondary:"bg-gray-200 text-gray-900 hover:bg-gray-300 focus:ring-gray-400",outline:"border-2 border-primary-500 text-primary-500 hover:bg-primary-50 focus:ring-primary-500",danger:"bg-danger-500 text-white hover:bg-danger-600 focus:ring-danger-500",ghost:"text-gray-700 hover:bg-gray-100 focus:ring-gray-400"},p={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-base",lg:"px-6 py-3 text-lg"};return e.jsxs("button",{className:re(u,h[r],p[s],o),disabled:i||a,...c,children:[a&&e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t]})},ne=l.forwardRef(({label:t,error:r,helperText:s,leftIcon:a,rightIcon:i,className:o,style:c,...u},h)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,u.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"relative",children:[a&&e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:a}),e.jsx("input",{ref:h,className:re("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-offset-0","disabled:opacity-60 disabled:cursor-not-allowed",a?"pl-10":"",i?"pr-10":"",o),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",...c},...u}),i&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:i})]}),r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-danger, #ef4444)"},children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s})]}));ne.displayName="Input";const _=({children:t,className:r,...s})=>e.jsx("div",{className:re("metakyc-card rounded-xl shadow-sm border",r),style:{backgroundColor:"var(--metakyc-surface, #ffffff)",borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),ie=({children:t,className:r,...s})=>e.jsx("div",{className:re("px-6 py-4 border-b",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),H=({children:t,className:r,...s})=>e.jsx("div",{className:re("px-6 py-4",r),...s,children:t}),le=({children:t,className:r,...s})=>e.jsx("div",{className:re("px-6 py-4 border-t",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),ve=({children:t,variant:r="default",className:s,...a})=>{const i={default:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",success:"bg-success-100 text-success-800 dark:bg-success-900 dark:text-success-300",danger:"bg-danger-100 text-danger-800 dark:bg-danger-900 dark:text-danger-300",warning:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300",info:"bg-primary-100 text-primary-800 dark:bg-primary-900 dark:text-primary-300"};return e.jsx("span",{className:re("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",i[r],s),...a,children:t})},ye=({size:t="md",className:r,...s})=>{const a={sm:"h-4 w-4",md:"h-8 w-8",lg:"h-12 w-12"};return e.jsx("div",{className:re("flex items-center justify-center",r),...s,children:e.jsxs("svg",{className:re("animate-spin text-primary-500",a[t]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})},Qe=l.forwardRef(({label:t,error:r,helperText:s,options:a,placeholder:i,className:o,style:c,...u},h)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,u.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("select",{ref:h,className:re("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-offset-0","disabled:opacity-60 disabled:cursor-not-allowed",r?"border-danger-500":"",o),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",...c},...u,children:[i&&e.jsx("option",{value:"",disabled:!0,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-secondary, #6b7280)"},children:i},"__placeholder__"),a.map((p,v)=>e.jsx("option",{value:p.value,disabled:p.disabled,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:p.disabled?"var(--metakyc-text-muted, #9ca3af)":"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))"},children:p.label},p.value||`option-${v}`))]}),r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-error, #ef4444)"},children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s})]}));Qe.displayName="Select";const st=280,nr=({label:t,value:r,onChange:s,options:a,placeholder:i="Select...",disabled:o=!1,required:c=!1})=>{const[u,h]=l.useState(!1),[p,v]=l.useState(""),[S,g]=l.useState(null),j=l.useRef(null),f=l.useRef(null),F=l.useRef(null),I=l.useCallback(()=>{if(!f.current)return null;const C=f.current.getBoundingClientRect(),Z=window.innerHeight-C.bottom<st&&C.top>st;return{top:Z?C.top:C.bottom+4,left:C.left,width:C.width,openUp:Z}},[]),A=l.useCallback(()=>{if(o)return;const C=I();C&&g(C),h(!0)},[o,I]),M=l.useCallback(()=>{h(!1),v("")},[]);l.useEffect(()=>{if(!u)return;const C=U=>{var me,se;const Z=U.target;!((me=j.current)!=null&&me.contains(Z))&&!((se=F.current)!=null&&se.contains(Z))&&M()};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[u,M]),l.useEffect(()=>{if(!u)return;const C=()=>{const U=I();U&&g(U)};return window.addEventListener("scroll",C,!0),window.addEventListener("resize",C),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C)}},[u,I]);const R=a.filter(C=>C.label.toLowerCase().includes(p.toLowerCase())),P=C=>{o||s(r.includes(C)?r.filter(U=>U!==C):[...r,C])},Y=(C,U)=>{U.stopPropagation(),o||s(r.filter(Z=>Z!==C))},J=C=>{var U;return((U=a.find(Z=>Z.value===C))==null?void 0:U.label)||C},E=f.current?getComputedStyle(f.current):null,w=(E==null?void 0:E.getPropertyValue("--metakyc-input-bg").trim())||"#ffffff",B=(E==null?void 0:E.getPropertyValue("--metakyc-input-border").trim())||(E==null?void 0:E.getPropertyValue("--metakyc-border").trim())||"#d1d5db",K=(E==null?void 0:E.getPropertyValue("--metakyc-input-text").trim())||(E==null?void 0:E.getPropertyValue("--metakyc-text-primary").trim())||"#111827",k=(E==null?void 0:E.getPropertyValue("--metakyc-text-secondary").trim())||"#6b7280",$=(E==null?void 0:E.getPropertyValue("--metakyc-primary").trim())||"#2563eb",T=(E==null?void 0:E.getPropertyValue("--metakyc-primary-light").trim())||"#eff6ff",D=(E==null?void 0:E.getPropertyValue("--metakyc-hover-bg").trim())||"#f9fafb",Q=u&&S&&e.jsxs("div",{ref:F,className:"metakyc-multiselect-dropdown",style:{position:"fixed",top:S.openUp?void 0:S.top,bottom:S.openUp?window.innerHeight-S.top+4:void 0,left:S.left,width:S.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${B}`,backgroundColor:w,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${B}`},children:e.jsx("input",{type:"text",value:p,onChange:C=>v(C.target.value),placeholder:"Search...",autoFocus:!0,onClick:C=>C.stopPropagation(),className:"metakyc-multiselect-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${B}`,backgroundColor:w,color:K,outline:"none",boxSizing:"border-box"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"192px",overflowY:"auto"},children:R.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:k},children:"No results"}):R.map(C=>{const U=r.includes(C.value);return e.jsxs("li",{onClick:()=>P(C.value),className:"metakyc-multiselect-option",style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",fontSize:"13px",cursor:"pointer",backgroundColor:U?T:"transparent",color:U?$:K,userSelect:"none"},onMouseEnter:Z=>{U||(Z.currentTarget.style.backgroundColor=D)},onMouseLeave:Z=>{U||(Z.currentTarget.style.backgroundColor="transparent")},children:[e.jsx("input",{type:"checkbox",checked:U,readOnly:!0,style:{accentColor:$,pointerEvents:"none",flexShrink:0}}),e.jsx("span",{children:C.label})]},C.value)})}),r.length>0&&e.jsx("div",{style:{padding:"6px 12px",borderTop:`1px solid ${B}`},children:e.jsxs("button",{type:"button",onClick:()=>{s([]),v("")},style:{fontSize:"12px",color:"#ef4444",background:"none",border:"none",cursor:"pointer",padding:0},children:["Clear all (",r.length," selected)"]})})]});return e.jsxs("div",{className:"w-full metakyc-multiselect",ref:j,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,c&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:f,onClick:()=>u?M():A(),className:re("metakyc-multiselect-trigger","min-h-[42px] w-full px-3 py-2 rounded-lg border text-sm transition-colors relative",o?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",borderColor:u?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",outline:u?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[r.length===0?e.jsx("span",{className:"metakyc-multiselect-placeholder leading-6",style:{color:"var(--metakyc-text-secondary, #9ca3af)"},children:i}):e.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:r.map(C=>e.jsxs("span",{className:"metakyc-multiselect-chip inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium",style:{backgroundColor:"var(--metakyc-primary-light, #eff6ff)",color:"var(--metakyc-primary, #2563eb)"},children:[J(C),!o&&e.jsx("button",{type:"button",onClick:U=>Y(C,U),className:"metakyc-multiselect-chip-remove",style:{background:"transparent",border:"none",padding:"0 0 0 2px",margin:0,cursor:"pointer",fontSize:"14px",lineHeight:1,fontWeight:"bold",display:"inline-flex",alignItems:"center",boxShadow:"none",transform:"none",minWidth:0,width:"auto",height:"auto",letterSpacing:"normal",textTransform:"none"},children:"×"})]},C))}),e.jsx("span",{className:"metakyc-multiselect-arrow absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:u?"▲":"▼"})]}),typeof document<"u"&&Q?qe.createPortal(Q,document.body):null]})},at=260,ke=({label:t,error:r,helperText:s,options:a,placeholder:i="Select...",value:o,onChange:c,disabled:u=!1,required:h=!1,className:p})=>{var se;const[v,S]=l.useState(!1),[g,j]=l.useState(""),[f,F]=l.useState(null),I=l.useRef(null),A=l.useRef(null),M=l.useRef(null),R=l.useRef(null),P=l.useCallback(()=>{if(!A.current)return null;const L=A.current.getBoundingClientRect(),te=window.innerHeight-L.bottom<at&&L.top>at;return{top:te?L.top:L.bottom+4,left:L.left,width:L.width,openUp:te}},[]),Y=l.useCallback(()=>{if(u)return;const L=P();L&&F(L),S(!0)},[u,P]),J=l.useCallback(()=>{S(!1),j("")},[]),E=()=>v?J():Y();l.useEffect(()=>{if(!v)return;const L=V=>{var je,Re;const te=V.target;!((je=I.current)!=null&&je.contains(te))&&!((Re=M.current)!=null&&Re.contains(te))&&J()};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[v,J]),l.useEffect(()=>{if(!v)return;const L=()=>{const V=P();V&&F(V)};return window.addEventListener("scroll",L,!0),window.addEventListener("resize",L),()=>{window.removeEventListener("scroll",L,!0),window.removeEventListener("resize",L)}},[v,P]),l.useEffect(()=>{v&&R.current&&setTimeout(()=>{var L;return(L=R.current)==null?void 0:L.focus()},0)},[v]);const w=a.filter(L=>L.label.toLowerCase().includes(g.toLowerCase())||L.value.toLowerCase().includes(g.toLowerCase())),B=(se=a.find(L=>L.value===o))==null?void 0:se.label,K=(L,V)=>{u||V||(c(L),J())},k=A.current?getComputedStyle(A.current):null,$=(k==null?void 0:k.getPropertyValue("--metakyc-input-bg").trim())||"#ffffff",T=(k==null?void 0:k.getPropertyValue("--metakyc-input-border").trim())||(k==null?void 0:k.getPropertyValue("--metakyc-border").trim())||"#d1d5db",D=(k==null?void 0:k.getPropertyValue("--metakyc-input-text").trim())||(k==null?void 0:k.getPropertyValue("--metakyc-text-primary").trim())||"#111827",Q=(k==null?void 0:k.getPropertyValue("--metakyc-text-secondary").trim())||"#6b7280",C=(k==null?void 0:k.getPropertyValue("--metakyc-primary").trim())||"#2563eb",U=(k==null?void 0:k.getPropertyValue("--metakyc-primary-light").trim())||"#eff6ff",Z=(k==null?void 0:k.getPropertyValue("--metakyc-hover-bg").trim())||"#f9fafb",me=v&&f&&e.jsxs("div",{ref:M,className:"metakyc-searchable-select-dropdown",style:{position:"fixed",top:f.openUp?void 0:f.top,bottom:f.openUp?window.innerHeight-f.top+4:void 0,left:f.left,width:f.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${T}`,backgroundColor:$,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${T}`},children:e.jsx("input",{ref:R,type:"text",value:g,onChange:L=>j(L.target.value),placeholder:"Search...",onClick:L=>L.stopPropagation(),className:"metakyc-searchable-select-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${T}`,backgroundColor:$,color:D,outline:"none",boxSizing:"border-box"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"208px",overflowY:"auto"},children:w.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:Q},children:"No results"}):w.map(L=>{const V=L.value===o;return e.jsx("li",{className:"metakyc-searchable-select-option",onClick:()=>K(L.value,L.disabled),style:{padding:"8px 12px",fontSize:"13px",cursor:L.disabled?"not-allowed":"pointer",opacity:L.disabled?.4:1,backgroundColor:V?U:"transparent",color:V?C:D,userSelect:"none"},onMouseEnter:te=>{!V&&!L.disabled&&(te.currentTarget.style.backgroundColor=Z)},onMouseLeave:te=>{V||(te.currentTarget.style.backgroundColor="transparent")},children:L.label},L.value)})})]});return e.jsxs("div",{className:re("w-full metakyc-searchable-select",p),ref:I,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,h&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:A,role:"button",tabIndex:u?-1:0,onClick:E,onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),E()),L.key==="Escape"&&J()},className:re("metakyc-searchable-select-trigger","w-full px-3 py-2 rounded-lg border text-sm transition-colors text-left","flex items-center justify-between gap-2","focus:outline-none",u?"opacity-60 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:B?"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))":"var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))",borderColor:r?"var(--metakyc-danger, #ef4444)":v?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",minHeight:"42px",outline:v?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[e.jsx("span",{className:"truncate flex-1",children:B||i}),e.jsx("span",{className:"flex-shrink-0 text-xs pointer-events-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:v?"▲":"▼"})]}),typeof document<"u"&&me?qe.createPortal(me,document.body):null,r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-error, #ef4444)"},children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s})]})};ke.displayName="SearchableSelect";const ir=({label:t,error:r,accept:s,multiple:a=!1,maxSize:i,onChange:o,value:c=[],className:u})=>{const[h,p]=l.useState(!1),v=l.useRef(null),S=A=>{if(!A)return;const M=Array.from(A);if(i&&M.filter(P=>P.size>i).length>0){const P=We(i);alert(`Some files exceed the maximum size of ${P}`);return}o==null||o(a?[...c,...M]:[M[0]])},g=A=>{A.preventDefault(),p(!0)},j=()=>{p(!1)},f=A=>{A.preventDefault(),p(!1),S(A.dataTransfer.files)},F=()=>{var A;(A=v.current)==null||A.click()},I=A=>{const M=c.filter((R,P)=>P!==A);o==null||o(M)};return e.jsxs("div",{className:re("w-full",u),children:[t&&e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t}),e.jsxs("div",{className:re("border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors",h?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-300 dark:border-gray-600 hover:border-primary-500",r&&"border-danger-500"),onDragOver:g,onDragLeave:j,onDrop:f,onClick:F,children:[e.jsx("input",{ref:v,type:"file",className:"hidden",accept:s,multiple:a,onChange:A=>S(A.target.files)}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",stroke:"currentColor",fill:"none",viewBox:"0 0 48 48",children:e.jsx("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("span",{className:"font-medium text-primary-500",children:"Click to upload"})," or drag and drop"]}),i&&e.jsxs("p",{className:"text-xs text-gray-500",children:["Maximum file size: ",We(i)]})]})]}),c.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:c.map((A,M)=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsxs("div",{className:"flex items-center space-x-2 flex-1 min-w-0",children:[e.jsx("svg",{className:"h-5 w-5 text-gray-400 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",children:A.name}),e.jsxs("span",{className:"text-xs text-gray-500",children:["(",We(A.size),")"]})]}),e.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),I(M)},className:"ml-2 text-danger-500 hover:text-danger-700 focus:outline-none",children:e.jsx("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]},M))}),r&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:r})]})},or=l.forwardRef(({countryCode:t="+1",onCountryCodeChange:r,className:s,...a},i)=>e.jsxs("div",{className:"w-full",children:[a.label&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[a.label,a.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:o=>r==null?void 0:r(o.target.value),className:re("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-offset-0"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-primary, #111827)",borderColor:"var(--metakyc-border, #d1d5db)"},placeholder:"+1"}),e.jsx(ne,{ref:i,type:"tel",className:re("flex-1",s),...a,label:""})]}),a.error&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:a.error})]}));or.displayName="PhoneInput";/**
2
52
  * @license lucide-react v0.574.0 - ISC
3
53
  *
4
54
  * This source code is licensed under the ISC license.
@@ -8,37 +58,37 @@
8
58
  *
9
59
  * This source code is licensed under the ISC license.
10
60
  * See the LICENSE file in the root directory of this source tree.
11
- */const Fr=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
61
+ */const Lr=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
12
62
  * @license lucide-react v0.574.0 - ISC
13
63
  *
14
64
  * This source code is licensed under the ISC license.
15
65
  * See the LICENSE file in the root directory of this source tree.
16
- */const Lr=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,s,a)=>a?a.toUpperCase():s.toLowerCase());/**
66
+ */const Dr=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,s,a)=>a?a.toUpperCase():s.toLowerCase());/**
17
67
  * @license lucide-react v0.574.0 - ISC
18
68
  *
19
69
  * This source code is licensed under the ISC license.
20
70
  * See the LICENSE file in the root directory of this source tree.
21
- */const nt=t=>{const r=Lr(t);return r.charAt(0).toUpperCase()+r.slice(1)};/**
71
+ */const nt=t=>{const r=Dr(t);return r.charAt(0).toUpperCase()+r.slice(1)};/**
22
72
  * @license lucide-react v0.574.0 - ISC
23
73
  *
24
74
  * This source code is licensed under the ISC license.
25
75
  * See the LICENSE file in the root directory of this source tree.
26
- */var Dr={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
76
+ */var Mr={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
27
77
  * @license lucide-react v0.574.0 - ISC
28
78
  *
29
79
  * This source code is licensed under the ISC license.
30
80
  * See the LICENSE file in the root directory of this source tree.
31
- */const Mr=t=>{for(const r in t)if(r.startsWith("aria-")||r==="role"||r==="title")return!0;return!1};/**
81
+ */const Or=t=>{for(const r in t)if(r.startsWith("aria-")||r==="role"||r==="title")return!0;return!1};/**
32
82
  * @license lucide-react v0.574.0 - ISC
33
83
  *
34
84
  * This source code is licensed under the ISC license.
35
85
  * See the LICENSE file in the root directory of this source tree.
36
- */const Or=l.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:s=2,absoluteStrokeWidth:a,className:i="",children:o,iconNode:c,...u},h)=>l.createElement("svg",{ref:h,...Dr,width:r,height:r,stroke:t,strokeWidth:a?Number(s)*24/Number(r):s,className:lr("lucide",i),...!o&&!Mr(u)&&{"aria-hidden":"true"},...u},[...c.map(([p,v])=>l.createElement(p,v)),...Array.isArray(o)?o:[o]]));/**
86
+ */const $r=l.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:s=2,absoluteStrokeWidth:a,className:i="",children:o,iconNode:c,...u},h)=>l.createElement("svg",{ref:h,...Mr,width:r,height:r,stroke:t,strokeWidth:a?Number(s)*24/Number(r):s,className:lr("lucide",i),...!o&&!Or(u)&&{"aria-hidden":"true"},...u},[...c.map(([p,v])=>l.createElement(p,v)),...Array.isArray(o)?o:[o]]));/**
37
87
  * @license lucide-react v0.574.0 - ISC
38
88
  *
39
89
  * This source code is licensed under the ISC license.
40
90
  * See the LICENSE file in the root directory of this source tree.
41
- */const cr=(t,r)=>{const s=l.forwardRef(({className:a,...i},o)=>l.createElement(Or,{ref:o,iconNode:r,className:lr(`lucide-${Fr(nt(t))}`,`lucide-${t}`,a),...i}));return s.displayName=nt(t),s};/**
91
+ */const cr=(t,r)=>{const s=l.forwardRef(({className:a,...i},o)=>l.createElement($r,{ref:o,iconNode:r,className:lr(`lucide-${Lr(nt(t))}`,`lucide-${t}`,a),...i}));return s.displayName=nt(t),s};/**
42
92
  * @license lucide-react v0.574.0 - ISC
43
93
  *
44
94
  * This source code is licensed under the ISC license.
@@ -48,7 +98,7 @@
48
98
  *
49
99
  * This source code is licensed under the ISC license.
50
100
  * See the LICENSE file in the root directory of this source tree.
51
- */const Br=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ur=cr("chevron-right",Br);function $r(t,r){const s=!r||r.length===0||r.every(a=>!a||!a.trim());if(t.isRequired&&s)return t.errorMessage||"This field is required";if(!s){const a=r[0]??"";if(a&&t.regex)try{if(!new RegExp(t.regex).test(a))return t.errorMessage||"Invalid format"}catch{}if(a!==""){const i=Number(a);if(!isNaN(i)&&a.trim()!==""){if(t.min!==void 0&&t.min!==null&&i<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&i>t.max)return`Maximum value is ${t.max}`}else{if(t.min!==void 0&&t.min!==null&&a.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&a.length>t.max)return`Maximum length is ${t.max} characters`}}}return null}function _r(t){const r=t.flatMap((a,i)=>(a.questions??[]).map((o,c)=>({question:o,groupIndex:i,qIdx:c}))),s=new Map;for(const a of r){const i=a.question.pageNumber!=null&&a.question.pageNumber>0?a.question.pageNumber:1;s.has(i)||s.set(i,[]),s.get(i).push(a)}return Array.from(s.entries()).sort(([a],[i])=>a-i).map(([,a])=>a)}const pr=({applicantId:t,onComplete:r,onBack:s})=>{const{questionnaire:a,initialAnswers:i,isLoading:o,isSubmitting:c,error:u,submit:h}=Xt(t),[p,v]=l.useState({}),[S,y]=l.useState({}),[j,f]=l.useState(0);l.useEffect(()=>{i&&Object.keys(i).length>0&&Object.keys(p).length===0&&v(i)},[i]);const F=l.useMemo(()=>a?_r(a.questionGroups):[],[a]),I=j===F.length-1,E=F[j]??[],M=l.useCallback((R,w)=>{v($=>({...$,[R]:w})),y($=>{const K={...$};return delete K[R],K})},[]),A=l.useCallback(()=>{const R={};for(const{question:w}of E){const $=$r(w,p[w.id]??[]);$&&(R[w.id]=$)}return y(w=>({...w,...R})),Object.keys(R).length===0},[E,p]),P=()=>{A()&&f(R=>R+1)},Y=()=>{j>0?f(R=>R-1):s==null||s()},J=async()=>{if(!(!A()||!a))try{const R=a.questionGroups.flatMap($=>($.questions??[]).map(K=>({questionId:K.id,values:p[K.id]??[]}))),w={applicantId:t,questionnarieId:a.id,questionResults:R};await h(w),r==null||r()}catch(R){console.error("Questionnaire submit error:",R)}};return o?e.jsx(_,{children:e.jsx(H,{children:e.jsx(ge,{className:"my-8"})})}):u?e.jsx(_,{children:e.jsx(H,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading questionnaire: ",u.message]})})}):a?e.jsxs(_,{children:[e.jsxs(ie,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.displayName}),a.subtitle&&e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a.subtitle}),F.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",j+1," of ",F.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:F.map((R,w)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:w===j?"20px":"6px",backgroundColor:w<=j?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},w))})]})]}),e.jsx(H,{className:"space-y-6",children:E.map(({question:R})=>e.jsx(Hr,{question:R,value:p[R.id]??[],error:S[R.id],onChange:w=>M(R.id,w)},R.id))}),e.jsxs(le,{className:"flex items-center justify-between",children:[e.jsxs(W,{type:"button",variant:"outline",onClick:Y,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(dr,{size:14}),j>0?"Previous":"Back"]}),I?e.jsx(W,{type:"button",isLoading:c,onClick:J,children:"Continue"}):e.jsxs(W,{type:"button",onClick:P,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(ur,{size:14})]})]}),u&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:u.message})})]}):null},Hr=({question:t,value:r,error:s,onChange:a})=>{var c;const o=(((c=t.defaultAnswers)==null?void 0:c.length)??0)>0?t.showAsDropdown?t.canMultipleAnswer?"multi-select":"single-select":t.canMultipleAnswer?"checkbox":"radio":"text";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.text,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.subtitle&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.subtitle}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.description}),o==="text"&&e.jsx(ne,{value:r[0]??"",onChange:u=>a([u.target.value]),placeholder:t.subtitle?void 0:"Enter your answer…",error:s,required:t.isRequired}),o==="single-select"&&e.jsx(Qe,{value:r[0]??"",onChange:u=>a([u.target.value]),options:(t.defaultAnswers??[]).map(u=>({value:u,label:u})),placeholder:"Select an option…",error:s,required:t.isRequired}),o==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(u=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===u,onChange:()=>a([u]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:u})]},u)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),(o==="checkbox"||o==="multi-select")&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(u=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(u),onChange:h=>{h.target.checked?a([...r,u]):a(r.filter(p=>p!==u))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:u})]},u)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),s&&o==="text"&&null]})},mr=({applicantId:t,onComplete:r,onBack:s})=>{const{uploadDocument:a,isLoading:i,isSubmitting:o,error:c,submit:u}=er(t),[h,p]=l.useState({}),v=async S=>{if(S.preventDefault(),!a)return;const y=await Promise.all(a.uploadDocumentFiles.map(async f=>{const F=h[f.id]||[],I=await Promise.all(F.map(async E=>({fileName:E.name,fileData:await Yt(E)})));return{uploadDocumentFileId:f.id,valueList:I}})),j={applicantId:t,uploadDocumentId:a.id,uploadDocumentResults:y};await u(j),r==null||r()};return i?e.jsx(_,{children:e.jsx(H,{children:e.jsx(ge,{className:"my-8"})})}):c?e.jsx(_,{children:e.jsx(H,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading document requirements: ",c.message]})})}):a?e.jsx("form",{onSubmit:v,children:e.jsxs(_,{children:[e.jsxs(ie,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.displayName}),a.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:a.subtitle})]}),e.jsx(H,{className:"space-y-6",children:a.uploadDocumentFiles.map(S=>e.jsx(ir,{label:S.displayName,accept:S.allowedTypes,multiple:S.multipleFile,maxSize:S.maxEachFileSizeByte,value:h[S.id]||[],onChange:y=>{p(j=>({...j,[S.id]:y}))}},S.id))}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(W,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(W,{type:"submit",isLoading:o,children:"Continue"})]})]})}):null},hr=({applicantId:t,onComplete:r,onBack:s})=>{const{overview:a,isLoading:i,isSubmitting:o,error:c,passOverview:u}=tr(t),h=async()=>{await u(),r==null||r()};return i?e.jsx(_,{children:e.jsx(H,{children:e.jsx(ge,{className:"my-8"})})}):c?e.jsx(_,{children:e.jsx(H,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading overview: ",c.message]})})}):a?e.jsxs(_,{children:[e.jsxs(ie,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.title||"Overview"}),a.description&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:a.description})]}),e.jsx(H,{className:"space-y-8",children:a.steps&&a.steps.length>0?a.steps.sort((p,v)=>p.order-v.order).map(p=>e.jsxs("div",{className:"metakyc-overview-step-item flex items-center space-x-3",children:[e.jsx("div",{className:"metakyc-step-icon flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary-500 text-white flex items-center justify-center font-medium text-sm",children:p.order+1})}),e.jsxs("div",{className:"metakyc-step-content",style:{flex:1,border:"none",height:"auto",background:"transparent"},children:[e.jsx("span",{className:"metakyc-step-title text-sm font-semibold text-gray-900 dark:text-white",children:p.title}),p.description&&e.jsx("p",{className:"metakyc-step-description text-sm text-gray-600 dark:text-gray-400",children:p.description})]})]},p.order)):e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Loading overview data..."})})}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(W,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(W,{onClick:h,isLoading:o,children:"Continue"})]})]}):null};function Ur(t){const r=(t??"en").toLowerCase().replace("_","-");try{return Intl.NumberFormat.supportedLocalesOf([r]),r}catch{return"en"}}function Kr(t){return t.valueDataType===be.Money&&Array.isArray(t.defaultValues)&&t.defaultValues.length>0}function Wr(t,r){const s=new Intl.NumberFormat(Ur(r),{minimumFractionDigits:0,maximumFractionDigits:2});return t.replace(/([\d]+(?:\.\d+)?)/g,a=>{const i=parseFloat(a);return isNaN(i)?a:s.format(i)})}function Yr(t,r){const s=!r||r.length===0||r.every(a=>!a||!a.trim());if(t.isRequired&&s)return t.errorMessage||`${t.displayName} is required`;if(!s){const a=r[0]??"";if(a&&t.regex)try{if(!new RegExp(t.regex).test(a))return t.errorMessage||"Invalid format"}catch{}const i=t.valueDataType===be.Integer||t.valueDataType===be.Money||t.valueDataType===be.DigitOnly;if(i&&a.trim()!==""){const o=Number(a);if(!isNaN(o)){if(t.min!==void 0&&t.min!==null&&o<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&o>t.max)return`Maximum value is ${t.max}`}}else if(!i&&a!==""){if(t.min!==void 0&&t.min!==null&&a.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&a.length>t.max)return`Maximum length is ${t.max} characters`}}return null}function qr(t){const r=new Map;return t.forEach((s,a)=>{const i=s.pageNumber!=null&&s.pageNumber>0?s.pageNumber:1;r.has(i)||r.set(i,[]),r.get(i).push({criterion:s,idx:a})}),Array.from(r.entries()).sort(([s],[a])=>s-a).map(([,s])=>s)}function Qr(t){return t.builtInType===1?"country":!t.defaultValues||t.defaultValues.length===0?"text":t.multipleValue?"checkbox":"radio"}const xr=({applicantId:t,onComplete:r,onBack:s})=>{const{config:a}=de(),i=a.locale??"en",{criteria:o,initialAnswers:c,isLoading:u,isSubmitting:h,error:p,submit:v}=sr(t),[S,y]=l.useState({}),[j,f]=l.useState({}),[F,I]=l.useState(0),[E,M]=l.useState(!1);l.useEffect(()=>{c&&Object.keys(c).length>0&&Object.keys(S).length===0&&y(c)},[c]);const A=l.useMemo(()=>o&&o.length>0?qr(o):[],[o]),P=F===A.length-1,Y=A[F]??[];l.useEffect(()=>{!u&&o&&o.length===0&&!E&&!h&&(M(!0),v({applicantId:t,criteriaValueInputs:[]}).then(()=>r==null?void 0:r()).catch(console.error))},[u,o,E,h,v,t,r]);const J=l.useCallback((k,z)=>{y(T=>({...T,[k]:z})),f(T=>{const D={...T};return delete D[k],D})},[]),R=l.useCallback(()=>{const k={};for(const{criterion:z}of Y){const T=Yr(z,S[z.id]??[]);T&&(k[z.id]=T)}return f(z=>({...z,...k})),Object.keys(k).length===0},[Y,S]),w=()=>{R()&&I(k=>k+1)},$=()=>{F>0?I(k=>k-1):s==null||s()},K=async()=>{if(!(!R()||!o))try{const k=o.map(T=>{const D=(S[T.id]??[]).filter(Q=>Q&&Q.trim());return D.length>0?{riskCriteriaId:T.id,values:D}:null}).filter(T=>T!==null);await v({applicantId:t,criteriaValueInputs:k}),r==null||r()}catch(k){console.error("Risk scoring submit error:",k)}};return u?e.jsx(_,{children:e.jsxs(H,{children:[e.jsx(ge,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading risk scoring criteria…"})]})}):!u&&o&&o.length===0?e.jsx(_,{children:e.jsxs(H,{children:[e.jsx(ge,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"No criteria required. Moving to next step…"})]})}):p?e.jsx(_,{children:e.jsx(H,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading criteria: ",p.message]})})}):o?e.jsxs(_,{children:[e.jsxs(ie,{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Risk Assessment"}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please answer the following questions for risk evaluation"}),A.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",F+1," of ",A.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:A.map((k,z)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:z===F?"20px":"6px",backgroundColor:z<=F?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},z))})]})]}),e.jsx(H,{className:"space-y-6",children:Y.map(({criterion:k})=>e.jsx(Gr,{criterion:k,value:S[k.id]??[],error:j[k.id],locale:i,onChange:z=>J(k.id,z)},k.id))}),e.jsxs(le,{className:"flex items-center justify-between",children:[e.jsxs(W,{type:"button",variant:"outline",onClick:$,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(dr,{size:14}),F>0?"Previous":"Back"]}),P?e.jsx(W,{type:"button",isLoading:h,onClick:K,children:"Continue"}):e.jsxs(W,{type:"button",onClick:w,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(ur,{size:14})]})]}),p&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:p.message})})]}):null},Gr=({criterion:t,value:r,error:s,locale:a,onChange:i})=>{const o=Qr(t),c=t.valueDataType===be.Integer||t.valueDataType===be.Money||t.valueDataType===be.DigitOnly,u=Kr(t),h=p=>u?Wr(p,a):p;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.displayName,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.description}),c&&(t.min!==void 0||t.max!==void 0)&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.min!==void 0&&t.max!==void 0?`Range: ${t.min} – ${t.max}`:t.min!==void 0?`Minimum: ${t.min}`:`Maximum: ${t.max}`}),o==="text"&&e.jsx(ne,{value:r[0]??"",onChange:p=>i([p.target.value]),type:c?"number":"text",placeholder:"Enter your answer…",error:s,required:t.isRequired,min:t.min,max:t.max,onKeyDown:p=>{t.valueDataType===be.DigitOnly&&["e","E","+","-","."].includes(p.key)&&p.preventDefault()}}),o==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(p=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===p,onChange:()=>i([p]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:h(p)})]},p)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),o==="checkbox"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(p=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(p),onChange:v=>{v.target.checked?i([...r,p]):i(r.filter(S=>S!==p))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:h(p)})]},p)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),o==="country"&&e.jsx(Qe,{value:r[0]??"",onChange:p=>i([p.target.value]),options:[{value:"US",label:"United States"},{value:"GB",label:"United Kingdom"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"AE",label:"United Arab Emirates"}],placeholder:"Select a country…",error:s,required:t.isRequired})]})},gr=({applicantId:t,onComplete:r,onBack:s})=>{const{investorCategorizationService:a}=de(),[i,o]=l.useState(null),[c,u]=l.useState(!1),[h,p]=l.useState(null),v=async S=>{if(S.preventDefault(),i===null){p("Please select an investor type");return}u(!0),p(null);try{const y={applicantId:t,investorType:i};console.log("Submitting investor categorization:",y);const j=await a.setInvestorCategorization(y);console.log("Investor categorization result:",j),r==null||r()}catch(y){console.error("Error submitting investor categorization:",y),p(y.message||"Failed to submit investor categorization")}finally{u(!1)}};return e.jsx("form",{onSubmit:v,children:e.jsxs(_,{children:[e.jsxs(ie,{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:"Which statement best describes you?"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:"All Tokenise clients are treated as Retail Investors under EU regulation, which gives you the highest level of investor protection. For our internal purposes, we ask you to select the description that best matches your situation"})]}),e.jsxs(H,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:"Choose one"}),e.jsx("label",{className:`
101
+ */const Br=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ur=cr("chevron-right",Br);function _r(t,r){const s=!r||r.length===0||r.every(a=>!a||!a.trim());if(t.isRequired&&s)return t.errorMessage||"This field is required";if(!s){const a=r[0]??"";if(a&&t.regex)try{if(!new RegExp(t.regex).test(a))return t.errorMessage||"Invalid format"}catch{}if(a!==""){const i=Number(a);if(!isNaN(i)&&a.trim()!==""){if(t.min!==void 0&&t.min!==null&&i<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&i>t.max)return`Maximum value is ${t.max}`}else{if(t.min!==void 0&&t.min!==null&&a.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&a.length>t.max)return`Maximum length is ${t.max} characters`}}}return null}function Hr(t){const r=t.flatMap((a,i)=>(a.questions??[]).map((o,c)=>({question:o,groupIndex:i,qIdx:c}))),s=new Map;for(const a of r){const i=a.question.pageNumber!=null&&a.question.pageNumber>0?a.question.pageNumber:1;s.has(i)||s.set(i,[]),s.get(i).push(a)}return Array.from(s.entries()).sort(([a],[i])=>a-i).map(([,a])=>a)}const pr=({applicantId:t,onComplete:r,onBack:s})=>{const{questionnaire:a,initialAnswers:i,isLoading:o,isSubmitting:c,error:u,submit:h}=Xt(t),[p,v]=l.useState({}),[S,g]=l.useState({}),[j,f]=l.useState(0);l.useEffect(()=>{i&&Object.keys(i).length>0&&Object.keys(p).length===0&&v(i)},[i]);const F=l.useMemo(()=>a?Hr(a.questionGroups):[],[a]),I=j===F.length-1,A=F[j]??[],M=l.useCallback((E,w)=>{v(B=>({...B,[E]:w})),g(B=>{const K={...B};return delete K[E],K})},[]),R=l.useCallback(()=>{const E={};for(const{question:w}of A){const B=_r(w,p[w.id]??[]);B&&(E[w.id]=B)}return g(w=>({...w,...E})),Object.keys(E).length===0},[A,p]),P=()=>{R()&&f(E=>E+1)},Y=()=>{j>0?f(E=>E-1):s==null||s()},J=async()=>{if(!(!R()||!a))try{const E=a.questionGroups.flatMap(B=>(B.questions??[]).map(K=>({questionId:K.id,values:p[K.id]??[]}))),w={applicantId:t,questionnarieId:a.id,questionResults:E};await h(w),r==null||r()}catch(E){console.error("Questionnaire submit error:",E)}};return o?e.jsx(_,{children:e.jsx(H,{children:e.jsx(ye,{className:"my-8"})})}):u?e.jsx(_,{children:e.jsx(H,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading questionnaire: ",u.message]})})}):a?e.jsxs(_,{children:[e.jsxs(ie,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.displayName}),a.subtitle&&e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a.subtitle}),F.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",j+1," of ",F.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:F.map((E,w)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:w===j?"20px":"6px",backgroundColor:w<=j?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},w))})]})]}),e.jsx(H,{className:"space-y-6",children:A.map(({question:E})=>e.jsx(Ur,{question:E,value:p[E.id]??[],error:S[E.id],onChange:w=>M(E.id,w)},E.id))}),e.jsxs(le,{className:"flex items-center justify-between",children:[e.jsxs(W,{type:"button",variant:"outline",onClick:Y,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(dr,{size:14}),j>0?"Previous":"Back"]}),I?e.jsx(W,{type:"button",isLoading:c,onClick:J,children:"Continue"}):e.jsxs(W,{type:"button",onClick:P,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(ur,{size:14})]})]}),u&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:u.message})})]}):null},Ur=({question:t,value:r,error:s,onChange:a})=>{var c;const o=(((c=t.defaultAnswers)==null?void 0:c.length)??0)>0?t.showAsDropdown?t.canMultipleAnswer?"multi-select":"single-select":t.canMultipleAnswer?"checkbox":"radio":"text";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.text,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.subtitle&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.subtitle}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.description}),o==="text"&&e.jsx(ne,{value:r[0]??"",onChange:u=>a([u.target.value]),placeholder:t.subtitle?void 0:"Enter your answer…",error:s,required:t.isRequired}),o==="single-select"&&e.jsx(Qe,{value:r[0]??"",onChange:u=>a([u.target.value]),options:(t.defaultAnswers??[]).map(u=>({value:u,label:u})),placeholder:"Select an option…",error:s,required:t.isRequired}),o==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(u=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===u,onChange:()=>a([u]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:u})]},u)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),(o==="checkbox"||o==="multi-select")&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(u=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(u),onChange:h=>{h.target.checked?a([...r,u]):a(r.filter(p=>p!==u))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:u})]},u)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),s&&o==="text"&&null]})},mr=({applicantId:t,onComplete:r,onBack:s})=>{const{uploadDocument:a,isLoading:i,isSubmitting:o,error:c,submit:u}=er(t),[h,p]=l.useState({}),v=async S=>{if(S.preventDefault(),!a)return;const g=await Promise.all(a.uploadDocumentFiles.map(async f=>{const F=h[f.id]||[],I=await Promise.all(F.map(async A=>({fileName:A.name,fileData:await Yt(A)})));return{uploadDocumentFileId:f.id,valueList:I}})),j={applicantId:t,uploadDocumentId:a.id,uploadDocumentResults:g};await u(j),r==null||r()};return i?e.jsx(_,{children:e.jsx(H,{children:e.jsx(ye,{className:"my-8"})})}):c?e.jsx(_,{children:e.jsx(H,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading document requirements: ",c.message]})})}):a?e.jsx("form",{onSubmit:v,children:e.jsxs(_,{children:[e.jsxs(ie,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.displayName}),a.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:a.subtitle})]}),e.jsx(H,{className:"space-y-6",children:a.uploadDocumentFiles.map(S=>e.jsx(ir,{label:S.displayName,accept:S.allowedTypes,multiple:S.multipleFile,maxSize:S.maxEachFileSizeByte,value:h[S.id]||[],onChange:g=>{p(j=>({...j,[S.id]:g}))}},S.id))}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(W,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(W,{type:"submit",isLoading:o,children:"Continue"})]})]})}):null},hr=({applicantId:t,onComplete:r,onBack:s})=>{const{overview:a,isLoading:i,isSubmitting:o,error:c,passOverview:u}=tr(t),h=async()=>{await u(),r==null||r()};return i?e.jsx(_,{children:e.jsx(H,{children:e.jsx(ye,{className:"my-8"})})}):c?e.jsx(_,{children:e.jsx(H,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading overview: ",c.message]})})}):a?e.jsxs(_,{children:[e.jsxs(ie,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.title||"Overview"}),a.description&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:a.description})]}),e.jsx(H,{className:"space-y-8",children:a.steps&&a.steps.length>0?a.steps.sort((p,v)=>p.order-v.order).map(p=>e.jsxs("div",{className:"metakyc-overview-step-item flex items-center space-x-3",children:[e.jsx("div",{className:"metakyc-step-icon flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary-500 text-white flex items-center justify-center font-medium text-sm",children:p.order+1})}),e.jsxs("div",{className:"metakyc-step-content",style:{flex:1,border:"none",height:"auto",background:"transparent"},children:[e.jsx("span",{className:"metakyc-step-title text-sm font-semibold text-gray-900 dark:text-white",children:p.title}),p.description&&e.jsx("p",{className:"metakyc-step-description text-sm text-gray-600 dark:text-gray-400",children:p.description})]})]},p.order)):e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Loading overview data..."})})}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(W,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(W,{onClick:h,isLoading:o,children:"Continue"})]})]}):null};function Kr(t){const r=(t??"en").toLowerCase().replace("_","-");try{return Intl.NumberFormat.supportedLocalesOf([r]),r}catch{return"en"}}function Wr(t){return t.valueDataType===be.Money&&Array.isArray(t.defaultValues)&&t.defaultValues.length>0}function Yr(t,r){const s=new Intl.NumberFormat(Kr(r),{minimumFractionDigits:0,maximumFractionDigits:2});return t.replace(/([\d]+(?:\.\d+)?)/g,a=>{const i=parseFloat(a);return isNaN(i)?a:s.format(i)})}function qr(t,r){const s=!r||r.length===0||r.every(a=>!a||!a.trim());if(t.isRequired&&s)return t.errorMessage||`${t.displayName} is required`;if(!s){const a=r[0]??"";if(a&&t.regex)try{if(!new RegExp(t.regex).test(a))return t.errorMessage||"Invalid format"}catch{}const i=t.valueDataType===be.Integer||t.valueDataType===be.Money||t.valueDataType===be.DigitOnly;if(i&&a.trim()!==""){const o=Number(a);if(!isNaN(o)){if(t.min!==void 0&&t.min!==null&&o<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&o>t.max)return`Maximum value is ${t.max}`}}else if(!i&&a!==""){if(t.min!==void 0&&t.min!==null&&a.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&a.length>t.max)return`Maximum length is ${t.max} characters`}}return null}function Qr(t){const r=new Map;return t.forEach((s,a)=>{const i=s.pageNumber!=null&&s.pageNumber>0?s.pageNumber:1;r.has(i)||r.set(i,[]),r.get(i).push({criterion:s,idx:a})}),Array.from(r.entries()).sort(([s],[a])=>s-a).map(([,s])=>s)}function Gr(t){return t.builtInType===1?"country":!t.defaultValues||t.defaultValues.length===0?"text":t.multipleValue?"checkbox":"radio"}const xr=({applicantId:t,onComplete:r,onBack:s})=>{const{config:a}=de(),i=a.locale??"en",{criteria:o,initialAnswers:c,isLoading:u,isSubmitting:h,error:p,submit:v}=sr(t),[S,g]=l.useState({}),[j,f]=l.useState({}),[F,I]=l.useState(0),[A,M]=l.useState(!1);l.useEffect(()=>{c&&Object.keys(c).length>0&&Object.keys(S).length===0&&g(c)},[c]);const R=l.useMemo(()=>o&&o.length>0?Qr(o):[],[o]),P=F===R.length-1,Y=R[F]??[];l.useEffect(()=>{!u&&o&&o.length===0&&!A&&!h&&(M(!0),v({applicantId:t,criteriaValueInputs:[]}).then(()=>r==null?void 0:r()).catch(console.error))},[u,o,A,h,v,t,r]);const J=l.useCallback((k,$)=>{g(T=>({...T,[k]:$})),f(T=>{const D={...T};return delete D[k],D})},[]),E=l.useCallback(()=>{const k={};for(const{criterion:$}of Y){const T=qr($,S[$.id]??[]);T&&(k[$.id]=T)}return f($=>({...$,...k})),Object.keys(k).length===0},[Y,S]),w=()=>{E()&&I(k=>k+1)},B=()=>{F>0?I(k=>k-1):s==null||s()},K=async()=>{if(!(!E()||!o))try{const k=o.map(T=>{const D=(S[T.id]??[]).filter(Q=>Q&&Q.trim());return D.length>0?{riskCriteriaId:T.id,values:D}:null}).filter(T=>T!==null);await v({applicantId:t,criteriaValueInputs:k}),r==null||r()}catch(k){console.error("Risk scoring submit error:",k)}};return u?e.jsx(_,{children:e.jsxs(H,{children:[e.jsx(ye,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading risk scoring criteria…"})]})}):!u&&o&&o.length===0?e.jsx(_,{children:e.jsxs(H,{children:[e.jsx(ye,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"No criteria required. Moving to next step…"})]})}):p?e.jsx(_,{children:e.jsx(H,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading criteria: ",p.message]})})}):o?e.jsxs(_,{children:[e.jsxs(ie,{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Risk Assessment"}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please answer the following questions for risk evaluation"}),R.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",F+1," of ",R.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:R.map((k,$)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:$===F?"20px":"6px",backgroundColor:$<=F?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},$))})]})]}),e.jsx(H,{className:"space-y-6",children:Y.map(({criterion:k})=>e.jsx(Vr,{criterion:k,value:S[k.id]??[],error:j[k.id],locale:i,onChange:$=>J(k.id,$)},k.id))}),e.jsxs(le,{className:"flex items-center justify-between",children:[e.jsxs(W,{type:"button",variant:"outline",onClick:B,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(dr,{size:14}),F>0?"Previous":"Back"]}),P?e.jsx(W,{type:"button",isLoading:h,onClick:K,children:"Continue"}):e.jsxs(W,{type:"button",onClick:w,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(ur,{size:14})]})]}),p&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:p.message})})]}):null},Vr=({criterion:t,value:r,error:s,locale:a,onChange:i})=>{const o=Gr(t),c=t.valueDataType===be.Integer||t.valueDataType===be.Money||t.valueDataType===be.DigitOnly,u=Wr(t),h=p=>u?Yr(p,a):p;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.displayName,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.description}),c&&(t.min!==void 0||t.max!==void 0)&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.min!==void 0&&t.max!==void 0?`Range: ${t.min} – ${t.max}`:t.min!==void 0?`Minimum: ${t.min}`:`Maximum: ${t.max}`}),o==="text"&&e.jsx(ne,{value:r[0]??"",onChange:p=>i([p.target.value]),type:c?"number":"text",placeholder:"Enter your answer…",error:s,required:t.isRequired,min:t.min,max:t.max,onKeyDown:p=>{t.valueDataType===be.DigitOnly&&["e","E","+","-","."].includes(p.key)&&p.preventDefault()}}),o==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(p=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===p,onChange:()=>i([p]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:h(p)})]},p)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),o==="checkbox"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(p=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(p),onChange:v=>{v.target.checked?i([...r,p]):i(r.filter(S=>S!==p))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:h(p)})]},p)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),o==="country"&&e.jsx(Qe,{value:r[0]??"",onChange:p=>i([p.target.value]),options:[{value:"US",label:"United States"},{value:"GB",label:"United Kingdom"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"AE",label:"United Arab Emirates"}],placeholder:"Select a country…",error:s,required:t.isRequired})]})},yr=({applicantId:t,onComplete:r,onBack:s})=>{const{investorCategorizationService:a}=de(),[i,o]=l.useState(null),[c,u]=l.useState(!1),[h,p]=l.useState(null),v=async S=>{if(S.preventDefault(),i===null){p("Please select an investor type");return}u(!0),p(null);try{const g={applicantId:t,investorType:i};console.log("Submitting investor categorization:",g);const j=await a.setInvestorCategorization(g);console.log("Investor categorization result:",j),r==null||r()}catch(g){console.error("Error submitting investor categorization:",g),p(g.message||"Failed to submit investor categorization")}finally{u(!1)}};return e.jsx("form",{onSubmit:v,children:e.jsxs(_,{children:[e.jsxs(ie,{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:"Which statement best describes you?"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:"All Tokenise clients are treated as Retail Investors under EU regulation, which gives you the highest level of investor protection. For our internal purposes, we ask you to select the description that best matches your situation"})]}),e.jsxs(H,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:"Choose one"}),e.jsx("label",{className:`
52
102
  block p-4 border-2 rounded-lg cursor-pointer transition-all
53
103
  ${i===pe.Individual?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}
54
104
  `,children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:pe.Individual,checked:i===pe.Individual,onChange:()=>o(pe.Individual),className:"mt-1 h-4 w-4 text-primary-500 border-gray-300 focus:ring-primary-500"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Individual investor"}),e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:"(Recommended) Most of our clients choose this option. Provides the strongest protection and aligns with our mission to make investing accessible to everyone."})]})]})}),e.jsx("label",{className:`
@@ -57,13 +107,13 @@
57
107
  `,children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:pe.Sophisticated,checked:i===pe.Sophisticated,onChange:()=>o(pe.Sophisticated),className:"mt-1 h-4 w-4 text-primary-500 border-gray-300 focus:ring-primary-500"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Sophisticated investor"}),e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:"In the last 2 years, I have done one or more of the following:"}),e.jsxs("ul",{className:"text-sm text-gray-600 dark:text-gray-400 mt-2 space-y-1 list-none",children:[e.jsx("li",{children:"Worked in private equity or provided capital to small and medium enterprises, and/or"}),e.jsx("li",{children:"Been the director of a company with an annual turnover of at least (USD) $2m million, and/or"}),e.jsx("li",{children:"Invested directly in at least 2 private (not listed) companies."})]})]})]})}),e.jsx("label",{className:`
58
108
  block p-4 border-2 rounded-lg cursor-pointer transition-all
59
109
  ${i===pe.HighNetWorth?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}
60
- `,children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:pe.HighNetWorth,checked:i===pe.HighNetWorth,onChange:()=>o(pe.HighNetWorth),className:"mt-1 h-4 w-4 text-primary-500 border-gray-300 focus:ring-primary-500"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"High networth investor"}),e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:["I earn more than (USD/EUR) $150,000 per year, and/or",e.jsx("br",{}),"I have net assets (excluding my main property) of at least $/EUR 300,000"]})]})]})}),h&&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:"})," ",h]})})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(W,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(W,{type:"submit",isLoading:c,disabled:i===null,children:"Submit"})]})]})})},yr=({applicantId:t,onComplete:r,onBack:s})=>{const{appropriatenessTestService:a}=de(),[i,o]=l.useState(null),[c,u]=l.useState(!0),[h,p]=l.useState(!1),[v,S]=l.useState(null),[y,j]=l.useState({}),[f,F]=l.useState(0),[I,E]=l.useState(!1),[M,A]=l.useState(!1),[P,Y]=l.useState(0);l.useEffect(()=>{(async()=>{try{u(!0),S(null),console.log("Loading appropriateness test for applicant:",t);const D=await a.getAppropriatenessTest(t);if(console.log("Appropriateness test data:",D),o(D),D.waitTimeSpanForNextTry&&D.waitTimeSpanForNextTry!=="00:00:00"){const Q=J(D.waitTimeSpanForNextTry);Q>0&&Y(Q)}}catch(D){console.error("Error loading appropriateness test:",D),S(D.message||"Failed to load appropriateness test")}finally{u(!1)}})()},[t,a]);const J=T=>{const D=T.split(":").map(Number);if(D.length===3){const[Q,C,U]=D;return Q*3600+C*60+U}return 0},R=T=>{const D=Math.floor(T/60),Q=T%60;return`${D.toString().padStart(2,"0")}:${Q.toString().padStart(2,"0")}`};l.useEffect(()=>{if(!I||f<=0)return;const T=setInterval(()=>{F(D=>D<=1?(A(!0),0):D-1)},1e3);return()=>clearInterval(T)},[I,f]),l.useEffect(()=>{if(P<=0)return;const T=setInterval(()=>{Y(D=>D<=1?0:D-1)},1e3);return()=>clearInterval(T)},[P]),l.useEffect(()=>{M&&!h&&K()},[M]);const w=()=>{i&&(E(!0),F(i.testDurationSec))},$=(T,D)=>{j(Q=>({...Q,[T]:D}))},K=async T=>{if(T&&T.preventDefault(),!!i){if(!M){const D=i.appropriatenessQuestions.length-Object.keys(y).length;if(D>0){S(`Please answer all questions. ${D} question(s) remaining.`);return}}p(!0),S(null);try{const D=i.appropriatenessQuestions.map(C=>({appropriatenessQuestionId:C.id,value:y[C.id]||""})),Q={applicantId:t,appropriatenessTestId:i.id,appropriatenessQuestionResults:D};console.log("Submitting appropriateness test:",Q);try{const C=await a.fillAppropriatenessTest(Q);console.log("Appropriateness test result:",C),C.message&&(C.message.toLowerCase().includes("pass")||C.message.toLowerCase().includes("success")||C.message.toLowerCase().includes("congratulations"))?r==null||r():(S(C.message||"Test completed. Please check the result."),E(!1),A(!1),j({}),setTimeout(()=>k(),1e3))}catch(C){if(C.code===400&&C.message){const U=C.message;console.log("Test failed:",U),S(U),E(!1),A(!1),j({}),setTimeout(()=>k(),1500)}else throw C}}catch(D){console.error("Error submitting appropriateness test:",D),S(D.message||"Failed to submit test. Please try again."),E(!1),A(!1),j({})}finally{p(!1)}}},k=async()=>{try{const T=await a.getAppropriatenessTest(t);if(console.log("Reloaded test data:",T),o(T),T.waitTimeSpanForNextTry&&T.waitTimeSpanForNextTry!=="00:00:00"){const D=J(T.waitTimeSpanForNextTry);D>0&&Y(D)}}catch(T){console.error("Error reloading test data:",T),S(D=>D+`
110
+ `,children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:pe.HighNetWorth,checked:i===pe.HighNetWorth,onChange:()=>o(pe.HighNetWorth),className:"mt-1 h-4 w-4 text-primary-500 border-gray-300 focus:ring-primary-500"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"High networth investor"}),e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:["I earn more than (USD/EUR) $150,000 per year, and/or",e.jsx("br",{}),"I have net assets (excluding my main property) of at least $/EUR 300,000"]})]})]})}),h&&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:"})," ",h]})})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(W,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(W,{type:"submit",isLoading:c,disabled:i===null,children:"Submit"})]})]})})},gr=({applicantId:t,onComplete:r,onBack:s})=>{const{appropriatenessTestService:a}=de(),[i,o]=l.useState(null),[c,u]=l.useState(!0),[h,p]=l.useState(!1),[v,S]=l.useState(null),[g,j]=l.useState({}),[f,F]=l.useState(0),[I,A]=l.useState(!1),[M,R]=l.useState(!1),[P,Y]=l.useState(0);l.useEffect(()=>{(async()=>{try{u(!0),S(null),console.log("Loading appropriateness test for applicant:",t);const D=await a.getAppropriatenessTest(t);if(console.log("Appropriateness test data:",D),o(D),D.waitTimeSpanForNextTry&&D.waitTimeSpanForNextTry!=="00:00:00"){const Q=J(D.waitTimeSpanForNextTry);Q>0&&Y(Q)}}catch(D){console.error("Error loading appropriateness test:",D),S(D.message||"Failed to load appropriateness test")}finally{u(!1)}})()},[t,a]);const J=T=>{const D=T.split(":").map(Number);if(D.length===3){const[Q,C,U]=D;return Q*3600+C*60+U}return 0},E=T=>{const D=Math.floor(T/60),Q=T%60;return`${D.toString().padStart(2,"0")}:${Q.toString().padStart(2,"0")}`};l.useEffect(()=>{if(!I||f<=0)return;const T=setInterval(()=>{F(D=>D<=1?(R(!0),0):D-1)},1e3);return()=>clearInterval(T)},[I,f]),l.useEffect(()=>{if(P<=0)return;const T=setInterval(()=>{Y(D=>D<=1?0:D-1)},1e3);return()=>clearInterval(T)},[P]),l.useEffect(()=>{M&&!h&&K()},[M]);const w=()=>{i&&(A(!0),F(i.testDurationSec))},B=(T,D)=>{j(Q=>({...Q,[T]:D}))},K=async T=>{if(T&&T.preventDefault(),!!i){if(!M){const D=i.appropriatenessQuestions.length-Object.keys(g).length;if(D>0){S(`Please answer all questions. ${D} question(s) remaining.`);return}}p(!0),S(null);try{const D=i.appropriatenessQuestions.map(C=>({appropriatenessQuestionId:C.id,value:g[C.id]||""})),Q={applicantId:t,appropriatenessTestId:i.id,appropriatenessQuestionResults:D};console.log("Submitting appropriateness test:",Q);try{const C=await a.fillAppropriatenessTest(Q);console.log("Appropriateness test result:",C),C.message&&(C.message.toLowerCase().includes("pass")||C.message.toLowerCase().includes("success")||C.message.toLowerCase().includes("congratulations"))?r==null||r():(S(C.message||"Test completed. Please check the result."),A(!1),R(!1),j({}),setTimeout(()=>k(),1e3))}catch(C){if(C.code===400&&C.message){const U=C.message;console.log("Test failed:",U),S(U),A(!1),R(!1),j({}),setTimeout(()=>k(),1500)}else throw C}}catch(D){console.error("Error submitting appropriateness test:",D),S(D.message||"Failed to submit test. Please try again."),A(!1),R(!1),j({})}finally{p(!1)}}},k=async()=>{try{const T=await a.getAppropriatenessTest(t);if(console.log("Reloaded test data:",T),o(T),T.waitTimeSpanForNextTry&&T.waitTimeSpanForNextTry!=="00:00:00"){const D=J(T.waitTimeSpanForNextTry);D>0&&Y(D)}}catch(T){console.error("Error reloading test data:",T),S(D=>D+`
61
111
 
62
- Failed to reload test data. Please refresh the page.`)}};if(c)return e.jsx(_,{children:e.jsxs(H,{children:[e.jsx(ge,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading appropriateness test..."})]})});if(!i)return e.jsx(_,{children:e.jsxs(H,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-danger-500 text-lg mb-4",children:"No test data available"}),v&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:v})]})});if(P>0)return e.jsxs(_,{children:[e.jsxs(ie,{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:i.displayName}),i.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:i.subtitle})]}),e.jsxs(H,{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:R(P)}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please wait before attempting the test again"})]}),v&&e.jsx("div",{className:"mt-4 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsx("p",{className:"text-red-600 dark:text-red-400 text-sm",children:v})})]})]});const z=i.testAllowedMaxTry-i.totalFailedTries;return I?e.jsx("form",{onSubmit:K,children:e.jsxs(_,{children:[e.jsx(ie,{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:i.displayName}),i.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:i.subtitle})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:`text-3xl font-bold ${f<=60?"text-danger-500":"text-primary-500"}`,children:R(f)}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Time Remaining"})]})]})}),e.jsxs(H,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs(ve,{variant:"info",children:["Question ",Object.keys(y).length," of ",i.totalQuestionCount]}),e.jsxs(ve,{variant:z>1?"success":"warning",children:[z," attempt",z!==1?"s":""," remaining"]})]}),i.appropriatenessQuestions.map((T,D)=>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 ",D+1]}),T.groupName&&e.jsx("span",{className:"ml-2 text-xs text-gray-500 dark:text-gray-400",children:T.groupName}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mt-2",children:T.question})]}),e.jsx("div",{className:"space-y-2",children:T.answers.map((Q,C)=>e.jsxs("label",{className:`
112
+ Failed to reload test data. Please refresh the page.`)}};if(c)return e.jsx(_,{children:e.jsxs(H,{children:[e.jsx(ye,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading appropriateness test..."})]})});if(!i)return e.jsx(_,{children:e.jsxs(H,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-danger-500 text-lg mb-4",children:"No test data available"}),v&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:v})]})});if(P>0)return e.jsxs(_,{children:[e.jsxs(ie,{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:i.displayName}),i.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:i.subtitle})]}),e.jsxs(H,{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:E(P)}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please wait before attempting the test again"})]}),v&&e.jsx("div",{className:"mt-4 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsx("p",{className:"text-red-600 dark:text-red-400 text-sm",children:v})})]})]});const $=i.testAllowedMaxTry-i.totalFailedTries;return I?e.jsx("form",{onSubmit:K,children:e.jsxs(_,{children:[e.jsx(ie,{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:i.displayName}),i.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:i.subtitle})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:`text-3xl font-bold ${f<=60?"text-danger-500":"text-primary-500"}`,children:E(f)}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Time Remaining"})]})]})}),e.jsxs(H,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs(ve,{variant:"info",children:["Question ",Object.keys(g).length," of ",i.totalQuestionCount]}),e.jsxs(ve,{variant:$>1?"success":"warning",children:[$," attempt",$!==1?"s":""," remaining"]})]}),i.appropriatenessQuestions.map((T,D)=>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 ",D+1]}),T.groupName&&e.jsx("span",{className:"ml-2 text-xs text-gray-500 dark:text-gray-400",children:T.groupName}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mt-2",children:T.question})]}),e.jsx("div",{className:"space-y-2",children:T.answers.map((Q,C)=>e.jsxs("label",{className:`
63
113
  flex items-center p-3 border-2 rounded-lg cursor-pointer transition-all
64
- ${y[T.id]===Q?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}
65
- `,children:[e.jsx("input",{type:"radio",name:`question-${T.id}`,value:Q,checked:y[T.id]===Q,onChange:U=>$(T.id,U.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:Q})]},C))})]},T.id)),v&&!M&&e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsxs("p",{className:"text-red-600 dark:text-red-400 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",v]})}),M&&e.jsx("div",{className:"p-4 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-700 dark:text-yellow-400 text-sm",children:[e.jsx("strong",{children:"Time's up!"})," Your answers are being submitted automatically."]})})]}),e.jsxs(le,{className:"flex justify-between",children:[e.jsx(W,{type:"button",variant:"outline",onClick:s,disabled:h,children:"Cancel"}),e.jsx(W,{type:"submit",isLoading:h,disabled:Object.keys(y).length<i.totalQuestionCount,children:M?"Submitting...":"Submit Test"})]})]})}):e.jsxs(_,{children:[e.jsxs(ie,{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:i.displayName}),i.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:i.subtitle})]}),e.jsxs(H,{children:[i.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:i.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(ve,{variant:"info",children:i.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(ve,{variant:"info",children:R(i.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(ve,{variant:"info",children:i.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(ve,{variant:z>1?"success":"warning",children:z})]})]}),v&&e.jsx("div",{className:"mb-4 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsxs("p",{className:"text-red-600 dark:text-red-400 text-sm",children:[e.jsx("strong",{children:"Previous Attempt:"})," ",v]})}),z<=0&&e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsx("p",{className:"text-red-600 dark:text-red-400",children:"You have used all your attempts. Please contact support for assistance."})})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(W,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(W,{type:"button",onClick:w,disabled:z<=0,children:"Start Test"})]})]})},fr=({applicantId:t,onComplete:r,onBack:s})=>{var Me,Oe,ze,Be;const{applicantService:a,baseInformationService:i,config:o,currentTheme:c}=de(),{identityData:u,provider:h,token:p,isLoading:v,error:S,requestIdentity:y,restartIdentity:j}=rr(t),[f,F]=l.useState(null),[I,E]=l.useState(null),[M,A]=l.useState([]),[P,Y]=l.useState([]),[J,R]=l.useState(!0),[w,$]=l.useState(!1),[K,k]=l.useState(null),[z,T]=l.useState(!1),D=l.useRef(!1),[Q,C]=l.useState({}),[U,Z]=l.useState({}),me=c!=null&&c.reviewPageFields&&c.reviewPageFields.length>0?c.reviewPageFields[0]:null,se=!!(c!=null&&c.reviewPageDisabled),L=l.useRef(!1);L.current=se;const V=Se.useForm({defaultValues:{street:"",streetNumber:"",city:"",zip:"",country:"",nationality:"",phonenumber:""}});l.useEffect(()=>{if(se){D.current||(D.current=!0,y().then(()=>$(!0)).catch(x=>console.error("[Identity] Auto-request failed:",x)).finally(()=>R(!1)));return}(async()=>{try{const[x,b,d]=await Promise.all([a.getApplicantData(t),i.getCountries("","en"),i.getCountries("","en",40)]);E(x);const m=new Set,N=b.map(q=>({value:q.abbreviation3||q.abbreviation,label:q.name})).filter(q=>!q.value||m.has(q.value)?!1:(m.add(q.value),!0));A(N);const O=new Set,B=d.filter(q=>q.countryCode).map(q=>({value:q.countryCode,label:`${q.countryCode} – ${q.name}`})).filter(q=>O.has(q.value)?!1:(O.add(q.value),!0));Y(B);const g=x.applicantRequestData;if(C({firstName:(g==null?void 0:g.firstName)||"",lastName:(g==null?void 0:g.lastName)||"",email:(g==null?void 0:g.email)||"",dateOfBirth:(g==null?void 0:g.dateOfBirth)||"",title:(g==null?void 0:g.title)||"",salutation:(g==null?void 0:g.salutation)||"",phonenumber:(g==null?void 0:g.phonenumber)||"",mobileCountryCode:(g==null?void 0:g.mobileCountryCode)||"",street:(g==null?void 0:g.street)||"",streetNumber:(g==null?void 0:g.streetNumber)||"",city:(g==null?void 0:g.city)||"",zip:(g==null?void 0:g.zip)||"",country:(g==null?void 0:g.country)||"",nationality:(g==null?void 0:g.nationality)||"",taxCountry:(g==null?void 0:g.taxCountry)||"",countryOfBirth:(g==null?void 0:g.countryOfBirth)||"",placeOfBirth:(g==null?void 0:g.placeOfBirth)||"",educationLevel:(g==null?void 0:g.educationLevel)||"",occupation:(g==null?void 0:g.occupation)||"",taxNumber:(g==null?void 0:g.taxNumber)||"",defaultLanguage:(g==null?void 0:g.defaultLanguage)||""}),V.reset({street:(g==null?void 0:g.street)||"",streetNumber:(g==null?void 0:g.streetNumber)||"",city:(g==null?void 0:g.city)||"",zip:(g==null?void 0:g.zip)||"",country:(g==null?void 0:g.country)||"",nationality:(g==null?void 0:g.nationality)||"",phonenumber:(g==null?void 0:g.phonenumber)||""}),x.kycRecords&&x.kycRecords.length>0&&x.kycRecords[0].providerTokenObject!==null&&!D.current&&L.current){console.log("[Identity] Review page disabled + existing identity — auto-requesting..."),D.current=!0;try{await y(),$(!0)}catch(q){console.error("[Identity] Auto-request failed:",q)}}}catch(x){console.error("Error loading applicant data:",x)}finally{R(!1)}})()},[t]),l.useEffect(()=>{u&&!w&&L.current&&(console.log("[Identity] Review page disabled — showing cached provider"),$(!0))},[u,w]),l.useEffect(()=>{if(p){if(p.expiresAt){const n=new Date(p.expiresAt).getTime();if(Date.now()>=n){console.warn("[Identity] Token has expired (expiresAt)"),T(!0),k("Your verification session has expired. Please restart.");return}}if(p.url)try{const x=new URL(p.url).toString().toLowerCase();if(x.includes("expired")||x.includes("invalid")||x.includes("error")){console.warn("[Identity] Token URL indicates expiration"),T(!0),k("Your verification link has expired. Please restart.");return}}catch{console.error("[Identity] Invalid token URL")}if(p.status==="expired"||p.error==="expired"||p.expired===!0){console.warn("[Identity] Token object indicates expiration"),T(!0),k("Your verification session has expired. Please restart.");return}}},[p]),l.useEffect(()=>{if(h!==null&&p&&!f&&w&&!z){const n=h;if(p.url){console.log("[Identity] Loading provider URL for user verification:",p.url),k(null);try{if(new URL(p.url),n===he.SardinAI){console.log("[SardinAI] Initializing Risk SDK in background...");try{const x=Pe.parseProviderConfig(h,p,o);Pe.createProvider(h,x).initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully in background")}).catch(d=>{console.warn("[SardinAI] Risk SDK initialization failed (non-blocking):",d)})}catch(x){console.warn("[SardinAI] Risk SDK setup failed (non-blocking):",x)}}F({type:"url",url:p.url})}catch(x){console.error("[Identity] Invalid URL:",x),k("Invalid verification URL. Please restart."),T(!0)}return}if(n===he.SardinAI){console.log("[SardinAI] No URL provided - initializing Risk SDK only..."),k(null);try{const x=Pe.parseProviderConfig(h,p,o),b=Pe.createProvider(h,x);b.initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully"),F(b),setTimeout(()=>{r==null||r()},2e3)}).catch(d=>{var N;console.error("[SardinAI] Failed to initialize:",d);const m=((N=d.message)==null?void 0:N.toLowerCase())||"";m.includes("expired")||m.includes("invalid")||m.includes("401")||m.includes("400")?(T(!0),k("Session expired or invalid. Please restart verification.")):k(`Failed to initialize: ${d.message}`)})}catch(x){console.error("[SardinAI] Error creating provider:",x),k(`Configuration error: ${x.message}`)}return}try{k(null);const x=Pe.parseProviderConfig(h,p,o),b=Pe.createProvider(h,x);n===he.Sumsub?(b.initialize("identity-container").catch(d=>{var m;console.error("[Sumsub] Initialization error:",d),k(`Failed to initialize: ${d.message}`),(m=d.message)!=null&&m.toLowerCase().includes("expired")&&T(!0)}),b.onComplete&&b.onComplete(()=>{r==null||r()})):n===he.Onfido&&b.initialize("identity-container").catch(d=>{console.error("[Onfido] Initialization error:",d),k(`Failed to initialize: ${d.message}`)}),F(b)}catch(x){console.error("[Identity] Provider setup error:",x),k(`Setup error: ${x.message}`)}}return()=>{if(f&&f.destroy)try{f.destroy()}catch(n){console.error("[Identity] Error destroying provider:",n)}}},[h,p,f,w,r,z]);const te=async()=>{try{k(null),T(!1),await y(),$(!0)}catch(n){console.error("Error starting identity verification:",n)}},je=async()=>{try{k(null),T(!1),F(null),console.log("[Identity] Restarting verification..."),await j(),$(!0)}catch(n){console.error("Error restarting identity verification:",n),k(n.message||"Failed to restart verification")}};if(J||v)return e.jsx(_,{children:e.jsxs(H,{children:[e.jsx(ge,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading identity verification..."})]})});if(S)return e.jsx(_,{children:e.jsx(H,{children:e.jsxs("p",{className:"text-danger-500",children:["Error: ",S.message]})})});if(w&&(K||z))return e.jsxs(_,{children:[e.jsx(ie,{children:e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Verification Session Issue"})}),e.jsxs(H,{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:z?"Session Expired":"Verification Error"}),e.jsx("p",{className:"text-red-800 dark:text-red-200 text-sm",children:K||"Your verification session has expired and needs to be restarted."})]})]})}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What to do next:"}),e.jsxs("ul",{className:"text-blue-800 dark:text-blue-200 text-sm space-y-1 list-disc list-inside",children:[e.jsx("li",{children:'Click "Restart Verification" below to generate a new session'}),e.jsx("li",{children:"Complete the verification process without delays"}),e.jsx("li",{children:"If issues persist, contact support"})]})]})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(W,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(W,{type:"button",onClick:je,disabled:v,children:v?"Restarting...":"Restart Verification"})]})]});if(w&&u){const n=h;return p!=null&&p.url?e.jsxs(_,{children:[e.jsx(ie,{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(W,{type:"button",variant:"outline",size:"sm",onClick:je,disabled:v,children:"Restart"})]})}),e.jsxs(H,{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:p.url,className:"w-full h-full border-0 rounded-lg",allow:"camera; microphone; geolocation",title:"Identity Verification",onLoad:x=>{var b,d,m;console.log("[Identity] Iframe loaded");try{const N=x.target,O=N.contentDocument||((b=N.contentWindow)==null?void 0:b.document);if(O){const B=((m=(d=O.body)==null?void 0:d.textContent)==null?void 0:m.toLowerCase())||"";(B.includes("expired")||B.includes("invalid")||B.includes("error"))&&(console.warn("[Identity] Iframe shows expiration message"),T(!0),k("Your verification link has expired."))}}catch{console.log("[Identity] Cannot check iframe content (CORS)")}}})})]}),s&&e.jsx(le,{children:e.jsx(W,{variant:"outline",onClick:s,children:"Back"})})]}):n===he.SardinAI?e.jsxs(_,{children:[e.jsxs(ie,{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(H,{children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(ge,{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(_,{children:[e.jsxs(ie,{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(H,{children:e.jsx("div",{id:"identity-container",className:"min-h-[400px]"})}),s&&e.jsx(le,{children:e.jsx(W,{variant:"outline",onClick:s,children:"Back"})})]})}const Ae=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),ue=(n=4)=>({1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4"})[n]||"col-span-4",Te=(n,x)=>{if(!x&&x!==0)return"—";if(Ae.has(n)&&n!=="mobileCountryCode"){const b=M.find(d=>d.value===x);return b?b.label:String(x)}return String(x)},Ge=({helpText:n})=>{const[x,b]=l.useState(!1),d=l.useRef(null),[,m]=l.useState({top:0,left:0}),N=()=>{if(d.current){const O=d.current.getBoundingClientRect();m({top:O.bottom+window.scrollY+6,left:O.left+window.scrollX})}b(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",ref:d,onClick:N,style:{width:18,height:18,borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #6366f1)",background:"transparent",color:"var(--metakyc-primary, #6366f1)",fontSize:11,fontWeight:700,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:1},children:"?"}),x&&qe.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.25)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>b(!1),children:e.jsxs("div",{onClick:O=>O.stopPropagation(),style:{background:"var(--metakyc-surface, #fff)",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 8px)",padding:"16px 20px",maxWidth:400,width:"90%",boxShadow:"0 10px 30px rgba(0,0,0,0.15)"},children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:n},style:{fontSize:13,color:"var(--metakyc-text-primary, #111827)",lineHeight:1.6}}),e.jsx("button",{type:"button",onClick:()=>b(!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)]})},ye=(n,x)=>x?e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:5,flexWrap:"nowrap"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:n}),e.jsx("div",{style:{paddingTop:24},children:e.jsx(Ge,{helpText:x})})]}):n,Ve=(n,x)=>{const b=`cf-${x}`,d=n.paramName??"",m=U[d];if(n.customType==="br")return e.jsx("div",{className:ue(n.colSpan),style:{minHeight:"0.5rem"}},b);if(n.customType==="paragraph")return e.jsx("div",{className:ue(n.colSpan),children:e.jsx("div",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:n.label||""}})},b);if(n.customType==="html")return e.jsx("div",{className:ue(n.colSpan),dangerouslySetInnerHTML:{__html:n.label||""}},b);if(n.customType==="link")return e.jsx("div",{className:ue(n.colSpan),children:ye(e.jsx("a",{href:n.linkUrl??"#",target:"_blank",rel:"noopener noreferrer",className:"text-sm underline",style:{color:"var(--metakyc-primary, #6366f1)"},children:n.displayText||n.label||n.linkText||n.linkUrl}),n.helpText)},b);if(n.customType==="checkbox"||n.customType==="link_checkbox"){const N=m==="true"||m===!0;return e.jsx("div",{className:ue(n.colSpan),children:ye(e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!N,onChange:O=>Z(B=>({...B,[d]:String(O.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:n.customType==="link_checkbox"&&n.linkUrl?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:n.linkUrl,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #6366f1)",textDecoration:"underline"},children:n.linkText||n.label}),n.label&&n.linkText?` ${n.label}`:""]}):n.displayText||n.label})]}),n.helpText)},b)}if(n.customType==="group_checkbox"){const N=Array.isArray(m)?m:m?[m]:[],O=B=>{n.singleSelect?Z(g=>({...g,[d]:N[0]===B?[]:[B]})):Z(g=>({...g,[d]:N.includes(B)?N.filter(ee=>ee!==B):[...N,B]}))};return e.jsx("div",{className:ue(n.colSpan),children:ye(e.jsxs("div",{className:"space-y-1.5",children:[n.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:n.displayText||n.label}),(n.options||[]).map(B=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:N.includes(B.value),onChange:()=>O(B.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:B.label})]},B.value))]}),n.helpText)},b)}return n.customType==="radio_group"?e.jsx("div",{className:ue(n.colSpan),children:ye(e.jsxs("div",{className:"space-y-1.5",children:[n.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:n.displayText||n.label}),(n.options||[]).map(N=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"radio",name:`rg-${d}`,value:N.value,checked:m===N.value,onChange:()=>Z(O=>({...O,[d]:N.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:N.label})]},N.value))]}),n.helpText)},b):e.jsx("div",{className:ue(n.colSpan),children:ye(e.jsx(ne,{label:n.displayText||n.label||d,value:String(m??""),onChange:N=>Z(O=>({...O,[d]:N.target.value}))}),n.helpText)},b)},Je=(n,x)=>{if(n.isCustom)return Ve(n,x);const b=n.name??"",d=Re[b],m=n.displayText||(d==null?void 0:d.label)||b,N=Q[b]??"",O=b==="mobileCountryCode",B=!!(d!=null&&d.countriesType)&&!O;return n.editable?O?e.jsx("div",{className:ue(n.colSpan??2),children:ye(e.jsx(ke,{label:m,value:String(N),onChange:g=>C(ee=>({...ee,[b]:g})),options:[{value:"",label:"Select country code…"},...P]}),n.helpText)},`epc-${x}`):B?e.jsx("div",{className:ue(n.colSpan??2),children:ye(e.jsx(ke,{label:m,value:String(N),onChange:g=>C(ee=>({...ee,[b]:g})),options:[{value:"",label:`Select ${m.toLowerCase()}…`},...M]}),n.helpText)},`ec-${x}`):e.jsx("div",{className:ue(n.colSpan??2),children:ye(e.jsx(ne,{label:m,type:(d==null?void 0:d.type)==="date"?"date":(d==null?void 0:d.type)==="email"?"email":"text",value:String(N),onChange:g=>C(ee=>({...ee,[b]:g.target.value}))}),n.helpText)},`ei-${x}`):e.jsx("div",{className:ue(n.colSpan??2),children:ye(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:m}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)",minHeight:"1.5rem"},children:Te(b,N)})]}),n.helpText)},`ro-${x}`)};if(me){const n=me.title||"Review Your Information",x=me.subtitle||"Please review and confirm your information before starting identity verification";return e.jsx("form",{onSubmit:b=>{b.preventDefault(),te()},children:e.jsxs(_,{children:[e.jsxs(ie,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:n}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:x})]}),e.jsx(H,{children:e.jsx("div",{className:"grid grid-cols-4 gap-4",children:me.fields.map((b,d)=>Je(b,d))})}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(W,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(W,{type:"submit",isLoading:v,children:"Confirm and Start Verification"})]})]})})}return e.jsx("form",{onSubmit:V.handleSubmit(te),children:e.jsxs(_,{children:[e.jsxs(ie,{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(H,{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:`${((Me=I==null?void 0:I.applicantRequestData)==null?void 0:Me.firstName)||""} ${((Oe=I==null?void 0:I.applicantRequestData)==null?void 0:Oe.lastName)||""}`.trim()},{label:"Email",value:(ze=I==null?void 0:I.applicantRequestData)==null?void 0:ze.email},{label:"Date of Birth",value:((Be=I==null?void 0:I.applicantRequestData)==null?void 0:Be.dateOfBirth)||"Not provided"}].map(({label:n,value:x})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:n}),e.jsx("p",{className:"mt-1 text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:x})]},n))}),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(Se.Controller,{control:V.control,name:"country",render:({field:n})=>e.jsx(ke,{label:"Country",value:n.value,onChange:n.onChange,options:[{value:"",label:"Select country…"},...M]})}),e.jsx(Se.Controller,{control:V.control,name:"nationality",render:({field:n})=>e.jsx(ke,{label:"Nationality",value:n.value,onChange:n.onChange,options:[{value:"",label:"Select nationality…"},...M]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Se.Controller,{control:V.control,name:"street",render:({field:n})=>e.jsx(ne,{...n,label:"Street"})}),e.jsx(Se.Controller,{control:V.control,name:"streetNumber",render:({field:n})=>e.jsx(ne,{...n,label:"Street Number"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Se.Controller,{control:V.control,name:"city",render:({field:n})=>e.jsx(ne,{...n,label:"City"})}),e.jsx(Se.Controller,{control:V.control,name:"zip",render:({field:n})=>e.jsx(ne,{...n,label:"ZIP / Postal Code"})})]}),e.jsx(Se.Controller,{control:V.control,name:"phonenumber",render:({field:n})=>e.jsx(ne,{...n,label:"Phone Number",type:"tel"})})]})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(W,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(W,{type:"submit",isLoading:v,children:"Confirm and Start Verification"})]})]})})},Xe=({kycStatus:t,reviewStatus:r,workflowResult:s,customMessage:a,onContinue:i,onContactSupport:o})=>{const u=t===Ne.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===Ne.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===Ne.Pending||t===Ne.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===Ce.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===Ce.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===Ce.UnderReview||r===Ce.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===He.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===He.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===He.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(_,{children:[e.jsxs(H,{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(ve,{variant:u.type==="success"?"success":u.type==="error"?"danger":u.type==="pending"?"warning":"info",children:t!=null?Ne[t]:Ce[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?Ne[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:Ce[r]})]})]})})]}),e.jsxs(le,{className:"flex justify-center gap-4",children:[u.type==="success"&&i&&e.jsx(W,{onClick:i,size:"lg",children:"Continue"}),u.type==="error"&&e.jsxs(e.Fragment,{children:[o&&e.jsx(W,{variant:"outline",onClick:o,children:"Contact Support"}),i&&e.jsx(W,{onClick:i,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"})})]})]})},br=({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"}})}),Ye=({title:t,subtitle:r,className:s=""})=>{const{currentTheme:a}=de(),i=t||(a==null?void 0:a.title)||"",o=!!(a!=null&&a.logo&&a.logo.visible&&a.logo.url),c=!!i;return!o&&!c?null:e.jsxs("div",{className:`metakyc-header ${s}`,children:[e.jsxs("div",{className:"metakyc-header-title flex items-center text-xl font-bold text-gray-900 dark:text-white",children:[o&&e.jsx(br,{config:a.logo}),o&&c&&e.jsx("span",{className:"text-gray-400 dark:text-gray-500 mx-3",style:{fontSize:"1.5rem",fontWeight:300},children:"|"}),c&&e.jsx("span",{children:i})]}),r&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:r})]})},Ke=["firstName","lastName","email","phonenumber","dateOfBirth"];function $e(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const _e={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"},it=({helpText:t,children:r})=>{const[s,a]=l.useState(!1);if(!t)return e.jsx(e.Fragment,{children:r});const i=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.45)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"},children:e.jsxs("div",{onClick:o=>o.stopPropagation(),style:{background:"var(--metakyc-card-bg, #ffffff)",borderRadius:"12px",padding:"28px 24px 24px",maxWidth:"480px",width:"100%",maxHeight:"80vh",overflowY:"auto",boxShadow:"0 24px 64px rgba(0,0,0,0.25)",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",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,transition:"background 0.15s, color 0.15s"},onMouseEnter:o=>{o.currentTarget.style.background="var(--metakyc-primary, #2563eb)",o.currentTarget.style.color="#fff"},onMouseLeave:o=>{o.currentTarget.style.background="transparent",o.currentTarget.style.color="var(--metakyc-primary, #2563eb)"},children:"?"}),typeof document<"u"&&i?qe.createPortal(i,document.body):null]})},Vr=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:a})=>{var Me,Oe,ze,Be;const{config:i,baseInformationService:o,currentTheme:c}=de(),{createApplicant:u,isLoading:h}=ar(),p=t||((Me=i.applicantForm)==null?void 0:Me.workflowKey);if(!p)throw new Error("workflowKey is required. Provide it either as a prop to CreateApplicantForm or set it in config.applicantForm.workflowKey");const v=r||((Oe=i.applicantForm)==null?void 0:Oe.externalRefId)||"",S=((ze=i.applicantForm)==null?void 0:ze.email)||"",y=l.useMemo(()=>c!=null&&c.applicantFormPages&&c.applicantFormPages.length>0?c.applicantFormPages:null,[c==null?void 0:c.applicantFormPages]),j=l.useMemo(()=>{const n=new Set(Ke),x=c==null?void 0:c.applicantFormRequiredFields;if(x)for(const b of x)n.add(b);if(y)for(const b of y)for(const d of b.fields)!d.isCustom&&d.name&&d.required&&n.add(d.name);return Array.from(n)},[c==null?void 0:c.applicantFormRequiredFields,y]),f=l.useMemo(()=>{var b;if(y){const d=y.flatMap(N=>N.fields).filter(N=>!N.isCustom&&N.name).map(N=>N.name),m=new Set(d);for(const N of Ke)m.add(N);return Array.from(m)}let n;(b=i.applicantForm)!=null&&b.visibleFields?n=i.applicantForm.visibleFields:c!=null&&c.applicantFormVisibleFields&&c.applicantFormVisibleFields.length>0?n=c.applicantFormVisibleFields:n=ft;const x=new Set(n);for(const d of Ke)x.add(d);return Array.from(x)},[(Be=i.applicantForm)==null?void 0:Be.visibleFields,c==null?void 0:c.applicantFormVisibleFields,y]),F=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),I=l.useMemo(()=>{var x,b;const n=new Set;if(y)for(const d of y)for(const m of d.fields)!m.isCustom&&m.name&&F.has(m.name)&&n.add(m.countriesType??((x=Re[m.name])==null?void 0:x.countriesType));else for(const d of f)F.has(d)&&n.add((b=Re[d])==null?void 0:b.countriesType);return n.size===0&&n.add(void 0),Array.from(n)},[f,y]),[E,M]=l.useState({}),[A,P]=l.useState(!0),Y=l.useRef(new Set),J=l.useRef(new Set);l.useEffect(()=>{if(!c)return;const n=I.filter(d=>{const m=d!=null?String(d):"all";return!J.current.has(m)&&!Y.current.has(m)});if(n.length===0){I.every(m=>{const N=m!=null?String(m):"all";return J.current.has(N)})&&P(!1);return}P(!0);const x=n.map(d=>d!=null?String(d):"all");x.forEach(d=>Y.current.add(d)),(async()=>{try{const d=await Promise.all(n.map(async m=>{const N=m!=null?String(m):"all",O=await o.getCountries("",i.locale||"en",m),B=m===40,g=new Set,ee=O.map(q=>B&&q.countryCode?{value:q.countryCode,label:`${q.countryCode} – ${q.name}`}:{value:q.abbreviation3||q.abbreviation,label:q.name}).filter(q=>!q.value||g.has(q.value)?!1:(g.add(q.value),!0));return J.current.add(N),Y.current.delete(N),[N,ee]}));M(m=>({...m,...Object.fromEntries(d)}))}catch(d){x.forEach(m=>Y.current.delete(m)),console.error("Failed to load countries:",d)}finally{I.every(m=>{const N=m!=null?String(m):"all";return J.current.has(N)})&&P(!1)}})()},[I,c]);const R=(n,x)=>{var m;const b=x??((m=Re[n])==null?void 0:m.countriesType),d=b!=null?String(b):"all";return E[d]||[]},[w,$]=l.useState({workflowKey:p,firstName:"",lastName:"",title:"",email:S,dateOfBirth:"",phonenumber:"",externalRefId:v,mobileCountryCode:"",street:"",streetNumber:"",zip:"",city:"",country:"",nationality:"",otherNationality:[],defaultLanguage:"EN",taxCountry:"",placeOfBirth:"",countryOfBirth:"",salutation:null,educationLevel:"",occupation:"",taxNumber:""}),[K,k]=l.useState({}),[z,T]=l.useState(0),[D,Q]=l.useState({}),[C,U]=l.useState(null),[Z,me]=l.useState(!1),se=(n,x)=>$(b=>({...b,[n]:x})),L=(n,x)=>k(b=>({...b,[n]:x})),V=n=>!n.conditionalOn||K[n.conditionalOn]==="true",te=y&&z<y.length-1?z+1:-1,je=y&&z>0?z-1:-1,Ae=n=>{var b;const x={};for(const d of n.fields)if(d.isCustom){if(d.customType==="paragraph"||d.customType==="html"||d.customType==="br"||d.customType==="link")continue;if(d.required&&d.paramName){const m=K[d.paramName],N=d.displayText||d.label||d.paramName;d.customType==="checkbox"||d.customType==="link_checkbox"?m!=="true"&&(x[d.paramName]=`${N} is required.`):(!m||m.trim()==="")&&(x[d.paramName]=`${N} is required.`)}}else if(d.name){const m=d.name;if(j.includes(m)&&$e(w[m])){const N=d.displayText||((b=Re[m])==null?void 0:b.label)||m;x[m]=`${N} is required.`}}return x},ue=async()=>{if(!y)return;const n=y[z];if(n.conditionalOn&&!V(n)){Q({}),te>=0?T(te):await Te();return}const x=Ae(n);if(Object.keys(x).length>0){Q(x);return}Q({}),te>=0?T(te):await Te()},Te=async()=>{if(y){let n={};for(const x of y)V(x)&&(n={...n,...Ae(x)});if(Object.keys(n).length>0){Q(n);return}}me(!0),U(null);try{if(!w.externalRefId||w.externalRefId.trim()===""){U("External Reference ID is required. Please pass it via config.applicantForm.externalRefId.");return}const n={workflowKey:w.workflowKey,externalRefId:w.externalRefId.trim()};if(y){for(const d of y)if(V(d)){for(const m of d.fields)if(!m.isCustom&&m.name){const N=m.name,O=w[N];$e(O)||(n[N]=O)}}for(const d of Ke)if(n[d]===void 0){const m=w[d];$e(m)||(n[d]=m)}}else f.forEach(d=>{if(d==="externalRefId")return;const m=w[d];$e(m)||(n[d]=m)});const x=[];if(y){for(const d of y)if(V(d))for(const m of d.fields){if(!m.isCustom||!m.paramName||m.customType==="paragraph"||m.customType==="html"||m.customType==="br"||m.customType==="link")continue;const N=K[m.paramName]??"";let O;if(m.customType==="checkbox"||m.customType==="link_checkbox")O=N==="true"?"yes":"no";else if(O=N,!O&&!m.required)continue;x.push({paramName:m.paramName,value:O})}}x.length>0&&(n.applicantAdditionalDatas=x);const b=await u(n);s(b.applicantId)}catch(n){console.error("Error creating applicant:",n),U(n.message||"Failed to create applicant")}finally{me(!1)}},Ge=async n=>{var x;n.preventDefault();for(const b of j)if($e(w[b])){const d=((x=Re[b])==null?void 0:x.label)||b;U(`${d} is required.`);return}await Te()},ye=(n,x,b,d)=>{var q;const m=Re[n];if(!m)return null;const N=j.includes(n),O=D[n],B=b||m.label,g=x??n,ee={required:N};switch(m.type){case"select":if(n==="country"||n==="nationality"||n==="taxCountry"||n==="countryOfBirth"||n==="mobileCountryCode"){const oe=R(n,d);return e.jsx(ke,{...ee,label:B,value:w[n]||"",onChange:Ee=>se(n,Ee),options:[{value:"",label:`Select ${B.toLowerCase()}...`},...oe],disabled:A,error:O},g)}if(n==="salutation")return e.jsx(ke,{...ee,label:B,value:((q=w[n])==null?void 0:q.toString())||"",onChange:oe=>se(n,oe?Number(oe):null),options:[{value:"",label:"Select salutation..."},{value:Ue.Male.toString(),label:"Male"},{value:Ue.Female.toString(),label:"Female"},{value:Ue.Other.toString(),label:"Other"}],error:O},g);if(n==="defaultLanguage"){const oe=c!=null&&c.allowedLanguages&&c.allowedLanguages.length>0?Ze.filter(Ee=>c.allowedLanguages.includes(Ee.value)):Ze;return e.jsx(ke,{...ee,label:B,value:w[n]||"",onChange:Ee=>se(n,Ee),options:[{value:"",label:"Select language..."},...oe],error:O},g)}return null;case"multiselect":if(n==="otherNationality"){const oe=R(n,d);return e.jsx(nr,{...ee,label:B,value:w[n]||[],onChange:Ee=>se(n,Ee),options:oe,placeholder:"Select other nationalities...",disabled:A},g)}return null;case"date":return e.jsx(ne,{...ee,type:"date",label:B,value:w[n]||"",onChange:oe=>se(n,oe.target.value),error:O},g);case"email":return e.jsx(ne,{...ee,type:"email",label:B,value:w[n]||"",onChange:oe=>se(n,oe.target.value),error:O},g);case"tel":return e.jsx(ne,{...ee,type:"tel",label:B,value:w[n]||"",onChange:oe=>se(n,oe.target.value),error:O},g);default:return e.jsx(ne,{...ee,type:"text",label:B,value:w[n]||"",onChange:oe=>se(n,oe.target.value),error:O},g)}},Ve=(n,x)=>{if(n.customType==="paragraph"){const m=n.displayText||n.label||"";return e.jsx("p",{className:"metakyc-paragraph",style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:m}},`custom-${x}`)}if(n.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:n.label||""}},`custom-${x}`);if(n.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${x}`);if(n.customType==="link"){const m=n.displayText||n.label||n.linkText||n.linkUrl||"";return e.jsx("div",{className:"metakyc-link-field",children:e.jsxs("a",{href:n.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:[m,e.jsx("span",{style:{fontSize:"10px",opacity:.7},children:"↗"})]})},`custom-${x}`)}if(!n.paramName)return null;const b=D[n.paramName],d=n.displayText||n.label||n.paramName;if(n.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:K[n.paramName]==="true",onChange:m=>L(n.paramName,m.target.checked?"true":"false"),className:"metakyc-option-input",style:_e}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[d,n.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),b&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:b})]},`custom-${x}`);if(n.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:K[n.paramName]==="true",onChange:m=>L(n.paramName,m.target.checked?"true":"false"),className:"metakyc-option-input",style:{..._e,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:[d," ",n.linkUrl&&e.jsx("a",{href:n.linkUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",style:{color:"var(--metakyc-primary, #2563eb)"},onClick:m=>m.stopPropagation(),children:n.linkText||n.linkUrl}),n.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),b&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:b})]},`custom-${x}`);if(n.customType==="group_checkbox"){const m=(K[n.paramName]||"").split(",").filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[d,n.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:(n.options||[]).map(N=>{const O=n.singleSelect?K[n.paramName]===N.value:m.includes(N.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:O,onChange:B=>{if(n.singleSelect)L(n.paramName,B.target.checked?N.value:"");else{const g=B.target.checked?[...m,N.value]:m.filter(ee=>ee!==N.value);L(n.paramName,g.join(","))}},className:"metakyc-option-input",style:_e}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:N.label})]},N.value)})}),b&&e.jsx("p",{className:"text-red-500 text-xs",children:b})]},`custom-${x}`)}return n.customType==="radio_group"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[d,n.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:(n.options||[]).map(m=>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:K[n.paramName]===m.value,onChange:()=>L(n.paramName,m.value),name:`radio-group-${n.paramName}-${x}`,className:"metakyc-option-input",style:_e}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:m.label})]},m.value))}),b&&e.jsx("p",{className:"text-red-500 text-xs",children:b})]},`custom-${x}`):e.jsx(ne,{type:"text",label:`${d}${n.required?" *":""}`,value:K[n.paramName]||"",onChange:m=>L(n.paramName,m.target.value),required:n.required,error:b},`custom-${x}`)},Je=(n,x)=>{const b=V(n);return e.jsxs("div",{className:"space-y-4",children:[n.conditionalOn&&e.jsx(it,{helpText:n.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:b,onChange:d=>L(n.conditionalOn,d.target.checked?"true":"false"),className:"metakyc-option-input",style:_e}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",fontWeight:500},children:n.conditionalOn})]})}),b&&e.jsx("div",{className:"grid grid-cols-4 gap-4",children:n.fields.map((d,m)=>{const N=d.colSpan===1?"col-span-1":d.colSpan===2?"col-span-2":d.colSpan===3?"col-span-3":"col-span-4",O=d.isCustom?`custom-${m}-${d.paramName}`:`builtin-${d.name}-${m}`;return e.jsx("div",{className:N,children:e.jsx(it,{helpText:d.helpText,children:d.isCustom?Ve(d,m):ye(d.name,O,d.displayText,d.countriesType)})},O)})})]})};if(!c||A)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(_,{children:e.jsxs(H,{children:[e.jsx(ge,{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(y){const n=y[z]??y[0],x=je===-1,b=te===-1,d=y.length,m=V(n),N=Object.values(D);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(_,{children:[e.jsx(ie,{children:e.jsx(Ye,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(H,{children:[(n.title||n.subtitle||n.description)&&e.jsxs("div",{className:"mb-4",children:[n.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:n.title}),n.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:n.subtitle}),n.description&&n.description!==n.subtitle&&e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:n.description})]}),(C||N.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[C&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",C]}),N.map((O,B)=>e.jsx("p",{className:"text-red-600 text-sm",children:O},B))]}),d>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[y.map((O,B)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${B===z?"flex-1":"w-8"}`,style:B===z?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:B<z?{backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{backgroundColor:"#e5e7eb"}},B)),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[z+1," / ",d]})]}),Je(n)]}),e.jsxs(le,{className:"flex justify-between",children:[e.jsxs("div",{children:[!x&&e.jsx(W,{type:"button",variant:"outline",onClick:()=>{T(je),Q({})},disabled:Z||h,children:"Previous"}),x&&a&&e.jsx(W,{type:"button",variant:"outline",onClick:a,disabled:Z||h,children:"Cancel"})]}),e.jsx(W,{type:"button",isLoading:Z||h,onClick:b?Te:ue,children:b?n.conditionalOn&&!m?"Skip & Submit":"Submit":n.conditionalOn&&!m?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:Ge,children:e.jsxs(_,{children:[e.jsx(ie,{children:e.jsx(Ye,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(H,{children:[C&&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:"})," ",C]})}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:f.map(n=>e.jsx("div",{className:"col-span-4",children:ye(n)},n))})]}),e.jsxs(le,{className:"flex justify-between",children:[a&&e.jsx(W,{type:"button",variant:"outline",onClick:a,disabled:Z||h,children:"Cancel"}),e.jsx(W,{type:"submit",isLoading:Z||h,children:"Create Applicant"})]})]})})})},Jr=({applicantId:t,onComplete:r,onError:s,theme:a="light",className:i})=>{const{progress:o,currentStep:c,steps:u,workflowKey:h,nextWorkflowKey:p,hasWorkflowChanged:v,isLoading:S,error:y,moveBack:j,refreshProgress:f}=Zt(t),[F,I]=l.useState(!1);if(l.useEffect(()=>{y&&s&&s(y)},[y,s]),l.useEffect(()=>{o!=null&&o.workflowResult&&r&&r(o.workflowResult)},[o==null?void 0:o.workflowResult,r]),l.useEffect(()=>{a==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},[a]),l.useEffect(()=>{v&&I(!1)},[v]),S||!o)return e.jsx("div",{className:i,children:e.jsx(_,{children:e.jsxs(H,{children:[e.jsx(ge,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading workflow..."})]})})});if(y)return e.jsx("div",{className:i,children:e.jsx(_,{children:e.jsx(H,{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:y.message})]})})})});if(v&&!F)return e.jsx("div",{className:`metakyc-sdk ${i||""}`,children:e.jsx(_,{children:e.jsx(H,{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:p})]})]}),o.nextWorkflowName&&e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-2 text-xs",children:o.nextWorkflowName})]}),e.jsx("button",{onClick:()=>I(!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(o.status===xe.Finished||o.status===xe.OnHold)return e.jsx("div",{className:`metakyc-sdk ${i||""}`,children:e.jsx(Xe,{kycStatus:o.kycStatus,reviewStatus:o.reviewStatus,workflowResult:o.workflowResult,customMessage:o.customMessage,onContinue:r&&o.workflowResult?()=>r(o.workflowResult):void 0,onContactSupport:()=>{typeof window<"u"&&(window.location.href="mailto:support@example.com")}})});if(!c)return e.jsx("div",{className:`metakyc-sdk ${i||""}`,children:e.jsx(_,{children:e.jsxs(H,{children:[e.jsx(ge,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:o.status===xe.IdentityPending?"Loading identity verification...":"Loading current step..."})]})})});const E=P=>{switch(P){case G.Overview:return"Overview";case G.Questionaries:return"Questionnaire";case G.UploadDocument:return"Documents";case G.IdentitySdk:return"Identity";case G.RiskScoring:return"Risk Assessment";case G.InvestorCategorization:return"Investor Categorization";case G.AppropriatenessTest:return"Appropriateness Test";case G.AdditionalData:return"Additional Data";case G.ManualReview:return"Review";default:return""}},M=()=>{const P=u.filter(w=>w.visibility!==!1),Y=P.findIndex(w=>w.order===c.order),J=Y>=0?Y+1:1,R=P.length;return e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsx(Ye,{}),e.jsxs(ve,{variant:o.status===1?"info":"success",children:["Step ",J," of ",R]})]}),e.jsx("div",{className:"flex items-center",children:P.map((w,$)=>{const K=$<Y,k=w.order===c.order;return e.jsxs(l.Fragment,{children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`
114
+ ${g[T.id]===Q?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}
115
+ `,children:[e.jsx("input",{type:"radio",name:`question-${T.id}`,value:Q,checked:g[T.id]===Q,onChange:U=>B(T.id,U.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:Q})]},C))})]},T.id)),v&&!M&&e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsxs("p",{className:"text-red-600 dark:text-red-400 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",v]})}),M&&e.jsx("div",{className:"p-4 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-700 dark:text-yellow-400 text-sm",children:[e.jsx("strong",{children:"Time's up!"})," Your answers are being submitted automatically."]})})]}),e.jsxs(le,{className:"flex justify-between",children:[e.jsx(W,{type:"button",variant:"outline",onClick:s,disabled:h,children:"Cancel"}),e.jsx(W,{type:"submit",isLoading:h,disabled:Object.keys(g).length<i.totalQuestionCount,children:M?"Submitting...":"Submit Test"})]})]})}):e.jsxs(_,{children:[e.jsxs(ie,{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:i.displayName}),i.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:i.subtitle})]}),e.jsxs(H,{children:[i.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:i.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(ve,{variant:"info",children:i.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(ve,{variant:"info",children:E(i.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(ve,{variant:"info",children:i.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(ve,{variant:$>1?"success":"warning",children:$})]})]}),v&&e.jsx("div",{className:"mb-4 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsxs("p",{className:"text-red-600 dark:text-red-400 text-sm",children:[e.jsx("strong",{children:"Previous Attempt:"})," ",v]})}),$<=0&&e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsx("p",{className:"text-red-600 dark:text-red-400",children:"You have used all your attempts. Please contact support for assistance."})})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(W,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(W,{type:"button",onClick:w,disabled:$<=0,children:"Start Test"})]})]})},fr=({applicantId:t,onComplete:r,onBack:s})=>{var Me,Oe,$e,ze;const{applicantService:a,baseInformationService:i,config:o,currentTheme:c}=de(),{identityData:u,provider:h,token:p,isLoading:v,error:S,requestIdentity:g,restartIdentity:j}=rr(t),[f,F]=l.useState(null),[I,A]=l.useState(null),[M,R]=l.useState([]),[P,Y]=l.useState([]),[J,E]=l.useState(!0),[w,B]=l.useState(!1),[K,k]=l.useState(null),[$,T]=l.useState(!1),D=l.useRef(!1),[Q,C]=l.useState({}),[U,Z]=l.useState({}),me=c!=null&&c.reviewPageFields&&c.reviewPageFields.length>0?c.reviewPageFields[0]:null,se=!!(c!=null&&c.reviewPageDisabled),L=l.useRef(!1);L.current=se;const V=Se.useForm({defaultValues:{street:"",streetNumber:"",city:"",zip:"",country:"",nationality:"",phonenumber:""}});l.useEffect(()=>{if(se){D.current||(D.current=!0,g().then(()=>B(!0)).catch(x=>console.error("[Identity] Auto-request failed:",x)).finally(()=>E(!1)));return}(async()=>{try{const[x,b,d]=await Promise.all([a.getApplicantData(t),i.getCountries("","en"),i.getCountries("","en",40)]);A(x);const m=new Set,N=b.map(q=>({value:q.abbreviation3||q.abbreviation,label:q.name})).filter(q=>!q.value||m.has(q.value)?!1:(m.add(q.value),!0));R(N);const O=new Set,z=d.filter(q=>q.countryCode).map(q=>({value:q.countryCode,label:`${q.countryCode} – ${q.name}`})).filter(q=>O.has(q.value)?!1:(O.add(q.value),!0));Y(z);const y=x.applicantRequestData;if(C({firstName:(y==null?void 0:y.firstName)||"",lastName:(y==null?void 0:y.lastName)||"",email:(y==null?void 0:y.email)||"",dateOfBirth:(y==null?void 0:y.dateOfBirth)||"",title:(y==null?void 0:y.title)||"",salutation:(y==null?void 0:y.salutation)||"",phonenumber:(y==null?void 0:y.phonenumber)||"",mobileCountryCode:(y==null?void 0:y.mobileCountryCode)||"",street:(y==null?void 0:y.street)||"",streetNumber:(y==null?void 0:y.streetNumber)||"",city:(y==null?void 0:y.city)||"",zip:(y==null?void 0:y.zip)||"",country:(y==null?void 0:y.country)||"",nationality:(y==null?void 0:y.nationality)||"",taxCountry:(y==null?void 0:y.taxCountry)||"",countryOfBirth:(y==null?void 0:y.countryOfBirth)||"",placeOfBirth:(y==null?void 0:y.placeOfBirth)||"",educationLevel:(y==null?void 0:y.educationLevel)||"",occupation:(y==null?void 0:y.occupation)||"",taxNumber:(y==null?void 0:y.taxNumber)||"",defaultLanguage:(y==null?void 0:y.defaultLanguage)||""}),V.reset({street:(y==null?void 0:y.street)||"",streetNumber:(y==null?void 0:y.streetNumber)||"",city:(y==null?void 0:y.city)||"",zip:(y==null?void 0:y.zip)||"",country:(y==null?void 0:y.country)||"",nationality:(y==null?void 0:y.nationality)||"",phonenumber:(y==null?void 0:y.phonenumber)||""}),x.kycRecords&&x.kycRecords.length>0&&x.kycRecords[0].providerTokenObject!==null&&!D.current&&L.current){console.log("[Identity] Review page disabled + existing identity — auto-requesting..."),D.current=!0;try{await g(),B(!0)}catch(q){console.error("[Identity] Auto-request failed:",q)}}}catch(x){console.error("Error loading applicant data:",x)}finally{E(!1)}})()},[t]),l.useEffect(()=>{u&&!w&&L.current&&(console.log("[Identity] Review page disabled — showing cached provider"),B(!0))},[u,w]),l.useEffect(()=>{if(p){if(p.expiresAt){const n=new Date(p.expiresAt).getTime();if(Date.now()>=n){console.warn("[Identity] Token has expired (expiresAt)"),T(!0),k("Your verification session has expired. Please restart.");return}}if(p.url)try{const x=new URL(p.url).toString().toLowerCase();if(x.includes("expired")||x.includes("invalid")||x.includes("error")){console.warn("[Identity] Token URL indicates expiration"),T(!0),k("Your verification link has expired. Please restart.");return}}catch{console.error("[Identity] Invalid token URL")}if(p.status==="expired"||p.error==="expired"||p.expired===!0){console.warn("[Identity] Token object indicates expiration"),T(!0),k("Your verification session has expired. Please restart.");return}}},[p]),l.useEffect(()=>{if(h!==null&&p&&!f&&w&&!$){const n=h;if(p.url){console.log("[Identity] Loading provider URL for user verification:",p.url),k(null);try{if(new URL(p.url),n===he.SardinAI){console.log("[SardinAI] Initializing Risk SDK in background...");try{const x=Pe.parseProviderConfig(h,p,o);Pe.createProvider(h,x).initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully in background")}).catch(d=>{console.warn("[SardinAI] Risk SDK initialization failed (non-blocking):",d)})}catch(x){console.warn("[SardinAI] Risk SDK setup failed (non-blocking):",x)}}F({type:"url",url:p.url})}catch(x){console.error("[Identity] Invalid URL:",x),k("Invalid verification URL. Please restart."),T(!0)}return}if(n===he.SardinAI){console.log("[SardinAI] No URL provided - initializing Risk SDK only..."),k(null);try{const x=Pe.parseProviderConfig(h,p,o),b=Pe.createProvider(h,x);b.initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully"),F(b),setTimeout(()=>{r==null||r()},2e3)}).catch(d=>{var N;console.error("[SardinAI] Failed to initialize:",d);const m=((N=d.message)==null?void 0:N.toLowerCase())||"";m.includes("expired")||m.includes("invalid")||m.includes("401")||m.includes("400")?(T(!0),k("Session expired or invalid. Please restart verification.")):k(`Failed to initialize: ${d.message}`)})}catch(x){console.error("[SardinAI] Error creating provider:",x),k(`Configuration error: ${x.message}`)}return}try{k(null);const x=Pe.parseProviderConfig(h,p,o),b=Pe.createProvider(h,x);n===he.Sumsub?(b.initialize("identity-container").catch(d=>{var m;console.error("[Sumsub] Initialization error:",d),k(`Failed to initialize: ${d.message}`),(m=d.message)!=null&&m.toLowerCase().includes("expired")&&T(!0)}),b.onComplete&&b.onComplete(()=>{r==null||r()})):n===he.Onfido&&b.initialize("identity-container").catch(d=>{console.error("[Onfido] Initialization error:",d),k(`Failed to initialize: ${d.message}`)}),F(b)}catch(x){console.error("[Identity] Provider setup error:",x),k(`Setup error: ${x.message}`)}}return()=>{if(f&&f.destroy)try{f.destroy()}catch(n){console.error("[Identity] Error destroying provider:",n)}}},[h,p,f,w,r,$]);const te=async()=>{try{k(null),T(!1),await g(),B(!0)}catch(n){console.error("Error starting identity verification:",n)}},je=async()=>{try{k(null),T(!1),F(null),console.log("[Identity] Restarting verification..."),await j(),B(!0)}catch(n){console.error("Error restarting identity verification:",n),k(n.message||"Failed to restart verification")}};if(J||v)return e.jsx(_,{children:e.jsxs(H,{children:[e.jsx(ye,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading identity verification..."})]})});if(S)return e.jsx(_,{children:e.jsx(H,{children:e.jsxs("p",{className:"text-danger-500",children:["Error: ",S.message]})})});if(w&&(K||$))return e.jsxs(_,{children:[e.jsx(ie,{children:e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Verification Session Issue"})}),e.jsxs(H,{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:$?"Session Expired":"Verification Error"}),e.jsx("p",{className:"text-red-800 dark:text-red-200 text-sm",children:K||"Your verification session has expired and needs to be restarted."})]})]})}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What to do next:"}),e.jsxs("ul",{className:"text-blue-800 dark:text-blue-200 text-sm space-y-1 list-disc list-inside",children:[e.jsx("li",{children:'Click "Restart Verification" below to generate a new session'}),e.jsx("li",{children:"Complete the verification process without delays"}),e.jsx("li",{children:"If issues persist, contact support"})]})]})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(W,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(W,{type:"button",onClick:je,disabled:v,children:v?"Restarting...":"Restart Verification"})]})]});if(w&&u){const n=h;return p!=null&&p.url?e.jsxs(_,{children:[e.jsx(ie,{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(W,{type:"button",variant:"outline",size:"sm",onClick:je,disabled:v,children:"Restart"})]})}),e.jsxs(H,{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:p.url,className:"w-full h-full border-0 rounded-lg",allow:"camera; microphone; geolocation",title:"Identity Verification",onLoad:x=>{var b,d,m;console.log("[Identity] Iframe loaded");try{const N=x.target,O=N.contentDocument||((b=N.contentWindow)==null?void 0:b.document);if(O){const z=((m=(d=O.body)==null?void 0:d.textContent)==null?void 0:m.toLowerCase())||"";(z.includes("expired")||z.includes("invalid")||z.includes("error"))&&(console.warn("[Identity] Iframe shows expiration message"),T(!0),k("Your verification link has expired."))}}catch{console.log("[Identity] Cannot check iframe content (CORS)")}}})})]}),s&&e.jsx(le,{children:e.jsx(W,{variant:"outline",onClick:s,children:"Back"})})]}):n===he.SardinAI?e.jsxs(_,{children:[e.jsxs(ie,{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(H,{children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(ye,{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(_,{children:[e.jsxs(ie,{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(H,{children:e.jsx("div",{id:"identity-container",className:"min-h-[400px]"})}),s&&e.jsx(le,{children:e.jsx(W,{variant:"outline",onClick:s,children:"Back"})})]})}const Re=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),ue=(n=4)=>({1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4"})[n]||"col-span-4",Te=(n,x)=>{if(!x&&x!==0)return"—";if(Re.has(n)&&n!=="mobileCountryCode"){const b=M.find(d=>d.value===x);return b?b.label:String(x)}return String(x)},Ge=({helpText:n})=>{const[x,b]=l.useState(!1),d=l.useRef(null),[,m]=l.useState({top:0,left:0}),N=()=>{if(d.current){const O=d.current.getBoundingClientRect();m({top:O.bottom+window.scrollY+6,left:O.left+window.scrollX})}b(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",ref:d,onClick:N,style:{width:18,height:18,borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #6366f1)",background:"transparent",color:"var(--metakyc-primary, #6366f1)",fontSize:11,fontWeight:700,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:1},children:"?"}),x&&qe.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.25)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>b(!1),children:e.jsxs("div",{onClick:O=>O.stopPropagation(),style:{background:"var(--metakyc-surface, #fff)",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 8px)",padding:"16px 20px",maxWidth:400,width:"90%",boxShadow:"0 10px 30px rgba(0,0,0,0.15)"},children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:n},style:{fontSize:13,color:"var(--metakyc-text-primary, #111827)",lineHeight:1.6}}),e.jsx("button",{type:"button",onClick:()=>b(!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)]})},ge=(n,x)=>x?e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:5,flexWrap:"nowrap"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:n}),e.jsx("div",{style:{paddingTop:24},children:e.jsx(Ge,{helpText:x})})]}):n,Ve=(n,x)=>{const b=`cf-${x}`,d=n.paramName??"",m=U[d];if(n.customType==="br")return e.jsx("div",{className:ue(n.colSpan),style:{minHeight:"0.5rem"}},b);if(n.customType==="paragraph")return e.jsx("div",{className:ue(n.colSpan),children:e.jsx("div",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:n.label||""}})},b);if(n.customType==="html")return e.jsx("div",{className:ue(n.colSpan),dangerouslySetInnerHTML:{__html:n.label||""}},b);if(n.customType==="link")return e.jsx("div",{className:ue(n.colSpan),children:ge(e.jsx("a",{href:n.linkUrl??"#",target:"_blank",rel:"noopener noreferrer",className:"text-sm underline",style:{color:"var(--metakyc-primary, #6366f1)"},children:n.displayText||n.label||n.linkText||n.linkUrl}),n.helpText)},b);if(n.customType==="checkbox"||n.customType==="link_checkbox"){const N=m==="true"||m===!0;return e.jsx("div",{className:ue(n.colSpan),children:ge(e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!N,onChange:O=>Z(z=>({...z,[d]:String(O.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:n.customType==="link_checkbox"&&n.linkUrl?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:n.linkUrl,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #6366f1)",textDecoration:"underline"},children:n.linkText||n.label}),n.label&&n.linkText?` ${n.label}`:""]}):n.displayText||n.label})]}),n.helpText)},b)}if(n.customType==="group_checkbox"){const N=Array.isArray(m)?m:m?[m]:[],O=z=>{n.singleSelect?Z(y=>({...y,[d]:N[0]===z?[]:[z]})):Z(y=>({...y,[d]:N.includes(z)?N.filter(ee=>ee!==z):[...N,z]}))};return e.jsx("div",{className:ue(n.colSpan),children:ge(e.jsxs("div",{className:"space-y-1.5",children:[n.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:n.displayText||n.label}),(n.options||[]).map(z=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:N.includes(z.value),onChange:()=>O(z.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:z.label})]},z.value))]}),n.helpText)},b)}return n.customType==="radio_group"?e.jsx("div",{className:ue(n.colSpan),children:ge(e.jsxs("div",{className:"space-y-1.5",children:[n.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:n.displayText||n.label}),(n.options||[]).map(N=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"radio",name:`rg-${d}`,value:N.value,checked:m===N.value,onChange:()=>Z(O=>({...O,[d]:N.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:N.label})]},N.value))]}),n.helpText)},b):e.jsx("div",{className:ue(n.colSpan),children:ge(e.jsx(ne,{label:n.displayText||n.label||d,value:String(m??""),onChange:N=>Z(O=>({...O,[d]:N.target.value}))}),n.helpText)},b)},Je=(n,x)=>{if(n.isCustom)return Ve(n,x);const b=n.name??"",d=Ee[b],m=n.displayText||(d==null?void 0:d.label)||b,N=Q[b]??"",O=b==="mobileCountryCode",z=!!(d!=null&&d.countriesType)&&!O;return n.editable?O?e.jsx("div",{className:ue(n.colSpan??2),children:ge(e.jsx(ke,{label:m,value:String(N),onChange:y=>C(ee=>({...ee,[b]:y})),options:[{value:"",label:"Select country code…"},...P]}),n.helpText)},`epc-${x}`):z?e.jsx("div",{className:ue(n.colSpan??2),children:ge(e.jsx(ke,{label:m,value:String(N),onChange:y=>C(ee=>({...ee,[b]:y})),options:[{value:"",label:`Select ${m.toLowerCase()}…`},...M]}),n.helpText)},`ec-${x}`):e.jsx("div",{className:ue(n.colSpan??2),children:ge(e.jsx(ne,{label:m,type:(d==null?void 0:d.type)==="date"?"date":(d==null?void 0:d.type)==="email"?"email":"text",value:String(N),onChange:y=>C(ee=>({...ee,[b]:y.target.value}))}),n.helpText)},`ei-${x}`):e.jsx("div",{className:ue(n.colSpan??2),children:ge(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:m}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)",minHeight:"1.5rem"},children:Te(b,N)})]}),n.helpText)},`ro-${x}`)};if(me){const n=me.title||"Review Your Information",x=me.subtitle||"Please review and confirm your information before starting identity verification";return e.jsx("form",{onSubmit:b=>{b.preventDefault(),te()},children:e.jsxs(_,{children:[e.jsxs(ie,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:n}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:x})]}),e.jsx(H,{children:e.jsx("div",{className:"grid grid-cols-4 gap-4",children:me.fields.map((b,d)=>Je(b,d))})}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(W,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(W,{type:"submit",isLoading:v,children:"Confirm and Start Verification"})]})]})})}return e.jsx("form",{onSubmit:V.handleSubmit(te),children:e.jsxs(_,{children:[e.jsxs(ie,{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(H,{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:`${((Me=I==null?void 0:I.applicantRequestData)==null?void 0:Me.firstName)||""} ${((Oe=I==null?void 0:I.applicantRequestData)==null?void 0:Oe.lastName)||""}`.trim()},{label:"Email",value:($e=I==null?void 0:I.applicantRequestData)==null?void 0:$e.email},{label:"Date of Birth",value:((ze=I==null?void 0:I.applicantRequestData)==null?void 0:ze.dateOfBirth)||"Not provided"}].map(({label:n,value:x})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:n}),e.jsx("p",{className:"mt-1 text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:x})]},n))}),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(Se.Controller,{control:V.control,name:"country",render:({field:n})=>e.jsx(ke,{label:"Country",value:n.value,onChange:n.onChange,options:[{value:"",label:"Select country…"},...M]})}),e.jsx(Se.Controller,{control:V.control,name:"nationality",render:({field:n})=>e.jsx(ke,{label:"Nationality",value:n.value,onChange:n.onChange,options:[{value:"",label:"Select nationality…"},...M]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Se.Controller,{control:V.control,name:"street",render:({field:n})=>e.jsx(ne,{...n,label:"Street"})}),e.jsx(Se.Controller,{control:V.control,name:"streetNumber",render:({field:n})=>e.jsx(ne,{...n,label:"Street Number"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Se.Controller,{control:V.control,name:"city",render:({field:n})=>e.jsx(ne,{...n,label:"City"})}),e.jsx(Se.Controller,{control:V.control,name:"zip",render:({field:n})=>e.jsx(ne,{...n,label:"ZIP / Postal Code"})})]}),e.jsx(Se.Controller,{control:V.control,name:"phonenumber",render:({field:n})=>e.jsx(ne,{...n,label:"Phone Number",type:"tel"})})]})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(W,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(W,{type:"submit",isLoading:v,children:"Confirm and Start Verification"})]})]})})},Xe=({kycStatus:t,reviewStatus:r,workflowResult:s,customMessage:a,onContinue:i,onContactSupport:o})=>{const u=t===Ne.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===Ne.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===Ne.Pending||t===Ne.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===Ce.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===Ce.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===Ce.UnderReview||r===Ce.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===He.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===He.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===He.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(_,{children:[e.jsxs(H,{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(ve,{variant:u.type==="success"?"success":u.type==="error"?"danger":u.type==="pending"?"warning":"info",children:t!=null?Ne[t]:Ce[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?Ne[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:Ce[r]})]})]})})]}),e.jsxs(le,{className:"flex justify-center gap-4",children:[u.type==="success"&&i&&e.jsx(W,{onClick:i,size:"lg",children:"Continue"}),u.type==="error"&&e.jsxs(e.Fragment,{children:[o&&e.jsx(W,{variant:"outline",onClick:o,children:"Contact Support"}),i&&e.jsx(W,{onClick:i,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"})})]})]})},br=({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"}})}),Ye=({title:t,subtitle:r,className:s=""})=>{const{currentTheme:a}=de(),i=t||(a==null?void 0:a.title)||"",o=!!(a!=null&&a.logo&&a.logo.visible&&a.logo.url),c=!!i;return!o&&!c?null:e.jsxs("div",{className:`metakyc-header ${s}`,children:[e.jsxs("div",{className:"metakyc-header-title flex items-center text-xl font-bold text-gray-900 dark:text-white",children:[o&&e.jsx(br,{config:a.logo}),o&&c&&e.jsx("span",{className:"text-gray-400 dark:text-gray-500 mx-3",style:{fontSize:"1.5rem",fontWeight:300},children:"|"}),c&&e.jsx("span",{children:i})]}),r&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:r})]})},Ke=["firstName","lastName","email","phonenumber","dateOfBirth"];function Be(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const _e={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"},it=({helpText:t,children:r})=>{const[s,a]=l.useState(!1);if(!t)return e.jsx(e.Fragment,{children:r});const i=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.45)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"},children:e.jsxs("div",{onClick:o=>o.stopPropagation(),style:{background:"var(--metakyc-card-bg, #ffffff)",borderRadius:"12px",padding:"28px 24px 24px",maxWidth:"480px",width:"100%",maxHeight:"80vh",overflowY:"auto",boxShadow:"0 24px 64px rgba(0,0,0,0.25)",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",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,transition:"background 0.15s, color 0.15s"},onMouseEnter:o=>{o.currentTarget.style.background="var(--metakyc-primary, #2563eb)",o.currentTarget.style.color="#fff"},onMouseLeave:o=>{o.currentTarget.style.background="transparent",o.currentTarget.style.color="var(--metakyc-primary, #2563eb)"},children:"?"}),typeof document<"u"&&i?qe.createPortal(i,document.body):null]})},Jr=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:a})=>{var Me,Oe,$e,ze;const{config:i,baseInformationService:o,currentTheme:c}=de(),{createApplicant:u,isLoading:h}=ar(),p=t||((Me=i.applicantForm)==null?void 0:Me.workflowKey);if(!p)throw new Error("workflowKey is required. Provide it either as a prop to CreateApplicantForm or set it in config.applicantForm.workflowKey");const v=r||((Oe=i.applicantForm)==null?void 0:Oe.externalRefId)||"",S=(($e=i.applicantForm)==null?void 0:$e.email)||"",g=l.useMemo(()=>c!=null&&c.applicantFormPages&&c.applicantFormPages.length>0?c.applicantFormPages:null,[c==null?void 0:c.applicantFormPages]),j=l.useMemo(()=>{const n=new Set(Ke),x=c==null?void 0:c.applicantFormRequiredFields;if(x)for(const b of x)n.add(b);if(g)for(const b of g)for(const d of b.fields)!d.isCustom&&d.name&&d.required&&n.add(d.name);return Array.from(n)},[c==null?void 0:c.applicantFormRequiredFields,g]),f=l.useMemo(()=>{var b;if(g){const d=g.flatMap(N=>N.fields).filter(N=>!N.isCustom&&N.name).map(N=>N.name),m=new Set(d);for(const N of Ke)m.add(N);return Array.from(m)}let n;(b=i.applicantForm)!=null&&b.visibleFields?n=i.applicantForm.visibleFields:c!=null&&c.applicantFormVisibleFields&&c.applicantFormVisibleFields.length>0?n=c.applicantFormVisibleFields:n=ft;const x=new Set(n);for(const d of Ke)x.add(d);return Array.from(x)},[(ze=i.applicantForm)==null?void 0:ze.visibleFields,c==null?void 0:c.applicantFormVisibleFields,g]),F=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),I=l.useMemo(()=>{var x,b;const n=new Set;if(g)for(const d of g)for(const m of d.fields)!m.isCustom&&m.name&&F.has(m.name)&&n.add(m.countriesType??((x=Ee[m.name])==null?void 0:x.countriesType));else for(const d of f)F.has(d)&&n.add((b=Ee[d])==null?void 0:b.countriesType);return n.size===0&&n.add(void 0),Array.from(n)},[f,g]),[A,M]=l.useState({}),[R,P]=l.useState(!0),Y=l.useRef(new Set),J=l.useRef(new Set);l.useEffect(()=>{if(!c)return;const n=I.filter(d=>{const m=d!=null?String(d):"all";return!J.current.has(m)&&!Y.current.has(m)});if(n.length===0){I.every(m=>{const N=m!=null?String(m):"all";return J.current.has(N)})&&P(!1);return}P(!0);const x=n.map(d=>d!=null?String(d):"all");x.forEach(d=>Y.current.add(d)),(async()=>{try{const d=await Promise.all(n.map(async m=>{const N=m!=null?String(m):"all",O=await o.getCountries("",i.locale||"en",m),z=m===40,y=new Set,ee=O.map(q=>z&&q.countryCode?{value:q.countryCode,label:`${q.countryCode} – ${q.name}`}:{value:q.abbreviation3||q.abbreviation,label:q.name}).filter(q=>!q.value||y.has(q.value)?!1:(y.add(q.value),!0));return J.current.add(N),Y.current.delete(N),[N,ee]}));M(m=>({...m,...Object.fromEntries(d)}))}catch(d){x.forEach(m=>Y.current.delete(m)),console.error("Failed to load countries:",d)}finally{I.every(m=>{const N=m!=null?String(m):"all";return J.current.has(N)})&&P(!1)}})()},[I,c]);const E=(n,x)=>{var m;const b=x??((m=Ee[n])==null?void 0:m.countriesType),d=b!=null?String(b):"all";return A[d]||[]},[w,B]=l.useState({workflowKey:p,firstName:"",lastName:"",title:"",email:S,dateOfBirth:"",phonenumber:"",externalRefId:v,mobileCountryCode:"",street:"",streetNumber:"",zip:"",city:"",country:"",nationality:"",otherNationality:[],defaultLanguage:"EN",taxCountry:"",placeOfBirth:"",countryOfBirth:"",salutation:null,educationLevel:"",occupation:"",taxNumber:""}),[K,k]=l.useState({}),[$,T]=l.useState(0),[D,Q]=l.useState({}),[C,U]=l.useState(null),[Z,me]=l.useState(!1),se=(n,x)=>B(b=>({...b,[n]:x})),L=(n,x)=>k(b=>({...b,[n]:x})),V=n=>!n.conditionalOn||K[n.conditionalOn]==="true",te=g&&$<g.length-1?$+1:-1,je=g&&$>0?$-1:-1,Re=n=>{var b;const x={};for(const d of n.fields)if(d.isCustom){if(d.customType==="paragraph"||d.customType==="html"||d.customType==="br"||d.customType==="link")continue;if(d.required&&d.paramName){const m=K[d.paramName],N=d.displayText||d.label||d.paramName;d.customType==="checkbox"||d.customType==="link_checkbox"?m!=="true"&&(x[d.paramName]=`${N} is required.`):(!m||m.trim()==="")&&(x[d.paramName]=`${N} is required.`)}}else if(d.name){const m=d.name;if(j.includes(m)&&Be(w[m])){const N=d.displayText||((b=Ee[m])==null?void 0:b.label)||m;x[m]=`${N} is required.`}}return x},ue=async()=>{if(!g)return;const n=g[$];if(n.conditionalOn&&!V(n)){Q({}),te>=0?T(te):await Te();return}const x=Re(n);if(Object.keys(x).length>0){Q(x);return}Q({}),te>=0?T(te):await Te()},Te=async()=>{if(g){let n={};for(const x of g)V(x)&&(n={...n,...Re(x)});if(Object.keys(n).length>0){Q(n);return}}me(!0),U(null);try{if(!w.externalRefId||w.externalRefId.trim()===""){U("External Reference ID is required. Please pass it via config.applicantForm.externalRefId.");return}const n={workflowKey:w.workflowKey,externalRefId:w.externalRefId.trim()};if(g){for(const d of g)if(V(d)){for(const m of d.fields)if(!m.isCustom&&m.name){const N=m.name,O=w[N];Be(O)||(n[N]=O)}}for(const d of Ke)if(n[d]===void 0){const m=w[d];Be(m)||(n[d]=m)}}else f.forEach(d=>{if(d==="externalRefId")return;const m=w[d];Be(m)||(n[d]=m)});const x=[];if(g){for(const d of g)if(V(d))for(const m of d.fields){if(!m.isCustom||!m.paramName||m.customType==="paragraph"||m.customType==="html"||m.customType==="br"||m.customType==="link")continue;const N=K[m.paramName]??"";let O;if(m.customType==="checkbox"||m.customType==="link_checkbox")O=N==="true"?"yes":"no";else if(O=N,!O&&!m.required)continue;x.push({paramName:m.paramName,value:O})}}x.length>0&&(n.applicantAdditionalDatas=x);const b=await u(n);s(b.applicantId)}catch(n){console.error("Error creating applicant:",n),U(n.message||"Failed to create applicant")}finally{me(!1)}},Ge=async n=>{var x;n.preventDefault();for(const b of j)if(Be(w[b])){const d=((x=Ee[b])==null?void 0:x.label)||b;U(`${d} is required.`);return}await Te()},ge=(n,x,b,d)=>{var q;const m=Ee[n];if(!m)return null;const N=j.includes(n),O=D[n],z=b||m.label,y=x??n,ee={required:N};switch(m.type){case"select":if(n==="country"||n==="nationality"||n==="taxCountry"||n==="countryOfBirth"||n==="mobileCountryCode"){const oe=E(n,d);return e.jsx(ke,{...ee,label:z,value:w[n]||"",onChange:Ae=>se(n,Ae),options:[{value:"",label:`Select ${z.toLowerCase()}...`},...oe],disabled:R,error:O},y)}if(n==="salutation")return e.jsx(ke,{...ee,label:z,value:((q=w[n])==null?void 0:q.toString())||"",onChange:oe=>se(n,oe?Number(oe):null),options:[{value:"",label:"Select salutation..."},{value:Ue.Male.toString(),label:"Male"},{value:Ue.Female.toString(),label:"Female"},{value:Ue.Other.toString(),label:"Other"}],error:O},y);if(n==="defaultLanguage"){const oe=c!=null&&c.allowedLanguages&&c.allowedLanguages.length>0?Ze.filter(Ae=>c.allowedLanguages.includes(Ae.value)):Ze;return e.jsx(ke,{...ee,label:z,value:w[n]||"",onChange:Ae=>se(n,Ae),options:[{value:"",label:"Select language..."},...oe],error:O},y)}return null;case"multiselect":if(n==="otherNationality"){const oe=E(n,d);return e.jsx(nr,{...ee,label:z,value:w[n]||[],onChange:Ae=>se(n,Ae),options:oe,placeholder:"Select other nationalities...",disabled:R},y)}return null;case"date":return e.jsx(ne,{...ee,type:"date",label:z,value:w[n]||"",onChange:oe=>se(n,oe.target.value),error:O},y);case"email":return e.jsx(ne,{...ee,type:"email",label:z,value:w[n]||"",onChange:oe=>se(n,oe.target.value),error:O},y);case"tel":return e.jsx(ne,{...ee,type:"tel",label:z,value:w[n]||"",onChange:oe=>se(n,oe.target.value),error:O},y);default:return e.jsx(ne,{...ee,type:"text",label:z,value:w[n]||"",onChange:oe=>se(n,oe.target.value),error:O},y)}},Ve=(n,x)=>{if(n.customType==="paragraph"){const m=n.displayText||n.label||"";return e.jsx("p",{className:"metakyc-paragraph",style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:m}},`custom-${x}`)}if(n.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:n.label||""}},`custom-${x}`);if(n.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${x}`);if(n.customType==="link"){const m=n.displayText||n.label||n.linkText||n.linkUrl||"";return e.jsx("div",{className:"metakyc-link-field",children:e.jsxs("a",{href:n.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:[m,e.jsx("span",{style:{fontSize:"10px",opacity:.7},children:"↗"})]})},`custom-${x}`)}if(!n.paramName)return null;const b=D[n.paramName],d=n.displayText||n.label||n.paramName;if(n.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:K[n.paramName]==="true",onChange:m=>L(n.paramName,m.target.checked?"true":"false"),className:"metakyc-option-input",style:_e}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[d,n.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),b&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:b})]},`custom-${x}`);if(n.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:K[n.paramName]==="true",onChange:m=>L(n.paramName,m.target.checked?"true":"false"),className:"metakyc-option-input",style:{..._e,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:[d," ",n.linkUrl&&e.jsx("a",{href:n.linkUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",style:{color:"var(--metakyc-primary, #2563eb)"},onClick:m=>m.stopPropagation(),children:n.linkText||n.linkUrl}),n.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),b&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:b})]},`custom-${x}`);if(n.customType==="group_checkbox"){const m=(K[n.paramName]||"").split(",").filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[d,n.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:(n.options||[]).map(N=>{const O=n.singleSelect?K[n.paramName]===N.value:m.includes(N.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:O,onChange:z=>{if(n.singleSelect)L(n.paramName,z.target.checked?N.value:"");else{const y=z.target.checked?[...m,N.value]:m.filter(ee=>ee!==N.value);L(n.paramName,y.join(","))}},className:"metakyc-option-input",style:_e}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:N.label})]},N.value)})}),b&&e.jsx("p",{className:"text-red-500 text-xs",children:b})]},`custom-${x}`)}return n.customType==="radio_group"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[d,n.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:(n.options||[]).map(m=>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:K[n.paramName]===m.value,onChange:()=>L(n.paramName,m.value),name:`radio-group-${n.paramName}-${x}`,className:"metakyc-option-input",style:_e}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:m.label})]},m.value))}),b&&e.jsx("p",{className:"text-red-500 text-xs",children:b})]},`custom-${x}`):e.jsx(ne,{type:"text",label:`${d}${n.required?" *":""}`,value:K[n.paramName]||"",onChange:m=>L(n.paramName,m.target.value),required:n.required,error:b},`custom-${x}`)},Je=(n,x)=>{const b=V(n);return e.jsxs("div",{className:"space-y-4",children:[n.conditionalOn&&e.jsx(it,{helpText:n.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:b,onChange:d=>L(n.conditionalOn,d.target.checked?"true":"false"),className:"metakyc-option-input",style:_e}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",fontWeight:500},children:n.conditionalOn})]})}),b&&e.jsx("div",{className:"grid grid-cols-4 gap-4",children:n.fields.map((d,m)=>{const N=d.colSpan===1?"col-span-1":d.colSpan===2?"col-span-2":d.colSpan===3?"col-span-3":"col-span-4",O=d.isCustom?`custom-${m}-${d.paramName}`:`builtin-${d.name}-${m}`;return e.jsx("div",{className:N,children:e.jsx(it,{helpText:d.helpText,children:d.isCustom?Ve(d,m):ge(d.name,O,d.displayText,d.countriesType)})},O)})})]})};if(!c||R)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(_,{children:e.jsxs(H,{children:[e.jsx(ye,{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(g){const n=g[$]??g[0],x=je===-1,b=te===-1,d=g.length,m=V(n),N=Object.values(D);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(_,{children:[e.jsx(ie,{children:e.jsx(Ye,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(H,{children:[(n.title||n.subtitle||n.description)&&e.jsxs("div",{className:"mb-4",children:[n.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:n.title}),n.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:n.subtitle}),n.description&&n.description!==n.subtitle&&e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:n.description})]}),(C||N.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[C&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",C]}),N.map((O,z)=>e.jsx("p",{className:"text-red-600 text-sm",children:O},z))]}),d>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[g.map((O,z)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${z===$?"flex-1":"w-8"}`,style:z===$?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:z<$?{backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{backgroundColor:"#e5e7eb"}},z)),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[$+1," / ",d]})]}),Je(n)]}),e.jsxs(le,{className:"flex justify-between",children:[e.jsxs("div",{children:[!x&&e.jsx(W,{type:"button",variant:"outline",onClick:()=>{T(je),Q({})},disabled:Z||h,children:"Previous"}),x&&a&&e.jsx(W,{type:"button",variant:"outline",onClick:a,disabled:Z||h,children:"Cancel"})]}),e.jsx(W,{type:"button",isLoading:Z||h,onClick:b?Te:ue,children:b?n.conditionalOn&&!m?"Skip & Submit":"Submit":n.conditionalOn&&!m?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:Ge,children:e.jsxs(_,{children:[e.jsx(ie,{children:e.jsx(Ye,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(H,{children:[C&&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:"})," ",C]})}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:f.map(n=>e.jsx("div",{className:"col-span-4",children:ge(n)},n))})]}),e.jsxs(le,{className:"flex justify-between",children:[a&&e.jsx(W,{type:"button",variant:"outline",onClick:a,disabled:Z||h,children:"Cancel"}),e.jsx(W,{type:"submit",isLoading:Z||h,children:"Create Applicant"})]})]})})})},Zr=({applicantId:t,onComplete:r,onError:s,theme:a="light",className:i})=>{const{progress:o,currentStep:c,steps:u,workflowKey:h,nextWorkflowKey:p,hasWorkflowChanged:v,isLoading:S,error:g,moveBack:j,refreshProgress:f}=Zt(t),[F,I]=l.useState(!1);if(l.useEffect(()=>{g&&s&&s(g)},[g,s]),l.useEffect(()=>{o!=null&&o.workflowResult&&r&&r(o.workflowResult)},[o==null?void 0:o.workflowResult,r]),l.useEffect(()=>{a==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},[a]),l.useEffect(()=>{v&&I(!1)},[v]),S||!o)return e.jsx("div",{className:i,children:e.jsx(_,{children:e.jsxs(H,{children:[e.jsx(ye,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading workflow..."})]})})});if(g)return e.jsx("div",{className:i,children:e.jsx(_,{children:e.jsx(H,{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:g.message})]})})})});if(v&&!F)return e.jsx("div",{className:`metakyc-sdk ${i||""}`,children:e.jsx(_,{children:e.jsx(H,{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:p})]})]}),o.nextWorkflowName&&e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-2 text-xs",children:o.nextWorkflowName})]}),e.jsx("button",{onClick:()=>I(!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(o.status===xe.Finished||o.status===xe.OnHold)return e.jsx("div",{className:`metakyc-sdk ${i||""}`,children:e.jsx(Xe,{kycStatus:o.kycStatus,reviewStatus:o.reviewStatus,workflowResult:o.workflowResult,customMessage:o.customMessage,onContinue:r&&o.workflowResult?()=>r(o.workflowResult):void 0,onContactSupport:()=>{typeof window<"u"&&(window.location.href="mailto:support@example.com")}})});if(!c)return e.jsx("div",{className:`metakyc-sdk ${i||""}`,children:e.jsx(_,{children:e.jsxs(H,{children:[e.jsx(ye,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:o.status===xe.IdentityPending?"Loading identity verification...":"Loading current step..."})]})})});const A=P=>{switch(P){case G.Overview:return"Overview";case G.Questionaries:return"Questionnaire";case G.UploadDocument:return"Documents";case G.IdentitySdk:return"Identity";case G.RiskScoring:return"Risk Assessment";case G.InvestorCategorization:return"Investor Categorization";case G.AppropriatenessTest:return"Appropriateness Test";case G.AdditionalData:return"Additional Data";case G.ManualReview:return"Review";default:return""}},M=()=>{const P=u.filter(w=>w.visibility!==!1),Y=P.findIndex(w=>w.order===c.order),J=Y>=0?Y+1:1,E=P.length;return e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsx(Ye,{}),e.jsxs(ve,{variant:o.status===1?"info":"success",children:["Step ",J," of ",E]})]}),e.jsx("div",{className:"flex items-center",children:P.map((w,B)=>{const K=B<Y,k=w.order===c.order;return e.jsxs(l.Fragment,{children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`
66
116
  w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium
67
117
  ${K||k?"bg-primary-500 text-white":"bg-gray-200 text-gray-600 dark:bg-gray-700 dark:text-gray-400"}
68
- `,children:$+1}),e.jsx("span",{className:`ml-2 text-sm ${k?"font-semibold text-gray-900 dark:text-white":"text-gray-600 dark:text-gray-400"}`,children:w.displayName||w.name||E(w.action)||`Step ${$+1}`})]}),$<P.length-1&&e.jsx("div",{className:`flex-1 h-0.5 mx-4 ${K?"bg-primary-500":"bg-gray-200 dark:bg-gray-700"}`})]},w.order)})})]})},A=()=>{const P={applicantId:t,onComplete:async()=>{await f()},onBack:c.order>0?j:void 0};switch(c.action){case G.Questionaries:return e.jsx(pr,{...P});case G.UploadDocument:return e.jsx(mr,{...P});case G.Overview:return e.jsx(hr,{...P});case G.IdentitySdk:return e.jsx(fr,{...P});case G.RiskScoring:return e.jsx(xr,{...P});case G.AdditionalData:case G.InvestorCategorization:return e.jsx(gr,{...P});case G.AppropriatenessTest:return e.jsx(yr,{...P});case G.ManualReview:return e.jsx(Xe,{kycStatus:o.kycStatus,reviewStatus:o.reviewStatus,workflowResult:o.workflowResult,customMessage:o.customMessage});default:return e.jsx(_,{children:e.jsxs(H,{className:"py-12 text-center",children:[e.jsx("div",{className:"mb-4",children:e.jsx(ge,{})}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mb-2",children:["Processing step: ",c.title||c.name]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Action type: ",G[c.action]]})]})})}};return e.jsxs("div",{className:`metakyc-sdk ${i||""}`,children:[M(),A()]})};function Zr(t){return we.z.object({questionResults:we.z.any()}).passthrough()}function Xr(t){let r=we.z.array(we.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(i=>s.some(o=>o.endsWith("/*")?i.type.startsWith(o.slice(0,-2)):i.type===o)):!0,{message:"Invalid file type"})}return r}function es(t){const r={};return t.uploadDocumentFiles.forEach(s=>{const a=`file_${s.id}`;r[a]=Xr(s)}),we.z.object(r)}function ts(t){return we.z.any()}function rs(t){return we.z.string().min(1,"This question is required")}function ss(t){const r={};return t.appropriatenessQuestions.forEach(s=>{const a=`question_${s.id}`;r[a]=rs()}),we.z.object(r)}const as=we.z.any();exports.ALLOWED_LANGUAGES=Ze;exports.ApplicantProgressOnHoldReason=ot;exports.ApplicantProgressStatus=xe;exports.ApplicantService=wt;exports.ApplicantStatus=ct;exports.AppropriatenessQuestionType=ht;exports.AppropriatenessTestService=Nt;exports.AppropriatenessTestStep=yr;exports.Badge=ve;exports.BaseInformationService=Et;exports.Button=W;exports.Card=_;exports.CardContent=H;exports.CardFooter=le;exports.CardHeader=ie;exports.CountriesType=Ie;exports.CreateApplicantForm=Vr;exports.CriteriaBuiltInType=gt;exports.DEFAULT_VISIBLE_FIELDS=ft;exports.DocumentReviewStatus=mt;exports.EndpointBuilder=vt;exports.ErrorHandler=Fe;exports.EventEmitter=zt;exports.FIELD_METADATA=Re;exports.FileType=pt;exports.FileUpload=ir;exports.GenderType=Ue;exports.Header=Ye;exports.HttpClient=kt;exports.IdentityProviderManager=Pe;exports.IdentityService=At;exports.IdentityVerificationProvider=he;exports.IdentityVerificationStep=fr;exports.Input=ne;exports.InvestorCategorizationService=It;exports.InvestorCategorizationStep=gr;exports.InvestorCategorizationType=pe;exports.InvestorCategoryType=yt;exports.KycProcessStatus=dt;exports.KycStatus=Ne;exports.KycStatusDisplay=Xe;exports.KycWorkflow=Jr;exports.Logo=br;exports.MetaKYCContext=tt;exports.MetaKYCError=fe;exports.MetaKYCProvider=Cr;exports.MultiSelect=nr;exports.OnfidoProvider=Ut;exports.OverviewService=Ct;exports.OverviewStep=hr;exports.PhoneInput=or;exports.QuestionnaireService=jt;exports.QuestionnaireStep=pr;exports.ReviewStatus=Ce;exports.RiskCriteriaType=xt;exports.RiskLevel=lt;exports.RiskScoringService=Rt;exports.RiskScoringStep=xr;exports.SardinAIProvider=Kt;exports.SearchableSelect=ke;exports.Select=Qe;exports.Spinner=ge;exports.StepRouter=$t;exports.SumsubProvider=Ht;exports.ThemeManager=Wt;exports.ThemePreset=ae;exports.ThemeService=Ot;exports.UploadDocumentService=St;exports.UploadDocumentStep=mr;exports.UserType=ut;exports.ValueDataType=be;exports.WorkflowOrchestrator=_t;exports.WorkflowResultType=He;exports.WorkflowState=Bt;exports.WorkflowStepAction=G;exports.appropriatenessTestSchema=as;exports.clearAllStorage=Pr;exports.clearApplicantId=Gt;exports.clearWorkflowState=Jt;exports.cn=re;exports.corporateTheme=Pt;exports.defaultConfig=bt;exports.defaultTheme=ce;exports.fileToBase64=Yt;exports.fintechTheme=Tt;exports.formatFileSize=We;exports.generateAppropriatenessSchema=ss;exports.generateQuestionnaireSchema=Zr;exports.generateRiskScoringSchema=ts;exports.generateUploadDocumentSchema=es;exports.getAcceptString=Er;exports.getApplicantId=Qt;exports.getThemePreset=Le;exports.getWorkflowState=Ir;exports.healthcareTheme=Ft;exports.isScriptLoaded=Sr;exports.loadScript=et;exports.minimalTheme=Dt;exports.modernTheme=Lt;exports.removeScript=Nr;exports.saveApplicantId=qt;exports.saveWorkflowState=Vt;exports.themePresets=Mt;exports.useApplicant=ar;exports.useAppropriatenessTest=Tr;exports.useIdentityVerification=rr;exports.useKycWorkflow=Zt;exports.useMetaKYC=de;exports.useOverview=tr;exports.useQuestionnaire=Xt;exports.useRiskScoring=sr;exports.useUploadDocument=er;exports.validateFileSize=Rr;exports.validateFileType=Ar;
118
+ `,children:B+1}),e.jsx("span",{className:`ml-2 text-sm ${k?"font-semibold text-gray-900 dark:text-white":"text-gray-600 dark:text-gray-400"}`,children:w.displayName||w.name||A(w.action)||`Step ${B+1}`})]}),B<P.length-1&&e.jsx("div",{className:`flex-1 h-0.5 mx-4 ${K?"bg-primary-500":"bg-gray-200 dark:bg-gray-700"}`})]},w.order)})})]})},R=()=>{const P={applicantId:t,onComplete:async()=>{await f()},onBack:c.order>0?j:void 0};switch(c.action){case G.Questionaries:return e.jsx(pr,{...P});case G.UploadDocument:return e.jsx(mr,{...P});case G.Overview:return e.jsx(hr,{...P});case G.IdentitySdk:return e.jsx(fr,{...P});case G.RiskScoring:return e.jsx(xr,{...P});case G.AdditionalData:case G.InvestorCategorization:return e.jsx(yr,{...P});case G.AppropriatenessTest:return e.jsx(gr,{...P});case G.ManualReview:return e.jsx(Xe,{kycStatus:o.kycStatus,reviewStatus:o.reviewStatus,workflowResult:o.workflowResult,customMessage:o.customMessage});default:return e.jsx(_,{children:e.jsxs(H,{className:"py-12 text-center",children:[e.jsx("div",{className:"mb-4",children:e.jsx(ye,{})}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mb-2",children:["Processing step: ",c.title||c.name]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Action type: ",G[c.action]]})]})})}};return e.jsxs("div",{className:`metakyc-sdk ${i||""}`,children:[M(),R()]})};function Xr(t){return we.z.object({questionResults:we.z.any()}).passthrough()}function es(t){let r=we.z.array(we.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(i=>s.some(o=>o.endsWith("/*")?i.type.startsWith(o.slice(0,-2)):i.type===o)):!0,{message:"Invalid file type"})}return r}function ts(t){const r={};return t.uploadDocumentFiles.forEach(s=>{const a=`file_${s.id}`;r[a]=es(s)}),we.z.object(r)}function rs(t){return we.z.any()}function ss(t){return we.z.string().min(1,"This question is required")}function as(t){const r={};return t.appropriatenessQuestions.forEach(s=>{const a=`question_${s.id}`;r[a]=ss()}),we.z.object(r)}const ns=we.z.any();exports.ALLOWED_LANGUAGES=Ze;exports.ApplicantProgressOnHoldReason=ot;exports.ApplicantProgressStatus=xe;exports.ApplicantService=wt;exports.ApplicantStatus=ct;exports.AppropriatenessQuestionType=ht;exports.AppropriatenessTestService=Nt;exports.AppropriatenessTestStep=gr;exports.Badge=ve;exports.BaseInformationService=At;exports.Button=W;exports.Card=_;exports.CardContent=H;exports.CardFooter=le;exports.CardHeader=ie;exports.CountriesType=Ie;exports.CreateApplicantForm=Jr;exports.CriteriaBuiltInType=yt;exports.DEFAULT_VISIBLE_FIELDS=ft;exports.DocumentReviewStatus=mt;exports.EndpointBuilder=vt;exports.ErrorHandler=Fe;exports.EventEmitter=$t;exports.FIELD_METADATA=Ee;exports.FileType=pt;exports.FileUpload=ir;exports.GenderType=Ue;exports.Header=Ye;exports.HttpClient=kt;exports.IdentityProviderManager=Pe;exports.IdentityService=Rt;exports.IdentityVerificationProvider=he;exports.IdentityVerificationStep=fr;exports.Input=ne;exports.InvestorCategorizationService=It;exports.InvestorCategorizationStep=yr;exports.InvestorCategorizationType=pe;exports.InvestorCategoryType=gt;exports.KycProcessStatus=dt;exports.KycStatus=Ne;exports.KycStatusDisplay=Xe;exports.KycWorkflow=Zr;exports.Logo=br;exports.MetaKYCContext=tt;exports.MetaKYCError=fe;exports.MetaKYCProvider=Er;exports.MultiSelect=nr;exports.OnfidoProvider=Ut;exports.OverviewService=Ct;exports.OverviewStep=hr;exports.PhoneInput=or;exports.QuestionnaireService=jt;exports.QuestionnaireStep=pr;exports.ReviewStatus=Ce;exports.RiskCriteriaType=xt;exports.RiskLevel=lt;exports.RiskScoringService=Et;exports.RiskScoringStep=xr;exports.SardinAIProvider=Kt;exports.SearchableSelect=ke;exports.Select=Qe;exports.Spinner=ye;exports.StepRouter=Bt;exports.SumsubProvider=Ht;exports.ThemeManager=Wt;exports.ThemePreset=ae;exports.ThemeService=Ot;exports.UploadDocumentService=St;exports.UploadDocumentStep=mr;exports.UserType=ut;exports.ValueDataType=be;exports.WorkflowOrchestrator=_t;exports.WorkflowResultType=He;exports.WorkflowState=zt;exports.WorkflowStepAction=G;exports.appropriatenessTestSchema=ns;exports.clearAllStorage=Tr;exports.clearApplicantId=Gt;exports.clearWorkflowState=Jt;exports.cn=re;exports.corporateTheme=Pt;exports.defaultConfig=bt;exports.defaultTheme=ce;exports.fileToBase64=Yt;exports.fintechTheme=Tt;exports.formatFileSize=We;exports.generateAppropriatenessSchema=as;exports.generateQuestionnaireSchema=Xr;exports.generateRiskScoringSchema=rs;exports.generateUploadDocumentSchema=ts;exports.getAcceptString=Ir;exports.getApplicantId=Qt;exports.getThemePreset=Le;exports.getWorkflowState=Pr;exports.healthcareTheme=Ft;exports.isScriptLoaded=Sr;exports.loadScript=et;exports.minimalTheme=Dt;exports.modernTheme=Lt;exports.removeScript=Nr;exports.saveApplicantId=qt;exports.saveWorkflowState=Vt;exports.themePresets=Mt;exports.useApplicant=ar;exports.useAppropriatenessTest=Fr;exports.useIdentityVerification=rr;exports.useKycWorkflow=Zt;exports.useMetaKYC=de;exports.useOverview=tr;exports.useQuestionnaire=Xt;exports.useRiskScoring=sr;exports.useUploadDocument=er;exports.validateFileSize=Rr;exports.validateFileType=Ar;
69
119
  //# sourceMappingURL=index.cjs.map