@remoteoss/remote-flows 0.1.1 → 0.2.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 (195) hide show
  1. package/README.md +2 -0
  2. package/dist/chunk-2EKC7DK3.js +2 -0
  3. package/dist/chunk-2EKC7DK3.js.map +1 -0
  4. package/dist/chunk-36UPHOJS.js +2 -0
  5. package/dist/chunk-36UPHOJS.js.map +1 -0
  6. package/dist/chunk-37DREOGC.js +2 -0
  7. package/dist/chunk-37DREOGC.js.map +1 -0
  8. package/dist/chunk-55VACCVZ.js +2 -0
  9. package/dist/{chunk-5UXOVZY5.js.map → chunk-55VACCVZ.js.map} +1 -1
  10. package/dist/chunk-5DQBY2TR.js +2 -0
  11. package/dist/chunk-5DQBY2TR.js.map +1 -0
  12. package/dist/chunk-6HGUGIYJ.js +2 -0
  13. package/dist/chunk-6HGUGIYJ.js.map +1 -0
  14. package/dist/chunk-6LTJBLSD.js +2 -0
  15. package/dist/chunk-6LTJBLSD.js.map +1 -0
  16. package/dist/chunk-A7ZJQCNU.js +1 -0
  17. package/dist/chunk-AYFHWLQZ.js +2 -0
  18. package/dist/chunk-AYFHWLQZ.js.map +1 -0
  19. package/dist/chunk-CKGTR44U.js +2 -0
  20. package/dist/chunk-CKGTR44U.js.map +1 -0
  21. package/dist/chunk-CTG3DYJR.js +2 -0
  22. package/dist/chunk-CTG3DYJR.js.map +1 -0
  23. package/dist/chunk-DZYFSFZ7.js +2 -0
  24. package/dist/chunk-DZYFSFZ7.js.map +1 -0
  25. package/dist/chunk-EQBNHLR4.js +2 -0
  26. package/dist/chunk-EQBNHLR4.js.map +1 -0
  27. package/dist/chunk-F5QJZKDL.js +2 -0
  28. package/dist/{chunk-Q6GIPVSE.js.map → chunk-F5QJZKDL.js.map} +1 -1
  29. package/dist/chunk-FZ2HS6G7.js +2 -0
  30. package/dist/chunk-FZ2HS6G7.js.map +1 -0
  31. package/dist/chunk-FZ7FWFJX.js +1 -0
  32. package/dist/chunk-FZ7FWFJX.js.map +1 -0
  33. package/dist/chunk-GW7GG5ZW.js +2 -0
  34. package/dist/chunk-GW7GG5ZW.js.map +1 -0
  35. package/dist/chunk-HP7ZP256.js +2 -0
  36. package/dist/chunk-HP7ZP256.js.map +1 -0
  37. package/dist/chunk-IJPE22L7.js +2 -0
  38. package/dist/chunk-IJPE22L7.js.map +1 -0
  39. package/dist/chunk-IPZEZMLD.js +2 -0
  40. package/dist/chunk-IPZEZMLD.js.map +1 -0
  41. package/dist/chunk-JLUDKN4H.js +2 -0
  42. package/dist/chunk-JLUDKN4H.js.map +1 -0
  43. package/dist/chunk-JODJFARP.js +2 -0
  44. package/dist/chunk-JODJFARP.js.map +1 -0
  45. package/dist/chunk-JRQSZHUU.js +2 -0
  46. package/dist/chunk-JRQSZHUU.js.map +1 -0
  47. package/dist/chunk-KPSFJ6BN.js +2 -0
  48. package/dist/chunk-KPSFJ6BN.js.map +1 -0
  49. package/dist/chunk-LNF27NTC.js +2 -0
  50. package/dist/chunk-LNF27NTC.js.map +1 -0
  51. package/dist/chunk-N5AQSLAU.js +2 -0
  52. package/dist/chunk-N5AQSLAU.js.map +1 -0
  53. package/dist/{chunk-KQCZ2KSO.js → chunk-NBD4VOG3.js} +2 -2
  54. package/dist/{chunk-KQCZ2KSO.js.map → chunk-NBD4VOG3.js.map} +1 -1
  55. package/dist/chunk-RCX4JUI3.js +2 -0
  56. package/dist/chunk-RCX4JUI3.js.map +1 -0
  57. package/dist/chunk-S56EWAS4.js +2 -0
  58. package/dist/chunk-S56EWAS4.js.map +1 -0
  59. package/dist/chunk-SABMDOWE.js +2 -0
  60. package/dist/chunk-SABMDOWE.js.map +1 -0
  61. package/dist/chunk-SEUQNAF6.js +2 -0
  62. package/dist/chunk-SEUQNAF6.js.map +1 -0
  63. package/dist/chunk-VX2UC3HG.js +2 -0
  64. package/dist/chunk-VX2UC3HG.js.map +1 -0
  65. package/dist/chunk-W5DG5WWJ.js +2 -0
  66. package/dist/chunk-W5DG5WWJ.js.map +1 -0
  67. package/dist/chunk-XFD3ULUF.js +2 -0
  68. package/dist/chunk-XFD3ULUF.js.map +1 -0
  69. package/dist/chunk-XULIEA44.js +2 -0
  70. package/dist/{chunk-YNLDKIE4.js.map → chunk-XULIEA44.js.map} +1 -1
  71. package/dist/{chunk-VV7RML2Q.js → chunk-YAHWFLDH.js} +2 -2
  72. package/dist/chunk-YBACB5A6.js +2 -0
  73. package/dist/chunk-YBACB5A6.js.map +1 -0
  74. package/dist/flows/ContractAmendment/ContractAmendmentBack.d.ts +5 -0
  75. package/dist/flows/ContractAmendment/ContractAmendmentBack.js +2 -0
  76. package/dist/flows/ContractAmendment/ContractAmendmentBack.js.map +1 -0
  77. package/dist/flows/ContractAmendment/ContractAmendmentConfirmationForm.d.ts +30 -0
  78. package/dist/flows/ContractAmendment/ContractAmendmentConfirmationForm.js +2 -0
  79. package/dist/flows/ContractAmendment/ContractAmendmentConfirmationForm.js.map +1 -0
  80. package/dist/flows/ContractAmendment/ContractAmendmentFlow.d.ts +24 -7
  81. package/dist/flows/ContractAmendment/ContractAmendmentFlow.js +1 -1
  82. package/dist/flows/ContractAmendment/ContractAmendmentForm.d.ts +26 -3
  83. package/dist/flows/ContractAmendment/ContractAmendmentForm.js +1 -1
  84. package/dist/flows/ContractAmendment/ContractAmendmentSubmit.d.ts +1 -1
  85. package/dist/flows/ContractAmendment/ContractAmendmentSubmit.js +1 -1
  86. package/dist/flows/ContractAmendment/context.d.ts +26 -24
  87. package/dist/flows/ContractAmendment/context.js +1 -1
  88. package/dist/flows/ContractAmendment/hooks.d.ts +94 -6
  89. package/dist/flows/ContractAmendment/hooks.js +1 -1
  90. package/dist/flows/ContractAmendment/index.d.ts +8 -5
  91. package/dist/flows/ContractAmendment/index.js +1 -1
  92. package/dist/flows/ContractAmendment/utils.d.ts +11 -0
  93. package/dist/flows/ContractAmendment/utils.js +2 -0
  94. package/dist/flows/ContractAmendment/utils.js.map +1 -0
  95. package/dist/flows/CostCalculator/CostCalculatorFlow.d.ts +2 -2
  96. package/dist/flows/CostCalculator/CostCalculatorFlow.js +1 -1
  97. package/dist/flows/CostCalculator/CostCalculatorForm.d.ts +1 -1
  98. package/dist/flows/CostCalculator/CostCalculatorForm.js +1 -1
  99. package/dist/flows/CostCalculator/Results/CostCalculatorResults.d.ts +1 -1
  100. package/dist/flows/CostCalculator/Results/CostCalculatorResults.js +1 -1
  101. package/dist/flows/CostCalculator/context.d.ts +1 -1
  102. package/dist/flows/CostCalculator/hooks.d.ts +1 -1
  103. package/dist/flows/CostCalculator/hooks.js +1 -1
  104. package/dist/flows/CostCalculator/index.d.ts +1 -1
  105. package/dist/flows/CostCalculator/index.js +1 -1
  106. package/dist/flows/CostCalculator/types.d.ts +1 -1
  107. package/dist/flows/CostCalculator/utils.d.ts +1 -1
  108. package/dist/flows/CostCalculator/utils.js +1 -1
  109. package/dist/flows/Termination/TerminationBack.d.ts +5 -0
  110. package/dist/flows/Termination/TerminationBack.js +2 -0
  111. package/dist/flows/Termination/TerminationBack.js.map +1 -0
  112. package/dist/flows/Termination/TerminationFlow.d.ts +46 -0
  113. package/dist/flows/Termination/TerminationFlow.js +2 -0
  114. package/dist/flows/Termination/TerminationFlow.js.map +1 -0
  115. package/dist/flows/Termination/TerminationForm.d.ts +13 -0
  116. package/dist/flows/Termination/TerminationForm.js +2 -0
  117. package/dist/flows/Termination/TerminationForm.js.map +1 -0
  118. package/dist/flows/Termination/TerminationSubmit.d.ts +5 -0
  119. package/dist/flows/Termination/TerminationSubmit.js +2 -0
  120. package/dist/flows/Termination/TerminationSubmit.js.map +1 -0
  121. package/dist/flows/Termination/TimeOff.d.ts +11 -0
  122. package/dist/flows/Termination/TimeOff.js +2 -0
  123. package/dist/flows/Termination/TimeOff.js.map +1 -0
  124. package/dist/flows/Termination/context.d.ts +52 -0
  125. package/dist/flows/Termination/context.js +2 -0
  126. package/dist/flows/Termination/context.js.map +1 -0
  127. package/dist/flows/Termination/hooks.d.ts +86 -0
  128. package/dist/flows/Termination/hooks.js +2 -0
  129. package/dist/flows/Termination/hooks.js.map +1 -0
  130. package/dist/flows/Termination/index.d.ts +14 -0
  131. package/dist/flows/Termination/index.js +2 -0
  132. package/dist/flows/Termination/index.js.map +1 -0
  133. package/dist/flows/Termination/json-schemas/additionalInformation.d.ts +25 -0
  134. package/dist/flows/Termination/json-schemas/additionalInformation.js +2 -0
  135. package/dist/flows/Termination/json-schemas/additionalInformation.js.map +1 -0
  136. package/dist/flows/Termination/json-schemas/defaultSchema.d.ts +15 -0
  137. package/dist/flows/Termination/json-schemas/defaultSchema.js +2 -0
  138. package/dist/flows/Termination/json-schemas/defaultSchema.js.map +1 -0
  139. package/dist/flows/Termination/json-schemas/employeeComunication.d.ts +133 -0
  140. package/dist/flows/Termination/json-schemas/employeeComunication.js +2 -0
  141. package/dist/flows/Termination/json-schemas/employeeComunication.js.map +1 -0
  142. package/dist/flows/Termination/json-schemas/jsonSchema.d.ts +339 -0
  143. package/dist/flows/Termination/json-schemas/jsonSchema.js +2 -0
  144. package/dist/flows/Termination/json-schemas/jsonSchema.js.map +1 -0
  145. package/dist/flows/Termination/json-schemas/paidTimeOff.d.ts +71 -0
  146. package/dist/flows/Termination/json-schemas/paidTimeOff.js +2 -0
  147. package/dist/flows/Termination/json-schemas/paidTimeOff.js.map +1 -0
  148. package/dist/flows/Termination/json-schemas/schema.d.ts +8 -0
  149. package/dist/flows/Termination/json-schemas/schema.js +2 -0
  150. package/dist/flows/Termination/json-schemas/schema.js.map +1 -0
  151. package/dist/flows/Termination/json-schemas/terminationDetails.d.ts +126 -0
  152. package/dist/flows/Termination/json-schemas/terminationDetails.js +2 -0
  153. package/dist/flows/Termination/json-schemas/terminationDetails.js.map +1 -0
  154. package/dist/flows/Termination/types.d.ts +23 -0
  155. package/dist/flows/Termination/types.js +1 -0
  156. package/dist/flows/Termination/types.js.map +1 -0
  157. package/dist/flows/Termination/utils.d.ts +8 -0
  158. package/dist/flows/Termination/utils.js +2 -0
  159. package/dist/flows/Termination/utils.js.map +1 -0
  160. package/dist/flows/useStepState.d.ts +49 -0
  161. package/dist/flows/useStepState.js +2 -0
  162. package/dist/flows/useStepState.js.map +1 -0
  163. package/dist/flows/utils.d.ts +20 -1
  164. package/dist/flows/utils.js +1 -1
  165. package/dist/index.css +1 -1
  166. package/dist/index.css.map +1 -1
  167. package/dist/index.d.ts +69 -8
  168. package/dist/index.js +1 -1
  169. package/dist/index.js.map +1 -1
  170. package/dist/mutations-v9H353tz.d.ts +10 -0
  171. package/dist/{types.gen-DCJSPsGk.d.ts → types.gen-BgLeTAqP.d.ts} +1 -1
  172. package/package.json +2 -1
  173. package/dist/chunk-4QHHDFB2.js +0 -2
  174. package/dist/chunk-4QHHDFB2.js.map +0 -1
  175. package/dist/chunk-5UXOVZY5.js +0 -2
  176. package/dist/chunk-ANPGCYMT.js +0 -2
  177. package/dist/chunk-ANPGCYMT.js.map +0 -1
  178. package/dist/chunk-GCF5EF2A.js +0 -2
  179. package/dist/chunk-GCF5EF2A.js.map +0 -1
  180. package/dist/chunk-GKEURJR4.js +0 -2
  181. package/dist/chunk-GKEURJR4.js.map +0 -1
  182. package/dist/chunk-KY7BGW6H.js +0 -2
  183. package/dist/chunk-KY7BGW6H.js.map +0 -1
  184. package/dist/chunk-MKJHD77O.js +0 -1
  185. package/dist/chunk-Q6GIPVSE.js +0 -2
  186. package/dist/chunk-UTCIIPYZ.js +0 -2
  187. package/dist/chunk-UTCIIPYZ.js.map +0 -1
  188. package/dist/chunk-VTAHQOKR.js +0 -2
  189. package/dist/chunk-VTAHQOKR.js.map +0 -1
  190. package/dist/chunk-YGP3O2VJ.js +0 -2
  191. package/dist/chunk-YGP3O2VJ.js.map +0 -1
  192. package/dist/chunk-YNLDKIE4.js +0 -2
  193. package/dist/hooks-BQWrl9Bj.d.ts +0 -50
  194. /package/dist/{chunk-MKJHD77O.js.map → chunk-A7ZJQCNU.js.map} +0 -0
  195. /package/dist/{chunk-VV7RML2Q.js.map → chunk-YAHWFLDH.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/Termination/json-schemas/additionalInformation.ts"],"sourcesContent":["export const additionalInformationSchema = {\n data: {\n version: 7,\n schema: {\n additionalProperties: false,\n allOf: [],\n properties: {\n acknowledge_termination_procedure: {\n description: '',\n title:\n 'I, {{username}} have read and agree to the procedures as defined in the termination form.',\n type: 'boolean',\n 'x-jsf-presentation': {\n direction: 'column',\n inputType: 'checkbox',\n },\n },\n },\n required: ['acknowledge_termination_procedure'],\n type: 'object',\n 'x-jsf-order': ['acknowledge_termination_procedure'],\n },\n },\n};\n"],"mappings":"AAAO,IAAMA,EAA8B,CACzC,KAAM,CACJ,QAAS,EACT,OAAQ,CACN,qBAAsB,GACtB,MAAO,CAAC,EACR,WAAY,CACV,kCAAmC,CACjC,YAAa,GACb,MACE,4FACF,KAAM,UACN,qBAAsB,CACpB,UAAW,SACX,UAAW,UACb,CACF,CACF,EACA,SAAU,CAAC,mCAAmC,EAC9C,KAAM,SACN,cAAe,CAAC,mCAAmC,CACrD,CACF,CACF","names":["additionalInformationSchema"]}
@@ -0,0 +1,2 @@
1
+ import{h as o,l as i}from"./chunk-55VACCVZ.js";import{d as n}from"./chunk-WRDKLT4N.js";import{a as e}from"./chunk-AYDF3IFZ.js";import{useQuery as s}from"@tanstack/react-query";var p=e(({employmentId:t})=>{let{client:r}=n();return s({queryKey:["employment",t],retry:!1,queryFn:e(()=>o({client:r,headers:{Authorization:""},path:{employment_id:t}}),"queryFn"),select:e(({data:m})=>m,"select")})},"useEmploymentQuery"),c=e(({employmentId:t,status:r})=>{let{client:m}=n();return s({queryKey:["timeoff",t,r],retry:!1,queryFn:e(()=>i({client:m,headers:{Authorization:""},query:{employment_id:t,status:r}}),"queryFn"),select:e(({data:u})=>u,"select")})},"useTimeOffQuery");export{p as a,c as b};
2
+ //# sourceMappingURL=chunk-JLUDKN4H.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/common/hooks.ts"],"sourcesContent":["import {\n getIndexTimeoff,\n getShowEmployment,\n TimeoffStatus,\n} from '@/src/client';\nimport { useClient } from '@/src/context';\nimport { ContractAmendmentParams } from '@/src/flows/ContractAmendment/types';\nimport { Client } from '@hey-api/client-fetch';\nimport { useQuery } from '@tanstack/react-query';\n\ntype UseEmployment = Pick<ContractAmendmentParams, 'employmentId'>;\n\n/**\n * Hook to retrieve employment details for a specific employment ID.\n *\n * @param {Object} params - The parameters for the query.\n * @param {string} params.employmentId - The ID of the employment to fetch details for.\n * @returns {UseQueryResult<any, unknown>} - The result of the query, including the employment details.\n */\nexport const useEmploymentQuery = ({ employmentId }: UseEmployment) => {\n const { client } = useClient();\n return useQuery({\n queryKey: ['employment', employmentId],\n retry: false,\n queryFn: () => {\n return getShowEmployment({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n path: { employment_id: employmentId },\n });\n },\n select: ({ data }) => data,\n });\n};\n\n/**\n * Hook to retrieve time off data for a specific employment.\n *\n * @param {Object} params - The parameters for the query.\n * @param {string} [params.employmentId] - The ID of the employment to fetch time off data for.\n * @param {TimeoffStatus} [params.status] - The status of the time off requests to filter by (e.g., 'approved', 'pending').\n * @returns {UseQueryResult<any, unknown>} - The result of the query, including the time off data.\n *\n */\nexport const useTimeOffQuery = ({\n employmentId,\n status,\n}: {\n employmentId?: string;\n status?: TimeoffStatus;\n}) => {\n const { client } = useClient();\n return useQuery({\n queryKey: ['timeoff', employmentId, status],\n retry: false,\n queryFn: () => {\n return getIndexTimeoff({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n query: {\n employment_id: employmentId,\n status: status,\n },\n });\n },\n select: ({ data }) => data,\n });\n};\n"],"mappings":"+HAQA,OAAS,YAAAA,MAAgB,wBAWlB,IAAMC,EAAqBC,EAAA,CAAC,CAAE,aAAAC,CAAa,IAAqB,CACrE,GAAM,CAAE,OAAAC,CAAO,EAAIC,EAAU,EAC7B,OAAOC,EAAS,CACd,SAAU,CAAC,aAAcH,CAAY,EACrC,MAAO,GACP,QAASD,EAAA,IACAK,EAAkB,CACvB,OAAQH,EACR,QAAS,CACP,cAAe,EACjB,EACA,KAAM,CAAE,cAAeD,CAAa,CACtC,CAAC,EAPM,WAST,OAAQD,EAAA,CAAC,CAAE,KAAAM,CAAK,IAAMA,EAAd,SACV,CAAC,CACH,EAhBkC,sBA2BrBC,EAAkBP,EAAA,CAAC,CAC9B,aAAAC,EACA,OAAAO,CACF,IAGM,CACJ,GAAM,CAAE,OAAAN,CAAO,EAAIC,EAAU,EAC7B,OAAOC,EAAS,CACd,SAAU,CAAC,UAAWH,EAAcO,CAAM,EAC1C,MAAO,GACP,QAASR,EAAA,IACAS,EAAgB,CACrB,OAAQP,EACR,QAAS,CACP,cAAe,EACjB,EACA,MAAO,CACL,cAAeD,EACf,OAAQO,CACV,CACF,CAAC,EAVM,WAYT,OAAQR,EAAA,CAAC,CAAE,KAAAM,CAAK,IAAMA,EAAd,SACV,CAAC,CACH,EAzB+B","names":["useQuery","useEmploymentQuery","__name","employmentId","client","useClient","useQuery","getShowEmployment","data","useTimeOffQuery","status","getIndexTimeoff"]}
@@ -0,0 +1,2 @@
1
+ var e={data:{version:7,schema:{additionalProperties:!1,allOf:[{if:{properties:{personal_email:{pattern:"^[a-zA-Z0-9 .]+$"}}},then:{properties:{personal_email:{"x-jsf-presentation":{statement:{title:"Please make sure to add the employee personal email so we can get in contact with the employee after the termination process takes effect.",inputType:"statement",severity:"warning"}}}}}},{if:{properties:{customer_informed_employee:{const:"yes"}},required:["customer_informed_employee"]},then:{properties:{customer_informed_employee_date:{type:"string"},customer_informed_employee_description:{type:"string"}},required:["customer_informed_employee_date","customer_informed_employee_description"]},else:{properties:{customer_informed_employee_date:!1,customer_informed_employee_description:!1}}}],properties:{confidential:{description:"Confidential requests are visible only to you. Non-confidential requests are visible to all admins in your company.",oneOf:[{const:"yes",description:"",title:"Yes"},{const:"no",description:"",title:"No"}],title:"Is this request confidential?",type:"string","x-jsf-presentation":{direction:"column",inputType:"radio",statement:{title:"Please do not inform the employee of their termination until we review your request for legal risks. When we approve your request, you can inform the employee and we'll take it from there.",inputType:"statement",severity:"warning"}}},customer_informed_employee:{description:"",oneOf:[{const:"yes",description:"",title:"Yes"},{const:"no",description:"",title:"No"}],title:"Have you informed the employee of the termination?",type:"string","x-jsf-presentation":{direction:"column",inputType:"radio"}},customer_informed_employee_date:{description:"",format:"date",maxLength:255,title:"When the employee was told about the termination",type:["string","null"],"x-jsf-presentation":{inputType:"date"}},customer_informed_employee_description:{description:"",maxLength:1e3,title:"How did you share this information?",type:["string","null"],"x-jsf-presentation":{inputType:"textarea"}},personal_email:{description:"",maxLength:255,title:"Employee's personal email",format:"email",type:"string","x-jsf-presentation":{inputType:"email"}}},required:["confidential","customer_informed_employee","personal_email"],type:"object","x-jsf-order":["is_confidential","customer_informed_employee","customer_informed_employee_date","customer_informed_employee_description","personal_email"]}}};export{e as a};
2
+ //# sourceMappingURL=chunk-JODJFARP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/Termination/json-schemas/employeeComunication.ts"],"sourcesContent":["export const employeeComunicationSchema = {\n data: {\n version: 7,\n schema: {\n additionalProperties: false,\n allOf: [\n {\n if: {\n properties: {\n personal_email: {\n pattern: '^[a-zA-Z0-9 .]+$',\n },\n },\n },\n then: {\n properties: {\n personal_email: {\n 'x-jsf-presentation': {\n statement: {\n title:\n 'Please make sure to add the employee personal email so we can get in contact with the employee after the termination process takes effect.',\n inputType: 'statement',\n severity: 'warning',\n },\n },\n },\n },\n },\n },\n {\n if: {\n properties: {\n customer_informed_employee: {\n const: 'yes',\n },\n },\n required: ['customer_informed_employee'],\n },\n then: {\n properties: {\n customer_informed_employee_date: {\n type: 'string',\n },\n customer_informed_employee_description: {\n type: 'string',\n },\n },\n required: [\n 'customer_informed_employee_date',\n 'customer_informed_employee_description',\n ],\n },\n else: {\n properties: {\n customer_informed_employee_date: false,\n customer_informed_employee_description: false,\n },\n },\n },\n ],\n properties: {\n confidential: {\n description:\n 'Confidential requests are visible only to you. Non-confidential requests are visible to all admins in your company.',\n oneOf: [\n {\n const: 'yes',\n description: '',\n title: 'Yes',\n },\n {\n const: 'no',\n description: '',\n title: 'No',\n },\n ],\n title: 'Is this request confidential?',\n type: 'string',\n 'x-jsf-presentation': {\n direction: 'column',\n inputType: 'radio',\n statement: {\n title:\n \"Please do not inform the employee of their termination until we review your request for legal risks. When we approve your request, you can inform the employee and we'll take it from there.\",\n inputType: 'statement',\n severity: 'warning',\n },\n },\n },\n customer_informed_employee: {\n description: '',\n oneOf: [\n {\n const: 'yes',\n description: '',\n title: 'Yes',\n },\n {\n const: 'no',\n description: '',\n title: 'No',\n },\n ],\n title: 'Have you informed the employee of the termination?',\n type: 'string',\n 'x-jsf-presentation': {\n direction: 'column',\n inputType: 'radio',\n },\n },\n customer_informed_employee_date: {\n description: '',\n format: 'date',\n maxLength: 255,\n title: 'When the employee was told about the termination',\n type: ['string', 'null'],\n 'x-jsf-presentation': {\n inputType: 'date',\n },\n },\n customer_informed_employee_description: {\n description: '',\n maxLength: 1000,\n title: 'How did you share this information?',\n type: ['string', 'null'],\n 'x-jsf-presentation': {\n inputType: 'textarea',\n },\n },\n personal_email: {\n description: '',\n maxLength: 255,\n title: \"Employee's personal email\",\n format: 'email',\n type: 'string',\n 'x-jsf-presentation': {\n inputType: 'email',\n },\n },\n },\n required: [\n 'confidential',\n 'customer_informed_employee',\n 'personal_email',\n ],\n type: 'object',\n 'x-jsf-order': [\n 'is_confidential',\n 'customer_informed_employee',\n 'customer_informed_employee_date',\n 'customer_informed_employee_description',\n 'personal_email',\n ],\n },\n },\n};\n"],"mappings":"AAAO,IAAMA,EAA6B,CACxC,KAAM,CACJ,QAAS,EACT,OAAQ,CACN,qBAAsB,GACtB,MAAO,CACL,CACE,GAAI,CACF,WAAY,CACV,eAAgB,CACd,QAAS,kBACX,CACF,CACF,EACA,KAAM,CACJ,WAAY,CACV,eAAgB,CACd,qBAAsB,CACpB,UAAW,CACT,MACE,6IACF,UAAW,YACX,SAAU,SACZ,CACF,CACF,CACF,CACF,CACF,EACA,CACE,GAAI,CACF,WAAY,CACV,2BAA4B,CAC1B,MAAO,KACT,CACF,EACA,SAAU,CAAC,4BAA4B,CACzC,EACA,KAAM,CACJ,WAAY,CACV,gCAAiC,CAC/B,KAAM,QACR,EACA,uCAAwC,CACtC,KAAM,QACR,CACF,EACA,SAAU,CACR,kCACA,wCACF,CACF,EACA,KAAM,CACJ,WAAY,CACV,gCAAiC,GACjC,uCAAwC,EAC1C,CACF,CACF,CACF,EACA,WAAY,CACV,aAAc,CACZ,YACE,sHACF,MAAO,CACL,CACE,MAAO,MACP,YAAa,GACb,MAAO,KACT,EACA,CACE,MAAO,KACP,YAAa,GACb,MAAO,IACT,CACF,EACA,MAAO,gCACP,KAAM,SACN,qBAAsB,CACpB,UAAW,SACX,UAAW,QACX,UAAW,CACT,MACE,+LACF,UAAW,YACX,SAAU,SACZ,CACF,CACF,EACA,2BAA4B,CAC1B,YAAa,GACb,MAAO,CACL,CACE,MAAO,MACP,YAAa,GACb,MAAO,KACT,EACA,CACE,MAAO,KACP,YAAa,GACb,MAAO,IACT,CACF,EACA,MAAO,qDACP,KAAM,SACN,qBAAsB,CACpB,UAAW,SACX,UAAW,OACb,CACF,EACA,gCAAiC,CAC/B,YAAa,GACb,OAAQ,OACR,UAAW,IACX,MAAO,mDACP,KAAM,CAAC,SAAU,MAAM,EACvB,qBAAsB,CACpB,UAAW,MACb,CACF,EACA,uCAAwC,CACtC,YAAa,GACb,UAAW,IACX,MAAO,sCACP,KAAM,CAAC,SAAU,MAAM,EACvB,qBAAsB,CACpB,UAAW,UACb,CACF,EACA,eAAgB,CACd,YAAa,GACb,UAAW,IACX,MAAO,4BACP,OAAQ,QACR,KAAM,SACN,qBAAsB,CACpB,UAAW,OACb,CACF,CACF,EACA,SAAU,CACR,eACA,6BACA,gBACF,EACA,KAAM,SACN,cAAe,CACb,kBACA,6BACA,kCACA,yCACA,gBACF,CACF,CACF,CACF","names":["employeeComunicationSchema"]}
@@ -0,0 +1,2 @@
1
+ import{a as e}from"./chunk-AYDF3IFZ.js";function s(a){return{mutateAsync:e(n=>new Promise((t,o)=>{a.mutate(n,{onSuccess:e(r=>{r.data?t({data:r.data,error:null}):t({data:null,error:new Error("Something went wrong. Please try again later.")})},"onSuccess"),onError:e(r=>{o({data:null,error:r})},"onError")})}),"mutateAsync")}}e(s,"mutationToPromise");export{s as a};
2
+ //# sourceMappingURL=chunk-JRQSZHUU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/mutations.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { UseMutationResult } from '@tanstack/react-query';\n\ntype MutationData<T> =\n T extends UseMutationResult<infer R, any, any, any> ? R : never;\ntype MutationVariables<T> =\n T extends UseMutationResult<any, any, infer V, any> ? V : never;\ntype MutationError<T> =\n T extends UseMutationResult<any, infer E, any, any> ? E : never;\n\nexport interface SuccessResponse<D> {\n data: D;\n error: null;\n}\n\nexport interface ErrorResponse<E> {\n data: null;\n error: E;\n}\n\ntype PromiseResult<D, E> = SuccessResponse<D> | ErrorResponse<E>;\n\n/**\n * Converts a mutation to a promise-based API. We avoid using the\n * `mutateAsync` method from react-query for 2 reasons:\n * 1. We lose the isPending state of the mutation\n * 2. We want to return the data and error in a consistent way\n * (either data or error is null)\n * @param mutation\n * @returns\n */\nexport function mutationToPromise<\n T extends UseMutationResult<any, any, any, any>,\n>(mutation: T) {\n type Data = MutationData<T>;\n type Variables = MutationVariables<T>;\n type Error = MutationError<T>;\n\n return {\n mutateAsync: (values: Variables): Promise<PromiseResult<Data, Error>> => {\n return new Promise((resolve, reject) => {\n mutation.mutate(values, {\n onSuccess: (response) => {\n if (response.data) {\n resolve({\n data: response.data as Data,\n error: null,\n });\n } else {\n resolve({\n data: null,\n error: new Error(\n 'Something went wrong. Please try again later.',\n ) as unknown as Error,\n });\n }\n },\n onError: (error) => {\n reject({\n data: null,\n error: error as Error,\n });\n },\n });\n });\n },\n };\n}\n"],"mappings":"wCA+BO,SAASA,EAEdC,EAAa,CAKb,MAAO,CACL,YAAaC,EAACC,GACL,IAAI,QAAQ,CAACC,EAASC,IAAW,CACtCJ,EAAS,OAAOE,EAAQ,CACtB,UAAWD,EAACI,GAAa,CACnBA,EAAS,KACXF,EAAQ,CACN,KAAME,EAAS,KACf,MAAO,IACT,CAAC,EAEDF,EAAQ,CACN,KAAM,KACN,MAAO,IAAI,MACT,+CACF,CACF,CAAC,CAEL,EAdW,aAeX,QAASF,EAACK,GAAU,CAClBF,EAAO,CACL,KAAM,KACN,MAAOE,CACT,CAAC,CACH,EALS,UAMX,CAAC,CACH,CAAC,EAzBU,cA2Bf,CACF,CApCgBL,EAAAF,EAAA","names":["mutationToPromise","mutation","__name","values","resolve","reject","response","error"]}
@@ -0,0 +1,2 @@
1
+ import{b as n}from"./chunk-DZYFSFZ7.js";import{b as o}from"./chunk-FI76EKUS.js";import{a as t}from"./chunk-AYDF3IFZ.js";import m from"react";function c({children:r,...i}){let{terminationBag:{back:e}}=n();return m.createElement(o,{...i,onClick:()=>{e()}},r)}t(c,"TerminationBack");export{c as a};
2
+ //# sourceMappingURL=chunk-KPSFJ6BN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/Termination/TerminationBack.tsx"],"sourcesContent":["import { Button } from '@/src/components/ui/button';\nimport React, { ButtonHTMLAttributes, PropsWithChildren } from 'react';\nimport { useTerminationContext } from '@/src/flows/Termination/context';\n\nexport function TerminationBack({\n children,\n ...props\n}: PropsWithChildren<ButtonHTMLAttributes<HTMLButtonElement>>) {\n const {\n terminationBag: { back },\n } = useTerminationContext();\n\n return (\n <Button\n {...props}\n onClick={() => {\n back();\n }}\n >\n {children}\n </Button>\n );\n}\n"],"mappings":"wHACA,OAAOA,MAAwD,QAGxD,SAASC,EAAgB,CAC9B,SAAAC,EACA,GAAGC,CACL,EAA+D,CAC7D,GAAM,CACJ,eAAgB,CAAE,KAAAC,CAAK,CACzB,EAAIC,EAAsB,EAE1B,OACEC,EAAA,cAACC,EAAA,CACE,GAAGJ,EACJ,QAAS,IAAM,CACbC,EAAK,CACP,GAECF,CACH,CAEJ,CAlBgBM,EAAAP,EAAA","names":["React","TerminationBack","children","props","back","useTerminationContext","React","Button","__name"]}
@@ -0,0 +1,2 @@
1
+ import{a as i}from"./chunk-SABMDOWE.js";import{a as f}from"./chunk-KPSFJ6BN.js";import{a as e}from"./chunk-HP7ZP256.js";import{a as n}from"./chunk-CKGTR44U.js";import{a as m}from"./chunk-EQBNHLR4.js";import{a as r}from"./chunk-DZYFSFZ7.js";import{a as t}from"./chunk-AYDF3IFZ.js";import d,{useId as c}from"react";var R=t(({employmentId:p,render:a,options:T})=>{let s=c(),o=i({employmentId:p,options:T});return d.createElement(r.Provider,{value:{formId:s,terminationBag:o}},a({terminationBag:o,components:{Form:e,SubmitButton:n,TimeOff:m,Back:f}}))},"TerminationFlow");export{R as a};
2
+ //# sourceMappingURL=chunk-LNF27NTC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/Termination/TerminationFlow.tsx"],"sourcesContent":["import { TerminationContext } from '@/src/flows/Termination/context';\nimport React, { useId } from 'react';\nimport { useTermination } from '@/src/flows/Termination/hooks';\nimport { JSFModify } from '@/src/flows/CostCalculator/types';\nimport { TerminationForm } from '@/src/flows/Termination/TerminationForm';\nimport { TerminationSubmit } from '@/src/flows/Termination/TerminationSubmit';\nimport { TimeOff } from '@/src/flows/Termination/TimeOff';\nimport { TerminationBack } from '@/src/flows/Termination/TerminationBack';\n\nexport type RenderProps = {\n /**\n * The termination bag returned by the useTermination hook.\n * This bag contains all the methods and properties needed to handle the termination flow.\n * @see {@link useTermination}\n */\n terminationBag: ReturnType<typeof useTermination>;\n /**\n * The components used in the contract amendment flow.\n * This includes the form, submit button, and confirmation form.\n * @see {@link TerminationForm}\n * @see {@link TerminationSubmit}\n * @see {@link TimeOff}\n * @see {@link TerminationBack}\n */\n components: {\n Form: typeof TerminationForm;\n SubmitButton: typeof TerminationSubmit;\n TimeOff: typeof TimeOff;\n Back: typeof TerminationBack;\n };\n};\n\ntype TerminationFlowProps = {\n employmentId: string;\n render: ({ terminationBag, components }: RenderProps) => React.ReactNode;\n options?: {\n jsfModify?: JSFModify;\n };\n};\n\nexport const TerminationFlow = ({\n employmentId,\n render,\n options,\n}: TerminationFlowProps) => {\n const formId = useId();\n const terminationBag = useTermination({ employmentId, options });\n\n return (\n <TerminationContext.Provider\n value={{\n formId: formId,\n terminationBag,\n }}\n >\n {render({\n terminationBag,\n components: {\n Form: TerminationForm,\n SubmitButton: TerminationSubmit,\n TimeOff: TimeOff,\n Back: TerminationBack,\n },\n })}\n </TerminationContext.Provider>\n );\n};\n"],"mappings":"wRACA,OAAOA,GAAS,SAAAC,MAAa,QAuCtB,IAAMC,EAAkBC,EAAA,CAAC,CAC9B,aAAAC,EACA,OAAAC,EACA,QAAAC,CACF,IAA4B,CAC1B,IAAMC,EAASC,EAAM,EACfC,EAAiBC,EAAe,CAAE,aAAAN,EAAc,QAAAE,CAAQ,CAAC,EAE/D,OACEK,EAAA,cAACC,EAAmB,SAAnB,CACC,MAAO,CACL,OAAQL,EACR,eAAAE,CACF,GAECJ,EAAO,CACN,eAAAI,EACA,WAAY,CACV,KAAMI,EACN,aAAcC,EACd,QAASC,EACT,KAAMC,CACR,CACF,CAAC,CACH,CAEJ,EA1B+B","names":["React","useId","TerminationFlow","__name","employmentId","render","options","formId","useId","terminationBag","useTermination","React","TerminationContext","TerminationForm","TerminationSubmit","TimeOff","TerminationBack"]}
@@ -0,0 +1,2 @@
1
+ import{a as s}from"./chunk-SJ56GVNV.js";import{a}from"./chunk-AYDF3IFZ.js";import{Slot as x}from"@radix-ui/react-slot";import*as o from"react";import d from"dompurify";import{Controller as C,FormProvider as g,useFormContext as R,useFormState as b}from"react-hook-form";import*as c from"react";import*as u from"@radix-ui/react-label";function f({className:e,...t}){return c.createElement(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");var M=g,p=o.createContext({}),$=a(({...e})=>o.createElement(p.Provider,{value:{name:e.name}},o.createElement(C,{...e})),"FormField"),l=a(()=>{let e=o.useContext(p),t=o.useContext(F),{getFieldState:r}=R(),n=b({name:e.name}),i=r(e.name,n);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:m}=t;return{id:m,name:e.name,formItemId:`${m}-form-item`,formDescriptionId:`${m}-form-item-description`,formMessageId:`${m}-form-item-message`,...i}},"useFormField"),F=o.createContext({});function _({className:e,...t}){let r=o.useId();return o.createElement(F.Provider,{value:{id:r}},o.createElement("div",{"data-slot":"form-item",...t,className:s("grid gap-2",e)}))}a(_,"FormItem");function H({className:e,...t}){let{error:r,formItemId:n}=l();return o.createElement(f,{"data-slot":"form-label","data-error":!!r,className:s("text-base-color mb-1 data-[error=true]:text-destructive",e),htmlFor:n,...t})}a(H,"FormLabel");var P=o.forwardRef(({...e},t)=>{let{error:r,formItemId:n,formDescriptionId:i,formMessageId:m}=l();return o.createElement(x,{"data-slot":"form-control",ref:t,id:n,"aria-describedby":r?`${i} ${m}`:`${i}`,"aria-invalid":!!r,...e})});P.displayName="FormControl";var I=a(e=>{let t=new Set(e?e.toLowerCase().split(" "):[]);return t.add("noopener"),t.add("noreferrer"),Array.from(t).join(" ")},"appendSecureRelValue");d.isSupported&&d.addHook("afterSanitizeAttributes",e=>{let t=e.getAttribute("target");if(e.tagName==="A"&&(!t||t!=="_self")){e.setAttribute("target","_blank");let r=e.getAttribute("rel");e.setAttribute("rel",I(r))}});function k({className:e,children:t,...r}){let{formDescriptionId:n}=l();return o.createElement("p",{"data-slot":"form-description",id:n,className:s("text-base-color text-xs",e),...typeof t=="string"?{dangerouslySetInnerHTML:{__html:d.sanitize(t,{ADD_ATTR:["target"]})}}:{},...r},typeof t=="function"?t():null)}a(k,"FormDescription");function z({className:e,...t}){let{error:r,formMessageId:n}=l(),i=r?String(r?.message??""):t.children;return i?o.createElement("p",{"data-slot":"form-message",id:n,className:s("text-destructive text-sm",e),...t},i):null}a(z,"FormMessage");export{M as a,$ as b,_ as c,H as d,P as e,k as f,z as g};
2
+ //# sourceMappingURL=chunk-N5AQSLAU.js.map
@@ -0,0 +1 @@
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 return (\n <p\n data-slot=\"form-description\"\n id={formDescriptionId}\n className={cn('text-base-color text-xs', className)}\n {...(typeof children === 'string'\n ? {\n dangerouslySetInnerHTML: {\n __html: DOMPurify.sanitize(children, { ADD_ATTR: ['target'] }),\n },\n }\n : {})} // Only add dangerouslySetInnerHTML when children is a string\n {...props}\n >\n {typeof children === 'function' ? children() : null}\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,kBCVP,UAAYC,MAAW,QACvB,UAAYC,MAAoB,wBAIhC,SAASC,EAAM,CACb,UAAAC,EACA,GAAGC,CACL,EAAqD,CACnD,OACE,gBAAgB,OAAf,CACC,YAAU,QACV,UAAWC,EACT,gJACAF,CACF,EACC,GAAGC,EACN,CAEJ,CAdSE,EAAAJ,EAAA,SDUT,IAAMK,EAAOC,EASPC,EAAyB,gBAC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EAAS,EAAI,IACjD,CAEJ,CA1BShC,EAAA+B,EAAA,mBA4BT,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,EAKH,gBAAC,KACC,YAAU,eACV,GAAIX,EACJ,UAAWR,EAAG,2BAA4BD,CAAS,EAClD,GAAGb,GAEHiC,CACH,EAXO,IAaX,CAlBSlC,EAAAiC,EAAA","names":["Slot","React","DOMPurify","Controller","FormProvider","useFormContext","useFormState","React","LabelPrimitive","Label","className","props","cn","__name","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 +1,2 @@
1
- import{a as x}from"./chunk-UPRUP24B.js";import{a as V}from"./chunk-A4RX3KRZ.js";import{c as j,d as M,f as w,h as B,i as O}from"./chunk-5UXOVZY5.js";import{a as y,d as A}from"./chunk-ANPGCYMT.js";import{d as f}from"./chunk-WRDKLT4N.js";import{a as r}from"./chunk-AYDF3IFZ.js";import{object as se}from"yup";import{createHeadlessForm as k,modify as I}from"@remoteoss/json-schema-form";import{useMutation as K,useQuery as p}from"@tanstack/react-query";import{useState as q}from"react";import{string as L,ValidationError as J}from"yup";var oe=r(({includePremiumBenefits:e})=>{let{client:o}=f();return p({queryKey:["cost-calculator-countries",e],queryFn:r(()=>w({client:o,headers:{Authorization:""},query:{include_premium_benefits:e}}),"queryFn"),select:r(n=>n.data?.data.map(a=>({value:a.region_slug,label:a.name,childRegions:a.child_regions,hasAdditionalFields:a.has_additional_fields,regionSlug:a.region_slug})),"select")})},"useCostCalculatorCountries"),ie=r(()=>{let{client:e}=f();return p({queryKey:["company-currencies"],queryFn:r(()=>O({client:e,headers:{Authorization:""}}),"queryFn"),select:r(o=>o.data?.data?.company_currencies.map(n=>({value:n.slug,label:n.code})),"select")})},"useCompanyCurrencies"),ne=r(()=>{let{client:e}=f();return K({mutationFn:r(o=>j({client:e,headers:{Authorization:""},body:o}),"mutationFn")})},"useCostCalculatorEstimation"),Fe=r(()=>{let{client:e}=f();return K({mutationFn:r(o=>M({client:e,headers:{Authorization:""},body:o}),"mutationFn")})},"useCostCalculatorEstimationPdf"),ae=r((e,{includePremiumBenefits:o,options:n})=>{let{client:a}=f();return p({queryKey:["cost-calculator-region-fields",e,o],queryFn:r(()=>B({client:a,headers:{Authorization:""},path:{slug:e},query:{include_premium_benefits:o}}),"queryFn"),enabled:!!e,select:r(({data:s})=>{let u=s?.data?.schema||{};if(n&&n.jsfModify){let{schema:c}=I(u,n.jsfModify);u=c}return k(u)},"select")})},"useRegionFields"),E={title:"Estimation",includeBenefits:!1,includeCostBreakdowns:!1,includePremiumBenefits:!1},Pe=r(({defaultRegion:e,estimationOptions:o,options:n}={estimationOptions:E})=>{let{schema:a}=I(x.data.schema,n?.jsfModify||{}),s=k(a),[u,c]=q(e),[h,b]=q(),{data:g,isLoading:G}=oe({includePremiumBenefits:o.includePremiumBenefits}),{data:_,isLoading:U}=ie(),$=u||h?.value,{data:S,isLoading:H}=ae($,{includePremiumBenefits:o.includePremiumBenefits,options:n}),F=ne();async function N(i){try{await C.validate(i,{abortEarly:!1})}catch(t){return{data:null,error:t}}return new Promise((t,d)=>{F.mutate(T(i,o),{onSuccess:r(l=>{l.data?t({data:l.data,error:null}):t({data:null,error:new Error("Something went wrong. Please try again later.")})},"onSuccess"),onError:r(l=>{d({data:null,error:l})},"onError")})})}r(N,"onSubmit");function Q(i){let t=g?.find(({value:d})=>d===i);t&&t.childRegions.length===0&&t.hasAdditionalFields?c(t.regionSlug):c(void 0),b(t)}r(Q,"onCountryChange");function D(i){c(i)}r(D,"onRegionChange");let m=s.fields.find(i=>i.name==="region");if(m){let i=h?.childRegions.map(t=>({value:t.slug,label:t.name}))??[];m.options=i,m.isVisible=i.length>0,m.required=i.length>0,m.onChange=D,m.schema=i.length>0?L().transform(t=>typeof t=="string"?t:"").required("Region is required"):L()}if(_){let i=s.fields.find(t=>t.name==="currency");i&&(i.options=_)}if(g){let i=s.fields.find(t=>t.name==="country");i&&(i.options=g,i.onChange=Q)}let W=r(()=>{b(void 0),c(e)},"resetForm"),P=[...s.fields,...S?.fields||[]],C=z(s.fields);async function X(i){let t=null,d=A(i,P,{isPartialValidation:!1});try{await C.validate(d,{abortEarly:!1}),t={formErrors:{},yupError:new J([],i)}}catch(R){let v=V(R);t={formErrors:Object.entries(v).reduce((ee,[te,re])=>({...ee,[te]:re.message}),{}),yupError:R}}let l=S?.handleValidation(d),Y=[...t?.yupError.inner||[],...l?.yupError?.inner||[]],Z={...t?.yupError?.value||{},...l?.yupError?.value||{}};return{formErrors:{...t?.formErrors||{},...l?.formErrors||{}},yupError:new J(Y,Z)}}return r(X,"handleValidation"),{stepState:{current:0,total:1,isLastStep:!0},fields:P,validationSchema:C,handleValidation:X,isSubmitting:F.isPending,isLoading:G&&U&&H,onSubmit:N,resetForm:W}},"useCostCalculator");function z(e){let o=e.reduce((n,a)=>(n[a.name]=a.schema,n),{});return se(o)}r(z,"buildValidationSchema");function le(e){let o="benefit-";return Object.keys(e).reduce((n,a)=>{let u={benefit_group_slug:a.replace(o,""),benefit_tier_slug:e[a]};return[...n,u]},[])}r(le,"formatBenefits");function T(e,o=E){return{employer_currency_slug:e.currency,include_benefits:o.includeBenefits,include_cost_breakdowns:o.includeCostBreakdowns,include_premium_benefits:o.includePremiumBenefits,employments:[{region_slug:e.region||e.country,annual_gross_salary:y(e.salary),annual_gross_salary_in_employer_currency:y(e.salary),employment_term:e.contract_duration_type??"fixed",title:o.title,regional_to_employer_exchange_rate:"1",age:e.age??void 0,...e.benefits&&{benefits:le(e.benefits)}}]}}r(T,"buildPayload");export{z as a,T as b,Fe as c,E as d,Pe as e};
2
- //# sourceMappingURL=chunk-KQCZ2KSO.js.map
1
+ import{a as x}from"./chunk-UPRUP24B.js";import{d as j,e as M,g as w,i as B,k as O}from"./chunk-55VACCVZ.js";import{a as y,c as A}from"./chunk-YBACB5A6.js";import{a as V}from"./chunk-A4RX3KRZ.js";import{d as f}from"./chunk-WRDKLT4N.js";import{a as r}from"./chunk-AYDF3IFZ.js";import{object as se}from"yup";import{createHeadlessForm as k,modify as I}from"@remoteoss/json-schema-form";import{useMutation as K,useQuery as p}from"@tanstack/react-query";import{useState as q}from"react";import{string as L,ValidationError as J}from"yup";var oe=r(({includePremiumBenefits:e})=>{let{client:o}=f();return p({queryKey:["cost-calculator-countries",e],queryFn:r(()=>w({client:o,headers:{Authorization:""},query:{include_premium_benefits:e}}),"queryFn"),select:r(n=>n.data?.data.map(a=>({value:a.region_slug,label:a.name,childRegions:a.child_regions,hasAdditionalFields:a.has_additional_fields,regionSlug:a.region_slug})),"select")})},"useCostCalculatorCountries"),ie=r(()=>{let{client:e}=f();return p({queryKey:["company-currencies"],queryFn:r(()=>O({client:e,headers:{Authorization:""}}),"queryFn"),select:r(o=>o.data?.data?.company_currencies.map(n=>({value:n.slug,label:n.code})),"select")})},"useCompanyCurrencies"),ne=r(()=>{let{client:e}=f();return K({mutationFn:r(o=>j({client:e,headers:{Authorization:""},body:o}),"mutationFn")})},"useCostCalculatorEstimation"),Fe=r(()=>{let{client:e}=f();return K({mutationFn:r(o=>M({client:e,headers:{Authorization:""},body:o}),"mutationFn")})},"useCostCalculatorEstimationPdf"),ae=r((e,{includePremiumBenefits:o,options:n})=>{let{client:a}=f();return p({queryKey:["cost-calculator-region-fields",e,o],queryFn:r(()=>B({client:a,headers:{Authorization:""},path:{slug:e},query:{include_premium_benefits:o}}),"queryFn"),enabled:!!e,select:r(({data:s})=>{let u=s?.data?.schema||{};if(n&&n.jsfModify){let{schema:c}=I(u,n.jsfModify);u=c}return k(u)},"select")})},"useRegionFields"),E={title:"Estimation",includeBenefits:!1,includeCostBreakdowns:!1,includePremiumBenefits:!1},Pe=r(({defaultRegion:e,estimationOptions:o,options:n}={estimationOptions:E})=>{let{schema:a}=I(x.data.schema,n?.jsfModify||{}),s=k(a),[u,c]=q(e),[h,b]=q(),{data:g,isLoading:G}=oe({includePremiumBenefits:o.includePremiumBenefits}),{data:_,isLoading:U}=ie(),$=u||h?.value,{data:S,isLoading:H}=ae($,{includePremiumBenefits:o.includePremiumBenefits,options:n}),F=ne();async function N(i){try{await C.validate(i,{abortEarly:!1})}catch(t){return{data:null,error:t}}return new Promise((t,d)=>{F.mutate(T(i,o),{onSuccess:r(l=>{l.data?t({data:l.data,error:null}):t({data:null,error:new Error("Something went wrong. Please try again later.")})},"onSuccess"),onError:r(l=>{d({data:null,error:l})},"onError")})})}r(N,"onSubmit");function Q(i){let t=g?.find(({value:d})=>d===i);t&&t.childRegions.length===0&&t.hasAdditionalFields?c(t.regionSlug):c(void 0),b(t)}r(Q,"onCountryChange");function D(i){c(i)}r(D,"onRegionChange");let m=s.fields.find(i=>i.name==="region");if(m){let i=h?.childRegions.map(t=>({value:t.slug,label:t.name}))??[];m.options=i,m.isVisible=i.length>0,m.required=i.length>0,m.onChange=D,m.schema=i.length>0?L().transform(t=>typeof t=="string"?t:"").required("Region is required"):L()}if(_){let i=s.fields.find(t=>t.name==="currency");i&&(i.options=_)}if(g){let i=s.fields.find(t=>t.name==="country");i&&(i.options=g,i.onChange=Q)}let W=r(()=>{b(void 0),c(e)},"resetForm"),P=[...s.fields,...S?.fields||[]],C=z(s.fields);async function X(i){let t=null,d=A(i,P);try{await C.validate(d,{abortEarly:!1}),t={formErrors:{},yupError:new J([],i)}}catch(R){let v=V(R);t={formErrors:Object.entries(v).reduce((ee,[te,re])=>({...ee,[te]:re.message}),{}),yupError:R}}let l=S?.handleValidation(d),Y=[...t?.yupError.inner||[],...l?.yupError?.inner||[]],Z={...t?.yupError?.value||{},...l?.yupError?.value||{}};return{formErrors:{...t?.formErrors||{},...l?.formErrors||{}},yupError:new J(Y,Z)}}return r(X,"handleValidation"),{stepState:{current:0,total:1,isLastStep:!0},fields:P,validationSchema:C,handleValidation:X,isSubmitting:F.isPending,isLoading:G&&U&&H,onSubmit:N,resetForm:W}},"useCostCalculator");function z(e){let o=e.reduce((n,a)=>(n[a.name]=a.schema,n),{});return se(o)}r(z,"buildValidationSchema");function le(e){let o="benefit-";return Object.keys(e).reduce((n,a)=>{let u={benefit_group_slug:a.replace(o,""),benefit_tier_slug:e[a]};return[...n,u]},[])}r(le,"formatBenefits");function T(e,o=E){return{employer_currency_slug:e.currency,include_benefits:o.includeBenefits,include_cost_breakdowns:o.includeCostBreakdowns,include_premium_benefits:o.includePremiumBenefits,employments:[{region_slug:e.region||e.country,annual_gross_salary:y(e.salary),annual_gross_salary_in_employer_currency:y(e.salary),employment_term:e.contract_duration_type??"fixed",title:o.title,regional_to_employer_exchange_rate:"1",age:e.age??void 0,...e.benefits&&{benefits:le(e.benefits)}}]}}r(T,"buildPayload");export{z as a,T as b,Fe as c,E as d,Pe as e};
2
+ //# sourceMappingURL=chunk-NBD4VOG3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/flows/CostCalculator/utils.ts","../src/flows/CostCalculator/hooks.ts"],"sourcesContent":["import type { CostCalculatorEstimateParams } from '@/src/client';\n\nimport { convertToCents } from '@/src/components/form/utils';\nimport { $TSFixMe } from '@remoteoss/json-schema-form';\nimport { AnyObjectSchema, object } from 'yup';\nimport { defaultEstimationOptions } from './hooks';\nimport type {\n CostCalculatorEstimationFormValues,\n CostCalculatorEstimationOptions,\n} from './types';\n\n/**\n * Build the validation schema for the form.\n * @returns\n */\nexport function buildValidationSchema(fields: $TSFixMe[]) {\n const fieldsSchema = fields.reduce<Record<string, AnyObjectSchema>>(\n (fieldsSchemaAcc, field) => {\n fieldsSchemaAcc[field.name] = field.schema as AnyObjectSchema;\n return fieldsSchemaAcc;\n },\n {},\n );\n return object(fieldsSchema) as AnyObjectSchema;\n}\n\n/**\n * Format the benefits to the expected format by the API.\n * @param benefits\n * @returns\n */\nfunction formatBenefits(benefits: Record<string, string>) {\n const needle = 'benefit-';\n return Object.keys(benefits).reduce<\n Array<{ benefit_group_slug: string; benefit_tier_slug: string }>\n >((acc, key) => {\n const benefitGroupSlug = key.replace(needle, '');\n const benefitEntry = {\n benefit_group_slug: benefitGroupSlug,\n benefit_tier_slug: benefits[key],\n };\n return [...acc, benefitEntry];\n }, []);\n}\n\n/**\n * Build the payload for the cost calculator estimation.\n * @param values\n * @param estimationOptions\n * @returns\n */\nexport function buildPayload(\n values: CostCalculatorEstimationFormValues,\n estimationOptions: CostCalculatorEstimationOptions = defaultEstimationOptions,\n): CostCalculatorEstimateParams {\n return {\n employer_currency_slug: values.currency,\n include_benefits: estimationOptions.includeBenefits,\n include_cost_breakdowns: estimationOptions.includeCostBreakdowns,\n include_premium_benefits: estimationOptions.includePremiumBenefits,\n employments: [\n {\n region_slug: values.region || values.country,\n annual_gross_salary: convertToCents(values.salary) as number,\n annual_gross_salary_in_employer_currency: convertToCents(\n values.salary,\n ) as number,\n employment_term: values.contract_duration_type ?? 'fixed',\n title: estimationOptions.title,\n regional_to_employer_exchange_rate: '1',\n age: values.age ?? undefined,\n ...(values.benefits && { benefits: formatBenefits(values.benefits) }),\n },\n ],\n };\n}\n","import {\n CostCalculatorEstimateParams,\n CostCalculatorEstimateResponse,\n getIndexCompanyCurrency,\n getIndexCountry,\n getShowRegionField,\n MinimalRegion,\n postCreateEstimation,\n PostCreateEstimationError,\n postCreateEstimationPdf,\n} from '@/src/client';\nimport { jsonSchema } from '@/src/flows/CostCalculator/jsonSchema';\nimport type {\n CostCalculatorEstimationFormValues,\n CostCalculatorEstimationOptions,\n JSFModify,\n} from '@/src/flows/CostCalculator/types';\nimport type { Result } from '@/src/flows/types';\n\nimport { parseJSFToValidate } from '@/src/components/form/utils';\nimport { iterateErrors } from '@/src/components/form/yupValidationResolver';\nimport { useClient } from '@/src/context';\nimport { Client } from '@hey-api/client-fetch';\nimport { createHeadlessForm, modify } from '@remoteoss/json-schema-form';\nimport { useMutation, useQuery } from '@tanstack/react-query';\nimport { useState } from 'react';\nimport { string, ValidationError } from 'yup';\nimport { buildPayload, buildValidationSchema } from './utils';\n\ntype CostCalculatorCountry = {\n value: string;\n label: string;\n childRegions: MinimalRegion[];\n hasAdditionalFields: boolean | undefined;\n regionSlug: string;\n};\n\ntype JSFValidationError = {\n formErrors: Record<\n string,\n {\n type: string;\n message: string;\n }\n >;\n yupError: ValidationError;\n};\n\n/**\n * Hook to fetch the countries for the cost calculator.\n * @returns\n */\nconst useCostCalculatorCountries = ({\n includePremiumBenefits,\n}: {\n includePremiumBenefits: CostCalculatorEstimationOptions['includePremiumBenefits'];\n}) => {\n const { client } = useClient();\n return useQuery({\n queryKey: ['cost-calculator-countries', includePremiumBenefits],\n queryFn: () => {\n return getIndexCountry({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n query: {\n include_premium_benefits: includePremiumBenefits,\n },\n });\n },\n select: (data) =>\n data.data?.data.map((country) => ({\n value: country.region_slug,\n label: country.name,\n childRegions: country.child_regions,\n hasAdditionalFields: country.has_additional_fields,\n regionSlug: country.region_slug,\n })),\n });\n};\n\n/**\n * Hook to fetch the company currencies.\n * @returns\n */\nconst useCompanyCurrencies = () => {\n const { client } = useClient();\n\n return useQuery({\n queryKey: ['company-currencies'],\n queryFn: () => {\n return getIndexCompanyCurrency({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n });\n },\n select: (data) =>\n data.data?.data?.company_currencies.map((currency) => ({\n value: currency.slug,\n label: currency.code,\n })),\n });\n};\n\n/**\n * Hook to create an estimation.\n * @returns\n */\nconst useCostCalculatorEstimation = () => {\n const { client } = useClient();\n\n return useMutation({\n mutationFn: (payload: CostCalculatorEstimateParams) => {\n return postCreateEstimation({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n body: payload,\n });\n },\n });\n};\n\n/**\n * Custom hook to create a PDF estimation.\n *\n * @returns\n */\nexport const useCostCalculatorEstimationPdf = () => {\n const { client } = useClient();\n\n return useMutation({\n mutationFn: (payload: CostCalculatorEstimateParams) => {\n return postCreateEstimationPdf({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n body: payload,\n });\n },\n });\n};\n\n/**\n * Hook to fetch the region fields.\n * @param region\n * @returns\n */\nconst useRegionFields = (\n region: string | undefined,\n {\n includePremiumBenefits,\n options,\n }: {\n includePremiumBenefits: CostCalculatorEstimationOptions['includePremiumBenefits'];\n options?: {\n jsfModify?: JSFModify;\n };\n },\n) => {\n const { client } = useClient();\n\n return useQuery({\n queryKey: ['cost-calculator-region-fields', region, includePremiumBenefits],\n queryFn: () => {\n return getShowRegionField({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n path: { slug: region as string },\n query: {\n include_premium_benefits: includePremiumBenefits,\n },\n });\n },\n enabled: !!region,\n select: ({ data }) => {\n let jsfSchema = data?.data?.schema || {};\n if (options && options.jsfModify) {\n const { schema } = modify(jsfSchema, options.jsfModify);\n jsfSchema = schema;\n }\n return createHeadlessForm(jsfSchema);\n },\n });\n};\n\nexport const defaultEstimationOptions: CostCalculatorEstimationOptions = {\n title: 'Estimation',\n includeBenefits: false,\n includeCostBreakdowns: false,\n includePremiumBenefits: false,\n};\n\ntype UseCostCalculatorParams = {\n /**\n * The default region slug to preselect a country and a region.\n */\n defaultRegion?: string;\n /**\n * The estimation options.\n */\n estimationOptions: CostCalculatorEstimationOptions;\n options?: {\n jsfModify?: JSFModify;\n };\n};\n\nexport type EstimationError = PostCreateEstimationError | ValidationError;\n\n/**\n * Hook to use the cost calculator.\n */\nexport const useCostCalculator = (\n { defaultRegion, estimationOptions, options }: UseCostCalculatorParams = {\n estimationOptions: defaultEstimationOptions,\n },\n) => {\n const { schema: jsonSchemaModified } = modify(\n jsonSchema.data.schema,\n options?.jsfModify || {},\n );\n\n const fieldsJSONSchema = createHeadlessForm(jsonSchemaModified);\n\n const [selectedRegion, setSelectedRegion] = useState<string | undefined>(\n defaultRegion,\n );\n const [selectedCountry, setSelectedCountry] =\n useState<CostCalculatorCountry>();\n const { data: countries, isLoading: isLoadingCountries } =\n useCostCalculatorCountries({\n includePremiumBenefits: estimationOptions.includePremiumBenefits,\n });\n const { data: currencies, isLoading: isLoadingCurrencies } =\n useCompanyCurrencies();\n\n const jsonSchemaRegionSlug = selectedRegion || selectedCountry?.value;\n\n const { data: jsonSchemaRegionFields, isLoading: isLoadingRegionFields } =\n useRegionFields(jsonSchemaRegionSlug, {\n includePremiumBenefits: estimationOptions.includePremiumBenefits,\n options,\n });\n const costCalculatorEstimationMutation = useCostCalculatorEstimation();\n\n /**\n * Submit the estimation form with the given values.\n * @param values\n */\n async function onSubmit(\n values: CostCalculatorEstimationFormValues,\n ): Promise<Result<CostCalculatorEstimateResponse, EstimationError>> {\n try {\n await validationSchema.validate(values, { abortEarly: false });\n } catch (err) {\n return {\n data: null,\n error: err as ValidationError,\n };\n }\n\n return new Promise((resolve, reject) => {\n costCalculatorEstimationMutation.mutate(\n buildPayload(values, estimationOptions),\n {\n onSuccess: (response) => {\n if (response.data) {\n resolve({\n data: response.data,\n error: null,\n });\n } else {\n resolve({\n data: null,\n error: new Error(\n 'Something went wrong. Please try again later.',\n ),\n });\n }\n },\n onError: (error) => {\n reject({\n data: null,\n error: error as PostCreateEstimationError,\n });\n },\n },\n );\n });\n }\n\n /**\n * If the selected country has no child regions and has additional fields,\n * set the current region to the country's region slug and fetch the region fields.\n * @param country\n */\n function onCountryChange(country: string) {\n const currentCountry = countries?.find(({ value }) => value === country);\n\n if (\n currentCountry &&\n currentCountry.childRegions.length === 0 &&\n currentCountry.hasAdditionalFields\n ) {\n setSelectedRegion(currentCountry.regionSlug);\n } else {\n setSelectedRegion(undefined);\n }\n setSelectedCountry(currentCountry);\n }\n\n /**\n * Update the selected region and fetch the region fields.\n * @param region\n */\n function onRegionChange(region: string) {\n setSelectedRegion(region);\n }\n\n const regionField = fieldsJSONSchema.fields.find(\n (field) => field.name === 'region',\n );\n\n if (regionField) {\n const regions =\n selectedCountry?.childRegions.map((region) => ({\n value: region.slug,\n label: region.name,\n })) ?? [];\n regionField.options = regions;\n regionField.isVisible = regions.length > 0;\n regionField.required = regions.length > 0;\n regionField.onChange = onRegionChange;\n regionField.schema =\n regions.length > 0\n ? string()\n .transform((value) => (typeof value === 'string' ? value : ''))\n .required('Region is required')\n : string();\n }\n\n if (currencies) {\n const currencyField = fieldsJSONSchema.fields.find(\n (field) => field.name === 'currency',\n );\n if (currencyField) {\n currencyField.options = currencies;\n }\n }\n\n if (countries) {\n const countryField = fieldsJSONSchema.fields.find(\n (field) => field.name === 'country',\n );\n if (countryField) {\n countryField.options = countries;\n countryField.onChange = onCountryChange;\n }\n }\n\n const resetForm = () => {\n setSelectedCountry(undefined);\n setSelectedRegion(defaultRegion);\n };\n\n const allFields = [\n ...fieldsJSONSchema.fields,\n ...(jsonSchemaRegionFields?.fields || []),\n ];\n\n const validationSchema = buildValidationSchema(fieldsJSONSchema.fields);\n\n async function handleValidation(values: CostCalculatorEstimationFormValues) {\n let errors: JSFValidationError | null = null;\n\n const parsedValues = parseJSFToValidate(values, allFields, {\n isPartialValidation: false,\n });\n\n // 1. validate static fields first using Yup validate function\n try {\n await validationSchema.validate(parsedValues, {\n abortEarly: false,\n });\n errors = {\n formErrors: {},\n yupError: new ValidationError([], values),\n };\n } catch (error) {\n const iterateResult = iterateErrors(error as ValidationError);\n\n errors = {\n // convert the errors to a format that can be used in the form\n formErrors: Object.entries(iterateResult).reduce(\n (acc, [key, value]) => ({ ...acc, [key]: value.message }),\n {},\n ),\n yupError: error as ValidationError,\n };\n }\n\n // 2. validate json schema fields using the handleValidation (from json-schema-form)\n const handleValidationResult =\n jsonSchemaRegionFields?.handleValidation(parsedValues);\n\n // 3. combine the errors from both validations\n const combinedInnerErrors = [\n ...(errors?.yupError.inner || []),\n ...(handleValidationResult?.yupError?.inner || []),\n ];\n const combinedValues = {\n ...(errors?.yupError?.value || {}),\n ...(handleValidationResult?.yupError?.value || {}),\n };\n\n return {\n formErrors: {\n ...(errors?.formErrors || {}),\n ...(handleValidationResult?.formErrors || {}),\n },\n yupError: new ValidationError(combinedInnerErrors, combinedValues),\n };\n }\n\n return {\n stepState: {\n current: 0,\n total: 1,\n isLastStep: true,\n },\n fields: allFields,\n validationSchema,\n handleValidation,\n isSubmitting: costCalculatorEstimationMutation.isPending,\n isLoading:\n isLoadingCountries && isLoadingCurrencies && isLoadingRegionFields,\n onSubmit,\n resetForm,\n };\n};\n"],"mappings":"mRAIA,OAA0B,UAAAA,OAAc,MCmBxC,OAAS,sBAAAC,EAAoB,UAAAC,MAAc,8BAC3C,OAAS,eAAAC,EAAa,YAAAC,MAAgB,wBACtC,OAAS,YAAAC,MAAgB,QACzB,OAAS,UAAAC,EAAQ,mBAAAC,MAAuB,MA0BxC,IAAMC,GAA6BC,EAAA,CAAC,CAClC,uBAAAC,CACF,IAEM,CACJ,GAAM,CAAE,OAAAC,CAAO,EAAIC,EAAU,EAC7B,OAAOC,EAAS,CACd,SAAU,CAAC,4BAA6BH,CAAsB,EAC9D,QAASD,EAAA,IACAK,EAAgB,CACrB,OAAQH,EACR,QAAS,CACP,cAAe,EACjB,EACA,MAAO,CACL,yBAA0BD,CAC5B,CACF,CAAC,EATM,WAWT,OAAQD,EAACM,GACPA,EAAK,MAAM,KAAK,IAAKC,IAAa,CAChC,MAAOA,EAAQ,YACf,MAAOA,EAAQ,KACf,aAAcA,EAAQ,cACtB,oBAAqBA,EAAQ,sBAC7B,WAAYA,EAAQ,WACtB,EAAE,EAPI,SAQV,CAAC,CACH,EA5BmC,8BAkC7BC,GAAuBR,EAAA,IAAM,CACjC,GAAM,CAAE,OAAAE,CAAO,EAAIC,EAAU,EAE7B,OAAOC,EAAS,CACd,SAAU,CAAC,oBAAoB,EAC/B,QAASJ,EAAA,IACAS,EAAwB,CAC7B,OAAQP,EACR,QAAS,CACP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,UAAAmB,CACF,CACF,EAnOiC,qBD5M1B,SAASe,EAAsBC,EAAoB,CACxD,IAAMC,EAAeD,EAAO,OAC1B,CAACE,EAAiBC,KAChBD,EAAgBC,EAAM,IAAI,EAAIA,EAAM,OAC7BD,GAET,CAAC,CACH,EACA,OAAOE,GAAOH,CAAY,CAC5B,CATgBI,EAAAN,EAAA,yBAgBhB,SAASO,GAAeC,EAAkC,CACxD,IAAMC,EAAS,WACf,OAAO,OAAO,KAAKD,CAAQ,EAAE,OAE3B,CAACE,EAAKC,IAAQ,CAEd,IAAMC,EAAe,CACnB,mBAFuBD,EAAI,QAAQF,EAAQ,EAAE,EAG7C,kBAAmBD,EAASG,CAAG,CACjC,EACA,MAAO,CAAC,GAAGD,EAAKE,CAAY,CAC9B,EAAG,CAAC,CAAC,CACP,CAZSN,EAAAC,GAAA,kBAoBF,SAASM,EACdC,EACAC,EAAqDC,EACvB,CAC9B,MAAO,CACL,uBAAwBF,EAAO,SAC/B,iBAAkBC,EAAkB,gBACpC,wBAAyBA,EAAkB,sBAC3C,yBAA0BA,EAAkB,uBAC5C,YAAa,CACX,CACE,YAAaD,EAAO,QAAUA,EAAO,QACrC,oBAAqBG,EAAeH,EAAO,MAAM,EACjD,yCAA0CG,EACxCH,EAAO,MACT,EACA,gBAAiBA,EAAO,wBAA0B,QAClD,MAAOC,EAAkB,MACzB,mCAAoC,IACpC,IAAKD,EAAO,KAAO,OACnB,GAAIA,EAAO,UAAY,CAAE,SAAUP,GAAeO,EAAO,QAAQ,CAAE,CACrE,CACF,CACF,CACF,CAxBgBR,EAAAO,EAAA","names":["object","createHeadlessForm","modify","useMutation","useQuery","useState","string","ValidationError","useCostCalculatorCountries","__name","includePremiumBenefits","client","useClient","useQuery","getIndexCountry","data","country","useCompanyCurrencies","getIndexCompanyCurrency","currency","useCostCalculatorEstimation","useMutation","payload","postCreateEstimation","useCostCalculatorEstimationPdf","postCreateEstimationPdf","useRegionFields","region","options","getShowRegionField","jsfSchema","schema","modify","createHeadlessForm","defaultEstimationOptions","useCostCalculator","defaultRegion","estimationOptions","jsonSchemaModified","jsonSchema","fieldsJSONSchema","selectedRegion","setSelectedRegion","useState","selectedCountry","setSelectedCountry","countries","isLoadingCountries","currencies","isLoadingCurrencies","jsonSchemaRegionSlug","jsonSchemaRegionFields","isLoadingRegionFields","costCalculatorEstimationMutation","onSubmit","values","validationSchema","err","resolve","reject","buildPayload","response","error","onCountryChange","currentCountry","value","onRegionChange","regionField","field","regions","string","currencyField","countryField","resetForm","allFields","buildValidationSchema","handleValidation","errors","parsedValues","parseJSFToValidate","ValidationError","iterateResult","iterateErrors","acc","key","handleValidationResult","combinedInnerErrors","combinedValues","buildValidationSchema","fields","fieldsSchema","fieldsSchemaAcc","field","object","__name","formatBenefits","benefits","needle","acc","key","benefitEntry","buildPayload","values","estimationOptions","defaultEstimationOptions","convertToCents"]}
1
+ {"version":3,"sources":["../src/flows/CostCalculator/utils.ts","../src/flows/CostCalculator/hooks.ts"],"sourcesContent":["import type { CostCalculatorEstimateParams } from '@/src/client';\n\nimport { convertToCents } from '@/src/components/form/utils';\nimport { $TSFixMe } from '@remoteoss/json-schema-form';\nimport { AnyObjectSchema, object } from 'yup';\nimport { defaultEstimationOptions } from './hooks';\nimport type {\n CostCalculatorEstimationFormValues,\n CostCalculatorEstimationOptions,\n} from './types';\n\n/**\n * Build the validation schema for the form.\n * @returns\n */\nexport function buildValidationSchema(fields: $TSFixMe[]) {\n const fieldsSchema = fields.reduce<Record<string, AnyObjectSchema>>(\n (fieldsSchemaAcc, field) => {\n fieldsSchemaAcc[field.name] = field.schema as AnyObjectSchema;\n return fieldsSchemaAcc;\n },\n {},\n );\n return object(fieldsSchema) as AnyObjectSchema;\n}\n\n/**\n * Format the benefits to the expected format by the API.\n * @param benefits\n * @returns\n */\nfunction formatBenefits(benefits: Record<string, string>) {\n const needle = 'benefit-';\n return Object.keys(benefits).reduce<\n Array<{ benefit_group_slug: string; benefit_tier_slug: string }>\n >((acc, key) => {\n const benefitGroupSlug = key.replace(needle, '');\n const benefitEntry = {\n benefit_group_slug: benefitGroupSlug,\n benefit_tier_slug: benefits[key],\n };\n return [...acc, benefitEntry];\n }, []);\n}\n\n/**\n * Build the payload for the cost calculator estimation.\n * @param values\n * @param estimationOptions\n * @returns\n */\nexport function buildPayload(\n values: CostCalculatorEstimationFormValues,\n estimationOptions: CostCalculatorEstimationOptions = defaultEstimationOptions,\n): CostCalculatorEstimateParams {\n return {\n employer_currency_slug: values.currency,\n include_benefits: estimationOptions.includeBenefits,\n include_cost_breakdowns: estimationOptions.includeCostBreakdowns,\n include_premium_benefits: estimationOptions.includePremiumBenefits,\n employments: [\n {\n region_slug: values.region || values.country,\n annual_gross_salary: convertToCents(values.salary) as number,\n annual_gross_salary_in_employer_currency: convertToCents(\n values.salary,\n ) as number,\n employment_term: values.contract_duration_type ?? 'fixed',\n title: estimationOptions.title,\n regional_to_employer_exchange_rate: '1',\n age: values.age ?? undefined,\n ...(values.benefits && { benefits: formatBenefits(values.benefits) }),\n },\n ],\n };\n}\n","import {\n CostCalculatorEstimateParams,\n CostCalculatorEstimateResponse,\n getIndexCompanyCurrency,\n getIndexCountry,\n getShowRegionField,\n MinimalRegion,\n postCreateEstimation,\n PostCreateEstimationError,\n postCreateEstimationPdf,\n} from '@/src/client';\nimport { jsonSchema } from '@/src/flows/CostCalculator/jsonSchema';\nimport type {\n CostCalculatorEstimationFormValues,\n CostCalculatorEstimationOptions,\n JSFModify,\n} from '@/src/flows/CostCalculator/types';\nimport type { Result } from '@/src/flows/types';\n\nimport { parseJSFToValidate } from '@/src/components/form/utils';\nimport { iterateErrors } from '@/src/components/form/yupValidationResolver';\nimport { useClient } from '@/src/context';\nimport { Client } from '@hey-api/client-fetch';\nimport { createHeadlessForm, modify } from '@remoteoss/json-schema-form';\nimport { useMutation, useQuery } from '@tanstack/react-query';\nimport { useState } from 'react';\nimport { string, ValidationError } from 'yup';\nimport { buildPayload, buildValidationSchema } from './utils';\n\ntype CostCalculatorCountry = {\n value: string;\n label: string;\n childRegions: MinimalRegion[];\n hasAdditionalFields: boolean | undefined;\n regionSlug: string;\n};\n\ntype JSFValidationError = {\n formErrors: Record<\n string,\n {\n type: string;\n message: string;\n }\n >;\n yupError: ValidationError;\n};\n\n/**\n * Hook to fetch the countries for the cost calculator.\n * @returns\n */\nconst useCostCalculatorCountries = ({\n includePremiumBenefits,\n}: {\n includePremiumBenefits: CostCalculatorEstimationOptions['includePremiumBenefits'];\n}) => {\n const { client } = useClient();\n return useQuery({\n queryKey: ['cost-calculator-countries', includePremiumBenefits],\n queryFn: () => {\n return getIndexCountry({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n query: {\n include_premium_benefits: includePremiumBenefits,\n },\n });\n },\n select: (data) =>\n data.data?.data.map((country) => ({\n value: country.region_slug,\n label: country.name,\n childRegions: country.child_regions,\n hasAdditionalFields: country.has_additional_fields,\n regionSlug: country.region_slug,\n })),\n });\n};\n\n/**\n * Hook to fetch the company currencies.\n * @returns\n */\nconst useCompanyCurrencies = () => {\n const { client } = useClient();\n\n return useQuery({\n queryKey: ['company-currencies'],\n queryFn: () => {\n return getIndexCompanyCurrency({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n });\n },\n select: (data) =>\n data.data?.data?.company_currencies.map((currency) => ({\n value: currency.slug,\n label: currency.code,\n })),\n });\n};\n\n/**\n * Hook to create an estimation.\n * @returns\n */\nconst useCostCalculatorEstimation = () => {\n const { client } = useClient();\n\n return useMutation({\n mutationFn: (payload: CostCalculatorEstimateParams) => {\n return postCreateEstimation({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n body: payload,\n });\n },\n });\n};\n\n/**\n * Custom hook to create a PDF estimation.\n *\n * @returns\n */\nexport const useCostCalculatorEstimationPdf = () => {\n const { client } = useClient();\n\n return useMutation({\n mutationFn: (payload: CostCalculatorEstimateParams) => {\n return postCreateEstimationPdf({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n body: payload,\n });\n },\n });\n};\n\n/**\n * Hook to fetch the region fields.\n * @param region\n * @returns\n */\nconst useRegionFields = (\n region: string | undefined,\n {\n includePremiumBenefits,\n options,\n }: {\n includePremiumBenefits: CostCalculatorEstimationOptions['includePremiumBenefits'];\n options?: {\n jsfModify?: JSFModify;\n };\n },\n) => {\n const { client } = useClient();\n\n return useQuery({\n queryKey: ['cost-calculator-region-fields', region, includePremiumBenefits],\n queryFn: () => {\n return getShowRegionField({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n path: { slug: region as string },\n query: {\n include_premium_benefits: includePremiumBenefits,\n },\n });\n },\n enabled: !!region,\n select: ({ data }) => {\n let jsfSchema = data?.data?.schema || {};\n if (options && options.jsfModify) {\n const { schema } = modify(jsfSchema, options.jsfModify);\n jsfSchema = schema;\n }\n return createHeadlessForm(jsfSchema);\n },\n });\n};\n\nexport const defaultEstimationOptions: CostCalculatorEstimationOptions = {\n title: 'Estimation',\n includeBenefits: false,\n includeCostBreakdowns: false,\n includePremiumBenefits: false,\n};\n\ntype UseCostCalculatorParams = {\n /**\n * The default region slug to preselect a country and a region.\n */\n defaultRegion?: string;\n /**\n * The estimation options.\n */\n estimationOptions: CostCalculatorEstimationOptions;\n options?: {\n jsfModify?: JSFModify;\n };\n};\n\nexport type EstimationError = PostCreateEstimationError | ValidationError;\n\n/**\n * Hook to use the cost calculator.\n */\nexport const useCostCalculator = (\n { defaultRegion, estimationOptions, options }: UseCostCalculatorParams = {\n estimationOptions: defaultEstimationOptions,\n },\n) => {\n const { schema: jsonSchemaModified } = modify(\n jsonSchema.data.schema,\n options?.jsfModify || {},\n );\n\n const fieldsJSONSchema = createHeadlessForm(jsonSchemaModified);\n\n const [selectedRegion, setSelectedRegion] = useState<string | undefined>(\n defaultRegion,\n );\n const [selectedCountry, setSelectedCountry] =\n useState<CostCalculatorCountry>();\n const { data: countries, isLoading: isLoadingCountries } =\n useCostCalculatorCountries({\n includePremiumBenefits: estimationOptions.includePremiumBenefits,\n });\n const { data: currencies, isLoading: isLoadingCurrencies } =\n useCompanyCurrencies();\n\n const jsonSchemaRegionSlug = selectedRegion || selectedCountry?.value;\n\n const { data: jsonSchemaRegionFields, isLoading: isLoadingRegionFields } =\n useRegionFields(jsonSchemaRegionSlug, {\n includePremiumBenefits: estimationOptions.includePremiumBenefits,\n options,\n });\n const costCalculatorEstimationMutation = useCostCalculatorEstimation();\n\n /**\n * Submit the estimation form with the given values.\n * @param values\n */\n async function onSubmit(\n values: CostCalculatorEstimationFormValues,\n ): Promise<Result<CostCalculatorEstimateResponse, EstimationError>> {\n try {\n await validationSchema.validate(values, { abortEarly: false });\n } catch (err) {\n return {\n data: null,\n error: err as ValidationError,\n };\n }\n\n return new Promise((resolve, reject) => {\n costCalculatorEstimationMutation.mutate(\n buildPayload(values, estimationOptions),\n {\n onSuccess: (response) => {\n if (response.data) {\n resolve({\n data: response.data,\n error: null,\n });\n } else {\n resolve({\n data: null,\n error: new Error(\n 'Something went wrong. Please try again later.',\n ),\n });\n }\n },\n onError: (error) => {\n reject({\n data: null,\n error: error as PostCreateEstimationError,\n });\n },\n },\n );\n });\n }\n\n /**\n * If the selected country has no child regions and has additional fields,\n * set the current region to the country's region slug and fetch the region fields.\n * @param country\n */\n function onCountryChange(country: string) {\n const currentCountry = countries?.find(({ value }) => value === country);\n\n if (\n currentCountry &&\n currentCountry.childRegions.length === 0 &&\n currentCountry.hasAdditionalFields\n ) {\n setSelectedRegion(currentCountry.regionSlug);\n } else {\n setSelectedRegion(undefined);\n }\n setSelectedCountry(currentCountry);\n }\n\n /**\n * Update the selected region and fetch the region fields.\n * @param region\n */\n function onRegionChange(region: string) {\n setSelectedRegion(region);\n }\n\n const regionField = fieldsJSONSchema.fields.find(\n (field) => field.name === 'region',\n );\n\n if (regionField) {\n const regions =\n selectedCountry?.childRegions.map((region) => ({\n value: region.slug,\n label: region.name,\n })) ?? [];\n regionField.options = regions;\n regionField.isVisible = regions.length > 0;\n regionField.required = regions.length > 0;\n regionField.onChange = onRegionChange;\n regionField.schema =\n regions.length > 0\n ? string()\n .transform((value) => (typeof value === 'string' ? value : ''))\n .required('Region is required')\n : string();\n }\n\n if (currencies) {\n const currencyField = fieldsJSONSchema.fields.find(\n (field) => field.name === 'currency',\n );\n if (currencyField) {\n currencyField.options = currencies;\n }\n }\n\n if (countries) {\n const countryField = fieldsJSONSchema.fields.find(\n (field) => field.name === 'country',\n );\n if (countryField) {\n countryField.options = countries;\n countryField.onChange = onCountryChange;\n }\n }\n\n const resetForm = () => {\n setSelectedCountry(undefined);\n setSelectedRegion(defaultRegion);\n };\n\n const allFields = [\n ...fieldsJSONSchema.fields,\n ...(jsonSchemaRegionFields?.fields || []),\n ];\n\n const validationSchema = buildValidationSchema(fieldsJSONSchema.fields);\n\n async function handleValidation(values: CostCalculatorEstimationFormValues) {\n let errors: JSFValidationError | null = null;\n\n const parsedValues = parseJSFToValidate(values, allFields);\n\n // 1. validate static fields first using Yup validate function\n try {\n await validationSchema.validate(parsedValues, {\n abortEarly: false,\n });\n errors = {\n formErrors: {},\n yupError: new ValidationError([], values),\n };\n } catch (error) {\n const iterateResult = iterateErrors(error as ValidationError);\n\n errors = {\n // convert the errors to a format that can be used in the form\n formErrors: Object.entries(iterateResult).reduce(\n (acc, [key, value]) => ({ ...acc, [key]: value.message }),\n {},\n ),\n yupError: error as ValidationError,\n };\n }\n\n // 2. validate json schema fields using the handleValidation (from json-schema-form)\n const handleValidationResult =\n jsonSchemaRegionFields?.handleValidation(parsedValues);\n\n // 3. combine the errors from both validations\n const combinedInnerErrors = [\n ...(errors?.yupError.inner || []),\n ...(handleValidationResult?.yupError?.inner || []),\n ];\n const combinedValues = {\n ...(errors?.yupError?.value || {}),\n ...(handleValidationResult?.yupError?.value || {}),\n };\n\n return {\n formErrors: {\n ...(errors?.formErrors || {}),\n ...(handleValidationResult?.formErrors || {}),\n },\n yupError: new ValidationError(combinedInnerErrors, combinedValues),\n };\n }\n\n return {\n stepState: {\n current: 0,\n total: 1,\n isLastStep: true,\n },\n fields: allFields,\n validationSchema,\n handleValidation,\n isSubmitting: costCalculatorEstimationMutation.isPending,\n isLoading:\n isLoadingCountries && isLoadingCurrencies && isLoadingRegionFields,\n onSubmit,\n resetForm,\n };\n};\n"],"mappings":"mRAIA,OAA0B,UAAAA,OAAc,MCmBxC,OAAS,sBAAAC,EAAoB,UAAAC,MAAc,8BAC3C,OAAS,eAAAC,EAAa,YAAAC,MAAgB,wBACtC,OAAS,YAAAC,MAAgB,QACzB,OAAS,UAAAC,EAAQ,mBAAAC,MAAuB,MA0BxC,IAAMC,GAA6BC,EAAA,CAAC,CAClC,uBAAAC,CACF,IAEM,CACJ,GAAM,CAAE,OAAAC,CAAO,EAAIC,EAAU,EAC7B,OAAOC,EAAS,CACd,SAAU,CAAC,4BAA6BH,CAAsB,EAC9D,QAASD,EAAA,IACAK,EAAgB,CACrB,OAAQH,EACR,QAAS,CACP,cAAe,EACjB,EACA,MAAO,CACL,yBAA0BD,CAC5B,CACF,CAAC,EATM,WAWT,OAAQD,EAACM,GACPA,EAAK,MAAM,KAAK,IAAKC,IAAa,CAChC,MAAOA,EAAQ,YACf,MAAOA,EAAQ,KACf,aAAcA,EAAQ,cACtB,oBAAqBA,EAAQ,sBAC7B,WAAYA,EAAQ,WACtB,EAAE,EAPI,SAQV,CAAC,CACH,EA5BmC,8BAkC7BC,GAAuBR,EAAA,IAAM,CACjC,GAAM,CAAE,OAAAE,CAAO,EAAIC,EAAU,EAE7B,OAAOC,EAAS,CACd,SAAU,CAAC,oBAAoB,EAC/B,QAASJ,EAAA,IACAS,EAAwB,CAC7B,OAAQP,EACR,QAAS,CACP,cAAe,EACjB,CACF,CAAC,EANM,WAQT,OAAQF,EAACM,GACPA,EAAK,MAAM,MAAM,mBAAmB,IAAKI,IAAc,CACrD,MAAOA,EAAS,KAChB,MAAOA,EAAS,IAClB,EAAE,EAJI,SAKV,CAAC,CACH,EAnB6B,wBAyBvBC,GAA8BX,EAAA,IAAM,CACxC,GAAM,CAAE,OAAAE,CAAO,EAAIC,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AS,WACf,OAAO,OAAO,KAAKD,CAAQ,EAAE,OAE3B,CAACE,EAAKC,IAAQ,CAEd,IAAMC,EAAe,CACnB,mBAFuBD,EAAI,QAAQF,EAAQ,EAAE,EAG7C,kBAAmBD,EAASG,CAAG,CACjC,EACA,MAAO,CAAC,GAAGD,EAAKE,CAAY,CAC9B,EAAG,CAAC,CAAC,CACP,CAZSN,EAAAC,GAAA,kBAoBF,SAASM,EACdC,EACAC,EAAqDC,EACvB,CAC9B,MAAO,CACL,uBAAwBF,EAAO,SAC/B,iBAAkBC,EAAkB,gBACpC,wBAAyBA,EAAkB,sBAC3C,yBAA0BA,EAAkB,uBAC5C,YAAa,CACX,CACE,YAAaD,EAAO,QAAUA,EAAO,QACrC,oBAAqBG,EAAeH,EAAO,MAAM,EACjD,yCAA0CG,EACxCH,EAAO,MACT,EACA,gBAAiBA,EAAO,wBAA0B,QAClD,MAAOC,EAAkB,MACzB,mCAAoC,IACpC,IAAKD,EAAO,KAAO,OACnB,GAAIA,EAAO,UAAY,CAAE,SAAUP,GAAeO,EAAO,QAAQ,CAAE,CACrE,CACF,CACF,CACF,CAxBgBR,EAAAO,EAAA","names":["object","createHeadlessForm","modify","useMutation","useQuery","useState","string","ValidationError","useCostCalculatorCountries","__name","includePremiumBenefits","client","useClient","useQuery","getIndexCountry","data","country","useCompanyCurrencies","getIndexCompanyCurrency","currency","useCostCalculatorEstimation","useMutation","payload","postCreateEstimation","useCostCalculatorEstimationPdf","postCreateEstimationPdf","useRegionFields","region","options","getShowRegionField","jsfSchema","schema","modify","createHeadlessForm","defaultEstimationOptions","useCostCalculator","defaultRegion","estimationOptions","jsonSchemaModified","jsonSchema","fieldsJSONSchema","selectedRegion","setSelectedRegion","useState","selectedCountry","setSelectedCountry","countries","isLoadingCountries","currencies","isLoadingCurrencies","jsonSchemaRegionSlug","jsonSchemaRegionFields","isLoadingRegionFields","costCalculatorEstimationMutation","onSubmit","values","validationSchema","err","resolve","reject","buildPayload","response","error","onCountryChange","currentCountry","value","onRegionChange","regionField","field","regions","string","currencyField","countryField","resetForm","allFields","buildValidationSchema","handleValidation","errors","parsedValues","parseJSFToValidate","ValidationError","iterateResult","iterateErrors","acc","key","handleValidationResult","combinedInnerErrors","combinedValues","buildValidationSchema","fields","fieldsSchema","fieldsSchemaAcc","field","object","__name","formatBenefits","benefits","needle","acc","key","benefitEntry","buildPayload","values","estimationOptions","defaultEstimationOptions","convertToCents"]}
@@ -0,0 +1,2 @@
1
+ import{b as e}from"./chunk-YBACB5A6.js";import{a as r}from"./chunk-AYDF3IFZ.js";var m={form:{index:0,name:"form"},confirmation_form:{index:1,name:"confirmation_form"}};function _(t,o){if(!t)return{};if(!o)return{...t.data.employment?.contract_details,effective_date:"",reason_for_change:"",job_title:t.data.employment?.job_title,additional_comments:"",annual_gross_salary:e(t.data.employment?.contract_details?.annual_gross_salary)};let s=o.map(n=>n.name),i=Object.keys(t?.data?.employment?.contract_details||{});return{...s.reduce((n,a)=>{if(i.includes(a)){let c=t?.data?.employment?.contract_details;n[a]=c[a]}return n},{}),effective_date:"",reason_for_change:"",job_title:t.data.employment?.job_title,additional_comments:"",annual_gross_salary:e(t.data.employment?.contract_details?.annual_gross_salary),additional_comments_toggle:!1}}r(_,"buildInitialValues");export{m as a,_ as b};
2
+ //# sourceMappingURL=chunk-RCX4JUI3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/ContractAmendment/utils.ts"],"sourcesContent":["import { EmploymentShowResponse } from '@/src/client';\nimport { convertFromCents } from '@/src/components/form/utils';\nimport { Fields } from '@remoteoss/json-schema-form';\nimport { Step } from '../useStepState';\n\ntype StepKeys = 'form' | 'confirmation_form';\n\nexport const STEPS: Record<StepKeys, Step> = {\n form: { index: 0, name: 'form' },\n confirmation_form: { index: 1, name: 'confirmation_form' },\n} as const;\n\nexport function buildInitialValues(\n employment: EmploymentShowResponse | undefined,\n fields?: Fields | undefined,\n) {\n if (!employment) {\n return {};\n }\n\n if (!fields) {\n return {\n ...employment.data.employment?.contract_details,\n effective_date: '',\n reason_for_change: '',\n job_title: employment.data.employment?.job_title,\n additional_comments: '',\n annual_gross_salary: convertFromCents(\n employment.data.employment?.contract_details\n ?.annual_gross_salary as string,\n ),\n };\n }\n\n const allFields = fields.map((field) => field.name);\n const employmentFields = Object.keys(\n employment?.data?.employment?.contract_details || {},\n );\n const initialValues = allFields.reduce<Record<string, unknown>>(\n (initialValuesAcc, field) => {\n // @ts-expect-error error\n if (employmentFields.includes(field)) {\n const contractDetails = employment?.data?.employment\n ?.contract_details as Record<string, unknown>;\n // @ts-expect-error error\n initialValuesAcc[field] = contractDetails[field];\n }\n return initialValuesAcc;\n },\n {} as Record<string, unknown>,\n );\n\n return {\n ...initialValues,\n effective_date: '',\n reason_for_change: '',\n job_title: employment.data.employment?.job_title,\n additional_comments: '',\n annual_gross_salary: convertFromCents(\n employment.data.employment?.contract_details\n ?.annual_gross_salary as string,\n ),\n additional_comments_toggle: false,\n };\n}\n"],"mappings":"gFAOO,IAAMA,EAAgC,CAC3C,KAAM,CAAE,MAAO,EAAG,KAAM,MAAO,EAC/B,kBAAmB,CAAE,MAAO,EAAG,KAAM,mBAAoB,CAC3D,EAEO,SAASC,EACdC,EACAC,EACA,CACA,GAAI,CAACD,EACH,MAAO,CAAC,EAGV,GAAI,CAACC,EACH,MAAO,CACL,GAAGD,EAAW,KAAK,YAAY,iBAC/B,eAAgB,GAChB,kBAAmB,GACnB,UAAWA,EAAW,KAAK,YAAY,UACvC,oBAAqB,GACrB,oBAAqBE,EACnBF,EAAW,KAAK,YAAY,kBACxB,mBACN,CACF,EAGF,IAAMG,EAAYF,EAAO,IAAKG,GAAUA,EAAM,IAAI,EAC5CC,EAAmB,OAAO,KAC9BL,GAAY,MAAM,YAAY,kBAAoB,CAAC,CACrD,EAeA,MAAO,CACL,GAfoBG,EAAU,OAC9B,CAACG,EAAkBF,IAAU,CAE3B,GAAIC,EAAiB,SAASD,CAAK,EAAG,CACpC,IAAMG,EAAkBP,GAAY,MAAM,YACtC,iBAEJM,EAAiBF,CAAK,EAAIG,EAAgBH,CAAK,CACjD,CACA,OAAOE,CACT,EACA,CAAC,CACH,EAIE,eAAgB,GAChB,kBAAmB,GACnB,UAAWN,EAAW,KAAK,YAAY,UACvC,oBAAqB,GACrB,oBAAqBE,EACnBF,EAAW,KAAK,YAAY,kBACxB,mBACN,EACA,2BAA4B,EAC9B,CACF,CApDgBQ,EAAAT,EAAA","names":["STEPS","buildInitialValues","employment","fields","convertFromCents","allFields","field","employmentFields","initialValuesAcc","contractDetails","__name"]}
@@ -0,0 +1,2 @@
1
+ import{a as n}from"./chunk-AYDF3IFZ.js";import{useState as d}from"react";var f=n(s=>{let l=Object.keys(s);if(l.length===0)throw new Error("No steps provided to useStepState");let[r,a]=d({}),[p,i]=d({currentStep:s[l[0]],totalSteps:l.length,values:null});function c(){let{index:u}=p.currentStep,t=Object.values(s).find(e=>e.index===u+1);t&&(i(e=>({...e,currentStep:t,values:{...e.values,[e.currentStep.name]:{...e.values?.[e.currentStep.name],...r}}})),a({}))}n(c,"nextStep");function S(){let{index:u}=p.currentStep,t=Object.values(s).find(e=>e.index===u-1);t&&(i(e=>({...e,currentStep:t,values:{...e.values,[e.currentStep.name]:{...e.values?.[e.currentStep.name],...r}}})),a({}))}return n(S,"previousStep"),{nextStep:c,previousStep:S,stepState:p,fieldValues:r,setFieldValues:a}},"useStepState");export{f as a};
2
+ //# sourceMappingURL=chunk-S56EWAS4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/useStepState.ts"],"sourcesContent":["import { useState } from 'react';\nimport { FieldValues } from 'react-hook-form';\n\nexport type Step = {\n index: number;\n name: string;\n};\n\ntype StepState<T extends string, Fields = FieldValues> = {\n currentStep: Step;\n totalSteps: number;\n values:\n | {\n [key in T]: Fields;\n }\n | null;\n};\n\nexport const useStepState = <T extends string, Fields = FieldValues>(\n steps: Record<T, Step>,\n) => {\n const stepKeys = Object.keys(steps) as Array<keyof typeof steps>;\n\n if (stepKeys.length === 0) {\n throw new Error('No steps provided to useStepState');\n }\n\n const [fieldValues, setFieldValues] = useState<Fields>({} as Fields);\n const [stepState, setStepState] = useState<StepState<T, Fields>>({\n currentStep: steps[stepKeys[0]],\n totalSteps: stepKeys.length,\n values: null,\n });\n\n function nextStep() {\n const { index } = stepState.currentStep;\n const stepValues = Object.values<Step>(steps);\n const nextStep = stepValues.find((step) => step.index === index + 1);\n\n if (nextStep) {\n setStepState((previousState) => ({\n ...previousState,\n currentStep: nextStep,\n values: {\n ...previousState.values,\n [previousState.currentStep.name]: {\n ...previousState.values?.[previousState.currentStep.name as T],\n ...fieldValues,\n },\n } as { [key in T]: Fields },\n }));\n setFieldValues({} as Fields); // Reset field values for the next step\n }\n }\n\n function previousStep() {\n const { index } = stepState.currentStep;\n const stepValues = Object.values<Step>(steps);\n const previousStep = stepValues.find((step) => step.index === index - 1);\n\n if (previousStep) {\n setStepState((previousState) => ({\n ...previousState,\n currentStep: previousStep,\n values: {\n ...previousState.values,\n [previousState.currentStep.name]: {\n ...previousState.values?.[previousState.currentStep.name as T],\n ...fieldValues,\n },\n } as { [key in T]: Fields },\n }));\n setFieldValues({} as Fields); // Reset field values for the previous step\n }\n }\n\n return {\n /**\n * Moves to the next step in the step state.\n * It updates the current step and resets the field values for the next step.\n * The field values for the current step are stored in the step state.\n * @returns {void}\n */\n nextStep,\n /**\n * Moves to the previous step in the step state.\n * It updates the current step and resets the field values for the previous step.\n * The field values for the current step are stored in the step state.\n * @returns {void}\n */\n previousStep,\n /**\n * The current step state containing the current step, total number of steps and\n * the form values for each step.\n * @returns {StepState<T>} The current step state.\n */\n stepState,\n /**\n * The field values for the current step.\n * @returns {FieldValues} The field values for the current step.\n */\n fieldValues,\n /**\n * Sets the field values for the current step.\n * @param values The field values to set.\n * @returns {void}\n */\n setFieldValues,\n };\n};\n"],"mappings":"wCAAA,OAAS,YAAAA,MAAgB,QAkBlB,IAAMC,EAAeC,EAC1BC,GACG,CACH,IAAMC,EAAW,OAAO,KAAKD,CAAK,EAElC,GAAIC,EAAS,SAAW,EACtB,MAAM,IAAI,MAAM,mCAAmC,EAGrD,GAAM,CAACC,EAAaC,CAAc,EAAIC,EAAiB,CAAC,CAAW,EAC7D,CAACC,EAAWC,CAAY,EAAIF,EAA+B,CAC/D,YAAaJ,EAAMC,EAAS,CAAC,CAAC,EAC9B,WAAYA,EAAS,OACrB,OAAQ,IACV,CAAC,EAED,SAASM,GAAW,CAClB,GAAM,CAAE,MAAAC,CAAM,EAAIH,EAAU,YAEtBE,EADa,OAAO,OAAaP,CAAK,EAChB,KAAMS,GAASA,EAAK,QAAUD,EAAQ,CAAC,EAE/DD,IACFD,EAAcI,IAAmB,CAC/B,GAAGA,EACH,YAAaH,EACb,OAAQ,CACN,GAAGG,EAAc,OACjB,CAACA,EAAc,YAAY,IAAI,EAAG,CAChC,GAAGA,EAAc,SAASA,EAAc,YAAY,IAAS,EAC7D,GAAGR,CACL,CACF,CACF,EAAE,EACFC,EAAe,CAAC,CAAW,EAE/B,CAnBSJ,EAAAQ,EAAA,YAqBT,SAASI,GAAe,CACtB,GAAM,CAAE,MAAAH,CAAM,EAAIH,EAAU,YAEtBM,EADa,OAAO,OAAaX,CAAK,EACZ,KAAMS,GAASA,EAAK,QAAUD,EAAQ,CAAC,EAEnEG,IACFL,EAAcI,IAAmB,CAC/B,GAAGA,EACH,YAAaC,EACb,OAAQ,CACN,GAAGD,EAAc,OACjB,CAACA,EAAc,YAAY,IAAI,EAAG,CAChC,GAAGA,EAAc,SAASA,EAAc,YAAY,IAAS,EAC7D,GAAGR,CACL,CACF,CACF,EAAE,EACFC,EAAe,CAAC,CAAW,EAE/B,CAnBS,OAAAJ,EAAAY,EAAA,gBAqBF,CAOL,SAAAJ,EAOA,aAAAI,EAMA,UAAAN,EAKA,YAAAH,EAMA,eAAAC,CACF,CACF,EA3F4B","names":["useState","useStepState","__name","steps","stepKeys","fieldValues","setFieldValues","useState","stepState","setStepState","nextStep","index","step","previousState","previousStep"]}
@@ -0,0 +1,2 @@
1
+ import{a as T}from"./chunk-XFD3ULUF.js";import{a as F}from"./chunk-CTG3DYJR.js";import{a as S}from"./chunk-SEUQNAF6.js";import{a as V}from"./chunk-FZ2HS6G7.js";import{b as y}from"./chunk-36UPHOJS.js";import{a as p}from"./chunk-JRQSZHUU.js";import{b as f}from"./chunk-55VACCVZ.js";import{c as m}from"./chunk-YBACB5A6.js";import{a as _}from"./chunk-S56EWAS4.js";import{d as c}from"./chunk-WRDKLT4N.js";import{a as o}from"./chunk-AYDF3IFZ.js";import{createHeadlessForm as h,modify as J}from"@remoteoss/json-schema-form";import{useMutation as O,useQuery as x}from"@tanstack/react-query";import z from"lodash/omit";function A(i){return{confidential:"",customer_informed_employee:"",customer_informed_employee_date:"",customer_informed_employee_description:"",personal_email:"",termination_reason:void 0,reason_description:"",termination_reason_files:[],will_challenge_termination:"",will_challenge_termination_description:null,agrees_to_pto_amount:"",agrees_to_pto_amount_notes:null,acknowledge_termination_procedure:!1,additional_comments:"",proposed_termination_date:"",risk_assessment_reasons:[],timesheet_file:void 0,...i}}o(A,"buildInitialValues");var K=o(()=>{let{client:i}=c();return O({mutationFn:o(a=>f({client:i,headers:{Authorization:""},body:a}),"mutationFn")})},"useCreateTermination"),L=o(({formValues:i,jsfModify:a,step:s})=>x({queryKey:["rmt-flows-termination-schema",s],queryFn:o(()=>S[s]??T,"queryFn"),select:o(({data:l})=>{let{schema:e}=J(l.schema,a||{});return h(e||{},{initialValues:i||{}})},"select")}),"useTerminationSchema"),ae=o(({employmentId:i,options:a})=>{let{fieldValues:s,setFieldValues:l,stepState:e,previousStep:u,nextStep:g}=_(V),P=e.values?e.values[e.currentStep.name]:s,{data:n,isLoading:b}=L({formValues:P,jsfModify:a?.jsfModify,step:e.currentStep.name}),k=h(F.data.schema),d=K(),{mutateAsync:w}=p(d);async function C(r){if(!i)throw new Error("Employment id is missing");if(e.currentStep.index<e.totalSteps-1){g();return}if(n){let t=m(r,k.fields),{customer_informed_employee:E}=t,j=E==="yes"?{employee_awareness:{date:t.customer_informed_employee_date,note:t.customer_informed_employee_description}}:void 0,D=y(t,["agrees_to_pto_amount","confidential","customer_informed_employee","will_challenge_termination"]),H={...z(D,"customer_informed_employee_date","customer_informed_employee_description"),...j};return w({employment_id:i,termination_details:H,type:"termination"})}}o(C,"onSubmit");function M(){u()}o(M,"back");let v=A({...e.values?.employee_communication,...e.values?.termination_details,...e.values?.paid_time_off,...e.values?.additional_information});return{employmentId:i,stepState:e,fields:n?.fields||[],isLoading:b,isSubmitting:d.isPending,initialValues:v,handleValidation:o(r=>{if(n){let t=m(r,n?.fields);return n?.handleValidation(t)}return null},"handleValidation"),checkFieldUpdates:o(r=>{if(n){let t=m(r,n?.fields,{isPartialValidation:!0});l(t)}},"checkFieldUpdates"),onSubmit:C,back:M}},"useTermination");export{ae as a};
2
+ //# sourceMappingURL=chunk-SABMDOWE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/Termination/hooks.ts"],"sourcesContent":["import {\n CreateOffboardingParams,\n postCreateOffboarding,\n TerminationDetailsParams,\n} from '@/src/client';\nimport { mutationToPromise } from '@/src/lib/mutations';\nimport { Client } from '@hey-api/client-fetch';\nimport { createHeadlessForm, modify } from '@remoteoss/json-schema-form';\nimport { useMutation, useQuery } from '@tanstack/react-query';\nimport { parseJSFToValidate } from '@/src/components/form/utils';\nimport { JSFModify } from '@/src/flows/CostCalculator/types';\nimport { TerminationFormValues } from '@/src/flows/Termination/types';\nimport { useClient } from '@/src/context';\nimport omit from 'lodash/omit';\nimport { parseFormRadioValues } from '@/src/flows/utils';\nimport { useStepState } from '@/src/flows/useStepState';\nimport { STEPS } from '@/src/flows/Termination/utils';\nimport { defaultSchema } from '@/src/flows/Termination/json-schemas/defaultSchema';\nimport { schema } from '@/src/flows/Termination/json-schemas/schema';\nimport { jsonSchema } from '@/src/flows/Termination/json-schemas/jsonSchema';\n\nfunction buildInitialValues(\n stepsInitialValues: Partial<TerminationFormValues>,\n): TerminationFormValues {\n const initialValues: TerminationFormValues = {\n confidential: '',\n customer_informed_employee: '',\n customer_informed_employee_date: '',\n customer_informed_employee_description: '',\n personal_email: '',\n termination_reason: undefined,\n reason_description: '',\n termination_reason_files: [],\n will_challenge_termination: '',\n will_challenge_termination_description: null,\n agrees_to_pto_amount: '',\n agrees_to_pto_amount_notes: null,\n acknowledge_termination_procedure: false,\n additional_comments: '',\n proposed_termination_date: '',\n risk_assessment_reasons: [],\n timesheet_file: undefined,\n ...stepsInitialValues,\n };\n\n return initialValues;\n}\n\nconst useCreateTermination = () => {\n const { client } = useClient();\n return useMutation({\n mutationFn: (payload: CreateOffboardingParams) => {\n return postCreateOffboarding({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n body: payload,\n });\n },\n });\n};\n\nconst useTerminationSchema = ({\n formValues,\n jsfModify,\n step,\n}: {\n formValues?: TerminationFormValues;\n jsfModify?: JSFModify;\n step?: string;\n}) => {\n return useQuery({\n queryKey: ['rmt-flows-termination-schema', step],\n queryFn: () => {\n return schema[step as keyof typeof schema] ?? defaultSchema;\n },\n select: ({ data }) => {\n const { schema } = modify(data.schema, jsfModify || {});\n const form = createHeadlessForm(schema || {}, {\n initialValues: formValues || {},\n });\n return form;\n },\n });\n};\n\ntype TerminationHookProps = {\n employmentId: string;\n options?: {\n jsfModify?: JSFModify;\n };\n};\n\nexport const useTermination = ({\n employmentId,\n options,\n}: TerminationHookProps) => {\n const { fieldValues, setFieldValues, stepState, previousStep, nextStep } =\n useStepState<keyof typeof STEPS, TerminationFormValues>(STEPS);\n\n const formValues = stepState.values\n ? stepState.values[stepState.currentStep.name as keyof typeof STEPS]\n : fieldValues;\n\n const { data: terminationHeadlessForm, isLoading: isLoadingTermination } =\n useTerminationSchema({\n formValues: formValues,\n jsfModify: options?.jsfModify,\n step: stepState.currentStep.name,\n });\n\n const entireTerminationSchema = createHeadlessForm(jsonSchema.data.schema);\n\n const createTermination = useCreateTermination();\n const { mutateAsync } = mutationToPromise(createTermination);\n\n async function onSubmit(values: TerminationFormValues) {\n if (!employmentId) {\n throw new Error('Employment id is missing');\n }\n\n if (stepState.currentStep.index < stepState.totalSteps - 1) {\n nextStep();\n return;\n }\n\n if (terminationHeadlessForm) {\n // this is a hack because I need to validate all form values with the entire schema\n const parsedValues = parseJSFToValidate(\n values,\n entireTerminationSchema.fields,\n );\n\n const { customer_informed_employee: customerInformedEmployee } =\n parsedValues;\n\n const employeeAwareness =\n customerInformedEmployee === 'yes'\n ? {\n employee_awareness: {\n date: parsedValues.customer_informed_employee_date,\n note: parsedValues.customer_informed_employee_description,\n },\n }\n : undefined;\n\n const radioFieldKeys = [\n 'agrees_to_pto_amount',\n 'confidential',\n 'customer_informed_employee',\n 'will_challenge_termination',\n ];\n\n const parsedRadioValues = parseFormRadioValues(\n parsedValues,\n radioFieldKeys,\n );\n\n const normalizedValues = omit(\n parsedRadioValues,\n 'customer_informed_employee_date',\n 'customer_informed_employee_description',\n );\n\n const terminationDetails: TerminationDetailsParams = {\n ...normalizedValues,\n ...employeeAwareness,\n } as TerminationDetailsParams;\n\n const terminationPayload: CreateOffboardingParams = {\n employment_id: employmentId,\n termination_details: terminationDetails,\n type: 'termination',\n };\n\n return mutateAsync(terminationPayload);\n }\n\n return;\n }\n\n function back() {\n previousStep();\n }\n\n const initialValues = buildInitialValues({\n ...stepState.values?.employee_communication,\n ...stepState.values?.termination_details,\n ...stepState.values?.paid_time_off,\n ...stepState.values?.additional_information,\n });\n\n return {\n /**\n * Employment id passed useful to be used between components\n */\n employmentId,\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 contract amendment schema\n */\n fields: terminationHeadlessForm?.fields || [],\n /**\n * Loading state indicating if the termination schema is being fetched\n */\n isLoading: isLoadingTermination,\n /**\n * Loading state indicating if a contract amendment mutation is in progress\n */\n isSubmitting: createTermination.isPending,\n /**\n * Initial form values\n */\n initialValues: initialValues,\n /**\n * Function to validate form values against the contract amendment schema\n * @param values - Form values to validate\n * @returns Validation result or null if no schema is available\n */\n handleValidation: (values: TerminationFormValues) => {\n if (terminationHeadlessForm) {\n const parsedValues = parseJSFToValidate(\n values,\n terminationHeadlessForm?.fields,\n );\n return terminationHeadlessForm?.handleValidation(parsedValues);\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: (values: Partial<TerminationFormValues>) => {\n if (terminationHeadlessForm) {\n const parsedValues = parseJSFToValidate(\n values,\n terminationHeadlessForm?.fields,\n { isPartialValidation: true },\n );\n setFieldValues(parsedValues as TerminationFormValues);\n }\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"],"mappings":"wbAOA,OAAS,sBAAAA,EAAoB,UAAAC,MAAc,8BAC3C,OAAS,eAAAC,EAAa,YAAAC,MAAgB,wBAKtC,OAAOC,MAAU,cAQjB,SAASC,EACPC,EACuB,CAsBvB,MArB6C,CAC3C,aAAc,GACd,2BAA4B,GAC5B,gCAAiC,GACjC,uCAAwC,GACxC,eAAgB,GAChB,mBAAoB,OACpB,mBAAoB,GACpB,yBAA0B,CAAC,EAC3B,2BAA4B,GAC5B,uCAAwC,KACxC,qBAAsB,GACtB,2BAA4B,KAC5B,kCAAmC,GACnC,oBAAqB,GACrB,0BAA2B,GAC3B,wBAAyB,CAAC,EAC1B,eAAgB,OAChB,GAAGA,CACL,CAGF,CAzBSC,EAAAF,EAAA,sBA2BT,IAAMG,EAAuBD,EAAA,IAAM,CACjC,GAAM,CAAE,OAAAE,CAAO,EAAIC,EAAU,EAC7B,OAAOC,EAAY,CACjB,WAAYJ,EAACK,GACJC,EAAsB,CAC3B,OAAQJ,EACR,QAAS,CACP,cAAe,EACjB,EACA,KAAMG,CACR,CAAC,EAPS,aASd,CAAC,CACH,EAb6B,wBAevBE,EAAuBP,EAAA,CAAC,CAC5B,WAAAQ,E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xBL,EARqB,CACrB,uBACA,eACA,6BACA,4BACF,CAKA,EAQMM,EAA+C,CACnD,GAPuBC,EACvBH,EACA,kCACA,wCACF,EAIE,GAAGD,CACL,EAQA,OAAOP,EAN6C,CAClD,cAAed,EACf,oBAAqBwB,EACrB,KAAM,aACR,CAEqC,CACvC,CAGF,CA/De1C,EAAAkC,EAAA,YAiEf,SAASU,GAAO,CACdrB,EAAa,CACf,CAFSvB,EAAA4C,EAAA,QAIT,IAAMC,EAAgB/C,EAAmB,CACvC,GAAGwB,EAAU,QAAQ,uBACrB,GAAGA,EAAU,QAAQ,oBACrB,GAAGA,EAAU,QAAQ,cACrB,GAAGA,EAAU,QAAQ,sBACvB,CAAC,EAED,MAAO,CAIL,aAAAJ,EAIA,UAAAI,EAIA,OAAQK,GAAyB,QAAU,CAAC,EAI5C,UAAWC,EAIX,aAAcG,EAAkB,UAIhC,cAAec,EAMf,iBAAkB7C,EAACmC,GAAkC,CACnD,GAAIR,EAAyB,CAC3B,IAAMS,EAAeC,EACnBF,EACAR,GAAyB,MAC3B,EACA,OAAOA,GAAyB,iBAAiBS,CAAY,CAC/D,CACA,OAAO,IACT,EATkB,oBAclB,kBAAmBpC,EAACmC,GAA2C,CAC7D,GAAIR,EAAyB,CAC3B,IAAMS,EAAeC,EACnBF,EACAR,GAAyB,OACzB,CAAE,oBAAqB,EAAK,CAC9B,EACAN,EAAee,CAAqC,CACtD,CACF,EATmB,qBAenB,SAAAF,EAMA,KAAAU,CACF,CACF,EAtK8B","names":["createHeadlessForm","modify","useMutation","useQuery","omit","buildInitialValues","stepsInitialValues","__name","useCreateTermination","client","useClient","useMutation","payload","postCreateOffboarding","useTerminationSchema","formValues","jsfModify","step","useQuery","schema","defaultSchema","data","modify","createHeadlessForm","useTermination","employmentId","options","fieldValues","setFieldValues","stepState","previousStep","nextStep","useStepState","STEPS","terminationHeadlessForm","isLoadingTermination","entireTerminationSchema","jsonSchema","createTermination","mutateAsync","mutationToPromise","onSubmit","values","parsedValues","parseJSFToValidate","customerInformedEmployee","employeeAwareness","parsedRadioValues","parseFormRadioValues","terminationDetails","omit","back","initialValues"]}
@@ -0,0 +1,2 @@
1
+ import{a as e}from"./chunk-VX2UC3HG.js";import{a as i}from"./chunk-IPZEZMLD.js";import{a as o}from"./chunk-JODJFARP.js";import{a as m}from"./chunk-W5DG5WWJ.js";var p={employee_communication:o,termination_details:e,paid_time_off:m,additional_information:i};export{p as a};
2
+ //# sourceMappingURL=chunk-SEUQNAF6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/Termination/json-schemas/schema.ts"],"sourcesContent":["import { additionalInformationSchema } from '@/src/flows/Termination/json-schemas/additionalInformation';\nimport { employeeComunicationSchema } from '@/src/flows/Termination/json-schemas/employeeComunication';\nimport { paidTimeOffSchema } from '@/src/flows/Termination/json-schemas/paidTimeOff';\nimport { terminationDetailsSchema } from '@/src/flows/Termination/json-schemas/terminationDetails';\nimport { StepTerminationKeys } from '@/src/flows/Termination/utils';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const schema: Record<StepTerminationKeys, Record<string, any>> = {\n employee_communication: employeeComunicationSchema,\n termination_details: terminationDetailsSchema,\n paid_time_off: paidTimeOffSchema,\n additional_information: additionalInformationSchema,\n};\n"],"mappings":"gKAOO,IAAMA,EAA2D,CACtE,uBAAwBC,EACxB,oBAAqBC,EACrB,cAAeC,EACf,uBAAwBC,CAC1B","names":["schema","employeeComunicationSchema","terminationDetailsSchema","paidTimeOffSchema","additionalInformationSchema"]}
@@ -0,0 +1,2 @@
1
+ var e={data:{version:7,schema:{additionalProperties:!1,allOf:[{if:{properties:{will_challenge_termination:{const:"yes"}},required:["will_challenge_termination"]},then:{properties:{will_challenge_termination_description:{type:"string"}},required:["will_challenge_termination_description"]},else:{properties:{will_challenge_termination_description:!1}}}],properties:{termination_reason:{title:"Termination reason",description:"Make sure you choose an accurate termination reason to avoid unfair or unlawful dismissal claims.",type:"string",oneOf:[{const:"gross_misconduct",title:"Gross misconduct"},{const:"performance",title:"Performance"},{const:"workforce_reduction",title:"Workforce Reduction"},{const:"values",title:"Values"},{const:"compliance_issue",title:"Compliance issue"},{const:"incapacity_to_perform_inherent_duties",title:"Incapacity To perform inherent duties"},{const:"mutual_agreement",title:"Mutual agreement"},{const:"cancellation_before_start_date",title:"Decision to cancel hiring before the employee starts"},{const:"job_abandonment",title:"Job abandonment"},{const:"dissatisfaction_with_remote_service",title:"Dissatisfaction with EOR service"},{const:"end_of_fixed_term_contract_compliance_issue",title:"End of fixed-term contract"},{const:"other",title:"Other"}],"x-jsf-presentation":{inputType:"select"}},reason_description:{description:"",maxLength:1e3,title:"Termination reason details",type:"string","x-jsf-presentation":{inputType:"textarea"}},additional_comments:{description:"",maxLength:1e3,title:"Additional details regarding this termination process.",type:"string","x-jsf-presentation":{inputType:"textarea"}},termination_reason_files:{description:"Please upload any supporting documents regarding the termination reason.",title:"Termination reason files",type:"string","x-jsf-presentation":{inputType:"file",accept:".pdf",multiple:!0}},risk_assessment_reasons:{description:"",title:"This employee is...",type:"array",items:{anyOf:[{const:"sick_leave",title:"Currently on or recently returned from sick leave"},{const:"family_leave",title:"Currently on or recently returned from maternity, paternity, or other family leave"},{const:"pregnant_or_breastfeeding",title:"Pregnant or breastfeeding"},{const:"requested_medical_or_family_leave",title:"Requested medical or family leave"},{const:"disabled_or_health_condition",title:"Disabled or has a health condition"},{const:"member_of_union_or_works_council",title:"A member of a union or works council"},{const:"caring_responsibilities",title:"Caring responsibilities"},{const:"reported_concerns_with_workplace",title:"Reported any wrongdoing; raised any allegations of discrimination, harassment, retaliation, etc.; or asserted their employment rights or raised complaints about their working conditions"},{const:"none_of_these",title:"To the best of my knowledge, I am not aware of any of these"}]},"x-jsf-presentation":{inputType:"checkbox",direction:"column"}},will_challenge_termination:{description:"",oneOf:[{const:"yes",description:"",title:"Yes"},{const:"no",description:"",title:"No"}],title:"Do you consider it is likely that the employee will challenge their termination?",type:"string","x-jsf-presentation":{direction:"column",inputType:"radio"}},will_challenge_termination_description:{description:"",maxLength:1e3,title:"Please explain how the employee will challenge their termination",type:["string","null"],"x-jsf-presentation":{inputType:"textarea"}},proposed_termination_date:{description:"",format:"date",maxLength:255,title:"Proposed termination date",type:"string","x-jsf-presentation":{inputType:"date"}}},required:["termination_reason","reason_description","risk_assessment_reasons","will_challenge_termination","proposed_termination_date"],type:"object","x-jsf-order":["termination_reason","reason_description","additional_comments","termination_reason_files","risk_assessment_reasons","will_challenge_termination","will_challenge_termination_description","proposed_termination_date"]}}};export{e as a};
2
+ //# sourceMappingURL=chunk-VX2UC3HG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/Termination/json-schemas/terminationDetails.ts"],"sourcesContent":["export const terminationDetailsSchema = {\n data: {\n version: 7,\n schema: {\n additionalProperties: false,\n allOf: [\n {\n if: {\n properties: {\n will_challenge_termination: {\n const: 'yes',\n },\n },\n required: ['will_challenge_termination'],\n },\n then: {\n properties: {\n will_challenge_termination_description: {\n type: 'string',\n },\n },\n required: ['will_challenge_termination_description'],\n },\n else: {\n properties: {\n will_challenge_termination_description: false,\n },\n },\n },\n ],\n properties: {\n termination_reason: {\n title: 'Termination reason',\n description:\n 'Make sure you choose an accurate termination reason to avoid unfair or unlawful dismissal claims.',\n type: 'string',\n oneOf: [\n {\n const: 'gross_misconduct',\n title: 'Gross misconduct',\n },\n {\n const: 'performance',\n title: 'Performance',\n },\n {\n const: 'workforce_reduction',\n title: 'Workforce Reduction',\n },\n {\n const: 'values',\n title: 'Values',\n },\n {\n const: 'compliance_issue',\n title: 'Compliance issue',\n },\n {\n const: 'incapacity_to_perform_inherent_duties',\n title: 'Incapacity To perform inherent duties',\n },\n {\n const: 'mutual_agreement',\n title: 'Mutual agreement',\n },\n {\n const: 'cancellation_before_start_date',\n title: 'Decision to cancel hiring before the employee starts',\n },\n {\n const: 'job_abandonment',\n title: 'Job abandonment',\n },\n {\n const: 'dissatisfaction_with_remote_service',\n title: 'Dissatisfaction with EOR service',\n },\n {\n const: 'end_of_fixed_term_contract_compliance_issue',\n title: 'End of fixed-term contract',\n },\n {\n const: 'other',\n title: 'Other',\n },\n ],\n 'x-jsf-presentation': {\n inputType: 'select',\n },\n },\n reason_description: {\n description: '',\n maxLength: 1000,\n title: 'Termination reason details',\n type: 'string',\n 'x-jsf-presentation': {\n inputType: 'textarea',\n },\n },\n additional_comments: {\n description: '',\n maxLength: 1000,\n title: 'Additional details regarding this termination process.',\n type: 'string',\n 'x-jsf-presentation': {\n inputType: 'textarea',\n },\n },\n termination_reason_files: {\n description:\n 'Please upload any supporting documents regarding the termination reason.',\n title: 'Termination reason files',\n type: 'string',\n 'x-jsf-presentation': {\n inputType: 'file',\n accept: '.pdf',\n multiple: true,\n },\n },\n risk_assessment_reasons: {\n description: '',\n title: 'This employee is...',\n type: 'array',\n items: {\n anyOf: [\n {\n const: 'sick_leave',\n title: 'Currently on or recently returned from sick leave',\n },\n {\n const: 'family_leave',\n title:\n 'Currently on or recently returned from maternity, paternity, or other family leave',\n },\n {\n const: 'pregnant_or_breastfeeding',\n title: 'Pregnant or breastfeeding',\n },\n {\n const: 'requested_medical_or_family_leave',\n title: 'Requested medical or family leave',\n },\n {\n const: 'disabled_or_health_condition',\n title: 'Disabled or has a health condition',\n },\n {\n const: 'member_of_union_or_works_council',\n title: 'A member of a union or works council',\n },\n {\n const: 'caring_responsibilities',\n title: 'Caring responsibilities',\n },\n {\n const: 'reported_concerns_with_workplace',\n title:\n 'Reported any wrongdoing; raised any allegations of discrimination, harassment, retaliation, etc.; or asserted their employment rights or raised complaints about their working conditions',\n },\n {\n const: 'none_of_these',\n title:\n 'To the best of my knowledge, I am not aware of any of these',\n },\n ],\n },\n 'x-jsf-presentation': {\n inputType: 'checkbox',\n direction: 'column',\n },\n },\n will_challenge_termination: {\n description: '',\n oneOf: [\n {\n const: 'yes',\n description: '',\n title: 'Yes',\n },\n {\n const: 'no',\n description: '',\n title: 'No',\n },\n ],\n title:\n 'Do you consider it is likely that the employee will challenge their termination?',\n type: 'string',\n 'x-jsf-presentation': {\n direction: 'column',\n inputType: 'radio',\n },\n },\n will_challenge_termination_description: {\n description: '',\n maxLength: 1000,\n title:\n 'Please explain how the employee will challenge their termination',\n type: ['string', 'null'],\n 'x-jsf-presentation': {\n inputType: 'textarea',\n },\n },\n proposed_termination_date: {\n description: '',\n format: 'date',\n maxLength: 255,\n title: 'Proposed termination date',\n type: 'string',\n 'x-jsf-presentation': {\n inputType: 'date',\n },\n },\n },\n required: [\n 'termination_reason',\n 'reason_description',\n 'risk_assessment_reasons',\n 'will_challenge_termination',\n 'proposed_termination_date',\n ],\n type: 'object',\n 'x-jsf-order': [\n 'termination_reason',\n 'reason_description',\n 'additional_comments',\n 'termination_reason_files',\n 'risk_assessment_reasons',\n 'will_challenge_termination',\n 'will_challenge_termination_description',\n 'proposed_termination_date',\n ],\n },\n },\n};\n"],"mappings":"AAAO,IAAMA,EAA2B,CACtC,KAAM,CACJ,QAAS,EACT,OAAQ,CACN,qBAAsB,GACtB,MAAO,CACL,CACE,GAAI,CACF,WAAY,CACV,2BAA4B,CAC1B,MAAO,KACT,CACF,EACA,SAAU,CAAC,4BAA4B,CACzC,EACA,KAAM,CACJ,WAAY,CACV,uCAAwC,CACtC,KAAM,QACR,CACF,EACA,SAAU,CAAC,wCAAwC,CACrD,EACA,KAAM,CACJ,WAAY,CACV,uCAAwC,EAC1C,CACF,CACF,CACF,EACA,WAAY,CACV,mBAAoB,CAClB,MAAO,qBACP,YACE,oGACF,KAAM,SACN,MAAO,CACL,CACE,MAAO,mBACP,MAAO,kBACT,EACA,CACE,MAAO,cACP,MAAO,aACT,EACA,CACE,MAAO,sBACP,MAAO,qBACT,EACA,CACE,MAAO,SACP,MAAO,QACT,EACA,CACE,MAAO,mBACP,MAAO,kBACT,EACA,CACE,MAAO,wCACP,MAAO,uCACT,EACA,CACE,MAAO,mBACP,MAAO,kBACT,EACA,CACE,MAAO,iCACP,MAAO,sDACT,EACA,CACE,MAAO,kBACP,MAAO,iBACT,EACA,CACE,MAAO,sCACP,MAAO,kCACT,EACA,CACE,MAAO,8CACP,MAAO,4BACT,EACA,CACE,MAAO,QACP,MAAO,OACT,CACF,EACA,qBAAsB,CACpB,UAAW,QACb,CACF,EACA,mBAAoB,CAClB,YAAa,GACb,UAAW,IACX,MAAO,6BACP,KAAM,SACN,qBAAsB,CACpB,UAAW,UACb,CACF,EACA,oBAAqB,CACnB,YAAa,GACb,UAAW,IACX,MAAO,yDACP,KAAM,SACN,qBAAsB,CACpB,UAAW,UACb,CACF,EACA,yBAA0B,CACxB,YACE,2EACF,MAAO,2BACP,KAAM,SACN,qBAAsB,CACpB,UAAW,OACX,OAAQ,OACR,SAAU,EACZ,CACF,EACA,wBAAyB,CACvB,YAAa,GACb,MAAO,sBACP,KAAM,QACN,MAAO,CACL,MAAO,CACL,CACE,MAAO,aACP,MAAO,mDACT,EACA,CACE,MAAO,eACP,MACE,oFACJ,EACA,CACE,MAAO,4BACP,MAAO,2BACT,EACA,CACE,MAAO,oCACP,MAAO,mCACT,EACA,CACE,MAAO,+BACP,MAAO,oCACT,EACA,CACE,MAAO,mCACP,MAAO,sCACT,EACA,CACE,MAAO,0BACP,MAAO,yBACT,EACA,CACE,MAAO,mCACP,MACE,2LACJ,EACA,CACE,MAAO,gBACP,MACE,6DACJ,CACF,CACF,EACA,qBAAsB,CACpB,UAAW,WACX,UAAW,QACb,CACF,EACA,2BAA4B,CAC1B,YAAa,GACb,MAAO,CACL,CACE,MAAO,MACP,YAAa,GACb,MAAO,KACT,EACA,CACE,MAAO,KACP,YAAa,GACb,MAAO,IACT,CACF,EACA,MACE,mFACF,KAAM,SACN,qBAAsB,CACpB,UAAW,SACX,UAAW,OACb,CACF,EACA,uCAAwC,CACtC,YAAa,GACb,UAAW,IACX,MACE,mEACF,KAAM,CAAC,SAAU,MAAM,EACvB,qBAAsB,CACpB,UAAW,UACb,CACF,EACA,0BAA2B,CACzB,YAAa,GACb,OAAQ,OACR,UAAW,IACX,MAAO,4BACP,KAAM,SACN,qBAAsB,CACpB,UAAW,MACb,CACF,CACF,EACA,SAAU,CACR,qBACA,qBACA,0BACA,6BACA,2BACF,EACA,KAAM,SACN,cAAe,CACb,qBACA,qBACA,sBACA,2BACA,0BACA,6BACA,yCACA,2BACF,CACF,CACF,CACF","names":["terminationDetailsSchema"]}
@@ -0,0 +1,2 @@
1
+ var e={data:{version:7,schema:{additionalProperties:!1,allOf:[{if:{properties:{agrees_to_pto_amount:{const:"no"}},required:["agrees_to_pto_amount"]},then:{properties:{agrees_to_pto_amount_notes:{type:"string"}},required:["agrees_to_pto_amount_notes"]},else:{properties:{agrees_to_pto_amount_notes:!1,timesheet_file:!1}}}],properties:{agrees_to_pto_amount:{description:"",oneOf:[{const:"yes",description:"",title:"Yes"},{const:"no",description:"",title:"No"}],title:"Are these paid time off records correct?",type:"string","x-jsf-presentation":{direction:"column",inputType:"radio"}},agrees_to_pto_amount_notes:{description:"Please provide details regarding any additional days taken, including specific dates, or any other inaccuracy in the time off data.",maxLength:1e3,title:"Provide time off details",type:["string","null"],"x-jsf-presentation":{inputType:"textarea"}},timesheet_file:{description:"Upload a timesheet exported from your HR software. This way we can compare and confirm the total number of Paid time off.",title:"Timesheet document",type:["string","null"],"x-jsf-presentation":{inputType:"file",accept:".pdf"}}},required:["agrees_to_pto_amount"],type:"object","x-jsf-order":["agrees_to_pto_amount","agrees_to_pto_amount_notes","timesheet_file"]}}};export{e as a};
2
+ //# sourceMappingURL=chunk-W5DG5WWJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/Termination/json-schemas/paidTimeOff.ts"],"sourcesContent":["export const paidTimeOffSchema = {\n data: {\n version: 7,\n schema: {\n additionalProperties: false,\n allOf: [\n {\n if: {\n properties: {\n agrees_to_pto_amount: {\n const: 'no',\n },\n },\n required: ['agrees_to_pto_amount'],\n },\n then: {\n properties: {\n agrees_to_pto_amount_notes: {\n type: 'string',\n },\n },\n required: ['agrees_to_pto_amount_notes'],\n },\n else: {\n properties: {\n agrees_to_pto_amount_notes: false,\n timesheet_file: false,\n },\n },\n },\n ],\n properties: {\n agrees_to_pto_amount: {\n description: '',\n oneOf: [\n {\n const: 'yes',\n description: '',\n title: 'Yes',\n },\n {\n const: 'no',\n description: '',\n title: 'No',\n },\n ],\n title: 'Are these paid time off records correct?',\n type: 'string',\n 'x-jsf-presentation': {\n direction: 'column',\n inputType: 'radio',\n },\n },\n agrees_to_pto_amount_notes: {\n description:\n 'Please provide details regarding any additional days taken, including specific dates, or any other inaccuracy in the time off data.',\n maxLength: 1000,\n title: 'Provide time off details',\n type: ['string', 'null'],\n 'x-jsf-presentation': {\n inputType: 'textarea',\n },\n },\n timesheet_file: {\n description:\n 'Upload a timesheet exported from your HR software. This way we can compare and confirm the total number of Paid time off.',\n title: 'Timesheet document',\n type: ['string', 'null'],\n 'x-jsf-presentation': {\n inputType: 'file',\n accept: '.pdf',\n },\n },\n },\n required: ['agrees_to_pto_amount'],\n type: 'object',\n 'x-jsf-order': [\n 'agrees_to_pto_amount',\n 'agrees_to_pto_amount_notes',\n 'timesheet_file',\n ],\n },\n },\n};\n"],"mappings":"AAAO,IAAMA,EAAoB,CAC/B,KAAM,CACJ,QAAS,EACT,OAAQ,CACN,qBAAsB,GACtB,MAAO,CACL,CACE,GAAI,CACF,WAAY,CACV,qBAAsB,CACpB,MAAO,IACT,CACF,EACA,SAAU,CAAC,sBAAsB,CACnC,EACA,KAAM,CACJ,WAAY,CACV,2BAA4B,CAC1B,KAAM,QACR,CACF,EACA,SAAU,CAAC,4BAA4B,CACzC,EACA,KAAM,CACJ,WAAY,CACV,2BAA4B,GAC5B,eAAgB,EAClB,CACF,CACF,CACF,EACA,WAAY,CACV,qBAAsB,CACpB,YAAa,GACb,MAAO,CACL,CACE,MAAO,MACP,YAAa,GACb,MAAO,KACT,EACA,CACE,MAAO,KACP,YAAa,GACb,MAAO,IACT,CACF,EACA,MAAO,2CACP,KAAM,SACN,qBAAsB,CACpB,UAAW,SACX,UAAW,OACb,CACF,EACA,2BAA4B,CAC1B,YACE,sIACF,UAAW,IACX,MAAO,2BACP,KAAM,CAAC,SAAU,MAAM,EACvB,qBAAsB,CACpB,UAAW,UACb,CACF,EACA,eAAgB,CACd,YACE,4HACF,MAAO,qBACP,KAAM,CAAC,SAAU,MAAM,EACvB,qBAAsB,CACpB,UAAW,OACX,OAAQ,MACV,CACF,CACF,EACA,SAAU,CAAC,sBAAsB,EACjC,KAAM,SACN,cAAe,CACb,uBACA,6BACA,gBACF,CACF,CACF,CACF","names":["paidTimeOffSchema"]}
@@ -0,0 +1,2 @@
1
+ var e={data:{version:7,schema:{additionalProperties:!1,allOf:[],properties:{},required:[],type:"object","x-jsf-order":[]}}};export{e as a};
2
+ //# sourceMappingURL=chunk-XFD3ULUF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/Termination/json-schemas/defaultSchema.ts"],"sourcesContent":["export const defaultSchema = {\n data: {\n version: 7,\n schema: {\n additionalProperties: false,\n allOf: [],\n properties: {},\n required: [],\n type: 'object',\n 'x-jsf-order': [],\n },\n },\n};\n"],"mappings":"AAAO,IAAMA,EAAgB,CAC3B,KAAM,CACJ,QAAS,EACT,OAAQ,CACN,qBAAsB,GACtB,MAAO,CAAC,EACR,WAAY,CAAC,EACb,SAAU,CAAC,EACX,KAAM,SACN,cAAe,CAAC,CAClB,CACF,CACF","names":["defaultSchema"]}
@@ -0,0 +1,2 @@
1
+ import{b as i}from"./chunk-OLJ2S6A6.js";import{a as e}from"./chunk-AYFHWLQZ.js";import{a as l}from"./chunk-N5AQSLAU.js";import{a as r}from"./chunk-AYDF3IFZ.js";import t from"react";function S({onSubmit:u,onError:C,onSuccess:c}){let{form:a,formId:n,costCalculatorBag:s}=i(),d=r(async m=>{let o=await s?.onSubmit(m);await u?.(m),o?.error?C?.(o.error):o?.data&&c?.(o?.data)},"handleSubmit");return t.createElement(l,{...a},t.createElement("form",{id:n,onSubmit:a.handleSubmit(d),className:"space-y-4 RemoteFlows__CostCalculatorForm"},t.createElement(e,{fields:s?.fields??[]})))}r(S,"CostCalculatorForm");export{S as a};
2
+ //# sourceMappingURL=chunk-XULIEA44.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/flows/CostCalculator/CostCalculatorForm.tsx"],"sourcesContent":["import { CostCalculatorEstimateResponse } from '@/src/client';\nimport { JSONSchemaFormFields } from '@/src/components/form/JSONSchemaForm';\nimport { Form } from '@/src/components/ui/form';\nimport { useCostCalculatorContext } from '@/src/flows/CostCalculator/context';\nimport { EstimationError } from '@/src/flows/CostCalculator/hooks';\nimport { CostCalculatorEstimationFormValues } from '@/src/flows/CostCalculator/types';\nimport React from 'react';\n\ntype CostCalculatorFormProps = Partial<{\n /**\n * Callback function that handles form submission. When form is submit, the form values are sent to the consumer app before behind submitted to Remote.\n * @param data - The payload sent to the /cost-calculator/estimation endpoint.\n */\n onSubmit: (data: CostCalculatorEstimationFormValues) => Promise<void> | void;\n /**\n * Callback function to handle the success when the estimation succeeds. The CostCalculatorEstimateResponse is sent back to you.\n * @param data - The response data from the /cost-calculator/estimation endpoint.\n */\n onSuccess: (data: CostCalculatorEstimateResponse) => Promise<void> | void;\n /**\n * Callback function to handle the error when the estimation fails.\n * @param error - The error object.\n */\n onError: (error: EstimationError) => void;\n}>;\n\nexport function CostCalculatorForm({\n onSubmit,\n onError,\n onSuccess,\n}: CostCalculatorFormProps) {\n const { form, formId, costCalculatorBag } = useCostCalculatorContext();\n\n const handleSubmit = async (values: CostCalculatorEstimationFormValues) => {\n const costCalculatorResults = await costCalculatorBag?.onSubmit(values);\n\n await onSubmit?.(values);\n\n if (costCalculatorResults?.error) {\n onError?.(costCalculatorResults.error);\n } else {\n if (costCalculatorResults?.data) {\n onSuccess?.(costCalculatorResults?.data);\n }\n }\n };\n\n return (\n <Form {...form}>\n <form\n id={formId}\n onSubmit={form.handleSubmit(handleSubmit)}\n className=\"space-y-4 RemoteFlows__CostCalculatorForm\"\n >\n <JSONSchemaFormFields fields={costCalculatorBag?.fields ?? []} />\n </form>\n </Form>\n );\n}\n"],"mappings":"+HAMA,OAAOA,MAAW,QAoBX,SAASC,EAAmB,CACjC,SAAAC,EACA,QAAAC,EACA,UAAAC,CACF,EAA4B,CAC1B,GAAM,CAAE,KAAAC,EAAM,OAAAC,EAAQ,kBAAAC,CAAkB,EAAIC,EAAyB,EAE/DC,EAAeC,EAAA,MAAOC,GAA+C,CACzE,IAAMC,EAAwB,MAAML,GAAmB,SAASI,CAAM,EAEtE,MAAMT,IAAWS,CAAM,EAEnBC,GAAuB,MACzBT,IAAUS,EAAsB,KAAK,EAEjCA,GAAuB,MACzBR,IAAYQ,GAAuB,IAAI,CAG7C,EAZqB,gBAcrB,OACEC,EAAA,cAACC,EAAA,CAAM,GAAGT,GACRQ,EAAA,cAAC,QACC,GAAIP,EACJ,SAAUD,EAAK,aAAaI,CAAY,EACxC,UAAU,6CAEVI,EAAA,cAACE,EAAA,CAAqB,OAAQR,GAAmB,QAAU,CAAC,EAAG,CACjE,CACF,CAEJ,CAhCgBG,EAAAT,EAAA","names":["React","CostCalculatorForm","onSubmit","onError","onSuccess","form","formId","costCalculatorBag","useCostCalculatorContext","handleSubmit","__name","values","costCalculatorResults","React","Form","JSONSchemaFormFields"]}
1
+ {"version":3,"sources":["../src/flows/CostCalculator/CostCalculatorForm.tsx"],"sourcesContent":["import { CostCalculatorEstimateResponse } from '@/src/client';\nimport { JSONSchemaFormFields } from '@/src/components/form/JSONSchemaForm';\nimport { Form } from '@/src/components/ui/form';\nimport { useCostCalculatorContext } from '@/src/flows/CostCalculator/context';\nimport { EstimationError } from '@/src/flows/CostCalculator/hooks';\nimport { CostCalculatorEstimationFormValues } from '@/src/flows/CostCalculator/types';\nimport React from 'react';\n\ntype CostCalculatorFormProps = Partial<{\n /**\n * Callback function that handles form submission. When form is submit, the form values are sent to the consumer app before behind submitted to Remote.\n * @param data - The payload sent to the /cost-calculator/estimation endpoint.\n */\n onSubmit: (data: CostCalculatorEstimationFormValues) => Promise<void> | void;\n /**\n * Callback function to handle the success when the estimation succeeds. The CostCalculatorEstimateResponse is sent back to you.\n * @param data - The response data from the /cost-calculator/estimation endpoint.\n */\n onSuccess: (data: CostCalculatorEstimateResponse) => Promise<void> | void;\n /**\n * Callback function to handle the error when the estimation fails.\n * @param error - The error object.\n */\n onError: (error: EstimationError) => void;\n}>;\n\nexport function CostCalculatorForm({\n onSubmit,\n onError,\n onSuccess,\n}: CostCalculatorFormProps) {\n const { form, formId, costCalculatorBag } = useCostCalculatorContext();\n\n const handleSubmit = async (values: CostCalculatorEstimationFormValues) => {\n const costCalculatorResults = await costCalculatorBag?.onSubmit(values);\n\n await onSubmit?.(values);\n\n if (costCalculatorResults?.error) {\n onError?.(costCalculatorResults.error);\n } else {\n if (costCalculatorResults?.data) {\n onSuccess?.(costCalculatorResults?.data);\n }\n }\n };\n\n return (\n <Form {...form}>\n <form\n id={formId}\n onSubmit={form.handleSubmit(handleSubmit)}\n className=\"space-y-4 RemoteFlows__CostCalculatorForm\"\n >\n <JSONSchemaFormFields fields={costCalculatorBag?.fields ?? []} />\n </form>\n </Form>\n );\n}\n"],"mappings":"gKAMA,OAAOA,MAAW,QAoBX,SAASC,EAAmB,CACjC,SAAAC,EACA,QAAAC,EACA,UAAAC,CACF,EAA4B,CAC1B,GAAM,CAAE,KAAAC,EAAM,OAAAC,EAAQ,kBAAAC,CAAkB,EAAIC,EAAyB,EAE/DC,EAAeC,EAAA,MAAOC,GAA+C,CACzE,IAAMC,EAAwB,MAAML,GAAmB,SAASI,CAAM,EAEtE,MAAMT,IAAWS,CAAM,EAEnBC,GAAuB,MACzBT,IAAUS,EAAsB,KAAK,EAEjCA,GAAuB,MACzBR,IAAYQ,GAAuB,IAAI,CAG7C,EAZqB,gBAcrB,OACEC,EAAA,cAACC,EAAA,CAAM,GAAGT,GACRQ,EAAA,cAAC,QACC,GAAIP,EACJ,SAAUD,EAAK,aAAaI,CAAY,EACxC,UAAU,6CAEVI,EAAA,cAACE,EAAA,CAAqB,OAAQR,GAAmB,QAAU,CAAC,EAAG,CACjE,CACF,CAEJ,CAhCgBG,EAAAT,EAAA","names":["React","CostCalculatorForm","onSubmit","onError","onSuccess","form","formId","costCalculatorBag","useCostCalculatorContext","handleSubmit","__name","values","costCalculatorResults","React","Form","JSONSchemaFormFields"]}
@@ -1,2 +1,2 @@
1
- import{a as P}from"./chunk-YVC4OEFJ.js";import{a as y,b as v,c as h,d as _,e as w}from"./chunk-XEQTLVMV.js";import{a as k}from"./chunk-DOA6BAUQ.js";import{a as x}from"./chunk-J2RINDSC.js";import{a as T}from"./chunk-4F7PYKUZ.js";import{a as n}from"./chunk-SJ56GVNV.js";import{a as s}from"./chunk-AYDF3IFZ.js";import{Euro as H}from"lucide-react";import t,{lazy as G,useState as A}from"react";import*as N from"react";import{Slot as z}from"@radix-ui/react-slot";import{cva as F}from"class-variance-authority";var E=F("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-badge text-badge-foreground rounded-full [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground rounded-full [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white rounded-full [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40",outline:"text-foreground rounded-full [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function B({className:a,variant:o,asChild:r=!1,...u}){return N.createElement(r?z:"span",{"data-slot":"badge",className:n(E({variant:o}),a),...u})}s(B,"Badge");import*as m from"react";import*as i from"@radix-ui/react-tabs";function S({className:a,...o}){return m.createElement(i.Root,{"data-slot":"tabs",className:n("flex flex-col gap-2",a),...o})}s(S,"Tabs");function V({className:a,...o}){return m.createElement(i.List,{"data-slot":"tabs-list",className:n("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-1",a),...o})}s(V,"TabsList");function b({className:a,...o}){return m.createElement(i.Trigger,{"data-slot":"tabs-trigger",className:n("data-[state=active]:bg-background data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring inline-flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",a),...o})}s(b,"TabsTrigger");var M=G(()=>import("./flows/CostCalculator/Results/CostCalculatorResultsChart.js"));function st({employmentData:a,options:o}){let[r,u]=A("monthly"),l=a.employments?.[0];if(!l)return null;let e=l.employer_currency_costs,c=e.currency.symbol,f=r==="monthly"?e.monthly_gross_salary:e.annual_gross_salary,p=r==="monthly"?e.monthly_benefits_total:e.annual_benefits_total,g=r==="monthly"?e.monthly_contributions_total:e.annual_contributions_total,D=r==="monthly"?e.monthly_total:e.annual_total,d=r==="monthly"?e.monthly_benefits_breakdown:e.annual_benefits_breakdown,L=r==="monthly"?e.monthly_contributions_breakdown:e.annual_contributions_breakdown,C=[{name:"Gross Salary",value:f,color:o?.chartColors?.grossSalary??"#3b82f6"},{name:"Contributions",value:g,color:o?.chartColors?.contributions??"#f59e0b"}];return d&&C.push({name:"Benefits",value:p??0,color:o?.chartColors?.benefits??"#10b981"}),t.createElement(t.Fragment,null,t.createElement("div",{className:"flex flex-col md:flex-row gap-4 md:items-center justify-between mb-6 RemoteFlows__CostCalculatorResults"},t.createElement("div",{className:"RemoteFlows__CostCalculatorResults__Header"},t.createElement("h2",{className:"text-xl font-semibold flex items-center gap-2"},t.createElement("span",{className:"flex items-center gap-1"},t.createElement(H,{className:"h-5 w-5 text-gray-600"}),o?.title??"Cost Calculator"),t.createElement(B,{className:"ml-2"},l.country.name)),t.createElement("p",{className:"text-primary-foreground font-medium mt-1"},o?.description??`Total cost of employment in ${l.country.name}`)),t.createElement(S,{value:r,onValueChange:j=>u(j),className:"w-full md:w-auto RemoteFlows__CostCalculatorResults__Tabs"},t.createElement(V,{className:"grid w-full md:w-[200px] grid-cols-2"},t.createElement(b,{value:"monthly"},"Monthly"),t.createElement(b,{value:"annual"},"Annual")))),t.createElement("div",{className:n("grid grid-cols-1 gap-6",o?.showChart?"md:grid-cols-3":"","RemoteFlows__CostCalculatorResults_CostBreakdown")},t.createElement(y,{className:"md:col-span-2 rounded-lg"},t.createElement(v,{className:"pb-2"},t.createElement(h,null,"Cost Breakdown"),t.createElement(_,null,"Detailed breakdown of all employer costs")),t.createElement(w,null,t.createElement("div",{className:"space-y-6"},t.createElement(P,{grossSalary:f,currency:c}),d?t.createElement(x,{benefitsBreakdown:d,benefitsTotal:p,currency:c}):null,t.createElement(T,{contributionsBreakdown:L,contributionsTotal:g,currency:c}),t.createElement(k,{totalCost:D,currency:c})))),o?.showChart&&t.createElement(M,{chartData:C,currency:c})))}s(st,"CostCalculatorResults");export{st as a};
2
- //# sourceMappingURL=chunk-VV7RML2Q.js.map
1
+ import{a as y,b as v,c as h,d as _,e as w}from"./chunk-XEQTLVMV.js";import{a as k}from"./chunk-DOA6BAUQ.js";import{a as x}from"./chunk-J2RINDSC.js";import{a as T}from"./chunk-4F7PYKUZ.js";import{a as P}from"./chunk-YVC4OEFJ.js";import{a as n}from"./chunk-SJ56GVNV.js";import{a as s}from"./chunk-AYDF3IFZ.js";import{Euro as H}from"lucide-react";import t,{lazy as G,useState as A}from"react";import*as N from"react";import{Slot as z}from"@radix-ui/react-slot";import{cva as F}from"class-variance-authority";var E=F("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-badge text-badge-foreground rounded-full [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground rounded-full [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white rounded-full [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40",outline:"text-foreground rounded-full [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function B({className:a,variant:o,asChild:r=!1,...u}){return N.createElement(r?z:"span",{"data-slot":"badge",className:n(E({variant:o}),a),...u})}s(B,"Badge");import*as m from"react";import*as i from"@radix-ui/react-tabs";function S({className:a,...o}){return m.createElement(i.Root,{"data-slot":"tabs",className:n("flex flex-col gap-2",a),...o})}s(S,"Tabs");function V({className:a,...o}){return m.createElement(i.List,{"data-slot":"tabs-list",className:n("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-1",a),...o})}s(V,"TabsList");function b({className:a,...o}){return m.createElement(i.Trigger,{"data-slot":"tabs-trigger",className:n("data-[state=active]:bg-background data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring inline-flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",a),...o})}s(b,"TabsTrigger");var M=G(()=>import("./flows/CostCalculator/Results/CostCalculatorResultsChart.js"));function st({employmentData:a,options:o}){let[r,u]=A("monthly"),l=a.employments?.[0];if(!l)return null;let e=l.employer_currency_costs,c=e.currency.symbol,f=r==="monthly"?e.monthly_gross_salary:e.annual_gross_salary,p=r==="monthly"?e.monthly_benefits_total:e.annual_benefits_total,g=r==="monthly"?e.monthly_contributions_total:e.annual_contributions_total,D=r==="monthly"?e.monthly_total:e.annual_total,d=r==="monthly"?e.monthly_benefits_breakdown:e.annual_benefits_breakdown,L=r==="monthly"?e.monthly_contributions_breakdown:e.annual_contributions_breakdown,C=[{name:"Gross Salary",value:f,color:o?.chartColors?.grossSalary??"#3b82f6"},{name:"Contributions",value:g,color:o?.chartColors?.contributions??"#f59e0b"}];return d&&C.push({name:"Benefits",value:p??0,color:o?.chartColors?.benefits??"#10b981"}),t.createElement(t.Fragment,null,t.createElement("div",{className:"flex flex-col md:flex-row gap-4 md:items-center justify-between mb-6 RemoteFlows__CostCalculatorResults"},t.createElement("div",{className:"RemoteFlows__CostCalculatorResults__Header"},t.createElement("h2",{className:"text-xl font-semibold flex items-center gap-2"},t.createElement("span",{className:"flex items-center gap-1"},t.createElement(H,{className:"h-5 w-5 text-gray-600"}),o?.title??"Cost Calculator"),t.createElement(B,{className:"ml-2"},l.country.name)),t.createElement("p",{className:"text-primary-foreground font-medium mt-1"},o?.description??`Total cost of employment in ${l.country.name}`)),t.createElement(S,{value:r,onValueChange:j=>u(j),className:"w-full md:w-auto RemoteFlows__CostCalculatorResults__Tabs"},t.createElement(V,{className:"grid w-full md:w-[200px] grid-cols-2"},t.createElement(b,{value:"monthly"},"Monthly"),t.createElement(b,{value:"annual"},"Annual")))),t.createElement("div",{className:n("grid grid-cols-1 gap-6",o?.showChart?"md:grid-cols-3":"","RemoteFlows__CostCalculatorResults_CostBreakdown")},t.createElement(y,{className:"md:col-span-2 rounded-lg"},t.createElement(v,{className:"pb-2"},t.createElement(h,null,"Cost Breakdown"),t.createElement(_,null,"Detailed breakdown of all employer costs")),t.createElement(w,null,t.createElement("div",{className:"space-y-6"},t.createElement(P,{grossSalary:f,currency:c}),d?t.createElement(x,{benefitsBreakdown:d,benefitsTotal:p,currency:c}):null,t.createElement(T,{contributionsBreakdown:L,contributionsTotal:g,currency:c}),t.createElement(k,{totalCost:D,currency:c})))),o?.showChart&&t.createElement(M,{chartData:C,currency:c})))}s(st,"CostCalculatorResults");export{st as a};
2
+ //# sourceMappingURL=chunk-YAHWFLDH.js.map
@@ -0,0 +1,2 @@
1
+ import{a as i}from"./chunk-AYDF3IFZ.js";import A from"lodash/get";var R={TEXT:"text",TEXTAREA:"textarea",NUMBER:"number",SELECT:"select",COUNTRIES:"countries",TEL:"tel",EMAIL:"email",MONEY:"money",DATE:"date",DATE_RANGE:"date-range",CURRENCIES:"currencies",TIME:"time"},V={CHECKBOX:"checkbox",ACK_CHECK:"ack-check"},u={FILE:"file",RADIO:"radio",RADIO_CARD:"radio-card",GROUP_ARRAY:"group-array",EXTRA:"extra",STATEMENT:"statement",HIDDEN:"hidden",FIELDSET:"fieldset",FIELDSET_FLAT:"fieldset-flat",WORK_SCHEDULE:"work-schedule",WORK_WEEK_SCHEDULE:"work-week-schedule",BENEFITS:"benefits",SIGNATURE:"signature",SELECT_MULTIPLE:"select-multiple",...R,...V};function g(e){return Math.round((e+Number.EPSILON)*100)/100}i(g,"round");function T(e){return parseFloat(e.replace(/,/g,""))}i(T,"convertToValidCost");function I(e){if(e==null||e===""||Number.isNaN(e)||Array.isArray(e)||typeof e=="boolean")return null;let n;return typeof e=="string"?n=T(e):n=e,g(n*100)}i(I,"convertToCents");function O(e){if(e==null||Number.isNaN(e))return null;let n;return typeof e=="string"?n=T(e||"0"):n=e,g(n/100)}i(O,"convertFromCents");var m=i(e=>Object.entries(e||{}).reduce((n,[s,t])=>(Array.isArray(t)?n[s]=t.map(r=>typeof r=="object"&&r!==null?m(r):typeof r=="string"?r.trim():r):typeof t=="object"&&t!==null?n[s]=m(t):n[s]=typeof t=="string"?t.trim():t,n),{}),"trimStringValues");function p(e){let n={};return Object.entries(e).forEach(([s,t])=>{Array.isArray(t)?n[s]=t.map(r=>typeof r=="object"&&r!==null?p(r):r===""?null:r):typeof t=="object"&&t!==null?n[s]=p(t):n[s]=t===""?null:t}),n}i(p,"convertEmptyStringsToNull");function d(e,n){let s={};return n.forEach(t=>{let r=t.name;if(!(!Object.prototype.hasOwnProperty.call(e,r)&&!(t.type===u.FIELDSET&&t.valueGroupingDisabled))){if(t.type===u.FIELDSET&&t.valueGroupingDisabled){Object.assign(s,d(e,t.fields));return}t.readOnly&&t.defaultValue?s[r]=t.defaultValue:s[r]=e[r]}}),s}i(d,"prefillReadOnlyFields");function b(e,n){return e.reduce((s,t)=>(t.type===u.FIELDSET&&t.valueGroupingDisabled?Object.assign(s,b(t.fields,n)):Object.prototype.hasOwnProperty.call(n,t.name)&&(s[t.name]=n[t.name]),s),{})}i(b,"extractFieldsetFieldsValues");var E={[u.COUNTRIES]:{transformValueFromAPI:i(e=>n=>{if(!e.multiple)return n??"";let s;return typeof n=="string"?s=n.split(","):s=n||[],s.map(r=>e.countries?.find?.(a=>"name"in a&&a.name===r)||{name:r})},"transformValueFromAPI"),transformValueToAPI:i(e=>n=>!e.multiple||typeof n=="string"?n:n.map(s=>typeof s=="string"?s:s.name),"transformValueToAPI"),transformValue:i(e=>{let n=i(s=>s?.name||s?.value||s?.label,"getCountryValue");return Array.isArray(e)?e.map(n):n(e)||""},"transformValue")},[u.NUMBER]:{transformValueToAPI:i(()=>e=>{let n=Number(e);return Number.isNaN(n)?e:n},"transformValueToAPI")},[u.MONEY]:{transformValueFromAPI:i(()=>e=>O(e)??"","transformValueFromAPI"),transformValueToAPI:i(()=>I,"transformValueToAPI")},[u.RADIO]:{transformValueToAPI:i(e=>n=>e.transformToBool?n==="yes":n,"transformValueToAPI")},[u.CHECKBOX]:{transformValueToAPI:i(e=>n=>n===void 0?!1:e.const&&n===!0?e.const:n,"transformValueToAPI")},[u.SELECT]:{transformValue:i(e=>Array.isArray(e)?e.map(n=>n.value):e?.value??"","transformValue")}};function y(e={},n){return n.filter(r=>e[r.name]||r.type===u.FIELDSET&&r.valueGroupingDisabled).reduce((r,a)=>{switch(a.type){case u.FIELDSET:{let o=a;if(o.valueGroupingDisabled){let l=b(o.fields,e);Object.assign(r,y(l,o.fields))}else r[a.name]=y(e[a.name],o.fields);break}case u.TEXTAREA:case u.TEXT:{r[a.name]=e[a.name].replace(/\0/g,"");break}case u.GROUP_ARRAY:{let o=a?.fields?.().map(c=>({...c,name:c.nameKey||""})),l=e[a.name]?.map(c=>y(c,o));r[a.name]=l;break}case u.EXTRA:{let o=a;if(o.includeValueToApi!==!1){let l=e[o.name],c=o?.transformValueToAPI||E[o.type]?.transformValueToAPI;if(c){r[o.name]=c(a)(l);break}r[o.name]=l;break}r[o.name]=void 0;break}default:{let o=e[a.name],l=a?.transformValueToAPI||E[a.type]?.transformValueToAPI;if(l){r[a.name]=l(a)(o);break}r[a.name]=o;break}}return a.forcedValue!==void 0&&(r[a.name]=a.forcedValue),r},{...e})}i(y,"parseFormValuesToAPI");function D(e,n){return e.visibilityCondition?e.visibilityCondition(n):typeof e.isVisible<"u"?!!e.isVisible:!0}i(D,"isFieldVisible");function F(e,n){return e.calculateDynamicProperties?{...e,...e.calculateDynamicProperties(n)||{}}:e}i(F,"applyFieldDynamicProperties");function f(e,n,s,t){let r={};return n.map(a=>F(a,e)).forEach(a=>{let o=a.name;t&&(o=o?`${t}.${a.name}`:t);let l=A(e,o);if(!(!D(a,e)&&!(s&&l))&&!a.meta?.ignoreValue)if(a.type==="fieldset"&&a.valueGroupingDisabled)Object.assign(r,f(e,a.fields,s,o));else if(Array.isArray(a.fields))r[a.name]=f(e,a.fields,s,o);else{if(l===void 0)return;r[a.name]=l}}),r}i(f,"excludeValuesInvisible");function P(e,n,s){let t=s?.keepInvisibleValues?e:f(e,n),r=y(t,n),a=m(r),o=p(a);return d(o,n)}i(P,"parseSubmitValues");function S(e,n,s={isPartialValidation:!1}){return P(e,n,{keepInvisibleValues:s?.isPartialValidation})}i(S,"parseJSFToValidate");export{I as a,O as b,S as c};
2
+ //# sourceMappingURL=chunk-YBACB5A6.js.map