1import{j as e}from"./vendor-motion-DLPIEEQC.js";import{a as b}from"./vendor-clerk-CU2QHutX.js";import{d as _e,u as ue,e as he,f as _,i as J,h as Ye,T as Q,z as G,A as Z,F as Qe,a as Ge}from"./index-BJQWevFb.js";import{u as Y}from"./useMutation-CAmBO9IL.js";import{C as R,a as ye,b as be,c as T}from"./card-BDpPZFml.js";import{B as y}from"./button-5dYAc1j6.js";import{B as M}from"./badge-imNVmoPi.js";import{D as X,a as ee,b as se,c as re,g as Me,d as Ze,e as We}from"./dialog-DHAQQ0TF.js";import{A as ve,a as Ne,b as we,c as Ce,d as Se,e as ke,f as Pe,g as De}from"./alert-dialog-DgpeBVEQ.js";import{A as Je,a as Xe}from"./alert-CLpkwuvT.js";import{B as Ae}from"./business-avatar-HRstBUQk.js";import{I as S}from"./input-PZ7U7Nwc.js";import{L as H}from"./label-Cy9tyBVc.js";import{S as ce,a as de,d as me,b as xe,c as k}from"./select-DuTEQT7a.js";import{C as L}from"./checkbox-BaB8qyPs.js";import{U as Fe}from"./users-COnQx6yP.js";import{F as le}from"./file-text-BdfBa5vK.js";import{C as ze}from"./circle-check-big-U3tmh5xD.js";import{U as He}from"./user-plus-BLNMUa4A.js";import{T as Ve}from"./trash-2-B7zm-E7K.js";import{u as es}from"./use-mobile-eBv7ktgh.js";import{R as ss}from"./refresh-cw-Do43LgNH.js";import{a as rs,d as ts,t as as,o as Ke,s as q,f as B,n as Ie,c as ns,e as is,Z as Re}from"./types-DukCuPG7.js";import{F as ls,a as u,b as h,c as p,d as j,e as F}from"./form-DWzPKCaN.js";import{T as je}from"./textarea-fwGYska5.js";import{I as W}from"./info-DWinl5pS.js";import{M as os}from"./prospera-b4Yi2O8o.js";import{g as Oe,a as cs,h as Te}from"./documents-tab-DliDQf5P.js";import{S as ds,a as ms}from"./business-status-D8oSS22y.js";import{D as Ee}from"./DashboardCenteredPage-yT-MDYuy.js";import{A as Le}from"./arrow-left-CPXAZ-Jg.js";import{H as xs}from"./headphones-uPRYXcNh.js";import{C as us}from"./circle-alert-B-5wgi1f.js";import{D as Be}from"./download-DpWOIsNh.js";import{S as ge}from"./shield-Ded-oaZB.js";import"./vendor-recharts-DRz6xlqx.js";import"./index-D7fGDeK1.js";import"./index-D1OMrIlo.js";import"./index-BdQq_4o_.js";import"./index-T33cpJpH.js";import"./index-Bqck3Hll.js";import"./chevron-down-DLfK0AgY.js";import"./check-CjHBYyse.js";import"./chevron-up-B9e43JY2.js";import"./sidebar-B9LzcOJt.js";import"./marketing-site-rfmqDE6p.js";import"./sheet-C3k7nLO_.js";import"./building-DCVHy0PP.js";import"./landmark-0W-kVsq9.js";import"./menu-C2IXzp-z.js";import"./globe-BwE0TC0y.js";import"./receipt-CqBUdry_.js";import"./chevron-right-CHnH-lub.js";import"./trending-up-CUB-_uax.js";import"./tag-DLP733Ib.js";import"./pen-tool-0k8L4lUH.js";import"./send-BomWvx3o.js";import"./circle-question-mark-DP5udTf3.js";import"./plus-DVf9dG66.js";import"./mail-Dr1EBJp_.js";import"./page-business-header-CXbYLQvU.js";import"./folder-open-pKtwQBw2.js";import"./clock-BGJrxBZ1.js";const hs=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],qe=_e("camera",hs),ps=(d,O)=>J({queryKey:["/api/businesses",d,"founders"],enabled:!!d&&O,staleTime:0});function js({businessId:d,founders:O,isOpen:l,onClose:i}){const{data:g}=ps(d,l),f=g||O,[N,w]=b.useState("allocate"),[x,v]=b.useState([]),[t,U]=b.useState([]),[D,P]=b.useState(null),{toast:A}=ue(),E=he();b.useEffect(()=>{if(l&&f.length>0){const s=f.map(r=>({founderId:r.id,firstName:r.firstName,lastName:r.lastName,email:r.email,role:r.role||"Owner",ownershipPercentage:parseFloat(r.ownershipPercentage),isNew:!1}));v(s),w("allocate"),U([])}},[l,f]);const o=Y({mutationFn:async s=>(await _("POST",`/api/businesses/${d}/redistribute-shares`,s)).json(),onSuccess:s=>{E.invalidateQueries({queryKey:["/api/businesses",d,"founders"]}),E.invalidateQueries({queryKey:["/api/businesses",d,"documents"]}),A({title:"Share Redistribution Initiated",description:"Share redistribution document has been created and is pending signatures."}),i()},onError:s=>{A({title:"Error",description:s.message||"Failed to redistribute shares",variant:"destructive"})}}),I=x.reduce((s,r)=>s+r.ownershipPercentage,0),$=Math.abs(I-100)<.01,z=()=>
1{v(s=>[...s,{firstName:"",lastName:"",email:"",role:"Owner",ownershipPercentage:0,isNew:!0}])},c=(s,r,n)=>{v(m=>m.map((K,a)=>a===s?{...K,[r]:n}:K))},te=s=>{v(r=>r.filter((n,m)=>m!==s)),P(null)},oe=s=>{P(s)},V=()=>{N==="allocate"&&$?w("review"):N==="review"?w("signatories"):N==="signatories"&&w("document")},ae=()=>{o.mutate({shareAllocations:x,signatories:t})},ne=s=>{const n=x[s].founderId||`new-${s}`;U(m=>m.includes(n)?m.filter(K=>K!==n):[...m,n])};return e.jsx(X,{open:l,onOpenChange:i,children:e.jsxs(ee,{className:"max-w-4xl max-h-[90vh] overflow-y-auto mx-4",children:[e.jsx(se,{children:e.jsxs(re,{className:"flex items-center gap-2 text-lg lg:text-xl",children:[e.jsx(Fe,{className:"w-5 h-5"}),"Share Redistribution"]})}),e.jsx("div",{className:"flex items-center justify-between mb-4 lg:mb-6 overflow-x-auto pb-2",children:[{key:"allocate",label:"Allocate Shares",icon:Fe},{key:"review",label:"Review Changes",icon:le},{key:"signatories",label:"Select Signatories",icon:ze},{key:"document",label:"Generate Document",icon:le}].map((s,r)=>{const n=s.icon,m=N===s.key,K=["allocate","review","signatories"].indexOf(N)>["allocate","review","signatories"].indexOf(s.key);return e.jsxs("div",{className:"flex items-center flex-shrink-0",children:[e.jsx("div",{className:`w-8 h-8 lg:w-10 lg:h-10 rounded-full flex items-center justify-center text-xs lg:text-sm ${m?"bg-prospin-red text-white":K?"bg-green-500 text-white":"bg-gray-200 text-gray-500"}`,children:e.jsx(n,{className:"w-4 h-4"})}),e.jsx("span",{className:`ml-2 text-sm ${m?"font-semibold":""}`,children:s.label}),r<3&&e.jsx("div",{className:"w-12 h-px bg-gray-300 mx-4"})]},s.key)})}),N==="allocate"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Redistribute Ownership Shares"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(M,{variant:$?"default":"destructive",children:["Total: ",I.toFixed(1),"%"]}),e.jsxs(y,{size:"sm",onClick:z,variant:"outline",children:[e.jsx(He,{className:"w-4 h-4 mr-2"}),"Add New Owner"]})]})]}),e.jsx("div",{className:"space-y-4",children:x.map((s,r)=>e.jsx(R,{className:"p-4",children:e.jsxs("div",{className:"grid grid-cols-12 gap-4 items-end",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(H,{children:"First Name"}),e.jsx(S,{value:s.firstName,onChange:n=>c(r,"firstName",n.target.value),disabled:!s.isNew})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(H,{children:"Last Name"}),e.jsx(S,{value:s.lastName,onChange:n=>c(r,"lastName",n.target.value),disabled:!s.isNew})]}),e.jsxs("div",{className:"col-span-3",children:[e.jsx(H,{children:"Email"}),e.jsx(S,{type:"email",value:s.email,onChange:n=>c(r,"email",n.target.value),disabled:!s.isNew})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(H,{children:"Role"}),e.jsxs(ce,{value:s.role,onValueChange:n=>c(r,"role",n),children:[e.jsx(de,{children:e.jsx(me,{})}),e.jsxs(xe,{children:[e.jsx(k,{value:"Founder",children:"Founder"}),e.jsx(k,{value:"CEO",children:"CEO"}),e.jsx(k,{value:"CTO",children:"CTO"}),e.jsx(k,{value:"CFO",children:"CFO"}),e.jsx(k,{value:"COO",children:"COO"}),e.jsx(k,{value:"Director",children:"Director"}),e.jsx(k,{value:"Investor",children:"Investor"}),e.jsx(k,{value:"Owner",children:"Owner"})]})]})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(H,{children:"Ownership %"}),e.jsx(S,{type:"number",min:"0",max:"100",step:"0.1",value:s.ownershipPercentage,onChange:n=>c(r,"ownershipPercentage",parseFloat(n.target.value)||0)})]}),e.jsx("div",{className:"col-span-1",children:x.length>1&&e.jsx(y,{size:"sm",variant:"destructive",onClick:()=>oe(r),className:"w-8 h-8 p-0 bg-red-50 hover:bg-red-100 border border-red-200 hover:border-red-300",children:e.jsx(Ve,{className:"w-4 h-4 text-red-600 stroke-2"})})})]})},r))}),!$&&e.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:e.jsxs("p",{className:"text-red-800 text-sm",children:["Total ownership must equal exactly 100%. Current total: ",I.toFixed(1),"%"]})})]}),N==="review"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Review Share Changes"}),e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:"Current Ownership"}),e.jsx("div",{className:"space-y-2",children:f.map(s=>e.jsxs("div",{className:"flex justify-between p-2 bg-gray-50 rounded",children:[e.jsxs("span",{children:[s.firstName," ",s.lastName]}),e.jsxs("span",{children:[parseFloat(s.ownershipPercentage).toFixed(1),"%"]})]},s.id))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:"New Ownership"}),e.jsx("div",{className:"space-y-2",children:x.map((s,r)=>e.jsxs("div",{className:"flex justify-between p-2 bg-green-50 rounded",children:[e.jsxs("span",{children:[s.firstName," ",s.lastName,s.isNew&&e.jsx(M,{className:"ml-2",variant:"secondary",children:"New"})]}),e.jsxs("span",{children:[s.ownershipPercentage.toFixed(1),"%"]})]},r))})]})]})]}),N==="signatories"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Select Required Signatories"}),e.jsx("p",{className:"text-gray-600",children:"Choose which owners must sign the share redistribution document."}),e.jsx("div",{className:"space-y-3",children:x.map((s,r)=>{const n=s.founderId||`new-${r}`,m=t.includes(n);return e.jsxs("div",{className:"flex items-center space-x-3 p-3 border rounded-lg",children:[e.jsx(L,{checked:m,onCheckedChange:()=>ne(r)}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-medium",children:[s.firstName," ",s.lastName,s.isNew&&e.jsx(M,{className:"ml-2",variant:"secondary",children:"New Owner"})]}),e.jsxs("div",{className:"text-sm text-gray-500",children:[s.email," ⢠",s.role," ⢠",s.ownershipPercentage.toFixed(1),"%"]})]})]},r)})}),t.length===0&&e.jsx("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-4",children:e.jsx("p",{className:"text-yellow-800 text-sm",children:"Please select at least one signatory for the redistribution document."})})]}),N==="document"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Generate Share Redistribution Document"}),e.jsx("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(le,{className:"w-5 h-5 text-blue-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-blue-900",children:"Share Redistribution Agreement"}),e.jsx("p",{className:"text-blue-800 text-sm mt-1",children:"This document will formalize the ownership changes and require signatures from selected parties."})]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium",children:"Document Summary:"}),e.jsxs("ul",{className:"space-y-2 text-sm",children:[e.jsx("li",{children:"⢠New ownership structure with 4 owners"}),e.jsxs("li",{children:["⢠",x.filter(s=>s.isNew).length," new owners to be added"]}),e.jsxs("li",{children:["⢠",t.length," required signatures"]}),e.jsx("li",{children:"⢠Document will be sent out for signing and ownership will be updated to pending"})]})]})]}),e.jsxs("div",{className:"flex justify-between pt-6 border-t",children:[e.jsx(y,{variant:"outline",onClick:i,children:"Cancel"}),e.jsxs("div",{className:"flex gap-2",children:[N!=="allocate"&&e.jsx(y,{variant:"outline",onClick:()=>{const s=["allocate","review","signatories","document"],r=s.indexOf(N);w(s[r-1])},children:"Back"}),N!=="document"?e.jsx(y,{onClick:V,disabled:N==="allocate"&&!$,children:"Next"}):e.jsx(y,{onClick:ae,disabled:o.isPending||t.length===0,children:o.isPending?"Processing...":"Generate Document & Redistribute"})]})]}),e.jsx(X,{open:D!==null,onOpenChange:()=>P(null),children:e.jsxs(ee,{className:"max-w-md",children:[e.jsx(se,{children:e.jsx(re,{children:"Remove Owner"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-gray-600",children:"Are you sure you want to remove this owner from the ownership structure?"}),D!==null&&x[D]&&e.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[e.jsxs("div",{className:"font-medium",children:[x[D].firstName," ",x[D].lastName]}),e.jsxs("div",{className:"text-sm text-gray-500",children:[x[D].ownershipPercentage.toFixed(1),"% ownership"]})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(y,{variant:"outline",onClick:()=>P(null),children:"Cancel"}),e.jsx(y,{variant:"destructive",onClick:()=>D!==null&&te(D),children:"Remove Owner"})]})]})]})})]})})}function gs({businessId:d}){const[O,l]=b.useState(!1),[i,g]=b.useState(null),[f,N]=b.useState(!1),{toast:w}=ue(),x=he();es();const{data:v=[],isLoading:t}=J({queryKey:["/api/businesses",d,"founders"],enabled:!!d}),U=Y({mutationFn:async o=>(await _("POST",`/api/businesses/${d}/founders`,o)).json(),onSuccess:()=>{x.invalidateQueries({queryKey:["/api/businesses",d,"founders"]}
1),l(!1),w({title:"Owner Added",description:"New business owner has been added successfully."})},onError:o=>{w({title:"Error",description:o.message||"Failed to add owner",variant:"destructive"})}}),D=Y({mutationFn:async({founderId:o,data:I})=>(await _("PUT",`/api/founders/${o}`,I)).json(),onSuccess:()=>{x.invalidateQueries({queryKey:["/api/businesses",d,"founders"]}),g(null),w({title:"Owner Updated",description:"Business owner information has been updated successfully."})},onError:o=>{w({title:"Error",description:o.message||"Failed to update owner",variant:"destructive"})}});Y({mutationFn:async o=>(await _("DELETE",`/api/founders/${o}`)).json(),onSuccess:()=>{x.invalidateQueries({queryKey:["/api/businesses",d,"founders"]}),w({title:"Owner Removed",description:"Business owner has been removed successfully."})},onError:o=>{w({title:"Error",description:o.message||"Failed to remove owner",variant:"destructive"})}});const P=Array.isArray(v)?v:[],A=P.reduce((o,I)=>o+parseFloat(I.ownershipPercentage||0),0),E=Math.abs(A-100)<.01;return t?e.jsxs(R,{className:"border-t-4 border-t-prospin-red",children:[e.jsx(ye,{children:e.jsx(be,{children:"Cap Table - Ownership Structure"})}),e.jsx(T,{children:e.jsx("div",{className:"animate-pulse space-y-4",children:[1,2,3].map(o=>e.jsx("div",{className:"h-16 bg-gray-200 rounded"},o))})})]}):e.jsxs(R,{className:"border-t-4 border-t-prospin-red",children:[e.jsx(ye,{children:e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center lg:justify-between space-y-3 lg:space-y-0",children:[e.jsx(be,{className:"text-lg lg:text-xl",children:"Cap Table - Ownership Structure"}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2 lg:space-x-2",children:[!E&&e.jsxs(M,{variant:"destructive",className:"text-xs",children:["Total: ",A.toFixed(2),"% (Must equal 100%)"]}),e.jsxs(y,{size:"sm",onClick:()=>N(!0),className:"hidden min-h-[44px] lg:min-h-auto",children:[e.jsx(ss,{className:"w-4 h-4 mr-2"}),"Update Owners"]}),e.jsxs(X,{open:O,onOpenChange:l,children:[e.jsx(Me,{asChild:!0,children:e.jsxs(y,{size:"sm",variant:"outline",style:{display:"none"},children:[e.jsx(He,{className:"w-4 h-4 mr-2"}),"Add Owner"]})}),e.jsxs(ee,{children:[e.jsx(se,{children:e.jsx(re,{children:"Add New Business Owner"})}),e.jsx(Ue,{onSubmit:o=>U.mutate(o),isLoading:U.isPending,remainingOwnership:100-A})]})]})]})]})}),e.jsxs(T,{className:"p-0",children:[e.jsx("div",{className:"lg:hidden",children:P.length>0?e.jsxs("div",{className:"divide-y divide-gray-200",children:[P.map(o=>e.jsx("div",{className:"p-4 hover:bg-gray-50",children:e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("h4",{className:"text-sm font-medium text-gray-900 break-words",children:[o.firstName," ",o.lastName]}),e.jsx("p",{className:"text-xs text-blue-600 mt-1 break-all",children:o.email}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:o.role||"Owner"})]}),e.jsx("div",{className:"flex-shrink-0 ml-3",children:e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"text-lg font-bold text-gray-900",children:[parseFloat(o.ownershipPercentage).toFixed(2),"%"]}),e.jsx(M,{variant:o.kycStatus==="completed"?"default":"secondary",className:"text-xs mt-1",children:o.kycStatus==="completed"?"Verified":"Pending"})]})})]})},o.id)),e.jsx("div",{className:`p-4 font-semibold ${E?"bg-green-50":"bg-red-50"}`,children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-gray-900",children:"Total Ownership"}),e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"text-lg font-bold text-gray-900",children:[A.toFixed(2),"%"]}),e.jsx(M,{variant:E?"default":"destructive",className:"text-xs",children:E?"Valid":"Invalid"})]})]})})]}):e.jsx("div",{className:"p-6 text-center text-gray-500",children:'No owners added yet. Use "Update Owners" to get started.'})}),e.jsx("div",{className:"hidden lg:block p-6",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"border-b",children:e.jsxs("tr",{className:"text-left",children:[e.jsx("th",{className:"pb-3 font-semibold text-gray-700",children:"Name"}),e.jsx("th",{className:"pb-3 font-semibold text-gray-700",children:"Email"}),e.jsx("th",{className:"pb-3 font-semibold text-gray-700",children:"Role"}),e.jsx("th",{className:"pb-3 font-semibold text-gray-700 text-right",children:"Ownership %"}),e.jsx("th",{className:"pb-3 font-semibold text-gray-700 text-right",children:"Status"})]})}),e.jsxs("tbody",{children:[P.length>0?P.map(o=>e.jsxs("tr",{className:"border-b",children:[e.jsxs("td",{className:"py-3 font-medium",children:[o.firstName," ",o.lastName]}),e.jsx("td",{className:"py-3 text-blue-600",children:o.email}),e.jsx("td",{className:"py-3 text-gray-600",children:o.role||"Owner"}),e.jsxs("td",{className:"py-3 text-right font-semibold",children:[parseFloat(o.ownershipPercentage).toFixed(2),"%"]}),e.jsx("td",{className:"py-3 text-right",children:e.jsx(M,{variant:o.kycStatus==="completed"?"default":"secondary",children:o.kycStatus==="completed"?"Verified":"Pending"})})]},o.id)):e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"py-6 text-center text-gray-500",children:'No owners added yet. Use "Update Owners" to get started.'})}),P.length>0&&e.jsxs("tr",{className:`border-b-2 font-semibold ${E?"border-green-300 bg-green-50":"border-red-300 bg-red-50"}`,children:[e.jsx("td",{className:"py-3",children:"Total"}),e.jsx("td",{className:"py-3"}),e.jsx("td",{className:"py-3"}),e.jsxs("td",{className:"py-3 text-right",children:[A.toFixed(2),"%"]}
1),e.jsx("td",{className:"py-3 text-right",children:E?e.jsx(M,{className:"bg-green-600",children:"Valid"}):e.jsx(M,{variant:"destructive",children:"Invalid"})})]})]})]})})}),e.jsx(X,{open:!!i,onOpenChange:()=>g(null),children:e.jsxs(ee,{children:[e.jsx(se,{children:e.jsx(re,{children:"Edit Business Owner"})}),i&&e.jsx(Ue,{initialData:i,onSubmit:o=>D.mutate({founderId:i.id,data:o}),isLoading:D.isPending,remainingOwnership:100-A+parseFloat(i.ownershipPercentage)})]})}),e.jsx(js,{businessId:d,founders:P,isOpen:f,onClose:()=>N(!1)})]})]})}function Ue({initialData:d,onSubmit:O,isLoading:l,remainingOwnership:i}){const[g,f]=b.useState({firstName:d?.firstName||"",lastName:d?.lastName||"",email:d?.email||"",role:d?.role||"Founder",ownershipPercentage:d?.ownershipPercentage||""}),N=v=>{v.preventDefault();const t=parseFloat(g.ownershipPercentage);t<=0||t>i||O({...g,ownershipPercentage:t})},w=parseFloat(g.ownershipPercentage)||0,x=w>0&&w<=i;return e.jsxs("form",{onSubmit:N,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(H,{htmlFor:"firstName",children:"First Name"}),e.jsx(S,{id:"firstName",value:g.firstName,onChange:v=>f(t=>({...t,firstName:v.target.value})),required:!0,"data-testid":"input-first-name"})]}),e.jsxs("div",{children:[e.jsx(H,{htmlFor:"lastName",children:"Last Name"}),e.jsx(S,{id:"lastName",value:g.lastName,onChange:v=>f(t=>({...t,lastName:v.target.value})),required:!0,"data-testid":"input-last-name"})]})]}),e.jsxs("div",{children:[e.jsx(H,{htmlFor:"email",children:"Email Address"}),e.jsx(S,{id:"email",type:"email",value:g.email,onChange:v=>f(t=>({...t,email:v.target.value})),required:!0,"data-testid":"input-email"})]}),e.jsxs("div",{children:[e.jsx(H,{htmlFor:"role",children:"Role"}),e.jsxs(ce,{value:g.role,onValueChange:v=>f(t=>({...t,role:v})),children:[e.jsx(de,{"data-testid":"select-role",children:e.jsx(me,{placeholder:"Select role"})}),e.jsxs(xe,{children:[e.jsx(k,{value:"Founder",children:"Founder"}),e.jsx(k,{value:"CEO",children:"CEO"}),e.jsx(k,{value:"CTO",children:"CTO"}),e.jsx(k,{value:"CFO",children:"CFO"}),e.jsx(k,{value:"COO",children:"COO"}),e.jsx(k,{value:"Director",children:"Director"}),e.jsx(k,{value:"Investor",children:"Investor"}),e.jsx(k,{value:"Advisor",children:"Advisor"})]})]})]}),e.jsxs("div",{children:[e.jsxs(H,{htmlFor:"ownership",children:["Ownership Percentage",e.jsxs("span",{className:"text-sm text-gray-500",children:["(Available: ",i.toFixed(2),"%)"]})]}),e.jsx(S,{id:"ownership",type:"number",min:"0.1",max:i,step:"0.1",value:g.ownershipPercentage,onChange:v=>f(t=>({...t,ownershipPercentage:v.target.value})),required:!0,"data-testid":"input-ownership"}),!x&&w>0&&e.jsxs("p",{className:"text-sm text-red-600 mt-1",children:["Ownership cannot exceed ",i.toFixed(2),"%"]})]}),e.jsx("div",{className:"flex justify-end space-x-2",children:e.jsx(y,{type:"submit",disabled:l||!x,"data-testid":"button-save-founder",children:l?"Saving...":d?"Update Owner":"Add Owner"})})]})}const fs=Ke({fullName:q().min(1,"Full name is required"),jobTitle:q().min(1,"Job title is required"),education:q().min(1,"Education is required"),experience:q().min(1,"Experience is required"),hasCreditScore:B().default(!1),priorInjuryLoss:B().default(!1),currentOnDebtTaxes:B().default(!0),hasBankingRelationships:B().default(!1),hasInsurancePolicies:B().default(!1),criminalHistory:B().default(!1),hasAssetsOrResidencyInProsperaOrUSA:B().default(!1),relatedToProsperaEmployees:B().default(!1),litigationLast10Years:B().default(!1),cvResumeUrl:q().url().optional()}),ys=Ke({insuredCompanyName:q().min(1,"Company name is required"),insuredResidentPermitNumber:q().optional(),insuredIndustry:q().min(1,"Industry is required"),regulatoryFramework:is(["common_law","peer_country"]).default("common_law"),peerCountry:q().optional(),businessTypeAndSales:q().min(1,"Please describe income-producing activities or enter 'None'").trim(),industryActivities:q().min(1,"Please describe the industry activities"),projectedFundsUSD:Ie().min(0,"Projection must be 0 or greater"),people:ns(fs).default([]),activitiesLocation:q().min(1,"Please enter the activities location"),hazardousDisclosure:B().default(!1),enforcementPolicyStatement:B().default(!1),enforcementPolicyDescription:q().optional(),haveEmployees:B().default(!1),maxAcceptablePremiumUSD:Ie().min(0,"Please enter a non-negative amount"),agree:B().refine(d=>d===!0,{message:"You must agree before submitting"})}).superRefine((d,O)=>{d.regulatoryFramework==="peer_country"&&!d.peerCountry&&O.addIssue({code:Re.custom,message:"Please select a peer country",path:["peerCountry"]}),d.enforcementPolicyStatement&&!d.enforcementPolicyDescription&&O.addIssue({code:Re.custom,message:"Please describe the enforcement policy statement status",path:["enforcementPolicyDescription"]})}),bs=["Australia","Austria","Belgium","Canada","Chile","Denmark","Dubai","Estonia","Finland","France","Germany","Honduras","Hong Kong","Iceland","Ireland","Israel","Italy","Japan","Luxembourg","Mexico","Netherlands","New Zealand","Norway","Poland","Singapore","South Korea","Spain","Sweden","Switzerland","United Kingdom","United States of America"];function $e({business:d,onSubmitted:O,readOnly:l=!1,initialValues:i=null}){const{user:g}=Ye(),{toast:f}=ue(),N=he(),[w,x]=b.useState(!1),v=b.useRef(null),t=rs({mode:"onChange",reValidateMode:"onChange",resolver:as(ys),defaultValues:{insuredCompanyName:i?.insuredCompanyName??d?.name??"",insuredResidentPermitNumber:i?.insuredResidentPermitNumber??d?.businessPermitNumber??"",insuredIndustry:i?.insuredIndustry??d?.industry??"",regulatoryFramework:i?.regulatoryFramework??"common_law",peerCountry:i?.peerCountry,businessTypeAndSales:i?.businessTypeAndSales??d?.activityDescription??"",industryActivities:i?.industryActivities??"",projectedFundsUSD:i?.projectedFundsUSD??0,people:i?.people??[],activitiesLocation:i?.activitiesLocation??d?.registeredAddress??"",hazardousDisclosure:i?.hazardousDisclosure??!1,enforcementPolicyStatement:i?.enforcementPolicyStatement??!1,enforcementPolicyDescription:i?.enforcementPolicyDescription??"",haveEmployees:i?.haveEmployees??!!d?.numberOfEmployees,maxAcceptablePremiumUSD:i?.maxAcceptablePremiumUSD??0,agree:i?.agree??!1}}),U=t.formState.isValid;b.useEffect(()=>{i&&t.reset({insuredCompanyName:i.insuredCompanyName??d?.name??"",insuredResidentPermitNumber:i.insuredResidentPermitNumber??d?.businessPermitNumber??"",insuredIndustry:i.insuredIndustry??d?.industry??"",regulatoryFramework:i.regulatoryFramework??"common_law",peerCountry:i.peerCountry,businessTypeAndSales:i.businessTypeAndSales??d?.activityDescription??"",industryActivities:i.industryActivities??"",projectedFundsUSD:i.projectedFundsUSD??0,people:i.people??[],activitiesLocation:i.activitiesLocation??d?.registeredAddress??"",hazardousDisclosure:i.hazardousDisclosure??!1,enforcementPolicyStatement:i.enforcementPolicyStatement??!1,enforcementPolicyDescription:i.enforcementPolicyDescription??"",haveEmployees:i.haveEmployees??!!d?.numberOfEmployees,maxAcceptablePremiumUSD:i.maxAcceptablePremiumUSD??0,agree:i.agree??!1})},[i]);const D=b.useRef(null),P=b.useRef(null),A=b.useRef(null),E=b.useRef(null),o=b.useRef(null),I=b.useRef(null),$=Y({mutationFn:async s=>(await _("POST","/api/insurance/applications",{businessId:d.id,application:s})).json(),onSuccess:()=>
1{f({title:"Application Submitted",description:"Your insurance application has been submitted successfully."});try{O?.()}catch{}N.invalidateQueries({queryKey:["/api/businesses",d.id,"insurance"]}),t.reset(),v.current?.click()},onError:s=>{f({title:"Submission Failed",description:s.message||"Failed to submit insurance application",variant:"destructive"})}}),z=s=>{x(!0),$.mutate(s,{onSettled:()=>x(!1)})},c=t.watch("regulatoryFramework"),te=t.watch("enforcementPolicyStatement"),oe=t.watch("agree");t.watch("insuredCompanyName"),t.watch("insuredResidentPermitNumber"),t.watch("insuredIndustry");const{fields:V,append:ae,remove:ne}=ts({control:t.control,name:"people"});return e.jsxs(ee,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ze,{ref:v,className:"hidden"}),e.jsxs(se,{children:[e.jsx(re,{children:"Próspera Insurance Company"}),e.jsx(We,{children:l?"Viewing submitted insurance application":"Apply for Regulatory Insurance"})]}),e.jsx("div",{className:"space-y-4",children:e.jsx(R,{children:e.jsx(T,{className:"pt-6 space-y-4 text-sm text-muted-foreground",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-foreground",children:"Próspera uses regulatory insurance, not bureaucratic agencies like the FDA or SEC. Here's how it works:"}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[e.jsx("div",{children:e.jsxs("div",{className:"font-medium text-foreground flex items-center gap-2",children:["1. Choose a regulatory framework",e.jsxs(Q,{children:[e.jsx(G,{asChild:!0,children:e.jsx(W,{className:"h-4 w-4 text-muted-foreground cursor-pointer"})}),e.jsx(Z,{side:"top",className:"max-w-xs text-xs leading-relaxed",children:`Select the legal framework you'll followâcommon law, the regulations of an approved peer country, or an approved "Optimal Regulation". You must run your business according to that regulatory framework.`})]})]})}),e.jsx("div",{children:e.jsxs("div",{className:"font-medium text-foreground flex items-center gap-2",children:["2. Secure a policy",e.
1jsxs(Q,{children:[e.jsx(G,{asChild:!0,children:e.jsx(W,{className:"h-4 w-4 text-muted-foreground cursor-pointer"})}),e.jsx(Z,{side:"top",className:"max-w-xs text-xs leading-relaxed",children:"If you hurt someone, your regulatory insurance will cover part of the damages, and you will be responsible for the rest. Because they're liable if you're out of compliance, they regularly check your business to confirm you're still following the rules."})]})]})}),e.jsx("div",{children:e.jsxs("div",{className:"font-medium text-foreground flex items-center gap-2",children:["3. Operate in Próspera",e.jsxs(Q,{children:[e.jsx(G,{asChild:!0,children:e.jsx(W,{className:"h-4 w-4 text-muted-foreground cursor-pointer"})}),e.jsx(Z,{side:"top",className:"max-w-xs text-xs leading-relaxed",children:"Once you have an insurance policy, you can operate in Próspera. Oversight shifts from a government agency to your insurer, keeping accountability high and bureaucracy low."})]})]})})]}),e.jsx("a",{href:"https://intercom.help/prospera-c3520d800849/en/articles/8275484-the-role-of-regulatory-insurance-for-traditionally-regulated-industries",target:"_blank",rel:"noreferrer",className:"text-prospin-red hover:underline text-xs",children:"Learn more about regulatory insurance"})]})})})}),e.jsx(ls,{...t,children:e.jsx("form",{onSubmit:t.handleSubmit(z,s=>{const r=s;if(r.insuredCompanyName||r.insuredResidentPermitNumber||r.insuredIndustry){D.current?.scrollIntoView({behavior:"smooth",block:"start"});return}if(r.regulatoryFramework||r.peerCountry){P.current?.scrollIntoView({behavior:"smooth",block:"start"});return}if(r.businessTypeAndSales||r.industryActivities||r.projectedFundsUSD){A.current?.scrollIntoView({behavior:"smooth",block:"start"});return}if(r.people){E.current?.scrollIntoView({behavior:"smooth",block:"start"});return}if(r.activitiesLocation||r.hazardousDisclosure||r.enforcementPolicyStatement||r.enforcementPolicyDescription||r.haveEmployees||r.maxAcceptablePremiumUSD){o.current?.scrollIntoView({behavior:"smooth",block:"start"});return}if(r.agree){I.current?.scrollIntoView({behavior:"smooth",block:"start"});return}}),className:"space-y-6",children:e.jsxs("fieldset",{disabled:l,children:[e.jsx(R,{ref:D,children:e.jsxs(T,{className:"pt-6 space-y-4",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold",children:"Insured Information"})}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsx(u,{control:t.control,name:"insuredCompanyName",render:({field:s})=>e.jsxs(h,{children:[e.jsx(p,{children:"Company Name"}),e.jsx(j,{children:e.jsx(S,{readOnly:!0,"aria-readonly":!0,className:"cursor-not-allowed",placeholder:"e.g., Acme Inc.",...s})}),e.jsx(F,{})]})}),e.jsx(u,{control:t.control,name:"insuredResidentPermitNumber",render:({field:s})=>e.jsxs(h,{children:[e.jsx(p,{children:"Resident Permit Number (optional)"}),e.jsx(j,{children:e.jsx(S,{readOnly:!0,"aria-readonly":!0,className:"cursor-not-allowed",placeholder:"e.g., eRes-123456",...s})}),e.jsx(F,{})]})}),e.jsx(u,{control:t.control,name:"insuredIndustry",render:({field:s})=>e.jsxs(h,{className:"sm:col-span-2",children:[e.jsx(p,{children:"Company Industry"}),e.jsx(j,{children:e.jsx(S,{readOnly:!0,"aria-readonly":!0,className:"cursor-not-allowed",placeholder:"e.g., Finance and Insurance",...s})}),e.jsx(F,{})]})})]})]})}),e.jsx(R,{ref:P,children:e.jsxs(T,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Regulatory Framework"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Please choose a regulatory framework for your activities."}),e.jsxs(Q,{children:[e.jsx(G,{asChild:!0,children:e.jsx(W,{className:"h-4 w-4 text-muted-foreground cursor-pointer"})}),e.jsx(Z,{side:"top",className:"max-w-sm text-xs leading-relaxed",children:"Your regulatory election is not permanent, but changing it requires your insurer's agreement and may increase costs. Choose carefully considering your long-term plans."})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 items-end",children:[e.jsx(u,{control:t.control,name:"regulatoryFramework",render:({field:s})=>e.jsxs(h,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{children:"Common Law:"}),e.jsxs(Q,{children:[e.jsx(G,{asChild:!0,children:e.jsx(W,{className:"h-4 w-4 text-muted-foreground cursor-pointer"})}),e.jsx(Z,{side:"top",className:"max-w-xs text-xs leading-relaxed",children:`Select the legal framework you'll followâcommon law, the regulations of an approved peer country, or an approved "Optimal Regulation". You must run your business according to that regulatory framework.`})]})]}),e.jsxs(ce,{value:s.value,onValueChange:s.onChange,children:[e.jsx(j,{children:e.jsx(de,{disabled:l,children:e.jsx(me,{placeholder:"Select a framework"})})}),e.jsxs(xe,{children:[e.jsx(k,{value:"common_law",children:"Common Law (Roatan Common Law Code) (default)"}),e.jsx(k,{value:"peer_country",children:"Peer-country regulations"})]})]}),e.jsx(F,{})]})}),c==="peer_country"&&e.jsx(u,{control:t.control,name:"peerCountry",render:({field:s})=>e.jsxs(h,{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(p,{children:"Peer-country regulations:"})}),e.jsxs(ce,{value:s.value,onValueChange:s.onChange,children:[e.jsx(j,{children:e.jsx(de,{disabled:l,children:e.jsx(me,{placeholder:"Select a country"})})}),e.jsx(xe,{children:bs.map(r=>e.jsx(k,{value:r,children:r},r))})]}),e.jsx(F,{})]})})]}),e.jsxs("div",{className:"text-xs",children:["Need a custom framework? You can propose your own Customized Optimal Regulation via petition if none of these options fit your needs. "," ",e.jsx("a",{href:"https://portal.eprospera.com/en/pic/activity/7493d37c-d21a-4da0-b13f-cf20d90c5546#:~:text=your%20specific%20needs.-,Read%20more%20here,-About%20your%20project",target:"_blank",rel:"noreferrer",className:"text-prospin-red hover:underline",children:"Read more here"})]})]})}),e.jsx(R,{ref:A,children:e.jsxs(T,{className:"pt-6 space-y-4",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold",children:"About Your Business"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(u,{control:t.control,name:"businessTypeAndSales",render:({field:s})=>e.jsxs(h,{children:[e.jsx(p,{children:"Will you be making money inside of Próspera? If yes, what type of business is it and what will you be selling or providing?"}),e.jsx(j,{children:e.jsx(je,{rows:3,placeholder:"Describe income-producing activities",...s})}),e.jsx(F,{})]})}),e.jsx(u,{control:t.control,name:"industryActivities",render:({field:s})=>e.jsxs(h,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{children:'What specific "Industry" activities are you applying to be insured for?'}),e.jsxs(Q,{children:[e.jsx(G,{asChild:!0,children:e.jsx(W,{className:"h-4 w-4 text-muted-foreground cursor-pointer"})}),e.jsx(Z,{side:"top",className:"max-w-sm text-xs leading-relaxed",children:"More detail helps us narrow down the scope of your insurance, ensuring you get the right coverage at the right price."})]})]}),e.jsx(j,{children:e.jsx(je,{rows:4,placeholder:"Enter project description",...s})}),e.jsx(F,{})]})}),e.jsx(u,{control:t.control,name:"projectedFundsUSD",render:({field:s})=>e.jsxs(h,{children:[e.jsx(p,{children:"Reasonable projection of funds to be handled in a fiscal year (USD):"}),e.jsx(j,{children:e.jsx(S,{type:"number",min:0,step:"1",value:Number.isFinite(s.value)?s.value:0,onChange:r=>s.onChange(Number(r.target.value)),placeholder:"$1,000,000"})}),e.jsx("p",{className:"text-xs italic text-muted-foreground",children:"Enter the total dollar amount (e.g., 1,000,000)"}),e.jsx(F,{})]})})]})]})}),e.jsx(R,{ref:E,children:e.jsxs(T,{className:"pt-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"People involved"}),!l&&e.jsx(y,{type:"button",variant:"outline",onClick:()=>ae({fullName:"",jobTitle:"",education:"",experience:"",hasCreditScore:!1,priorInjuryLoss:!1,currentOnDebtTaxes:!0,hasBankingRelationships:!1,hasInsurancePolicies:!1,criminalHistory:!1,hasAssetsOrResidencyInProsperaOrUSA:!1,relatedToProsperaEmployees:!1,litigationLast10Years:!1,cvResumeUrl:""}),children:"+ Add Person"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:"We need a list of people involved in the Finance and Insurance Industry regulated activity. At a minimum, this must include:"}),e.jsxs("ul",{className:"list-disc pl-5 space-y-1",children:[e.jsx("li",{children:"C-level management & people with 25%+ ownership of the company"}),e.jsx("li",{children:"All professionals making financial decisions or providing advice, including:"}),e.jsx("li",{children:"Investment advisors and portfolio managers"}
1),e.jsx("li",{children:"Risk assessment professionals and underwriters"}),e.jsx("li",{children:"Compliance officers and regulatory specialists"}),e.jsx("li",{children:"Brokers, agents, and intermediaries"}),e.jsx("li",{children:"Credit officers and loan approval personnel"}),e.jsx("li",{children:"Fund managers and trustees"})]}),e.jsx("p",{children:"It's better to list too many people rather than too few. Próspera Insurance Company will work with you to decide who needs coverage."})]}),V.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground",children:"No people added yet."}),e.jsx("div",{className:"space-y-6",children:V.map((s,r)=>e.jsxs("div",{className:"border rounded-lg p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"font-medium",children:["Person ",r+1]}),!l&&e.jsx(y,{type:"button",variant:"ghost",className:"text-red-600",onClick:()=>ne(r),children:"Remove"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsx(u,{control:t.control,name:`people.${r}.fullName`,render:({field:n})=>e.jsxs(h,{children:[e.jsx(p,{children:"Full name"}),e.jsx(j,{children:e.jsx(S,{placeholder:"Full name",...n})}),e.jsx(F,{})]})}),e.jsx(u,{control:t.control,name:`people.${r}.jobTitle`,render:({field:n})=>e.jsxs(h,{children:[e.jsx(p,{children:"Job title/role"}),e.jsx(j,{children:e.jsx(S,{placeholder:"e.g., CEO, Head of Compliance",...n})}),e.jsx(F,{})]})}),e.jsx(u,{control:t.control,name:`people.${r}.education`,render:({field:n})=>e.jsxs(h,{children:[e.jsx(p,{children:"Education"}),e.jsx(j,{children:e.jsx(S,{placeholder:"Highest level completed",...n})}),e.jsx(F,{})]})}),e.jsx(u,{control:t.control,name:`people.${r}.experience`,render:({field:n})=>e.jsxs(h,{children:[e.jsx(p,{children:"How much experience in the current line of work? (years or months)"}),e.jsx(j,{children:e.jsx(S,{placeholder:"e.g., 5 years",...n})}),e.jsx(F,{})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsx(u,{control:t.control,name:`people.${r}.hasCreditScore`,render:({field:n})=>e.jsxs(h,{className:"flex items-start space-x-2 space-y-0",children:[e.jsx(j,{children:e.jsx(L,{disabled:l,checked:!!n.value,onCheckedChange:m=>n.onChange(m===!0)})}),e.jsx(p,{className:"!mt-0 text-sm font-normal cursor-pointer",children:"Does this person have a credit score with any major credit scoring service?"})]})}),e.jsx(u,{control:t.control,name:`people.${r}.priorInjuryLoss`,render:({field:n})=>e.jsxs(h,{className:"flex items-start space-x-2 space-y-0",children:[e.jsx(j,{children:e.jsx(L,{disabled:l,checked:!!n.value,onCheckedChange:m=>n.onChange(m===!0)})}),e.jsx(p,{className:"!mt-0 text-sm font-normal cursor-pointer",children:"Has this person ever suffered a monetary loss due to an injury-related claim?"})]})}),e.jsx(u,{control:t.control,name:`people.${r}.currentOnDebtTaxes`,render:({field:n})=>e.jsxs(h,{className:"flex items-start space-x-2 space-y-0",children:[e.jsx(j,{children:e.jsx(L,{disabled:l,checked:!!n.value,onCheckedChange:m=>n.onChange(m===!0)})}),e.jsx(p,{className:"!mt-0 text-sm font-normal cursor-pointer",children:"Is this person current on all debt and tax obligations?"})]})}),e.jsx(u,{control:t.control,name:`people.${r}.hasBankingRelationships`,render:({field:n})=>e.jsxs(h,{className:"flex items-start space-x-2 space-y-0",children:[e.jsx(j,{children:e.jsx(L,{disabled:l,checked:!!n.value,onCheckedChange:m=>n.onChange(m===!0)})}),e.jsx(p,{className:"!mt-0 text-sm font-normal cursor-pointer",children:"Does this person have formal banking or investment relationships?"})]})}),e.jsx(u,{control:t.control,name:`people.${r}.hasInsurancePolicies`,render:({field:n})=>e.jsxs(h,{className:"flex items-start space-x-2 space-y-0",children:[e.jsx(j,{children:e.jsx(L,{disabled:l,checked:!!n.value,onCheckedChange:m=>n.onChange(m===!0)})}),e.jsx(p,{className:"!mt-0 text-sm font-normal cursor-pointer",children:"Does this person currently maintain any insurance policies?"})]})}),e.jsx(u,{control:t.control,name:`people.${r}.criminalHistory`,render:({field:n})=>e.jsxs(h,{className:"flex items-start space-x-2 space-y-0",children:[e.jsx(j,{children:e.jsx(L,{disabled:l,checked:!!n.value,onCheckedChange:m=>n.onChange(m===!0)})}),e.jsx(p,{className:"!mt-0 text-sm font-normal cursor-pointer",children:"Does this person have any criminal history?"})]})}),e.jsx(u,{control:t.control,name:`people.${r}.hasAssetsOrResidencyInProsperaOrUSA`,render:({field:n})=>e.jsxs(h,{className:"flex items-start space-x-2 space-y-0",children:[e.jsx(j,{children:e.jsx(L,{disabled:l,checked:!!n.value,onCheckedChange:m=>n.onChange(m===!0)})}),e.jsx(p,{className:"!mt-0 text-sm font-normal cursor-pointer",children:"Does this person have assets, permanent residency, or business operations in either Próspera ZEDE or the United States of America?"})]})}),e.jsx(u,{control:t.control,name:`people.${r}.relatedToProsperaEmployees`,render:({field:n})=>e.jsxs(h,{className:"flex items-start space-x-2 space-y-0",children:[e.jsx(j,{children:e.jsx(L,{disabled:l,checked:!!n.value,onCheckedChange:m=>n.onChange(m===!0)})}),e.jsx(p,{className:"!mt-0 text-sm font-normal cursor-pointer",children:"Does this person have a personal or familial relationship with anyone working at Honduras Próspera LLC, Próspera ZEDE, Próspera Arbitration Center LLC, or North Bay GSP, Inc.?"})]})}),e.jsx(u,{control:t.control,name:`people.${r}.litigationLast10Years`,render:({field:n})=>e.jsxs(h,{className:"flex items-start space-x-2 space-y-0",children:[e.jsx(j,{children:e.jsx(L,{disabled:l,checked:!!n.value,onCheckedChange:m=>n.onChange(m===!0)})}),e.jsx(p,{className:"!mt-0 text-sm font-normal cursor-pointer",children:"Has this person been engaged in litigation, arbitration or the prosecution of any claim or cause of action in the last 10 years?"})]})})]}),e.jsx(u,{control:t.control,name:`people.${r}.cvResumeUrl`,render:({field:n})=>e.jsxs(h,{children:[e.jsx(p,{children:"CV/Resume *"}),e.jsx(j,{children:e.jsx(S,{placeholder:"Attach CV",...n})}),e.jsx(F,{})]})})]},s.id))})]})}),e.jsx(R,{ref:o,children:e.jsxs(T,{className:"pt-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Miscellaneous questions"}),e.jsx(u,{control:t.control,name:"activitiesLocation",render:({field:s})=>e.jsxs(h,{children:[e.jsx(p,{children:"Where will the activities described be conducted?"}
1),e.jsx(j,{children:e.jsx(S,{readOnly:!0,"aria-readonly":!0,className:"cursor-not-allowed",placeholder:"Enter facility location",...s})}),e.jsx(F,{})]})}),e.jsx(u,{control:t.control,name:"hazardousDisclosure",render:({field:s})=>e.jsxs(h,{className:"flex items-start space-x-2 space-y-0",children:[e.jsx(j,{children:e.jsx(L,{disabled:l,checked:!!s.value,onCheckedChange:r=>s.onChange(r===!0)})}),e.jsx("div",{className:"grid gap-1.5 leading-none",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{className:`!mt-0 ${l?"cursor-not-allowed text-muted-foreground":"cursor-pointer"}`,"aria-readonly":l,children:"Do you need to file a Hazardous Activity Disclosure? Yes / No"}),e.jsxs(Q,{children:[e.jsx(G,{asChild:!0,children:e.jsx(W,{className:"h-4 w-4 text-muted-foreground cursor-pointer"})}),e.jsxs(Z,{side:"top",className:"max-w-sm text-xs leading-relaxed",children:["If your business involves abnormally dangerous activities, such as (but not limited to): working with toxic chemicals, pathogens, heavy machinery, explosives, highly flammable materials, or other hazardous materials, you should file a Hazardous Activity Disclosure. If you're unsure, filing a disclosure is a good idea. Learn more "," ",e.jsx("a",{href:"https://intercom.help/prospera-c3520d800849/en/articles/8269916-hazardous-activity-or-condition-disclosure",target:"_blank",rel:"noreferrer",className:"text-prospin-red underline",children:"here"})]})]})]})})]})}),e.jsx(u,{control:t.control,name:"enforcementPolicyStatement",render:({field:s})=>e.jsxs(h,{className:"flex items-start space-x-2 space-y-0",children:[e.jsx(j,{children:e.jsx(L,{disabled:l,checked:!!s.value,onCheckedChange:r=>s.onChange(r===!0)})}),e.jsxs("div",{className:"grid gap-1.5 leading-none",children:[e.jsx(p,{className:`!mt-0 ${l?"cursor-not-allowed text-muted-foreground":"cursor-pointer"}`,"aria-readonly":l,children:"Have you or will you petition for an Enforcement Policy Statement from the General Service Provider? : Yes / No"}),e.jsx("p",{className:"text-xs italic text-muted-foreground",children:"If you're not sure, the answer is probably no."})]})]})}),te&&e.jsx(u,{control:t.control,name:"enforcementPolicyDescription",render:({field:s})=>e.jsxs(h,{children:[e.jsx(p,{children:"Describe enforcement policy statement status"}),e.jsx(j,{children:e.jsx(je,{rows:3,placeholder:"Describe status",...s})}),e.jsx(F,{})]})}),e.jsx("div",{className:"grid grid-cols-1 gap-4",children:e.jsx(u,{control:t.control,name:"haveEmployees",render:({field:s})=>e.jsxs(h,{className:"flex items-start space-x-2 space-y-0",children:[e.jsx(j,{children:e.jsx(L,{disabled:l,checked:!!s.value,onCheckedChange:r=>s.onChange(r===!0)})}),e.jsx(p,{className:"!mt-0 cursor-pointer",children:"Will you have employees?: Yes / No"})]})})}),e.jsx(u,{control:t.control,name:"maxAcceptablePremiumUSD",render:({field:s})=>e.jsxs(h,{children:[e.jsx(p,{children:"How high would the required annual insurance premium have to get before you'd decide it's not worth doing business in Próspera ZEDE?:"}),e.jsx(j,{children:e.jsx(S,{type:"number",min:0,step:"1",value:Number.isFinite(s.value)?s.value:0,onChange:r=>s.onChange(Number(r.target.value)),placeholder:"Enter maximum acceptable insurance premium amount"})}),e.jsx(F,{})]})})]})}),e.jsx(R,{ref:I,children:e.jsx(T,{className:"pt-6 space-y-4",children:e.jsx(u,{control:t.control,name:"agree",render:({field:s})=>e.jsxs(h,{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start space-x-2",children:[e.jsx(j,{children:e.jsx(L,{disabled:l,checked:!!s.value,onCheckedChange:r=>s.onChange(r===!0)})}),e.jsx(p,{className:"!mt-0 text-sm font-normal cursor-pointer",children:'By clicking "I Agree" and thereby affixing my digital signature below, for good and valuable consideration consisting of the opportunity to be considered for the issuance of an insurance policy, I agree to be held liable by Próspera Insurance Company LLC for the civil penalty applicable to the tort of fraud under Próspera ZEDE Rule published here, if any of the foregoing is found be materially false or misleading to the issuance of insurance for any of the applying named insured(s) by Próspera Insurance Company LLC.'})]}),e.jsx(F,{className:"text-xs font-medium"})]})})})}),!l&&e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>t.reset(),children:"Reset"}),e.jsx(y,{type:"submit",disabled:w||!oe||!U,children:w?"Submittingâ¦":"Submit Application"})]})]})})})]})}function Fr(){const[,d]=Qe("/business/:id"),[,O]=Ge(),l=d?.id,i=he(),{toast:g}=ue(),[f,N]=b.useState(null),[w,x]=b.useState(!1),[v,t]=b.useState(!1),[U,D]=b.useState(!1),[P,A]=b.useState(null),[E,o]=b.useState(!1),I=Y({mutationFn:async a=>(await _("POST",`/api/documents/${a}/confirm-signatures`)).json(),onSuccess:()=>
1{i.invalidateQueries({queryKey:["/api/businesses",l,"founders"]}),i.invalidateQueries({queryKey:["/api/businesses",l,"documents"]}),g({title:"Share Redistribution Complete",description:"All signatures confirmed. Ownership has been updated."}),N(null)},onError:a=>{g({title:"Confirmation Failed",description:a.message||"Failed to confirm signatures",variant:"destructive"})}});Y({mutationFn:async a=>(await _("PUT","/api/business-logos",{businessId:l,logoURL:a})).json(),onSuccess:()=>{i.invalidateQueries({queryKey:["/api/businesses",l]}),i.invalidateQueries({queryKey:["/api/businesses"]}),g({title:"Logo Updated",description:"Business logo has been updated successfully."})},onError:a=>{g({title:"Upload Failed",description:a.message,variant:"destructive"})}});const $=Y({mutationFn:async()=>(await _("POST",`/api/businesses/${l}/banking/confirm`)).json(),onSuccess:()=>{i.setQueryData(["/api/businesses",l],a=>a&&{...a,hasBankAccount:!0}),i.invalidateQueries({queryKey:["/api/businesses",l]}),g({title:"Banking Confirmed",description:"Weâve marked banking as set up for this company."}),o(!1)},onError:a=>{g({title:"Update Failed",description:a.message||"Failed to confirm banking setup",variant:"destructive"})}}),z=Y({mutationFn:async()=>(await _("POST",`/api/businesses/${l}/banking/assisted-request`)).json(),onSuccess:()=>{g({title:"Request sent",description:"ProspIn support will contact you about assisted banking and next steps."})},onError:a=>{g({title:"Request not sent",description:a.message||"Please try again in a moment.",variant:"destructive"})}}),{data:c,isLoading:te}=J({queryKey:["/api/businesses",l],enabled:!!l}),{data:oe=[]}=J({queryKey:["/api/businesses",l,"founders"],enabled:!!l}),{data:V=[]}=J({queryKey:["/api/businesses",l,"documents"],enabled:!!l}),{data:ae=[]}=J({queryKey:["/api/documents/storage-submissions"],enabled:!!l,staleTime:300*1e3}),ne=ae.filter(a=>a.businessId===l).flatMap(a=>(a.files||[]).map(C=>({id:`submission:${a.submissionId}:${C.name}`,name:C.name,type:"Signed Submission",status:"signed",businessId:a.businessId,businessName:a.businessName,objectPath:C.object,fileSize:C.size||"N/A",createdAt:C.lastModified||null}))),s=[...V,...ne],{data:r=[]}=J({queryKey:["/api/businesses",l,"insurance"],enabled:!!l});b.useEffect(()=>{!U&&(r?.length??0)>0&&D(!0)},[r,U]);const n=()=>{U||(r?.length??0)>0?t(!0):x(!0)};if(te||!c)return e.jsx(Ee,{activeTab:"businesses",children:e.jsxs("div",{className:"animate-pulse space-y-6",children:[e.jsx("div",{className:"h-20 bg-gray-200 rounded"}),e.jsx("div",{className:"h-96 bg-gray-200 rounded"})]})});const m=c.status==="Approved",K=!!(c.industry&&os.some(a=>c.industry.toLowerCase().includes(a.toLowerCase())||a.toLowerCase().includes(c.industry.toLowerCase())));return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{activeTab:"businesses",children:[e.jsxs("div",{className:"mb-6 lg:mb-8",children:[e.jsxs("div",{className:"lg:hidden",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsx(y,{variant:"ghost",onClick:()=>O("/businesses"),className:"min-h-[44px] p-2","data-testid":"button-back-businesses",children:e.jsx(Le,{className:"h-5 w-5"})})}),e.jsxs("div",{className:"flex items-center justify-center mb-3",children:[e.jsxs("div",{className:"relative mr-3",children:[e.jsx(Ae,{business:c,size:"md"}),e.jsx(qe,{className:"hidden h-3 w-3"})]}),e.jsxs("div",{className:"text-left",children:[e.jsx("h1",{className:"text-xl font-bold text-gray-900 break-words mb-1",children:c.name}),e.jsxs("p",{className:"text-sm text-gray-500",children:[c.suffix," ⢠",c.industry]})]})]})]}),e.jsx("div",{className:"hidden lg:flex lg:items-center lg:justify-between",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(y,{variant:"ghost",onClick:()=>O("/businesses"),className:"mr-4 hover:bg-gray-200 rounded-full","data-testid":"button-back-businesses",children:e.jsx(Le,{className:"h-4 w-4"})}),e.jsxs("div",{className:"relative mr-4",children:[e.jsx(Ae,{business:c,size:"lg"}),e.jsx(qe,{className:"hidden h-3 w-3"})]}),e.jsxs("div",{className:"flex flex-col items-start ml-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-900",children:[c.name," ",c.suffix]}),e.jsx(M,{className:ms[c.status],variant:"secondary",children:ds[c.status]})]}),e.jsx("span",{className:"text-gray-500",children:c.industry})]})]})})]}),e.jsx(R,{className:"mb-6 border-prospin-red/30 bg-prospin-red/[0.03] border-l-4 border-l-prospin-red",children:e.jsx(T,{className:"p-4 sm:p-5",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(xs,{className:"mt-0.5 h-5 w-5 shrink-0 text-prospin-red"}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold text-prospin-black",children:"Questions? Speak with the ProspIn team"}),e.jsx("p",{className:"mt-1 text-sm text-prospin-gray-600",children:"Book a 30-minute c
1onsultation for guidance and support whenever you need it."})]})]}),e.jsx(y,{asChild:!0,className:"w-full shrink-0 sm:w-auto",children:e.jsx("a",{href:"https://tidycal.com/prospin/set-up-llc-in-prospera-with-prospin-30m",target:"_blank",rel:"noreferrer","data-testid":"link-business-prospin-consultation",children:"Book a consultation"})})]})})}),K&&e.jsxs(Je,{className:"border-amber-200 bg-amber-50 mb-6 pb-2",children:[e.jsx(us,{className:"h-4 w-4 !text-amber-600"}),e.jsx(Xe,{className:"text-amber-800",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("strong",{children:"Insurance Required:"}),e.jsx("br",{}),"Your ",c.industry," business requires professional insurance before operations can commence. This may delay final verification.",e.jsxs(Q,{children:[e.jsx(G,{asChild:!0,children:e.jsx(W,{className:"h-4 w-4 text-amber-600 ml-1 cursor-help inline-block"})}),e.jsx(Z,{children:e.jsx("p",{className:"max-w-xs",children:"We'll provide you with fast-track access to leading insurance providers to streamline the insurance process and reduce delays."})})]})]}),e.jsx(y,{size:"sm",className:"bg-amber-600 hover:bg-amber-700 text-white ml-4 flex-shrink-0",onClick:n,"data-testid":"button-get-insured",children:U||(r?.length??0)>0?"Submitted":"Get Insured"})]})})]}),!c.hasBankAccount&&e.jsx(R,{className:"mb-6 border-prospin-red/30",children:e.jsx(T,{className:"p-5 sm:p-6",children:e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-prospin-black",children:"Banking Requirement"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-prospin-gray-600",children:"To operate in Próspera, you need to have a bank account. The community commonly uses OneSafe, Slash, and Hevn."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-prospin-black",children:"Self-Apply"}),e.jsxs("p",{className:"mt-1 text-sm leading-6 text-prospin-gray-600",children:["You can open your account independently. Use the code ",e.jsx("strong",{children:"Prospin"})," to receive additional benefits (e.g., with OneSafe you get 1 extra free month)."]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-prospin-black",children:"Assisted Banking"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-prospin-gray-600",children:"If you prefer, we can handle the entire process for you. We use our direct channel to speed up approval, facilitate bank introductions, support KYB and KYC, and increase your success rate."}),e.jsx("p",{className:"mt-2 font-semibold text-prospin-black",children:"$749 service fee"})]}),e.jsxs("div",{className:"flex flex-col-reverse gap-2 pt-1 sm:flex-row sm:justify-end",children:[e.jsx(y,{variant:"outline",onClick:()=>o(!0),disabled:z.isPending,"data-testid":"button-i-have-a-bank",children:"I have a bank"}),e.jsx(y,{onClick:()=>z.mutate(),disabled:z.isPending||z.isSuccess,"data-testid":"button-request-assisted-banking",children:z.isPending?"Sending request...":z.isSuccess?"Request sent":"Request assistance"})]})]})})}),e.jsxs("div",{className:"space-y-4 lg:space-y-8",children:[e.jsxs(R,{className:"hidden border-t-4 border-t-prospin-red",children:[e.jsx("div",{className:"px-4 lg:px-6 py-4 border-b border-gray-100",children:e.jsx("h2",{className:"text-lg lg:text-xl font-bold text-gray-900",children:"Notices & Reminders"})}),e.jsx(T,{className:"p-4 lg:p-6 space-y-4",children:e.jsx("div",{className:"text-center text-gray-500 py-6 lg:py-8",children:"No notices or reminders at this time"})})]}),e.jsxs(R,{className:"border-t-4 border-t-prospin-red",children:[e.jsx("div",{className:"px-4 lg:px-6 py-4 border-b border-gray-100",children:e.jsx("h2",{className:"text-lg lg:text-xl font-bold text-gray-900",children:"Business Information"})}),e.jsxs(T,{className:"p-4 lg:p-6",children:[e.jsxs("div",{className:"lg:hidden space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3 text-sm",children:"Basic Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-gray-50 p-3 rounded-lg",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Business N
1ame with Suffix"}),e.jsxs("div",{className:"text-sm font-medium break-words",children:[c.name," ",c.suffix]})]}),e.jsxs("div",{className:"bg-gray-50 p-3 rounded-lg",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Business Address"}),e.jsx("div",{className:"text-sm font-medium",children:c.registeredAddress})]}),e.jsxs("div",{className:"hidden bg-gray-50 p-3 rounded-lg",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Formation Type"}),e.jsx("div",{className:"text-sm font-medium",children:c.businessModel==="digital"?"Digital":"Physical"})]}),e.jsxs("div",{className:"bg-gray-50 p-3 rounded-lg",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Industry"}),e.jsx("div",{className:"text-sm font-medium break-words",children:c.industry})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3 text-sm",children:"Registration Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-gray-50 p-3 rounded-lg",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Formation Date"}),e.jsx("div",{className:"text-sm font-medium",children:c.incorporationDate?new Date(c.incorporationDate).toLocaleDateString():"Pending"})]}),e.jsxs("div",{className:"bg-gray-50 p-3 rounded-lg",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Permit Number"}),e.jsx("div",{className:"text-sm font-medium",children:c.businessPermitNumber?`${c.businessPermitNumber}`:"Pending Approval"})]}),e.jsxs("div",{className:"bg-gray-50 p-3 rounded-lg",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Status"}),e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`w-2 h-2 rounded-full mr-2 ${m?"bg-green-500":"bg-yellow-500"}`}),e.jsx("span",{className:"text-sm font-medium",children:m?"Active":"Under review"})]})]}),e.jsxs("div",{className:"bg-gray-50 p-3 rounded-lg",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Jurisdiction"}),e.jsx("div",{className:"text-sm font-medium",children:"Próspera ZEDE"})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3 text-sm",children:"Business Activity"}),e.jsx("div",{className:"bg-gray-50 p-3 rounded-lg",children:e.jsx("div",{className:"text-sm text-gray-700 break-words",children:c.activityDescription||"No business activity description provided."})})]})]}),e.jsxs("div",{className:"hidden lg:grid grid-cols-3 gap-8",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-4",children:"Basic Details"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-500",children:"Business Name with Suffix"}),e.jsxs("div",{className:"font-medium",children:[c.name," ",c.suffix]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-500",children:"Business Address"}),e.jsx("div",{className:"font-medium",children:c.registeredAddress})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-500",children:"Formation Type"}),e.jsx("div",{className:"font-medium",children:c.businessModel==="digital"?"Digital Business":"Physical Business"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-500",children:"Industry"}),e.jsx("div",{className:"font-medium",children:c.industry})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-4",children:"Registration Details"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-500",children:"Formation Date"}),e.jsx("div",{className:"font-medium",children:c.incorporationDate?new Date(c.incorporationDate).toLocaleDateString():"Pending"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-500",children:"Business Permit Number"}),e.jsx("div",{className:"font-medium",children:c.businessPermitNumber?`${c.businessPermitNumber}`:"Pending"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-500",children:"Status"}),e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`w-2 h-2 rounded-full mr-2 ${m?"bg-green-500":"bg-yellow-500"}`}),e.jsx("span",{className:"font-medium",children:m?"Active":"Under review"})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-500",children:"Jurisdiction"}),e.jsx("div",{className:"font-medium",children:"Próspera ZEDE, Honduras"})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-4",children:"Business Activity"}),e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-500",children:"Activity Description"}),e.jsx("div",{className:"font-medium break-words",children:c.activityDescription||"No business activity description provided."})]})})]})]})]})]}),e.jsx(gs,{businessId:l}),e.jsxs(R,{className:"border-t-4 border-t-prospin-red",children:[e.jsx("div",{className:"px-4 lg:px-6 py-4 border-b border-gray-100",children:e.jsx("h2",{className:"text-lg lg:text-xl font-bold text-gray-900",children:"Company Documents"})}),e.jsx(T,{className:"p-0",children:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"lg:hidden",children:s.length===0?e.jsxs("div",{className:"px-4 py-12 text-center",children:[e.jsx(le,{className:"mx-auto h-12 w-12 text-gray-400"}),e.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:"No documents"})]}):e.jsx("div",{className:"divide-y divide-gray-200",children:s.map(a=>e.jsx("div",{className:"p-4 hover:bg-gray-50",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"flex-shrink-0",children:Oe(a.status)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"text-sm font-medium text-prospin-black break-words",children:a.name}),e.jsx("p",{className:"text-xs text-prospin-gray-600 mt-1 break-words",children:a.businessName}),a.signedBy&&e.jsxs("div",{className:"flex items-center mt-2",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full mr-2 flex-shrink-0"}),e.jsxs("div",{className:"text-xs text-green-700 break-words",children:["Signed by ",a.signedBy]})]})]}),e.jsx("div",{className:"flex-shrink-0 ml-2",children:cs(a.status)})]}),e.jsx("div",{className:"mt-3 flex flex-col sm:flex-row sm:items-center sm:justify-between space-y-2 sm:space-y-0",children:e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(y,{size:"sm",variant:"outline",className:"text-xs min-h-[36px]",onClick:()=>Te(a,g),"data-testid":`button-download-${a.id}`,children:[e.jsx(Be,{className:"h-3 w-3 mr-1"}),"Download"]})})})]})]})},a.id))})}),e.jsx("div",{className:"hidden lg:block overflow-x-auto",children:e.jsxs("table",{className:"min-w-full table-fixed",children:[e.jsx("thead",{className:"border-b bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"w-1/4 px-4 py-3 text-left text-xs font-medium text-prospin-gray-500 uppercase tracking-wider",children:"Document Name"}),e.jsx("th",{className:"w-1/6 px-4 py-3 text-left text-xs font-medium text-prospin-gray-500 uppercase tracking-wider",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200",children:s.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:5,className:"px-4 py-12 text-center",children:[e.jsx(le,{className:"mx-auto h-12 w-12 text-gray-400"}),e.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:"No documents"})]})}):s.map(a=>e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-4",children:e.jsxs("div",{className:"flex items-center",children:[Oe
1(a.status),e.jsxs("div",{className:"ml-3 min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-prospin-black truncate",children:a.name}),a.signedBy&&e.jsxs("div",{className:"flex items-center mt-1",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full mr-2 flex-shrink-0"}),e.jsxs("div",{className:"text-xs text-green-700 truncate",children:["Signed by ",a.signedBy]})]})]})]})}),e.jsx("td",{className:"px-4 py-4 text-sm font-medium",children:e.jsx("div",{className:"flex items-center",children:e.jsxs(y,{size:"sm",variant:"outline",onClick:()=>Te(a,g),children:[e.jsx(Be,{className:"h-3 w-3 mr-1"}),"Download"]})})})]},a.id))})]})})]})})]}),K&&e.jsxs(R,{className:"border-t-4 border-t-prospin-red",children:[e.jsxs("div",{className:"px-4 lg:px-6 py-4 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg lg:text-xl font-bold text-gray-900",children:"Insurance Applications"}),e.jsxs(X,{children:[e.jsx(Me,{asChild:!0,children:e.jsxs(y,{className:"hidden bg-prospin-red/10 hover:bg-prospin-red/20 text-prospin-red border border-prospin-red","data-testid":"button-apply-insurance",children:[e.jsx(ge,{className:"h-4 w-4 mr-2"}),"Apply for Insurance"]})}),e.jsx($e,{business:c})]})]}),e.jsxs(T,{className:"p-0",children:[e.jsx("div",{className:"lg:hidden",children:r&&r.length>0?e.jsx("div",{className:"divide-y divide-gray-200",children:r.map(a=>{const C=a.fullApplication||{},pe=C.regulatoryFramework==="peer_country"?`Peer-country: ${C.peerCountry||"â"}`:"Common Law",ie=typeof C.projectedFundsUSD=="number"?C.projectedFundsUSD:void 0;return e.jsx("div",{className:"p-4 hover:bg-gray-50 cursor-pointer",onClick:()=>{A(a),x(!0)},role:"button",tabIndex:0,onKeyDown:fe=>{(fe.key==="Enter"||fe.key===" ")&&(A(a),x(!0))},children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"flex-shrink-0 mt-1",children:e.jsx(ge,{className:"w-4 h-4 text-blue-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 break-words",children:pe}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Applied: ",a.createdAt?new Date(a.createdAt).toLocaleDateString("en-GB"):"â"]})]})}),C.activitiesLocation&&e.jsxs("div",{className:"mt-2 text-xs text-gray-600 break-words",children:["Location: ",C.activitiesLocation]}),ie!==void 0&&e.jsxs("div",{className:"mt-1 text-xs text-gray-600",children:["Projected Funds: $",ie.toLocaleString()]})]})]})},a.id)})}):e.jsx("div",{className:"p-4 text-center text-gray-500",children:"No insurance applications yet"})}),e.jsx("div",{className:"hidden lg:block",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Framework"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Activities Location"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Projected Funds (USD)"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Applied Date"})]})}),e.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:r&&r.length>0?r.map(a=>{const C=a.fullApplication||{},pe=C.regulatoryFramework==="peer_country"?`Peer-country: ${C.peerCountry||"â"}`:"Common Law",ie=typeof C.projectedFundsUSD=="number"?C.projectedFundsUSD:void 0;return e.jsxs("tr",{className:"hover:bg-gray-50 cursor-pointer",onClick:()=>{A(a),x(!0)},children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(ge,{className:"w-4 h-4 text-blue-500 mr-2"}),e.jsx("div",{className:"text-sm font-medium text-gray-900",children:pe})]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900",children:C.activitiesLocation||"â"}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900",children:ie!==void 0?`$${ie.toLocaleStr
1ing()}`:"â"}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:a.createdAt?new Date(a.createdAt).toLocaleDateString("en-GB"):"â"})]},a.id)}):e.jsx("tr",{className:"border-b",children:e.jsx("td",{colSpan:4,className:"py-6 text-center text-gray-500",children:"No insurance applications available"})})})]})})})]})]})]})]}),e.jsx(X,{open:!!f,onOpenChange:()=>N(null),children:e.jsxs(ee,{className:"max-w-4xl max-h-[80vh] overflow-auto",children:[e.jsx(se,{children:e.jsxs(re,{children:[f?.name,f?.type==="share_redistribution"&&f?.status==="pending"&&e.jsx(M,{variant:"outline",className:"ml-2 text-yellow-600 border-yellow-600",children:"Pending Signatures"})]})}),e.jsx("div",{className:"bg-white p-6 border rounded-lg",children:f?.content?e.jsx("pre",{className:"whitespace-pre-wrap text-sm leading-relaxed font-mono",children:f.content}):e.jsx("div",{className:"text-center py-8 text-gray-500",children:"No content available for preview"})}),f?.type==="share_redistribution"&&f?.status==="pending"&&e.jsx("div",{className:"flex justify-end mt-4 pt-4 border-t border-gray-200",children:e.jsxs(y,{onClick:()=>I.mutate(f.id),disabled:I.isPending,className:"bg-green-600 hover:bg-green-700","data-testid":"button-confirm-all-signatures",children:[e.jsx(ze,{className:"w-4 h-4 mr-2"}),I.isPending?"Confirming...":"Confirm All Signatures Complete"]})})]})}),e.jsx(X,{open:w,onOpenChange:a=>{x(a),a||A(null)},children:e.jsx($e,{business:c,readOnly:!!P,initialValues:P?.fullApplication||null,onSubmitted:()=>{D(!0)}})}),e.jsx(ve,{open:v,onOpenChange:t,children:e.jsxs(Ne,{children:[e.jsxs(we,{children:[e.jsx(Ce,{children:"Submit a new insurance application?"}),e.jsx(Se,{children:"You already submitted the request. Do you want to submit a new one?"})]}),e.jsxs(ke,{children:[e.jsx(Pe,{onClick:()=>t(!1),children:"No"}),e.jsx(De,{onClick:()=>{t(!1),x(!0)},"data-testid":"button-insurance-preconfirm-yes",children:"Yes"})]})]})}),e.jsx(ve,{open:E,onOpenChange:o,children:e.jsxs(Ne,{children:[e.jsxs(we,{children:[e.jsx(Ce,{children:"Confirm banking is already set up?"}),e.jsx(Se,{children:"I already have a bank account set up for this company."})]}),e.jsxs(ke,{children:[e.jsx(Pe,{onClick:()=>o(!1),disabled:$.isPending,children:"Cancel"}),e.jsx(De,{onClick:()=>$.mutate(),disabled:$.isPending,"data-testid":"button-confirm-i-have-a-bank",children:$.isPending?"Saving...":"Confirm"})]})]})})]})}export{Fr as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.