@remoteoss/remote-flows 0.4.1 → 0.5.0

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 (149) hide show
  1. package/dist/{chunk-IKJFPDZL.js → chunk-2YGGLGBG.js} +2 -2
  2. package/dist/{chunk-RNR4JEHX.js → chunk-3AOOE4V2.js} +2 -2
  3. package/dist/{chunk-6ACGE24H.js → chunk-42M5XC23.js} +2 -2
  4. package/dist/{chunk-QJWVOD4K.js → chunk-4OWFS6J6.js} +2 -2
  5. package/dist/{chunk-BLVS2A23.js → chunk-B4UHZS6S.js} +2 -2
  6. package/dist/{chunk-L6CLZL2D.js → chunk-DIL47M74.js} +2 -2
  7. package/dist/{chunk-XIPPSRO6.js → chunk-F66G33YT.js} +2 -2
  8. package/dist/{chunk-XIPPSRO6.js.map → chunk-F66G33YT.js.map} +1 -1
  9. package/dist/{chunk-M6ZWJ7KV.js → chunk-GPPJCUV6.js} +2 -2
  10. package/dist/chunk-HUEFMP54.js +2 -0
  11. package/dist/{chunk-SG67NZYI.js.map → chunk-HUEFMP54.js.map} +1 -1
  12. package/dist/{chunk-KT6EAWZO.js → chunk-HVZOU73K.js} +2 -2
  13. package/dist/chunk-KDWPT7ZP.js +2 -0
  14. package/dist/chunk-KDWPT7ZP.js.map +1 -0
  15. package/dist/{chunk-CK2Y7YLV.js → chunk-LRCSXZ5Y.js} +2 -2
  16. package/dist/chunk-MPMOHDZP.js +2 -0
  17. package/dist/chunk-MPMOHDZP.js.map +1 -0
  18. package/dist/{chunk-PJ6EQF5M.js → chunk-RMFW7BZM.js} +2 -2
  19. package/dist/{chunk-BIXYNFMY.js → chunk-S2VTL2TR.js} +2 -2
  20. package/dist/{chunk-G7ELSCK7.js → chunk-S4WAMYEE.js} +2 -2
  21. package/dist/chunk-STEO7MS2.js +2 -0
  22. package/dist/chunk-STEO7MS2.js.map +1 -0
  23. package/dist/chunk-SYYKU72Z.js +2 -0
  24. package/dist/chunk-SYYKU72Z.js.map +1 -0
  25. package/dist/chunk-T33QM3L4.js +2 -0
  26. package/dist/{chunk-TQNMLD3A.js.map → chunk-T33QM3L4.js.map} +1 -1
  27. package/dist/{chunk-SX5W3CBP.js → chunk-T3HJ2JSB.js} +2 -2
  28. package/dist/chunk-TWLIQ3LY.js +2 -0
  29. package/dist/{chunk-CM7ZXKYC.js.map → chunk-TWLIQ3LY.js.map} +1 -1
  30. package/dist/{chunk-HHMKYM4S.js → chunk-VFR5R7GS.js} +2 -2
  31. package/dist/chunk-VQM22EFM.js +2 -0
  32. package/dist/{chunk-V4X62BBS.js.map → chunk-VQM22EFM.js.map} +1 -1
  33. package/dist/{chunk-ZHGFPGWR.js → chunk-WBL23WGD.js} +2 -2
  34. package/dist/{chunk-5KX664N7.js → chunk-Y3HI42AP.js} +2 -2
  35. package/dist/{chunk-2XVOKTPC.js → chunk-YMOTYFSL.js} +2 -2
  36. package/dist/chunk-YYFIIPLI.js +2 -0
  37. package/dist/{chunk-GATKVXGB.js.map → chunk-YYFIIPLI.js.map} +1 -1
  38. package/dist/chunk-Z7WBY27D.js +2 -0
  39. package/dist/chunk-Z7WBY27D.js.map +1 -0
  40. package/dist/chunk-ZKALTI3E.js +2 -0
  41. package/dist/{chunk-OZCFRM4R.js.map → chunk-ZKALTI3E.js.map} +1 -1
  42. package/dist/flows/ContractAmendment/ContractAmendmentConfirmationForm.d.ts +1 -1
  43. package/dist/flows/ContractAmendment/ContractAmendmentConfirmationForm.js +1 -1
  44. package/dist/flows/ContractAmendment/ContractAmendmentFlow.d.ts +1 -1
  45. package/dist/flows/ContractAmendment/ContractAmendmentFlow.js +1 -1
  46. package/dist/flows/ContractAmendment/ContractAmendmentForm.d.ts +1 -1
  47. package/dist/flows/ContractAmendment/ContractAmendmentForm.js +1 -1
  48. package/dist/flows/ContractAmendment/context.d.ts +1 -1
  49. package/dist/flows/ContractAmendment/hooks.d.ts +1 -1
  50. package/dist/flows/ContractAmendment/hooks.js +1 -1
  51. package/dist/flows/ContractAmendment/index.d.ts +1 -1
  52. package/dist/flows/ContractAmendment/index.js +1 -1
  53. package/dist/flows/ContractAmendment/utils.d.ts +1 -1
  54. package/dist/flows/CostCalculator/CostCalculatorFlow.d.ts +1 -1
  55. package/dist/flows/CostCalculator/CostCalculatorFlow.js +1 -1
  56. package/dist/flows/CostCalculator/CostCalculatorForm.d.ts +1 -1
  57. package/dist/flows/CostCalculator/CostCalculatorForm.js +1 -1
  58. package/dist/flows/CostCalculator/Results/CostCalculatorResults.d.ts +1 -1
  59. package/dist/flows/CostCalculator/Results/CostCalculatorResults.js +1 -1
  60. package/dist/flows/CostCalculator/api.d.ts +1 -1
  61. package/dist/flows/CostCalculator/components/SalaryField.js +1 -1
  62. package/dist/flows/CostCalculator/context.d.ts +1 -1
  63. package/dist/flows/CostCalculator/hooks.d.ts +1 -1
  64. package/dist/flows/CostCalculator/hooks.js +1 -1
  65. package/dist/flows/CostCalculator/index.d.ts +1 -1
  66. package/dist/flows/CostCalculator/index.js +1 -1
  67. package/dist/flows/CostCalculator/types.d.ts +1 -1
  68. package/dist/flows/CostCalculator/utils.d.ts +1 -1
  69. package/dist/flows/CostCalculator/utils.js +1 -1
  70. package/dist/flows/Onboarding/OnboardingFlow.d.ts +1 -1
  71. package/dist/flows/Onboarding/OnboardingFlow.js +1 -1
  72. package/dist/flows/Onboarding/api.d.ts +1 -1
  73. package/dist/flows/Onboarding/components/AnnualGrossSalary.js +1 -1
  74. package/dist/flows/Onboarding/components/BasicInformationStep.d.ts +1 -1
  75. package/dist/flows/Onboarding/components/BasicInformationStep.js +1 -1
  76. package/dist/flows/Onboarding/components/BenefitsStep.d.ts +1 -1
  77. package/dist/flows/Onboarding/components/BenefitsStep.js +1 -1
  78. package/dist/flows/Onboarding/components/ContractDetailsStep.d.ts +1 -1
  79. package/dist/flows/Onboarding/components/ContractDetailsStep.js +1 -1
  80. package/dist/flows/Onboarding/components/OnboardingForm.d.ts +1 -1
  81. package/dist/flows/Onboarding/components/OnboardingForm.js +1 -1
  82. package/dist/flows/Onboarding/components/OnboardingInvite.d.ts +1 -1
  83. package/dist/flows/Onboarding/components/ReviewStep.d.ts +2 -1
  84. package/dist/flows/Onboarding/components/ReviewStep.js +1 -1
  85. package/dist/flows/Onboarding/components/SelectCountryStep.d.ts +1 -1
  86. package/dist/flows/Onboarding/components/SelectCountryStep.js +1 -1
  87. package/dist/flows/Onboarding/context.d.ts +2 -1
  88. package/dist/flows/Onboarding/hooks.d.ts +6 -1
  89. package/dist/flows/Onboarding/hooks.js +1 -1
  90. package/dist/flows/Onboarding/index.d.ts +1 -1
  91. package/dist/flows/Onboarding/index.js +1 -1
  92. package/dist/flows/Onboarding/types.d.ts +2 -2
  93. package/dist/flows/Onboarding/utils.d.ts +3 -2
  94. package/dist/flows/Onboarding/utils.js +1 -1
  95. package/dist/flows/Termination/AdditionalDetailsForm.d.ts +1 -1
  96. package/dist/flows/Termination/AdditionalDetailsForm.js +1 -1
  97. package/dist/flows/Termination/EmployeeComunicationForm.d.ts +1 -1
  98. package/dist/flows/Termination/EmployeeComunicationForm.js +1 -1
  99. package/dist/flows/Termination/PaidTimeOffForm.d.ts +1 -1
  100. package/dist/flows/Termination/PaidTimeOffForm.js +1 -1
  101. package/dist/flows/Termination/TerminationDetailsForm.d.ts +1 -1
  102. package/dist/flows/Termination/TerminationDetailsForm.js +1 -1
  103. package/dist/flows/Termination/TerminationFlow.d.ts +1 -1
  104. package/dist/flows/Termination/TerminationFlow.js +1 -1
  105. package/dist/flows/Termination/TerminationForm.d.ts +1 -1
  106. package/dist/flows/Termination/TerminationForm.js +1 -1
  107. package/dist/flows/Termination/TimeOff.d.ts +1 -1
  108. package/dist/flows/Termination/context.d.ts +1 -1
  109. package/dist/flows/Termination/hooks.d.ts +1 -1
  110. package/dist/flows/Termination/index.d.ts +1 -1
  111. package/dist/flows/Termination/index.js +1 -1
  112. package/dist/flows/Termination/types.d.ts +1 -1
  113. package/dist/index.d.ts +2 -2
  114. package/dist/index.js +1 -1
  115. package/dist/{types.gen-DSJsKiNm.d.ts → types.gen-uIYQx7Be.d.ts} +1 -1
  116. package/package.json +1 -1
  117. package/dist/chunk-52J6QK2N.js +0 -2
  118. package/dist/chunk-52J6QK2N.js.map +0 -1
  119. package/dist/chunk-CCJOYSVQ.js +0 -2
  120. package/dist/chunk-CCJOYSVQ.js.map +0 -1
  121. package/dist/chunk-CM7ZXKYC.js +0 -2
  122. package/dist/chunk-GATKVXGB.js +0 -2
  123. package/dist/chunk-GVDARE4K.js +0 -2
  124. package/dist/chunk-GVDARE4K.js.map +0 -1
  125. package/dist/chunk-KFVOK5X5.js +0 -2
  126. package/dist/chunk-KFVOK5X5.js.map +0 -1
  127. package/dist/chunk-OZCFRM4R.js +0 -2
  128. package/dist/chunk-SG67NZYI.js +0 -2
  129. package/dist/chunk-TQNMLD3A.js +0 -2
  130. package/dist/chunk-V4X62BBS.js +0 -2
  131. package/dist/chunk-Y6K2UK3D.js +0 -2
  132. package/dist/chunk-Y6K2UK3D.js.map +0 -1
  133. /package/dist/{chunk-IKJFPDZL.js.map → chunk-2YGGLGBG.js.map} +0 -0
  134. /package/dist/{chunk-RNR4JEHX.js.map → chunk-3AOOE4V2.js.map} +0 -0
  135. /package/dist/{chunk-6ACGE24H.js.map → chunk-42M5XC23.js.map} +0 -0
  136. /package/dist/{chunk-QJWVOD4K.js.map → chunk-4OWFS6J6.js.map} +0 -0
  137. /package/dist/{chunk-BLVS2A23.js.map → chunk-B4UHZS6S.js.map} +0 -0
  138. /package/dist/{chunk-L6CLZL2D.js.map → chunk-DIL47M74.js.map} +0 -0
  139. /package/dist/{chunk-M6ZWJ7KV.js.map → chunk-GPPJCUV6.js.map} +0 -0
  140. /package/dist/{chunk-KT6EAWZO.js.map → chunk-HVZOU73K.js.map} +0 -0
  141. /package/dist/{chunk-CK2Y7YLV.js.map → chunk-LRCSXZ5Y.js.map} +0 -0
  142. /package/dist/{chunk-PJ6EQF5M.js.map → chunk-RMFW7BZM.js.map} +0 -0
  143. /package/dist/{chunk-BIXYNFMY.js.map → chunk-S2VTL2TR.js.map} +0 -0
  144. /package/dist/{chunk-G7ELSCK7.js.map → chunk-S4WAMYEE.js.map} +0 -0
  145. /package/dist/{chunk-SX5W3CBP.js.map → chunk-T3HJ2JSB.js.map} +0 -0
  146. /package/dist/{chunk-HHMKYM4S.js.map → chunk-VFR5R7GS.js.map} +0 -0
  147. /package/dist/{chunk-ZHGFPGWR.js.map → chunk-WBL23WGD.js.map} +0 -0
  148. /package/dist/{chunk-5KX664N7.js.map → chunk-Y3HI42AP.js.map} +0 -0
  149. /package/dist/{chunk-2XVOKTPC.js.map → chunk-YMOTYFSL.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/form/fields/TextField.tsx","../src/components/ui/input.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport * as React from 'react';\n\nimport { useFormFields } from '@/src/context';\nimport { Components, JSFField } from '@/src/types/remoteFlows';\nimport { useFormContext } from 'react-hook-form';\nimport {\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from '../../ui/form';\nimport { Input } from '../../ui/input';\n\nexport type TextFieldProps = React.ComponentProps<'input'> & {\n name: string;\n} & Partial<\n JSFField & {\n onChange?: (value: any) => void;\n component?: Components['text'];\n includeErrorMessage?: boolean;\n additionalProps?: Record<string, unknown>;\n }\n >;\n\nexport function TextField({\n name,\n description,\n label,\n type,\n onChange,\n component,\n includeErrorMessage = true,\n additionalProps = {},\n maxLength,\n ...rest\n}: TextFieldProps) {\n const { components } = useFormFields();\n const { control } = useFormContext();\n\n return (\n <FormField\n control={control}\n name={name}\n render={({ field, fieldState }) => {\n const CustomTextField = component || components?.text;\n if (CustomTextField) {\n const customTextFieldProps = {\n name,\n description,\n label,\n type,\n onChange,\n metadata: additionalProps,\n maxLength,\n ...rest,\n };\n return (\n <CustomTextField\n field={{\n ...field,\n onChange: (value: any) => {\n field.onChange(value);\n onChange?.(value);\n },\n }}\n fieldState={fieldState}\n fieldData={customTextFieldProps}\n />\n );\n }\n\n return (\n <FormItem\n data-field={name}\n className={`RemoteFlows__TextField__Item__${name}`}\n >\n {label && (\n <FormLabel className=\"RemoteFlows__TextField__Label\">\n {label}\n </FormLabel>\n )}\n <FormControl>\n <Input\n {...field}\n value={field.value ?? ''}\n onChange={(event: React.ChangeEvent<HTMLInputElement>) => {\n field.onChange(event);\n onChange?.(event);\n }}\n className=\"RemoteFlows__TextField__Input\"\n placeholder={label}\n maxLength={maxLength}\n />\n </FormControl>\n {description && (\n <FormDescription className=\"RemoteFlows__TextField__Description\">\n {description}\n </FormDescription>\n )}\n {includeErrorMessage && fieldState.error && (\n <FormMessage className=\"RemoteFlows__TextField__Error\" />\n )}\n </FormItem>\n );\n }}\n />\n );\n}\n","import * as React from 'react';\n\nimport { cn } from '@/src/lib/utils';\n\nfunction Input({ className, type, ...props }: React.ComponentProps<'input'>) {\n return (\n <input\n type={type}\n data-slot=\"input\"\n className={cn(\n 'shadow-xs border-input file:text-foreground placeholder:text-muted-foreground flex h-9 w-full min-w-0 rounded-xl border bg-transparent px-4 py-7 text-sm transition-[color] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',\n 'focus-visible:border-focused',\n 'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Input };\n"],"mappings":"mMAKA,OAAS,kBAAAA,MAAsB,kBCC3B,cAAAC,MAAA,oBAFJ,SAASC,EAAM,CAAE,UAAAC,EAAW,KAAAC,EAAM,GAAGC,CAAM,EAAkC,CAC3E,OACEJ,EAAC,SACC,KAAMG,EACN,YAAU,QACV,UAAWE,EACT,6WACA,+BACA,yGACAH,CACF,EACC,GAAGE,EACN,CAEJ,CAdSE,EAAAL,EAAA,SDwDG,cAAAM,EAeF,QA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J,CAnFgBR,EAAApB,EAAA","names":["useFormContext","jsx","Input","className","type","props","cn","__name","jsx","jsxs","TextField","name","description","label","type","onChange","component","includeErrorMessage","additionalProps","maxLength","rest","components","useFormFields","control","useFormContext","FormField","field","fieldState","CustomTextField","customTextFieldProps","__name","value","FormItem","FormLabel","FormControl","Input","event","FormDescription","FormMessage"]}
@@ -1,2 +0,0 @@
1
- import{a as Ve}from"./chunk-IKJFPDZL.js";import{a as Fe,b as Ee,c as h,d as he}from"./chunk-XIPPSRO6.js";import{a as le,b as me,c as de,f as fe,g as ue,h as ye,i as pe,j as _e,l as Se,n as be}from"./chunk-X36OBDKD.js";import{a as w}from"./chunk-QW4JPW6J.js";import{a as ge}from"./chunk-PJBAQZ6G.js";import{c as E,d as M,f as q}from"./chunk-CNYSTJVL.js";import{a as c}from"./chunk-P37U34EQ.js";import{useEffect as Ye,useMemo as l,useRef as Qe,useState as Oe}from"react";import Xe from"lodash.mergewith";import{jsx as tt}from"react/jsx-runtime";var Ze={employment_basic_information:"basic_information",contract_details:"contract_details"},$e={select_country:null,basic_information:"employment_basic_information",contract_details:"contract_details",benefits:null,review:null},et=c(({isLoadingBasicInformationForm:f,isLoadingContractDetailsForm:R,isLoadingEmployment:j,isLoadingBenefitsOffersSchema:v,isLoadingBenefitOffers:a,isLoadingCompany:N,isLoadingCountries:y,employmentStatus:o,employmentId:J,currentStepName:s,basicInformationFields:T,contractDetailsFields:i})=>{let V=f||R||j||v||a||N||y,k=o&&he.includes(o),O=!!(J&&k&&s!=="review"),I=V||O,p=!!(O&&!V&&T.length>0&&i.length>0);return{isLoading:I,isNavigatingToReview:p,isEmploymentReadOnly:k}},"getLoadingStates"),dt=c(({employmentId:f,companyId:R,countryCode:j,type:v,options:a,skipSteps:N})=>{let y=Qe({select_country:{},basic_information:{},contract_details:{},benefits:{}}),[o,J]=Oe(f),[s,T]=Oe(j||null),{data:i,isLoading:V,refetch:k}=le(o);i?.country?.code&&s!==i.country.code&&T(i.country.code);let{data:O,isLoading:I}=de(o),{data:p,isLoading:U,refetch:Ce}=me(R),Pe=N?.includes("select_country")?Ee:Fe,{fieldValues:_,stepState:t,setFieldValues:Le,previousStep:Me,nextStep:Te,goToStep:A,setStepValues:x}=ge(Pe),{selectCountryForm:B,isLoading:H}=Se({jsfModify:a?.jsfModify?.select_country,jsonSchemaVersion:a?.jsonSchemaVersion,queryOptions:{enabled:t.currentStep.name==="select_country"}}),W=ye(a),G=pe(a),z=_e(a),ke=be(),{mutateAsync:Ie}=w(W),{mutateAsync:K}=w(G),{mutateAsync:Be}=w(z),we=$e[t.currentStep.name]||"employment_basic_information",Re=Ze[we],je=i?.[Re]||{},Y=c(({form:n,options:r={}})=>fe({countryCode:s,form:n,fieldValues:Object.keys(_).length>0?{...t.values?.[t.currentStep.name],..._}:je,options:{...r,queryOptions:{enabled:r.queryOptions?.enabled??!0}}}),"useJSONSchema"),ve=!!(s&&(t.currentStep.name==="basic_information"||f)),Ne=!!(s&&(t.currentStep.name==="contract_details"||f)),{data:m,isLoading:Q}=Y({form:"employment_basic_information",options:{jsfModify:a?.jsfModify?.basic_information,queryOptions:{enabled:ve}}}),S=a?.jsfModify?.contract_details?.fields?.annual_gross_salary,D=S&&typeof S=="object"&&"presentation"in S?S.presentation:void 0,Je=l(()=>({fields:{annual_gross_salary:{...S,presentation:{annual_gross_salary_conversion_properties:{label:D?.annual_gross_salary_conversion_properties?.label,description:D?.annual_gross_salary_conversion_properties?.description},desiredCurrency:p?.desired_currency,Component:c(n=>tt(Ve,{desiredCurrency:p?.desired_currency||"",...n}),"Component")}}}}),[S,D,p?.desired_currency]),{data:d,isLoading:X}=Y({form:"contract_details",options:{jsfModify:{...a?.jsfModify?.contract_details,fields:{...a?.jsfModify?.contract_details?.fields,...Je.fields}},queryOptions:{enabled:Ne}}}),{data:C,isLoading:Z}=ue(o,_,a),$=l(()=>{if(t.currentStep.name==="benefits"){let n={...t.values?.[t.currentStep.name],..._};return Xe({},O,n)}return{}},[t.currentStep.name,O,t.values,_]),e=l(()=>({select_country:B?.fields||[],basic_information:m?.fields||[],contract_details:d?.fields||[],benefits:C?.fields||[],review:[]}),[B?.fields,m?.fields,d?.fields,C?.fields]),Ae={select_country:null,basic_information:m?.meta["x-jsf-fieldsets"],contract_details:d?.meta["x-jsf-fieldsets"],benefits:null,review:null},{country:{code:ee}={},basic_information:te={},contract_details:ne={},status:oe}=i||{},ie=t.currentStep.name,b=l(()=>M(e.select_country,{country:s||ee||""}),[e.select_country,s,ee]),g=l(()=>M(e.basic_information,te||{}),[e.basic_information,te]),u=l(()=>M(e.contract_details,ne||{}),[e.contract_details,ne]),F=l(()=>M(e.benefits,$),[e.benefits,$]),De=l(()=>i?{select_country:b,basic_information:q(e.basic_information,g),contract_details:i?.contract_details!==null?q(e.contract_details,u):u,benefits:F}:{select_country:b,basic_information:g,contract_details:u,benefits:F},[b,g,u,F,i,e]),{isLoading:qe,isNavigatingToReview:ae,isEmploymentReadOnly:Ue}=l(()=>et({isLoadingBasicInformationForm:Q,isLoadingContractDetailsForm:X,isLoadingEmployment:V,isLoadingBenefitsOffersSchema:Z,isLoadingBenefitOffers:I,isLoadingCompany:U,isLoadingCountries:H,employmentId:f,employmentStatus:oe,basicInformationFields:e.basic_information,contractDetailsFields:e.contract_details,currentStepName:ie}),[Q,X,V,Z,I,U,H,f,oe,e.basic_information,e.contract_details,ie]);Ye(()=>{ae&&(y.current={select_country:h(b,e.select_country),basic_information:h(g,e.basic_information),contract_details:h(u,e.contract_details),benefits:h(F,e.benefits)},x({select_country:b,basic_information:g,contract_details:u,benefits:F,review:{}}),A("review"))},[g,F,u,A,ae,b,x,e.basic_information,e.benefits,e.contract_details,e.select_country]);let se=c(n=>B&&t.currentStep.name==="select_country"?n:m&&t.currentStep.name==="basic_information"?E(n,m?.fields,{isPartialValidation:!1}):d&&t.currentStep.name==="contract_details"?E(n,d?.fields,{isPartialValidation:!1}):{},"parseFormValues");async function xe(n){let r=t.currentStep.name;r in y.current&&(y.current[r]=h(n,e[r]));let P=se(n);switch(Ce(),t.currentStep.name){case"select_country":return T(P.country),Promise.resolve({data:{countryCode:P.country}});case"basic_information":{let re=!o&&s,ze=o&&s&&i?.country&&i?.country.code!==s;if(re||ze){let Ke={basic_information:P,type:v,country_code:s};try{let L=await Ie(Ke),ce=L.data?.data?.employment?.id;return J(ce),await ke.mutateAsync({employmentId:ce,eligible_to_work_in_residing_country:"citizen",employer_or_work_restrictions:!1}),L}catch(L){throw console.error("Error creating onboarding:",L),L}}else if(o)return K({employmentId:o,basic_information:P,pricing_plan_details:{frequency:"monthly"}});return}case"contract_details":return K({employmentId:o,...{contract_details:P,pricing_plan_details:{frequency:"monthly"}}});case"benefits":return Be({employmentId:o,...n})}}c(xe,"onSubmit");function He(){Me()}c(He,"back");function We(){Te()}c(We,"next");function Ge(n){A(n)}return c(Ge,"goTo"),{employmentId:o,creditRiskStatus:p?.default_legal_entity_credit_risk_status,fieldValues:_,stepState:t,fields:e[t.currentStep.name],isLoading:qe,isSubmitting:W.isPending||G.isPending||z.isPending,initialValues:De,handleValidation:c(n=>{if(t.currentStep.name==="select_country")return B.handleValidation(n);if(t.currentStep.name==="benefits"&&C){let r=E(n,C?.fields,{isPartialValidation:!1});return C?.handleValidation(r)}if(m&&t.currentStep.name==="basic_information"){let r=E(n,m?.fields,{isPartialValidation:!1});return m?.handleValidation(r)}if(d&&t.currentStep.name==="contract_details"){let r=E(n,d?.fields,{isPartialValidation:!1});return d?.handleValidation(r)}return null},"handleValidation"),checkFieldUpdates:Le,parseFormValues:se,onSubmit:xe,back:He,next:We,goTo:Ge,meta:{fields:y.current,fieldsets:Ae[t.currentStep.name]},refetchEmployment:k,employment:i,isEmploymentReadOnly:Ue}},"useOnboarding");export{dt as a};
2
- //# sourceMappingURL=chunk-CCJOYSVQ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/flows/Onboarding/hooks.tsx"],"sourcesContent":["import {\n Employment,\n EmploymentCreateParams,\n EmploymentFullParams,\n} from '@/src/client';\nimport { Fields } from '@remoteoss/json-schema-form';\n\nimport { useStepState, Step } from '@/src/flows/useStepState';\nimport {\n prettifyFormValues,\n reviewStepAllowedEmploymentStatus,\n STEPS,\n STEPS_WITHOUT_SELECT_COUNTRY,\n} from '@/src/flows/Onboarding/utils';\nimport {\n getInitialValues,\n enableAckFields,\n parseJSFToValidate,\n} from '@/src/components/form/utils';\nimport { mutationToPromise } from '@/src/lib/mutations';\nimport { FieldValues } from 'react-hook-form';\nimport { Meta, OnboardingFlowParams } from '@/src/flows/Onboarding/types';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport mergeWith from 'lodash.mergewith';\nimport {\n useBenefitOffers,\n useBenefitOffersSchema,\n useCompany,\n useCountriesSchemaField,\n useCreateEmployment,\n useEmployment,\n useJSONSchemaForm,\n useUpdateBenefitsOffers,\n useUpdateEmployment,\n useUpsertContractEligibility,\n} from '@/src/flows/Onboarding/api';\nimport { JSFModify, JSONSchemaFormType } from '@/src/flows/types';\nimport { AnnualGrossSalary } from '@/src/flows/Onboarding/components/AnnualGrossSalary';\nimport { JSFField, JSFFieldset } from '@/src/types/remoteFlows';\n\ntype OnboardingHookProps = OnboardingFlowParams;\n\nconst jsonSchemaToEmployment: Partial<\n Record<JSONSchemaFormType, keyof Employment>\n> = {\n employment_basic_information: 'basic_information',\n contract_details: 'contract_details',\n};\n\nconst stepToFormSchemaMap: Record<\n keyof typeof STEPS,\n JSONSchemaFormType | null\n> = {\n select_country: null,\n basic_information: 'employment_basic_information',\n contract_details: 'contract_details',\n benefits: null,\n review: null,\n};\n\nconst getLoadingStates = ({\n isLoadingBasicInformationForm,\n isLoadingContractDetailsForm,\n isLoadingEmployment,\n isLoadingBenefitsOffersSchema,\n isLoadingBenefitOffers,\n isLoadingCompany,\n isLoadingCountries,\n employmentStatus,\n employmentId,\n currentStepName,\n basicInformationFields,\n contractDetailsFields,\n}: {\n isLoadingBasicInformationForm: boolean;\n isLoadingContractDetailsForm: boolean;\n isLoadingEmployment: boolean;\n isLoadingBenefitsOffersSchema: boolean;\n isLoadingBenefitOffers: boolean;\n isLoadingCompany: boolean;\n isLoadingCountries: boolean;\n employmentStatus?: Employment['status'];\n employmentId?: string;\n currentStepName: string;\n basicInformationFields: Fields;\n contractDetailsFields: Fields;\n}) => {\n const initialLoading =\n isLoadingBasicInformationForm ||\n isLoadingContractDetailsForm ||\n isLoadingEmployment ||\n isLoadingBenefitsOffersSchema ||\n isLoadingBenefitOffers ||\n isLoadingCompany ||\n isLoadingCountries;\n\n const isEmploymentReadOnly =\n employmentStatus &&\n reviewStepAllowedEmploymentStatus.includes(employmentStatus);\n\n const shouldHandleReadOnlyEmployment = Boolean(\n employmentId && isEmploymentReadOnly && currentStepName !== 'review',\n );\n\n const isLoading = initialLoading || shouldHandleReadOnlyEmployment;\n\n const isNavigatingToReview = Boolean(\n shouldHandleReadOnlyEmployment &&\n !initialLoading &&\n basicInformationFields.length > 0 &&\n contractDetailsFields.length > 0,\n );\n\n return { isLoading, isNavigatingToReview, isEmploymentReadOnly };\n};\n\nexport const useOnboarding = ({\n employmentId,\n companyId,\n countryCode,\n type,\n options,\n skipSteps,\n}: OnboardingHookProps) => {\n const fieldsMetaRef = useRef<{\n select_country: Meta;\n basic_information: Meta;\n contract_details: Meta;\n benefits: Meta;\n }>({\n select_country: {},\n basic_information: {},\n contract_details: {},\n benefits: {},\n });\n const [internalEmploymentId, setInternalEmploymentId] = useState<\n string | undefined\n >(employmentId);\n const [internalCountryCode, setInternalCountryCode] = useState<string | null>(\n countryCode || null,\n );\n const {\n data: employment,\n isLoading: isLoadingEmployment,\n refetch: refetchEmployment,\n } = useEmployment(internalEmploymentId);\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 (\n employment?.country?.code &&\n internalCountryCode !== employment.country.code\n ) {\n setInternalCountryCode(employment.country.code);\n }\n\n const { data: benefitOffers, isLoading: isLoadingBenefitOffers } =\n useBenefitOffers(internalEmploymentId);\n const {\n data: company,\n isLoading: isLoadingCompany,\n refetch: refetchCompany,\n } = useCompany(companyId);\n const stepsToUse = skipSteps?.includes('select_country')\n ? STEPS_WITHOUT_SELECT_COUNTRY\n : STEPS;\n\n const {\n fieldValues,\n stepState,\n setFieldValues,\n previousStep,\n nextStep,\n goToStep,\n setStepValues,\n } = useStepState(\n stepsToUse as Record<keyof typeof STEPS, Step<keyof typeof STEPS>>,\n );\n\n const { selectCountryForm, isLoading: isLoadingCountries } =\n useCountriesSchemaField({\n jsfModify: options?.jsfModify?.select_country,\n jsonSchemaVersion: options?.jsonSchemaVersion,\n queryOptions: {\n enabled: stepState.currentStep.name === 'select_country',\n },\n });\n\n const createEmploymentMutation = useCreateEmployment(options);\n const updateEmploymentMutation = useUpdateEmployment(options);\n const updateBenefitsOffersMutation = useUpdateBenefitsOffers(options);\n const updateContractEligibilityMutation = useUpsertContractEligibility();\n const { mutateAsync: createEmploymentMutationAsync } = mutationToPromise(\n createEmploymentMutation,\n );\n const { mutateAsync: updateEmploymentMutationAsync } = mutationToPromise(\n updateEmploymentMutation,\n );\n const { mutateAsync: updateBenefitsOffersMutationAsync } = mutationToPromise(\n updateBenefitsOffersMutation,\n );\n\n const formType =\n stepToFormSchemaMap[stepState.currentStep.name] ||\n 'employment_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 }: {\n form: JSONSchemaFormType;\n options?: {\n jsfModify?: JSFModify;\n queryOptions?: { enabled?: boolean };\n };\n }) => {\n return useJSONSchemaForm({\n countryCode: internalCountryCode as string,\n form: form,\n fieldValues:\n Object.keys(fieldValues).length > 0\n ? {\n ...stepState.values?.[stepState.currentStep.name], // Restore values for the current step\n ...fieldValues,\n }\n : serverEmploymentData,\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 isContractDetailsEnabled = Boolean(\n internalCountryCode &&\n (stepState.currentStep.name === 'contract_details' ||\n Boolean(employmentId)),\n );\n\n const {\n data: basicInformationForm,\n isLoading: isLoadingBasicInformationForm,\n } = useJSONSchema({\n form: 'employment_basic_information',\n options: {\n jsfModify: options?.jsfModify?.basic_information,\n queryOptions: {\n enabled: isBasicInformationDetailsEnabled,\n },\n },\n });\n\n const annualGrossSalaryField =\n options?.jsfModify?.contract_details?.fields?.annual_gross_salary;\n const annualSalaryFieldPresentation =\n annualGrossSalaryField &&\n typeof annualGrossSalaryField === 'object' &&\n 'presentation' in annualGrossSalaryField\n ? (\n annualGrossSalaryField as {\n presentation?: {\n annual_gross_salary_conversion_properties?: {\n label?: string;\n description?: string;\n };\n };\n }\n ).presentation\n : undefined;\n\n const customFields = useMemo(\n () => ({\n fields: {\n annual_gross_salary: {\n ...annualGrossSalaryField,\n presentation: {\n annual_gross_salary_conversion_properties: {\n label:\n annualSalaryFieldPresentation\n ?.annual_gross_salary_conversion_properties?.label,\n description:\n annualSalaryFieldPresentation\n ?.annual_gross_salary_conversion_properties?.description,\n },\n desiredCurrency: company?.desired_currency,\n Component: (props: JSFField & { currency: string }) => {\n return (\n <AnnualGrossSalary\n desiredCurrency={company?.desired_currency || ''}\n {...props}\n />\n );\n },\n },\n },\n },\n }),\n [\n annualGrossSalaryField,\n annualSalaryFieldPresentation,\n company?.desired_currency,\n ],\n );\n\n const { data: contractDetailsForm, isLoading: isLoadingContractDetailsForm } =\n useJSONSchema({\n form: 'contract_details',\n options: {\n jsfModify: {\n ...options?.jsfModify?.contract_details,\n fields: {\n ...options?.jsfModify?.contract_details?.fields,\n ...customFields.fields,\n },\n },\n queryOptions: {\n enabled: isContractDetailsEnabled,\n },\n },\n });\n\n const {\n data: benefitOffersSchema,\n isLoading: isLoadingBenefitsOffersSchema,\n } = useBenefitOffersSchema(\n internalEmploymentId as string,\n fieldValues,\n options,\n );\n\n const initialValuesBenefitOffers = useMemo(() => {\n if (stepState.currentStep.name === 'benefits') {\n const benefitsFormValues = {\n ...stepState.values?.[stepState.currentStep.name as keyof typeof STEPS], // Restore values for the current step\n ...fieldValues,\n };\n return mergeWith({}, benefitOffers, benefitsFormValues);\n }\n return {};\n }, [\n stepState.currentStep.name,\n benefitOffers,\n stepState.values,\n fieldValues,\n ]);\n\n const stepFields: Record<keyof typeof STEPS, Fields> = useMemo(\n () => ({\n select_country: selectCountryForm?.fields || [],\n basic_information: basicInformationForm?.fields || [],\n contract_details: contractDetailsForm?.fields || [],\n benefits: benefitOffersSchema?.fields || [],\n review: [],\n }),\n [\n selectCountryForm?.fields,\n basicInformationForm?.fields,\n contractDetailsForm?.fields,\n benefitOffersSchema?.fields,\n ],\n );\n\n const stepFieldsWithFlatFieldsets: Record<\n keyof typeof STEPS,\n JSFFieldset | null | undefined\n > = {\n select_country: null,\n basic_information: basicInformationForm?.meta['x-jsf-fieldsets'],\n contract_details: contractDetailsForm?.meta['x-jsf-fieldsets'],\n benefits: null,\n review: null,\n };\n\n const {\n country: { code: employmentCountryCode } = {},\n basic_information: employmentBasicInformation = {},\n contract_details: employmentContractDetails = {},\n status: employmentStatus,\n } = employment || {};\n const currentStepName = stepState.currentStep.name;\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 const basicInformationInitialValues = useMemo(\n () =>\n getInitialValues(\n stepFields.basic_information,\n employmentBasicInformation || {},\n ),\n [stepFields.basic_information, employmentBasicInformation],\n );\n\n const contractDetailsInitialValues = useMemo(\n () =>\n getInitialValues(\n stepFields.contract_details,\n employmentContractDetails || {},\n ),\n [stepFields.contract_details, employmentContractDetails],\n );\n\n const benefitsInitialValues = useMemo(\n () => getInitialValues(stepFields.benefits, initialValuesBenefitOffers),\n [stepFields.benefits, initialValuesBenefitOffers],\n );\n\n const initialValues = useMemo(() => {\n if (employment) {\n return {\n select_country: selectCountryInitialValues,\n // We don't store ack fields in the db, eg \"ack_start_date_ammendment\" for Argentina, and therefore is not returned in the employment response\n // So when an employmentId exists, it means that the user has already started the onboarding process, and we need to enable the ack fields\n basic_information: enableAckFields(\n stepFields['basic_information'],\n basicInformationInitialValues,\n ),\n contract_details:\n // if contract details is null, it means it has not been filled yet, so we can't enable the ack fields\n employment?.contract_details !== null\n ? enableAckFields(\n stepFields['contract_details'],\n contractDetailsInitialValues,\n )\n : contractDetailsInitialValues,\n benefits: benefitsInitialValues,\n };\n }\n return {\n select_country: selectCountryInitialValues,\n basic_information: basicInformationInitialValues,\n contract_details: contractDetailsInitialValues,\n benefits: benefitsInitialValues,\n };\n }, [\n selectCountryInitialValues,\n basicInformationInitialValues,\n contractDetailsInitialValues,\n benefitsInitialValues,\n employment,\n stepFields,\n ]);\n\n const { isLoading, isNavigatingToReview, isEmploymentReadOnly } = useMemo(\n () =>\n getLoadingStates({\n isLoadingBasicInformationForm,\n isLoadingContractDetailsForm,\n isLoadingEmployment,\n isLoadingBenefitsOffersSchema,\n isLoadingBenefitOffers,\n isLoadingCompany,\n isLoadingCountries,\n employmentId,\n employmentStatus: employmentStatus,\n basicInformationFields: stepFields.basic_information,\n contractDetailsFields: stepFields.contract_details,\n currentStepName: currentStepName,\n }),\n [\n isLoadingBasicInformationForm,\n isLoadingContractDetailsForm,\n isLoadingEmployment,\n isLoadingBenefitsOffersSchema,\n isLoadingBenefitOffers,\n isLoadingCompany,\n isLoadingCountries,\n employmentId,\n employmentStatus,\n stepFields.basic_information,\n stepFields.contract_details,\n currentStepName,\n ],\n );\n\n useEffect(() => {\n if (isNavigatingToReview) {\n fieldsMetaRef.current = {\n select_country: prettifyFormValues(\n selectCountryInitialValues,\n stepFields.select_country,\n ),\n basic_information: prettifyFormValues(\n basicInformationInitialValues,\n stepFields.basic_information,\n ),\n contract_details: prettifyFormValues(\n contractDetailsInitialValues,\n stepFields.contract_details,\n ),\n benefits: prettifyFormValues(\n benefitsInitialValues,\n stepFields.benefits,\n ),\n };\n\n setStepValues({\n select_country: selectCountryInitialValues,\n basic_information: basicInformationInitialValues,\n contract_details: contractDetailsInitialValues,\n benefits: benefitsInitialValues,\n review: {},\n });\n\n goToStep('review');\n }\n }, [\n basicInformationInitialValues,\n benefitsInitialValues,\n contractDetailsInitialValues,\n goToStep,\n isNavigatingToReview,\n selectCountryInitialValues,\n setStepValues,\n stepFields.basic_information,\n stepFields.benefits,\n stepFields.contract_details,\n stepFields.select_country,\n ]);\n\n const parseFormValues = (values: FieldValues) => {\n if (selectCountryForm && stepState.currentStep.name === 'select_country') {\n return values;\n }\n if (\n basicInformationForm &&\n stepState.currentStep.name === 'basic_information'\n ) {\n return parseJSFToValidate(values, basicInformationForm?.fields, {\n isPartialValidation: false,\n });\n }\n\n if (\n contractDetailsForm &&\n stepState.currentStep.name === 'contract_details'\n ) {\n return parseJSFToValidate(values, contractDetailsForm?.fields, {\n isPartialValidation: false,\n });\n }\n\n return {};\n };\n\n async function onSubmit(values: FieldValues) {\n // Prettify values for the current step\n const currentStepName = stepState.currentStep.name;\n if (currentStepName in fieldsMetaRef.current) {\n fieldsMetaRef.current[\n currentStepName as keyof typeof fieldsMetaRef.current\n ] = prettifyFormValues(values, stepFields[currentStepName]);\n }\n\n const parsedValues = parseFormValues(values);\n refetchCompany();\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 if (isEmploymentNotLoaded || hasChangedCountry) {\n const payload: EmploymentCreateParams = {\n basic_information: parsedValues,\n type: type,\n country_code: internalCountryCode,\n };\n try {\n const response = await createEmploymentMutationAsync(payload);\n // @ts-expect-error the types from the response are not matching\n const employmentId = response.data?.data?.employment?.id;\n setInternalEmploymentId(employmentId);\n await updateContractEligibilityMutation.mutateAsync({\n employmentId: employmentId,\n eligible_to_work_in_residing_country: 'citizen',\n employer_or_work_restrictions: false,\n });\n\n return response;\n } catch (error) {\n console.error('Error creating onboarding:', error);\n throw error;\n }\n } else if (internalEmploymentId) {\n return updateEmploymentMutationAsync({\n employmentId: internalEmploymentId,\n basic_information: parsedValues,\n pricing_plan_details: {\n frequency: 'monthly',\n },\n });\n }\n\n return;\n }\n case 'contract_details': {\n const payload: EmploymentFullParams = {\n contract_details: parsedValues,\n pricing_plan_details: {\n frequency: 'monthly',\n },\n };\n return updateEmploymentMutationAsync({\n employmentId: internalEmploymentId as string,\n ...payload,\n });\n }\n\n case 'benefits': {\n return updateBenefitsOffersMutationAsync({\n employmentId: internalEmploymentId as string,\n ...values,\n });\n }\n }\n return;\n }\n\n function back() {\n previousStep();\n }\n\n function next() {\n nextStep();\n }\n\n function goTo(step: keyof typeof STEPS) {\n goToStep(step);\n }\n\n return {\n /**\n * Employment id passed useful to be used between components\n */\n employmentId: internalEmploymentId,\n\n /**\n * Credit risk status of the company, useful to know what to to show in the review step\n * The possible values are:\n * - not_started\n * - ready\n * - in_progress\n * - referred\n * - fail\n * - deposit_required\n * - no_deposit_required\n */\n\n creditRiskStatus: company?.default_legal_entity_credit_risk_status,\n /**\n * Current state of the form fields for the current step.\n */\n fieldValues,\n /**\n * Current step state containing the current step and total number of steps\n */\n stepState,\n /**\n * Array of form fields from the onboarding schema\n */\n fields: stepFields[stepState.currentStep.name],\n /**\n * Loading state indicating if the onboarding schema is being fetched\n */\n isLoading: isLoading,\n /**\n * Loading state indicating if the onboarding mutation is in progress\n */\n isSubmitting:\n createEmploymentMutation.isPending ||\n updateEmploymentMutation.isPending ||\n updateBenefitsOffersMutation.isPending,\n /**\n * Initial form values\n */\n initialValues,\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: (values: FieldValues) => {\n if (stepState.currentStep.name === 'select_country') {\n return selectCountryForm.handleValidation(values);\n }\n if (stepState.currentStep.name === 'benefits' && benefitOffersSchema) {\n const parsedValues = parseJSFToValidate(\n values,\n benefitOffersSchema?.fields,\n { isPartialValidation: false },\n );\n\n return benefitOffersSchema?.handleValidation(parsedValues);\n }\n if (\n basicInformationForm &&\n stepState.currentStep.name === 'basic_information'\n ) {\n const parsedValues = parseJSFToValidate(\n values,\n basicInformationForm?.fields,\n { isPartialValidation: false },\n );\n return basicInformationForm?.handleValidation(parsedValues);\n }\n\n if (\n contractDetailsForm &&\n stepState.currentStep.name === 'contract_details'\n ) {\n const parsedValues = parseJSFToValidate(\n values,\n contractDetailsForm?.fields,\n { isPartialValidation: false },\n );\n return contractDetailsForm?.handleValidation(parsedValues);\n }\n\n return null;\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 parse form values before submission\n * @param values - Form values to parse\n * @returns Parsed form values\n */\n parseFormValues,\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 * Function to handle going back to the previous step\n * @returns {void}\n */\n back,\n\n /**\n * Function to handle going to the next step\n * @returns {void}\n */\n next,\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,\n\n /**\n * Fields metadata for each step\n */\n meta: {\n fields: fieldsMetaRef.current,\n fieldsets: stepFieldsWithFlatFieldsets[stepState.currentStep.name],\n },\n\n /**\n * Function to refetch the employment data\n * @returns {void}\n */\n refetchEmployment,\n /**\n * Employment data\n */\n employment,\n\n /**\n * let's the user know that the employment cannot be edited, happens when employment.status is invited, created_awaiting_reserve or created_reserve_paid\n * @returns {boolean}\n */\n isEmploymentReadOnly,\n };\n};\n"],"mappings":"yYAsBA,OAAS,aAA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,IAAI,CACnE,EAMA,kBAAAX,EAIA,WAAAD,EAMA,qBAAAlB,EACF,CACF,EArrB6B","names":["useEffect","useMemo","useRef","useState","mergeWith","jsx","jsonSchemaToEmployment","stepToFormSchemaMap","getLoadingStates","__name","isLoadingBasicInformationForm","isLoadingContractDetailsForm","isLoadingEmployment","isLoadingBenefitsOffersSchema","isLoadingBenefitOffers","isLoadingCompany","isLoadingCountries","employmentStatus","employmentId","currentStepName","basicInformationFields","contractDetailsFields","initialLoading","isEmploymentReadOnly","reviewStepAllowedEmploymentStatus","shouldHandleReadOnlyEmployment","isLoading","isNavigatingToReview","useOnboarding","companyId","countryCode","type","options","skipSteps","fieldsMetaRef","useRef","internalEmploymentId","setInternalEmploymentId","useState","internalCountryCode","setInternalCountryCode","employment","refetchEmployment","useEmployment","benefitOffers","useBenefitOffers","company","refetchCompany","useCompany","stepsToUse","STEPS_WITHOUT_SELECT_COUNTRY","STEPS","fieldValues","stepState","setFieldValues","previousStep","nextStep","goToStep","setStepValues","useStepState","selectCountryForm","useCountriesSchemaField","createEmploymentMutation","useCreateEmployment","updateEmploymentMutation","useUpdateEmployment","updateBenefitsOffersMutation","useUpdateBenefitsOffers","updateContractEligibilityMutation","useUpsertContractEligibility","createEmploymentMutationAsync","mutationToPromise","updateEmploymentMutationAsync","updateBenefitsOffersMutationAsync","formType","employmentKey","serverEmploymentData","useJSONSchema","form","jsonSchemaOptions","useJSONSchemaForm","isBasicInformationDetailsEnabled","isContractDetailsEnabled","basicInformationForm","annualGrossSalaryField","annualSalaryFieldPresentation","customFields","useMemo","props","AnnualGrossSalary","contractDetailsForm","benefitOffersSchema","useBenefitOffersSchema","initialValuesBenefitOffers","benefitsFormValues","mergeWith","stepFields","stepFieldsWithFlatFieldsets","employmentCountryCode","employmentBasicInformation","employmentContractDetails","selectCountryInitialValues","getInitialValues","basicInformationInitialValues","contractDetailsInitialValues","benefitsInitialValues","initialValues","enableAckFields","useEffect","prettifyFormValues","parseFormValues","values","parseJSFToValidate","onSubmit","parsedValues","isEmploymentNotLoaded","hasChangedCountry","payload","response","error","back","next","goTo","step"]}
@@ -1,2 +0,0 @@
1
- import{b as y}from"./chunk-PGWKJ6FK.js";import{b as u}from"./chunk-QW4JPW6J.js";import{a as F}from"./chunk-Y6K2UK3D.js";import{b as f}from"./chunk-CFIJKJXD.js";import{a as p}from"./chunk-GVDARE4K.js";import{a as m}from"./chunk-P37U34EQ.js";import{useEffect as b}from"react";import{useForm as O}from"react-hook-form";import{jsx as d}from"react/jsx-runtime";function N({defaultValues:l,onSubmit:S,components:g}){let{formId:E,onboardingBag:o}=y(),w=f(o.handleValidation),r=O({resolver:w,defaultValues:l,shouldUnregister:!1,mode:"onBlur"});b(()=>{o.employmentId&&o?.checkFieldUpdates(r.getValues())},[]),b(()=>{let t=r?.watch(e=>{Object.keys(e).some(i=>e[i]!==l[i])&&o?.checkFieldUpdates(e)});return()=>t?.unsubscribe()},[]);let h=m(async(t,e)=>{let s=e?.nativeEvent;if(s?.isDraftSubmission){let{onSuccess:i,onError:c}=s.draftCallbacks;try{if(!await r.trigger())return;let n=await o.onSubmit(t);if(n?.data)i?.();else if(n?.error){let k=o.stepState.currentStep.name,B=o.meta?.fields?.[k],P=u(n?.fieldErrors||[],B);c?.({error:n.error,rawError:n.rawError,fieldErrors:P})}}catch(a){c?.({error:a,rawError:a,fieldErrors:[]})}}else S(t)},"handleSubmit");return d(p,{...r,children:d("form",{id:E,onSubmit:r.handleSubmit(h),className:"space-y-4 RemoteFlows__OnboardingForm",children:d(F,{components:g,fields:o.fields,fieldsets:o.meta.fieldsets,fieldValues:o.fieldValues})})})}m(N,"OnboardingForm");export{N as a};
2
- //# sourceMappingURL=chunk-CM7ZXKYC.js.map
@@ -1,2 +0,0 @@
1
- import{a as p}from"./chunk-Y6K2UK3D.js";import{b as l}from"./chunk-CFIJKJXD.js";import{a as f}from"./chunk-GVDARE4K.js";import{c as u}from"./chunk-CNYSTJVL.js";import{b as F}from"./chunk-TVZAFTPT.js";import{a as r}from"./chunk-P37U34EQ.js";import{useEffect as P}from"react";import{useForm as R}from"react-hook-form";import{jsx as a}from"react/jsx-runtime";var w=["effective_date","reason_for_change","reason_for_change_description","additional_comments","additional_comments_toggle"];function x({onSubmit:_,onError:m,onSuccess:b}){let{formId:A,contractAmendment:{checkFieldUpdates:C,fields:s,onSubmit:h,stepState:S,initialValues:i,handleValidation:g}}=F(),y=l(g),e=R({resolver:y,defaultValues:S.values?.form||i,shouldUnregister:!0,mode:"onBlur"});P(()=>{let t=e?.watch(o=>{(Object.keys(e.formState.dirtyFields).length>0||e.formState.isDirty)&&C(o)});return()=>t?.unsubscribe()},[]);let V=r(async t=>{let o=!1;for(let[c,v]of Object.entries(t))if(!w.includes(c)&&i[c]!==v){o=!0;break}if(!o)return m?.({message:"no_changes_detected_contract_details"});let d=u(t,s,{isPartialValidation:!1});await _?.(d);let n=await h(t);n.error?m?.(n.error):await b?.(n.data)},"handleSubmit");return a(f,{...e,children:a("form",{id:A,"data-testid":"contract-amendment-form",onSubmit:e.handleSubmit(V),className:"space-y-4 RemoteFlows__ContractAmendmentForm",children:a(p,{fields:s})})})}r(x,"ContractAmendmentForm");export{x as a};
2
- //# sourceMappingURL=chunk-GATKVXGB.js.map
@@ -1,2 +0,0 @@
1
- import{a as s}from"./chunk-TC3SWPEN.js";import{a}from"./chunk-P37U34EQ.js";import{Slot as C}from"@radix-ui/react-slot";import*as i from"react";import c from"dompurify";import{Controller as b,FormProvider as R,useFormContext as g,useFormState as P}from"react-hook-form";import*as u from"@radix-ui/react-label";import{jsx as x}from"react/jsx-runtime";function f({className:e,...t}){return x(u.Root,{"data-slot":"label",className:s("flex items-center gap-2 text-sm leading-none select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50",e),...t})}a(f,"Label");import{jsx as n}from"react/jsx-runtime";var _=R,p=i.createContext({}),k=a(({...e})=>n(p.Provider,{value:{name:e.name},children:n(b,{...e})}),"FormField"),d=a(()=>{let e=i.useContext(p),t=i.useContext(F),{getFieldState:o}=g(),r=P({name:e.name}),m=o(e.name,r);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:l}=t;return{id:l,name:e.name,formItemId:`${l}-form-item`,formDescriptionId:`${l}-form-item-description`,formMessageId:`${l}-form-item-message`,...m}},"useFormField"),F=i.createContext({});function z({className:e,...t}){let o=i.useId();return n(F.Provider,{value:{id:o},children:n("div",{"data-slot":"form-item",...t,className:s("grid gap-2",e)})})}a(z,"FormItem");function H({className:e,...t}){let{error:o,formItemId:r}=d();return n(f,{"data-slot":"form-label","data-error":!!o,className:s("text-base-color mb-1 data-[error=true]:text-destructive",e),htmlFor:r,...t})}a(H,"FormLabel");var I=i.forwardRef(({...e},t)=>{let{error:o,formItemId:r,formDescriptionId:m,formMessageId:l}=d();return n(C,{"data-slot":"form-control",ref:t,id:r,"aria-describedby":o?`${m} ${l}`:`${m}`,"aria-invalid":!!o,...e})});I.displayName="FormControl";var V=a(e=>{let t=new Set(e?e.toLowerCase().split(" "):[]);return t.add("noopener"),t.add("noreferrer"),Array.from(t).join(" ")},"appendSecureRelValue");c.isSupported&&c.addHook("afterSanitizeAttributes",e=>{let t=e.getAttribute("target");if(e.tagName==="A"&&(!t||t!=="_self")){e.setAttribute("target","_blank");let o=e.getAttribute("rel");e.setAttribute("rel",V(o))}});function E({className:e,children:t,...o}){let{formDescriptionId:r}=d();return typeof t=="string"?n("p",{"data-slot":"form-description",id:r,className:s("text-base-color text-xs",e),dangerouslySetInnerHTML:{__html:c.sanitize(t,{ADD_ATTR:["target"]})},...o}):n("p",{"data-slot":"form-description",id:r,className:s("text-base-color text-xs",e),...o,children:typeof t=="function"?t():t})}a(E,"FormDescription");function O({className:e,...t}){let{error:o,formMessageId:r}=d(),m=o?String(o?.message??""):t.children;return m?n("p",{"data-slot":"form-message",id:r,className:s("text-destructive text-sm",e),...t,children:m}):null}a(O,"FormMessage");export{_ as a,k as b,z as c,H as d,I as e,E as f,O as g};
2
- //# sourceMappingURL=chunk-GVDARE4K.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/ui/form.tsx","../src/components/ui/label.tsx"],"sourcesContent":["import * as LabelPrimitive from '@radix-ui/react-label';\nimport { Slot } from '@radix-ui/react-slot';\nimport * as React from 'react';\nimport DOMPurify from 'dompurify';\nimport {\n Controller,\n ControllerProps,\n FieldPath,\n FieldValues,\n FormProvider,\n useFormContext,\n useFormState,\n} from 'react-hook-form';\n\nimport { Label } from '@/src/components/ui/label';\nimport { cn } from '@/src/lib/utils';\n\nconst Form = FormProvider;\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName;\n};\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>(\n {} as FormFieldContextValue,\n);\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n};\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext);\n const itemContext = React.useContext(FormItemContext);\n const { getFieldState } = useFormContext();\n const formState = useFormState({ name: fieldContext.name });\n const fieldState = getFieldState(fieldContext.name, formState);\n\n if (!fieldContext) {\n throw new Error('useFormField should be used within <FormField>');\n }\n\n const { id } = itemContext;\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n};\n\ntype FormItemContextValue = {\n id: string;\n};\n\nconst FormItemContext = React.createContext<FormItemContextValue>(\n {} as FormItemContextValue,\n);\n\nfunction FormItem({ className, ...props }: React.ComponentProps<'div'>) {\n const id = React.useId();\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div\n data-slot=\"form-item\"\n {...props}\n className={cn('grid gap-2', className)}\n />\n </FormItemContext.Provider>\n );\n}\n\nfunction FormLabel({\n className,\n ...props\n}: React.ComponentProps<typeof LabelPrimitive.Root>) {\n const { error, formItemId } = useFormField();\n\n return (\n <Label\n data-slot=\"form-label\"\n data-error={!!error}\n className={cn(\n 'text-base-color mb-1 data-[error=true]:text-destructive',\n className,\n )}\n htmlFor={formItemId}\n {...props}\n />\n );\n}\n\nconst FormControl = React.forwardRef<\n React.ComponentRef<typeof Slot>,\n React.ComponentPropsWithoutRef<typeof Slot>\n>(({ ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } =\n useFormField();\n\n return (\n <Slot\n data-slot=\"form-control\"\n ref={ref}\n id={formItemId}\n aria-describedby={\n !error\n ? `${formDescriptionId}`\n : `${formDescriptionId} ${formMessageId}`\n }\n aria-invalid={!!error}\n {...props}\n />\n );\n});\n\nFormControl.displayName = 'FormControl';\n\n// Deduplicates rel values if necessary and appends noopener and noreferrer\nconst appendSecureRelValue = (rel: string | null) => {\n const attributes = new Set(rel ? rel.toLowerCase().split(' ') : []);\n\n attributes.add('noopener');\n attributes.add('noreferrer');\n\n return Array.from(attributes).join(' ');\n};\n\nif (DOMPurify.isSupported) {\n DOMPurify.addHook('afterSanitizeAttributes', (node) => {\n const target = node.getAttribute('target');\n\n // set value of target to be _blank with rel, or keep as _self if already set\n if (node.tagName === 'A' && (!target || target !== '_self')) {\n node.setAttribute('target', '_blank');\n const rel = node.getAttribute('rel');\n node.setAttribute('rel', appendSecureRelValue(rel));\n }\n });\n}\n\nfunction FormDescription({\n className,\n children,\n ...props\n}: React.ComponentProps<'p'> & {\n children?: React.ReactNode | (() => React.ReactNode);\n}) {\n const { formDescriptionId } = useFormField();\n\n if (typeof children === 'string') {\n return (\n <p\n data-slot=\"form-description\"\n id={formDescriptionId}\n className={cn('text-base-color text-xs', className)}\n dangerouslySetInnerHTML={{\n __html: DOMPurify.sanitize(children, { ADD_ATTR: ['target'] }),\n }}\n {...props}\n />\n );\n }\n\n return (\n <p\n data-slot=\"form-description\"\n id={formDescriptionId}\n className={cn('text-base-color text-xs', className)}\n {...props}\n >\n {typeof children === 'function' ? children() : children}\n </p>\n );\n}\n\nfunction FormMessage({ className, ...props }: React.ComponentProps<'p'>) {\n const { error, formMessageId } = useFormField();\n const body = error ? String(error?.message ?? '') : props.children;\n\n if (!body) {\n return null;\n }\n\n return (\n <p\n data-slot=\"form-message\"\n id={formMessageId}\n className={cn('text-destructive text-sm', className)}\n {...props}\n >\n {body}\n </p>\n );\n}\n\nexport {\n Form,\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n useFormField,\n};\n","'use client';\n\nimport * as React from 'react';\nimport * as LabelPrimitive from '@radix-ui/react-label';\n\nimport { cn } from '@/src/lib/utils';\n\nfunction Label({\n className,\n ...props\n}: React.ComponentProps<typeof LabelPrimitive.Root>) {\n return (\n <LabelPrimitive.Root\n data-slot=\"label\"\n className={cn(\n 'flex items-center gap-2 text-sm leading-none select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50',\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Label };\n"],"mappings":"2EACA,OAAS,QAAAA,MAAY,uBACrB,UAAYC,MAAW,QACvB,OAAOC,MAAe,YACtB,OACE,cAAAC,EAIA,gBAAAC,EACA,kBAAAC,EACA,gBAAAC,MACK,kBCTP,UAAYC,MAAoB,wBAS5B,cAAAC,MAAA,oBALJ,SAASC,EAAM,CACb,UAAAC,EACA,GAAGC,CACL,EAAqD,CACnD,OACEH,EAAgB,OAAf,CACC,YAAU,QACV,UAAWI,EACT,gJACAF,CACF,EACC,GAAGC,EACN,CAEJ,CAdSE,EAAAJ,EAAA,SD+BH,cAAAK,MAAA,oBArBN,IAAMC,EAAOC,EASPC,EAAyB,gBAC7B,CAAC,CACH,EAEMC,EAAYC,EAAA,CAGhB,CACA,GAAGC,CACL,IAEIN,EAACG,EAAiB,SAAjB,CAA0B,MAAO,CAAE,KAAMG,EAA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EAAA+B,EAAA,mBAmCT,SAASE,EAAY,CAAE,UAAAnB,EAAW,GAAGb,CAAM,EAA8B,CACvE,GAAM,CAAE,MAAAgB,EAAO,cAAAM,CAAc,EAAIpB,EAAa,EACxC+B,EAAOjB,EAAQ,OAAOA,GAAO,SAAW,EAAE,EAAIhB,EAAM,SAE1D,OAAKiC,EAKHvC,EAAC,KACC,YAAU,eACV,GAAI4B,EACJ,UAAWR,EAAG,2BAA4BD,CAAS,EAClD,GAAGb,EAEH,SAAAiC,EACH,EAXO,IAaX,CAlBSlC,EAAAiC,EAAA","names":["Slot","React","DOMPurify","Controller","FormProvider","useFormContext","useFormState","LabelPrimitive","jsx","Label","className","props","cn","__name","jsx","Form","FormProvider","FormFieldContext","FormField","__name","props","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","useFormContext","formState","useFormState","fieldState","id","FormItem","className","cn","FormLabel","error","formItemId","Label","FormControl","ref","formDescriptionId","formMessageId","Slot","appendSecureRelValue","rel","attributes","DOMPurify","node","target","FormDescription","children","FormMessage","body"]}
@@ -1,2 +0,0 @@
1
- import{b as r}from"./chunk-PGWKJ6FK.js";import{a as e}from"./chunk-P37U34EQ.js";var S=["invited","created_reserve_paid"],R=["deposit_required","referred"];function l({render:o}){let{onboardingBag:t,creditScore:s}=r(),d=t.creditRiskStatus==="deposit_required",i=t.employment?.status&&S.includes(t.employment.status),n=t.creditRiskStatus&&R.includes(t.creditRiskStatus),u=d&&t.employment?.status&&!i,c=t.creditRiskStatus&&!n||t.employment?.status&&i,a=e(()=>u?s.showReserveInvoice?"deposit_required_successful":"deposit_required":c?s.showInviteSuccessful?"invite_successful":"invite":null,"getCreditRiskState")();return o({creditRiskState:a,creditRiskStatus:t.creditRiskStatus})}e(l,"ReviewStep");export{l as a};
2
- //# sourceMappingURL=chunk-KFVOK5X5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/flows/Onboarding/components/ReviewStep.tsx"],"sourcesContent":["import { useOnboardingContext } from '@/src/flows/Onboarding/context';\nimport {\n CreditRiskStatus,\n CreditRiskState,\n Employment,\n} from '@/src/flows/Onboarding/types';\n\ntype ReviewStepProps = {\n /**\n * Render prop function for customizing the review step credit risk flow UI\n *\n * @param props - Object containing credit risk information\n * @param props.creditRiskState - Current state of the credit risk flow\n * - 'deposit_required': Deposit payment is required but not yet paid\n * - 'deposit_required_successful': Deposit payment has been successfully processed\n * - 'invite': Regular invite flow is available (no deposit required)\n * - 'invite_successful': Invitation has been successfully sent\n * - null: No specific credit risk state applies\n *\n * @param props.creditRiskStatus - Credit risk status from the backend\n * - 'not_started': Credit risk assessment has not been initiated\n * - 'ready': Ready for credit risk assessment\n * - 'in_progress': Credit risk assessment is in progress\n * - 'referred': Company has been referred for manual review\n * - 'fail': Credit risk assessment failed\n * - 'deposit_required': Company requires a deposit payment\n * - 'no_deposit_required': No deposit is required for this company\n * - undefined: Credit risk status not yet determined\n * @returns React.ReactNode to render for the review step\n */\n render: (props: {\n creditRiskState: CreditRiskState;\n creditRiskStatus: CreditRiskStatus | undefined;\n }) => React.ReactNode;\n};\n\nconst statusesToNotShowDeposit: Employment['status'][] = [\n 'invited',\n 'created_reserve_paid',\n];\n\nconst CREDIT_RISK_STATUSES: CreditRiskStatus[] = [\n 'deposit_required',\n 'referred',\n];\n\nexport function ReviewStep({ render }: ReviewStepProps) {\n const { onboardingBag, creditScore } = useOnboardingContext();\n\n // Helper variables to make logic more readable\n const isDepositRequiredCreditRisk =\n onboardingBag.creditRiskStatus === 'deposit_required';\n\n const hasEmploymentStatusThatHidesDeposit =\n onboardingBag.employment?.status &&\n statusesToNotShowDeposit.includes(onboardingBag.employment.status);\n\n const isCreditRiskStatusInExclusionList =\n onboardingBag.creditRiskStatus &&\n CREDIT_RISK_STATUSES.includes(onboardingBag.creditRiskStatus);\n\n const shouldShowDepositFlow =\n isDepositRequiredCreditRisk &&\n onboardingBag.employment?.status &&\n !hasEmploymentStatusThatHidesDeposit;\n\n const shouldShowInviteFlow =\n (onboardingBag.creditRiskStatus && !isCreditRiskStatusInExclusionList) ||\n (onboardingBag.employment?.status && hasEmploymentStatusThatHidesDeposit);\n\n const getCreditRiskState = (): CreditRiskState => {\n // Priority 1: Deposit required flow\n if (shouldShowDepositFlow) {\n return creditScore.showReserveInvoice\n ? 'deposit_required_successful'\n : 'deposit_required';\n }\n\n // Priority 2: Invite flow\n if (shouldShowInviteFlow) {\n return creditScore.showInviteSuccessful ? 'invite_successful' : 'invite';\n }\n\n // Default case\n return null;\n };\n\n const creditRiskState = getCreditRiskState();\n\n return render({\n creditRiskState,\n creditRiskStatus: onboardingBag.creditRiskStatus,\n });\n}\n"],"mappings":"gFAoCA,IAAMA,EAAmD,CACvD,UACA,sBACF,EAEMC,EAA2C,CAC/C,mBACA,UACF,EAEO,SAASC,EAAW,CAAE,OAAAC,CAAO,EAAoB,CACtD,GAAM,CAAE,cAAAC,EAAe,YAAAC,CAAY,EAAIC,EAAqB,EAGtDC,EACJH,EAAc,mBAAqB,mBAE/BI,EACJJ,EAAc,YAAY,QAC1BJ,EAAyB,SAASI,EAAc,WAAW,MAAM,EAE7DK,EACJL,EAAc,kBACdH,EAAqB,SAASG,EAAc,gBAAgB,EAExDM,EACJH,GACAH,EAAc,YAAY,QAC1B,CAACI,EAEGG,EACHP,EAAc,kBAAoB,CAACK,GACnCL,EAAc,YAAY,QAAUI,EAmBjCI,EAjBqBC,EAAA,IAErBH,EACKL,EAAY,mBACf,8BACA,mBAIFM,EACKN,EAAY,qBAAuB,oBAAsB,SAI3D,KAdkB,sBAiBgB,EAE3C,OAAOF,EAAO,CACZ,gBAAAS,EACA,iBAAkBR,EAAc,gBAClC,CAAC,CACH,CA/CgBS,EAAAX,EAAA","names":["statusesToNotShowDeposit","CREDIT_RISK_STATUSES","ReviewStep","render","onboardingBag","creditScore","useOnboardingContext","isDepositRequiredCreditRisk","hasEmploymentStatusThatHidesDeposit","isCreditRiskStatusInExclusionList","shouldShowDepositFlow","shouldShowInviteFlow","creditRiskState","__name"]}
@@ -1,2 +0,0 @@
1
- import{m as D}from"./chunk-X36OBDKD.js";import{a as P}from"./chunk-52J6QK2N.js";import{b as W}from"./chunk-3ZWDIEEM.js";import{a as t,b as c,c as Te}from"./chunk-P37U34EQ.js";var k=c((xt,_)=>{"use strict";function he(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}t(he,"isObject");_.exports=he});var H=c((Tt,B)=>{"use strict";var Se=typeof global=="object"&&global&&global.Object===Object&&global;B.exports=Se});var M=c((ht,A)=>{"use strict";var je=H(),Oe=typeof self=="object"&&self&&self.Object===Object&&self,Ee=je||Oe||Function("return this")();A.exports=Ee});var J=c((St,G)=>{"use strict";var qe=M(),Fe=t(function(){return qe.Date.now()},"now");G.exports=Fe});var V=c((Ot,U)=>{"use strict";var Re=/\s/;function Ie(e){for(var n=e.length;n--&&Re.test(e.charAt(n)););return n}t(Ie,"trimmedEndIndex");U.exports=Ie});var z=c((qt,X)=>{"use strict";var Pe=V(),ke=/^\s+/;function Me(e){return e&&e.slice(0,Pe(e)+1).replace(ke,"")}t(Me,"baseTrim");X.exports=Me});var w=c((Rt,K)=>{"use strict";var we=M(),Le=we.Symbol;K.exports=Le});var ee=c((It,Z)=>{"use strict";var Q=w(),Y=Object.prototype,Ne=Y.hasOwnProperty,$e=Y.toString,T=Q?Q.toStringTag:void 0;function We(e){var n=Ne.call(e,T),o=e[T];try{e[T]=void 0;var s=!0}catch{}var a=$e.call(e);return s&&(n?e[T]=o:delete e[T]),a}t(We,"getRawTag");Z.exports=We});var ne=c((kt,te)=>{"use strict";var De=Object.prototype,_e=De.toString;function Be(e){return _e.call(e)}t(Be,"objectToString");te.exports=Be});var se=c((wt,ie)=>{"use strict";var re=w(),He=ee(),Ae=ne(),Ge="[object Null]",Je="[object Undefined]",oe=re?re.toStringTag:void 0;function Ue(e){return e==null?e===void 0?Je:Ge:oe&&oe in Object(e)?He(e):Ae(e)}t(Ue,"baseGetTag");ie.exports=Ue});var ce=c((Nt,ae)=>{"use strict";function Ve(e){return e!=null&&typeof e=="object"}t(Ve,"isObjectLike");ae.exports=Ve});var fe=c((Wt,ue)=>{"use strict";var Xe=se(),ze=ce(),Ke="[object Symbol]";function Qe(e){return typeof e=="symbol"||ze(e)&&Xe(e)==Ke}t(Qe,"isSymbol");ue.exports=Qe});var pe=c((_t,me)=>{"use strict";var Ye=z(),le=k(),Ze=fe(),de=NaN,et=/^[-+]0x[0-9a-f]+$/i,tt=/^0b[01]+$/i,nt=/^0o[0-7]+$/i,rt=parseInt;function ot(e){if(typeof e=="number")return e;if(Ze(e))return de;if(le(e)){var n=typeof e.valueOf=="function"?e.valueOf():e;e=le(n)?n+"":n}if(typeof e!="string")return e===0?e:+e;e=Ye(e);var o=tt.test(e);return o||nt.test(e)?rt(e.slice(2),o?2:8):et.test(e)?de:+e}t(ot,"toNumber");me.exports=ot});var ve=c((Ht,be)=>{"use strict";var it=k(),L=J(),ge=pe(),st="Expected a function",at=Math.max,ct=Math.min;function ut(e,n,o){var s,a,l,u,i,m,d=0,S=!1,p=!1,b=!0;if(typeof e!="function")throw new TypeError(st);n=ge(n)||0,it(o)&&(S=!!o.leading,p="maxWait"in o,l=p?at(ge(o.maxWait)||0,n):l,b="trailing"in o?!!o.trailing:b);function y(r){var f=s,g=a;return s=a=void 0,d=r,u=e.apply(g,f),u}t(y,"invokeFunc");function j(r){return d=r,i=setTimeout(v,n),S?y(r):u}t(j,"leadingEdge");function O(r){var f=r-m,g=r-d,q=n-f;return p?ct(q,l-g):q}t(O,"remainingWait");function x(r){var f=r-m,g=r-d;return m===void 0||f>=n||f<0||p&&g>=l}t(x,"shouldInvoke");function v(){var r=L();if(x(r))return E(r);i=setTimeout(v,O(r))}t(v,"timerExpired");function E(r){return i=void 0,b&&s?y(r):(s=a=void 0,u)}t(E,"trailingEdge");function R(){i!==void 0&&clearTimeout(i),d=0,s=m=a=i=void 0}t(R,"cancel");function I(){return i===void 0?u:E(L())}t(I,"flush");function C(){var r=L(),f=x(r);if(s=arguments,a=this,m=r,f){if(i===void 0)return j(m);if(p)return clearTimeout(i),i=setTimeout(v,n),y(m)}return i===void 0&&(i=setTimeout(v,n)),u}return t(C,"debounced"),C.cancel=R,C.flush=I,C}t(ut,"debounce");be.exports=ut});import{useState as dt,useCallback as mt,useEffect as pt,useRef as gt}from"react";import{useFormContext as bt}from"react-hook-form";var xe=Te(ve(),1);import{useCallback as ft,useEffect as lt,useRef as ye}from"react";function N(e,n){let o=ye(e);lt(()=>{o.current=e},[e]);let s=ye((0,xe.default)(a=>{o.current(a)},n)).current;return ft(a=>{s(a)},[s])}t(N,"useDebounce");import{Fragment as yt,jsx as h,jsxs as Ce}from"react/jsx-runtime";var vt=t(({description:e,showConversion:n,targetCurrency:o,className:s,onClick:a})=>{let{components:l}=W(),u=n?`Hide ${o} conversion`:`Show ${o} conversion`,i=l?.button;return Ce("span",{className:s,children:[e," ",i?h(i,{className:`${s.replace("-description","-button")}`,"data-type":"inline",onClick:a,children:u}):h("button",{className:`${s.replace("-description","-button")}`,onClick:a,children:u})]})},"DescriptionWithConversion"),en=t(({sourceCurrency:e,targetCurrency:n,conversionFieldName:o,conversionProperties:s,classNamePrefix:a,description:l,...u})=>{let[i,m]=dt(!1),{setValue:d,watch:S}=bt(),p=S(u.name),b=gt(!0),y=e&&n&&e!==n,{mutateAsync:j}=D();pt(()=>{if(b.current){b.current=!1;return}d(o,"")},[e,o,d]);let O=mt(async(r,f,g,q)=>{if(r)try{let F=await j({source_currency:f,target_currency:g,amount:Number(r)});if(F.data?.data?.conversion_data?.target_amount){let $=F.data.data.conversion_data.target_amount;$&&d(q,$?.toString())}}catch(F){console.error("Error converting currency:",F)}},[j,d]),x=N(r=>O(r,e,n,o),500),v=N(r=>O(r,n,e,u.name),500),E=t(r=>{i&&x(r.target.value)},"handleMainFieldChange"),R=t(r=>{v(r.target.value)},"handleConversionFieldChange"),I=t(r=>{r.preventDefault(),m(f=>!f),!i&&p&&x(p)},"toggleConversion"),C=y?h(vt,{targetCurrency:n,description:l,showConversion:i,className:`${a}-description`,onClick:I}):l;return Ce(yt,{children:[h(P,{...u,additionalProps:{currency:e},description:C,type:"text",inputMode:"decimal",pattern:"^[0-9.]*$",maxLength:15,onChange:E}),i&&h(P,{additionalProps:{currency:n},name:o,label:s?.label||"Conversion",description:s?.description,type:"text",inputMode:"decimal",pattern:"^[0-9.]*$",maxLength:15,onChange:R})]})},"CurrencyConversionField");export{en as a};
2
- //# sourceMappingURL=chunk-OZCFRM4R.js.map
@@ -1,2 +0,0 @@
1
- import{a as m}from"./chunk-GVDARE4K.js";import{c as n}from"./chunk-CNYSTJVL.js";import{b as a}from"./chunk-TVZAFTPT.js";import{a as o}from"./chunk-P37U34EQ.js";import{useForm as S}from"react-hook-form";import{jsx as i}from"react/jsx-runtime";function w({onSubmit:s,onError:d,onSuccess:c}){let{contractAmendment:{stepState:l,isSubmitting:u,onSubmit:f,fields:C},formId:p}=a(),e=S({defaultValues:l.values?.form}),A=o(async r=>{let F=n(r,C,{isPartialValidation:!1});await s?.(F);let t=await f(r);t.error?d?.(t.error):await c?.(t.data)},"handleSubmit");return u?null:i(m,{...e,children:i("form",{id:p,onSubmit:e.handleSubmit(A),className:"RemoteFlows__ContractAmendmentConfirmationForm"})})}o(w,"ContractAmendmentConfirmationForm");export{w as a};
2
- //# sourceMappingURL=chunk-SG67NZYI.js.map
@@ -1,2 +0,0 @@
1
- import{a as s}from"./chunk-KSHK3ZPX.js";import{c as l,d as n}from"./chunk-M6ZWJ7KV.js";import{b as a}from"./chunk-CFIJKJXD.js";import{a as r}from"./chunk-P37U34EQ.js";import{useId as p}from"react";import{useForm as y}from"react-hook-form";import{jsx as d}from"react/jsx-runtime";var h=r(({estimationOptions:e=l,defaultValues:o={countryRegionSlug:"",currencySlug:"",salary:""},options:i,render:u,version:c="standard"})=>{let C=p(),t=n({defaultRegion:o.countryRegionSlug,estimationOptions:e,version:c,options:i}),m=a(t.handleValidation),g=y({resolver:m,defaultValues:{country:o?.countryRegionSlug,currency:o?.currencySlug,region:"",salary:o?.salary},shouldUnregister:!1,mode:"onBlur"});return d(s.Provider,{value:{form:g,formId:C,costCalculatorBag:t},children:u(t)})},"CostCalculatorFlow");export{h as a};
2
- //# sourceMappingURL=chunk-TQNMLD3A.js.map
@@ -1,2 +0,0 @@
1
- import{b as f}from"./chunk-MRYRNB7Y.js";import{a as l}from"./chunk-Y6K2UK3D.js";import{b as s}from"./chunk-CFIJKJXD.js";import{a}from"./chunk-GVDARE4K.js";import{a as n}from"./chunk-P37U34EQ.js";import{useEffect as y}from"react";import{useForm as T}from"react-hook-form";import{jsx as e}from"react/jsx-runtime";function A({fields:m,onSubmit:d}){let{formId:F,terminationBag:o}=f(),u=s(o.handleValidation),i=T({resolver:u,defaultValues:o?.initialValues,shouldUnregister:!1,mode:"onBlur"});y(()=>{let p=i?.watch(r=>{Object.keys(r).some(t=>r[t]!==o?.initialValues?.[t])&&o?.checkFieldUpdates(r)});return()=>p?.unsubscribe()},[]);let c=m||(o?.fields??[]);return e(a,{...i,children:e("form",{id:F,onSubmit:i.handleSubmit(d),className:"space-y-4 RemoteFlows__TerminationForm",children:e(l,{fields:c})})})}n(A,"TerminationForm");export{A as a};
2
- //# sourceMappingURL=chunk-V4X62BBS.js.map
@@ -1,2 +0,0 @@
1
- import{a as Oe}from"./chunk-OYI5OCMY.js";import{a as A}from"./chunk-52J6QK2N.js";import{a as he,b as B}from"./chunk-WZSGDTVV.js";import{b}from"./chunk-3ZWDIEEM.js";import{a as Ae,b as S,c as k,d as P,e as N,f as R,g as D}from"./chunk-GVDARE4K.js";import{e as He,g as Be}from"./chunk-CNYSTJVL.js";import{a as u}from"./chunk-TC3SWPEN.js";import{a as o}from"./chunk-P37U34EQ.js";import{Fragment as jo}from"react";import*as ze from"react";import*as oe from"@radix-ui/react-checkbox";import{Check as $t}from"lucide-react";import{jsx as _e}from"react/jsx-runtime";var re=ze.forwardRef(({className:e,...t},r)=>_e(oe.Root,{ref:r,className:u("peer h-4 w-4 shrink-0 rounded-sm border border-input ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-checkbox data-[state=checked]:text-primary",e),...t,children:_e(oe.Indicator,{className:u("flex items-center justify-center text-current"),children:_e($t,{className:"h-4 w-4"})})}));re.displayName=oe.Root.displayName;import{useFormContext as Et}from"react-hook-form";import{Fragment as Ht,jsx as O,jsxs as ae}from"react/jsx-runtime";function ne({name:e,defaultValue:t,description:r,label:a,onChange:s,multiple:n,options:p,component:F,...v}){let{components:d}=b(),{control:l}=Et(),f=o((c,i,m)=>{let g=m.value?[...m.value]:[];i?g.includes(c)||m.onChange([...g,c]):m.onChange(g.filter(y=>y!==c))},"handleCheckboxChange");return O(S,{control:l,name:e,defaultValue:t,render:({field:c,fieldState:i})=>{let m=F||d?.checkbox;if(m){let g={name:e,description:r,label:a,defaultValue:t,multiple:n,options:p,...v};return O(m,{field:{...c,onChange:o(y=>{if(n){let{checked:x,value:C}=y.target;f(C,x,c),s?.(x);return}c.onChange(y),s?.(y)},"onChange")},fieldState:i,fieldData:g})}return ae(k,{"data-field":e,className:u(`RemoteFlows__CheckBoxField__Item__${e}`),children:[O(N,{children:ae(Ht,{children:[p&&n?O(P,{children:a}):null,p&&n?p.map(g=>ae("div",{className:"flex space-x-2",children:[O(re,{id:g.value,onCheckedChange:y=>{f(g.value,y===!0,c),s?.(y,g.value)},checked:c.value?.includes(g.value),className:"RemoteFlows__CheckBox__Input"}),O(P,{htmlFor:g.value,className:"mb-0 RemoteFlows__CheckBox__Label",children:g.label})]},g.value)):ae("div",{className:"flex space-x-2",children:[O(re,{id:e,onCheckedChange:g=>{c.onChange(g),s?.(g)},checked:c.value,className:"RemoteFlows__CheckBox__Input"}),O(P,{htmlFor:e,className:"mb-0 RemoteFlows__CheckBox__Label",children:a})]})]})}),r&&O(R,{children:r}),i.error&&O(D,{})]})}})}o(ne,"CheckBoxField");import{CalendarIcon as zt}from"lucide-react";import{useFormContext as Vt}from"react-hook-form";import{PopoverClose as Gt}from"@radix-ui/react-popover";import{ChevronLeft as Bt,ChevronRight as At}from"lucide-react";import{DayPicker as Ot}from"react-day-picker";import{jsx as Ce}from"react/jsx-runtime";function Ve({className:e,classNames:t,showOutsideDays:r=!0,...a}){return Ce(Ot,{showOutsideDays:r,className:u("p-3",e),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:u(he({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:u("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",a.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:u(he({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",...t},components:{IconLeft:o(({className:s,...n})=>Ce(Bt,{className:u("size-4",s),...n}),"IconLeft"),IconRight:o(({className:s,...n})=>Ce(At,{className:u("size-4",s),...n}),"IconRight")},...a})}o(Ve,"Calendar");import*as z from"@radix-ui/react-popover";import{jsx as ie}from"react/jsx-runtime";function se({...e}){return ie(z.Root,{"data-slot":"popover",...e})}o(se,"Popover");function le({...e}){return ie(z.Trigger,{"data-slot":"popover-trigger",...e})}o(le,"PopoverTrigger");function me({className:e,align:t="center",sideOffset:r=4,...a}){return ie(z.Portal,{children:ie(z.Content,{"data-slot":"popover-content",align:t,sideOffset:r,className:u("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...a})})}o(me,"PopoverContent");import{format as Ge}from"date-fns";import{Fragment as Ut,jsx as M,jsxs as xe}from"react/jsx-runtime";function Ue({description:e,label:t,name:r,minDate:a,onChange:s,component:n,...p}){let{components:F}=b(),{control:v}=Vt(),d;return p.meta?.mot&&typeof p.meta.mot=="number"?d=Be(p.meta.mot):a&&(d=new Date(a)),M(S,{control:v,name:r,render:({field:l,fieldState:f})=>{let c=n||F?.date;if(c){let i={description:e,label:t,name:r,onChange:s,...d&&{minDate:d.toISOString()},...p};return M(c,{field:{...l,onChange:o(m=>{l.onChange(m),s?.(m)},"onChange")},fieldState:f,fieldData:i})}return xe(k,{"data-field":r,className:`flex flex-col RemoteFlows__DatePickerField__Item__${r}`,children:[M(P,{className:"RemoteFlows__DatePickerField__Label",children:t}),xe(se,{children:[M(le,{asChild:!0,children:M(N,{children:M("div",{children:xe(B,{type:"button",variant:"outline",className:u("w-full pl-3 text-left font-normal",!l.value&&"text-muted-foreground"),"data-testid":`date-picker-button-${r}`,children:[l.value&&M(Ut,{children:Ge(l.value,"yyyy-MM-dd")}),M(zt,{className:"ml-auto h-4 w-4 opacity-50"})]})})})}),M(me,{className:"w-auto p-0 RemoteFlows__DatepickerField__PopoverContent",align:"start",children:M(Ve,{mode:"single",className:"RemoteFlows__DatepickerField__Calendar",selected:l.value?new Date(l.value):void 0,onSelect:i=>{l.onChange(i?Ge(i,"yyyy-MM-dd"):null),s?.(i)},defaultMonth:d,components:{DayContent:o(i=>M(Gt,{children:i.date.getDate()}),"DayContent")},...d&&{disabled:o(i=>i<d,"disabled")}})})]}),e?M(R,{children:e}):null,f.error&&M(D,{className:"RemoteFlows__DatePickerField__Error"})]})}})}o(Ue,"DatePickerField");import{cva as Jt}from"class-variance-authority";import{jsx as be}from"react/jsx-runtime";var qt=Jt("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90",warning:"bg-card bg-warning border-warning-border [&>svg]:text-current"}},defaultVariants:{variant:"default"}});function Je({className:e,variant:t,...r}){return be("div",{"data-slot":"alert",role:"alert",className:u(qt({variant:t}),e),...r})}o(Je,"Alert");function qe({className:e,...t}){return be("div",{"data-slot":"alert-title",className:u("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t})}o(qe,"AlertTitle");function Ke({className:e,...t}){return be("div",{"data-slot":"alert-description",className:u("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t})}o(Ke,"AlertDescription");import{AlertCircle as Kt}from"lucide-react";import{jsx as ce,jsxs as Yt}from"react/jsx-runtime";function de({title:e,description:t,severity:r}){let{components:a}=b();if(a?.statement){let s=a?.statement;return ce(s,{data:{title:e,description:t,severity:r}})}return Yt(Je,{variant:"warning",children:[ce(Kt,{className:"h-4 w-4"}),e&&ce(qe,{children:e}),ce(Ke,{children:t})]})}o(de,"Statement");import{useFormContext as Xt}from"react-hook-form";import{useEffect as Qt,useRef as Ye}from"react";import{jsx as pe,jsxs as Xe}from"react/jsx-runtime";import{createElement as Zt}from"react";function Se({label:e,name:t,fields:r,description:a,components:s,statement:n,isFlatFieldset:p}){let{watch:F,trigger:v,formState:d}=Xt(),l=r.map(({name:m})=>`${t}.${m}`),f=F(l),c=Ye(f),i=Ye(null);return Qt(()=>{let m=f,g=c.current,y=d.isSubmitted||d.submitCount>0,x=!1;for(let C=0;C<m.length;C++)if(m[C]!==void 0&&g[C]!==m[C]){x=!0;break}return x&&y&&(i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{v()},50)),c.current=[...m],()=>{i.current&&clearTimeout(i.current)}},[f,v,d.isSubmitted,d.submitCount]),Xe("fieldset",{className:u("border-1 border-input p-4 rounded-xl",`RemoteFlows__FieldSetField__${t}`),children:[pe("legend",{className:"text-sm font-semibold px-2",children:e}),a?pe("div",{className:"mb-5 RemoteFlows__FieldSetField__Description",dangerouslySetInnerHTML:{__html:a}}):null,Xe("div",{className:"grid gap-4",children:[r.map(m=>{let g=X[m.type];if(m.isVisible===!1||m.deprecated)return null;if(m.Component){let{Component:y}=m;return pe(y,{...m},m.name)}return m.inputType==="select"&&m.multiple&&(g=X["multi-select"]),Zt(g,{...m,key:m.name,name:`${p?m.name:`${t}.${m.name}`}`,component:s?.[m.type]})}),n?pe(de,{...n}):null]})]})}o(Se,"FieldSetField");import{useFormContext as ro}from"react-hook-form";import{useState as jt,useRef as eo}from"react";import{Upload as to,X as oo}from"lucide-react";import{jsx as G,jsxs as Pe}from"react/jsx-runtime";function Qe({onChange:e,className:t,multiple:r}){let[a,s]=jt([]),n=eo(null),p=o(d=>{d.preventDefault(),n.current?.click()},"handleClick"),F=o(d=>{if(d.target.files&&d.target.files.length>0){let l=Array.from(d.target.files);s(l),e(d)}},"handleChange"),v=o(d=>{s(l=>l.filter(f=>f!==d))},"onRemoveFile");return Pe("div",{className:u("flex flex-col items-start gap-4",t),children:[G("input",{type:"file",ref:n,onChange:F,className:"hidden","aria-label":"File upload",multiple:r}),Pe(B,{type:"button",onClick:p,className:"gap-2",children:[G(to,{className:"h-4 w-4"}),"Choose File"]}),a.length===0&&G("div",{className:"text-sm",children:r?G("span",{className:"font-medium",children:"No files selected. You can select multiple files"}):G("span",{className:"font-medium",children:"No file selected."})}),a.length>0&&a.map((d,l)=>Pe("div",{className:"text-sm flex items-center gap-2",children:["Selected file: ",G("span",{className:"font-medium",children:d.name})," (",Math.round(d.size/1024)," KB)",G(B,{variant:"ghost",onClick:()=>v(d),children:G(oo,{})})]},l))]})}o(Qe,"FileUploader");import{jsx as U,jsxs as no}from"react/jsx-runtime";var ao=o(e=>new Promise((t,r)=>{let a=new FileReader;a.readAsDataURL(e),a.onload=()=>t(a.result),a.onerror=s=>r(s)}),"toBase64"),Ze=o(async e=>{let t=e.target.files?Array.from(e.target.files):[];return await Promise.all(t.map(async a=>{let s=await ao(a);return{name:a.name,content:s.split(",")[1]}}))},"convertFilesToBase64");function je({name:e,description:t,label:r,multiple:a,onChange:s,component:n,...p}){let{components:F}=b(),{control:v}=ro();return U(S,{control:v,name:e,render:({field:d,fieldState:l})=>{let f=n||F?.file;if(f){let c={name:e,description:t,label:r,multiple:a,...p};return U(f,{field:{...d,value:null,onChange:o(async i=>{let m=await Ze(i);d.onChange(m),s?.(m)},"onChange")},fieldState:l,fieldData:c})}return no(k,{"data-field":e,className:`RemoteFlows__FileUpload__Item__${e}`,children:[U(P,{className:"RemoteFlows__FileUpload__Label",children:r}),U(N,{children:U(Qe,{onChange:async c=>{let i=await Ze(c);d.onChange(i),s?.(i)},multiple:a,className:u("RemoteFlows__FileUpload__Input")})}),t&&U("div",{className:"flex items-center justify-between",children:U(R,{className:"RemoteFlows__FileUpload__Description",children:t})}),l.error&&U(D,{className:"RemoteFlows__FileUpload__Error"})]})}})}o(je,"FileUploadField");import{useFormContext as io}from"react-hook-form";import{jsx as ke}from"react/jsx-runtime";function ue(e){let{components:t}=b(),{control:r}=io(),a=e.component||t?.number;return a?ke(S,{control:r,name:e.name,render:({field:s,fieldState:n})=>ke(a,{field:{...s,onChange:o(p=>{s.onChange(p),e.onChange?.(p)},"onChange")},fieldState:n,fieldData:e})}):ke(A,{...e,type:"text",inputMode:"decimal",pattern:"^[0-9.]*$"})}o(ue,"NumberField");import*as Q from"@radix-ui/react-radio-group";import{CircleIcon as so}from"lucide-react";import{jsx as fe}from"react/jsx-runtime";function et({className:e,...t}){return fe(Q.Root,{"data-slot":"radio-group",className:u("grid gap-3",e),...t})}o(et,"RadioGroup");function tt({className:e,...t}){return fe(Q.Item,{"data-slot":"radio-group-item",className:u("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:fe(Q.Indicator,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:fe(so,{className:"fill-radio absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}o(tt,"RadioGroupItem");import{useFormContext as lo}from"react-hook-form";import{Fragment as mo,jsx as $,jsxs as Ne}from"react/jsx-runtime";function ot({name:e,defaultValue:t,description:r,label:a,options:s,onChange:n,component:p,...F}){let{components:v}=b(),{control:d}=lo();return $(S,{control:d,name:e,defaultValue:t,render:({field:l,fieldState:f})=>{let c=p||v?.radio;if(c){let i={name:e,defaultValue:t,description:r,label:a,options:s,...F};return $(c,{field:{...l,onChange:o(m=>{l.onChange(m),n?.(m)},"onChange")},fieldState:f,fieldData:i})}return Ne(k,{className:u("space-y-3",`RemoteFlows__RadioGroupField__Item__${e}`),"data-field":e,children:[$(P,{children:a}),$(N,{children:$(et,{"aria-label":a||e,onValueChange:i=>{l.onChange(i),n?.(i)},value:l.value,className:"flex flex-col space-y-3",children:s?.map(i=>$(mo,{children:Ne(k,{"data-field":e,className:"flex items-start space-x-3 space-y-0 gap-0 RemoteFlows__RadioField__Item",children:[$(N,{children:$(tt,{value:i.value,className:"RemoteFlows__RadioField__Input",disabled:i.disabled})}),Ne("div",{children:[$(P,{className:"font-normal mb-0 RemoteFlows__RadioField__Label",children:i.label}),i.description&&$(R,{className:"mt-2",children:i.description})]})]},i.value)}))})}),r&&$(R,{children:r}),f.error&&$(D,{})]})}})}o(ot,"RadioGroupField");import*as _ from"@radix-ui/react-select";import{CheckIcon as co,ChevronDownIcon as rt,ChevronUpIcon as po}from"lucide-react";import{jsx as w,jsxs as Re}from"react/jsx-runtime";function at({...e}){return w(_.Root,{"data-slot":"select",...e})}o(at,"Select");function nt({...e}){return w(_.Group,{"data-slot":"select-group",...e})}o(nt,"SelectGroup");function it({...e}){return w(_.Value,{"data-slot":"select-value",...e})}o(it,"SelectValue");function st({className:e,children:t,...r}){return Re(_.Trigger,{"data-slot":"select-trigger",className:u("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex w-full items-center justify-between rounded-xl border bg-transparent px-4 py-7 text-sm whitespace-nowrap transition-[color] outline-none disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","focus-visible:border-focused",e),...r,children:[t,w(_.Icon,{asChild:!0,className:"absolute right-4",children:w(rt,{className:"size-4"})})]})}o(st,"SelectTrigger");function lt({className:e,children:t,position:r="popper",...a}){return w(_.Portal,{children:Re(_.Content,{"data-slot":"select-content",className:u("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-xl border",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...a,children:[w(uo,{}),w(_.Viewport,{className:u(r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),w(fo,{})]})})}o(lt,"SelectContent");function mt({className:e,children:t,...r}){return Re(_.Item,{"data-slot":"select-item",className:u("focus:bg-accent focus:text-accent-foreground min-h-11 justify-between [&_svg:not([class*='text-'])]:text-muted-foreground flex w-full cursor-default items-center gap-2 py-2 px-4 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...r,children:[w(_.ItemText,{children:t}),w("span",{className:"flex size-3.5 items-center justify-center",children:w(_.ItemIndicator,{children:w(co,{className:"size-4"})})})]})}o(mt,"SelectItem");function uo({className:e,...t}){return w(_.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:u("flex cursor-default items-center justify-center py-1",e),...t,children:w(po,{className:"size-4"})})}o(uo,"SelectScrollUpButton");function fo({className:e,...t}){return w(_.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:u("flex cursor-default items-center justify-center py-1",e),...t,children:w(rt,{className:"size-4"})})}o(fo,"SelectScrollDownButton");import{useFormContext as go}from"react-hook-form";import{jsx as W,jsxs as ct}from"react/jsx-runtime";function dt({label:e,name:t,options:r,defaultValue:a,description:s,onChange:n,component:p,...F}){let{control:v}=go(),{components:d}=b();return W(S,{defaultValue:a,control:v,name:t,render:({field:l,fieldState:f})=>{let c=p||d?.select;if(c){let i={label:e,name:t,options:r,defaultValue:a,description:s,onChange:n,...F};return W(c,{field:{...l,onChange:o(m=>{let g=!isNaN(Number(m))&&typeof m!="boolean"?Number(m):m;l.onChange(g),n?.(g)},"onChange")},fieldState:f,fieldData:i})}return ct(k,{"data-field":t,className:`RemoteFlows__SelectField__Item__${t}`,children:[W(P,{className:"RemoteFlows__SelectField__Label",children:e}),W(N,{children:W("div",{className:"relative",children:ct(at,{value:l.value||"",onValueChange:i=>{let m=!isNaN(Number(i))&&typeof i!="boolean"?Number(i):i;l.onChange(m),n?.(m)},children:[W(st,{className:"RemoteFlows__SelectField__Trigger","aria-invalid":!!f.error,"aria-label":e,children:W("span",{className:"absolute",children:W(it,{placeholder:e})})}),W(lt,{className:"RemoteFlows__SelectField__Content",children:W(nt,{className:"RemoteFlows__SelectField__Group",children:r.map(i=>W(mt,{value:i.value,className:"RemoteFlows__SelectField__SelectItem",children:i.label},i.value))})})]})})}),s&&W(R,{children:s}),f.error&&W(D,{})]})}})}o(dt,"SelectField");import{useState as So}from"react";import{useFormContext as Po}from"react-hook-form";import{Fragment as ho,useState as _o}from"react";import{Check as Co,ChevronDownIcon as xo,X as bo}from"lucide-react";import{Command as Z}from"cmdk";import{SearchIcon as pn}from"lucide-react";import*as T from"@radix-ui/react-dialog";import{XIcon as Fo}from"lucide-react";import{jsx as V,jsxs as we}from"react/jsx-runtime";function De({...e}){return V(T.Root,{"data-slot":"dialog",...e})}o(De,"Dialog");function pt({...e}){return V(T.Trigger,{"data-slot":"dialog-trigger",...e})}o(pt,"DialogTrigger");function vo({...e}){return V(T.Portal,{"data-slot":"dialog-portal",...e})}o(vo,"DialogPortal");function yo({className:e,...t}){return V(T.Overlay,{"data-slot":"dialog-overlay",className:u("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}o(yo,"DialogOverlay");function Te({className:e,children:t,...r}){return we(vo,{"data-slot":"dialog-portal",children:[V(yo,{}),we(T.Content,{"data-slot":"dialog-content",className:u("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r,children:[t,we(T.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 RemoteFlows__Dialog__Close",children:[V(Fo,{}),V("span",{className:"sr-only",children:"Close"})]})]})]})}o(Te,"DialogContent");function Ie({className:e,...t}){return V("div",{"data-slot":"dialog-header",className:u("flex flex-col gap-2 text-center sm:text-left",e),...t})}o(Ie,"DialogHeader");function Me({className:e,...t}){return V(T.Title,{"data-slot":"dialog-title",className:u("text-lg leading-none font-semibold",e),...t})}o(Me,"DialogTitle");import{jsx as j,jsxs as Fn}from"react/jsx-runtime";function ut({className:e,...t}){return j(Z,{"data-slot":"command",className:u("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...t})}o(ut,"Command");function ft({className:e,...t}){return j(Z.List,{"data-slot":"command-list",className:u("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}o(ft,"CommandList");function gt({...e}){return j(Z.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}o(gt,"CommandEmpty");function Ft({className:e,...t}){return j(Z.Group,{"data-slot":"command-group",className:u("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...t})}o(Ft,"CommandGroup");function vt({className:e,...t}){return j(Z.Separator,{"data-slot":"command-separator",className:u("bg-border -mx-1 h-px",e),...t})}o(vt,"CommandSeparator");function yt({className:e,...t}){return j(Z.Item,{"data-slot":"command-item",className:u("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}o(yt,"CommandItem");import{jsx as E,jsxs as ee}from"react/jsx-runtime";function ge({options:e,selected:t,onChange:r,placeholder:a,...s}){let[n,p]=_o(!1),F=o(l=>{r(t.filter(f=>f.value!==l.value))},"handleUnselect"),v=e.some(l=>l.category),d=e.reduce((l,f)=>{let c=f.category||"Uncategorized";return l[c]||(l[c]=[]),l[c].push(f),l},{});return ee(se,{open:n,onOpenChange:p,...s,children:[E(le,{children:ee(B,{variant:"outline",role:"combobox","aria-expanded":n,className:"w-full justify-between font-normal",type:"button",children:[E("div",{className:"flex gap-1 flex-wrap overflow-x-auto max-h-[2.5rem] items-center",children:t.length>0?t.map(l=>ee(Oe,{variant:"secondary",className:"mr-1 mb-1",children:[l.label,E("div",{role:"button",tabIndex:0,"aria-label":`remove ${l.label}`,className:"ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 cursor-pointer",onKeyDown:f=>{f.key==="Enter"&&F(l)},onMouseDown:f=>{f.preventDefault(),f.stopPropagation()},onClick:()=>F(l),children:E(bo,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},l.label)):E("span",{className:"text-foreground",children:a})}),E(xo,{className:"size-4"})]})}),E(me,{align:"start",className:"w-full p-0",children:E(ut,{children:ee(ft,{children:[E(gt,{children:"No item found."}),Object.entries(d).map(([l,f],c)=>ee(ho,{children:[c>0&&E(vt,{}),E(Ft,{heading:v?l:void 0,children:f.map(i=>{let m=t.some(g=>g.value===i.value);return ee(yt,{onSelect:()=>{r(m?t.filter(g=>g.value!==i.value):[...t,i])},children:[E(Co,{className:u("mr-2 h-4 w-4",m?"opacity-100":"opacity-0")}),i.label]},i.label)})})]},l))]})})})]})}o(ge,"MultiSelect");import{jsx as J,jsxs as ko}from"react/jsx-runtime";function ht({label:e,name:t,options:r,defaultValue:a,description:s,onChange:n,$meta:p,component:F,...v}){let{control:d}=Po(),{components:l}=b(),[f,c]=So([]);return J(S,{defaultValue:a,control:d,name:t,render:({field:i,fieldState:m})=>{let g=F||l?.countries;if(g){let C={label:e,name:t,options:r,defaultValue:a,description:s,onChange:n,$meta:p,...v};return J(g,{field:{...i,onChange:o(L=>{i.onChange(L),n?.(L)},"onChange")},fieldState:m,fieldData:C})}let y=[...Object.entries(p?.regions||{}).map(([C,L])=>({value:L,label:C,category:"Regions"})),...Object.entries(p?.subregions||{}).map(([C,L])=>({value:L,label:C,category:"Subregions"})),...r.map(C=>({...C,value:C.value,label:C.label,category:"Countries"}))],x=o(C=>{let L=C.map(({value:Lt})=>Lt);i.onChange(L),n?.(L),c(C)},"handleChange");return ko(k,{"data-field":t,className:`RemoteFlows__CountryField__Item__${t}`,children:[J(P,{className:"RemoteFlows__CountryField__Label",children:e}),J(N,{children:J(ge,{options:y,selected:f,onChange:x,...v})}),s&&J(R,{children:s}),m.error&&J(D,{})]})}})}o(ht,"CountryField");import{useFormContext as Ro}from"react-hook-form";import*as _t from"react";import{jsx as No}from"react/jsx-runtime";var We=_t.forwardRef(({className:e,...t},r)=>No("textarea",{className:u("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...t}));We.displayName="Textarea";import{jsx as q,jsxs as Le}from"react/jsx-runtime";function Ct({name:e,description:t,label:r,onChange:a,maxLength:s,component:n,...p}){let{components:F}=b(),{control:v}=Ro();return q(S,{control:v,name:e,render:({field:d,fieldState:l})=>{let f=n||F?.textarea;if(f){let i={name:e,description:t,label:r,maxLength:s,...p};return q(f,{field:{...d,onChange:o(m=>{d.onChange(m),a?.(m)},"onChange")},fieldState:l,fieldData:i})}let c=d.value?.length??0;return Le(k,{"data-field":e,className:`RemoteFlows__TextArea__Item__${e}`,children:[q(P,{className:"RemoteFlows__TextArea__Label",children:r}),q(N,{children:q(We,{...d,value:d.value??"",onChange:i=>{d.onChange(i),a?.(i)},className:u(l.error&&"border-red-500 focus-visible:ring-red-500","RemoteFlows__TextArea__Input"),placeholder:r})}),(t||s)&&Le("div",{className:"flex items-center justify-between",children:[t&&q(R,{className:"RemoteFlows__TextArea__Description",children:t}),s&&Le("span",{className:"text-sm ml-auto RemoteFlows__TextArea__MaxLength",children:[c,"/",s]})]}),l.error&&q(D,{className:"RemoteFlows__TextArea__Error"})]})}})}o(Ct,"TextAreaField");import{useFormContext as wo}from"react-hook-form";import{jsx as $e}from"react/jsx-runtime";function xt(e){let{components:t}=b(),{control:r}=wo(),a=e.component||t?.email;return a?$e(S,{control:r,name:e.name,render:({field:s,fieldState:n})=>$e(a,{field:{...s,onChange:o(p=>{s.onChange(p),e.onChange?.(p)},"onChange")},fieldState:n,fieldData:e})}):$e(A,{...e,type:"email"})}o(xt,"EmailField");import{useFormContext as Do}from"react-hook-form";import{jsx as bt}from"react/jsx-runtime";function St(e){let{control:t}=Do();return bt(S,{control:t,name:e.name,render:({field:r})=>bt("input",{...r,type:"hidden"})})}o(St,"HiddenField");import $o,{useEffect as Eo,useState as wt}from"react";import{yupResolver as Ho}from"@hookform/resolvers/yup";import{useForm as Bo,useFormContext as Ao,useFieldArray as Oo}from"react-hook-form";import*as I from"yup";import Pt from"lodash.groupby";import te from"lodash.capitalize";var kt=60,Fe=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];function To(e){if(e<60)return`${e}m`;let t=Math.floor(e/kt),r=e%kt;return r>0?`${t}h${r}m`:`${t}h`}o(To,"convertBreakDurationToHours");function Nt(e){let t=e.reduce((r,a)=>a.hours+r,0);return Number(t.toFixed(2))}o(Nt,"calculateTotalWorkHours");function Io(e,t){let r=t.map(({day:n})=>n.toLowerCase()),a=r.indexOf(e),s=null;for(;a<r.length&&!s;){let n=r[a],p=r[a+1],F=Fe.indexOf(n)+1;Fe[F]===p||(s=n),a+=1}return s}o(Io,"findLastConsecutiveDay");function Mo(e){return e.start_time&&e.end_time&&(typeof e.hours=="number"?e.hours:Number.parseInt(e.hours))>0}o(Mo,"shouldSummarizeSchedule");function Wo(e){return Number.parseInt(e.break_duration_minutes)>0}o(Wo,"shouldSummarizeBreaks");function Rt(e){let t=e.filter(Mo),r=Pt(t,F=>`${F.start_time}|${F.end_time}`),a=e.filter(Wo),s=Pt(a,"break_duration_minutes"),n=Object.keys(r).map(F=>{let v=r[F],d=v[0].day,[l,f]=F.split("|"),c=`from <span>${l.replace(":","h")}</span> to <span>${f.replace(":","h")}</span>`,i=Io(d,v),g=(i?v.findIndex(y=>y.day===i):-1)===v.length-1;return v.length===1?`${te(d)}, ${c}`:!g||!i?v.reduce((y,x,C)=>{let L=te(x.day);return C===v.length-1?`${y}and ${L}, ${c}`:`${y}<span>${L}</span>, `},""):`<span>${te(d)}</span> to <span>${te(i)}</span>, ${c}`}),p=Object.keys(s).reverse().map((F,v)=>{let d=v===0,l=s[F],f=To(parseInt(F,10));if(Object.keys(s).length===1)return`With ${f} daily breaks`;if(l.length===1){let c=`${f} break on ${te(l[0].day)}.`;return d?`With ${c}`:c}return l.reduce((c,i,m)=>{let g=te(i.day);return m===0?`${c} ${g}`:m===l.length-1?`${c}, and ${g}.`:`${c}, ${g}`},d?`With ${f} break on`:`${f} break on`)});return{workHoursSummary:n,breakSummary:p}}o(Rt,"buildWorkScheduleSummary");function Ee(e){let{checked:t,start_time:r,end_time:a,break_duration_minutes:s}=e;if(!t)return 0;let[n,p]=r.split(":").map(Number),[F,v]=a.split(":").map(Number),d=n*60+p,c=(F*60+v-d-Number.parseInt(s||"0"))/60;return c===Math.floor(c)?c:Number(c.toFixed(2))}o(Ee,"calculateHours");var Lo={monday:"Mon",tuesday:"Tue",wednesday:"Wed",thursday:"Thu",friday:"Fri",saturday:"Sat",sunday:"Sun"};function ve(e){return Lo[e]}o(ve,"getShortWeekday");import{jsx as h,jsxs as H}from"react/jsx-runtime";var zo=I.object({day:I.string().required(),checked:I.boolean().required(),start_time:I.string().matches(/^([01]\d|2[0-3]):([0-5]\d)$/,"Invalid time format (HH:mm)").when("checked",{is:!0,then:o(e=>e.required("Required"),"then"),otherwise:o(e=>e.optional().nullable(),"otherwise")}),end_time:I.string().matches(/^([01]\d|2[0-3]):([0-5]\d)$/,"Invalid time format (HH:mm)").when("checked",{is:!0,then:o(e=>e.required("Required"),"then"),otherwise:o(e=>e.optional().nullable(),"otherwise")}),hours:I.number().default(0),break_duration_minutes:I.string().default("0")}),Vo=I.object({schedule:I.array(zo)});function Go({defaultSchedule:e,onSubmit:t}){let[r,a]=wt(!1),s=Fe.map(g=>{let y=e.find(x=>x.day.toLowerCase()===ve(g).toLowerCase()||x.day.toLowerCase()===g.toLowerCase());return y?{...y,day:ve(g),checked:!0}:{...e[0],checked:!1,day:ve(g)}}),n=Bo({defaultValues:{schedule:s},resolver:Ho(Vo)}),{handleSubmit:p,watch:F,reset:v,control:d,formState:l}=n,{fields:f}=Oo({name:"schedule",control:d}),c=F("schedule");function i(g){let y=g.schedule.filter(({checked:x})=>x).map(x=>({...x,hours:Ee(x)}));t(y),a(!1)}o(i,"handleSubmitWorkingHours");function m(){v(),a(!1)}return o(m,"handleCancel"),h("div",{className:"flex items-center justify-between",children:H(De,{open:r,onOpenChange:a,children:[h(pt,{asChild:!0,children:h(B,{variant:"link",className:"flex items-center p-0 RemoteFlows__WorkScheduleSelectionForm__Trigger",children:"Edit Schedule"})}),H(Te,{className:"max-w-5xl max-h-[90vh] overflow-y-auto px-8 py-4 RemoteFlows__WorkScheduleSelectionForm__Content",children:[h(Ie,{children:h(Me,{className:"RemoteFlows__WorkScheduleSelectionForm__Title",children:"Edit employee working hours"})}),h(Ae,{...n,children:H("form",{className:"space-y-4 RemoteFlows__WorkScheduleSelectionForm__Form",children:[H("div",{className:"rounded-lg",children:[h("p",{className:"text-gray-600 text-sm mb-4 RemoteFlows__WorkScheduleSelectionForm__Description",children:"The times displayed are in the employee's time zone in the 24-hour format."}),H("div",{className:"grid grid-cols-12 gap-4 text-sm font-medium text-gray-500 uppercase tracking-wide RemoteFlows__WorkScheduleSelectionForm__Header",children:[h("div",{className:"col-span-2"}),h("div",{className:"col-span-3 text-center",children:"START"}),h("div",{className:"col-span-1 text-center"}),h("div",{className:"col-span-3 text-center",children:"END"}),h("div",{className:"col-span-2 text-center",children:"HOURS"})]}),h("div",{className:"RemoteFlows__WorkScheduleSelectionForm__Rows",children:f.map((g,y)=>{let x=c[y],C=Ee(x);return H($o.Fragment,{children:[H("div",{className:"grid grid-cols-12 gap-4 items-center py-2 RemoteFlows__WorkScheduleSelectionForm__Row-Hours",children:[h("div",{className:"col-span-2 flex items-center gap-3",children:h(ne,{label:g.day,name:`schedule.${y}.checked`})}),h("div",{className:"col-span-3",children:h(A,{name:`schedule.${y}.start_time`,includeErrorMessage:!1})}),h("div",{className:"col-span-1 text-center text-gray-500",children:"to"}),h("div",{className:"col-span-3",children:h(A,{name:`schedule.${y}.end_time`,includeErrorMessage:!1})}),h("div",{className:"col-span-2 text-center text-gray-600",children:isNaN(C)?"-":`${C} hours`})]}),H("div",{className:"grid grid-cols-12 gap-4 items-center py-2 RemoteFlows__WorkScheduleSelectionForm__Row-Break",children:[h("div",{className:"col-span-2 text-gray-500",children:"Break"}),h("div",{className:"col-span-2",children:h(A,{name:`schedule.${y}.break_duration_minutes`,includeErrorMessage:!1})}),h("div",{className:"col-span-2 text-gray-500",children:"minutes"}),h("div",{className:"col-span-4"})]})]},g.id)})})]}),Object.keys(l.errors).length>0&&h("p",{className:"text-destructive text-sm mb-0",children:"Invalid time format (HH:mm)"}),H("div",{className:"flex gap-4 pt-4",children:[h(B,{type:"button",className:"reset-button",variant:"outline",onClick:m,children:"Cancel"}),h(B,{type:"button",className:"submit-button",onClick:p(i),children:"Save Schedule"})]})]})})]})]})})}o(Go,"WorkScheduleSelectionForm");function Dt(e){let{components:t}=b(),{setValue:r,control:a,watch:s}=Ao(),n=s(e.name),[p,F]=wt(n),{workHoursSummary:v,breakSummary:d}=Rt(p),l=Nt(p);Eo(()=>{r(e.name,p)},[p,e.name,r]);function f(i){F(i)}o(f,"onSubmit");let c=e.component||t?.["work-schedule"];return c?h(S,{control:a,name:e.name,render:({field:i,fieldState:m})=>h(c,{field:{...i,onChange:o(g=>{i.onChange(g),e.onChange?.(g)},"onChange")},fieldState:m,fieldData:{...e,defaultFormattedValue:{workHoursSummary:v,breakSummary:d,totalWorkHours:l}}})}):H("div",{className:"flex flex-col gap-3 RemoteFlows__WorkScheduleField",children:[h("p",{className:"text-sm RemoteFlows__WorkScheduleField__Title",children:"Work hours"}),H("div",{className:"flex flex-col gap-1 RemoteFlows__WorkScheduleField__Summary",children:[h("p",{className:"text-sm text-gray-500 RemoteFlows__WorkScheduleField__Summary__WorkHours",dangerouslySetInnerHTML:{__html:v.join(", ")}}),h("p",{className:"text-sm text-gray-500 RemoteFlows__WorkScheduleField__Summary__Break",children:d.join()}),H("p",{className:"text-sm text-gray-500 RemoteFlows__WorkScheduleField__Summary__Total",children:["Total of ",h("span",{children:l})," hours per week"]}),h(Go,{defaultSchedule:p,onSubmit:f})]})]})}o(Dt,"WorkScheduleField");import{useFormContext as Uo}from"react-hook-form";import{useState as Jo}from"react";import{jsx as K,jsxs as qo}from"react/jsx-runtime";function Tt({label:e,name:t,options:r,defaultValue:a,description:s,onChange:n,component:p,...F}){let{control:v}=Uo(),{components:d}=b(),[l,f]=Jo();return K(S,{defaultValue:a,control:v,name:t,render:({field:c,fieldState:i})=>{let m=p||d?.["multi-select"];if(m){let y={label:e,name:t,options:r,defaultValue:a,description:s,onChange:n,...F};return K(m,{field:{...c,onChange:o(x=>{c.onChange(x),n?.(x)},"onChange")},fieldState:i,fieldData:y})}let g=l||r.filter(y=>c.value.includes(y.value));return qo(k,{"data-field":t,className:`RemoteFlows__SelectField__Item__${t}`,children:[K(P,{className:"RemoteFlows__SelectField__Label",children:e}),K(N,{children:K(ge,{options:r,selected:g,onChange:y=>{let x=y.map(({value:C})=>C);c.onChange(x),n?.(x),f(y)},...F})}),s&&K(R,{children:s}),i.error&&K(D,{})]})}})}o(Tt,"MultiSelectField");import{jsx as Ko}from"react/jsx-runtime";var It=o(e=>Ko(ue,{maxLength:15,...e}),"MoneyField");var X={checkbox:ne,text:A,email:xt,money:It,select:dt,"multi-select":Tt,radio:ot,number:ue,file:je,fieldset:Se,"fieldset-flat":Se,date:Ue,textarea:Ct,countries:ht,hidden:St,"work-schedule":Dt};import{useEffect as Yo}from"react";import{useFormContext as Xo}from"react-hook-form";import{Fragment as Qo,jsx as ye,jsxs as Zo}from"react/jsx-runtime";function Mt({name:e,value:t,description:r,statement:a}){let{setValue:s}=Xo();return Yo(()=>{s(e,t)},[]),ye("div",{children:a?Zo(Qo,{children:[ye("p",{className:`text-sm RemoteFlows__ForcedValue__Title__${e}`,dangerouslySetInnerHTML:{__html:a?.title}}),ye("p",{className:`text-xs RemoteFlows__ForcedValue__Description__${e}`,dangerouslySetInnerHTML:{__html:a?.description}})]}):ye("p",{className:`text-xs RemoteFlows__ForcedValue__Description__${e}`,dangerouslySetInnerHTML:{__html:r}})})}o(Mt,"ForcedValueField");import{Fragment as tr,jsx as Y,jsxs as Wt}from"react/jsx-runtime";function er(e){return e.const!==void 0&&e.const===e.default&&e.inputType!=="checkbox"&&e.inputType!=="hidden"}o(er,"checkFieldHasForcedValue");var ps=o(({fields:e,fieldsets:t,fieldValues:r,components:a})=>{if(!e||e.length===0)return null;let s=t&&r?He({fields:e,fieldsets:t,values:r}):e;return Y(tr,{children:s.map(n=>{if(n.isVisible===!1||n.deprecated)return null;if(er(n))return Y(Mt,{name:n.name,description:n.description,value:n.const,statement:n.statement},n.name);if(n.Component){let{Component:F}=n;return Y(F,{...n},n.name)}let p=X[n.inputType];return n.inputType==="select"&&n.multiple&&(p=X["multi-select"]),n.inputType==="fieldset"?Y(p,{...n,components:a}):n.inputType==="fieldset-flat"?Y(p,{...n,components:a,isFlatFieldset:!0}):p?Wt(jo,{children:[Y(p,{...n,component:a&&a[n.inputType]}),n.statement?Y(de,{...n.statement}):null]},n.name):Wt("p",{className:"error",children:["Field type ",n.inputType," not supported"]})})})},"JSONSchemaFormFields");export{ps as a};
2
- //# sourceMappingURL=chunk-Y6K2UK3D.js.map