@remoteoss/remote-flows 1.42.0 → 1.42.1

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.
Files changed (219) hide show
  1. package/dist/{DatePickerFieldDefault-EUPACNZD.js → DatePickerFieldDefault-XMG6ZDVQ.js} +2 -2
  2. package/dist/chunk-3HMUXWNW.js +2 -0
  3. package/dist/chunk-3HMUXWNW.js.map +1 -0
  4. package/dist/{chunk-XEK3MUYF.js → chunk-7JWQ24VU.js} +2 -2
  5. package/dist/chunk-7WB6IHRF.js +2 -0
  6. package/dist/chunk-7WB6IHRF.js.map +1 -0
  7. package/dist/{chunk-XGXXXWTH.js → chunk-ADXJUDVS.js} +2 -2
  8. package/dist/{chunk-QKSYPFRB.js → chunk-BSOKKYGH.js} +2 -2
  9. package/dist/{chunk-T7QVVLKT.js → chunk-CFGQQEXD.js} +2 -2
  10. package/dist/chunk-DAFIBCX4.js +2 -0
  11. package/dist/chunk-DAFIBCX4.js.map +1 -0
  12. package/dist/{chunk-GR6QMP4Z.js → chunk-DSL5O7NR.js} +2 -2
  13. package/dist/{chunk-YPLIXSIP.js → chunk-E2463GRM.js} +2 -2
  14. package/dist/{chunk-YPLIXSIP.js.map → chunk-E2463GRM.js.map} +1 -1
  15. package/dist/{chunk-FJGDFNEH.js → chunk-F67DSAFU.js} +2 -2
  16. package/dist/{chunk-MG6UYSCR.js → chunk-G2FGMFTN.js} +2 -2
  17. package/dist/{chunk-LES7J6H4.js → chunk-HAI4J2FU.js} +2 -2
  18. package/dist/{chunk-W4BOTAD6.js → chunk-HIDA2KDX.js} +2 -2
  19. package/dist/{chunk-44F5FY7C.js → chunk-JQN26ZTU.js} +2 -2
  20. package/dist/{chunk-TWULMMMY.js → chunk-LV6MDD3M.js} +2 -2
  21. package/dist/{chunk-WTVYMT5N.js → chunk-OISWU4YR.js} +2 -2
  22. package/dist/{chunk-SJO4XFQD.js → chunk-PEJ5SKA2.js} +2 -2
  23. package/dist/{chunk-YADHCTR7.js → chunk-PXU2LCFW.js} +2 -2
  24. package/dist/{chunk-4RVJJ33G.js → chunk-Q5OFEWTH.js} +2 -2
  25. package/dist/{chunk-QGC2HCZG.js → chunk-R3JUKEDN.js} +2 -2
  26. package/dist/{chunk-F74X2V2N.js → chunk-RG36YL7L.js} +2 -2
  27. package/dist/{chunk-LXNEYPO5.js → chunk-SL7O5CUW.js} +2 -2
  28. package/dist/{chunk-XS5ASVWY.js → chunk-SQ5KB57O.js} +2 -2
  29. package/dist/{chunk-VUQH44VX.js → chunk-UYSY6Z5S.js} +2 -2
  30. package/dist/{chunk-UJWKHGH5.js → chunk-VJGCSIOB.js} +2 -2
  31. package/dist/{chunk-HYNJ3ITY.js → chunk-XICRWKIW.js} +2 -2
  32. package/dist/{chunk-C332PSLT.js → chunk-YCP65XIN.js} +2 -2
  33. package/dist/{chunk-VCF327FJ.js → chunk-YRDXBXXA.js} +2 -2
  34. package/dist/{chunk-3U4PZ4KB.js → chunk-YUKREGGF.js} +2 -2
  35. package/dist/{chunk-QQ3PZHXO.js → chunk-YZ3KEILH.js} +2 -2
  36. package/dist/default-components.d.ts +2 -2
  37. package/dist/default-components.js +1 -1
  38. package/dist/flows/ContractAmendment/ContractAmendmentConfirmationForm.d.ts +1 -1
  39. package/dist/flows/ContractAmendment/ContractAmendmentFlow.d.ts +3 -3
  40. package/dist/flows/ContractAmendment/ContractAmendmentFlow.js +1 -1
  41. package/dist/flows/ContractAmendment/ContractAmendmentForm.d.ts +1 -1
  42. package/dist/flows/ContractAmendment/context.d.ts +3 -3
  43. package/dist/flows/ContractAmendment/hooks.d.ts +3 -3
  44. package/dist/flows/ContractAmendment/hooks.js +1 -1
  45. package/dist/flows/ContractAmendment/index.d.ts +3 -3
  46. package/dist/flows/ContractAmendment/index.js +1 -1
  47. package/dist/flows/ContractAmendment/types.d.ts +2 -2
  48. package/dist/flows/ContractAmendment/utils.d.ts +2 -2
  49. package/dist/flows/ContractorOnboarding/ContractorOnboarding.d.ts +5 -5
  50. package/dist/flows/ContractorOnboarding/ContractorOnboarding.js +1 -1
  51. package/dist/flows/ContractorOnboarding/api.d.ts +2 -2
  52. package/dist/flows/ContractorOnboarding/api.js +1 -1
  53. package/dist/flows/ContractorOnboarding/components/BasicInformationStep.d.ts +4 -4
  54. package/dist/flows/ContractorOnboarding/components/ContractDetailsStep.d.ts +5 -5
  55. package/dist/flows/ContractorOnboarding/components/ContractDetailsStep.js +1 -1
  56. package/dist/flows/ContractorOnboarding/components/ContractOriginStep.d.ts +3 -3
  57. package/dist/flows/ContractorOnboarding/components/ContractPreviewHeader.d.ts +2 -2
  58. package/dist/flows/ContractorOnboarding/components/ContractPreviewStatement.d.ts +2 -2
  59. package/dist/flows/ContractorOnboarding/components/ContractPreviewStep.d.ts +5 -5
  60. package/dist/flows/ContractorOnboarding/components/ContractorOnboardingForm.d.ts +5 -5
  61. package/dist/flows/ContractorOnboarding/components/EligibilityQuestionnaireStep.d.ts +5 -5
  62. package/dist/flows/ContractorOnboarding/components/OnboardingInvite.d.ts +3 -3
  63. package/dist/flows/ContractorOnboarding/components/OnboardingInvite.js +1 -1
  64. package/dist/flows/ContractorOnboarding/components/PricingPlan.d.ts +5 -5
  65. package/dist/flows/ContractorOnboarding/components/SaveDraftButton.d.ts +3 -3
  66. package/dist/flows/ContractorOnboarding/components/SelectCountryStep.d.ts +4 -4
  67. package/dist/flows/ContractorOnboarding/context.d.ts +5 -5
  68. package/dist/flows/ContractorOnboarding/hooks.d.ts +5 -5
  69. package/dist/flows/ContractorOnboarding/hooks.js +1 -1
  70. package/dist/flows/ContractorOnboarding/index.d.ts +5 -5
  71. package/dist/flows/ContractorOnboarding/index.js +1 -1
  72. package/dist/flows/ContractorOnboarding/jsfModify.d.ts +5 -5
  73. package/dist/flows/ContractorOnboarding/jsfModify.js +1 -1
  74. package/dist/flows/ContractorOnboarding/types.d.ts +5 -5
  75. package/dist/flows/ContractorOnboarding/utils.d.ts +4 -4
  76. package/dist/flows/ContractorOnboarding/utils.js +1 -1
  77. package/dist/flows/CostCalculator/CostCalculatorFlow.d.ts +3 -3
  78. package/dist/flows/CostCalculator/CostCalculatorFlow.js +1 -1
  79. package/dist/flows/CostCalculator/CostCalculatorForm.d.ts +3 -3
  80. package/dist/flows/CostCalculator/EstimationResults/EstimationResults.d.ts +2 -2
  81. package/dist/flows/CostCalculator/SummaryResults/SummaryResults.d.ts +2 -2
  82. package/dist/flows/CostCalculator/api.d.ts +2 -2
  83. package/dist/flows/CostCalculator/api.js +1 -1
  84. package/dist/flows/CostCalculator/components/SalaryField.d.ts +2 -2
  85. package/dist/flows/CostCalculator/components/SalaryField.js +1 -1
  86. package/dist/flows/CostCalculator/context.d.ts +3 -3
  87. package/dist/flows/CostCalculator/hooks.d.ts +3 -3
  88. package/dist/flows/CostCalculator/hooks.js +1 -1
  89. package/dist/flows/CostCalculator/index.d.ts +3 -3
  90. package/dist/flows/CostCalculator/index.js +1 -1
  91. package/dist/flows/CostCalculator/types.d.ts +2 -2
  92. package/dist/flows/CostCalculator/utils.d.ts +3 -3
  93. package/dist/flows/CostCalculator/utils.js +1 -1
  94. package/dist/flows/CreateCompany/CreateCompany.d.ts +4 -4
  95. package/dist/flows/CreateCompany/CreateCompany.js +1 -1
  96. package/dist/flows/CreateCompany/api.d.ts +2 -2
  97. package/dist/flows/CreateCompany/api.js +1 -1
  98. package/dist/flows/CreateCompany/components/AddressDetailsStep.d.ts +4 -4
  99. package/dist/flows/CreateCompany/components/CompanyBasicInformationStep.d.ts +4 -4
  100. package/dist/flows/CreateCompany/components/CreateCompanyForm.d.ts +2 -2
  101. package/dist/flows/CreateCompany/context.d.ts +4 -4
  102. package/dist/flows/CreateCompany/hooks.d.ts +4 -4
  103. package/dist/flows/CreateCompany/hooks.js +1 -1
  104. package/dist/flows/CreateCompany/index.d.ts +4 -4
  105. package/dist/flows/CreateCompany/index.js +1 -1
  106. package/dist/flows/CreateCompany/types.d.ts +4 -4
  107. package/dist/flows/Onboarding/OnboardingFlow.d.ts +4 -4
  108. package/dist/flows/Onboarding/OnboardingFlow.js +1 -1
  109. package/dist/flows/Onboarding/api.d.ts +4 -4
  110. package/dist/flows/Onboarding/api.js +1 -1
  111. package/dist/flows/Onboarding/components/AnnualGrossSalary.d.ts +2 -2
  112. package/dist/flows/Onboarding/components/AnnualGrossSalary.js +1 -1
  113. package/dist/flows/Onboarding/components/BasicInformationStep.d.ts +4 -4
  114. package/dist/flows/Onboarding/components/BenefitsStep.d.ts +4 -4
  115. package/dist/flows/Onboarding/components/ContractDetailsStep.d.ts +4 -4
  116. package/dist/flows/Onboarding/components/EmploymentAgreementInfoContent.js +1 -1
  117. package/dist/flows/Onboarding/components/EngagementAgreementDetailsStep.d.ts +4 -4
  118. package/dist/flows/Onboarding/components/OnboardingForm.d.ts +4 -4
  119. package/dist/flows/Onboarding/components/OnboardingInvite.d.ts +3 -3
  120. package/dist/flows/Onboarding/components/OnboardingInvite.js +1 -1
  121. package/dist/flows/Onboarding/components/PreOnboardingRequirements.d.ts +4 -4
  122. package/dist/flows/Onboarding/components/PreOnboardingRequirements.js +1 -1
  123. package/dist/flows/Onboarding/components/ReviewStep.d.ts +4 -4
  124. package/dist/flows/Onboarding/components/SaveDraftButton.d.ts +3 -3
  125. package/dist/flows/Onboarding/components/SelectCountryStep.d.ts +4 -4
  126. package/dist/flows/Onboarding/context.d.ts +4 -4
  127. package/dist/flows/Onboarding/hooks.d.ts +4 -4
  128. package/dist/flows/Onboarding/hooks.js +1 -1
  129. package/dist/flows/Onboarding/index.d.ts +4 -4
  130. package/dist/flows/Onboarding/index.js +1 -1
  131. package/dist/flows/Onboarding/types.d.ts +4 -4
  132. package/dist/flows/Onboarding/utils.d.ts +4 -4
  133. package/dist/flows/PayrollAdminOnboarding/PayrollAdminOnboardingFlow.d.ts +3 -3
  134. package/dist/flows/PayrollAdminOnboarding/context.d.ts +3 -3
  135. package/dist/flows/PayrollAdminOnboarding/hooks.d.ts +3 -3
  136. package/dist/flows/PayrollAdminOnboarding/index.d.ts +3 -3
  137. package/dist/flows/PayrollAdminOnboarding/types.d.ts +3 -3
  138. package/dist/flows/PayrollEmployeeOnboarding/PayrollEmployeeOnboardingFlow.d.ts +3 -3
  139. package/dist/flows/PayrollEmployeeOnboarding/context.d.ts +3 -3
  140. package/dist/flows/PayrollEmployeeOnboarding/hooks.d.ts +3 -3
  141. package/dist/flows/PayrollEmployeeOnboarding/index.d.ts +3 -3
  142. package/dist/flows/PayrollEmployeeOnboarding/types.d.ts +3 -3
  143. package/dist/flows/Termination/AdditionalDetailsForm.d.ts +4 -4
  144. package/dist/flows/Termination/EmployeeComunicationForm.d.ts +4 -4
  145. package/dist/flows/Termination/PaidTimeOffForm.d.ts +4 -4
  146. package/dist/flows/Termination/TerminationDetailsForm.d.ts +4 -4
  147. package/dist/flows/Termination/TerminationFlow.d.ts +4 -4
  148. package/dist/flows/Termination/TerminationFlow.js +1 -1
  149. package/dist/flows/Termination/TerminationForm.d.ts +4 -4
  150. package/dist/flows/Termination/api.d.ts +5 -5
  151. package/dist/flows/Termination/api.js +1 -1
  152. package/dist/flows/Termination/components/PaidTimeOff/PaidTimeOff.d.ts +6 -6
  153. package/dist/flows/Termination/components/PaidTimeOff/PaidTimeOffContainer.d.ts +6 -6
  154. package/dist/flows/Termination/components/PaidTimeOff/PaidTimeOffContainer.js +1 -1
  155. package/dist/flows/Termination/components/PaidTimeOff/types.d.ts +6 -6
  156. package/dist/flows/Termination/components/TerminationDialogInfoContent/TerminationDialogInfoContent.js +1 -1
  157. package/dist/flows/Termination/context.d.ts +4 -4
  158. package/dist/flows/Termination/hooks.d.ts +4 -4
  159. package/dist/flows/Termination/hooks.js +1 -1
  160. package/dist/flows/Termination/index.d.ts +6 -6
  161. package/dist/flows/Termination/index.js +1 -1
  162. package/dist/flows/Termination/json-schemas/schema.d.ts +4 -4
  163. package/dist/flows/Termination/types.d.ts +4 -4
  164. package/dist/flows/Termination/utils.d.ts +4 -4
  165. package/dist/flows/types.d.ts +2 -2
  166. package/dist/flows/utils.d.ts +2 -2
  167. package/dist/index.css +1 -1
  168. package/dist/index.css.map +1 -1
  169. package/dist/index.d.ts +13 -13
  170. package/dist/index.js +2 -2
  171. package/dist/internals.d.ts +3 -3
  172. package/dist/internals.js +1 -1
  173. package/dist/{mutations-HzXri7rU.d.ts → mutations-CvqpPAsB.d.ts} +1 -1
  174. package/dist/{remoteFlows-D6N3P-Z8.d.ts → remoteFlows-BVi0Lj1G.d.ts} +1 -1
  175. package/dist/styles.css +1 -1
  176. package/dist/styles.css.map +1 -1
  177. package/dist/{types-CKY2s5Tl.d.ts → types--NmU3NkX.d.ts} +5 -4
  178. package/dist/{types-SOAhi2Xb.d.ts → types-Bfjdf2vn.d.ts} +1 -1
  179. package/dist/{types-BA5HatKg.d.ts → types-Bj0pRx3Z.d.ts} +1 -1
  180. package/dist/{types-OIG1NWJB.d.ts → types-CrB4ZN-n.d.ts} +3 -3
  181. package/dist/{types-CeMJCc7f.d.ts → types-DDzY4RXN.d.ts} +3 -3
  182. package/dist/{types-BxGIDgr8.d.ts → types-DaXs0fB1.d.ts} +2 -2
  183. package/dist/{types-PiIfh75U.d.ts → types-DyMXlKcr.d.ts} +1 -1
  184. package/dist/{types.gen-DCswUxeu.d.ts → types.gen-B96RNslX.d.ts} +1 -1
  185. package/dist/{utils-VhDQSRx8.d.ts → utils-BoX3Tocr.d.ts} +1 -1
  186. package/package.json +2 -2
  187. package/dist/chunk-4LQDSIUG.js +0 -2
  188. package/dist/chunk-4LQDSIUG.js.map +0 -1
  189. package/dist/chunk-6WGW27VH.js +0 -2
  190. package/dist/chunk-6WGW27VH.js.map +0 -1
  191. package/dist/chunk-LKVQ32ZK.js +0 -2
  192. package/dist/chunk-LKVQ32ZK.js.map +0 -1
  193. /package/dist/{DatePickerFieldDefault-EUPACNZD.js.map → DatePickerFieldDefault-XMG6ZDVQ.js.map} +0 -0
  194. /package/dist/{chunk-XEK3MUYF.js.map → chunk-7JWQ24VU.js.map} +0 -0
  195. /package/dist/{chunk-XGXXXWTH.js.map → chunk-ADXJUDVS.js.map} +0 -0
  196. /package/dist/{chunk-QKSYPFRB.js.map → chunk-BSOKKYGH.js.map} +0 -0
  197. /package/dist/{chunk-T7QVVLKT.js.map → chunk-CFGQQEXD.js.map} +0 -0
  198. /package/dist/{chunk-GR6QMP4Z.js.map → chunk-DSL5O7NR.js.map} +0 -0
  199. /package/dist/{chunk-FJGDFNEH.js.map → chunk-F67DSAFU.js.map} +0 -0
  200. /package/dist/{chunk-MG6UYSCR.js.map → chunk-G2FGMFTN.js.map} +0 -0
  201. /package/dist/{chunk-LES7J6H4.js.map → chunk-HAI4J2FU.js.map} +0 -0
  202. /package/dist/{chunk-W4BOTAD6.js.map → chunk-HIDA2KDX.js.map} +0 -0
  203. /package/dist/{chunk-44F5FY7C.js.map → chunk-JQN26ZTU.js.map} +0 -0
  204. /package/dist/{chunk-TWULMMMY.js.map → chunk-LV6MDD3M.js.map} +0 -0
  205. /package/dist/{chunk-WTVYMT5N.js.map → chunk-OISWU4YR.js.map} +0 -0
  206. /package/dist/{chunk-SJO4XFQD.js.map → chunk-PEJ5SKA2.js.map} +0 -0
  207. /package/dist/{chunk-YADHCTR7.js.map → chunk-PXU2LCFW.js.map} +0 -0
  208. /package/dist/{chunk-4RVJJ33G.js.map → chunk-Q5OFEWTH.js.map} +0 -0
  209. /package/dist/{chunk-QGC2HCZG.js.map → chunk-R3JUKEDN.js.map} +0 -0
  210. /package/dist/{chunk-F74X2V2N.js.map → chunk-RG36YL7L.js.map} +0 -0
  211. /package/dist/{chunk-LXNEYPO5.js.map → chunk-SL7O5CUW.js.map} +0 -0
  212. /package/dist/{chunk-XS5ASVWY.js.map → chunk-SQ5KB57O.js.map} +0 -0
  213. /package/dist/{chunk-VUQH44VX.js.map → chunk-UYSY6Z5S.js.map} +0 -0
  214. /package/dist/{chunk-UJWKHGH5.js.map → chunk-VJGCSIOB.js.map} +0 -0
  215. /package/dist/{chunk-HYNJ3ITY.js.map → chunk-XICRWKIW.js.map} +0 -0
  216. /package/dist/{chunk-C332PSLT.js.map → chunk-YCP65XIN.js.map} +0 -0
  217. /package/dist/{chunk-VCF327FJ.js.map → chunk-YRDXBXXA.js.map} +0 -0
  218. /package/dist/{chunk-3U4PZ4KB.js.map → chunk-YUKREGGF.js.map} +0 -0
  219. /package/dist/{chunk-QQ3PZHXO.js.map → chunk-YZ3KEILH.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-6WGW27VH.js";import"./chunk-3B6BHFDV.js";import"./chunk-OPDKYPYM.js";import"./chunk-T5J2Z6ZR.js";import"./chunk-RFVHV6RE.js";import"./chunk-Y3CJRZLA.js";import"./chunk-BYDNNJHZ.js";import"./chunk-G2LZFGZA.js";import"./chunk-H2O4CVKF.js";import"./chunk-P37U34EQ.js";export{a as DatePickerFieldDefault};
2
- //# sourceMappingURL=DatePickerFieldDefault-EUPACNZD.js.map
1
+ import{a}from"./chunk-DAFIBCX4.js";import"./chunk-3B6BHFDV.js";import"./chunk-OPDKYPYM.js";import"./chunk-T5J2Z6ZR.js";import"./chunk-RFVHV6RE.js";import"./chunk-Y3CJRZLA.js";import"./chunk-BYDNNJHZ.js";import"./chunk-G2LZFGZA.js";import"./chunk-H2O4CVKF.js";import"./chunk-P37U34EQ.js";export{a as DatePickerFieldDefault};
2
+ //# sourceMappingURL=DatePickerFieldDefault-XMG6ZDVQ.js.map
@@ -0,0 +1,2 @@
1
+ import{a as se,b as me,c as fe,d as ye,e as _e,f as ge,g as be,i as Ce,j as Se,k as we,l as ve,m as he,n as Pe,o as Ee,p as Oe,q as Ve,r as Fe,s as Me,t as Ie,u as De,v as Ae,w as Re,x as ke}from"./chunk-ADXJUDVS.js";import{a as Te,b as qe,c as Le}from"./chunk-PXU2LCFW.js";import{a as ce,b as le,f as ue,g as de,h as pe}from"./chunk-E2463GRM.js";import{a as q,b as st,c as _,d as oe,g as ae}from"./chunk-PB6UQ4A4.js";import{a as ie}from"./chunk-GNDFT5KG.js";import{f as te,h as ee,i as ne}from"./chunk-HIDA2KDX.js";import{Q as Zt}from"./chunk-BYDNNJHZ.js";import{a as zt,b,d as Xt,h as y,i as D,u as A,v}from"./chunk-G2LZFGZA.js";import{a as re}from"./chunk-JDIKYCN6.js";import{e as Yt}from"./chunk-H2O4CVKF.js";import{a as p}from"./chunk-P37U34EQ.js";import{useEffect as h,useMemo as a,useRef as xe,useState as P}from"react";import Be from"lodash.omit";import{useQuery as Bn}from"@tanstack/react-query";var Qn=p(()=>{let{client:B}=Yt(),{data:L}=me(),d=fe(L)?L?.company?.id??"":"";return Bn({queryKey:["legal-entities",d],queryFn:p(()=>Zt({client:B,path:{company_id:d},query:{page_size:100}}),"queryFn"),select:p(j=>j.data?.data?.legal_entities,"select"),enabled:!!d})},"useLegalEntities"),je=p(()=>{let{data:B}=Qn();return B?.find(L=>L.is_default)},"useDefaultLegalEntity");var Nn={select_country:null,basic_information:"employment_basic_information",contract_origin:null,contract_details:null,eligibility_questionnaire:null,pricing_plan:null,contract_preview:null,review:null},Jn={employment_basic_information:"basic_information"},Ci=p(({countryCode:B,externalId:L,employmentId:d,skipSteps:j,options:f,initialValues:l})=>{let Qe=f?.excludeProducts||[],gt=xe(f?.onContractReviewed);h(()=>{gt.current=f?.onContractReviewed},[f?.onContractReviewed]);let[u,bt]=P(B||null),[r,Ne]=P(d),[g,Ct]=P(void 0),tt=xe({select_country:{},basic_information:{},contract_origin:{},contract_details:{},contract_preview:{},pricing_plan:{},eligibility_questionnaire:{}}),[Q,Je]=P(void 0),[St,wt]=P(!1),[vt,Ue]=P(!0),[ht,Ke]=P(!0),[Pt,Ge]=P(!0),[ct,Et]=P(null),{steps:He,stepsArray:We}=a(()=>ce({includeSelectCountry:!j?.includes("select_country"),includeContractOrigin:Pt,includeEligibilityQuestionnaire:St,includeContractDetails:ht,includeContractPreview:vt}),[Pt,St,ht,vt,j]),{fieldValues:s,stepState:e,setFieldValues:Ot,previousStep:$e,nextStep:ze,goToStep:N,setStepValues:Vt}=re(He);h(()=>{ct&&(N(ct),Et(null))},[ct,N]);let{data:o,isLoading:Xe,refetch:Ft}=ie({employmentId:r,queryParams:{exclude_files:!0}}),Ye=je(),{data:Mt}=ke({options:{queryOptions:{enabled:e.currentStep.name==="review"}}}),{status:R}=o||{},E=R&&ue.includes(R),Ze=R&&!de.includes(R),tn=a(()=>R&&["invited","initiated"].includes(R)?"invited":"not_invited",[R]),It=ee(),Dt=ne(u,f),lt=Se(),At=se(),{mutateAsync:Rt}=he(lt,At,s),kt=Ve(),Tt=Fe(),qt=Ie(),{mutateAsyncOrThrow:en}=b(Dt),Lt=_e(),jt=Ce(),xt=Me(),{mutateAsyncOrThrow:nn}=b(It),{mutateAsyncOrThrow:rn}=b(lt),{mutateAsyncOrThrow:on}=b(Lt),{mutateAsyncOrThrow:Bt}=b(jt),{mutateAsyncOrThrow:an}=b(kt),{mutateAsyncOrThrow:Qt}=b(Tt),{mutateAsyncOrThrow:sn}=b(xt),{mutateAsyncOrThrow:cn}=b(qt);d&&o?.country?.code&&!u&&bt(o.country.code);let{selectCountryForm:J,isLoading:ln,countries:Nt}=Ae({jsfModify:f?.jsfModify?.select_country}),ut=a(()=>Nt?.find(t=>t.value===u),[Nt,u]),un=a(()=>ut?.label,[ut]),dn=e.currentStep.name==="pricing_plan"||!!d&&E,{form:O,isLoading:pn,contractorSubscriptions:et,filteredContractorSubscriptions:U,refetch:dt,isEligibilityQuestionnaireBlocked:K}=ve(r,ut,{jsonSchemaVersion:f?.jsonSchemaVersion,queryOptions:{enabled:dn},excludeProducts:Qe,jsfModify:f?.jsfModify?.pricing_plan}),k=a(()=>!!et?.find(t=>t.product.identifier===_)?.eligibility_questionnaire?.submitted_at,[et]),Jt=a(()=>k?!1:Q===_,[k,Q]),Ut=o?.contractor_type!=="cor",mn=s.contract_origin??e.values?.contract_origin?.contract_origin??o?.contract_details?.contract_origin,x=Q===q&&mn==="provided_by_customer";h(()=>{Ke(!x)},[x]),h(()=>{wt(!x&&Jt)},[x,Jt]),h(()=>{Ue(!x&&Ut)},[x,Ut]);let nt=a(()=>et?.find(t=>t.product.identifier===_)?.eligibility_questionnaire?.responses,[et]),fn=Nn[e.currentStep.name]||"contractor_basic_information",yn=Jn[fn],_n=o?.[yn]||{},gn=p(({form:t,options:i={},query:c={}})=>{let I=Object.keys(s).length>0?{...l,...e.values?.[e.currentStep.name],...s}:{...l,..._n};return te({countryCode:u,form:t,fieldValues:I,query:c,options:{...i,queryOptions:{enabled:i.queryOptions?.enabled??!0}}})},"useJSONSchema"),bn=!!(u&&(e.currentStep.name==="basic_information"||d)),Cn=!!(u==="GBR"&&d&&e.currentStep.name==="basic_information"),{data:G,isLoading:Sn}=Pe(d,{enabled:Cn}),{data:it,isLoading:wn}=Ee(r,{enabled:!!r});h(()=>{it&&it.length>0&&!g&&Ct(it[0].id)},[it,g]);let{data:C,isLoading:vn}=gn({form:"contractor_basic_information",options:{jsfModify:qe(u,un,f),queryOptions:{enabled:bn}}}),hn=a(()=>le(o?.basic_information?.provisional_start_date,s?.service_duration?.provisional_start_date),[o?.basic_information?.provisional_start_date,s?.service_duration?.provisional_start_date]),m=a(()=>{let t={standard:q,plus:st,cor:_};if(s.subscription)return s.subscription;let i=e.values?.pricing_plan?.subscription;if(i&&!K)return i;if(k&&!K)return _;if(K&&k)return q;if(U&&U.length>0)return t[o?.contractor_type]||q},[s,e.values,k,o?.contractor_type,K,U]);h(()=>{m&&m!==Q&&Je(m)},[m,Q]),h(()=>{Ge(!j?.includes("contract_origin")&&m===q)},[j,m]);let Pn=a(()=>({...nt,...l,...e.values?.eligibility_questionnaire,...s}),[nt,l,e.values?.eligibility_questionnaire,s]),En=a(()=>m===_&&e.currentStep.name==="eligibility_questionnaire"||!!d&&E&&m===_,[m,e.currentStep.name,d,E]),{data:V,isLoading:On}=Oe({options:{queryOptions:{enabled:En},jsfModify:f?.jsfModify?.eligibility_questionnaire},fieldValues:Pn}),Vn=!!(u&&e.currentStep.name==="contract_details"||E),{data:S,isLoading:Fn}=Re({countryCode:u,fieldValues:s,employmentId:r,options:{queryOptions:{enabled:Vn},jsfModify:Te(f?.jsfModify?.contract_details,hn,m,s,m===_)}}),Mn=a(()=>e.currentStep.name==="contract_preview"||!!d&&E,[e.currentStep.name,d,E]),{data:F}=ye({fieldValues:s,options:{queryOptions:{enabled:Mn},jsfModify:Le(f,s)}}),{data:M}=De({fieldValues:s,options:{jsfModify:f?.jsfModify?.contract_origin}}),{data:pt,isLoading:In,refetch:Dn}=ge({employmentId:r,contractDocumentId:g,options:{queryOptions:{enabled:!!g}}}),{hasCompanySignedContract:An}=be({employmentId:r,contractDocumentId:g,options:{queryOptions:{enabled:!!g}}}),n=a(()=>({select_country:J?.fields||[],basic_information:C?.fields||[],contract_origin:M?.fields||[],pricing_plan:O?.fields||[],eligibility_questionnaire:V?.fields||[],contract_details:S?.fields||[],contract_preview:F?.fields||[],review:[]}),[J?.fields,C?.fields,M?.fields,O?.fields,S?.fields,F?.fields,V?.fields]),Rn={select_country:null,basic_information:C?.meta["x-jsf-fieldsets"],contract_origin:null,pricing_plan:null,contract_details:S?.meta["x-jsf-fieldsets"],eligibility_questionnaire:null,contract_preview:null,review:null},kn={select_country:J?.meta?.["x-jsf-presentation"],basic_information:C?.meta?.["x-jsf-presentation"],contract_origin:M?.meta?.["x-jsf-presentation"],pricing_plan:O?.meta?.["x-jsf-presentation"],eligibility_questionnaire:V?.meta?.["x-jsf-presentation"],contract_details:S?.meta?.["x-jsf-presentation"],contract_preview:F?.meta?.["x-jsf-presentation"],review:null},{country:Tn,basic_information:rt={},contract_details:Kt={}}=o||{},Gt=Tn?.code,H=a(()=>D(n.select_country,{country:u||Gt||""}),[n.select_country,u,Gt]),mt=a(()=>G?.content?Xt(G.content,G.name):null,[G?.content,G?.name]),W=a(()=>{let t={...l,...rt,ir35:o?.contract_details?.ir_35,nationality_status:o?.contract_details?.nationality,...mt&&{ir35_sds_file:[mt]}};return D(n.basic_information,t)},[l,rt,o?.contract_details?.ir_35,o?.contract_details?.nationality,mt,n.basic_information]),Ht=a(()=>{let t={...l,contract_origin:o?.contract_details?.contract_origin};return D(n.contract_origin,t)},[n.contract_origin,l,o?.contract_details?.contract_origin]),$=a(()=>{let i={...{service_duration:{provisional_start_date:rt.provisional_start_date}},...l,...Kt};return D(n.contract_details,i)},[n.contract_details,Kt,l,rt]),z=a(()=>{let t=pt?.contract_document?.signatories?.find(c=>c.type==="company"),i={...l,signature:t?.signature};return D(n.contract_preview,i)},[n.contract_preview,l,pt]),X=a(()=>{let i={...{subscription:m},...l};return D(n.pricing_plan,i)},[n.pricing_plan,l,m]),Y=a(()=>{let t={...l,...nt};return D(n.eligibility_questionnaire,t)},[n.eligibility_questionnaire,l,nt]),qn=a(()=>({select_country:H,basic_information:W,contract_origin:Ht,contract_details:$,contract_preview:z,pricing_plan:X,eligibility_questionnaire:Y}),[H,W,Ht,$,z,X,Y]),ft=!!(d&&E&&e.currentStep.name!=="review"),yt=ln||vn||Xe||Fn||pn||In||Sn||wn||On,Wt=a(()=>{let i=o?.contractor_type==="cor"||n.contract_preview.length>0;return!!(ft&&!yt&&g&&n.basic_information.length>0&&n.contract_details.length>0&&i)},[ft,yt,g,n.basic_information.length,n.contract_details.length,n.contract_preview.length,o?.contractor_type]);h(()=>{Wt&&(tt.current={select_country:A(H,n.select_country,{skipMoneyConversion:!0}),basic_information:A(W,n.basic_information,{skipMoneyConversion:!0}),contract_origin:{},contract_details:A($,n.contract_details,{skipMoneyConversion:!0}),contract_preview:A(z,n.contract_preview,{skipMoneyConversion:!0}),pricing_plan:A(X,n.pricing_plan,{skipMoneyConversion:!0}),eligibility_questionnaire:A(Y,n.eligibility_questionnaire,{skipMoneyConversion:!0})},Vt({select_country:H,basic_information:W,contract_origin:{},contract_details:$,contract_preview:z,pricing_plan:X,eligibility_questionnaire:Y,review:{}}),N("review"))},[Wt,N,H,W,$,Vt,n.select_country,n.basic_information,n.contract_details,n.pricing_plan,X,n.contract_preview,z,n.eligibility_questionnaire,Y]);let Ln=p(t=>{N(t)},"goTo"),$t=p(async t=>J&&e.currentStep.name==="select_country"?t:C&&e.currentStep.name==="basic_information"?await y(t,C?.fields,{isPartialValidation:!1}):S&&e.currentStep.name==="contract_details"?await y(t,S?.fields,{isPartialValidation:!1}):F&&e.currentStep.name==="contract_preview"?await y(t,F?.fields,{isPartialValidation:!1}):O&&e.currentStep.name==="pricing_plan"?await y(t,O?.fields,{isPartialValidation:!1}):V&&e.currentStep.name==="eligibility_questionnaire"?await y(t,V?.fields,{isPartialValidation:!1}):M&&e.currentStep.name==="contract_origin"?await y(t,M?.fields,{isPartialValidation:!1}):{},"parseFormValues"),jn=p(t=>{if(!zt(t))return null;let i=t.normalizedErrors.services_and_deliverables,c=Array.isArray(i)?i[0]:i;return c?.source===ae?{error:c.error,source:c.source,skippable:c.skippable}:null},"extractAiValidationError");async function xn(t){let i=e.currentStep.name,c=await $t(t);switch(i in tt.current&&(tt.current[i]=A(c,n[i])),e.currentStep.name){case"select_country":return bt(c.country),Promise.resolve({data:{countryCode:c.country}});case"basic_information":{let T=!r&&u,I=r&&u&&o?.country&&o?.country.code!==u;if(T||I){let _t={basic_information:Be(c,"nationality_status","ir35","ir35_sds_file"),type:"contractor",country_code:u,external_id:L},at=await nn(_t),w=at?.data?.employment?.id;if(!w)throw v("Employment ID not found");return await Rt({employmentId:w}),Ne(w),at}else if(r){let ot=Be(c,"nationality_status","ir35","ir35_sds_file");return await Rt({employmentId:r}),en({employmentId:r,basic_information:ot})}return}case"contract_details":{let{services_and_deliverables_ai_warning:T,services_and_deliverables_error_skippable:I,...ot}=c,_t=s.services_and_deliverables_error_skippable===!0,at={contract_document:ot,skip_ai_checks:_t};try{let w=await rn({employmentId:r,payload:at}),Z=w?.data?.contract_document?.id;if(!Z)throw v("Contract document ID not found");return Ct(Z),w}catch(w){let Z=jn(w);throw Z&&Ot({...t,services_and_deliverables_ai_warning:pe(m===_),services_and_deliverables_error_skippable:Z.skippable}),w}}case"contract_preview":{if(An)return Promise.resolve({data:{contract_document:{id:g}}});let T=await on({employmentId:r,contractDocumentId:g,payload:{signature:c.signature}});return await Dn(),T}case"pricing_plan":{if(t.subscription===oe)return Promise.resolve({data:{subscription:t.subscription}});if(U.length===0)throw v("No available subscriptions.");if(!t.subscription&&U.length>0)throw v("Please select a subscription plan.");if(K&&[_,st].includes(t.subscription))throw v(`This individual is not eligible for ${we[t.subscription]}.`);if(k&&t.subscription!==_)try{await sn({employmentId:r}),await dt()}catch(I){if(I?.response?.status!==404)throw I;await dt()}if(t.subscription==q)return Bt({employmentId:r,payload:{operation:"downgrade"}});if(t.subscription==st)return Bt({employmentId:r,payload:{operation:"upgrade"}});if(t.subscription==_)return k&&o?.contractor_type!=="cor"?Qt({employmentId:r}):Promise.resolve({data:{subscription:t.subscription}});throw v("invalid selection")}case"contract_origin":return t.contract_origin==="provided_by_customer"&&await cn({employmentId:r,contractOrigin:"provided_by_customer",templateType:"contractor_agreement"}),{data:{contractOrigin:t.contract_origin}};case"eligibility_questionnaire":try{if((await an({employmentId:r,payload:c}))?.data?.is_blocking)throw wt(!1),Et("pricing_plan"),v("This individual is not eligible for Contractor of Record.");return await Qt({employmentId:r})}finally{await dt()}default:throw v("Invalid step state")}}return p(xn,"onSubmit"),{isLoading:yt||ft,fieldValues:s,stepState:e,checkFieldUpdates:Ot,markContractAsReviewed:p(()=>{gt.current?.()},"markContractAsReviewed"),back:$e,next:p(()=>{r&&Ft(),ze()},"handleNextStep"),goTo:Ln,onSubmit:xn,fields:n[e.currentStep.name],meta:{fields:tt.current,fieldsets:Rn[e.currentStep.name],presentation:kn[e.currentStep.name]},parseFormValues:$t,canSkipAiValidation:s.services_and_deliverables_error_skippable===!0,handleValidation:p(async t=>{if(e.currentStep.name==="select_country")return J.handleValidation(t);if(C&&e.currentStep.name==="basic_information"){let i=await y(t,C?.fields,{isPartialValidation:!1});return C?.handleValidation(i)}if(S&&e.currentStep.name==="contract_details"){let i=await y(t,S?.fields,{isPartialValidation:!1});return S?.handleValidation(i)}if(F&&e.currentStep.name==="contract_preview"){let i=await y(t,F?.fields,{isPartialValidation:!0});return F?.handleValidation(i)}if(O&&e.currentStep.name==="pricing_plan"){let i=await y(t,O?.fields,{isPartialValidation:!1});return O?.handleValidation(i)}if(V&&e.currentStep.name==="eligibility_questionnaire"){let i=await y(t,V?.fields,{isPartialValidation:!1});return V?.handleValidation(i)}if(M&&e.currentStep.name==="contract_origin"){let i=await y(t,M?.fields,{isPartialValidation:!1});return M?.handleValidation(i)}return null},"handleValidation"),initialValues:qn,employmentId:r,refetchEmployment:Ft,isSubmitting:It.isPending||Dt.isPending||lt.isPending||Lt.isPending||jt.isPending||At.isPending||kt.isPending||Tt.isPending||xt.isPending||qt.isPending,documentPreviewPdf:pt,canInvite:Ze,isEmploymentReadOnly:E,invitedStatus:tn,employment:o,defaultLegalEntity:Ye,needsCompanyVerification:Mt?.some(t=>t.type==="verify_company")??!1,needsRemotePaymentsSetup:Mt?.some(t=>t.type==="setup_remote_payments")??!1,steps:We}},"useContractorOnboarding");export{Ci as a};
2
+ //# sourceMappingURL=chunk-3HMUXWNW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/ContractorOnboarding/hooks.tsx","../src/common/api/legal-entities.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react';\nimport { FieldValues } from 'react-hook-form';\nimport omit from 'lodash.omit';\nimport { $TSFixMe, JSFFields } from '@/src/types/remoteFlows';\nimport {\n CreateContractDocument,\n Employment,\n EmploymentCreateParams,\n} from '@/src/client/types.gen';\nimport {\n getInitialValues,\n parseJSFToValidate,\n} from '@/src/components/form/utils';\nimport { ValidationResult } from '@remoteoss/remote-json-schema-form-kit';\nimport {\n useCreateContractorContractDocument,\n useGetContractDocumentSignatureSchema,\n usePostManageContractorSubscriptions,\n useContractorSubscriptionSchemaField,\n useGetShowContractDocument,\n useSignContractDocument,\n useUpdateUKandSaudiFields,\n useGetIR35File,\n useGetContractDocuments,\n useGetEligibilityQuestionnaire,\n usePostCreateEligibilityQuestionnaire,\n usePostManageContractorCorSubscription,\n useDeleteContractorCorSubscription,\n useCountriesSchemaField,\n useContractorOnboardingDetailsSchemaWithCurrencies,\n CONTRACT_PRODUCT_TITLES,\n useHasCompanySignedContract,\n useCompanyOpenTasks,\n useSetContractOrigin,\n useGetContractOriginSchema,\n} from '@/src/flows/ContractorOnboarding/api';\nimport {\n ContractorOnboardingFlowProps,\n ContractorOnboardingHookOptions,\n} from '@/src/flows/ContractorOnboarding/types';\nimport {\n buildSteps,\n calculateProvisionalStartDateDescription,\n reviewStepAllowedEmploymentStatus,\n disabledInviteButtonEmploymentStatus,\n StepKeys,\n} from '@/src/flows/ContractorOnboarding/utils';\nimport {\n useCreateEmployment,\n useJSONSchemaForm,\n useUpdateEmployment,\n} from '@/src/flows/Onboarding/api';\nimport { FlowOptions, JSFModify, JSONSchemaFormType } from '@/src/flows/types';\nimport { useStepState } from '@/src/flows/useStepState';\nimport { mutationToPromise, isMutationError } from '@/src/lib/mutations';\nimport { createStructuredError, prettifyFormValues } from '@/src/lib/utils';\nimport { JSFFieldset, Meta } from '@/src/types/remoteFlows';\nimport {\n contractorStandardProductIdentifier,\n contractorPlusProductIdentifier,\n corProductIdentifier,\n eorProductIdentifier,\n REMOTE_AI_ERROR_SOURCE,\n} from '@/src/flows/ContractorOnboarding/constants';\nimport {\n buildBasicInformationJsfModify,\n buildContractDetailsJsfModify,\n buildContractPreviewJsfModify,\n} from '@/src/flows/ContractorOnboarding/jsfModify';\nimport { transformAiErrorResponse } from '@/src/flows/ContractorOnboarding/utils';\nimport { AiValidationError } from '@/src/flows/ContractorOnboarding/types';\nimport { useUploadFile } from '@/src/common/api/files';\nimport { dataURLtoFile } from '@/src/lib/files';\nimport { useEmploymentQuery } from '@/src/common/api/employment';\nimport { useDefaultLegalEntity } from '@/src/common/api/legal-entities';\n\ntype useContractorOnboardingProps = Omit<\n ContractorOnboardingFlowProps,\n 'render' | 'options'\n> & {\n options: ContractorOnboardingHookOptions;\n};\n\nconst stepToFormSchemaMap: Record<StepKeys, JSONSchemaFormType | null> = {\n select_country: null,\n basic_information: 'employment_basic_information',\n contract_origin: null,\n contract_details: null,\n eligibility_questionnaire: null,\n pricing_plan: null,\n contract_preview: null,\n review: null,\n};\n\nconst jsonSchemaToEmployment: Partial<\n Record<JSONSchemaFormType, keyof Employment>\n> = {\n employment_basic_information: 'basic_information',\n};\n\nexport const useContractorOnboarding = ({\n countryCode,\n externalId,\n employmentId,\n skipSteps,\n options,\n initialValues: onboardingInitialValues,\n}: useContractorOnboardingProps) => {\n const excludeProducts = options?.excludeProducts || [];\n\n const onContractReviewedRef = useRef(options?.onContractReviewed);\n\n useEffect(() => {\n onContractReviewedRef.current = options?.onContractReviewed;\n }, [options?.onContractReviewed]);\n\n const [internalCountryCode, setInternalCountryCode] = useState<string | null>(\n countryCode || null,\n );\n const [internalEmploymentId, setInternalEmploymentId] = useState<\n string | undefined\n >(employmentId);\n const [internalContractDocumentId, setInternalContractDocumentId] = useState<\n string | undefined\n >(undefined);\n const fieldsMetaRef = useRef<{\n select_country: Meta;\n basic_information: Meta;\n contract_origin: Meta;\n contract_details: Meta;\n contract_preview: Meta;\n pricing_plan: Meta;\n eligibility_questionnaire: Meta;\n }>({\n select_country: {},\n basic_information: {},\n contract_origin: {},\n contract_details: {},\n contract_preview: {},\n pricing_plan: {},\n eligibility_questionnaire: {},\n });\n\n const [selectedProduct, setSelectedProduct] = useState<string | undefined>(\n undefined,\n );\n\n const [includeEligibilityQuestionnaire, setIncludeEligibilityQuestionnaire] =\n useState<boolean>(false);\n\n const [includeContractPreview, setIncludeContractPreview] =\n useState<boolean>(true);\n\n const [includeContractDetails, setIncludeContractDetails] =\n useState<boolean>(true);\n\n const [includeContractOrigin, setIncludeContractOrigin] =\n useState<boolean>(true);\n\n const [pendingNavigationStep, setPendingNavigationStep] =\n useState<StepKeys | null>(null);\n\n const { steps, stepsArray } = useMemo(\n () =>\n buildSteps({\n includeSelectCountry: !skipSteps?.includes('select_country'),\n includeContractOrigin: includeContractOrigin,\n includeEligibilityQuestionnaire: includeEligibilityQuestionnaire,\n includeContractDetails: includeContractDetails,\n includeContractPreview: includeContractPreview,\n }),\n [\n includeContractOrigin,\n includeEligibilityQuestionnaire,\n includeContractDetails,\n includeContractPreview,\n skipSteps,\n ],\n );\n\n const {\n fieldValues,\n stepState,\n setFieldValues,\n previousStep,\n nextStep,\n goToStep,\n setStepValues,\n } = useStepState(steps);\n\n useEffect(() => {\n if (pendingNavigationStep) {\n // Now steps have been updated\n goToStep(pendingNavigationStep);\n setPendingNavigationStep(null);\n }\n }, [pendingNavigationStep, goToStep]);\n\n const {\n data: employment,\n isLoading: isLoadingEmployment,\n refetch: refetchEmployment,\n } = useEmploymentQuery({\n employmentId: internalEmploymentId as string,\n queryParams: { exclude_files: true },\n });\n\n const defaultLegalEntity = useDefaultLegalEntity();\n\n const { data: openTasks } = useCompanyOpenTasks({\n options: {\n queryOptions: {\n enabled: stepState.currentStep.name === 'review',\n },\n },\n });\n\n const { status: employmentStatus } = employment || {};\n\n const isEmploymentReadOnly =\n employmentStatus &&\n reviewStepAllowedEmploymentStatus.includes(employmentStatus);\n\n const canInvite =\n employmentStatus &&\n !disabledInviteButtonEmploymentStatus.includes(employmentStatus);\n\n const invitedStatus: 'invited' | 'not_invited' = useMemo(() => {\n const invitedStatuses = ['invited', 'initiated'];\n const isInvited =\n employmentStatus && invitedStatuses.includes(employmentStatus);\n\n return isInvited ? 'invited' : 'not_invited';\n }, [employmentStatus]);\n\n const createEmploymentMutation = useCreateEmployment();\n const updateEmploymentMutation = useUpdateEmployment(\n internalCountryCode as string,\n options,\n );\n const createContractorContractDocumentMutation =\n useCreateContractorContractDocument();\n const uploadFileMutation = useUploadFile();\n const { mutateAsync: updateUKandSaudiFieldsMutation } =\n useUpdateUKandSaudiFields(\n createContractorContractDocumentMutation,\n uploadFileMutation,\n fieldValues,\n );\n const createEligibilityQuestionnaireMutation =\n usePostCreateEligibilityQuestionnaire();\n const manageContractorCorSubscriptionMutation =\n usePostManageContractorCorSubscription();\n const setContractOriginMutation = useSetContractOrigin();\n\n const { mutateAsyncOrThrow: updateEmploymentMutationAsync } =\n mutationToPromise(updateEmploymentMutation);\n const signContractDocumentMutation = useSignContractDocument();\n const manageContractorSubscriptionMutation =\n usePostManageContractorSubscriptions();\n const deleteContractorCorSubscriptionMutation =\n useDeleteContractorCorSubscription();\n\n const { mutateAsyncOrThrow: createEmploymentMutationAsync } =\n mutationToPromise(createEmploymentMutation);\n\n const { mutateAsyncOrThrow: createContractorContractDocumentMutationAsync } =\n mutationToPromise(createContractorContractDocumentMutation);\n\n const { mutateAsyncOrThrow: signContractDocumentMutationAsync } =\n mutationToPromise(signContractDocumentMutation);\n\n const { mutateAsyncOrThrow: manageContractorSubscriptionMutationAsync } =\n mutationToPromise(manageContractorSubscriptionMutation);\n\n const { mutateAsyncOrThrow: createEligibilityQuestionnaireMutationAsync } =\n mutationToPromise(createEligibilityQuestionnaireMutation);\n\n const { mutateAsyncOrThrow: manageContractorCorSubscriptionMutationAsync } =\n mutationToPromise(manageContractorCorSubscriptionMutation);\n\n const { mutateAsyncOrThrow: deleteContractorCorSubscriptionMutationAsync } =\n mutationToPromise(deleteContractorCorSubscriptionMutation);\n\n const { mutateAsyncOrThrow: setContractOriginMutationAsync } =\n mutationToPromise(setContractOriginMutation);\n\n // if the employment is loaded, country code has not been set yet\n // we set the internal country code with the employment country code\n if (employmentId && employment?.country?.code && !internalCountryCode) {\n setInternalCountryCode(employment.country.code);\n }\n\n const {\n selectCountryForm,\n isLoading: isLoadingCountries,\n countries,\n } = useCountriesSchemaField({\n jsfModify: options?.jsfModify?.select_country,\n });\n\n const selectedCountry = useMemo(() => {\n return countries?.find((country) => country.value === internalCountryCode);\n }, [countries, internalCountryCode]);\n\n const countryName = useMemo(() => {\n return selectedCountry?.label;\n }, [selectedCountry]);\n\n const isPricingPlanEnabled =\n stepState.currentStep.name === 'pricing_plan' ||\n (Boolean(employmentId) && isEmploymentReadOnly);\n\n const {\n form: selectContractorSubscriptionForm,\n isLoading: isLoadingContractorSubscriptions,\n contractorSubscriptions,\n filteredContractorSubscriptions,\n refetch: refetchContractorSubscriptions,\n isEligibilityQuestionnaireBlocked,\n } = useContractorSubscriptionSchemaField(\n internalEmploymentId as string,\n selectedCountry,\n {\n jsonSchemaVersion: options?.jsonSchemaVersion,\n queryOptions: {\n enabled: isPricingPlanEnabled,\n },\n excludeProducts: excludeProducts,\n jsfModify: options?.jsfModify?.pricing_plan,\n },\n );\n\n const hasEligibilityQuestionnaireSubmitted = useMemo(() => {\n return Boolean(\n contractorSubscriptions?.find(\n (subscription) =>\n subscription.product.identifier === corProductIdentifier,\n )?.eligibility_questionnaire?.submitted_at,\n );\n }, [contractorSubscriptions]);\n\n const shouldIncludeEligibilityQuestionnaire = useMemo(() => {\n if (hasEligibilityQuestionnaireSubmitted) return false;\n return selectedProduct === corProductIdentifier;\n }, [hasEligibilityQuestionnaireSubmitted, selectedProduct]);\n\n const shouldIncludeContractPreview = employment?.contractor_type !== 'cor';\n\n const selectedContractOrigin =\n (fieldValues.contract_origin as string | undefined) ??\n (stepState.values?.contract_origin?.contract_origin as\n | string\n | undefined) ??\n employment?.contract_details?.contract_origin;\n\n const isContractProvidedByCustomer =\n selectedProduct === contractorStandardProductIdentifier &&\n selectedContractOrigin === 'provided_by_customer';\n\n useEffect(() => {\n setIncludeContractDetails(!isContractProvidedByCustomer);\n }, [isContractProvidedByCustomer]);\n\n useEffect(() => {\n setIncludeEligibilityQuestionnaire(\n !isContractProvidedByCustomer && shouldIncludeEligibilityQuestionnaire,\n );\n }, [isContractProvidedByCustomer, shouldIncludeEligibilityQuestionnaire]);\n\n useEffect(() => {\n setIncludeContractPreview(\n !isContractProvidedByCustomer && shouldIncludeContractPreview,\n );\n }, [isContractProvidedByCustomer, shouldIncludeContractPreview]);\n\n const eligibilityAnswers = useMemo(() => {\n return contractorSubscriptions?.find(\n (subscription) =>\n subscription.product.identifier === corProductIdentifier,\n )?.eligibility_questionnaire?.responses;\n }, [contractorSubscriptions]);\n\n const formType =\n stepToFormSchemaMap[stepState.currentStep.name] ||\n 'contractor_basic_information';\n const employmentKey = jsonSchemaToEmployment[formType] as keyof Employment;\n const serverEmploymentData = (employment?.[employmentKey] || {}) as Record<\n string,\n unknown\n >;\n\n const useJSONSchema = ({\n form,\n options: jsonSchemaOptions = {},\n query = {},\n }: {\n form: JSONSchemaFormType;\n options?: {\n jsfModify?: JSFModify;\n queryOptions?: { enabled?: boolean };\n jsonSchemaVersion?: FlowOptions['jsonSchemaVersion'];\n };\n query?: Record<string, string>;\n }) => {\n const hasUserEnteredAnyValues = Object.keys(fieldValues).length > 0;\n // when you write on the fields, the values are stored in the fieldValues state\n // when values are stored in the stepState is when the user has navigated to the step\n // and then we have the values from the server and the onboardingInitialValues that the user can inject,\n const mergedFormValues = hasUserEnteredAnyValues\n ? {\n ...onboardingInitialValues,\n ...stepState.values?.[stepState.currentStep.name], // Restore values for the current step\n ...fieldValues,\n }\n : {\n ...onboardingInitialValues,\n ...serverEmploymentData,\n };\n\n return useJSONSchemaForm({\n countryCode: internalCountryCode as string,\n form: form,\n fieldValues: mergedFormValues,\n query,\n options: {\n ...jsonSchemaOptions,\n queryOptions: {\n enabled: jsonSchemaOptions.queryOptions?.enabled ?? true,\n },\n },\n });\n };\n\n const isBasicInformationDetailsEnabled = Boolean(\n internalCountryCode &&\n (stepState.currentStep.name === 'basic_information' ||\n Boolean(employmentId)),\n );\n\n const isIR35FileEnabled = Boolean(\n internalCountryCode === 'GBR' &&\n employmentId &&\n stepState.currentStep.name === 'basic_information',\n );\n\n const { data: ir35File, isLoading: isLoadingIR35File } = useGetIR35File(\n employmentId as string,\n {\n enabled: isIR35FileEnabled,\n },\n );\n\n const { data: contractDocuments, isLoading: isLoadingContractDocuments } =\n useGetContractDocuments(internalEmploymentId as string, {\n enabled: Boolean(internalEmploymentId),\n });\n\n useEffect(() => {\n if (\n contractDocuments &&\n contractDocuments.length > 0 &&\n !internalContractDocumentId\n ) {\n setInternalContractDocumentId(contractDocuments[0].id);\n }\n }, [contractDocuments, internalContractDocumentId]);\n\n const {\n data: basicInformationForm,\n isLoading: isLoadingBasicInformationForm,\n } = useJSONSchema({\n form: 'contractor_basic_information',\n options: {\n jsfModify: buildBasicInformationJsfModify(\n internalCountryCode as string,\n countryName,\n options,\n ),\n queryOptions: {\n enabled: isBasicInformationDetailsEnabled,\n },\n },\n });\n\n const descriptionProvisionalStartDate = useMemo(() => {\n return calculateProvisionalStartDateDescription(\n employment?.basic_information?.provisional_start_date as string,\n fieldValues?.service_duration?.provisional_start_date as string,\n );\n }, [\n employment?.basic_information?.provisional_start_date,\n fieldValues?.service_duration?.provisional_start_date,\n ]);\n\n /**\n * When the user selects COR, the data isn't saved yet in the BE\n * We need to use the internalState to know what has happened\n */\n const selectedPricingPlan = useMemo(() => {\n const subscriptions = {\n standard: contractorStandardProductIdentifier,\n plus: contractorPlusProductIdentifier,\n cor: corProductIdentifier,\n };\n\n // HIGHEST PRIORITY: Current form value (user is actively selecting)\n if (fieldValues.subscription) {\n return fieldValues.subscription;\n }\n\n // SECOND: Previously submitted value in this session\n const subscription = stepState.values?.pricing_plan?.subscription;\n if (subscription && !isEligibilityQuestionnaireBlocked) {\n return subscription;\n }\n\n // THIRD: Backend state (eligibility submitted or employment contractor_type)\n if (\n hasEligibilityQuestionnaireSubmitted &&\n !isEligibilityQuestionnaireBlocked\n ) {\n return corProductIdentifier;\n }\n\n // Fourth: If the eligibility questionnaire is blocked and has been submitted, return the standard product\n if (\n isEligibilityQuestionnaireBlocked &&\n hasEligibilityQuestionnaireSubmitted\n ) {\n return contractorStandardProductIdentifier;\n }\n\n // Fifth: If there are no available subscriptions, return undefined\n const hasAvailableSubscriptions =\n filteredContractorSubscriptions &&\n filteredContractorSubscriptions.length > 0;\n\n if (!hasAvailableSubscriptions) {\n return undefined;\n }\n\n // FALLBACK: Employment contractor_type or default\n return (\n subscriptions[\n employment?.contractor_type as keyof typeof subscriptions\n ] || contractorStandardProductIdentifier\n );\n }, [\n fieldValues,\n stepState.values,\n hasEligibilityQuestionnaireSubmitted,\n employment?.contractor_type,\n isEligibilityQuestionnaireBlocked,\n filteredContractorSubscriptions,\n ]);\n\n useEffect(() => {\n if (selectedPricingPlan && selectedPricingPlan !== selectedProduct) {\n setSelectedProduct(selectedPricingPlan);\n }\n }, [selectedPricingPlan, selectedProduct]);\n\n useEffect(() => {\n setIncludeContractOrigin(\n !skipSteps?.includes('contract_origin') &&\n selectedPricingPlan === contractorStandardProductIdentifier,\n );\n }, [skipSteps, selectedPricingPlan]);\n\n const eligibilityFields = useMemo(() => {\n return {\n ...eligibilityAnswers,\n ...onboardingInitialValues,\n ...stepState.values?.eligibility_questionnaire,\n ...fieldValues,\n };\n }, [\n eligibilityAnswers,\n onboardingInitialValues,\n stepState.values?.eligibility_questionnaire,\n fieldValues,\n ]);\n\n const isEligibilityQuestionnaireEnabled = useMemo(() => {\n return (\n (selectedPricingPlan === corProductIdentifier &&\n stepState.currentStep.name === 'eligibility_questionnaire') ||\n (Boolean(employmentId) &&\n isEmploymentReadOnly &&\n selectedPricingPlan === corProductIdentifier)\n );\n }, [\n selectedPricingPlan,\n stepState.currentStep.name,\n employmentId,\n isEmploymentReadOnly,\n ]);\n\n const {\n data: eligibilityQuestionnaireForm,\n isLoading: isLoadingEligibilityQuestionnaire,\n } = useGetEligibilityQuestionnaire({\n options: {\n queryOptions: {\n enabled: isEligibilityQuestionnaireEnabled,\n },\n jsfModify: options?.jsfModify?.eligibility_questionnaire,\n },\n fieldValues: eligibilityFields,\n });\n\n const isContractorOnboardingDetailsEnabled = Boolean(\n (internalCountryCode &&\n stepState.currentStep.name === 'contract_details') ||\n isEmploymentReadOnly,\n );\n\n const {\n data: contractorOnboardingDetailsForm,\n isLoading: isLoadingContractorOnboardingDetailsForm,\n } = useContractorOnboardingDetailsSchemaWithCurrencies({\n countryCode: internalCountryCode as string,\n fieldValues: fieldValues,\n employmentId: internalEmploymentId as string,\n options: {\n queryOptions: {\n enabled: isContractorOnboardingDetailsEnabled,\n },\n jsfModify: buildContractDetailsJsfModify(\n options?.jsfModify?.contract_details,\n descriptionProvisionalStartDate,\n selectedPricingPlan,\n fieldValues,\n selectedPricingPlan === corProductIdentifier,\n ),\n },\n });\n\n const isSignatureSchemaEnabled = useMemo(() => {\n return (\n stepState.currentStep.name === 'contract_preview' ||\n (Boolean(employmentId) && isEmploymentReadOnly)\n );\n }, [stepState.currentStep.name, employmentId, isEmploymentReadOnly]);\n\n const { data: signatureSchemaForm } = useGetContractDocumentSignatureSchema({\n fieldValues: fieldValues,\n options: {\n queryOptions: {\n enabled: isSignatureSchemaEnabled,\n },\n jsfModify: buildContractPreviewJsfModify(options, fieldValues),\n },\n });\n\n const { data: contractOriginForm } = useGetContractOriginSchema({\n fieldValues: fieldValues,\n options: {\n jsfModify: options?.jsfModify?.contract_origin,\n },\n });\n\n const {\n data: documentPreviewPdf,\n isLoading: isLoadingDocumentPreviewForm,\n refetch: refetchDocumentPreviewForm,\n } = useGetShowContractDocument({\n employmentId: internalEmploymentId as string,\n contractDocumentId: internalContractDocumentId as string,\n options: {\n queryOptions: {\n enabled: Boolean(internalContractDocumentId),\n },\n },\n });\n\n const { hasCompanySignedContract } = useHasCompanySignedContract({\n employmentId: internalEmploymentId as string,\n contractDocumentId: internalContractDocumentId as string,\n options: {\n queryOptions: {\n enabled: Boolean(internalContractDocumentId),\n },\n },\n });\n\n const stepFields: Record<StepKeys, JSFFields> = useMemo(\n () => ({\n select_country: selectCountryForm?.fields || [],\n basic_information: basicInformationForm?.fields || [],\n contract_origin: contractOriginForm?.fields || [],\n pricing_plan: selectContractorSubscriptionForm?.fields || [],\n eligibility_questionnaire: eligibilityQuestionnaireForm?.fields || [],\n contract_details: contractorOnboardingDetailsForm?.fields || [],\n contract_preview: signatureSchemaForm?.fields || [],\n review: [],\n }),\n [\n selectCountryForm?.fields,\n basicInformationForm?.fields,\n contractOriginForm?.fields,\n selectContractorSubscriptionForm?.fields,\n contractorOnboardingDetailsForm?.fields,\n signatureSchemaForm?.fields,\n eligibilityQuestionnaireForm?.fields,\n ],\n );\n\n const stepFieldsWithFlatFieldsets: Record<\n StepKeys,\n JSFFieldset | null | undefined\n > = {\n select_country: null,\n basic_information: basicInformationForm?.meta['x-jsf-fieldsets'],\n contract_origin: null,\n pricing_plan: null,\n contract_details: contractorOnboardingDetailsForm?.meta['x-jsf-fieldsets'],\n eligibility_questionnaire: null,\n contract_preview: null,\n review: null,\n };\n\n const stepPresentation: Record<\n StepKeys,\n Record<string, unknown> | null | undefined\n > = {\n select_country: selectCountryForm?.meta?.['x-jsf-presentation'],\n basic_information: basicInformationForm?.meta?.['x-jsf-presentation'],\n contract_origin: contractOriginForm?.meta?.['x-jsf-presentation'],\n pricing_plan:\n selectContractorSubscriptionForm?.meta?.['x-jsf-presentation'],\n eligibility_questionnaire:\n eligibilityQuestionnaireForm?.meta?.['x-jsf-presentation'],\n contract_details:\n contractorOnboardingDetailsForm?.meta?.['x-jsf-presentation'],\n contract_preview: signatureSchemaForm?.meta?.['x-jsf-presentation'],\n review: null,\n };\n\n const {\n country,\n basic_information: employmentBasicInformation = {},\n contract_details: employmentContractDetails = {},\n } = employment || {};\n\n const employmentCountryCode = country?.code;\n\n const selectCountryInitialValues = useMemo(\n () =>\n getInitialValues(stepFields.select_country, {\n country: internalCountryCode || employmentCountryCode || '',\n }),\n [stepFields.select_country, internalCountryCode, employmentCountryCode],\n );\n\n // memoize file conversion to avoid re-converting the file on every render\n // noticed performance issues when not doing memoizing individually\n const convertedIr35File = useMemo(() => {\n if (!ir35File?.content) return null;\n return dataURLtoFile(ir35File.content as unknown as string, ir35File.name);\n }, [ir35File?.content, ir35File?.name]);\n\n const basicInformationInitialValues = useMemo(() => {\n const initialValues = {\n ...onboardingInitialValues,\n ...employmentBasicInformation,\n ir35: employment?.contract_details?.ir_35,\n nationality_status: employment?.contract_details?.nationality,\n ...(convertedIr35File && {\n ir35_sds_file: [convertedIr35File],\n }),\n };\n\n return getInitialValues(stepFields.basic_information, initialValues);\n }, [\n onboardingInitialValues,\n employmentBasicInformation,\n employment?.contract_details?.ir_35,\n employment?.contract_details?.nationality,\n convertedIr35File,\n stepFields.basic_information,\n ]);\n\n const contractOriginInitialValues = useMemo(() => {\n const initialValues = {\n ...onboardingInitialValues,\n contract_origin: employment?.contract_details?.contract_origin,\n };\n return getInitialValues(stepFields.contract_origin, initialValues);\n }, [\n stepFields.contract_origin,\n onboardingInitialValues,\n employment?.contract_details?.contract_origin,\n ]);\n\n const contractDetailsInitialValues = useMemo(() => {\n const hardcodedValues = {\n service_duration: {\n provisional_start_date:\n employmentBasicInformation.provisional_start_date,\n },\n };\n const initialValues = {\n ...hardcodedValues,\n ...onboardingInitialValues,\n ...employmentContractDetails,\n };\n\n return getInitialValues(stepFields.contract_details, initialValues);\n }, [\n stepFields.contract_details,\n employmentContractDetails,\n onboardingInitialValues,\n employmentBasicInformation,\n ]);\n\n const contractPreviewInitialValues = useMemo(() => {\n const signature = documentPreviewPdf?.contract_document?.signatories?.find(\n (signatory) => signatory.type === 'company',\n );\n const initialValues = {\n ...onboardingInitialValues,\n signature: signature?.signature,\n };\n\n return getInitialValues(stepFields.contract_preview, initialValues);\n }, [\n stepFields.contract_preview,\n onboardingInitialValues,\n documentPreviewPdf,\n ]);\n\n const pricingPlanInitialValues = useMemo(() => {\n const preselectedPricingPlan = {\n subscription: selectedPricingPlan,\n };\n const initialValues = {\n ...preselectedPricingPlan,\n ...onboardingInitialValues,\n };\n\n return getInitialValues(stepFields.pricing_plan, initialValues);\n }, [stepFields.pricing_plan, onboardingInitialValues, selectedPricingPlan]);\n\n const eligibilityQuestionnaireInitialValues = useMemo(() => {\n const initialValues = {\n ...onboardingInitialValues,\n ...eligibilityAnswers,\n };\n return getInitialValues(\n stepFields.eligibility_questionnaire,\n initialValues,\n );\n }, [\n stepFields.eligibility_questionnaire,\n onboardingInitialValues,\n eligibilityAnswers,\n ]);\n\n const initialValues = useMemo(() => {\n return {\n select_country: selectCountryInitialValues,\n basic_information: basicInformationInitialValues,\n contract_origin: contractOriginInitialValues,\n contract_details: contractDetailsInitialValues,\n contract_preview: contractPreviewInitialValues,\n pricing_plan: pricingPlanInitialValues,\n eligibility_questionnaire: eligibilityQuestionnaireInitialValues,\n };\n }, [\n selectCountryInitialValues,\n basicInformationInitialValues,\n contractOriginInitialValues,\n contractDetailsInitialValues,\n contractPreviewInitialValues,\n pricingPlanInitialValues,\n eligibilityQuestionnaireInitialValues,\n ]);\n\n const shouldHandleReadOnlyEmployment = Boolean(\n employmentId &&\n isEmploymentReadOnly &&\n stepState.currentStep.name !== 'review',\n );\n\n const initialLoading =\n isLoadingCountries ||\n isLoadingBasicInformationForm ||\n isLoadingEmployment ||\n isLoadingContractorOnboardingDetailsForm ||\n isLoadingContractorSubscriptions ||\n isLoadingDocumentPreviewForm ||\n isLoadingIR35File ||\n isLoadingContractDocuments ||\n isLoadingEligibilityQuestionnaire;\n\n const isNavigatingToReview = useMemo(() => {\n const isCor = employment?.contractor_type === 'cor';\n const hasContractPreviewFields =\n isCor || stepFields.contract_preview.length > 0;\n\n return Boolean(\n shouldHandleReadOnlyEmployment &&\n !initialLoading &&\n Boolean(internalContractDocumentId) &&\n stepFields.basic_information.length > 0 &&\n stepFields.contract_details.length > 0 &&\n hasContractPreviewFields,\n );\n }, [\n shouldHandleReadOnlyEmployment,\n initialLoading,\n internalContractDocumentId,\n stepFields.basic_information.length,\n stepFields.contract_details.length,\n stepFields.contract_preview.length,\n employment?.contractor_type,\n ]);\n\n useEffect(() => {\n if (isNavigatingToReview) {\n fieldsMetaRef.current = {\n select_country: prettifyFormValues(\n selectCountryInitialValues,\n stepFields.select_country,\n { skipMoneyConversion: true },\n ),\n basic_information: prettifyFormValues(\n basicInformationInitialValues,\n stepFields.basic_information,\n { skipMoneyConversion: true },\n ),\n contract_origin: {},\n contract_details: prettifyFormValues(\n contractDetailsInitialValues,\n stepFields.contract_details,\n { skipMoneyConversion: true },\n ),\n contract_preview: prettifyFormValues(\n contractPreviewInitialValues,\n stepFields.contract_preview,\n { skipMoneyConversion: true },\n ),\n pricing_plan: prettifyFormValues(\n pricingPlanInitialValues,\n stepFields.pricing_plan,\n { skipMoneyConversion: true },\n ),\n eligibility_questionnaire: prettifyFormValues(\n eligibilityQuestionnaireInitialValues,\n stepFields.eligibility_questionnaire,\n { skipMoneyConversion: true },\n ),\n };\n\n setStepValues({\n select_country: selectCountryInitialValues,\n basic_information: basicInformationInitialValues,\n contract_origin: {},\n contract_details: contractDetailsInitialValues,\n contract_preview: contractPreviewInitialValues,\n pricing_plan: pricingPlanInitialValues,\n eligibility_questionnaire: eligibilityQuestionnaireInitialValues,\n review: {},\n });\n goToStep('review');\n }\n }, [\n isNavigatingToReview,\n goToStep,\n selectCountryInitialValues,\n basicInformationInitialValues,\n contractDetailsInitialValues,\n setStepValues,\n stepFields.select_country,\n stepFields.basic_information,\n stepFields.contract_details,\n stepFields.pricing_plan,\n pricingPlanInitialValues,\n stepFields.contract_preview,\n contractPreviewInitialValues,\n stepFields.eligibility_questionnaire,\n eligibilityQuestionnaireInitialValues,\n ]);\n\n const goTo = (step: StepKeys) => {\n goToStep(step);\n };\n\n const parseFormValues = async (values: FieldValues) => {\n if (selectCountryForm && stepState.currentStep.name === 'select_country') {\n return values;\n }\n\n if (\n basicInformationForm &&\n stepState.currentStep.name === 'basic_information'\n ) {\n return await parseJSFToValidate(values, basicInformationForm?.fields, {\n isPartialValidation: false,\n });\n }\n\n if (\n contractorOnboardingDetailsForm &&\n stepState.currentStep.name === 'contract_details'\n ) {\n return await parseJSFToValidate(\n values,\n contractorOnboardingDetailsForm?.fields,\n {\n isPartialValidation: false,\n },\n );\n }\n\n if (\n signatureSchemaForm &&\n stepState.currentStep.name === 'contract_preview'\n ) {\n return await parseJSFToValidate(values, signatureSchemaForm?.fields, {\n isPartialValidation: false,\n });\n }\n\n if (\n selectContractorSubscriptionForm &&\n stepState.currentStep.name === 'pricing_plan'\n ) {\n return await parseJSFToValidate(\n values,\n selectContractorSubscriptionForm?.fields,\n {\n isPartialValidation: false,\n },\n );\n }\n\n if (\n eligibilityQuestionnaireForm &&\n stepState.currentStep.name === 'eligibility_questionnaire'\n ) {\n return await parseJSFToValidate(\n values,\n eligibilityQuestionnaireForm?.fields,\n {\n isPartialValidation: false,\n },\n );\n }\n\n if (\n contractOriginForm &&\n stepState.currentStep.name === 'contract_origin'\n ) {\n return await parseJSFToValidate(values, contractOriginForm?.fields, {\n isPartialValidation: false,\n });\n }\n\n return {};\n };\n\n /**\n * Extracts AI validation error from the error response\n * @param error - The error object from the API call\n * @returns The AI validation error if found, null otherwise\n */\n const extractAiValidationError = (\n error: unknown,\n ): AiValidationError | null => {\n if (!isMutationError(error)) {\n return null;\n }\n\n const rawError = error.normalizedErrors.services_and_deliverables;\n\n // The backend's normalize_errors wraps non-list values in an array,\n // so the AI validation error object arrives as a single-element array.\n const servicesAndDeliverablesError = (\n Array.isArray(rawError) ? rawError[0] : rawError\n ) as\n | {\n error: string[];\n source: string;\n skippable: boolean;\n }\n | undefined;\n\n if (servicesAndDeliverablesError?.source === REMOTE_AI_ERROR_SOURCE) {\n return {\n error: servicesAndDeliverablesError.error,\n source: servicesAndDeliverablesError.source,\n skippable: servicesAndDeliverablesError.skippable,\n };\n }\n return null;\n };\n\n async function onSubmit(values: FieldValues) {\n const currentStepName = stepState.currentStep.name;\n const parsedValues = await parseFormValues(values);\n\n if (currentStepName in fieldsMetaRef.current) {\n fieldsMetaRef.current[\n currentStepName as keyof typeof fieldsMetaRef.current\n ] = prettifyFormValues(parsedValues, stepFields[currentStepName]);\n }\n switch (stepState.currentStep.name) {\n case 'select_country': {\n setInternalCountryCode(parsedValues.country);\n return Promise.resolve({ data: { countryCode: parsedValues.country } });\n }\n case 'basic_information': {\n const isEmploymentNotLoaded =\n !internalEmploymentId && internalCountryCode;\n const hasChangedCountry =\n internalEmploymentId &&\n internalCountryCode &&\n employment?.country &&\n employment?.country.code !== internalCountryCode;\n\n if (isEmploymentNotLoaded || hasChangedCountry) {\n const basicInformationParsedValues = omit(\n parsedValues,\n 'nationality_status',\n 'ir35',\n 'ir35_sds_file',\n );\n const basicInformationPayload: EmploymentCreateParams = {\n basic_information: basicInformationParsedValues,\n type: 'contractor',\n country_code: internalCountryCode,\n external_id: externalId,\n };\n const response = await createEmploymentMutationAsync(\n basicInformationPayload,\n );\n const employmentId = response?.data?.employment?.id;\n if (!employmentId) {\n throw createStructuredError('Employment ID not found');\n }\n\n await updateUKandSaudiFieldsMutation({\n employmentId: employmentId as string,\n });\n\n // Only update state (triggers queries with fully consistent backend state) if not caused a bug\n // if one of the updateUKandSaudiFieldsMutation fails with a 422 for example\n setInternalEmploymentId(employmentId);\n\n return response;\n } else if (internalEmploymentId) {\n const basicInformationParsedValues = omit(\n parsedValues,\n 'nationality_status',\n 'ir35',\n 'ir35_sds_file',\n );\n\n await updateUKandSaudiFieldsMutation({\n employmentId: internalEmploymentId,\n });\n return updateEmploymentMutationAsync({\n employmentId: internalEmploymentId,\n basic_information: basicInformationParsedValues,\n });\n }\n\n return;\n }\n case 'contract_details': {\n const {\n services_and_deliverables_ai_warning:\n _servicesAndDeliverablesAiWarning,\n services_and_deliverables_error_skippable:\n _servicesAndDeliverablesErrorSkippable,\n ...contractDetailsData\n } = parsedValues;\n\n const shouldSkipAiChecks =\n fieldValues.services_and_deliverables_error_skippable === true;\n const payload: CreateContractDocument = {\n contract_document: contractDetailsData,\n skip_ai_checks: shouldSkipAiChecks,\n };\n\n try {\n const response = await createContractorContractDocumentMutationAsync({\n employmentId: internalEmploymentId as string,\n payload,\n });\n const contractDocumentId = response?.data?.contract_document?.id;\n if (!contractDocumentId) {\n throw createStructuredError('Contract document ID not found');\n }\n setInternalContractDocumentId(contractDocumentId);\n\n return response;\n } catch (error) {\n const aiError = extractAiValidationError(error);\n if (aiError) {\n const isContractorOfRecord =\n selectedPricingPlan === corProductIdentifier;\n setFieldValues({\n ...values,\n services_and_deliverables_ai_warning:\n transformAiErrorResponse(isContractorOfRecord),\n services_and_deliverables_error_skippable: aiError.skippable,\n });\n }\n\n throw error;\n }\n }\n\n case 'contract_preview': {\n if (hasCompanySignedContract) {\n return Promise.resolve({\n data: {\n contract_document: {\n id: internalContractDocumentId,\n },\n },\n });\n }\n const response = await signContractDocumentMutationAsync({\n employmentId: internalEmploymentId as string,\n contractDocumentId: internalContractDocumentId as string,\n payload: {\n signature: parsedValues.signature,\n },\n });\n await refetchDocumentPreviewForm();\n return response;\n }\n case 'pricing_plan': {\n if (values.subscription === eorProductIdentifier) {\n // EOR selection - no API call needed at this step\n return Promise.resolve({\n data: {\n subscription: values.subscription,\n },\n });\n }\n // If there are no available contractor subscriptions, throw an error\n if (filteredContractorSubscriptions.length === 0) {\n throw createStructuredError('No available subscriptions.');\n }\n\n if (\n !values.subscription &&\n filteredContractorSubscriptions.length > 0\n ) {\n throw createStructuredError('Please select a subscription plan.');\n }\n\n const blockedProductsEligibility = [\n corProductIdentifier,\n contractorPlusProductIdentifier,\n ];\n\n if (\n isEligibilityQuestionnaireBlocked &&\n blockedProductsEligibility.includes(values.subscription)\n ) {\n throw createStructuredError(\n `This individual is not eligible for ${\n CONTRACT_PRODUCT_TITLES[\n values.subscription as keyof typeof CONTRACT_PRODUCT_TITLES\n ]\n }.`,\n );\n }\n\n if (\n hasEligibilityQuestionnaireSubmitted &&\n values.subscription !== corProductIdentifier\n ) {\n try {\n await deleteContractorCorSubscriptionMutationAsync({\n employmentId: internalEmploymentId as string,\n });\n await refetchContractorSubscriptions();\n } catch (error) {\n if ((error as $TSFixMe)?.response?.status !== 404) {\n throw error;\n }\n // Still refetch to update the UI state\n await refetchContractorSubscriptions();\n }\n }\n\n if (values.subscription == contractorStandardProductIdentifier) {\n return manageContractorSubscriptionMutationAsync({\n employmentId: internalEmploymentId as string,\n payload: {\n operation: 'downgrade',\n },\n });\n } else if (values.subscription == contractorPlusProductIdentifier) {\n return manageContractorSubscriptionMutationAsync({\n employmentId: internalEmploymentId as string,\n payload: {\n operation: 'upgrade',\n },\n });\n } else if (values.subscription == corProductIdentifier) {\n if (\n hasEligibilityQuestionnaireSubmitted &&\n employment?.contractor_type !== 'cor'\n ) {\n return manageContractorCorSubscriptionMutationAsync({\n employmentId: internalEmploymentId as string,\n });\n } else {\n return Promise.resolve({\n data: { subscription: values.subscription },\n });\n }\n }\n\n throw createStructuredError('invalid selection');\n }\n\n case 'contract_origin': {\n // Step visibility is already reconciled reactively from the selected\n // value, so a plain next() lands on the right step (review when the\n // customer provides their own contract, otherwise eligibility /\n // contract_details). We only persist the choice server-side here.\n if (values.contract_origin === 'provided_by_customer') {\n await setContractOriginMutationAsync({\n employmentId: internalEmploymentId as string,\n contractOrigin: 'provided_by_customer',\n templateType: 'contractor_agreement',\n });\n }\n\n return {\n data: { contractOrigin: values.contract_origin },\n };\n }\n\n case 'eligibility_questionnaire': {\n try {\n const response = await createEligibilityQuestionnaireMutationAsync({\n employmentId: internalEmploymentId as string,\n payload: parsedValues,\n });\n\n const isEligibilityQuestionnaireBlocked = response?.data?.is_blocking;\n\n if (isEligibilityQuestionnaireBlocked) {\n setIncludeEligibilityQuestionnaire(false);\n setPendingNavigationStep('pricing_plan');\n throw createStructuredError(\n 'This individual is not eligible for Contractor of Record.',\n );\n }\n\n return await manageContractorCorSubscriptionMutationAsync({\n employmentId: internalEmploymentId as string,\n });\n } finally {\n // Always refetch to keep state in sync, even on error\n await refetchContractorSubscriptions();\n }\n }\n\n default: {\n throw createStructuredError('Invalid step state');\n }\n }\n }\n\n const markContractAsReviewed = () => {\n // Notify parent to sync form state\n onContractReviewedRef.current?.();\n };\n\n const handleNextStep = () => {\n if (internalEmploymentId) {\n refetchEmployment();\n }\n nextStep();\n };\n\n const isLoading = initialLoading || shouldHandleReadOnlyEmployment;\n\n return {\n /**\n * Loading state indicating if the flow is loading data\n */\n isLoading,\n\n /**\n * Current state of the form fields for the current step.\n */\n fieldValues,\n\n /**\n * Current step state containing the current step and total number of steps\n */\n stepState,\n\n /**\n * Function to update the current form field values\n * @param values - New form values to set\n */\n checkFieldUpdates: setFieldValues,\n\n /**\n * Function to mark the contract as reviewed\n * @param values - New form values to check\n * @returns {boolean}\n */\n markContractAsReviewed,\n\n /**\n * Function to handle going back to the previous step\n * @returns {void}\n */\n back: previousStep,\n\n /**\n * Function to handle going to the next step\n * @returns {void}\n */\n next: handleNextStep,\n\n /**\n * Function to handle going to a specific step\n * @param step The step to go to.\n * @returns {void}\n */\n goTo: goTo,\n\n /**\n * Function to handle form submission\n * @param values - Form values to submit\n * @returns Promise resolving to the mutation result\n */\n onSubmit,\n\n /**\n * Array of form fields from the onboarding schema\n */\n fields: stepFields[stepState.currentStep.name],\n\n /**\n * Fields metadata for each step\n */\n meta: {\n fields: fieldsMetaRef.current,\n fieldsets: stepFieldsWithFlatFieldsets[stepState.currentStep.name],\n presentation: stepPresentation[stepState.currentStep.name],\n },\n\n /**\n * Function to parse form values before submission\n * @param values - Form values to parse\n * @returns Parsed form values\n */\n parseFormValues,\n\n /**\n * Indicates whether AI validation errors can be skipped (user can continue at their own risk).\n * True when there's a skippable AI validation error on services_and_deliverables field.\n * @returns {boolean}\n */\n canSkipAiValidation:\n fieldValues.services_and_deliverables_error_skippable === true,\n\n /**\n * Function to validate form values against the onboarding schema\n * @param values - Form values to validate\n * @returns Validation result or null if no schema is available\n */\n handleValidation: async (\n values: FieldValues,\n ): Promise<ValidationResult | null> => {\n if (stepState.currentStep.name === 'select_country') {\n return selectCountryForm.handleValidation(values);\n }\n\n if (\n basicInformationForm &&\n stepState.currentStep.name === 'basic_information'\n ) {\n const parsedValues = await parseJSFToValidate(\n values,\n basicInformationForm?.fields,\n { isPartialValidation: false },\n );\n return basicInformationForm?.handleValidation(parsedValues);\n }\n\n if (\n contractorOnboardingDetailsForm &&\n stepState.currentStep.name === 'contract_details'\n ) {\n const parsedValues = await parseJSFToValidate(\n values,\n contractorOnboardingDetailsForm?.fields,\n { isPartialValidation: false },\n );\n return contractorOnboardingDetailsForm?.handleValidation(parsedValues);\n }\n\n if (\n signatureSchemaForm &&\n stepState.currentStep.name === 'contract_preview'\n ) {\n const parsedValues = await parseJSFToValidate(\n values,\n signatureSchemaForm?.fields,\n { isPartialValidation: true },\n );\n return signatureSchemaForm?.handleValidation(parsedValues);\n }\n\n if (\n selectContractorSubscriptionForm &&\n stepState.currentStep.name === 'pricing_plan'\n ) {\n const parsedValues = await parseJSFToValidate(\n values,\n selectContractorSubscriptionForm?.fields,\n { isPartialValidation: false },\n );\n return selectContractorSubscriptionForm?.handleValidation(parsedValues);\n }\n\n if (\n eligibilityQuestionnaireForm &&\n stepState.currentStep.name === 'eligibility_questionnaire'\n ) {\n const parsedValues = await parseJSFToValidate(\n values,\n eligibilityQuestionnaireForm?.fields,\n { isPartialValidation: false },\n );\n return eligibilityQuestionnaireForm?.handleValidation(parsedValues);\n }\n\n if (\n contractOriginForm &&\n stepState.currentStep.name === 'contract_origin'\n ) {\n const parsedValues = await parseJSFToValidate(\n values,\n contractOriginForm?.fields,\n { isPartialValidation: false },\n );\n return contractOriginForm?.handleValidation(parsedValues);\n }\n\n return null;\n },\n\n /**\n * Initial form values\n */\n initialValues,\n\n /**\n * Employment id\n */\n employmentId: internalEmploymentId,\n\n /**\n * Function to refetch the employment data\n * @returns {void}\n */\n refetchEmployment: refetchEmployment,\n\n /**\n * Loading state indicating if the onboarding mutation is in progress\n */\n isSubmitting:\n createEmploymentMutation.isPending ||\n updateEmploymentMutation.isPending ||\n createContractorContractDocumentMutation.isPending ||\n signContractDocumentMutation.isPending ||\n manageContractorSubscriptionMutation.isPending ||\n uploadFileMutation.isPending ||\n createEligibilityQuestionnaireMutation.isPending ||\n manageContractorCorSubscriptionMutation.isPending ||\n deleteContractorCorSubscriptionMutation.isPending ||\n setContractOriginMutation.isPending,\n\n /**\n * Document preview PDF data\n */\n documentPreviewPdf,\n\n /**\n * let's the user know if the company can invite employees\n * @returns {boolean}\n */\n canInvite,\n\n /**\n * let's the user know that the employment cannot be edited, happens when employment.status is invited\n * @returns {boolean}\n */\n isEmploymentReadOnly,\n /**\n * let's the user know if the employment is invited or not\n * @returns {'invited' | 'not_invited'}\n */\n invitedStatus,\n\n /**\n * Employment data\n * @returns {Employment}\n */\n employment,\n\n /**\n * Default legal entity\n * @returns {CompanyLegalEntity}\n */\n defaultLegalEntity,\n\n /**\n * Whether the company needs to complete KYB verification before contractors can be paid.\n * Use this to show a company verification nudge banner on the review step.\n */\n needsCompanyVerification:\n openTasks?.some((a) => a.type === 'verify_company') ?? false,\n\n /**\n * Whether the company needs to set up Remote Payments.\n * Use this to show a Remote Payments setup nudge banner on the review step.\n */\n needsRemotePaymentsSetup:\n openTasks?.some((a) => a.type === 'setup_remote_payments') ?? false,\n\n /**\n * Steps array\n * @returns {Array<{name: string, index: number, visible: boolean, label: string}>}\n */\n steps: stepsArray,\n };\n};\n","import { useQuery } from '@tanstack/react-query';\nimport {\n getV1CompaniesCompanyIdLegalEntities,\n CompanyLegalEntity,\n} from '@/src/client';\nimport { Client } from '@/src/client/client';\nimport { useClient } from '@/src/context';\nimport { useIdentity } from '@/src/common/api/identity';\nimport { hasCompany } from '@/src/common/api/companies';\n\n/**\n * Hook to get the legal entities for a company\n * @param companyId - The company ID\n * @returns The legal entities\n */\nexport const useLegalEntities = () => {\n const { client } = useClient();\n const { data: identity } = useIdentity();\n const companyId = hasCompany(identity) ? (identity?.company?.id ?? '') : '';\n\n return useQuery({\n queryKey: ['legal-entities', companyId],\n queryFn: () =>\n getV1CompaniesCompanyIdLegalEntities({\n client: client as Client,\n path: {\n company_id: companyId,\n },\n query: {\n page_size: 100,\n },\n }),\n select: (data) => data.data?.data?.legal_entities,\n enabled: !!companyId,\n });\n};\n\nexport const useDefaultLegalEntity = () => {\n const { data: legalEntities } = useLegalEntities();\n return legalEntities?.find(\n (legalEntity: CompanyLegalEntity) => legalEntity.is_default,\n );\n};\n"],"mappings":"ivBAAA,OAAS,aAAAA,EAAW,WAAAC,EAAS,UAAAC,GAAQ,YA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AAiByD,CAAY,CACpE,CAEA,GACE7C,GACApH,EAAU,YAAY,OAAS,kBAC/B,CACA,IAAMiK,EAAe,MAAMT,EACzBD,EACAnC,GAAoB,OACpB,CAAE,oBAAqB,EAAM,CAC/B,EACA,OAAOA,GAAoB,iBAAiB6C,CAAY,CAC1D,CAEA,OAAO,IACT,EAhFkB,oBAqFlB,cAAA1B,GAKA,aAAc7J,EAMd,kBAAmB+B,GAKnB,aACEY,GAAyB,WACzBE,GAAyB,WACzBE,GAAyC,WACzCc,GAA6B,WAC7BE,GAAqC,WACrCd,GAAmB,WACnBI,GAAuC,WACvCE,GAAwC,WACxCU,GAAwC,WACxCR,GAA0B,UAK5B,mBAAAmF,GAMA,UAAApG,GAMA,qBAAAF,EAKA,cAAAI,GAMA,WAAAb,EAMA,mBAAAI,GAMA,yBACEE,IAAW,KAAMsK,GAAMA,EAAE,OAAS,gBAAgB,GAAK,GAMzD,yBACEtK,IAAW,KAAMsK,GAAMA,EAAE,OAAS,uBAAuB,GAAK,GAMhE,MAAOvL,EACT,CACF,EA1gDuC","names":["useEffect","useMemo","useRef","useState","omit","useQuery","useLegalEntities","__name","client","useClient","identity","useIdentity","companyId","hasCompany","useQuery","getV1CompaniesCompanyIdLegalEntities","data","useDefaultLegalEntity","legalEntities","legalEntity","stepToFormSchemaMap","jsonSchemaToEmployment","useContractorOnboarding","__name","countryCode","externalId","employmentId","skipSteps","options","onboardingInitialValues","excludeProducts","onContractReviewedRef","useRef","useEffect","internalCountryCode","setInternalCountryCode","useState","internalEmploymentId","setInternalEmploymentId","internalContractDocumentId","setInternalContractDocumentId","fieldsMetaRef","selectedProduct","setSelectedProduct","includeEligibilityQuestionnaire","setIncludeEligibilityQuestionnaire","includeContractPreview","setIncludeContractPreview","includeContractDetails","setIncludeContractDetails","includeContractOrigin","setIncludeContractOrigin","pendingNavigationStep","setPendingNavigationStep","steps","stepsArray","useMemo","buildSteps","fieldValues","stepState","setFieldValues","previousStep","nextStep","goToStep","setStepValues","useStepState","employment","isLoadingEmployment","refetchEmployment","useEmploymentQuery","defaultLegalEntity","useDefaultLegalEntity","openTasks","useCompanyOpenTasks","employmentStatus","isEmploymentReadOnly","reviewStepAllowedEmploymentStatus","canInvite","disabledInviteButtonEmploymentStatus","invitedStatus","createEmploymentMutation","useCreateEmployment","updateEmploymentMutation","useUpdateEmployment","createContractorContractDocumentMutation","useCreateContractorContractDocument","uploadFileMutation","useUploadFile","updateUKandSaudiFieldsMutation","useUpdateUKandSaudiFields","createEligibilityQuestionnaireMutation","usePostCreateEligibilityQuestionnaire","manageContractorCorSubscriptionMutation","usePostManageContractorCorSubscription","setContractOriginMutation","useSetContractOrigin","updateEmploymentMutationAsync","mutationToPromise","signContractDocumentMutation","useSignContractDocument","manageContractorSubscriptionMutation","usePostManageContractorSubscriptions","deleteContractorCorSubscriptionMutation","useDeleteContractorCorSubscription","createEmploymentMutationAsync","createContractorContractDocumentMutationAsync","signContractDocumentMutationAsync","manageContractorSubscriptionMutationAsync","createEligibilityQuestionnaireMutationAsync","manageContractorCorSubscriptionMutationAsync","deleteContractorCorSubscriptionMutationAsync","setContractOriginMutationAsync","selectCountryForm","isLoadingCountries","countries","useCountriesSchemaField","selectedCountry","country","countryName","isPricingPlanEnabled","selectContractorSubscriptionForm","isLoadingContractorSubscriptions","contractorSubscriptions","filteredContractorSubscriptions","refetchContractorSubscriptions","isEligibilityQuestionnaireBlocked","useContractorSubscriptionSchemaField","hasEligibilityQuestionnaireSubmitted","subscription","corProductIdentifier","shouldIncludeEligibilityQuestionnaire","shouldIncludeContractPreview","selectedContractOrigin","isContractProvidedByCustomer","contractorStandardProductIdentifier","eligibilityAnswers","formType","employmentKey","serverEmploymentData","useJSONSchema","form","jsonSchemaOptions","query","mergedFormValues","useJSONSchemaForm","isBasicInformationDetailsEnabled","isIR35FileEnabled","ir35File","isLoadingIR35File","useGetIR35File","contractDocuments","isLoadingContractDocuments","useGetContractDocuments","basicInformationForm","isLoadingBasicInformationForm","buildBasicInformationJsfModify","descriptionProvisionalStartDate","calculateProvisionalStartDateDescription","selectedPricingPlan","subscriptions","contractorPlusProductIdentifier","eligibilityFields","isEligibilityQuestionnaireEnabled","eligibilityQuestionnaireForm","isLoadingEligibilityQuestionnaire","useGetEligibilityQuestionnaire","isContractorOnboardingDetailsEnabled","contractorOnboardingDetailsForm","isLoadingContractorOnboardingDetailsForm","useContractorOnboardingDetailsSchemaWithCurrencies","buildContractDetailsJsfModify","isSignatureSchemaEnabled","signatureSchemaForm","useGetContractDocumentSignatureSchema","buildContractPreviewJsfModify","contractOriginForm","useGetContractOriginSchema","documentPreviewPdf","isLoadingDocumentPreviewForm","refetchDocumentPreviewForm","useGetShowContractDocument","hasCompanySignedContract","useHasCompanySignedContract","stepFields","stepFieldsWithFlatFieldsets","stepPresentation","employmentBasicInformation","employmentContractDetails","employmentCountryCode","selectCountryInitialValues","getInitialValues","convertedIr35File","dataURLtoFile","basicInformationInitialValues","initialValues","contractOriginInitialValues","contractDetailsInitialValues","contractPreviewInitialValues","signature","signatory","pricingPlanInitialValues","eligibilityQuestionnaireInitialValues","shouldHandleReadOnlyEmployment","initialLoading","isNavigatingToReview","hasContractPreviewFields","prettifyFormValues","goTo","step","parseFormValues","values","parseJSFToValidate","extractAiValidationError","error","isMutationError","rawError","servicesAndDeliverablesError","REMOTE_AI_ERROR_SOURCE","onSubmit","currentStepName","parsedValues","isEmploymentNotLoaded","hasChangedCountry","basicInformationPayload","omit","response","createStructuredError","basicInformationParsedValues","_servicesAndDeliverablesAiWarning","_servicesAndDeliverablesErrorSkippable","contractDetailsData","shouldSkipAiChecks","payload","contractDocumentId","aiError","transformAiErrorResponse","eorProductIdentifier","CONTRACT_PRODUCT_TITLES","a"]}
@@ -1,2 +1,2 @@
1
- import{b as y}from"./chunk-Q3ALCPJN.js";import{d as p,e as v}from"./chunk-W4BOTAD6.js";import{b as n,w as u}from"./chunk-G2LZFGZA.js";import{b as l}from"./chunk-H2O4CVKF.js";import{a as r}from"./chunk-P37U34EQ.js";import O from"lodash.omit";import{jsx as C}from"react/jsx-runtime";function T({onSubmit:f,onSuccess:i,onError:s,render:w,...o}){let{components:E}=l(),{contractorOnboardingBag:e}=y(),a=p(),m=v(),{mutateAsyncOrThrow:g}=n(a),{mutateAsyncOrThrow:I}=n(m),c=e.employment?.contractor_type==="cor"&&!e.isEmploymentReadOnly,R=r(async()=>{try{if(await f?.(),c&&e.employmentId){let t=await I({employment_slug:e.employmentId});if(t?.data){await i?.({data:t,employmentStatus:"created_awaiting_reserve"}),e.refetchEmployment();return}}else if(e.employmentId){let t=await g({employment_id:e.employmentId});t&&(await i?.({data:t,employmentStatus:"invited"}),e.refetchEmployment())}}catch(t){u(t)?s?.(O(t,"response")):s?.({error:t,rawError:t,fieldErrors:[]})}},"handleSubmit"),d=E?.button;if(!d)throw new Error("Button component not found");let b=a.isPending||m.isPending||!e.canInvite||o.disabled;return C(d,{...o,disabled:b,onClick:t=>{R(),o.onClick?.(t)},children:w({status:c?"create_reserve":"invite"})})}r(T,"OnboardingInvite");export{T as a};
2
- //# sourceMappingURL=chunk-XEK3MUYF.js.map
1
+ import{b as y}from"./chunk-Q3ALCPJN.js";import{d as p,e as v}from"./chunk-HIDA2KDX.js";import{b as n,w as u}from"./chunk-G2LZFGZA.js";import{b as l}from"./chunk-H2O4CVKF.js";import{a as r}from"./chunk-P37U34EQ.js";import O from"lodash.omit";import{jsx as C}from"react/jsx-runtime";function T({onSubmit:f,onSuccess:i,onError:s,render:w,...o}){let{components:E}=l(),{contractorOnboardingBag:e}=y(),a=p(),m=v(),{mutateAsyncOrThrow:g}=n(a),{mutateAsyncOrThrow:I}=n(m),c=e.employment?.contractor_type==="cor"&&!e.isEmploymentReadOnly,R=r(async()=>{try{if(await f?.(),c&&e.employmentId){let t=await I({employment_slug:e.employmentId});if(t?.data){await i?.({data:t,employmentStatus:"created_awaiting_reserve"}),e.refetchEmployment();return}}else if(e.employmentId){let t=await g({employment_id:e.employmentId});t&&(await i?.({data:t,employmentStatus:"invited"}),e.refetchEmployment())}}catch(t){u(t)?s?.(O(t,"response")):s?.({error:t,rawError:t,fieldErrors:[]})}},"handleSubmit"),d=E?.button;if(!d)throw new Error("Button component not found");let b=a.isPending||m.isPending||!e.canInvite||o.disabled;return C(d,{...o,disabled:b,onClick:t=>{R(),o.onClick?.(t)},children:w({status:c?"create_reserve":"invite"})})}r(T,"OnboardingInvite");export{T as a};
2
+ //# sourceMappingURL=chunk-7JWQ24VU.js.map
@@ -0,0 +1,2 @@
1
+ import{f as m}from"./chunk-G2LZFGZA.js";import{b as u}from"./chunk-626FTNKA.js";import{a}from"./chunk-P37U34EQ.js";import{createHeadlessForm as F,modify as p}from"@remoteoss/remote-json-schema-form-kit";var O=a((e,t,n)=>{if(n&&n.jsfModify){let{required:r,allOf:i,...s}=n.jsfModify,{schema:o,warnings:d}=p(e,{...s,muteLogging:!0});if(d&&d.length>0&&console.warn("jsfModify warnings:",d),e=o,r){let f=Array.isArray(o.required)?o.required:[];typeof r=="function"?e.required=r(f):e.required=[...f,...r]}i&&(e.allOf=[...Array.isArray(o.allOf)?o.allOf:[],...i])}let l={};t&&(l=u(e.properties||{},"money").reduce((i,s)=>(i[s]=m(t[s]),i),{}));let y=JSON.parse(JSON.stringify({...t,...l}));return{meta:{"x-jsf-fieldsets":e["x-jsf-fieldsets"],"x-jsf-presentation":e["x-jsf-presentation"]},...F(e,{initialValues:y})}},"createHeadlessForm");export{O as a};
2
+ //# sourceMappingURL=chunk-7WB6IHRF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/common/createHeadlessForm.tsx"],"sourcesContent":["import { FieldValues } from 'react-hook-form';\nimport {\n createHeadlessForm as baseCreateHeadlessForm,\n modify,\n} from '@remoteoss/remote-json-schema-form-kit';\nimport { convertToCents } from '@/src/components/form/utils';\nimport {\n JSFModify,\n JSONSchemaFormResultWithFieldsets,\n} from '@/src/flows/types';\nimport { findFieldsByType } from '@/src/flows/utils';\nimport { JSFFieldset } from '@/src/types/remoteFlows';\n\n/*\n * Creates a headless form from a JSON Schema, useful to avoid code duplication when creating headless forms.\n * @param jsfSchema - The JSON Schema\n * @param fieldValues - The field values\n * @param options - The options\n * @returns The headless form\n */\nexport const createHeadlessForm = (\n jsfSchema: Record<string, unknown>,\n fieldValues?: FieldValues,\n options?: { jsfModify?: JSFModify },\n): JSONSchemaFormResultWithFieldsets => {\n if (options && options.jsfModify) {\n const { required, allOf, ...modifyConfig } = options.jsfModify;\n // muteLogging: true suppresses the generic library log; we surface the\n // actual warnings ourselves when present so they're actionable.\n const { schema, warnings } = modify(jsfSchema, {\n ...modifyConfig,\n muteLogging: true,\n } as Parameters<typeof modify>[1]);\n if (warnings && warnings.length > 0) {\n // eslint-disable-next-line no-console\n console.warn('jsfModify warnings:', warnings);\n }\n jsfSchema = schema;\n\n if (required) {\n const baseRequired = Array.isArray(schema.required)\n ? schema.required\n : [];\n\n if (typeof required === 'function') {\n // Function: allows full control over required fields\n jsfSchema.required = required(baseRequired);\n } else {\n // Array: merge with existing required fields (backwards compatible)\n jsfSchema.required = [...baseRequired, ...required];\n }\n }\n\n if (allOf) {\n jsfSchema.allOf = [\n ...(Array.isArray(schema.allOf) ? schema.allOf : []),\n ...allOf,\n ];\n }\n }\n\n let moneyFieldsData: Record<string, number | null> = {};\n\n if (fieldValues) {\n const moneyFields = findFieldsByType(jsfSchema.properties || {}, 'money');\n moneyFieldsData = moneyFields.reduce<Record<string, number | null>>(\n (acc, field) => {\n acc[field] = convertToCents(fieldValues[field]);\n return acc;\n },\n {},\n );\n }\n\n /**\n * We create a deep copy of the field values to avoid modifying the original object.\n * This problem is caused by json-schema-form-v0.\n */\n const initialValues = JSON.parse(\n JSON.stringify({\n ...fieldValues,\n ...moneyFieldsData,\n }),\n );\n\n return {\n meta: {\n 'x-jsf-fieldsets': jsfSchema['x-jsf-fieldsets'] as JSFFieldset,\n 'x-jsf-presentation': jsfSchema['x-jsf-presentation'] as\n | Record<string, unknown>\n | undefined,\n },\n ...baseCreateHeadlessForm(jsfSchema, {\n initialValues,\n }),\n };\n};\n"],"mappings":"mHACA,OACE,sBAAsBA,EACtB,UAAAC,MACK,yCAgBA,IAAMC,EAAqBC,EAAA,CAChCC,EACAC,EACAC,IACsC,CACtC,GAAIA,GAAWA,EAAQ,UAAW,CAChC,GAAM,CAAE,SAAAC,EAAU,MAAAC,EAAO,GAAGC,CAAa,EAAIH,EAAQ,UAG/C,CAAE,OAAAI,EAAQ,SAAAC,CAAS,EAAIC,EAAOR,EAAW,CAC7C,GAAGK,EACH,YAAa,EACf,CAAiC,EAOjC,GANIE,GAAYA,EAAS,OAAS,GAEhC,QAAQ,KAAK,sBAAuBA,CAAQ,EAE9CP,EAAYM,EAERH,EAAU,CACZ,IAAMM,EAAe,MAAM,QAAQH,EAAO,QAAQ,EAC9CA,EAAO,SACP,CAAC,EAED,OAAOH,GAAa,WAEtBH,EAAU,SAAWG,EAASM,CAAY,EAG1CT,EAAU,SAAW,CAAC,GAAGS,EAAc,GAAGN,CAAQ,CAEtD,CAEIC,IACFJ,EAAU,MAAQ,CAChB,GAAI,MAAM,QAAQM,EAAO,KAAK,EAAIA,EAAO,MAAQ,CAAC,EAClD,GAAGF,CACL,EAEJ,CAEA,IAAIM,EAAiD,CAAC,EAElDT,IAEFS,EADoBC,EAAiBX,EAAU,YAAc,CAAC,EAAG,OAAO,EAC1C,OAC5B,CAACY,EAAKC,KACJD,EAAIC,CAAK,EAAIC,EAAeb,EAAYY,CAAK,CAAC,EACvCD,GAET,CAAC,CACH,GAOF,IAAMG,EAAgB,KAAK,MACzB,KAAK,UAAU,CACb,GAAGd,EACH,GAAGS,CACL,CAAC,CACH,EAEA,MAAO,CACL,KAAM,CACJ,kBAAmBV,EAAU,iBAAiB,EAC9C,qBAAsBA,EAAU,oBAAoB,CAGtD,EACA,GAAGgB,EAAuBhB,EAAW,CACnC,cAAAe,CACF,CAAC,CACH,CACF,EA5EkC","names":["baseCreateHeadlessForm","modify","createHeadlessForm","__name","jsfSchema","fieldValues","options","required","allOf","modifyConfig","schema","warnings","modify","baseRequired","moneyFieldsData","findFieldsByType","acc","field","convertToCents","initialValues","baseCreateHeadlessForm"]}
@@ -1,2 +1,2 @@
1
- import{a as te}from"./chunk-BFXBFGBH.js";import{a as ne}from"./chunk-AP56UUME.js";import{a as ee}from"./chunk-IJCTN52C.js";import{e as M}from"./chunk-YPLIXSIP.js";import{a as I,b as oe,c as P,d as h,f as _,m as re}from"./chunk-PB6UQ4A4.js";import{a as X}from"./chunk-WVJDCDGZ.js";import{a as Z}from"./chunk-ID4S6FWD.js";import{a as b}from"./chunk-LKVQ32ZK.js";import{$,E as v,K as J,S as K,V as N,X as k,_ as G,aa as B,ba as W,ea as H,f as w,ga as Y,h as Q,ha as z,r as A,t as L,u as U,v as j}from"./chunk-BYDNNJHZ.js";import{b as O,g as E,t as V}from"./chunk-G2LZFGZA.js";import{e as a}from"./chunk-H2O4CVKF.js";import{a as n}from"./chunk-P37U34EQ.js";import{useMemo as le}from"react";import{useMutation as g,useQuery as d}from"@tanstack/react-query";import{useMutation as ge,useQuery as ie}from"@tanstack/react-query";var we=n(()=>{let{client:e}=a();return ge({mutationFn:n(t=>k({client:e,body:t,headers:{Authorization:""}}),"mutationFn")})},"useUploadFile"),se=n(e=>{let{client:t}=a();return ie({queryKey:["download-file",e],queryFn:n(async()=>{let o=await v({client:t,path:{id:e}});if(o.error)throw o.error;return o.data},"queryFn"),select:n(({data:o})=>o?.file,"select"),enabled:!!e})},"useDownloadFile"),ae=n((e,t,o)=>{let{client:r}=a();return ie({queryKey:["employment-files",e],queryFn:n(async()=>{let i=await N({client:r,path:{employment_id:e},query:t});if(i.error)throw i.error;return i.data},"queryFn"),...o})},"useEmploymentFiles");import{useQuery as Se}from"@tanstack/react-query";import{useQuery as Fe}from"@tanstack/react-query";var q=n(()=>{let{client:e}=a();return Fe({queryKey:["identity"],queryFn:n(()=>$({client:e,headers:{Authorization:""}}),"queryFn"),select:n(t=>t.data?.data,"select")})},"useIdentity");function R(e){return e!=null&&"company"in e}n(R,"hasCompany");var ce=n((e={enabled:!0})=>{let{data:t}=q(),o=R(t)?t?.company?.id??"":"",{client:r}=a();return Se({queryKey:["pricing-plans",o],queryFn:n(()=>w({client:r,path:{company_id:o}}),"queryFn"),select:n(i=>i.data?.data?.pricing_plans,"select"),enabled:!!e?.enabled&&!!o})},"useCompanyPricingPlans");var he=n(({employmentId:e,options:t})=>{let{client:o}=a();return d({queryKey:["contractor-currencies",e],queryFn:n(async()=>j({client:o,path:{employment_id:e},query:{restrict_to_guaranteed_pay_out_currencies:!1}}),"queryFn"),enabled:t?.queryOptions?.enabled,select:n(({data:r})=>r?.data,"select")})},"useContractorCurrencies"),qt=n(({fieldValues:e,options:t})=>d({queryKey:["contract-document-signature",e.review_completed,t?.jsfModify],queryFn:n(async()=>b(ee,e,{jsfModify:t?.jsfModify}),"queryFn"),enabled:t?.queryOptions?.enabled}),"useGetContractDocumentSignatureSchema"),Ot=n(()=>{let{client:e}=a();return g({mutationFn:n(async({employmentId:t,contractDocumentId:o,payload:r})=>G({client:e,body:r,path:{employment_id:t,contract_document_id:o}}),"mutationFn")})},"useSignContractDocument"),_e=n(({employmentId:e,contractDocumentId:t,options:o})=>{let{client:r}=a();return d({queryKey:["contract-document",e,t],queryFn:n(async()=>L({client:r,path:{employment_id:e,id:t}}),"queryFn"),enabled:o?.queryOptions?.enabled,select:n(({data:i})=>({...i?.data,contract_document:{...i?.data?.contract_document,content:V(i?.data?.contract_document?.content)}}),"select")})},"useGetShowContractDocument"),Et=n(({employmentId:e,contractDocumentId:t,options:o})=>{let{data:r}=_e({employmentId:e,contractDocumentId:t,options:{queryOptions:{enabled:o?.queryOptions?.enabled}}});return{hasCompanySignedContract:r?.contract_document?.signatories?.some(s=>s.type==="company"&&s.status==="signed")}},"useHasCompanySignedContract"),qe=n(({employmentId:e,options:t})=>{let{client:o}=a();return d({queryKey:["contractor-subscriptions",e],queryFn:n(async()=>A({client:o,path:{employment_id:e}}),"queryFn"),enabled:t?.queryOptions?.enabled,select:n(({data:r})=>r?.data,"select")})},"useGetContractorSubscriptions"),It=n(()=>{let{client:e}=a();return g({mutationFn:n(async({employmentId:t,payload:o})=>W({client:e,body:o,path:{employment_id:t}}),"mutationFn")})},"usePostManageContractorSubscriptions"),Pt=n(()=>{let{client:e}=a();return g({mutationFn:n(async({employmentId:t,payload:o})=>K({client:e,body:o,path:{employment_id:t}}),"mutationFn")})},"useCreateContractorContractDocument"),Oe=n(({countryCode:e,employmentId:t,fieldValues:o,options:r})=>{let{client:i}=a();return d({queryKey:["contractor-onboarding-details-schema",e,t],retry:!1,queryFn:n(async()=>Q({client:i,path:{country_code:e},query:{json_schema_version:1,employment_id:t}}),"queryFn"),enabled:r?.queryOptions?.enabled,select:n(({data:s})=>{let c=s?.data?.schema||{};return b(c,o,r)},"select")})},"useContractorOnboardingDetailsSchema"),Ee={[I]:"Contractor Management",[oe]:"Contractor Management Plus",[P]:"Contractor of Record"},Ie=n(e=>{let{data:t,isLoading:o}=ce({enabled:e?.enabled}),r=t?.find(s=>s.product.name==="EOR Monthly");return{eorSubscription:r?{product:{identifier:h,short_name:"EOR"},currency:r.price.currency,price:{amount:E(r.price.amount)},features:["Contract between Remote and employee","Remote manages onboarding, payroll, and compliance","Manages taxes, benefits, and time-off tracking","Handles contracts, transfers, and terminations"],description:"Enables hiring in countries without a local entity",label:"Employer of Record",value:h}:null,isLoading:o}},"useEorSubscription"),Pe=n((e,t,o)=>(t&&M(h,o)&&e.push({label:t.label,value:t.value,description:t.description,meta:{features:t.features,price:{amount:t.price.amount,currencyCode:t.currency?.code??""}},disabled:!1}),e),"addEorToFieldOptions"),Mt=n((e,t,o)=>{let{data:r,isLoading:i,refetch:s}=qe({employmentId:e,options:{queryOptions:o?.queryOptions}}),c=le(()=>r?.filter(u=>M(u.product.identifier??"",o?.excludeProducts))??[],[r,o?.excludeProducts]),F=r?r?.length<3:!1,m=r?.find(u=>u.product.identifier===P)?.eligibility_questionnaire?.is_blocking,f=(F||m)&&t?.eor_onboarding&&!o?.excludeProducts?.includes("eor"),{eorSubscription:T,isLoading:ue}=Ie({enabled:f}),de=c.length>0||f&&T!==null,x=b(ne.data.schema,{},{...o,jsfModify:{...o?.jsfModify,required:de?o?.jsfModify?.required:u=>u.filter(C=>C!=="subscription")}}),D=x.fields.find(u=>u.name==="subscription");if(D){let u=c.map(S=>{let l=S.product,me=S.price.amount,pe=S.currency.code,ye=Ee[l.identifier]??"",fe=l.identifier??"",Ce=l.description??"";l.description||console.error(`[Data Integrity] Missing description for product: ${l.identifier}`,{product:l});let be={features:l.features??re[l.identifier]??[],price:{amount:E(me),currencyCode:pe}};return{label:ye,value:fe,description:Ce,meta:be,disabled:m&&l.identifier!==I}});u.sort((S,l)=>S.label.localeCompare(l.label));let C=[];f&&(Pe(C,T,o?.excludeProducts),C.length>0&&(C[0].meta={...C[0].meta,groupSeparator:{show:!0}})),D.options=[...u,...C]}return{isLoading:i||ue,form:x,contractorSubscriptions:r,filteredContractorSubscriptions:c,refetch:s,isEligibilityQuestionnaireBlocked:m}},"useContractorSubscriptionSchemaField"),Rt=n((e,t,o)=>{let{mutateAsyncOrThrow:r}=O(t),{mutateAsyncOrThrow:i}=O(e);return{mutateAsync:n(async({employmentId:s})=>{let{nationality_status:c,ir35:p,ir35_sds_file:F}=o,y={contract_document:{ir_35:p}},m={contract_document:{nationality:c}};return p?(await i({employmentId:s,payload:y}),F?r({employment_id:s,file:F,sub_type:_}):Promise.resolve()):c?i({employmentId:s,payload:m}):Promise.resolve()},"mutateAsync")}},"useUpdateUKandSaudiFields"),Tt=n((e,t)=>{let{data:o,isLoading:r}=ae(e,{sub_type:_},{...t,select:n(({data:c})=>c?.files?.filter(p=>p.sub_type===_),"select")}),i=o?.[0]?.id,s=se(i);return{...s,isLoading:r||s.isLoading}},"useGetIR35File"),xt=n((e,t)=>{let{client:o}=a();return d({queryKey:["contract-documents",e],queryFn:n(async()=>U({client:o,path:{employment_id:e}}),"queryFn"),enabled:t?.enabled,select:n(({data:r})=>r?.data?.contract_documents,"select")})},"useGetContractDocuments"),Dt=n(({options:e,fieldValues:t})=>{let{client:o}=a();return d({queryKey:["eligibility-questionnaire"],queryFn:n(async()=>{let r=await B({client:o,query:{type:"contractor_of_record",json_schema_version:1}});if(r.error)throw new Error("Failed to fetch eligibility questionnaire");return r.data.data},"queryFn"),select:n(r=>{let i=r?.schema||{};return b(i,t,{jsfModify:e?.jsfModify})},"select"),enabled:e?.queryOptions?.enabled})},"useGetEligibilityQuestionnaire"),Vt=n(()=>{let{client:e}=a();return g({mutationFn:n(async({employmentId:t,payload:o})=>J({client:e,body:{employment_slug:t,responses:o,type:"contractor_of_record"},query:{json_schema_version:1}}),"mutationFn")})},"usePostCreateEligibilityQuestionnaire"),wt=n(()=>{let{client:e}=a();return g({mutationFn:n(async({employmentId:t})=>z({client:e,path:{employment_id:t}}),"mutationFn")})},"usePostManageContractorCorSubscription"),Qt=n(()=>{let{client:e}=a();return g({mutationFn:n(async({employmentId:t})=>Y({client:e,path:{employment_id:t}}),"mutationFn")})},"useDeleteContractorCorSubscription"),At=n(()=>{let{client:e}=a();return g({mutationFn:n(async({employmentId:t,contractOrigin:o,templateType:r})=>e.post({url:"/v1/employments/{employment_id}/contract-origin",path:{employment_id:t},body:{contract_origin:o,template_type:r},security:[{scheme:"bearer",type:"http"},{scheme:"bearer",type:"http"}]}),"mutationFn")})},"useSetContractOrigin"),Lt=n(({fieldValues:e,options:t})=>d({queryKey:["contract-origin-schema",t?.jsfModify],queryFn:n(async()=>b(te,e,{jsfModify:t?.jsfModify}),"queryFn"),enabled:t?.queryOptions?.enabled}),"useGetContractOriginSchema"),Ut=n(e=>{let{client:t}=a(),{data:o,isLoading:r}=d({...Z(t,"contractor-onboarding-countries"),select:n(s=>s.data?.data?.map(c=>({label:c.name,value:c.code,eor_onboarding:c.eor_onboarding,contractor_products_available:c.contractor_products_available}))||[],"select"),enabled:e?.queryOptions?.enabled}),i=b(X.data.schema,{},e);if(o){let s=i.fields.find(c=>c.name==="country");s&&(s.options=o)}return{isLoading:r,selectCountryForm:i,countries:o}},"useCountriesSchemaField"),jt=n(({countryCode:e,employmentId:t,fieldValues:o,options:r})=>{let i=Oe({countryCode:e,employmentId:t,fieldValues:o,options:r}),{data:s,isLoading:c}=he({employmentId:t,options:{queryOptions:{enabled:r?.queryOptions?.enabled}}}),p=le(()=>!i.data||!s?i.data:{...i.data,fields:i.data.fields.map(y=>y.name!=="payment_terms"?y:{...y,fields:y.fields?.map(m=>m.name!=="compensation_currency_code"?m:{...m,options:s.map(f=>({label:f.code,value:f.code,meta:{source:f.source}}))})})},[i.data,s]);return{...i,data:p,isLoading:i.isLoading||c}},"useContractorOnboardingDetailsSchemaWithCurrencies"),vt=n(({options:e}={})=>{let{data:t}=q(),o=R(t)?t?.company?.id??"":"",{client:r}=a();return d({queryKey:["company-open-tasks",o],queryFn:n(()=>H({client:r,path:{company_id:o}}),"queryFn"),select:n(({data:i})=>i?.data?.actions??[],"select"),enabled:(e?.queryOptions?.enabled??!0)&&!!o})},"useCompanyOpenTasks");export{we as a,q as b,R as c,qt as d,Ot as e,_e as f,Et as g,qe as h,It as i,Pt as j,Ee as k,Mt as l,Rt as m,Tt as n,xt as o,Dt as p,Vt as q,wt as r,Qt as s,At as t,Lt as u,Ut as v,jt as w,vt as x};
2
- //# sourceMappingURL=chunk-XGXXXWTH.js.map
1
+ import{a as te}from"./chunk-BFXBFGBH.js";import{a as ne}from"./chunk-AP56UUME.js";import{a as ee}from"./chunk-IJCTN52C.js";import{e as M}from"./chunk-E2463GRM.js";import{a as I,b as oe,c as P,d as h,f as _,m as re}from"./chunk-PB6UQ4A4.js";import{a as X}from"./chunk-WVJDCDGZ.js";import{a as Z}from"./chunk-ID4S6FWD.js";import{a as b}from"./chunk-7WB6IHRF.js";import{$,E as v,K as J,S as K,V as N,X as k,_ as G,aa as B,ba as W,ea as H,f as w,ga as Y,h as Q,ha as z,r as A,t as L,u as U,v as j}from"./chunk-BYDNNJHZ.js";import{b as O,g as E,t as V}from"./chunk-G2LZFGZA.js";import{e as a}from"./chunk-H2O4CVKF.js";import{a as n}from"./chunk-P37U34EQ.js";import{useMemo as le}from"react";import{useMutation as g,useQuery as d}from"@tanstack/react-query";import{useMutation as ge,useQuery as ie}from"@tanstack/react-query";var we=n(()=>{let{client:e}=a();return ge({mutationFn:n(t=>k({client:e,body:t,headers:{Authorization:""}}),"mutationFn")})},"useUploadFile"),se=n(e=>{let{client:t}=a();return ie({queryKey:["download-file",e],queryFn:n(async()=>{let o=await v({client:t,path:{id:e}});if(o.error)throw o.error;return o.data},"queryFn"),select:n(({data:o})=>o?.file,"select"),enabled:!!e})},"useDownloadFile"),ae=n((e,t,o)=>{let{client:r}=a();return ie({queryKey:["employment-files",e],queryFn:n(async()=>{let i=await N({client:r,path:{employment_id:e},query:t});if(i.error)throw i.error;return i.data},"queryFn"),...o})},"useEmploymentFiles");import{useQuery as Se}from"@tanstack/react-query";import{useQuery as Fe}from"@tanstack/react-query";var q=n(()=>{let{client:e}=a();return Fe({queryKey:["identity"],queryFn:n(()=>$({client:e,headers:{Authorization:""}}),"queryFn"),select:n(t=>t.data?.data,"select")})},"useIdentity");function R(e){return e!=null&&"company"in e}n(R,"hasCompany");var ce=n((e={enabled:!0})=>{let{data:t}=q(),o=R(t)?t?.company?.id??"":"",{client:r}=a();return Se({queryKey:["pricing-plans",o],queryFn:n(()=>w({client:r,path:{company_id:o}}),"queryFn"),select:n(i=>i.data?.data?.pricing_plans,"select"),enabled:!!e?.enabled&&!!o})},"useCompanyPricingPlans");var he=n(({employmentId:e,options:t})=>{let{client:o}=a();return d({queryKey:["contractor-currencies",e],queryFn:n(async()=>j({client:o,path:{employment_id:e},query:{restrict_to_guaranteed_pay_out_currencies:!1}}),"queryFn"),enabled:t?.queryOptions?.enabled,select:n(({data:r})=>r?.data,"select")})},"useContractorCurrencies"),qt=n(({fieldValues:e,options:t})=>d({queryKey:["contract-document-signature",e.review_completed,t?.jsfModify],queryFn:n(async()=>b(ee,e,{jsfModify:t?.jsfModify}),"queryFn"),enabled:t?.queryOptions?.enabled}),"useGetContractDocumentSignatureSchema"),Ot=n(()=>{let{client:e}=a();return g({mutationFn:n(async({employmentId:t,contractDocumentId:o,payload:r})=>G({client:e,body:r,path:{employment_id:t,contract_document_id:o}}),"mutationFn")})},"useSignContractDocument"),_e=n(({employmentId:e,contractDocumentId:t,options:o})=>{let{client:r}=a();return d({queryKey:["contract-document",e,t],queryFn:n(async()=>L({client:r,path:{employment_id:e,id:t}}),"queryFn"),enabled:o?.queryOptions?.enabled,select:n(({data:i})=>({...i?.data,contract_document:{...i?.data?.contract_document,content:V(i?.data?.contract_document?.content)}}),"select")})},"useGetShowContractDocument"),Et=n(({employmentId:e,contractDocumentId:t,options:o})=>{let{data:r}=_e({employmentId:e,contractDocumentId:t,options:{queryOptions:{enabled:o?.queryOptions?.enabled}}});return{hasCompanySignedContract:r?.contract_document?.signatories?.some(s=>s.type==="company"&&s.status==="signed")}},"useHasCompanySignedContract"),qe=n(({employmentId:e,options:t})=>{let{client:o}=a();return d({queryKey:["contractor-subscriptions",e],queryFn:n(async()=>A({client:o,path:{employment_id:e}}),"queryFn"),enabled:t?.queryOptions?.enabled,select:n(({data:r})=>r?.data,"select")})},"useGetContractorSubscriptions"),It=n(()=>{let{client:e}=a();return g({mutationFn:n(async({employmentId:t,payload:o})=>W({client:e,body:o,path:{employment_id:t}}),"mutationFn")})},"usePostManageContractorSubscriptions"),Pt=n(()=>{let{client:e}=a();return g({mutationFn:n(async({employmentId:t,payload:o})=>K({client:e,body:o,path:{employment_id:t}}),"mutationFn")})},"useCreateContractorContractDocument"),Oe=n(({countryCode:e,employmentId:t,fieldValues:o,options:r})=>{let{client:i}=a();return d({queryKey:["contractor-onboarding-details-schema",e,t],retry:!1,queryFn:n(async()=>Q({client:i,path:{country_code:e},query:{json_schema_version:1,employment_id:t}}),"queryFn"),enabled:r?.queryOptions?.enabled,select:n(({data:s})=>{let c=s?.data?.schema||{};return b(c,o,r)},"select")})},"useContractorOnboardingDetailsSchema"),Ee={[I]:"Contractor Management",[oe]:"Contractor Management Plus",[P]:"Contractor of Record"},Ie=n(e=>{let{data:t,isLoading:o}=ce({enabled:e?.enabled}),r=t?.find(s=>s.product.name==="EOR Monthly");return{eorSubscription:r?{product:{identifier:h,short_name:"EOR"},currency:r.price.currency,price:{amount:E(r.price.amount)},features:["Contract between Remote and employee","Remote manages onboarding, payroll, and compliance","Manages taxes, benefits, and time-off tracking","Handles contracts, transfers, and terminations"],description:"Enables hiring in countries without a local entity",label:"Employer of Record",value:h}:null,isLoading:o}},"useEorSubscription"),Pe=n((e,t,o)=>(t&&M(h,o)&&e.push({label:t.label,value:t.value,description:t.description,meta:{features:t.features,price:{amount:t.price.amount,currencyCode:t.currency?.code??""}},disabled:!1}),e),"addEorToFieldOptions"),Mt=n((e,t,o)=>{let{data:r,isLoading:i,refetch:s}=qe({employmentId:e,options:{queryOptions:o?.queryOptions}}),c=le(()=>r?.filter(u=>M(u.product.identifier??"",o?.excludeProducts))??[],[r,o?.excludeProducts]),F=r?r?.length<3:!1,m=r?.find(u=>u.product.identifier===P)?.eligibility_questionnaire?.is_blocking,f=(F||m)&&t?.eor_onboarding&&!o?.excludeProducts?.includes("eor"),{eorSubscription:T,isLoading:ue}=Ie({enabled:f}),de=c.length>0||f&&T!==null,x=b(ne.data.schema,{},{...o,jsfModify:{...o?.jsfModify,required:de?o?.jsfModify?.required:u=>u.filter(C=>C!=="subscription")}}),D=x.fields.find(u=>u.name==="subscription");if(D){let u=c.map(S=>{let l=S.product,me=S.price.amount,pe=S.currency.code,ye=Ee[l.identifier]??"",fe=l.identifier??"",Ce=l.description??"";l.description||console.error(`[Data Integrity] Missing description for product: ${l.identifier}`,{product:l});let be={features:l.features??re[l.identifier]??[],price:{amount:E(me),currencyCode:pe}};return{label:ye,value:fe,description:Ce,meta:be,disabled:m&&l.identifier!==I}});u.sort((S,l)=>S.label.localeCompare(l.label));let C=[];f&&(Pe(C,T,o?.excludeProducts),C.length>0&&(C[0].meta={...C[0].meta,groupSeparator:{show:!0}})),D.options=[...u,...C]}return{isLoading:i||ue,form:x,contractorSubscriptions:r,filteredContractorSubscriptions:c,refetch:s,isEligibilityQuestionnaireBlocked:m}},"useContractorSubscriptionSchemaField"),Rt=n((e,t,o)=>{let{mutateAsyncOrThrow:r}=O(t),{mutateAsyncOrThrow:i}=O(e);return{mutateAsync:n(async({employmentId:s})=>{let{nationality_status:c,ir35:p,ir35_sds_file:F}=o,y={contract_document:{ir_35:p}},m={contract_document:{nationality:c}};return p?(await i({employmentId:s,payload:y}),F?r({employment_id:s,file:F,sub_type:_}):Promise.resolve()):c?i({employmentId:s,payload:m}):Promise.resolve()},"mutateAsync")}},"useUpdateUKandSaudiFields"),Tt=n((e,t)=>{let{data:o,isLoading:r}=ae(e,{sub_type:_},{...t,select:n(({data:c})=>c?.files?.filter(p=>p.sub_type===_),"select")}),i=o?.[0]?.id,s=se(i);return{...s,isLoading:r||s.isLoading}},"useGetIR35File"),xt=n((e,t)=>{let{client:o}=a();return d({queryKey:["contract-documents",e],queryFn:n(async()=>U({client:o,path:{employment_id:e}}),"queryFn"),enabled:t?.enabled,select:n(({data:r})=>r?.data?.contract_documents,"select")})},"useGetContractDocuments"),Dt=n(({options:e,fieldValues:t})=>{let{client:o}=a();return d({queryKey:["eligibility-questionnaire"],queryFn:n(async()=>{let r=await B({client:o,query:{type:"contractor_of_record",json_schema_version:1}});if(r.error)throw new Error("Failed to fetch eligibility questionnaire");return r.data.data},"queryFn"),select:n(r=>{let i=r?.schema||{};return b(i,t,{jsfModify:e?.jsfModify})},"select"),enabled:e?.queryOptions?.enabled})},"useGetEligibilityQuestionnaire"),Vt=n(()=>{let{client:e}=a();return g({mutationFn:n(async({employmentId:t,payload:o})=>J({client:e,body:{employment_slug:t,responses:o,type:"contractor_of_record"},query:{json_schema_version:1}}),"mutationFn")})},"usePostCreateEligibilityQuestionnaire"),wt=n(()=>{let{client:e}=a();return g({mutationFn:n(async({employmentId:t})=>z({client:e,path:{employment_id:t}}),"mutationFn")})},"usePostManageContractorCorSubscription"),Qt=n(()=>{let{client:e}=a();return g({mutationFn:n(async({employmentId:t})=>Y({client:e,path:{employment_id:t}}),"mutationFn")})},"useDeleteContractorCorSubscription"),At=n(()=>{let{client:e}=a();return g({mutationFn:n(async({employmentId:t,contractOrigin:o,templateType:r})=>e.post({url:"/v1/employments/{employment_id}/contract-origin",path:{employment_id:t},body:{contract_origin:o,template_type:r},security:[{scheme:"bearer",type:"http"},{scheme:"bearer",type:"http"}]}),"mutationFn")})},"useSetContractOrigin"),Lt=n(({fieldValues:e,options:t})=>d({queryKey:["contract-origin-schema",t?.jsfModify],queryFn:n(async()=>b(te,e,{jsfModify:t?.jsfModify}),"queryFn"),enabled:t?.queryOptions?.enabled}),"useGetContractOriginSchema"),Ut=n(e=>{let{client:t}=a(),{data:o,isLoading:r}=d({...Z(t,"contractor-onboarding-countries"),select:n(s=>s.data?.data?.map(c=>({label:c.name,value:c.code,eor_onboarding:c.eor_onboarding,contractor_products_available:c.contractor_products_available}))||[],"select"),enabled:e?.queryOptions?.enabled}),i=b(X.data.schema,{},e);if(o){let s=i.fields.find(c=>c.name==="country");s&&(s.options=o)}return{isLoading:r,selectCountryForm:i,countries:o}},"useCountriesSchemaField"),jt=n(({countryCode:e,employmentId:t,fieldValues:o,options:r})=>{let i=Oe({countryCode:e,employmentId:t,fieldValues:o,options:r}),{data:s,isLoading:c}=he({employmentId:t,options:{queryOptions:{enabled:r?.queryOptions?.enabled}}}),p=le(()=>!i.data||!s?i.data:{...i.data,fields:i.data.fields.map(y=>y.name!=="payment_terms"?y:{...y,fields:y.fields?.map(m=>m.name!=="compensation_currency_code"?m:{...m,options:s.map(f=>({label:f.code,value:f.code,meta:{source:f.source}}))})})},[i.data,s]);return{...i,data:p,isLoading:i.isLoading||c}},"useContractorOnboardingDetailsSchemaWithCurrencies"),vt=n(({options:e}={})=>{let{data:t}=q(),o=R(t)?t?.company?.id??"":"",{client:r}=a();return d({queryKey:["company-open-tasks",o],queryFn:n(()=>H({client:r,path:{company_id:o}}),"queryFn"),select:n(({data:i})=>i?.data?.actions??[],"select"),enabled:(e?.queryOptions?.enabled??!0)&&!!o})},"useCompanyOpenTasks");export{we as a,q as b,R as c,qt as d,Ot as e,_e as f,Et as g,qe as h,It as i,Pt as j,Ee as k,Mt as l,Rt as m,Tt as n,xt as o,Dt as p,Vt as q,wt as r,Qt as s,At as t,Lt as u,Ut as v,jt as w,vt as x};
2
+ //# sourceMappingURL=chunk-ADXJUDVS.js.map
@@ -1,2 +1,2 @@
1
- import{a as d}from"./chunk-WIFDQWVX.js";import{a as c}from"./chunk-4QJUNKBR.js";import{b as s}from"./chunk-Q3ALCPJN.js";import{c as l}from"./chunk-YPLIXSIP.js";import{x as n}from"./chunk-G2LZFGZA.js";import{a}from"./chunk-P37U34EQ.js";import{jsx as m,jsxs as g}from"react/jsx-runtime";function x({onSubmit:p,onSuccess:u,onError:S}){let{contractorOnboardingBag:r}=s(),f=a(async(e,F)=>{try{let t=await r.parseFormValues(e);await p?.(t);let o=await r.onSubmit(e);if(o?.data){await u?.(o?.data),r?.next();return}}catch(t){let o=n(t,r.meta?.fields?.contract_details,F);S?.(o)}},"handleSubmit"),C=r.stepState.values?.contract_details||r.initialValues.contract_details,i=r.stepState.values?.pricing_plan?.subscription,b=l(i);return g("div",{className:"space-y-4",children:[m(c,{defaultValues:C,onSubmit:f}),b&&m(d,{subscription:i})]})}a(x,"ContractDetailsStep");export{x as a};
2
- //# sourceMappingURL=chunk-QKSYPFRB.js.map
1
+ import{a as d}from"./chunk-WIFDQWVX.js";import{a as c}from"./chunk-4QJUNKBR.js";import{b as s}from"./chunk-Q3ALCPJN.js";import{c as l}from"./chunk-E2463GRM.js";import{x as n}from"./chunk-G2LZFGZA.js";import{a}from"./chunk-P37U34EQ.js";import{jsx as m,jsxs as g}from"react/jsx-runtime";function x({onSubmit:p,onSuccess:u,onError:S}){let{contractorOnboardingBag:r}=s(),f=a(async(e,F)=>{try{let t=await r.parseFormValues(e);await p?.(t);let o=await r.onSubmit(e);if(o?.data){await u?.(o?.data),r?.next();return}}catch(t){let o=n(t,r.meta?.fields?.contract_details,F);S?.(o)}},"handleSubmit"),C=r.stepState.values?.contract_details||r.initialValues.contract_details,i=r.stepState.values?.pricing_plan?.subscription,b=l(i);return g("div",{className:"space-y-4",children:[m(c,{defaultValues:C,onSubmit:f}),b&&m(d,{subscription:i})]})}a(x,"ContractDetailsStep");export{x as a};
2
+ //# sourceMappingURL=chunk-BSOKKYGH.js.map
@@ -1,2 +1,2 @@
1
- import{a as d,b as w}from"./chunk-WMBHCIFS.js";import{a as g}from"./chunk-GNDFT5KG.js";import{a as E}from"./chunk-LKVQ32ZK.js";import{C as P,U as F,e as _}from"./chunk-BYDNNJHZ.js";import{b as h,h as C}from"./chunk-G2LZFGZA.js";import{a as j}from"./chunk-JDIKYCN6.js";import{e as c}from"./chunk-H2O4CVKF.js";import{a as e}from"./chunk-P37U34EQ.js";import{useMutation as b,useQuery as I}from"@tanstack/react-query";var B=e(({countryCode:n,employment:r,fieldValues:a,options:t})=>{let{client:u}=c(),m=t?.jsonSchemaVersion?.contract_amendments?{json_schema_version:t.jsonSchemaVersion.contract_amendments}:{};return I({queryKey:["contract-amendment-schema"],retry:!1,queryFn:e(async()=>{let o=await _({client:u,headers:{Authorization:""},query:{employment_id:r?.id,country_code:n,...m}});if(o.error||!o.data)throw new Error("Failed to fetch contract amendment schema");return o},"queryFn"),enabled:!!r,select:e(({data:o})=>{let l=o?.data||{};return E(l,a,t)},"select")})},"useContractAmendmentSchemaQuery"),J=e(n=>{let{client:r}=c(),a=n?.jsonSchemaVersion?.contract_amendments?{json_schema_version:n.jsonSchemaVersion.contract_amendments}:{};return b({mutationFn:e(t=>P({client:r,headers:{Authorization:""},body:t,query:{...a}}),"mutationFn")})},"useCreateContractAmendmentMutation"),K=e(n=>{let{client:r}=c(),a=n?.jsonSchemaVersion?.contract_amendments?{json_schema_version:n.jsonSchemaVersion.contract_amendments}:{};return b({mutationFn:e(t=>F({client:r,headers:{Authorization:""},body:t,query:{...a}}),"mutationFn")})},"useAutomatableContractAmendmentMutation"),te=e(({employmentId:n,countryCode:r,options:a})=>{let{fieldValues:t,setFieldValues:u,stepState:m,nextStep:o,previousStep:l}=j(d),{data:i,isLoading:v,isError:q,error:Q}=g({employmentId:n,queryParams:{exclude_files:!0}}),{data:s,isLoading:L,isError:M,error:T}=B({employment:i,countryCode:r,fieldValues:{...m.values?.[m.currentStep.name],...t},options:a}),k=w(i,s?.fields),S=J(a),A=K(a);async function x(p){let f=await C(p,s?.fields||[],{isPartialValidation:!1}),V={employment_id:i?.id,amendment_contract_id:i?.active_contract_id,contract_amendment:{...f}};switch(m.currentStep.name){case d.form.name:{let{mutateAsync:y}=h(A),H=await y(V);return o(),H}case d.confirmation_form.name:{let{mutateAsync:y}=h(S);return y(V)}default:throw new Error("Invalid step state")}}e(x,"onSubmit");async function z(p){if(s){let f=await C(p,s?.fields);return s?.handleValidation(f)}return null}e(z,"handleValidation");function O(){l()}return e(O,"back"),{stepState:m,fields:s?.fields||[],isLoading:v||L,isError:q||M,error:Q||T,isSubmitting:A.isPending||S.isPending,initialValues:k,values:t,handleValidation:z,checkFieldUpdates:u,onSubmit:x,back:O}},"useContractAmendment");export{te as a};
2
- //# sourceMappingURL=chunk-T7QVVLKT.js.map
1
+ import{a as d,b as w}from"./chunk-WMBHCIFS.js";import{a as g}from"./chunk-GNDFT5KG.js";import{a as E}from"./chunk-7WB6IHRF.js";import{C as P,U as F,e as _}from"./chunk-BYDNNJHZ.js";import{b as h,h as C}from"./chunk-G2LZFGZA.js";import{a as j}from"./chunk-JDIKYCN6.js";import{e as c}from"./chunk-H2O4CVKF.js";import{a as e}from"./chunk-P37U34EQ.js";import{useMutation as b,useQuery as I}from"@tanstack/react-query";var B=e(({countryCode:n,employment:r,fieldValues:a,options:t})=>{let{client:u}=c(),m=t?.jsonSchemaVersion?.contract_amendments?{json_schema_version:t.jsonSchemaVersion.contract_amendments}:{};return I({queryKey:["contract-amendment-schema"],retry:!1,queryFn:e(async()=>{let o=await _({client:u,headers:{Authorization:""},query:{employment_id:r?.id,country_code:n,...m}});if(o.error||!o.data)throw new Error("Failed to fetch contract amendment schema");return o},"queryFn"),enabled:!!r,select:e(({data:o})=>{let l=o?.data||{};return E(l,a,t)},"select")})},"useContractAmendmentSchemaQuery"),J=e(n=>{let{client:r}=c(),a=n?.jsonSchemaVersion?.contract_amendments?{json_schema_version:n.jsonSchemaVersion.contract_amendments}:{};return b({mutationFn:e(t=>P({client:r,headers:{Authorization:""},body:t,query:{...a}}),"mutationFn")})},"useCreateContractAmendmentMutation"),K=e(n=>{let{client:r}=c(),a=n?.jsonSchemaVersion?.contract_amendments?{json_schema_version:n.jsonSchemaVersion.contract_amendments}:{};return b({mutationFn:e(t=>F({client:r,headers:{Authorization:""},body:t,query:{...a}}),"mutationFn")})},"useAutomatableContractAmendmentMutation"),te=e(({employmentId:n,countryCode:r,options:a})=>{let{fieldValues:t,setFieldValues:u,stepState:m,nextStep:o,previousStep:l}=j(d),{data:i,isLoading:v,isError:q,error:Q}=g({employmentId:n,queryParams:{exclude_files:!0}}),{data:s,isLoading:L,isError:M,error:T}=B({employment:i,countryCode:r,fieldValues:{...m.values?.[m.currentStep.name],...t},options:a}),k=w(i,s?.fields),S=J(a),A=K(a);async function x(p){let f=await C(p,s?.fields||[],{isPartialValidation:!1}),V={employment_id:i?.id,amendment_contract_id:i?.active_contract_id,contract_amendment:{...f}};switch(m.currentStep.name){case d.form.name:{let{mutateAsync:y}=h(A),H=await y(V);return o(),H}case d.confirmation_form.name:{let{mutateAsync:y}=h(S);return y(V)}default:throw new Error("Invalid step state")}}e(x,"onSubmit");async function z(p){if(s){let f=await C(p,s?.fields);return s?.handleValidation(f)}return null}e(z,"handleValidation");function O(){l()}return e(O,"back"),{stepState:m,fields:s?.fields||[],isLoading:v||L,isError:q||M,error:Q||T,isSubmitting:A.isPending||S.isPending,initialValues:k,values:t,handleValidation:z,checkFieldUpdates:u,onSubmit:x,back:O}},"useContractAmendment");export{te as a};
2
+ //# sourceMappingURL=chunk-CFGQQEXD.js.map
@@ -0,0 +1,2 @@
1
+ import{a as P,b as k,c as N}from"./chunk-3B6BHFDV.js";import{a as C}from"./chunk-OPDKYPYM.js";import{a as u,b as F}from"./chunk-T5J2Z6ZR.js";import{j as v,k as x,l as b,n as D,o as w}from"./chunk-Y3CJRZLA.js";import{n as a}from"./chunk-G2LZFGZA.js";import{a as n}from"./chunk-P37U34EQ.js";import{CalendarIcon as T}from"lucide-react";import{format as Y}from"date-fns";import{ChevronLeft as O,ChevronRight as V}from"lucide-react";import{DayPicker as B}from"react-day-picker";import{jsx as p}from"react/jsx-runtime";function R({className:t,classNames:m,showOutsideDays:c=!0,...r}){return p(B,{showOutsideDays:c,className:a("p-3",t),classNames:{months:"flex flex-col sm:flex-row gap-2",month:"flex flex-col gap-4",caption:"flex justify-center pt-1 relative items-center w-full",caption_label:"text-sm font-medium",nav:"flex items-center gap-1",nav_button:a(u({variant:"outline"}),"size-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-x-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:a("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md",r.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:a(u({variant:"ghost"}),"size-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground",day_range_end:"day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...m},components:{IconLeft:n(({className:l,...o})=>p(O,{className:a("size-4",l),...o}),"IconLeft"),IconRight:n(({className:l,...o})=>p(V,{className:a("size-4",l),...o}),"IconRight")},...r})}n(R,"Calendar");import{useState as $}from"react";import{Fragment as E,jsx as e,jsxs as f}from"react/jsx-runtime";function re({field:t,fieldData:m,fieldState:c}){let{name:r,label:l,description:o,minDate:g,maxDate:y}=m,d=g?new Date(g):void 0,i=y?new Date(y):void 0,[M,_]=$(!1),I=new Date().getFullYear(),h=d?d.getFullYear():1900,L=Math.max(h,i?i.getFullYear():I+10);return f(v,{"data-field":r,className:`flex flex-col RemoteFlows__DatePickerField__Item__${r}`,children:[e(x,{className:"RemoteFlows__DatePickerField__Label",children:l}),f(P,{open:M,onOpenChange:_,children:[e(k,{asChild:!0,children:e(b,{children:e("div",{children:f(F,{type:"button",variant:"outline",className:a("w-full pl-3 text-left font-normal",!t.value&&"text-muted-foreground"),"data-testid":`date-picker-button-${r}`,children:[t.value&&e(E,{children:Y(t.value,"yyyy-MM-dd")}),e(T,{className:"ml-auto h-4 w-4 opacity-50"})]})})})}),e(N,{className:"w-auto p-0 RemoteFlows__DatepickerField__PopoverContent",align:"start",children:e(R,{mode:"single",captionLayout:"dropdown",fromYear:h,toYear:L,className:"RemoteFlows__DatepickerField__Calendar",selected:t.value?new Date(t.value):void 0,onDayClick:s=>{let z=Y(s,"yyyy-MM-dd");t.onChange(z),_(!1)},defaultMonth:t.value?new Date(t.value):i??d,disabled:s=>!!(d&&s<d||i&&s>i)})})]}),o?e(D,{helpCenter:e(C,{helpCenter:m.meta?.helpCenter}),children:o}):null,c.error&&e(w,{className:"RemoteFlows__DatePickerField__Error"})]})}n(re,"DatePickerFieldDefault");export{re as a};
2
+ //# sourceMappingURL=chunk-DAFIBCX4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/form/fields/default/DatePickerFieldDefault.tsx","../src/components/ui/calendar.tsx"],"sourcesContent":["import { Button } from '@/src/components/ui/button';\nimport {\n FormControl,\n FormDescription,\n FormItem,\n FormLabel,\n FormMessage,\n} from '@/src/components/ui/form';\nimport { DatePickerComponentProps } from '@/src/types/fields';\nimport { CalendarIcon } from 'lucide-react';\nimport { format } from 'date-fns';\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from '@/src/components/ui/popover';\nimport { cn } from '@/src/lib/utils';\nimport { Calendar } from '@/src/components/ui/calendar';\nimport { HelpCenter } from '@/src/components/shared/zendesk-drawer/HelpCenter';\nimport { useState } from 'react';\n\nexport function DatePickerFieldDefault({\n field,\n fieldData,\n fieldState,\n}: DatePickerComponentProps) {\n const { name, label, description, minDate, maxDate } = fieldData;\n const minDateValue = minDate ? new Date(minDate) : undefined;\n const maxDateValue = maxDate ? new Date(maxDate) : undefined;\n const [open, setOpen] = useState(false);\n\n const currentYear = new Date().getFullYear();\n const fromYear = minDateValue ? minDateValue.getFullYear() : 1900;\n const toYear = Math.max(\n fromYear,\n maxDateValue ? maxDateValue.getFullYear() : currentYear + 10,\n );\n\n return (\n <FormItem\n data-field={name}\n className={`flex flex-col RemoteFlows__DatePickerField__Item__${name}`}\n >\n <FormLabel className='RemoteFlows__DatePickerField__Label'>\n {label}\n </FormLabel>\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <FormControl>\n <div>\n <Button\n type='button'\n variant={'outline'}\n className={cn(\n 'w-full pl-3 text-left font-normal',\n !field.value && 'text-muted-foreground',\n )}\n data-testid={`date-picker-button-${name}`}\n >\n {field.value && <>{format(field.value, 'yyyy-MM-dd')}</>}\n <CalendarIcon className='ml-auto h-4 w-4 opacity-50' />\n </Button>\n </div>\n </FormControl>\n </PopoverTrigger>\n <PopoverContent\n className={`w-auto p-0 RemoteFlows__DatepickerField__PopoverContent`}\n align='start'\n >\n <Calendar\n mode='single'\n captionLayout='dropdown'\n fromYear={fromYear}\n toYear={toYear}\n className='RemoteFlows__DatepickerField__Calendar'\n selected={field.value ? new Date(field.value) : undefined}\n onDayClick={(day) => {\n const formattedDate = format(day, 'yyyy-MM-dd');\n field.onChange(formattedDate);\n setOpen(false);\n }}\n defaultMonth={\n field.value\n ? new Date(field.value)\n : (maxDateValue ?? minDateValue)\n }\n disabled={(date: Date) => {\n if (minDateValue && date < minDateValue) return true;\n if (maxDateValue && date > maxDateValue) return true;\n return false;\n }}\n />\n </PopoverContent>\n </Popover>\n {description ? (\n <FormDescription\n helpCenter={<HelpCenter helpCenter={fieldData.meta?.helpCenter} />}\n >\n {description}\n </FormDescription>\n ) : null}\n {fieldState.error && (\n <FormMessage className='RemoteFlows__DatePickerField__Error' />\n )}\n </FormItem>\n );\n}\n","import * as React from 'react';\nimport { ChevronLeft, ChevronRight } from 'lucide-react';\nimport { DayPicker } from 'react-day-picker';\n\nimport { cn } from '@/src/lib/utils';\nimport { buttonVariants } from '@/src/components/ui/button';\n\nfunction Calendar({\n className,\n classNames,\n showOutsideDays = true,\n ...props\n}: React.ComponentProps<typeof DayPicker>) {\n return (\n <DayPicker\n showOutsideDays={showOutsideDays}\n className={cn('p-3', className)}\n classNames={{\n months: 'flex flex-col sm:flex-row gap-2',\n month: 'flex flex-col gap-4',\n caption: 'flex justify-center pt-1 relative items-center w-full',\n caption_label: 'text-sm font-medium',\n nav: 'flex items-center gap-1',\n nav_button: cn(\n buttonVariants({ variant: 'outline' }),\n 'size-7 bg-transparent p-0 opacity-50 hover:opacity-100',\n ),\n nav_button_previous: 'absolute left-1',\n nav_button_next: 'absolute right-1',\n table: 'w-full border-collapse space-x-1',\n head_row: 'flex',\n head_cell:\n 'text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]',\n row: 'flex w-full mt-2',\n cell: cn(\n 'relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md',\n props.mode === 'range'\n ? '[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md'\n : '[&:has([aria-selected])]:rounded-md',\n ),\n day: cn(\n buttonVariants({ variant: 'ghost' }),\n 'size-8 p-0 font-normal aria-selected:opacity-100',\n ),\n day_range_start:\n 'day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground',\n day_range_end:\n 'day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground',\n day_selected:\n 'bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground',\n day_today: 'bg-accent text-accent-foreground',\n day_outside:\n 'day-outside text-muted-foreground aria-selected:text-muted-foreground',\n day_disabled: 'text-muted-foreground opacity-50',\n day_range_middle:\n 'aria-selected:bg-accent aria-selected:text-accent-foreground',\n day_hidden: 'invisible',\n ...classNames,\n }}\n components={{\n IconLeft: ({ className, ...props }) => (\n <ChevronLeft className={cn('size-4', className)} {...props} />\n ),\n IconRight: ({ className, ...props }) => (\n <ChevronRight className={cn('size-4', className)} {...props} />\n ),\n }}\n {...props}\n />\n );\n}\n\nexport { Calendar };\n"],"mappings":"iSASA,OAAS,gBAAAA,MAAoB,eAC7B,OAAS,UAAAC,MAAc,WCTvB,OAAS,eAAAC,EAAa,gBAAAC,MAAoB,eAC1C,OAAS,aAAAC,MAAiB,mBA2DhB,cAAAC,MAAA,oBAtDV,SAASC,EAAS,CAChB,UAAAC,EACA,WAAAC,EACA,gBAAAC,EAAkB,GAClB,GAAGC,CACL,EAA2C,CACzC,OACEL,EAACM,EAAA,CACC,gBAAiBF,EACjB,UAAWG,EAAG,MAAOL,CAAS,EAC9B,WAAY,CACV,OAAQ,kCACR,MAAO,sBACP,QAAS,wDACT,cAAe,sBACf,I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icker","jsx","Calendar","className","classNames","showOutsideDays","props","DayPicker","cn","buttonVariants","__name","ChevronLeft","ChevronRight","useState","Fragment","jsx","jsxs","DatePickerFieldDefault","field","fieldData","fieldState","name","label","description","minDate","maxDate","minDateValue","maxDateValue","open","setOpen","useState","currentYear","fromYear","toYear","FormItem","FormLabel","Popover","PopoverTrigger","FormControl","Button","cn","format","CalendarIcon","PopoverContent","Calendar","day","formattedDate","date","FormDescription","HelpCenter","FormMessage","__name"]}
@@ -1,2 +1,2 @@
1
- import{a as y}from"./chunk-C332PSLT.js";import{a as l,c as m}from"./chunk-RFVHV6RE.js";import{c}from"./chunk-Y3CJRZLA.js";import{a as t}from"./chunk-P37U34EQ.js";import{useEffect as N}from"react";import{Fragment as b,jsx as v,jsxs as C}from"react/jsx-runtime";var R=t(({currencies:{from:d,to:F},shouldSwapOrder:s,salary_conversion_properties:a,conversionType:_="no_spread",defaultValue:r,...e})=>{let{setValue:n,getValues:i}=c(),f={label:a?.label||"Salary conversion",description:a?.description||C(b,{children:["The conversion is based on the Remote FX rate."," ",v(m,{className:"text-sm",zendeskId:l.remoteFxRate,children:"Learn more \u2197"})]})},g=s?"salary_conversion":e.name,u=s?e.name:"salary_conversion";return N(()=>{if(s){let o=i(e.name);o?(n("salary_conversion",o),n("salary_converted","salary_conversion")):r&&(n("salary_conversion",r),n("salary_converted","salary_conversion"))}else{let o=i("salary_conversion");o?(n(e.name,o),n("salary_converted",e.name)):r&&(n(e.name,r),n("salary_converted",e.name))}},[s,r,n,i,e.name]),v(y,{...e,sourceCurrency:d,targetCurrency:F,mainFieldName:g,conversionFieldName:u,conversionProperties:f,classNamePrefix:"RemoteFlows-Salary",conversionType:_})},"SalaryField");export{R as a};
2
- //# sourceMappingURL=chunk-GR6QMP4Z.js.map
1
+ import{a as y}from"./chunk-YCP65XIN.js";import{a as l,c as m}from"./chunk-RFVHV6RE.js";import{c}from"./chunk-Y3CJRZLA.js";import{a as t}from"./chunk-P37U34EQ.js";import{useEffect as N}from"react";import{Fragment as b,jsx as v,jsxs as C}from"react/jsx-runtime";var R=t(({currencies:{from:d,to:F},shouldSwapOrder:s,salary_conversion_properties:a,conversionType:_="no_spread",defaultValue:r,...e})=>{let{setValue:n,getValues:i}=c(),f={label:a?.label||"Salary conversion",description:a?.description||C(b,{children:["The conversion is based on the Remote FX rate."," ",v(m,{className:"text-sm",zendeskId:l.remoteFxRate,children:"Learn more \u2197"})]})},g=s?"salary_conversion":e.name,u=s?e.name:"salary_conversion";return N(()=>{if(s){let o=i(e.name);o?(n("salary_conversion",o),n("salary_converted","salary_conversion")):r&&(n("salary_conversion",r),n("salary_converted","salary_conversion"))}else{let o=i("salary_conversion");o?(n(e.name,o),n("salary_converted",e.name)):r&&(n(e.name,r),n("salary_converted",e.name))}},[s,r,n,i,e.name]),v(y,{...e,sourceCurrency:d,targetCurrency:F,mainFieldName:g,conversionFieldName:u,conversionProperties:f,classNamePrefix:"RemoteFlows-Salary",conversionType:_})},"SalaryField");export{R as a};
2
+ //# sourceMappingURL=chunk-DSL5O7NR.js.map
@@ -1,2 +1,2 @@
1
- import{a,b as l,e as s,h as c,i as d}from"./chunk-PB6UQ4A4.js";import{a as n}from"./chunk-P37U34EQ.js";function _(e={}){let o=[{name:"select_country",label:"Select Country",visible:!!e?.includeSelectCountry},{name:"basic_information",label:"Basic Information",visible:!0},{name:"pricing_plan",label:"Pricing Plan",visible:!0},{name:"contract_origin",label:"Contract Options",visible:!!(e?.includeContractOrigin??!0)},{name:"eligibility_questionnaire",label:"Eligibility Questionnaire",visible:!!e?.includeEligibilityQuestionnaire},{name:"contract_details",label:"Contract Details",visible:!!(e?.includeContractDetails??!0)},{name:"contract_preview",label:"Contract Preview",visible:!!e?.includeContractPreview},{name:"review",label:"Review",visible:!0}].map((i,r)=>({name:i.name,index:r,label:i.label,visible:i.visible}));return{steps:o.reduce((i,r)=>(i[r.name]={index:r.index,name:r.name,visible:r.visible},i),{}),stepsArray:o}}n(_,"buildSteps");var E=n((e,t)=>{if(e&&t&&e!==t)return`When the contractor will start providing service to your company. ${`This date does not match the date you provided in the Basic Information step - ${e} - and will override it only when both parties have signed the contract.`}`},"calculateProvisionalStartDateDescription"),v=n(e=>e===a||e===l,"isCMOrCMPlus"),p=["SAU","KWT","OMN","QAT","BHR"],g=n(e=>p.includes(e),"isNationalityCountryCode"),y=n((e,t)=>!t||t.length===0?!0:!t.some(o=>s[o]===e),"shouldIncludeProduct"),S=["initiated","invited","created_awaiting_reserve","created_reserve_paid","active"],C=["initiated","created_awaiting_reserve","invited","active"];function R(e){return e?d:c}n(R,"transformAiErrorResponse");export{_ as a,E as b,v as c,g as d,y as e,S as f,C as g,R as h};
2
- //# sourceMappingURL=chunk-YPLIXSIP.js.map
1
+ import{a,b as l,e as s,h as c,i as d}from"./chunk-PB6UQ4A4.js";import{a as n}from"./chunk-P37U34EQ.js";function _(e={}){let o=[{name:"select_country",label:"Select Country",visible:!!e?.includeSelectCountry},{name:"basic_information",label:"Basic Information",visible:!0},{name:"pricing_plan",label:"Pricing Plan",visible:!0},{name:"eligibility_questionnaire",label:"Eligibility Questionnaire",visible:!!e?.includeEligibilityQuestionnaire},{name:"contract_origin",label:"Contract Options",visible:!!(e?.includeContractOrigin??!0)},{name:"contract_details",label:"Contract Details",visible:!!(e?.includeContractDetails??!0)},{name:"contract_preview",label:"Contract Preview",visible:!!e?.includeContractPreview},{name:"review",label:"Review",visible:!0}].map((i,r)=>({name:i.name,index:r,label:i.label,visible:i.visible}));return{steps:o.reduce((i,r)=>(i[r.name]={index:r.index,name:r.name,visible:r.visible},i),{}),stepsArray:o}}n(_,"buildSteps");var E=n((e,t)=>{if(e&&t&&e!==t)return`When the contractor will start providing service to your company. ${`This date does not match the date you provided in the Basic Information step - ${e} - and will override it only when both parties have signed the contract.`}`},"calculateProvisionalStartDateDescription"),v=n(e=>e===a||e===l,"isCMOrCMPlus"),p=["SAU","KWT","OMN","QAT","BHR"],g=n(e=>p.includes(e),"isNationalityCountryCode"),y=n((e,t)=>!t||t.length===0?!0:!t.some(o=>s[o]===e),"shouldIncludeProduct"),S=["initiated","invited","created_awaiting_reserve","created_reserve_paid","active"],C=["initiated","created_awaiting_reserve","invited","active"];function R(e){return e?d:c}n(R,"transformAiErrorResponse");export{_ as a,E as b,v as c,g as d,y as e,S as f,C as g,R as h};
2
+ //# sourceMappingURL=chunk-E2463GRM.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/flows/ContractorOnboarding/utils.ts"],"sourcesContent":["import { Step } from '@/src/flows/useStepState';\nimport {\n contractorStandardProductIdentifier,\n contractorPlusProductIdentifier,\n ProductType,\n PRODUCT_IDENTIFIER_MAP,\n REMOTE_AI_SERVICES_AND_DELIVERABLES_ERROR_MESSAGE,\n REMOTE_AI_SERVICES_AND_DELIVERABLES_COR_ERROR_MESSAGE,\n} from '@/src/flows/ContractorOnboarding/constants';\nimport { Employment } from '@/src/flows/Onboarding/types';\n\nexport type StepKeys =\n | 'select_country'\n | 'basic_information'\n | 'contract_origin'\n | 'contract_details'\n | 'eligibility_questionnaire'\n | 'contract_preview'\n | 'pricing_plan'\n | 'review';\n\ntype StepConfig = {\n includeSelectCountry?: boolean;\n includeContractOrigin?: boolean;\n includeEligibilityQuestionnaire?: boolean;\n includeContractDetails?: boolean;\n includeContractPreview?: boolean;\n};\n\nexport function buildSteps(config: StepConfig = {}) {\n const stepDefinitions: Array<{\n name: StepKeys;\n label: string;\n visible: boolean;\n }> = [\n {\n name: 'select_country',\n label: 'Select Country',\n visible: Boolean(config?.includeSelectCountry),\n },\n {\n name: 'basic_information',\n label: 'Basic Information',\n visible: true,\n },\n {\n name: 'pricing_plan',\n label: 'Pricing Plan',\n visible: true,\n },\n {\n name: 'contract_origin',\n label: 'Contract Options',\n visible: Boolean(config?.includeContractOrigin ?? true),\n },\n {\n name: 'eligibility_questionnaire',\n label: 'Eligibility Questionnaire',\n visible: Boolean(config?.includeEligibilityQuestionnaire),\n },\n {\n name: 'contract_details',\n label: 'Contract Details',\n visible: Boolean(config?.includeContractDetails ?? true),\n },\n {\n name: 'contract_preview',\n label: 'Contract Preview',\n visible: Boolean(config?.includeContractPreview),\n },\n {\n name: 'review',\n label: 'Review',\n visible: true,\n },\n ];\n\n const stepsArray = stepDefinitions.map((step, index) => ({\n name: step.name,\n index,\n label: step.label,\n visible: step.visible,\n }));\n\n const steps = stepsArray.reduce(\n (acc, step) => {\n acc[step.name] = {\n index: step.index,\n name: step.name,\n visible: step.visible,\n };\n return acc;\n },\n {} as Record<string, Step<StepKeys>>,\n );\n\n return { steps, stepsArray };\n}\n\n/**\n * Calculates the description for the provisional start date field\n * based on whether the dates match between basic information and contract details steps\n */\nexport const calculateProvisionalStartDateDescription = (\n employmentProvisionalStartDate: string | undefined,\n fieldProvisionalStartDate: string | undefined,\n): string | undefined => {\n const datesNotMatching =\n employmentProvisionalStartDate &&\n fieldProvisionalStartDate &&\n employmentProvisionalStartDate !== fieldProvisionalStartDate;\n\n if (datesNotMatching) {\n const datesDontMatchWarning = `This date does not match the date you provided in the Basic Information step - ${\n employmentProvisionalStartDate\n } - and will override it only when both parties have signed the contract.`;\n return `When the contractor will start providing service to your company. ${datesDontMatchWarning}`;\n }\n return undefined;\n};\n\n/**\n * Checks if the selected pricing plan is CM (standard) or CM+ (plus)\n */\nexport const isCMOrCMPlus = (subscription: string | undefined): boolean => {\n return (\n subscription === contractorStandardProductIdentifier ||\n subscription === contractorPlusProductIdentifier\n );\n};\n\nconst NATIONALITY_COUNTRY_CODES = ['SAU', 'KWT', 'OMN', 'QAT', 'BHR'];\n\n/**\n * Checks if the country code is a country code that requires nationality status field\n */\nexport const isNationalityCountryCode = (countryCode: string) => {\n return NATIONALITY_COUNTRY_CODES.includes(countryCode);\n};\n\n/**\n * Checks if a product should be included based on the excludeProducts list\n * @param productIdentifier - The product identifier to check\n * @param excludeProducts - Array of products to exclude\n * @returns true if the product should be included, false otherwise\n */\nexport const shouldIncludeProduct = (\n productIdentifier: string,\n excludeProducts?: ProductType[],\n): boolean => {\n if (!excludeProducts || excludeProducts.length === 0) {\n return true;\n }\n\n return !excludeProducts.some(\n (excluded) => PRODUCT_IDENTIFIER_MAP[excluded] === productIdentifier,\n );\n};\n\n/**\n * Array of employment statuses that are allowed to proceed to the review step.\n * These statuses indicate that the employment is in a final state and the employment cannot be modified further.\n * @type {Employment['status'][]}\n * @constant\n */\nexport const reviewStepAllowedEmploymentStatus: Employment['status'][] = [\n 'initiated',\n 'invited',\n 'created_awaiting_reserve',\n 'created_reserve_paid',\n 'active',\n];\n\nexport const disabledInviteButtonEmploymentStatus: Employment['status'][] = [\n 'initiated',\n 'created_awaiting_reserve',\n 'invited',\n 'active',\n];\n\n/**\n * Transforms AI error messages to use default localized messages\n * @param isContractorOfRecord - Whether the contractor is a Contractor of Record\n * @param errors - Array of error messages from the API\n * @returns Array containing the appropriate default error message\n */\nexport function transformAiErrorResponse(\n isContractorOfRecord: boolean,\n): string {\n const remoteAiErrorMessage = isContractorOfRecord\n ? REMOTE_AI_SERVICES_AND_DELIVERABLES_COR_ERROR_MESSAGE\n : REMOTE_AI_SERVICES_AND_DELIVERABLES_ERROR_MESSAGE;\n return remoteAiErrorMessage;\n}\n"],"mappings":"uGA6BO,SAASA,EAAWC,EAAqB,CAAC,EAAG,CAgDlD,IAAMC,EA3CD,CACH,CACE,KAAM,iBACN,MAAO,iBACP,QAAS,EAAQD,GAAQ,oBAC3B,EACA,CACE,KAAM,oBACN,MAAO,oBACP,QAAS,EACX,EACA,CACE,KAAM,eACN,MAAO,eACP,QAAS,EACX,EACA,CACE,KAAM,kBACN,MAAO,mBACP,QAAS,GAAQA,GAAQ,uBAAyB,GACpD,EACA,CACE,KAAM,4BACN,MAAO,4BACP,QAAS,EAAQA,GAAQ,+BAC3B,EACA,CACE,KAAM,mBACN,MAAO,mBACP,QAAS,GAAQA,GAAQ,wBAA0B,GACrD,EACA,CACE,KAAM,mBACN,MAAO,mBACP,QAAS,EAAQA,GAAQ,sBAC3B,EACA,CACE,KAAM,SACN,MAAO,SACP,QAAS,EACX,CACF,EAEmC,IAAI,CAACE,EAAMC,KAAW,CACvD,KAAMD,EAAK,KACX,MAAAC,EACA,MAAOD,EAAK,MACZ,QAASA,EAAK,OAChB,EAAE,EAcF,MAAO,CAAE,MAZKD,EAAW,OACvB,CAACG,EAAKF,KACJE,EAAIF,EAAK,IAAI,EAAI,CACf,MAAOA,EAAK,MACZ,KAAMA,EAAK,KACX,QAASA,EAAK,OAChB,EACOE,GAET,CAAC,CACH,EAEgB,WAAAH,CAAW,CAC7B,CApEgBI,EAAAN,EAAA,cA0ET,IAAMO,EAA2CD,EAAA,CACtDE,EACAC,IACuB,CAMvB,GAJED,GACAC,GACAD,IAAmCC,EAMnC,MAAO,qEAHuB,kFAC5BD,CACF,0EACiG,EAGrG,EAhBwD,4CAqB3CE,EAAeJ,EAACK,GAEzBA,IAAiBC,GACjBD,IAAiBE,EAHO,gBAOtBC,EAA4B,CAAC,MAAO,MAAO,MAAO,MAAO,KAAK,EAKvDC,EAA2BT,EAACU,GAChCF,EAA0B,SAASE,CAAW,EADf,4BAU3BC,EAAuBX,EAAA,CAClCY,EACAC,IAEI,CAACA,GAAmBA,EAAgB,SAAW,EAC1C,GAGF,CAACA,EAAgB,KACrBC,GAAaC,EAAuBD,CAAQ,IAAMF,CACrD,EAVkC,wBAmBvBI,EAA4D,CACvE,YACA,UACA,2BACA,uBACA,QACF,EAEaC,EAA+D,CAC1E,YACA,2BACA,UACA,QACF,EAQO,SAASC,EACdC,EACQ,CAIR,OAH6BA,EACzBC,EACAC,CAEN,CAPgBrB,EAAAkB,EAAA","names":["buildSteps","config","stepsArray","step","index","acc","__name","calculateProvisionalStartDateDescription","employmentProvisionalStartDate","fieldProvisionalStartDate","isCMOrCMPlus","subscription","contractorStandardProductIdentifier","contractorPlusProductIdentifier","NATIONALITY_COUNTRY_CODES","isNationalityCountryCode","countryCode","shouldIncludeProduct","productIdentifier","excludeProducts","excluded","PRODUCT_IDENTIFIER_MAP","reviewStepAllowedEmploymentStatus","disabledInviteButtonEmploymentStatus","transformAiErrorResponse","isContractorOfRecord","REMOTE_AI_SERVICES_AND_DELIVERABLES_COR_ERROR_MESSAGE","REMOTE_AI_SERVICES_AND_DELIVERABLES_ERROR_MESSAGE"]}
1
+ {"version":3,"sources":["../src/flows/ContractorOnboarding/utils.ts"],"sourcesContent":["import { Step } from '@/src/flows/useStepState';\nimport {\n contractorStandardProductIdentifier,\n contractorPlusProductIdentifier,\n ProductType,\n PRODUCT_IDENTIFIER_MAP,\n REMOTE_AI_SERVICES_AND_DELIVERABLES_ERROR_MESSAGE,\n REMOTE_AI_SERVICES_AND_DELIVERABLES_COR_ERROR_MESSAGE,\n} from '@/src/flows/ContractorOnboarding/constants';\nimport { Employment } from '@/src/flows/Onboarding/types';\n\nexport type StepKeys =\n | 'select_country'\n | 'basic_information'\n | 'contract_origin'\n | 'contract_details'\n | 'eligibility_questionnaire'\n | 'contract_preview'\n | 'pricing_plan'\n | 'review';\n\ntype StepConfig = {\n includeSelectCountry?: boolean;\n includeContractOrigin?: boolean;\n includeEligibilityQuestionnaire?: boolean;\n includeContractDetails?: boolean;\n includeContractPreview?: boolean;\n};\n\nexport function buildSteps(config: StepConfig = {}) {\n const stepDefinitions: Array<{\n name: StepKeys;\n label: string;\n visible: boolean;\n }> = [\n {\n name: 'select_country',\n label: 'Select Country',\n visible: Boolean(config?.includeSelectCountry),\n },\n {\n name: 'basic_information',\n label: 'Basic Information',\n visible: true,\n },\n {\n name: 'pricing_plan',\n label: 'Pricing Plan',\n visible: true,\n },\n {\n name: 'eligibility_questionnaire',\n label: 'Eligibility Questionnaire',\n visible: Boolean(config?.includeEligibilityQuestionnaire),\n },\n {\n name: 'contract_origin',\n label: 'Contract Options',\n visible: Boolean(config?.includeContractOrigin ?? true),\n },\n {\n name: 'contract_details',\n label: 'Contract Details',\n visible: Boolean(config?.includeContractDetails ?? true),\n },\n {\n name: 'contract_preview',\n label: 'Contract Preview',\n visible: Boolean(config?.includeContractPreview),\n },\n {\n name: 'review',\n label: 'Review',\n visible: true,\n },\n ];\n\n const stepsArray = stepDefinitions.map((step, index) => ({\n name: step.name,\n index,\n label: step.label,\n visible: step.visible,\n }));\n\n const steps = stepsArray.reduce(\n (acc, step) => {\n acc[step.name] = {\n index: step.index,\n name: step.name,\n visible: step.visible,\n };\n return acc;\n },\n {} as Record<string, Step<StepKeys>>,\n );\n\n return { steps, stepsArray };\n}\n\n/**\n * Calculates the description for the provisional start date field\n * based on whether the dates match between basic information and contract details steps\n */\nexport const calculateProvisionalStartDateDescription = (\n employmentProvisionalStartDate: string | undefined,\n fieldProvisionalStartDate: string | undefined,\n): string | undefined => {\n const datesNotMatching =\n employmentProvisionalStartDate &&\n fieldProvisionalStartDate &&\n employmentProvisionalStartDate !== fieldProvisionalStartDate;\n\n if (datesNotMatching) {\n const datesDontMatchWarning = `This date does not match the date you provided in the Basic Information step - ${\n employmentProvisionalStartDate\n } - and will override it only when both parties have signed the contract.`;\n return `When the contractor will start providing service to your company. ${datesDontMatchWarning}`;\n }\n return undefined;\n};\n\n/**\n * Checks if the selected pricing plan is CM (standard) or CM+ (plus)\n */\nexport const isCMOrCMPlus = (subscription: string | undefined): boolean => {\n return (\n subscription === contractorStandardProductIdentifier ||\n subscription === contractorPlusProductIdentifier\n );\n};\n\nconst NATIONALITY_COUNTRY_CODES = ['SAU', 'KWT', 'OMN', 'QAT', 'BHR'];\n\n/**\n * Checks if the country code is a country code that requires nationality status field\n */\nexport const isNationalityCountryCode = (countryCode: string) => {\n return NATIONALITY_COUNTRY_CODES.includes(countryCode);\n};\n\n/**\n * Checks if a product should be included based on the excludeProducts list\n * @param productIdentifier - The product identifier to check\n * @param excludeProducts - Array of products to exclude\n * @returns true if the product should be included, false otherwise\n */\nexport const shouldIncludeProduct = (\n productIdentifier: string,\n excludeProducts?: ProductType[],\n): boolean => {\n if (!excludeProducts || excludeProducts.length === 0) {\n return true;\n }\n\n return !excludeProducts.some(\n (excluded) => PRODUCT_IDENTIFIER_MAP[excluded] === productIdentifier,\n );\n};\n\n/**\n * Array of employment statuses that are allowed to proceed to the review step.\n * These statuses indicate that the employment is in a final state and the employment cannot be modified further.\n * @type {Employment['status'][]}\n * @constant\n */\nexport const reviewStepAllowedEmploymentStatus: Employment['status'][] = [\n 'initiated',\n 'invited',\n 'created_awaiting_reserve',\n 'created_reserve_paid',\n 'active',\n];\n\nexport const disabledInviteButtonEmploymentStatus: Employment['status'][] = [\n 'initiated',\n 'created_awaiting_reserve',\n 'invited',\n 'active',\n];\n\n/**\n * Transforms AI error messages to use default localized messages\n * @param isContractorOfRecord - Whether the contractor is a Contractor of Record\n * @param errors - Array of error messages from the API\n * @returns Array containing the appropriate default error message\n */\nexport function transformAiErrorResponse(\n isContractorOfRecord: boolean,\n): string {\n const remoteAiErrorMessage = isContractorOfRecord\n ? REMOTE_AI_SERVICES_AND_DELIVERABLES_COR_ERROR_MESSAGE\n : REMOTE_AI_SERVICES_AND_DELIVERABLES_ERROR_MESSAGE;\n return remoteAiErrorMessage;\n}\n"],"mappings":"uGA6BO,SAASA,EAAWC,EAAqB,CAAC,EAAG,CAgDlD,IAAMC,EA3CD,CACH,CACE,KAAM,iBACN,MAAO,iBACP,QAAS,EAAQD,GAAQ,oBAC3B,EACA,CACE,KAAM,oBACN,MAAO,oBACP,QAAS,EACX,EACA,CACE,KAAM,eACN,MAAO,eACP,QAAS,EACX,EACA,CACE,KAAM,4BACN,MAAO,4BACP,QAAS,EAAQA,GAAQ,+BAC3B,EACA,CACE,KAAM,kBACN,MAAO,mBACP,QAAS,GAAQA,GAAQ,uBAAyB,GACpD,EACA,CACE,KAAM,mBACN,MAAO,mBACP,QAAS,GAAQA,GAAQ,wBAA0B,GACrD,EACA,CACE,KAAM,mBACN,MAAO,mBACP,QAAS,EAAQA,GAAQ,sBAC3B,EACA,CACE,KAAM,SACN,MAAO,SACP,QAAS,EACX,CACF,EAEmC,IAAI,CAACE,EAAMC,KAAW,CACvD,KAAMD,EAAK,KACX,MAAAC,EACA,MAAOD,EAAK,MACZ,QAASA,EAAK,OAChB,EAAE,EAcF,MAAO,CAAE,MAZKD,EAAW,OACvB,CAACG,EAAKF,KACJE,EAAIF,EAAK,IAAI,EAAI,CACf,MAAOA,EAAK,MACZ,KAAMA,EAAK,KACX,QAASA,EAAK,OAChB,EACOE,GAET,CAAC,CACH,EAEgB,WAAAH,CAAW,CAC7B,CApEgBI,EAAAN,EAAA,cA0ET,IAAMO,EAA2CD,EAAA,CACtDE,EACAC,IACuB,CAMvB,GAJED,GACAC,GACAD,IAAmCC,EAMnC,MAAO,qEAHuB,kFAC5BD,CACF,0EACiG,EAGrG,EAhBwD,4CAqB3CE,EAAeJ,EAACK,GAEzBA,IAAiBC,GACjBD,IAAiBE,EAHO,gBAOtBC,EAA4B,CAAC,MAAO,MAAO,MAAO,MAAO,KAAK,EAKvDC,EAA2BT,EAACU,GAChCF,EAA0B,SAASE,CAAW,EADf,4BAU3BC,EAAuBX,EAAA,CAClCY,EACAC,IAEI,CAACA,GAAmBA,EAAgB,SAAW,EAC1C,GAGF,CAACA,EAAgB,KACrBC,GAAaC,EAAuBD,CAAQ,IAAMF,CACrD,EAVkC,wBAmBvBI,EAA4D,CACvE,YACA,UACA,2BACA,uBACA,QACF,EAEaC,EAA+D,CAC1E,YACA,2BACA,UACA,QACF,EAQO,SAASC,EACdC,EACQ,CAIR,OAH6BA,EACzBC,EACAC,CAEN,CAPgBrB,EAAAkB,EAAA","names":["buildSteps","config","stepsArray","step","index","acc","__name","calculateProvisionalStartDateDescription","employmentProvisionalStartDate","fieldProvisionalStartDate","isCMOrCMPlus","subscription","contractorStandardProductIdentifier","contractorPlusProductIdentifier","NATIONALITY_COUNTRY_CODES","isNationalityCountryCode","countryCode","shouldIncludeProduct","productIdentifier","excludeProducts","excluded","PRODUCT_IDENTIFIER_MAP","reviewStepAllowedEmploymentStatus","disabledInviteButtonEmploymentStatus","transformAiErrorResponse","isContractorOfRecord","REMOTE_AI_SERVICES_AND_DELIVERABLES_COR_ERROR_MESSAGE","REMOTE_AI_SERVICES_AND_DELIVERABLES_ERROR_MESSAGE"]}
@@ -1,2 +1,2 @@
1
- import{c as d,d as S}from"./chunk-LES7J6H4.js";import{a as f}from"./chunk-KSHK3ZPX.js";import{a as u}from"./chunk-HN5HLFTB.js";import{b as C}from"./chunk-KFYWUBRS.js";import{f as y}from"./chunk-Y3CJRZLA.js";import{a as o}from"./chunk-P37U34EQ.js";import{useEffect as T,useId as U,useState as I}from"react";import{jsx as k}from"react/jsx-runtime";var l=o((n,e,r)=>r&&r[e]?r[e]:n[e]?n[e]/100:0,"getDefaultManagementFee"),A=o((n,e,r,g)=>!e&&!r?.management_fee&&n?l(u,n,g):e&&!r?.management_fee?"":r?.management_fee,"getManagementFee"),W=o(({estimationOptions:n=d,defaultValues:e={countryRegionSlug:"",regionSlug:"",currencySlug:"",salary:"",benefits:{},management:{management_fee:""}},options:r,render:g,version:_="standard"})=>{let p=U(),[R,m]=I("USD"),F=o(s=>{m(s);let a=l(u,s,n.managementFees);a&&c.setValue("management.management_fee",a.toString())},"onCurrencyChange"),t=S({defaultRegion:e.countryRegionSlug,defaultCurrency:e.currencySlug,defaultSalary:e.salary,estimationOptions:n,version:_,options:{...r,onCurrencyChange:F}}),K=C(t.handleValidation),b=A(R,e.currencySlug,e.management,n.managementFees),{countryRegionSlug:v,currencySlug:h,salary:D,benefits:P,hiringBudget:B,age:E,contractDurationType:M,regionSlug:w,...x}=e,c=y({resolver:K,defaultValues:{country:v,currency:h,region:w,salary:D,salary_conversion:"",salary_converted:void 0,hiring_budget:B||"employee_annual_salary",age:E,contract_duration_type:M,management:{management_fee:b?.toString()||""},benefits:P,estimation_title:n.title,...x},shouldUnregister:!1,mode:"onBlur"});return T(()=>{if(e.currencySlug&&t.currencies&&n.includeManagementFee&&!e.management?.management_fee){let a=t.currencies.find(i=>i.value===e.currencySlug)?.label;if(a){m(a);let i=l(u,a,n.managementFees);c.setValue("management.management_fee",i?.toString()||"")}}},[e.currencySlug,t.currencies,n.includeManagementFee,n.managementFees,e.management?.management_fee,c]),k(f.Provider,{value:{form:c,formId:p,costCalculatorBag:t},children:g(t)})},"CostCalculatorFlow");export{W as a};
2
- //# sourceMappingURL=chunk-FJGDFNEH.js.map
1
+ import{c as d,d as S}from"./chunk-HAI4J2FU.js";import{a as f}from"./chunk-KSHK3ZPX.js";import{a as u}from"./chunk-HN5HLFTB.js";import{b as C}from"./chunk-KFYWUBRS.js";import{f as y}from"./chunk-Y3CJRZLA.js";import{a as o}from"./chunk-P37U34EQ.js";import{useEffect as T,useId as U,useState as I}from"react";import{jsx as k}from"react/jsx-runtime";var l=o((n,e,r)=>r&&r[e]?r[e]:n[e]?n[e]/100:0,"getDefaultManagementFee"),A=o((n,e,r,g)=>!e&&!r?.management_fee&&n?l(u,n,g):e&&!r?.management_fee?"":r?.management_fee,"getManagementFee"),W=o(({estimationOptions:n=d,defaultValues:e={countryRegionSlug:"",regionSlug:"",currencySlug:"",salary:"",benefits:{},management:{management_fee:""}},options:r,render:g,version:_="standard"})=>{let p=U(),[R,m]=I("USD"),F=o(s=>{m(s);let a=l(u,s,n.managementFees);a&&c.setValue("management.management_fee",a.toString())},"onCurrencyChange"),t=S({defaultRegion:e.countryRegionSlug,defaultCurrency:e.currencySlug,defaultSalary:e.salary,estimationOptions:n,version:_,options:{...r,onCurrencyChange:F}}),K=C(t.handleValidation),b=A(R,e.currencySlug,e.management,n.managementFees),{countryRegionSlug:v,currencySlug:h,salary:D,benefits:P,hiringBudget:B,age:E,contractDurationType:M,regionSlug:w,...x}=e,c=y({resolver:K,defaultValues:{country:v,currency:h,region:w,salary:D,salary_conversion:"",salary_converted:void 0,hiring_budget:B||"employee_annual_salary",age:E,contract_duration_type:M,management:{management_fee:b?.toString()||""},benefits:P,estimation_title:n.title,...x},shouldUnregister:!1,mode:"onBlur"});return T(()=>{if(e.currencySlug&&t.currencies&&n.includeManagementFee&&!e.management?.management_fee){let a=t.currencies.find(i=>i.value===e.currencySlug)?.label;if(a){m(a);let i=l(u,a,n.managementFees);c.setValue("management.management_fee",i?.toString()||"")}}},[e.currencySlug,t.currencies,n.includeManagementFee,n.managementFees,e.management?.management_fee,c]),k(f.Provider,{value:{form:c,formId:p,costCalculatorBag:t},children:g(t)})},"CostCalculatorFlow");export{W as a};
2
+ //# sourceMappingURL=chunk-F67DSAFU.js.map
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-F74X2V2N.js";import{a as i}from"./chunk-G6F6ZZES.js";import{b as d}from"./chunk-QQ3PZHXO.js";import{a as l}from"./chunk-X25ZOPO6.js";import{a as S}from"./chunk-FHYOWPXB.js";import{a as c}from"./chunk-QXW2MAFG.js";import{a as f}from"./chunk-NRGNFMIO.js";import{a as n}from"./chunk-EI44AIUW.js";import{a as s}from"./chunk-GHHMGTM4.js";import{a as p}from"./chunk-BS2B4OOE.js";import{a as g}from"./chunk-TZGC6PWQ.js";import{a as m}from"./chunk-B7BJXPGT.js";import{a as t}from"./chunk-VUQH44VX.js";import{a as r}from"./chunk-PGWKJ6FK.js";import{a as o}from"./chunk-P37U34EQ.js";import{useId as h,useState as A}from"react";import{jsx as E}from"react/jsx-runtime";var V=o(({employmentId:u,companyId:b,countryCode:v,type:O="employee",externalId:w,skipSteps:B,initialValues:I,render:C,options:P})=>{let D=h(),e=t({companyId:b,countryCode:v,employmentId:u,type:O,options:P,skipSteps:B,externalId:w,initialValues:I}),[R,y]=A({showReserveInvoice:!1,showInviteSuccessful:!1});return E(r.Provider,{value:{formId:D,onboardingBag:e,creditScore:R,setCreditScore:y},children:C({onboardingBag:e,components:{BasicInformationStep:n,EngagementAgreementDetailsStep:g,ContractDetailsStep:p,BenefitsStep:s,SubmitButton:i,SaveDraftButton:c,BackButton:m,OnboardingInvite:a,SelectCountryStep:f,ReviewStep:S,PreOnboardingRequirements:d,PreviewEmploymentAgreementStep:l}})})},"OnboardingFlow");export{V as a};
2
- //# sourceMappingURL=chunk-MG6UYSCR.js.map
1
+ import{a as c}from"./chunk-QXW2MAFG.js";import{a as f}from"./chunk-NRGNFMIO.js";import{a as m}from"./chunk-B7BJXPGT.js";import{a}from"./chunk-RG36YL7L.js";import{a as i}from"./chunk-G6F6ZZES.js";import{b as d}from"./chunk-YZ3KEILH.js";import{a as l}from"./chunk-X25ZOPO6.js";import{a as S}from"./chunk-FHYOWPXB.js";import{a as n}from"./chunk-EI44AIUW.js";import{a as s}from"./chunk-GHHMGTM4.js";import{a as p}from"./chunk-BS2B4OOE.js";import{a as g}from"./chunk-TZGC6PWQ.js";import{a as r}from"./chunk-PGWKJ6FK.js";import{a as t}from"./chunk-UYSY6Z5S.js";import{a as o}from"./chunk-P37U34EQ.js";import{useId as h,useState as A}from"react";import{jsx as E}from"react/jsx-runtime";var V=o(({employmentId:u,companyId:b,countryCode:v,type:O="employee",externalId:w,skipSteps:B,initialValues:I,render:C,options:P})=>{let D=h(),e=t({companyId:b,countryCode:v,employmentId:u,type:O,options:P,skipSteps:B,externalId:w,initialValues:I}),[R,y]=A({showReserveInvoice:!1,showInviteSuccessful:!1});return E(r.Provider,{value:{formId:D,onboardingBag:e,creditScore:R,setCreditScore:y},children:C({onboardingBag:e,components:{BasicInformationStep:n,EngagementAgreementDetailsStep:g,ContractDetailsStep:p,BenefitsStep:s,SubmitButton:i,SaveDraftButton:c,BackButton:m,OnboardingInvite:a,SelectCountryStep:f,ReviewStep:S,PreOnboardingRequirements:d,PreviewEmploymentAgreementStep:l}})})},"OnboardingFlow");export{V as a};
2
+ //# sourceMappingURL=chunk-G2FGMFTN.js.map
@@ -1,2 +1,2 @@
1
- import{a as Z}from"./chunk-GR6QMP4Z.js";import{a as I}from"./chunk-VFRHMNLJ.js";import{a as Q,b as W,c as X,f as Y}from"./chunk-TWULMMMY.js";import{a as C}from"./chunk-HN5HLFTB.js";import{a as G}from"./chunk-KFYWUBRS.js";import{c as ee}from"./chunk-A5SRPVT2.js";import{a as z}from"./chunk-LKVQ32ZK.js";import{b as K,h as M}from"./chunk-G2LZFGZA.js";import{a as o}from"./chunk-P37U34EQ.js";import{number as Be,object as se}from"yup";import{useCallback as je,useEffect as te,useMemo as we,useRef as Re,useState as j}from"react";import{string as ne,ValidationError as re}from"yup";import{jsx as ie}from"react/jsx-runtime";var O={title:"Estimation",includeBenefits:!1,includeCostBreakdowns:!1,includePremiumBenefits:!1,enableCurrencyConversion:!1,includeEstimationTitle:!1,includeManagementFee:!1},Pe=o(t=>z(I.data.schema,void 0,t),"useStaticSchema");function xe(t,i){if(typeof t=="object"&&t!==null&&"title"in t){let l=t.title;if(l)return l}return i==="my_hiring_budget"?"Hiring budget":"Employee's annual salary"}o(xe,"getSalaryTitle");var ze=o(({defaultRegion:t,defaultCurrency:i,defaultSalary:l,estimationOptions:s,options:n,version:a}={estimationOptions:O})=>{let u=Re({fields:{}}),[k,h]=j(t),[w,R]=j(),[m,q]=j(),[H,le]=j(),{data:_,isLoading:ue}=Q({includePremiumBenefits:s.includePremiumBenefits}),{data:d,isLoading:ce}=W(),me=k||w?.value,{data:P,isLoading:de}=Y(me,{includePremiumBenefits:s.includePremiumBenefits,options:n}),U=X(),{mutateAsync:fe}=K(U),b=w?.currency,p=n?.jsfModify?.fields?.salary,F=p&&typeof p=="object"&&"presentation"in p?p.presentation:void 0,L=je(()=>{let e=b&&m?b!==m:!1;return b!==m?{from:m,to:b,shouldSwapOrder:e}:{from:b,to:m,shouldSwapOrder:e}},[b,m]),J=s.showManagementFee,$=s.includeEstimationTitle,ge=we(()=>{let{from:e,to:r,shouldSwapOrder:c}=L(),g=xe(p,H);return{fields:{salary:{...p,title:g,presentation:{salary_conversion_properties:{label:F?.salary_conversion_properties?.label,description:F?.salary_conversion_properties?.description},currencies:{from:e,to:r},Component:o(y=>ie(Z,{...y,shouldSwapOrder:c,conversionType:a==="marketing"?"no_spread":"spread",defaultValue:l}),"Component")}},hiring_budget:{...n?.jsfModify?.fields?.hiring_budget,presentation:{hidden:a=="marketing"}},management:{...n?.jsfModify?.fields?.management,properties:{...n?.jsfModify?.fields?.management?.properties,management_fee:{...n?.jsfModify?.fields?.management?.properties?.management_fee,"x-jsf-presentation":{inputType:"money",additionalProps:{currency:m||"USD"}}}},presentation:{...typeof n?.jsfModify?.fields?.management=="object"?(n?.jsfModify?.fields?.management)["x-jsf-presentation"]:{},hidden:!J,Component:o(y=>ie(ee,{...y,variant:"inset",features:{toggle:{enabled:!0,stateField:"management._expanded",labels:{expand:"Define",collapse:"Remove"}}}}),"Component")}},estimation_title:{...n?.jsfModify?.fields?.estimation_title,"x-jsf-presentation":{hidden:!$}}}}},[L,p,H,F?.salary_conversion_properties?.label,F?.salary_conversion_properties?.description,n?.jsfModify?.fields?.hiring_budget,n?.jsfModify?.fields?.management,n?.jsfModify?.fields?.estimation_title,a,m,J,$,l]),f=Pe({jsfModify:{fields:{...n?.jsfModify?.fields,...ge?.fields}}});te(()=>{if(t&&_){let e=_.find(({value:r})=>r===t);e&&R(e)}},[t,_]),te(()=>{if(i&&d){let e=d.find(({value:r})=>r===i);e&&q(e.label)}},[i,d]);async function ye(e){return fe(oe(e,s,a))}o(ye,"onSubmit");function pe(e){let r=_?.find(({value:c})=>c===e);r&&r.childRegions.length===0&&r.hasAdditionalFields?h(r.regionSlug):h(void 0),R(r)}o(pe,"onCountryChange");function Ce(e){h(e)}o(Ce,"onRegionChange");function _e(e){le(e.target.value)}o(_e,"onHiringBudgetChange");function be(e){let r=d?.find(c=>c.value===e)?.label;q(r),n?.onCurrencyChange?.(r||"")}o(be,"onChangeCurrency");let E=f.fields.find(e=>e.name==="region");if(E){let e=w?.childRegions.map(r=>({value:r.slug,label:r.name}))??[];E.options=e,E.isVisible=e.length>0,E.required=e.length>0,E.onChange=Ce,E.schema=e.length>0?ne().transform(r=>typeof r=="string"?r:"").required("Region is required"):ne()}if(d){let e=f.fields.find(r=>r.name==="currency");e&&(e.options=d,e.onChange=be)}let v=f.fields.find(e=>e.name==="hiring_budget");if(v&&(v.onChange=_e),_){let e=f.fields.find(r=>r.name==="country");e&&(e.options=_,e.onChange=pe)}let Ee=o(()=>{R(void 0),h(t)},"resetForm"),D=[...f.fields.filter(e=>e.name!=="management"),...P?.fields||[],...f.fields.filter(e=>e.name==="management")],N=ae(f.fields,m||"USD",s.includeEstimationTitle);async function Se(e){let r=null;n?.onValidation?.(e);let c=await M(e,D);try{await N.validate(c,{abortEarly:!1}),r={formErrors:{},yupError:new re([],e)}}catch(S){let B=G(S);r={formErrors:Object.entries(B).reduce((T,[A,V])=>({...T,[A]:V.message}),{}),yupError:S}}let g=P?.handleValidation(c),y=[...r?.yupError.inner||[],...g?.yupError?.inner||[]],x={...r?.yupError?.value||{},...g?.yupError?.value||{}};return{formErrors:{...r?.formErrors||{},...g?.formErrors||{}},yupError:new re(y,x)}}return o(Se,"handleValidation"),{stepState:{current:0,total:1,isLastStep:!0},fields:D,validationSchema:N,parseFormValues:o(async e=>{let{country:r,region:c,currency:g,salary_converted:y,hiring_budget:x,salary_conversion:S,management:B,estimation_title:T,...A}=e,V=e.salary;y==="salary_conversion"&&(V=S);let he=await M({country:r,region:c,salary:V,salary_converted:y,salary_conversion:S,hiring_budget:x,currency:g,management:B,estimation_title:T},f.fields),Fe=await M(A,P?.fields||[]),Ve={currency_code:d?.find(Me=>Me.value===g)?.label};return{...he,...Fe,...Ve}},"parseFormValues"),handleValidation:Se,isSubmitting:U.isPending,isLoading:ue&&ce&&de,onSubmit:ye,resetForm:Ee,currencies:d,meta:{fields:u.current?.fields}}},"useCostCalculator");function ae(t,i,l){let s=t.reduce((n,a)=>(a.name==="salary"||a.name==="salary_conversion"?n[a.name]=a.schema.when("salary_converted",{is:o(u=>u===a.name,"is"),then:o(u=>u.required("Required field"),"then"),otherwise:o(u=>u.optional(),"otherwise")}):a.name==="management"?n[a.name]=se({management_fee:Be().transform(u=>isNaN(u)?void 0:u).min(0,"Management fee must be greater than or equal to 0").max(i?C[i]:C.USD,()=>`Management fee cannot exceed ${(i?C[i]:C.USD)/100} ${i}`)}):a.name==="estimation_title"&&l?n[a.name]=a.schema.required("Required field"):n[a.name]=a.schema,n),{});return se(s)}o(ae,"buildValidationSchema");function Te(t){let i="benefit-";return Object.keys(t).reduce((l,s)=>{let n=t[s];if(n==="none")return l;let u={benefit_group_slug:s.replace(i,""),benefit_tier_slug:n};return[...l,u]},[])}o(Te,"formatBenefits");function Ae(t,i,l){let s=Number(t.management?.management_fee),n=t.currency_code;return{...{region_slug:t.region||t.country,employment_term:t.contract_duration_type??"fixed",title:t.estimation_title||i.title,age:t.age??void 0,...t.benefits&&{benefits:Te(t.benefits)},...i.includeManagementFee&&s&&{discount:{quoted_amount:i.showManagementFee?s:C[n]||C.USD,text:""}}},...Oe(t,l)}}o(Ae,"mapValueToEmployment");function Oe(t,i){let l=i==="marketing"||t.salary_converted==="salary_conversion",s=i==="standard"&&t.salary_converted==="salary",n=t.hiring_budget==="my_hiring_budget";if(l){let a=t.salary_converted==="salary_conversion";return n?{annual_total_cost_in_employer_currency:t.salary}:{[a?"annual_gross_salary_in_employer_currency":"annual_gross_salary"]:t.salary}}return s?n?{annual_total_cost:t.salary}:{annual_gross_salary:t.salary}:{}}o(Oe,"getSalaryFields");function oe(t,i=O,l="standard"){let s=Array.isArray(t)?t:[t];if(s.length===0)throw new Error("At least one employment value is required");return s.length>1&&new Set(s.map(a=>a.currency)).size>1&&console.warn("Multiple currencies detected in array. Using currency from first employment."),{employer_currency_slug:s[0].currency,include_benefits:i.includeBenefits,include_cost_breakdowns:i.includeCostBreakdowns,include_premium_benefits:i.includePremiumBenefits,include_management_fee:i.includeManagementFee,employments:s.map(n=>Ae(n,i,l))}}o(oe,"buildPayload");export{ae as a,oe as b,O as c,ze as d};
2
- //# sourceMappingURL=chunk-LES7J6H4.js.map
1
+ import{a as Z}from"./chunk-DSL5O7NR.js";import{a as I}from"./chunk-VFRHMNLJ.js";import{a as Q,b as W,c as X,f as Y}from"./chunk-LV6MDD3M.js";import{a as C}from"./chunk-HN5HLFTB.js";import{a as G}from"./chunk-KFYWUBRS.js";import{c as ee}from"./chunk-A5SRPVT2.js";import{a as z}from"./chunk-7WB6IHRF.js";import{b as K,h as M}from"./chunk-G2LZFGZA.js";import{a as o}from"./chunk-P37U34EQ.js";import{number as Be,object as se}from"yup";import{useCallback as je,useEffect as te,useMemo as we,useRef as Re,useState as j}from"react";import{string as ne,ValidationError as re}from"yup";import{jsx as ie}from"react/jsx-runtime";var O={title:"Estimation",includeBenefits:!1,includeCostBreakdowns:!1,includePremiumBenefits:!1,enableCurrencyConversion:!1,includeEstimationTitle:!1,includeManagementFee:!1},Pe=o(t=>z(I.data.schema,void 0,t),"useStaticSchema");function xe(t,i){if(typeof t=="object"&&t!==null&&"title"in t){let l=t.title;if(l)return l}return i==="my_hiring_budget"?"Hiring budget":"Employee's annual salary"}o(xe,"getSalaryTitle");var ze=o(({defaultRegion:t,defaultCurrency:i,defaultSalary:l,estimationOptions:s,options:n,version:a}={estimationOptions:O})=>{let u=Re({fields:{}}),[k,h]=j(t),[w,R]=j(),[m,q]=j(),[H,le]=j(),{data:_,isLoading:ue}=Q({includePremiumBenefits:s.includePremiumBenefits}),{data:d,isLoading:ce}=W(),me=k||w?.value,{data:P,isLoading:de}=Y(me,{includePremiumBenefits:s.includePremiumBenefits,options:n}),U=X(),{mutateAsync:fe}=K(U),b=w?.currency,p=n?.jsfModify?.fields?.salary,F=p&&typeof p=="object"&&"presentation"in p?p.presentation:void 0,L=je(()=>{let e=b&&m?b!==m:!1;return b!==m?{from:m,to:b,shouldSwapOrder:e}:{from:b,to:m,shouldSwapOrder:e}},[b,m]),J=s.showManagementFee,$=s.includeEstimationTitle,ge=we(()=>{let{from:e,to:r,shouldSwapOrder:c}=L(),g=xe(p,H);return{fields:{salary:{...p,title:g,presentation:{salary_conversion_properties:{label:F?.salary_conversion_properties?.label,description:F?.salary_conversion_properties?.description},currencies:{from:e,to:r},Component:o(y=>ie(Z,{...y,shouldSwapOrder:c,conversionType:a==="marketing"?"no_spread":"spread",defaultValue:l}),"Component")}},hiring_budget:{...n?.jsfModify?.fields?.hiring_budget,presentation:{hidden:a=="marketing"}},management:{...n?.jsfModify?.fields?.management,properties:{...n?.jsfModify?.fields?.management?.properties,management_fee:{...n?.jsfModify?.fields?.management?.properties?.management_fee,"x-jsf-presentation":{inputType:"money",additionalProps:{currency:m||"USD"}}}},presentation:{...typeof n?.jsfModify?.fields?.management=="object"?(n?.jsfModify?.fields?.management)["x-jsf-presentation"]:{},hidden:!J,Component:o(y=>ie(ee,{...y,variant:"inset",features:{toggle:{enabled:!0,stateField:"management._expanded",labels:{expand:"Define",collapse:"Remove"}}}}),"Component")}},estimation_title:{...n?.jsfModify?.fields?.estimation_title,"x-jsf-presentation":{hidden:!$}}}}},[L,p,H,F?.salary_conversion_properties?.label,F?.salary_conversion_properties?.description,n?.jsfModify?.fields?.hiring_budget,n?.jsfModify?.fields?.management,n?.jsfModify?.fields?.estimation_title,a,m,J,$,l]),f=Pe({jsfModify:{fields:{...n?.jsfModify?.fields,...ge?.fields}}});te(()=>{if(t&&_){let e=_.find(({value:r})=>r===t);e&&R(e)}},[t,_]),te(()=>{if(i&&d){let e=d.find(({value:r})=>r===i);e&&q(e.label)}},[i,d]);async function ye(e){return fe(oe(e,s,a))}o(ye,"onSubmit");function pe(e){let r=_?.find(({value:c})=>c===e);r&&r.childRegions.length===0&&r.hasAdditionalFields?h(r.regionSlug):h(void 0),R(r)}o(pe,"onCountryChange");function Ce(e){h(e)}o(Ce,"onRegionChange");function _e(e){le(e.target.value)}o(_e,"onHiringBudgetChange");function be(e){let r=d?.find(c=>c.value===e)?.label;q(r),n?.onCurrencyChange?.(r||"")}o(be,"onChangeCurrency");let E=f.fields.find(e=>e.name==="region");if(E){let e=w?.childRegions.map(r=>({value:r.slug,label:r.name}))??[];E.options=e,E.isVisible=e.length>0,E.required=e.length>0,E.onChange=Ce,E.schema=e.length>0?ne().transform(r=>typeof r=="string"?r:"").required("Region is required"):ne()}if(d){let e=f.fields.find(r=>r.name==="currency");e&&(e.options=d,e.onChange=be)}let v=f.fields.find(e=>e.name==="hiring_budget");if(v&&(v.onChange=_e),_){let e=f.fields.find(r=>r.name==="country");e&&(e.options=_,e.onChange=pe)}let Ee=o(()=>{R(void 0),h(t)},"resetForm"),D=[...f.fields.filter(e=>e.name!=="management"),...P?.fields||[],...f.fields.filter(e=>e.name==="management")],N=ae(f.fields,m||"USD",s.includeEstimationTitle);async function Se(e){let r=null;n?.onValidation?.(e);let c=await M(e,D);try{await N.validate(c,{abortEarly:!1}),r={formErrors:{},yupError:new re([],e)}}catch(S){let B=G(S);r={formErrors:Object.entries(B).reduce((T,[A,V])=>({...T,[A]:V.message}),{}),yupError:S}}let g=P?.handleValidation(c),y=[...r?.yupError.inner||[],...g?.yupError?.inner||[]],x={...r?.yupError?.value||{},...g?.yupError?.value||{}};return{formErrors:{...r?.formErrors||{},...g?.formErrors||{}},yupError:new re(y,x)}}return o(Se,"handleValidation"),{stepState:{current:0,total:1,isLastStep:!0},fields:D,validationSchema:N,parseFormValues:o(async e=>{let{country:r,region:c,currency:g,salary_converted:y,hiring_budget:x,salary_conversion:S,management:B,estimation_title:T,...A}=e,V=e.salary;y==="salary_conversion"&&(V=S);let he=await M({country:r,region:c,salary:V,salary_converted:y,salary_conversion:S,hiring_budget:x,currency:g,management:B,estimation_title:T},f.fields),Fe=await M(A,P?.fields||[]),Ve={currency_code:d?.find(Me=>Me.value===g)?.label};return{...he,...Fe,...Ve}},"parseFormValues"),handleValidation:Se,isSubmitting:U.isPending,isLoading:ue&&ce&&de,onSubmit:ye,resetForm:Ee,currencies:d,meta:{fields:u.current?.fields}}},"useCostCalculator");function ae(t,i,l){let s=t.reduce((n,a)=>(a.name==="salary"||a.name==="salary_conversion"?n[a.name]=a.schema.when("salary_converted",{is:o(u=>u===a.name,"is"),then:o(u=>u.required("Required field"),"then"),otherwise:o(u=>u.optional(),"otherwise")}):a.name==="management"?n[a.name]=se({management_fee:Be().transform(u=>isNaN(u)?void 0:u).min(0,"Management fee must be greater than or equal to 0").max(i?C[i]:C.USD,()=>`Management fee cannot exceed ${(i?C[i]:C.USD)/100} ${i}`)}):a.name==="estimation_title"&&l?n[a.name]=a.schema.required("Required field"):n[a.name]=a.schema,n),{});return se(s)}o(ae,"buildValidationSchema");function Te(t){let i="benefit-";return Object.keys(t).reduce((l,s)=>{let n=t[s];if(n==="none")return l;let u={benefit_group_slug:s.replace(i,""),benefit_tier_slug:n};return[...l,u]},[])}o(Te,"formatBenefits");function Ae(t,i,l){let s=Number(t.management?.management_fee),n=t.currency_code;return{...{region_slug:t.region||t.country,employment_term:t.contract_duration_type??"fixed",title:t.estimation_title||i.title,age:t.age??void 0,...t.benefits&&{benefits:Te(t.benefits)},...i.includeManagementFee&&s&&{discount:{quoted_amount:i.showManagementFee?s:C[n]||C.USD,text:""}}},...Oe(t,l)}}o(Ae,"mapValueToEmployment");function Oe(t,i){let l=i==="marketing"||t.salary_converted==="salary_conversion",s=i==="standard"&&t.salary_converted==="salary",n=t.hiring_budget==="my_hiring_budget";if(l){let a=t.salary_converted==="salary_conversion";return n?{annual_total_cost_in_employer_currency:t.salary}:{[a?"annual_gross_salary_in_employer_currency":"annual_gross_salary"]:t.salary}}return s?n?{annual_total_cost:t.salary}:{annual_gross_salary:t.salary}:{}}o(Oe,"getSalaryFields");function oe(t,i=O,l="standard"){let s=Array.isArray(t)?t:[t];if(s.length===0)throw new Error("At least one employment value is required");return s.length>1&&new Set(s.map(a=>a.currency)).size>1&&console.warn("Multiple currencies detected in array. Using currency from first employment."),{employer_currency_slug:s[0].currency,include_benefits:i.includeBenefits,include_cost_breakdowns:i.includeCostBreakdowns,include_premium_benefits:i.includePremiumBenefits,include_management_fee:i.includeManagementFee,employments:s.map(n=>Ae(n,i,l))}}o(oe,"buildPayload");export{ae as a,oe as b,O as c,ze as d};
2
+ //# sourceMappingURL=chunk-HAI4J2FU.js.map